diff --git a/sflphone-client-kde/src/conf/dlgaccounts.cpp b/sflphone-client-kde/src/conf/dlgaccounts.cpp index 582dd1c4b0c75619a17bdf0f65d3ff375bcff2e9..c791df3d7ac038b9d57de82df056852d1a7feb88 100644 --- a/sflphone-client-kde/src/conf/dlgaccounts.cpp +++ b/sflphone-client-kde/src/conf/dlgaccounts.cpp @@ -119,6 +119,15 @@ DlgAccounts::DlgAccounts(KConfigDialog *parent) connect(combo_security_STRP, SIGNAL(currentIndexChanged(int)), this, SLOT(updateCombo(int))); + + connect(button_add_credential, SIGNAL(clicked()), + this, SLOT(addCredential())); + + connect(button_remove_credential, SIGNAL(clicked()), + this, SLOT(removeCredential())); + + connect(list_credential, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + this,SLOT( selectCredential(QListWidgetItem*, QListWidgetItem*))); } @@ -233,7 +242,15 @@ void DlgAccounts::saveAccount(QListWidgetItem * item) account->setAccountDetail(ACCOUNT_ZRTP_NOT_SUPP_WARNING, checkbox_ZRTP_warn_supported->isChecked()?"true":"false"); account->setAccountDetail(ACCOUNT_ZRTP_HELLO_HASH, checkbox_ZTRP_send_hello->isChecked()?"true":"false"); + account->setAccountDetail(ACCOUNT_SIP_STUN_ENABLED, checkbox_stun->isChecked()?"true":"false"); + account->setAccountDetail(ACCOUNT_SIP_STUN_SERVER, line_stun->text()); + + account->setAccountDetail(PUBLISHED_SAMEAS_LOCAL, radioButton_pa_same_as_local->isChecked()?"true":"false"); + //account->setAccountDetail(PUBLISHED_PORT, spinBox_pa_published_port->value()); //TODO fix + account->setAccountDetail(PUBLISHED_ADDRESS, lineEdit_pa_published_address ->text()); + account->setAccountDetail(LOCAL_PORT,QString::number(spinBox_pa_published_port->value())); + account->setAccountDetail(LOCAL_INTERFACE,comboBox_ni_local_address->currentText()); QStringList _codecList; foreach (QString aCodec, keditlistbox_codec->items()) { @@ -247,6 +264,8 @@ void DlgAccounts::saveAccount(QListWidgetItem * item) ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); configurationManager.setActiveCodecList(_codecList, account->getAccountDetail(ACCOUNT_ID)); qDebug() << "Account codec have been saved" << _codecList << account->getAccountDetail(ACCOUNT_ID); + + saveCredential(account->getAccountDetail(ACCOUNT_ID)); } void DlgAccounts::loadAccount(QListWidgetItem * item) @@ -304,6 +323,7 @@ void DlgAccounts::loadAccount(QListWidgetItem * item) combo_security_STRP->setCurrentIndex(account->getAccountDetail(TLS_METHOD ).toInt()); + switch (account->getAccountDetail(TLS_METHOD ).toInt()) { case 0: //KEY_EXCHANGE_NONE checkbox_SDES_fallback_rtp->setVisible(false); @@ -333,6 +353,17 @@ void DlgAccounts::loadAccount(QListWidgetItem * item) checkbox_ZRTP_display_SAS->setChecked((account->getAccountDetail(ACCOUNT_ZRTP_DISPLAY_SAS) == "true")?1:0); checkbox_ZRTP_warn_supported->setChecked((account->getAccountDetail(ACCOUNT_ZRTP_NOT_SUPP_WARNING) == "true")?1:0); checkbox_ZTRP_send_hello->setChecked((account->getAccountDetail(ACCOUNT_ZRTP_HELLO_HASH) == "true")?1:0); + + checkbox_stun->setChecked((account->getAccountDetail(ACCOUNT_SIP_STUN_ENABLED) == "true")?1:0); + line_stun->setText(account->getAccountDetail(ACCOUNT_SIP_STUN_SERVER)); + + radioButton_pa_same_as_local->setChecked((account->getAccountDetail(PUBLISHED_SAMEAS_LOCAL) == "true")?1:0); + radioButton_pa_custom->setChecked((account->getAccountDetail(PUBLISHED_SAMEAS_LOCAL) == "true")?1:0); + //spinBox_pa_published_port->setValue(account->getAccountDetail(PUBLISHED_PORT)); //TODO fix + lineEdit_pa_published_address->setText(account->getAccountDetail(PUBLISHED_ADDRESS)); + + spinBox_pa_published_port->setValue(account->getAccountDetail(LOCAL_PORT).toInt()); + //comboBox_ni_local_address->setCurentText(account->getAccountDetail(LOCAL_INTERFACE)); //TODO need to load the list first keditlistbox_codec->clear(); ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); @@ -364,6 +395,8 @@ void DlgAccounts::loadAccount(QListWidgetItem * item) updateStatusLabel(account); frame2_editAccounts->setEnabled(true); + + loadCredentails(account->getAccountDetail(ACCOUNT_ID)); } void DlgAccounts::loadAccountList() @@ -674,4 +707,64 @@ void DlgAccounts::updateCombo(int value) { checkbox_ZTRP_send_hello->setVisible(false); break; } +} + +void DlgAccounts::loadCredentails(QString accountId) { + credentialInfo.clear(); + list_credential->clear(); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + int credentialCount = configurationManager.getNumberOfCredential(accountId); + for (int i=0; i < credentialCount; i++) { + QMap<QString, QString> credentialData = configurationManager.getCredential(accountId,i); + qDebug() << "Credential: " << credentialData; + QListWidgetItem* newItem = new QListWidgetItem(); + newItem->setText(credentialData["username"]); + credentialInfo[newItem] = {newItem, credentialData["username"], credentialData["password"],credentialData["realm"]}; + list_credential->addItem(newItem); + } +} + +void DlgAccounts::saveCredential(QString accountId) { + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + configurationManager.setNumberOfCredential(accountId, list_credential->count()); + + for (int i=0; i < list_credential->count();i++) { + QListWidgetItem* currentItem = list_credential->item(i); + MapStringString credentialData; + credentialData["username"] = credentialInfo[currentItem].name; + credentialData["password"] = credentialInfo[currentItem].password; + credentialData["realm"] = credentialInfo[currentItem].realm; + configurationManager.setCredential(accountId, i,credentialData); + } +} + +void DlgAccounts::addCredential() { + QListWidgetItem* newItem = new QListWidgetItem(); + newItem->setText("New credential"); + credentialInfo[newItem] = {newItem, "New credential", "",""}; + + selectCredential(newItem,list_credential->currentItem()); + list_credential->addItem(newItem); + list_credential->setCurrentItem(newItem); +} + +void DlgAccounts::selectCredential(QListWidgetItem* item, QListWidgetItem* previous) { + if (previous) { + credentialInfo[previous].realm = edit_credential_realm->text(); + credentialInfo[previous].name = edit_credential_auth->text(); + credentialInfo[previous].password = edit_credential_password->text(); + previous->setText(edit_credential_auth->text()); + } + list_credential->setCurrentItem(item); + edit_credential_realm->setText(credentialInfo[item].realm); + edit_credential_auth->setText(credentialInfo[item].name); + edit_credential_password->setText(credentialInfo[item].password); + edit_credential_realm->setEnabled(true); + edit_credential_auth->setEnabled(true); + edit_credential_password->setEnabled(true); +} + +void DlgAccounts::removeCredential() { + qDebug() << "I am here"; + list_credential->takeItem(list_credential->currentRow()); } \ No newline at end of file diff --git a/sflphone-client-kde/src/conf/dlgaccounts.h b/sflphone-client-kde/src/conf/dlgaccounts.h index 7abfe60f99cc97cf4d1041c3424ebaf8b4b41a4b..5d836296925423d5bf8333f5b94d509164d81f43 100644 --- a/sflphone-client-kde/src/conf/dlgaccounts.h +++ b/sflphone-client-kde/src/conf/dlgaccounts.h @@ -24,6 +24,7 @@ #include <QWidget> #include <kconfigdialog.h> #include <QTableWidget> +#include <QListWidgetItem> #include "ui_dlgaccountsbase.h" #include "Account.h" @@ -32,6 +33,15 @@ typedef QHash<QString, QString> StringHash; //Needed to fix a Qt foreach macro argument parsing bug +struct CredentialData { + QListWidgetItem* pointer; + QString name; + QString password; + QString realm; +}; + +typedef QHash<QListWidgetItem*, CredentialData> QListWidgetItemHash; //Needed to fix a Qt foreach macro argument parsing bug + class Private_AddCodecDialog : public KDialog { Q_OBJECT public: @@ -102,9 +112,10 @@ public: private: AccountList * accountList; - QList< StringHash > codecList; + QList< StringHash > codecList; + QListWidgetItemHash credentialInfo; bool accountListHasChanged; - void loadCodecList(); + void loadCodecList(); public slots: void saveAccountList(); @@ -134,6 +145,11 @@ private slots: void addCodec(QString name = ""); void codecChanged(); void updateCombo(int value); + void addCredential(); + void removeCredential(); + void selectCredential(QListWidgetItem* item, QListWidgetItem* previous); + void loadCredentails(QString accountId); + void saveCredential(QString accountId); signals: diff --git a/sflphone-client-kde/src/conf/dlgaccountsbase.ui b/sflphone-client-kde/src/conf/dlgaccountsbase.ui index e2231cf501d5a9b1156931df1a54322ef0b1a45a..7da7aa130c448d7864b1c62a4784e53d15ffaf70 100644 --- a/sflphone-client-kde/src/conf/dlgaccountsbase.ui +++ b/sflphone-client-kde/src/conf/dlgaccountsbase.ui @@ -233,7 +233,7 @@ </sizepolicy> </property> <property name="currentIndex"> - <number>5</number> + <number>0</number> </property> <widget class="QWidget" name="tab_basic"> <attribute name="title"> @@ -385,34 +385,164 @@ <attribute name="title"> <string>Advanced</string> </attribute> - <layout class="QFormLayout" name="formLayout_2"> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::ExpandingFieldsGrow</enum> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="label_regExpire"> - <property name="text"> - <string>Registration expire</string> - </property> - <property name="buddy"> - <cstring>spinbox_regExpire</cstring> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Resgistration</string> </property> + <layout class="QGridLayout" name="gridLayout_8"> + <item row="0" column="0"> + <widget class="QLabel" name="label_regExpire"> + <property name="text"> + <string>Registration expire</string> + </property> + <property name="buddy"> + <cstring>spinbox_regExpire</cstring> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="KIntSpinBox" name="spinbox_regExpire"> + <property name="maximum"> + <number>16777215</number> + </property> + </widget> + </item> + <item row="1" column="0" colspan="2"> + <widget class="QCheckBox" name="checkBox_conformRFC"> + <property name="text"> + <string>Conform to RFC 3263</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <spacer name="horizontalSpacer_7"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> </widget> </item> - <item row="0" column="1"> - <widget class="KIntSpinBox" name="spinbox_regExpire"> - <property name="maximum"> - <number>16777215</number> + <item> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Network Interface</string> </property> + <layout class="QGridLayout" name="gridLayout_9"> + <item row="0" column="0"> + <widget class="QLabel" name="label_ni_local_address"> + <property name="text"> + <string>Local address</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="comboBox_ni_local_address"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_ni_local_port"> + <property name="text"> + <string>Local port</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QSpinBox" name="spinBox_ni_local_port"/> + </item> + <item row="0" column="2"> + <spacer name="horizontalSpacer_8"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> </widget> </item> - <item row="3" column="0" colspan="2"> - <widget class="QCheckBox" name="checkBox_conformRFC"> - <property name="text"> - <string>Conform to RFC 3263</string> + <item> + <widget class="QGroupBox" name="groupBox_3"> + <property name="title"> + <string>Published address</string> </property> + <layout class="QGridLayout" name="gridLayout_10"> + <item row="0" column="0" colspan="3"> + <widget class="QRadioButton" name="radioButton_pa_same_as_local"> + <property name="text"> + <string>Same as local parameters</string> + </property> + </widget> + </item> + <item row="1" column="0" rowspan="2" colspan="3"> + <widget class="QRadioButton" name="radioButton_pa_custom"> + <property name="text"> + <string>Set published address and port</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_published_address"> + <property name="text"> + <string>Published address</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_pa_published_port"> + <property name="text"> + <string>Published port</string> + </property> + </widget> + </item> + <item row="4" column="1" colspan="2"> + <widget class="QSpinBox" name="spinBox_pa_published_port"/> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="lineEdit_pa_published_address"/> + </item> + <item row="3" column="3"> + <spacer name="horizontalSpacer_9"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> </widget> </item> + <item> + <spacer name="verticalSpacer_3"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>138</height> + </size> + </property> + </spacer> + </item> </layout> </widget> <widget class="QWidget" name="tab_stun"> @@ -593,13 +723,25 @@ </widget> </item> <item row="0" column="1"> - <widget class="KLineEdit" name="edit_credential_realm"/> + <widget class="KLineEdit" name="edit_credential_realm"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> </item> <item row="1" column="1"> - <widget class="KLineEdit" name="edit_credential_auth"/> + <widget class="KLineEdit" name="edit_credential_auth"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> </item> <item row="2" column="1"> - <widget class="KLineEdit" name="edit_credential_password"/> + <widget class="KLineEdit" name="edit_credential_password"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> </item> </layout> </widget>