Skip to content
Snippets Groups Projects
Commit 5c05eab8 authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee
Browse files

Add all missing account settings, but 3 still fail to save corectly

parent d16503d9
No related branches found
No related tags found
No related merge requests found
...@@ -120,6 +120,15 @@ DlgAccounts::DlgAccounts(KConfigDialog *parent) ...@@ -120,6 +120,15 @@ DlgAccounts::DlgAccounts(KConfigDialog *parent)
connect(combo_security_STRP, SIGNAL(currentIndexChanged(int)), connect(combo_security_STRP, SIGNAL(currentIndexChanged(int)),
this, SLOT(updateCombo(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*)));
} }
void DlgAccounts::saveAccountList() void DlgAccounts::saveAccountList()
...@@ -233,7 +242,15 @@ void DlgAccounts::saveAccount(QListWidgetItem * item) ...@@ -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_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_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; QStringList _codecList;
foreach (QString aCodec, keditlistbox_codec->items()) { foreach (QString aCodec, keditlistbox_codec->items()) {
...@@ -247,6 +264,8 @@ void DlgAccounts::saveAccount(QListWidgetItem * item) ...@@ -247,6 +264,8 @@ void DlgAccounts::saveAccount(QListWidgetItem * item)
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
configurationManager.setActiveCodecList(_codecList, account->getAccountDetail(ACCOUNT_ID)); configurationManager.setActiveCodecList(_codecList, account->getAccountDetail(ACCOUNT_ID));
qDebug() << "Account codec have been saved" << _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) void DlgAccounts::loadAccount(QListWidgetItem * item)
...@@ -304,6 +323,7 @@ void DlgAccounts::loadAccount(QListWidgetItem * item) ...@@ -304,6 +323,7 @@ void DlgAccounts::loadAccount(QListWidgetItem * item)
combo_security_STRP->setCurrentIndex(account->getAccountDetail(TLS_METHOD ).toInt()); combo_security_STRP->setCurrentIndex(account->getAccountDetail(TLS_METHOD ).toInt());
switch (account->getAccountDetail(TLS_METHOD ).toInt()) { switch (account->getAccountDetail(TLS_METHOD ).toInt()) {
case 0: //KEY_EXCHANGE_NONE case 0: //KEY_EXCHANGE_NONE
checkbox_SDES_fallback_rtp->setVisible(false); checkbox_SDES_fallback_rtp->setVisible(false);
...@@ -334,6 +354,17 @@ void DlgAccounts::loadAccount(QListWidgetItem * item) ...@@ -334,6 +354,17 @@ void DlgAccounts::loadAccount(QListWidgetItem * item)
checkbox_ZRTP_warn_supported->setChecked((account->getAccountDetail(ACCOUNT_ZRTP_NOT_SUPP_WARNING) == "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_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(); keditlistbox_codec->clear();
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
QStringList activeCodecList = configurationManager.getActiveCodecList(account->getAccountDetail(ACCOUNT_ID)); QStringList activeCodecList = configurationManager.getActiveCodecList(account->getAccountDetail(ACCOUNT_ID));
...@@ -364,6 +395,8 @@ void DlgAccounts::loadAccount(QListWidgetItem * item) ...@@ -364,6 +395,8 @@ void DlgAccounts::loadAccount(QListWidgetItem * item)
updateStatusLabel(account); updateStatusLabel(account);
frame2_editAccounts->setEnabled(true); frame2_editAccounts->setEnabled(true);
loadCredentails(account->getAccountDetail(ACCOUNT_ID));
} }
void DlgAccounts::loadAccountList() void DlgAccounts::loadAccountList()
...@@ -675,3 +708,63 @@ void DlgAccounts::updateCombo(int value) { ...@@ -675,3 +708,63 @@ void DlgAccounts::updateCombo(int value) {
break; 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
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <QWidget> #include <QWidget>
#include <kconfigdialog.h> #include <kconfigdialog.h>
#include <QTableWidget> #include <QTableWidget>
#include <QListWidgetItem>
#include "ui_dlgaccountsbase.h" #include "ui_dlgaccountsbase.h"
#include "Account.h" #include "Account.h"
...@@ -32,6 +33,15 @@ ...@@ -32,6 +33,15 @@
typedef QHash<QString, QString> StringHash; //Needed to fix a Qt foreach macro argument parsing bug 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 { class Private_AddCodecDialog : public KDialog {
Q_OBJECT Q_OBJECT
public: public:
...@@ -103,6 +113,7 @@ public: ...@@ -103,6 +113,7 @@ public:
private: private:
AccountList * accountList; AccountList * accountList;
QList< StringHash > codecList; QList< StringHash > codecList;
QListWidgetItemHash credentialInfo;
bool accountListHasChanged; bool accountListHasChanged;
void loadCodecList(); void loadCodecList();
...@@ -134,6 +145,11 @@ private slots: ...@@ -134,6 +145,11 @@ private slots:
void addCodec(QString name = ""); void addCodec(QString name = "");
void codecChanged(); void codecChanged();
void updateCombo(int value); void updateCombo(int value);
void addCredential();
void removeCredential();
void selectCredential(QListWidgetItem* item, QListWidgetItem* previous);
void loadCredentails(QString accountId);
void saveCredential(QString accountId);
signals: signals:
......
...@@ -233,7 +233,7 @@ ...@@ -233,7 +233,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>5</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tab_basic"> <widget class="QWidget" name="tab_basic">
<attribute name="title"> <attribute name="title">
...@@ -385,10 +385,13 @@ ...@@ -385,10 +385,13 @@
<attribute name="title"> <attribute name="title">
<string>Advanced</string> <string>Advanced</string>
</attribute> </attribute>
<layout class="QFormLayout" name="formLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="fieldGrowthPolicy"> <item>
<enum>QFormLayout::ExpandingFieldsGrow</enum> <widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Resgistration</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_regExpire"> <widget class="QLabel" name="label_regExpire">
<property name="text"> <property name="text">
...@@ -406,13 +409,140 @@ ...@@ -406,13 +409,140 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_conformRFC"> <widget class="QCheckBox" name="checkBox_conformRFC">
<property name="text"> <property name="text">
<string>Conform to RFC 3263</string> <string>Conform to RFC 3263</string>
</property> </property>
</widget> </widget>
</item> </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>
<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>
<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> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_stun"> <widget class="QWidget" name="tab_stun">
...@@ -593,13 +723,25 @@ ...@@ -593,13 +723,25 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <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>
<item row="1" column="1"> <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>
<item row="2" column="1"> <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> </item>
</layout> </layout>
</widget> </widget>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment