From kde-commits Mon Sep 30 19:50:51 2013 From: Emmanuel Lepage Vallee Date: Mon, 30 Sep 2013 19:50:51 +0000 To: kde-commits Subject: [sflphone-kde] src: [ #30839 ] Better handling of KeyExchnage categories Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=138057066213469 Git commit 255047f94652ea4fe87aa671f8c0d242068e571a by Emmanuel Lepage Vall= ee. Committed on 30/09/2013 at 16:35. Pushed by lepagevalleeemmanuel into branch 'master'. [ #30839 ] Better handling of KeyExchnage categories This helped discover a serious bug in security handling. It cannot be explpoited because the feature is downright broken. Will be fixed next. M +6 -6 src/accountwizard.cpp M +36 -33 src/conf/dlgaccounts.cpp M +0 -15 src/conf/dlgaccountsbase.ui M +2 -0 src/lib/CMakeLists.txt M +54 -51 src/lib/account.cpp M +36 -35 src/lib/account.h M +6 -6 src/lib/accountlistmodel.cpp M +1 -1 src/lib/call.cpp A +77 -0 src/lib/keyexchangemodel.cpp [License: LGPL (v2.1+)] A +65 -0 src/lib/keyexchangemodel.h [License: LGPL (v2.1+)] M +2 -2 src/lib/sflphone_const.h M +5 -5 src/sflphoneview.cpp M +2 -2 src/widgets/bookmarkdock.cpp http://commits.kde.org/sflphone-kde/255047f94652ea4fe87aa671f8c0d242068e571a diff --git a/src/accountwizard.cpp b/src/accountwizard.cpp index b457eb5..63de55b 100644 --- a/src/accountwizard.cpp +++ b/src/accountwizard.cpp @@ -302,12 +302,12 @@ void AccountWizard::accept() } = if(field(FIELD_ZRTP_ENABLED).toBool()) { - srtp_enabled =3D QString( REGISTRATION_ENABLED_TRUE ); - key_exchange =3D QString( ZRTP ); - zrtp_display_sas =3D QString( REGISTRATION_ENABLED_TRUE ); - zrtp_not_supp_warning =3D QString( REGISTRATION_ENABLED_TRUE ); - zrtp_hello_hash =3D QString( REGISTRATION_ENABLED_TRUE ); - display_sas_once =3D QString( REGISTRATION_ENABLED_FALSE ); + srtp_enabled =3D QString( REGISTRATION_ENABLED_TRUE = ); + key_exchange =3D QString( KeyExchangeModel::Name::ZRTP ); + zrtp_display_sas =3D QString( REGISTRATION_ENABLED_TRUE = ); + zrtp_not_supp_warning =3D QString( REGISTRATION_ENABLED_TRUE = ); + zrtp_hello_hash =3D QString( REGISTRATION_ENABLED_TRUE = ); + display_sas_once =3D QString( REGISTRATION_ENABLED_FALSE = ); } = QStringList ifaceList =3D configurationManager.getAllIpInterface(); diff --git a/src/conf/dlgaccounts.cpp b/src/conf/dlgaccounts.cpp index a2ab4ad..ce72f36 100644 --- a/src/conf/dlgaccounts.cpp +++ b/src/conf/dlgaccounts.cpp @@ -42,6 +42,7 @@ #include "lib/credentialmodel.h" #include "lib/audiocodecmodel.h" #include "lib/accountlistmodel.h" +#include "lib/keyexchangemodel.h" = //OS #ifdef Q_WS_WIN // MS Windows version @@ -80,6 +81,8 @@ DlgAccounts::DlgAccounts(KConfigDialog* parent) loadAccountList(); accountListHasChanged =3D false; = + combo_security_STRP->setModel(KeyExchangeModel::instance()); + //SLOTS // SENDER SIGNAL = RECEIVER SLOT / /**/connect(edit1_alias, SIGNAL(textEdited(QStrin= g)) , this , SLOT(changedAccountList()) ); @@ -194,24 +197,24 @@ void DlgAccounts::saveAccount(QModelIndex item) return; } m_IsLoading++; - = + if (!m_pProxyCK->isChecked()) { m_pProxyLE->setText(""); } - = + QString protocolsTab[] =3D ACCOUNT_TYPES_TAB; - = + //ACCOUNT DETAILS // = WIDGET VALUE / - /**/account->setAccountType ( protocolsTab[edit2_protoc= ol->currentIndex()] ); + /**/account->setType ( protocolsTab[edit2_protoc= ol->currentIndex()] ); /**/account->setAlias ( edit1_alias->text() = ); /**/account->setHostname ( edit3_server->text() = ); /**/account->setUsername ( edit4_user->text() = ); - /**/account->setAccountPassword ( edit5_password->text() = ); + /**/account->setPassword ( edit5_password->text() = ); /**/account->setMailbox ( edit6_mailbox->text() = ); /**/account->setProxy ( m_pProxyLE->text() = ); /**/account->setEnabled ( item.data(Qt::CheckStateR= ole).toBool() ); - /**/account->setAccountRegistrationExpire ( spinbox_regExpire->value(= ) ); + /**/account->setRegistrationExpire ( spinbox_regExpire->value(= ) ); /**/ = /**/ /* Security = */ /**/account->setTlsPassword ( edit_tls_private_key_pass= word->text() ); @@ -219,7 +222,7 @@ void DlgAccounts::saveAccount(QModelIndex item) /**/account->setTlsCaListFile ( file_tls_authority->text(= ) ); /**/account->setTlsCertificateFile ( file_tls_endpoint->text()= ); /**/account->setTlsPrivateKeyFile ( file_tls_private_key->tex= t() ); - /**/account->setTlsMethod ( combo_tls_method->current= Index() ); + /**/account->setTlsMethod ( static_cast(combo_tls_method->currentIndex()) ); /**/account->setTlsCiphers ( edit_tls_cipher->text() = ); /**/account->setTlsServerName ( edit_tls_outgoing->text()= ); /**/account->setTlsNegotiationTimeoutSec ( spinbox_tls_timeout_sec->= value() ); @@ -229,14 +232,14 @@ void DlgAccounts::saveAccount(QModelIndex item) /**/account->setTlsVerifyClient ( check_tls_answer->isCheck= ed() ); /**/account->setTlsRequireClientCertificate ( check_tls_requier_cert->i= sChecked() ); /**/account->setTlsEnable ( group_security_tls->isChe= cked() ); - /**/account->setAccountDisplaySasOnce ( checkbox_ZRTP_Ask_user->i= sChecked() ); - /**/account->setAccountSrtpRtpFallback ( checkbox_SDES_fallback_rt= p->isChecked() ); - /**/account->setAccountZrtpDisplaySas ( checkbox_ZRTP_display_SAS= ->isChecked() ); - /**/account->setAccountZrtpNotSuppWarning ( checkbox_ZRTP_warn_suppor= ted->isChecked() ); - /**/account->setAccountZrtpHelloHash ( checkbox_ZTRP_send_hello-= >isChecked() ); - /**/account->setAccountSipStunEnabled ( checkbox_stun->isChecked(= ) ); + /**/account->setDisplaySasOnce ( checkbox_ZRTP_Ask_user->i= sChecked() ); + /**/account->setSrtpRtpFallback ( checkbox_SDES_fallback_rt= p->isChecked() ); + /**/account->setZrtpDisplaySas ( checkbox_ZRTP_display_SAS= ->isChecked() ); + /**/account->setZrtpNotSuppWarning ( checkbox_ZRTP_warn_suppor= ted->isChecked() ); + /**/account->setZrtpHelloHash ( checkbox_ZTRP_send_hello-= >isChecked() ); + /**/account->setSipStunEnabled ( checkbox_stun->isChecked(= ) ); /**/account->setPublishedSameAsLocal ( radioButton_pa_same_as_lo= cal->isChecked() ); - /**/account->setAccountSipStunServer ( line_stun->text() = ); + /**/account->setSipStunServer ( line_stun->text() = ); /**/account->setPublishedPort ( spinBox_pa_published_port= ->value() ); /**/account->setPublishedAddress ( lineEdit_pa_published_add= ress ->text() ); /**/account->setLocalPort ( spinBox_pa_published_port= ->value() ); @@ -299,8 +302,8 @@ void DlgAccounts::loadAccount(QModelIndex item) protocolsList->append(protocolsTab[i]); } = - const QString accountName =3D account->accountType(); - int protocolIndex =3D protocolsList->indexOf(accountName); + const QString accountType =3D account->type(); + const int protocolIndex =3D protocolsList->indexOf(accountType); delete protocolsList; = = @@ -317,21 +320,21 @@ void DlgAccounts::loadAccount(QModelIndex item) connect(account,SIGNAL(aliasChanged(QString)),this,SLOT(aliasChanged(QS= tring))); = switch (account->tlsMethod()) { - case 0: //KEY_EXCHANGE_NONE + case KeyExchangeModel::Type::NONE: checkbox_SDES_fallback_rtp->setVisible ( false ); checkbox_ZRTP_Ask_user->setVisible ( false ); checkbox_ZRTP_display_SAS->setVisible ( false ); checkbox_ZRTP_warn_supported->setVisible ( false ); checkbox_ZTRP_send_hello->setVisible ( false ); break; - case 1: //ZRTP + case KeyExchangeModel::Type::ZRTP: checkbox_SDES_fallback_rtp->setVisible ( false ); checkbox_ZRTP_Ask_user->setVisible ( true ); checkbox_ZRTP_display_SAS->setVisible ( true ); checkbox_ZRTP_warn_supported->setVisible ( true ); checkbox_ZTRP_send_hello->setVisible ( true ); break; - case 2: //SDES + case KeyExchangeModel::Type::SDES: checkbox_SDES_fallback_rtp->setVisible ( true ); checkbox_ZRTP_Ask_user->setVisible ( false ); checkbox_ZRTP_display_SAS->setVisible ( false ); @@ -346,14 +349,14 @@ void DlgAccounts::loadAccount(QModelIndex item) /**/edit4_user->setText ( account->username = ()); /**/edit6_mailbox->setText ( account->mailbox = ()); /**/m_pProxyLE->setText ( account->proxy = ()); - /**/checkbox_ZRTP_Ask_user->setChecked ( account->isAccountDispl= aySasOnce ()); - /**/checkbox_SDES_fallback_rtp->setChecked ( account->isAccountSrtpR= tpFallback ()); - /**/checkbox_ZRTP_display_SAS->setChecked ( account->isAccountZrtpD= isplaySas ()); - /**/checkbox_ZRTP_warn_supported->setChecked ( account->isAccountZrtpN= otSuppWarning ()); - /**/checkbox_ZTRP_send_hello->setChecked ( account->isAccountZrtpH= elloHash ()); - /**/checkbox_stun->setChecked ( account->isAccountSipSt= unEnabled ()); - /**/line_stun->setText ( account->accountSipStun= Server ()); - /**/spinbox_regExpire->setValue ( account->accountRegistr= ationExpire ()); + /**/checkbox_ZRTP_Ask_user->setChecked ( account->isDisplaySasOn= ce ()); + /**/checkbox_SDES_fallback_rtp->setChecked ( account->isSrtpRtpFallb= ack ()); + /**/checkbox_ZRTP_display_SAS->setChecked ( account->isZrtpDisplayS= as ()); + /**/checkbox_ZRTP_warn_supported->setChecked ( account->isZrtpNotSuppW= arning ()); + /**/checkbox_ZTRP_send_hello->setChecked ( account->isZrtpHelloHas= h ()); + /**/checkbox_stun->setChecked ( account->isSipStunEnabl= ed ()); + /**/line_stun->setText ( account->sipStunServer = ()); + /**/spinbox_regExpire->setValue ( account->registrationEx= pire ()); /**/radioButton_pa_same_as_local->setChecked ( account->isPublishedSam= eAsLocal ()); /**/radioButton_pa_custom->setChecked ( !account->isPublishedSam= eAsLocal ()); /**/lineEdit_pa_published_address->setText ( account->publishedAddre= ss ()); @@ -372,8 +375,8 @@ void DlgAccounts::loadAccount(QModelIndex item) /**/check_tls_answer->setChecked ( account->isTlsVerifyCli= ent ()); /**/check_tls_requier_cert->setChecked ( account->isTlsRequireCl= ientCertificate ()); /**/group_security_tls->setChecked ( account->isTlsEnable = ()); - /**/combo_security_STRP->setCurrentIndex ( account->tlsMethod = ()); /**/m_pAutoAnswer->setChecked ( account->isAutoAnswer = ()); + /**/combo_security_STRP->setCurrentIndex ( KeyExchangeModel::insta= nce()->toIndex(account->tlsMethod()).row()); /* = */ = m_pDTMFOverRTP->setChecked(account->DTMFType()=3D=3DDtmfType::OverRtp); @@ -435,7 +438,7 @@ void DlgAccounts::loadAccount(QModelIndex item) m_pRingTonePath->setUrl( ringtonePath ); = = - combo_tls_method->setCurrentIndex( account->tlsMethod() ); + combo_tls_method->setCurrentIndex( KeyExchangeModel::instance()->toInde= x(account->tlsMethod()).row() ); ConfigurationManagerInterface& configurationManager =3D DBus::Configura= tionManager::instance(); = m_pRingtoneListLW->clear(); @@ -480,8 +483,8 @@ void DlgAccounts::loadAccount(QModelIndex item) comboBox_ni_local_address->setCurrentIndex(0); = if(protocolIndex =3D=3D 0 || account->isNew()) { // if sip selected - checkbox_stun->setChecked(account->isAccountSipStunEnabled()); - line_stun->setText( account->accountSipStunServer() ); + checkbox_stun->setChecked(account->isSipStunEnabled()); + line_stun->setText( account->sipStunServer() ); //checkbox_zrtp->setChecked(account->accountDetail(ACCOUNT_SRTP_ENAB= LED) =3D=3D REGISTRATION_ENABLED_TRUE); = tab_advanced-> setEnabled ( true = ); @@ -492,7 +495,7 @@ void DlgAccounts::loadAccount(QModelIndex item) else { checkbox_stun->setChecked(false); tab_advanced->setEnabled (false); - line_stun->setText( account->accountSipStunServer() ); + line_stun->setText( account->sipStunServer() ); //checkbox_zrtp->setChecked(false); } = @@ -719,7 +722,7 @@ void DlgAccounts::updateStatusLabel(Account* account) { if(!account || AccountListModel::instance()->getAccountByModelIndex(lis= tView_accountList->currentIndex()) !=3D account) return; - const QString status =3D account->accountRegistrationStatus(); + const QString status =3D account->registrationStatus(); edit7_state->setText( "stateColorName() + = "\">" + status + "" ); } = diff --git a/src/conf/dlgaccountsbase.ui b/src/conf/dlgaccountsbase.ui index 22541b0..3206bbf 100644 --- a/src/conf/dlgaccountsbase.ui +++ b/src/conf/dlgaccountsbase.ui @@ -1322,21 +1322,6 @@ 0 - - - Disabled - - - - - ZRTP - - - - - SDES - - diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 465d437..6447521 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -65,6 +65,7 @@ set( qtsflphone_LIB_SRCS phonedirectorymodel.cpp historytimecategorymodel.cpp numbercategorymodel.cpp + keyexchangemodel.cpp = #Communication dbus/configurationmanager.cpp @@ -106,6 +107,7 @@ set( qtsflphone_LIB_HDRS historytimecategorymodel.h numbercategorymodel.h videocodec.h + keyexchangemodel.h ) = set( qtsflphone_extra_LIB_HDRS diff --git a/src/lib/account.cpp b/src/lib/account.cpp index ea70795..3c2f8a1 100644 --- a/src/lib/account.cpp +++ b/src/lib/account.cpp @@ -233,9 +233,9 @@ QModelIndex Account::index() ///Return status color name QString Account::stateColorName() const { - if(accountRegistrationStatus() =3D=3D Account::State::UNREGISTERED) + if(registrationStatus() =3D=3D Account::State::UNREGISTERED) return "black"; - if(accountRegistrationStatus() =3D=3D Account::State::REGISTERED || acc= ountRegistrationStatus() =3D=3D Account::State::READY) + if(registrationStatus() =3D=3D Account::State::REGISTERED || registrati= onStatus() =3D=3D Account::State::READY) return "darkGreen"; return "red"; } @@ -318,49 +318,49 @@ QString Account::proxy() const } = /// -bool Account::isAccountDisplaySasOnce() const +bool Account::isDisplaySasOnce() const { = return (accountDetail(ACCOUNT_DISPLAY_SAS_ONCE) =3D=3D "true")?1:0 ; } = ///Return the account security fallback -bool Account::isAccountSrtpRtpFallback() const +bool Account::isSrtpRtpFallback() const { return (accountDetail(ACCOUNT_SRTP_RTP_FALLBACK) =3D=3D "true")?1:0 ; } = /// -bool Account::isAccountZrtpDisplaySas () const +bool Account::isZrtpDisplaySas () const { return (accountDetail(ACCOUNT_ZRTP_DISPLAY_SAS) =3D=3D "true")?1:0 ; } = ///Return if the other side support warning -bool Account::isAccountZrtpNotSuppWarning() const +bool Account::isZrtpNotSuppWarning() const { return (accountDetail(ACCOUNT_ZRTP_NOT_SUPP_WARNING) =3D=3D "true")?1:0= ; } = /// -bool Account::isAccountZrtpHelloHash() const +bool Account::isZrtpHelloHash() const { return (accountDetail(ACCOUNT_ZRTP_HELLO_HASH) =3D=3D "true")?1:0 ; } = ///Return if the account is using a STUN server -bool Account::isAccountSipStunEnabled() const +bool Account::isSipStunEnabled() const { return (accountDetail(ACCOUNT_SIP_STUN_ENABLED) =3D=3D "true")?1:0 ; } = ///Return the account STUN server -QString Account::accountSipStunServer() const +QString Account::sipStunServer() const { return accountDetail(ACCOUNT_SIP_STUN_SERVER); } = ///Return when the account expire (require renewal) -int Account::accountRegistrationExpire() const +int Account::registrationExpire() const { return accountDetail(Account::MapField::Registration::EXPIRE).toInt(); } @@ -462,9 +462,10 @@ bool Account::isTlsEnable() const } = ///Return the account the TLS encryption method -int Account::tlsMethod() const +KeyExchangeModel::Type Account::tlsMethod() const { - return accountDetail(TLS_METHOD).toInt(); + const int value =3D accountDetail(TLS_METHOD).toInt(); + return value<=3D2?static_cast(value):KeyExchang= eModel::Type::NONE; } = ///Return if the ringtone are enabled @@ -492,13 +493,13 @@ QString Account::localInterface() const } = ///Return the account registration status -QString Account::accountRegistrationStatus() const +QString Account::registrationStatus() const { return accountDetail(Account::MapField::Registration::STATUS); } = ///Return the account type -QString Account::accountType() const +QString Account::type() const { return accountDetail(Account::MapField::TYPE); } @@ -527,7 +528,7 @@ QVariant Account::roleData(int role) const case Account::Role::Alias: return alias(); case Account::Role::Type: - return accountType(); + return type(); case Account::Role::Hostname: return hostname(); case Account::Role::Username: @@ -551,7 +552,7 @@ QVariant Account::roleData(int role) const case Account::Role::TlsServerName: return tlsServerName(); case Account::Role::SipStunServer: - return accountSipStunServer(); + return sipStunServer(); case Account::Role::PublishedAddress: return publishedAddress(); case Account::Role::LocalInterface: @@ -559,9 +560,9 @@ QVariant Account::roleData(int role) const case Account::Role::RingtonePath: return ringtonePath(); case Account::Role::TlsMethod: - return tlsMethod(); - case Account::Role::AccountRegistrationExpire: - return accountRegistrationExpire(); + return static_cast(tlsMethod()); + case Account::Role::RegistrationExpire: + return registrationExpire(); case Account::Role::TlsNegotiationTimeoutSec: return tlsNegotiationTimeoutSec(); case Account::Role::TlsNegotiationTimeoutMsec: @@ -585,17 +586,17 @@ QVariant Account::roleData(int role) const case Account::Role::TlsEnable: return isTlsEnable(); case Account::Role::DisplaySasOnce: - return isAccountDisplaySasOnce(); + return isDisplaySasOnce(); case Account::Role::SrtpRtpFallback: - return isAccountSrtpRtpFallback(); + return isSrtpRtpFallback(); case Account::Role::ZrtpDisplaySas: - return isAccountZrtpDisplaySas(); + return isZrtpDisplaySas(); case Account::Role::ZrtpNotSuppWarning: - return isAccountZrtpNotSuppWarning(); + return isZrtpNotSuppWarning(); case Account::Role::ZrtpHelloHash: - return isAccountZrtpHelloHash(); + return isZrtpHelloHash(); case Account::Role::SipStunEnabled: - return isAccountSipStunEnabled(); + return isSipStunEnabled(); case Account::Role::PublishedSameAsLocal: return isPublishedSameAsLocal(); case Account::Role::RingtoneEnabled: @@ -610,7 +611,7 @@ QVariant Account::roleData(int role) const return var; } case Account::Role::TypeName: - return accountType(); + return type(); case Account::Role::PresenceStatus: return PresenceStatusModel::instance()->currentStatus(); case Account::Role::PresenceMessage: @@ -668,7 +669,7 @@ void Account::setId(const QString& id) } = ///Set the account type, SIP or IAX -void Account::setAccountType(const QString& detail) +void Account::setType(const QString& detail) { setAccountDetail(Account::MapField::TYPE ,detail); } @@ -701,7 +702,7 @@ void Account::setProxy(const QString& detail) } = ///Set the main credential password -void Account::setAccountPassword(const QString& detail) +void Account::setPassword(const QString& detail) { setAccountDetail(Account::MapField::PASSWORD, detail); } @@ -743,7 +744,7 @@ void Account::setTlsServerName(const QString& detail) } = ///Set the stun server -void Account::setAccountSipStunServer(const QString& detail) +void Account::setSipStunServer(const QString& detail) { setAccountDetail(ACCOUNT_SIP_STUN_SERVER, detail); } @@ -767,13 +768,13 @@ void Account::setRingtonePath(const QString& detail) } = ///Set the Tls method -void Account::setTlsMethod(int detail) +void Account::setTlsMethod(KeyExchangeModel::Type detail) { - setAccountDetail(TLS_METHOD ,QString::number(detail)); + setAccountDetail(TLS_METHOD ,QString::number(static_cast(detail))); } = ///Set the account timeout, it will be renegotiated when that timeout occur -void Account::setAccountRegistrationExpire(int detail) +void Account::setRegistrationExpire(int detail) { setAccountDetail(Account::MapField::Registration::EXPIRE, QString::numb= er(detail)); } @@ -844,32 +845,32 @@ void Account::setTlsEnable(bool detail) setAccountDetail(TLS_ENABLE ,detail?"true":"false"); } = -void Account::setAccountDisplaySasOnce(bool detail) +void Account::setDisplaySasOnce(bool detail) { setAccountDetail(ACCOUNT_DISPLAY_SAS_ONCE, detail?"true":"false"); } = -void Account::setAccountSrtpRtpFallback(bool detail) +void Account::setSrtpRtpFallback(bool detail) { setAccountDetail(ACCOUNT_SRTP_RTP_FALLBACK, detail?"true":"false"); } = -void Account::setAccountZrtpDisplaySas(bool detail) +void Account::setZrtpDisplaySas(bool detail) { setAccountDetail(ACCOUNT_ZRTP_DISPLAY_SAS, detail?"true":"false"); } = -void Account::setAccountZrtpNotSuppWarning(bool detail) +void Account::setZrtpNotSuppWarning(bool detail) { setAccountDetail(ACCOUNT_ZRTP_NOT_SUPP_WARNING, detail?"true":"false"); } = -void Account::setAccountZrtpHelloHash(bool detail) +void Account::setZrtpHelloHash(bool detail) { setAccountDetail(ACCOUNT_ZRTP_HELLO_HASH, detail?"true":"false"); } = -void Account::setAccountSipStunEnabled(bool detail) +void Account::setSipStunEnabled(bool detail) { setAccountDetail(ACCOUNT_SIP_STUN_ENABLED, detail?"true":"false"); } @@ -897,7 +898,7 @@ void Account::setRoleData(int role, const QVariant& val= ue) case Account::Role::Alias: setAlias(value.toString()); case Account::Role::Type: - setAccountType(value.toString()); + setType(value.toString()); case Account::Role::Hostname: setHostname(value.toString()); case Account::Role::Username: @@ -921,17 +922,19 @@ void Account::setRoleData(int role, const QVariant& v= alue) case Account::Role::TlsServerName: setTlsServerName(value.toString()); case Account::Role::SipStunServer: - setAccountSipStunServer(value.toString()); + setSipStunServer(value.toString()); case Account::Role::PublishedAddress: setPublishedAddress(value.toString()); case Account::Role::LocalInterface: setLocalInterface(value.toString()); case Account::Role::RingtonePath: setRingtonePath(value.toString()); - case Account::Role::TlsMethod: - setTlsMethod(value.toInt()); - case Account::Role::AccountRegistrationExpire: - setAccountRegistrationExpire(value.toInt()); + case Account::Role::TlsMethod: { + const int method =3D value.toInt(); + setTlsMethod(method<=3D2?static_cast(meth= od):KeyExchangeModel::Type::NONE); + } + case Account::Role::RegistrationExpire: + setRegistrationExpire(value.toInt()); case Account::Role::TlsNegotiationTimeoutSec: setTlsNegotiationTimeoutSec(value.toInt()); case Account::Role::TlsNegotiationTimeoutMsec: @@ -955,17 +958,17 @@ void Account::setRoleData(int role, const QVariant& v= alue) case Account::Role::TlsEnable: setTlsEnable(value.toBool()); case Account::Role::DisplaySasOnce: - setAccountDisplaySasOnce(value.toBool()); + setDisplaySasOnce(value.toBool()); case Account::Role::SrtpRtpFallback: - setAccountSrtpRtpFallback(value.toBool()); + setSrtpRtpFallback(value.toBool()); case Account::Role::ZrtpDisplaySas: - setAccountZrtpDisplaySas(value.toBool()); + setZrtpDisplaySas(value.toBool()); case Account::Role::ZrtpNotSuppWarning: - setAccountZrtpNotSuppWarning(value.toBool()); + setZrtpNotSuppWarning(value.toBool()); case Account::Role::ZrtpHelloHash: - setAccountZrtpHelloHash(value.toBool()); + setZrtpHelloHash(value.toBool()); case Account::Role::SipStunEnabled: - setAccountSipStunEnabled(value.toBool()); + setSipStunEnabled(value.toBool()); case Account::Role::PublishedSameAsLocal: setPublishedSameAsLocal(value.toBool()); case Account::Role::RingtoneEnabled: @@ -1005,7 +1008,7 @@ bool Account::updateState() ConfigurationManagerInterface & configurationManager =3D DBus::Confi= gurationManager::instance(); const MapStringString details =3D configurationManager.getAcco= untDetails(id()).value(); const QString status =3D details[Account::MapField::R= egistration::STATUS]; - const QString currentStatus =3D accountRegistrationStatus(); + const QString currentStatus =3D registrationStatus(); setAccountDetail(Account::MapField::Registration::STATUS, status); /= /Update -internal- object state return status =3D=3D currentStatus; } diff --git a/src/lib/account.h b/src/lib/account.h index d83c0d3..63331c6 100644 --- a/src/lib/account.h +++ b/src/lib/account.h @@ -27,6 +27,7 @@ class QString; = //SFLPhone #include "videocodecmodel.h" +#include "keyexchangemodel.h" #include "sflphone_const.h" #include "typedefs.h" // #include "dbus/metatypes.h" @@ -54,7 +55,7 @@ class LIB_EXPORT Account : public QObject { = //Properties Q_PROPERTY(QString alias READ alias = WRITE setAlias ) - Q_PROPERTY(QString type READ accountType= WRITE setAccountType ) + Q_PROPERTY(QString type READ type = WRITE setType ) Q_PROPERTY(QString hostname READ hostname = WRITE setHostname ) Q_PROPERTY(QString username READ username = WRITE setUsername ) Q_PROPERTY(QString mailbox READ mailbox = WRITE setMailbox ) @@ -65,12 +66,12 @@ class LIB_EXPORT Account : public QObject { Q_PROPERTY(QString tlsPrivateKeyFile READ tlsPrivateK= eyFile WRITE setTlsPrivateKeyFile ) Q_PROPERTY(QString tlsCiphers READ tlsCiphers = WRITE setTlsCiphers ) Q_PROPERTY(QString tlsServerName READ tlsServerNa= me WRITE setTlsServerName ) - Q_PROPERTY(QString sipStunServer READ accountSipS= tunServer WRITE setAccountSipStunServer ) + Q_PROPERTY(QString sipStunServer READ sipStunServ= er WRITE setSipStunServer ) Q_PROPERTY(QString publishedAddress READ publishedAd= dress WRITE setPublishedAddress ) Q_PROPERTY(QString localInterface READ localInterf= ace WRITE setLocalInterface ) Q_PROPERTY(QString ringtonePath READ ringtonePat= h WRITE setRingtonePath ) - Q_PROPERTY(int tlsMethod READ tlsMethod = WRITE setTlsMethod ) - Q_PROPERTY(int accountRegistrationExpire READ accountRegi= strationExpire WRITE setAccountRegistrationExpire ) + Q_PROPERTY(KeyExchangeModel::Type tlsMethod READ tlsMethod = WRITE setTlsMethod ) + Q_PROPERTY(int registrationExpire READ registratio= nExpire WRITE setRegistrationExpire ) Q_PROPERTY(int tlsNegotiationTimeoutSec READ tlsNegotiat= ionTimeoutSec WRITE setTlsNegotiationTimeoutSec ) Q_PROPERTY(int tlsNegotiationTimeoutMsec READ tlsNegotiat= ionTimeoutMsec WRITE setTlsNegotiationTimeoutMsec ) Q_PROPERTY(int localPort READ localPort = WRITE setLocalPort ) @@ -82,16 +83,16 @@ class LIB_EXPORT Account : public QObject { Q_PROPERTY(bool tlsVerifyClient READ isTlsVerify= Client WRITE setTlsVerifyClient ) Q_PROPERTY(bool tlsRequireClientCertificate READ isTlsRequir= eClientCertificate WRITE setTlsRequireClientCertificate ) Q_PROPERTY(bool tlsEnable READ isTlsEnable= WRITE setTlsEnable ) - Q_PROPERTY(bool displaySasOnce READ isAccountDi= splaySasOnce WRITE setAccountDisplaySasOnce ) - Q_PROPERTY(bool srtpRtpFallback READ isAccountSr= tpRtpFallback WRITE setAccountSrtpRtpFallback ) - Q_PROPERTY(bool zrtpDisplaySas READ isAccountZr= tpDisplaySas WRITE setAccountZrtpDisplaySas ) - Q_PROPERTY(bool zrtpNotSuppWarning READ isAccountZr= tpNotSuppWarning WRITE setAccountZrtpNotSuppWarning ) - Q_PROPERTY(bool zrtpHelloHash READ isAccountZr= tpHelloHash WRITE setAccountZrtpHelloHash ) - Q_PROPERTY(bool sipStunEnabled READ isAccountSi= pStunEnabled WRITE setAccountSipStunEnabled ) + Q_PROPERTY(bool displaySasOnce READ isDisplaySa= sOnce WRITE setDisplaySasOnce ) + Q_PROPERTY(bool srtpRtpFallback READ isSrtpRtpFa= llback WRITE setSrtpRtpFallback ) + Q_PROPERTY(bool zrtpDisplaySas READ isZrtpDispl= aySas WRITE setZrtpDisplaySas ) + Q_PROPERTY(bool zrtpNotSuppWarning READ isZrtpNotSu= ppWarning WRITE setZrtpNotSuppWarning ) + Q_PROPERTY(bool zrtpHelloHash READ isZrtpHello= Hash WRITE setZrtpHelloHash ) + Q_PROPERTY(bool sipStunEnabled READ isSipStunEn= abled WRITE setSipStunEnabled ) Q_PROPERTY(bool publishedSameAsLocal READ isPublished= SameAsLocal WRITE setPublishedSameAsLocal ) Q_PROPERTY(bool ringtoneEnabled READ isRingtoneE= nabled WRITE setRingtoneEnabled ) Q_PROPERTY(DtmfType dTMFType READ DTMFType = WRITE setDTMFType ) - Q_PROPERTY(QString typeName READ accountType= WRITE setAccountType ) + Q_PROPERTY(QString typeName READ type = WRITE setType ) Q_PROPERTY(bool presenceStatus READ presenceSta= tus ) Q_PROPERTY(QString presenceMessage READ presenceMes= sage ) = @@ -154,7 +155,7 @@ class LIB_EXPORT Account : public QObject { LocalInterface =3D 115, RingtonePath =3D 116, TlsMethod =3D 117, - AccountRegistrationExpire =3D 118, + RegistrationExpire =3D 118, TlsNegotiationTimeoutSec =3D 119, TlsNegotiationTimeoutMsec =3D 120, LocalPort =3D 121, @@ -248,14 +249,14 @@ class LIB_EXPORT Account : public QObject { QString username () const; QString mailbox () const; QString proxy () const; - bool isAccountDisplaySasOnce () const; - bool isAccountSrtpRtpFallback () const; - bool isAccountZrtpDisplaySas () const; - bool isAccountZrtpNotSuppWarning () const; - bool isAccountZrtpHelloHash () const; - bool isAccountSipStunEnabled () const; - QString accountSipStunServer () const; - int accountRegistrationExpire () const; + bool isDisplaySasOnce () const; + bool isSrtpRtpFallback () const; + bool isZrtpDisplaySas () const; + bool isZrtpNotSuppWarning () const; + bool isZrtpHelloHash () const; + bool isSipStunEnabled () const; + QString sipStunServer () const; + int registrationExpire () const; bool isPublishedSameAsLocal () const; QString publishedAddress () const; int publishedPort () const; @@ -272,39 +273,39 @@ class LIB_EXPORT Account : public QObject { bool isTlsVerifyClient () const; bool isTlsRequireClientCertificate() const; bool isTlsEnable () const; - int tlsMethod () const; bool isRingtoneEnabled () const; QString ringtonePath () const; int localPort () const; QString localInterface () const; - QString accountRegistrationStatus () const; - QString accountType () const; + QString registrationStatus () const; + QString type () const; DtmfType DTMFType () const; bool presenceStatus () const; QString presenceMessage () const; + KeyExchangeModel::Type tlsMethod () const; QVariant roleData (int role) const; = //Setters void setId (const QString& id); void setAlias (const QString& detail); - void setAccountType (const QString& detail); + void setType (const QString& detail); void setHostname (const QString& detail); void setUsername (const QString& detail); void setMailbox (const QString& detail); void setProxy (const QString& detail); - void setAccountPassword (const QString& detail); + void setPassword (const QString& detail); void setTlsPassword (const QString& detail); void setTlsCaListFile (const QString& detail); void setTlsCertificateFile (const QString& detail); void setTlsPrivateKeyFile (const QString& detail); void setTlsCiphers (const QString& detail); void setTlsServerName (const QString& detail); - void setAccountSipStunServer (const QString& detail); + void setSipStunServer (const QString& detail); void setPublishedAddress (const QString& detail); void setLocalInterface (const QString& detail); void setRingtonePath (const QString& detail); - void setTlsMethod (int detail); - void setAccountRegistrationExpire (int detail); + void setTlsMethod (KeyExchangeModel::Type detail= ); + void setRegistrationExpire (int detail); void setTlsNegotiationTimeoutSec (int detail); void setTlsNegotiationTimeoutMsec (int detail); void setLocalPort (unsigned short detail); @@ -315,15 +316,15 @@ class LIB_EXPORT Account : public QObject { void setTlsVerifyClient (bool detail); void setTlsRequireClientCertificate (bool detail); void setTlsEnable (bool detail); - void setAccountDisplaySasOnce (bool detail); - void setAccountSrtpRtpFallback (bool detail); - void setAccountZrtpDisplaySas (bool detail); - void setAccountZrtpNotSuppWarning (bool detail); - void setAccountZrtpHelloHash (bool detail); - void setAccountSipStunEnabled (bool detail); + void setDisplaySasOnce (bool detail); + void setSrtpRtpFallback (bool detail); + void setZrtpDisplaySas (bool detail); + void setZrtpNotSuppWarning (bool detail); + void setZrtpHelloHash (bool detail); + void setSipStunEnabled (bool detail); void setPublishedSameAsLocal (bool detail); void setRingtoneEnabled (bool detail); - void setDTMFType (DtmfType type ); + void setDTMFType (DtmfType type); = void setRoleData(int role, const QVariant& value); = diff --git a/src/lib/accountlistmodel.cpp b/src/lib/accountlistmodel.cpp index 6b0e307..a2b3c90 100644 --- a/src/lib/accountlistmodel.cpp +++ b/src/lib/accountlistmodel.cpp @@ -103,7 +103,7 @@ void AccountListModel::setupRoleName() roles.insert(Account::Role::LocalInterface ,QByteArray("local= Interface" )); roles.insert(Account::Role::RingtonePath ,QByteArray("ringt= onePath" )); roles.insert(Account::Role::TlsMethod ,QByteArray("tlsMe= thod" )); - roles.insert(Account::Role::AccountRegistrationExpire,QByteArray("accou= ntRegistrationExpire" )); + roles.insert(Account::Role::RegistrationExpire ,QByteArray("regis= trationExpire" )); roles.insert(Account::Role::TlsNegotiationTimeoutSec ,QByteArray("tlsNe= gotiationTimeoutSec" )); roles.insert(Account::Role::TlsNegotiationTimeoutMsec,QByteArray("tlsNe= gotiationTimeoutMsec" )); roles.insert(Account::Role::LocalPort ,QByteArray("local= Port" )); @@ -360,7 +360,7 @@ QVector AccountListModel::getAccountsByState(= const QString& state) { QVector v; for (int i =3D 0; i < m_lAccounts.size(); ++i) { - if (m_lAccounts[i]->accountRegistrationStatus() =3D=3D state) + if (m_lAccounts[i]->registrationStatus() =3D=3D state) v +=3D m_lAccounts[i]; } return v; @@ -374,7 +374,7 @@ QVector AccountListModel::registeredAccounts(= ) const Account* current; for (int i =3D 0; i < m_lAccounts.count(); ++i) { current =3D m_lAccounts[i]; - if(current->accountRegistrationStatus() =3D=3D Account::State::REGIS= TERED) { + if(current->registrationStatus() =3D=3D Account::State::REGISTERED) { qDebug() << current->alias() << " : " << current; registeredAccountsVector.append(current); } @@ -388,9 +388,9 @@ Account* AccountListModel::firstRegisteredAccount() con= st Account* current; for (int i =3D 0; i < m_lAccounts.count(); ++i) { current =3D m_lAccounts[i]; - if(current && current->accountRegistrationStatus() =3D=3D Account::S= tate::REGISTERED && current->isEnabled()) + if(current && current->registrationStatus() =3D=3D Account::State::R= EGISTERED && current->isEnabled()) return current; - else if (current && (current->accountRegistrationStatus() =3D=3D Acc= ount::State::READY) && m_lAccounts.count() =3D=3D 1) + else if (current && (current->registrationStatus() =3D=3D Account::S= tate::READY) && m_lAccounts.count() =3D=3D 1) return current; // else if (current && !(current->accountRegistrationStatus()() =3D= =3D ACCOUNT_STATE_READY)) { // qDebug() << "Account " << ((current)?current->accountId():"") = << " is not registered (" @@ -411,7 +411,7 @@ int AccountListModel::size() const Account* AccountListModel::currentAccount() { Account* priorAccount =3D m_spPriorAccount; - if(priorAccount && priorAccount->accountRegistrationStatus() =3D=3D Acc= ount::State::REGISTERED && priorAccount->isEnabled() ) { + if(priorAccount && priorAccount->registrationStatus() =3D=3D Account::S= tate::REGISTERED && priorAccount->isEnabled() ) { return priorAccount; } else { diff --git a/src/lib/call.cpp b/src/lib/call.cpp index 2177ebc..e0a08f8 100644 --- a/src/lib/call.cpp +++ b/src/lib/call.cpp @@ -604,7 +604,7 @@ bool Call::isSecure() const { return false; } = - return m_Account && ((m_Account->isTlsEnable()) || (m_Account->tlsMetho= d())); + return m_Account && ((m_Account->isTlsEnable()) || (m_Account->tlsMetho= d() !=3D KeyExchangeModel::Type::NONE)); } //isSecure = ///Return the renderer associated with this call or nullptr diff --git a/src/lib/keyexchangemodel.cpp b/src/lib/keyexchangemodel.cpp new file mode 100644 index 0000000..67938ae --- /dev/null +++ b/src/lib/keyexchangemodel.cpp @@ -0,0 +1,77 @@ +/*************************************************************************= *** + * Copyright (C) 2013 by Savoir-Faire Linux = * + * Author : Emmanuel Lepage Vallee * + * = * + * This library is free software; you can redistribute it and/or = * + * modify it under the terms of the GNU Lesser General Public = * + * License as published by the Free Software Foundation; either = * + * version 2.1 of the License, or (at your option) any later version. = * + * = * + * This library is distributed in the hope that it will be useful, = * + * but WITHOUT ANY WARRANTY; without even the implied warranty of = * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU = * + * Lesser General Public License for more details. = * + * = * + * You should have received a copy of the GNU General Public License = * + * along with this program. If not, see .= * + *************************************************************************= **/ +#include "keyexchangemodel.h" + +#include + +KeyExchangeModel* KeyExchangeModel::m_spInstance =3D nullptr; + +KeyExchangeModel::KeyExchangeModel() : QAbstractListModel(QCoreApplication= ::instance()) {} + +//Model functions +QVariant KeyExchangeModel::data( const QModelIndex& index, int role) const +{ + if (!index.isValid()) return QVariant(); + KeyExchangeModel::Type mathod =3D static_cast(i= ndex.row()); + if (role =3D=3D Qt::DisplayRole) { + switch (mathod) { + case KeyExchangeModel::Type::NONE: + return KeyExchangeModel::Name::NONE; + break; + case KeyExchangeModel::Type::ZRTP: + return KeyExchangeModel::Name::ZRTP; + break; + case KeyExchangeModel::Type::SDES: + return KeyExchangeModel::Name::SDES; + break; + }; + } + return QVariant(); +} + +int KeyExchangeModel::rowCount( const QModelIndex& parent ) const +{ + return parent.isValid()?0:3; +} + +Qt::ItemFlags KeyExchangeModel::flags( const QModelIndex& index ) const +{ + if (!index.isValid()) return Qt::NoItemFlags; + return Qt::ItemIsEnabled|Qt::ItemIsSelectable; +} + +bool KeyExchangeModel::setData( const QModelIndex& index, const QVariant &= value, int role) +{ + Q_UNUSED(index) + Q_UNUSED(value) + Q_UNUSED(role ) + return false; +} + +KeyExchangeModel* KeyExchangeModel::instance() +{ + if (!m_spInstance) + m_spInstance =3D new KeyExchangeModel(); + return m_spInstance; +} + +///Translate enum type to QModelIndex +QModelIndex KeyExchangeModel::toIndex(KeyExchangeModel::Type type) +{ + return index(static_cast(type),0,QModelIndex()); +} diff --git a/src/lib/keyexchangemodel.h b/src/lib/keyexchangemodel.h new file mode 100644 index 0000000..2cf9e06 --- /dev/null +++ b/src/lib/keyexchangemodel.h @@ -0,0 +1,65 @@ +/*************************************************************************= *** + * Copyright (C) 2013 by Savoir-Faire Linux = * + * Author : Emmanuel Lepage Vallee * + * = * + * This library is free software; you can redistribute it and/or = * + * modify it under the terms of the GNU Lesser General Public = * + * License as published by the Free Software Foundation; either = * + * version 2.1 of the License, or (at your option) any later version. = * + * = * + * This library is distributed in the hope that it will be useful, = * + * but WITHOUT ANY WARRANTY; without even the implied warranty of = * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU = * + * Lesser General Public License for more details. = * + * = * + * You should have received a copy of the GNU General Public License = * + * along with this program. If not, see .= * + *************************************************************************= **/ +#ifndef KEYEXCHANGEMODEL_H +#define KEYEXCHANGEMODEL_H + +#include "typedefs.h" +#include + +///Static model for handling encryption types +class LIB_EXPORT KeyExchangeModel : public QAbstractListModel { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" + Q_OBJECT + #pragma GCC diagnostic pop + +public: + ///@enum Type Every supported encryption types + enum class Type { + NONE =3D 0, + ZRTP =3D 1, + SDES =3D 2, + }; + + class Name { + public: + constexpr static const char* NONE =3D "none"; + constexpr static const char* ZRTP =3D "zrtp"; + constexpr static const char* SDES =3D "sdes"; + }; + + //Private constructor, can only be called by 'Account' + explicit KeyExchangeModel(); + + //Model functions + QVariant data ( const QModelIndex& index, int role =3D Qt::Dis= playRole ) const; + int rowCount ( const QModelIndex& parent =3D QModelIndex() = ) const; + Qt::ItemFlags flags ( const QModelIndex& index = ) const; + virtual bool setData ( const QModelIndex& index, const QVariant &valu= e, int role) ; + + //Getters + QModelIndex toIndex (KeyExchangeModel::Type type); + + //Singleton + static KeyExchangeModel* instance(); + +private: + static KeyExchangeModel* m_spInstance; +}; +Q_DECLARE_METATYPE(KeyExchangeModel*) +#endif diff --git a/src/lib/sflphone_const.h b/src/lib/sflphone_const.h index 7865df3..2289dd1 100644 --- a/src/lib/sflphone_const.h +++ b/src/lib/sflphone_const.h @@ -88,8 +88,8 @@ #define ACCOUNT_ZRTP_HELLO_HASH "ZRTP.helloHashEnable" #define ACCOUNT_DISPLAY_SAS_ONCE "ZRTP.displaySasOnce" #define KEY_EXCHANGE_NONE "none" -#define ZRTP "zrtp" -#define SDES "sdes" +// #define ZRTP "zrtp" +// #define SDES "sdes" = = = diff --git a/src/sflphoneview.cpp b/src/sflphoneview.cpp index 32ee0d1..b235ad9 100644 --- a/src/sflphoneview.cpp +++ b/src/sflphoneview.cpp @@ -117,12 +117,12 @@ public: } = virtual QVariant getColor(const Account* a) { - if(a->accountRegistrationStatus() =3D=3D Account::State::UNREGISTERE= D || !a->isEnabled()) + if(a->registrationStatus() =3D=3D Account::State::UNREGISTERED || !a= ->isEnabled()) return m_Pal.color(QPalette::Base); - if(a->accountRegistrationStatus() =3D=3D Account::State::REGISTERED = || a->accountRegistrationStatus() =3D=3D Account::State::READY) { + if(a->registrationStatus() =3D=3D Account::State::REGISTERED || a->r= egistrationStatus() =3D=3D Account::State::READY) { return m_Green; } - if(a->accountRegistrationStatus() =3D=3D Account::State::TRYING) + if(a->registrationStatus() =3D=3D Account::State::TRYING) return m_Yellow; return m_Red; } @@ -900,14 +900,14 @@ void SFLPhoneView::updateDialpad() ///Change the statusbar message void SFLPhoneView::updateStatusMessage() { - Account * account =3D AccountListModel::currentAccount(); + const Account* account =3D AccountListModel::currentAccount(); = if(!account) { emit statusMessageChangeAsked(i18n("No registered accounts")); } else { emit statusMessageChangeAsked(i18n("Using account \'%1\' (%2)", - account->alias(), account->accountRegistrationStatus())); + account->alias(), account->registrationStatus())); } } = diff --git a/src/widgets/bookmarkdock.cpp b/src/widgets/bookmarkdock.cpp index 2557210..97251da 100644 --- a/src/widgets/bookmarkdock.cpp +++ b/src/widgets/bookmarkdock.cpp @@ -77,7 +77,7 @@ BookmarkDock::BookmarkDock(QWidget* parent) : QDockWidget= (parent) = m_pFilterLE->setPlaceholderText(i18n("Filter")); = - m_pMostUsedCK->setChecked(ConfigurationSkeleton::displayContactCallHist= ory()); + m_pMostUsedCK->setChecked(ConfigurationSkeleton::displayPopularAsBookma= rk()); = setWidget(mainWidget); = @@ -113,7 +113,7 @@ BookmarkDock::~BookmarkDock() ///Show the most popular items void BookmarkDock::reload() { - ConfigurationSkeleton::setDisplayContactCallHistory(m_pMostUsedCK->isCh= ecked()); + ConfigurationSkeleton::setDisplayPopularAsBookmark(m_pMostUsedCK->isChe= cked()); BookmarkModel::instance()->reloadCategories(); } //reload =