diff --git a/sflphone-client-kde/src/sflphone_kdeview.cpp b/sflphone-client-kde/src/sflphone_kdeview.cpp index 3049235f1a1c6ee6c872963a1614be2b2bedd420..b40fde0d20be6596ed34ec38ea203530a8666dee 100644 --- a/sflphone-client-kde/src/sflphone_kdeview.cpp +++ b/sflphone-client-kde/src/sflphone_kdeview.cpp @@ -107,6 +107,8 @@ sflphone_kdeView::sflphone_kdeView(QWidget *parent) connect(accountList, SIGNAL(accountListUpdated()), this, SLOT(updateStatusMessage())); + connect(accountList, SIGNAL(accountListUpdated()), + this, SLOT(updateWindowCallState())); accountList->updateAccounts(); @@ -163,6 +165,19 @@ Account * sflphone_kdeView::firstRegisteredAccount() } } +QString sflphone_kdeView::firstRegisteredAccountId() +{ + Account * firstRegistered = firstRegisteredAccount(); + if(firstRegistered == NULL) + { + return QString(); + } + else + { + return firstRegistered->getAccountId(); + } +} + AccountList * sflphone_kdeView::getAccountList() { return accountList; @@ -463,7 +478,7 @@ void sflphone_kdeView::updateWindowCallState() item = listWidget_callList->currentItem(); if (!item) { - qDebug() << "No item selected. Updating window."; + qDebug() << "No item selected."; enabledActions[1] = false; enabledActions[2] = false; enabledActions[3] = false; @@ -479,57 +494,57 @@ void sflphone_kdeView::updateWindowCallState() switch (state) { case CALL_STATE_INCOMING: - qDebug() << "Reached CALL_STATE_INCOMING with call " << (*callList)[item]->getCallId() << ". Updating window."; + qDebug() << "Reached CALL_STATE_INCOMING with call " << (*callList)[item]->getCallId(); buttonIconFiles[0] = ICON_ACCEPT; buttonIconFiles[1] = ICON_REFUSE; actionTexts[0] = ACTION_LABEL_ACCEPT; actionTexts[0] = ACTION_LABEL_REFUSE; break; case CALL_STATE_RINGING: - qDebug() << "Reached CALL_STATE_RINGING with call " << (*callList)[item]->getCallId() << ". Updating window."; + qDebug() << "Reached CALL_STATE_RINGING with call " << (*callList)[item]->getCallId(); enabledActions[2] = false; enabledActions[3] = false; break; case CALL_STATE_CURRENT: qDebug() << "details = " << CallManagerInterfaceSingleton::getInstance().getCallDetails(call->getCallId()).value(); - qDebug() << "Reached CALL_STATE_CURRENT with call " << (*callList)[item]->getCallId() << ". Updating window."; + qDebug() << "Reached CALL_STATE_CURRENT with call " << (*callList)[item]->getCallId(); recordEnabled = true; break; case CALL_STATE_DIALING: - qDebug() << "Reached CALL_STATE_DIALING with call " << (*callList)[item]->getCallId() << ". Updating window."; + qDebug() << "Reached CALL_STATE_DIALING with call " << (*callList)[item]->getCallId(); enabledActions[2] = false; enabledActions[3] = false; enabledActions[4] = false; buttonIconFiles[0] = ICON_ACCEPT; break; case CALL_STATE_HOLD: - qDebug() << "Reached CALL_STATE_HOLD with call " << (*callList)[item]->getCallId() << ". Updating window."; + qDebug() << "Reached CALL_STATE_HOLD with call " << (*callList)[item]->getCallId(); buttonIconFiles[2] = ICON_UNHOLD; actionTexts[2] = ACTION_LABEL_UNHOLD; break; case CALL_STATE_FAILURE: - qDebug() << "Reached CALL_STATE_FAILURE with call " << (*callList)[item]->getCallId() << ". Updating window."; + qDebug() << "Reached CALL_STATE_FAILURE with call " << (*callList)[item]->getCallId(); enabledActions[0] = false; enabledActions[2] = false; enabledActions[3] = false; enabledActions[4] = false; break; case CALL_STATE_BUSY: - qDebug() << "Reached CALL_STATE_BUSY with call " << (*callList)[item]->getCallId() << ". Updating window."; + qDebug() << "Reached CALL_STATE_BUSY with call " << (*callList)[item]->getCallId(); enabledActions[0] = false; enabledActions[2] = false; enabledActions[3] = false; enabledActions[4] = false; break; case CALL_STATE_TRANSFER: - qDebug() << "Reached CALL_STATE_TRANSFER with call " << (*callList)[item]->getCallId() << ". Updating window."; + qDebug() << "Reached CALL_STATE_TRANSFER with call " << (*callList)[item]->getCallId(); buttonIconFiles[0] = ICON_EXEC_TRANSF; actionTexts[3] = ACTION_LABEL_GIVE_UP_TRANSF; transfer = true; recordEnabled = true; break; case CALL_STATE_TRANSF_HOLD: - qDebug() << "Reached CALL_STATE_TRANSF_HOLD with call " << (*callList)[item]->getCallId() << ". Updating window."; + qDebug() << "Reached CALL_STATE_TRANSF_HOLD with call " << (*callList)[item]->getCallId(); buttonIconFiles[0] = ICON_EXEC_TRANSF; buttonIconFiles[2] = ICON_UNHOLD; actionTexts[3] = ACTION_LABEL_GIVE_UP_TRANSF; @@ -553,10 +568,10 @@ void sflphone_kdeView::updateWindowCallState() item = listWidget_callHistory->currentItem(); buttonIconFiles[0] = ICON_ACCEPT; actionTexts[0] = ACTION_LABEL_CALL_BACK; - actionTexts[1] = ACTION_LABEL_GIVE_UP_SEARCH; +// actionTexts[1] = ACTION_LABEL_GIVE_UP_SEARCH; if (!item) { - qDebug() << "No item selected. Updating window."; + qDebug() << "No item selected."; enabledActions[0] = false; enabledActions[1] = false; enabledActions[2] = false; @@ -570,19 +585,19 @@ void sflphone_kdeView::updateWindowCallState() enabledActions[3] = false; enabledActions[4] = false; } - if(!lineEdit_searchHistory->text().isEmpty()) - { - enabledActions[1] = true; - } +// if(!lineEdit_searchHistory->text().isEmpty()) +// { +// enabledActions[1] = true; +// } } if(stackedWidget_screen->currentWidget() == page_addressBook) { item = listWidget_addressBook->currentItem(); buttonIconFiles[0] = ICON_ACCEPT; - actionTexts[1] = ACTION_LABEL_GIVE_UP_SEARCH; +// actionTexts[1] = ACTION_LABEL_GIVE_UP_SEARCH; if (!item) { - qDebug() << "No item selected. Updating window."; + qDebug() << "No item selected."; enabledActions[0] = false; enabledActions[1] = false; enabledActions[2] = false; @@ -596,12 +611,14 @@ void sflphone_kdeView::updateWindowCallState() enabledActions[3] = false; enabledActions[4] = false; } - if(!lineEdit_addressBook->text().isEmpty()) - { - enabledActions[1] = true; - } +// if(!lineEdit_addressBook->text().isEmpty()) +// { +// enabledActions[1] = true; +// } } + qDebug() << "Updating Window."; + action_accept->setEnabled(enabledActions[0]); action_refuse->setEnabled(enabledActions[1]); action_hold->setEnabled(enabledActions[2]); @@ -622,6 +639,8 @@ void sflphone_kdeView::updateWindowCallState() action_transfer->setChecked(transfer); action_record->setChecked(recordActivated); + + qDebug() << "Window updated."; } void sflphone_kdeView::updateSearchHistory() @@ -1337,7 +1356,6 @@ void sflphone_kdeView::on_action_addressBook_triggered(bool checked) void sflphone_kdeView::on_action_mailBox_triggered() { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); Account * account = firstRegisteredAccount(); QString mailBoxNumber = account->getAccountDetail(ACCOUNT_MAILBOX); Call * call = callList->addDialingCall(); diff --git a/sflphone-client-kde/src/sflphone_kdeview.h b/sflphone-client-kde/src/sflphone_kdeview.h index 41bdde02f89c710300c73f5ce30f2117da0db658..ddcc22354e92b93caa56d47de0e49692d7575240 100644 --- a/sflphone-client-kde/src/sflphone_kdeview.h +++ b/sflphone-client-kde/src/sflphone_kdeview.h @@ -97,6 +97,15 @@ public: * @return the account to use if an outgoing call is placed. */ static Account * firstRegisteredAccount(); + /** + * Seeks the ID of the account to use. + * If priorAccountId is defined and the corresponding + * account exists and is registered, uses this one, else, + * asks the first registered of accountList. + * If there is no account registered, returns an empty string. + * @return the ID of the account to use if an outgoing call is placed. + */ + static QString firstRegisteredAccountId(); static AccountList * getAccountList(); QErrorMessage * getErrorWindow();