From kde-commits Mon Sep 30 19:50:52 2013 From: Emmanuel Lepage Vallee Date: Mon, 30 Sep 2013 19:50:52 +0000 To: kde-commits Subject: [sflphone-kde] src: [ #30848 ] Make TLS and SRTP feature work again Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=138057066213468 Git commit addfbbcde9b67d3c9cc53cad0b1e8ee871fc92ad by Emmanuel Lepage Vall= ee. Committed on 30/09/2013 at 19:38. Pushed by lepagevalleeemmanuel into branch 'master'. [ #30848 ] Make TLS and SRTP feature work again It was broken since an undocumented daemon syntax change, probably a long time ago (years?). All security feilds are now validated, everything is saved correctly and there is now additional protections against this happening again. M +12 -10 src/conf/dlgaccounts.cpp M +3 -29 src/conf/dlgaccountsbase.ui M +2 -0 src/lib/CMakeLists.txt M +23 -6 src/lib/account.cpp M +10 -5 src/lib/account.h M +9 -24 src/lib/accountlistmodel.cpp M +0 -1 src/lib/accountlistmodel.h M +2 -1 src/lib/call.cpp M +30 -1 src/lib/keyexchangemodel.cpp M +11 -2 src/lib/keyexchangemodel.h A +105 -0 src/lib/tlsmethodmodel.cpp [License: LGPL (v2.1+)] C +26 -14 src/lib/tlsmethodmodel.h [from: src/lib/keyexchangemodel.h -= 068% similarity] M +2 -32 src/sflphoneview.cpp M +0 -8 src/sflphoneview.h http://commits.kde.org/sflphone-kde/addfbbcde9b67d3c9cc53cad0b1e8ee871fc92ad diff --git a/src/conf/dlgaccounts.cpp b/src/conf/dlgaccounts.cpp index ce72f36..ba86625 100644 --- a/src/conf/dlgaccounts.cpp +++ b/src/conf/dlgaccounts.cpp @@ -43,6 +43,7 @@ #include "lib/audiocodecmodel.h" #include "lib/accountlistmodel.h" #include "lib/keyexchangemodel.h" +#include "lib/tlsmethodmodel.h" = //OS #ifdef Q_WS_WIN // MS Windows version @@ -82,6 +83,7 @@ DlgAccounts::DlgAccounts(KConfigDialog* parent) accountListHasChanged =3D false; = combo_security_STRP->setModel(KeyExchangeModel::instance()); + combo_tls_method->setModel(TlsMethodModel::instance()); = //SLOTS // SENDER SIGNAL = RECEIVER SLOT / @@ -119,6 +121,7 @@ DlgAccounts::DlgAccounts(KConfigDialog* parent) /**/connect(file_tls_endpoint, SIGNAL(textChanged(QStri= ng)) , this , SLOT(changedAccountList()) ); /**/connect(file_tls_private_key, SIGNAL(textChanged(QStri= ng)) , this , SLOT(changedAccountList()) ); /**/connect(combo_tls_method, SIGNAL(currentIndexChang= ed(int)) , this , SLOT(changedAccountList()) ); + /**/connect(combo_security_STRP, SIGNAL(currentIndexChang= ed(int)) , this , SLOT(changedAccountList()) ); /**/connect(edit_tls_cipher, SIGNAL(textEdited(QStrin= g)) , this , SLOT(changedAccountList()) ); /**/connect(edit_tls_outgoing, SIGNAL(textEdited(QStrin= g)) , this , SLOT(changedAccountList()) ); /**/connect(spinbox_tls_timeout_sec, SIGNAL(valueChanged(int)= ) , this , SLOT(changedAccountList()) ); @@ -222,12 +225,12 @@ 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 ( static_cast(combo_tls_method->currentIndex()) ); + /**/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() ); /**/account->setTlsNegotiationTimeoutMsec ( spinbox_tls_timeout_msec-= >value() ); - ///**/account->setTlsMethod ( QString::number(combo_s= ecurity_STRP->currentIndex()) ); + /**/account->setKeyExchange ( static_cast(combo_security_STRP->currentIndex()) ); /**/account->setTlsVerifyServer ( check_tls_incoming->isChe= cked() ); /**/account->setTlsVerifyClient ( check_tls_answer->isCheck= ed() ); /**/account->setTlsRequireClientCertificate ( check_tls_requier_cert->i= sChecked() ); @@ -319,7 +322,7 @@ void DlgAccounts::loadAccount(QModelIndex item) disconnect(this,SLOT(aliasChanged(QString))); connect(account,SIGNAL(aliasChanged(QString)),this,SLOT(aliasChanged(QS= tring))); = - switch (account->tlsMethod()) { + switch (account->keyExchange()) { case KeyExchangeModel::Type::NONE: checkbox_SDES_fallback_rtp->setVisible ( false ); checkbox_ZRTP_Ask_user->setVisible ( false ); @@ -376,7 +379,7 @@ void DlgAccounts::loadAccount(QModelIndex item) /**/check_tls_requier_cert->setChecked ( account->isTlsRequireCl= ientCertificate ()); /**/group_security_tls->setChecked ( account->isTlsEnable = ()); /**/m_pAutoAnswer->setChecked ( account->isAutoAnswer = ()); - /**/combo_security_STRP->setCurrentIndex ( KeyExchangeModel::insta= nce()->toIndex(account->tlsMethod()).row()); + /**/combo_security_STRP->setCurrentIndex ( KeyExchangeModel::insta= nce()->toIndex(account->keyExchange()).row()); /* = */ = m_pDTMFOverRTP->setChecked(account->DTMFType()=3D=3DDtmfType::OverRtp); @@ -437,8 +440,7 @@ void DlgAccounts::loadAccount(QModelIndex item) const QString ringtonePath =3D KStandardDirs::realFilePath(account->rin= gtonePath()); m_pRingTonePath->setUrl( ringtonePath ); = - - combo_tls_method->setCurrentIndex( KeyExchangeModel::instance()->toInde= x(account->tlsMethod()).row() ); + combo_tls_method->setCurrentIndex( TlsMethodModel::instance()->toIndex(= account->tlsMethod()).row() ); ConfigurationManagerInterface& configurationManager =3D DBus::Configura= tionManager::instance(); = m_pRingtoneListLW->clear(); @@ -784,22 +786,22 @@ void DlgAccounts::selectedCodecChanged(const QModelIn= dex& current,const QModelIn void DlgAccounts::updateCombo(int value) { Q_UNUSED(value) - switch (combo_security_STRP->currentIndex()) { - case 0: //KEY_EXCHANGE_NONE + switch (static_cast(combo_security_STRP->curren= tIndex())) { + 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 ); diff --git a/src/conf/dlgaccountsbase.ui b/src/conf/dlgaccountsbase.ui index 3206bbf..76fee99 100644 --- a/src/conf/dlgaccountsbase.ui +++ b/src/conf/dlgaccountsbase.ui @@ -203,7 +203,7 @@ - 0 + 4 @@ -1011,7 +1011,7 @@ 0 - 0 + -168 539 666 @@ -1126,33 +1126,7 @@ - - - - Default - - - - - TLSv1 - - - - - SSLv2 - - - - - SSLv3 - - - - - SSLv23 - - - + diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 6447521..a9bbed3 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -66,6 +66,7 @@ set( qtsflphone_LIB_SRCS historytimecategorymodel.cpp numbercategorymodel.cpp keyexchangemodel.cpp + tlsmethodmodel.cpp = #Communication dbus/configurationmanager.cpp @@ -108,6 +109,7 @@ set( qtsflphone_LIB_HDRS numbercategorymodel.h videocodec.h keyexchangemodel.h + tlsmethodmodel.h ) = set( qtsflphone_extra_LIB_HDRS diff --git a/src/lib/account.cpp b/src/lib/account.cpp index 3c2f8a1..0234ee9 100644 --- a/src/lib/account.cpp +++ b/src/lib/account.cpp @@ -462,10 +462,16 @@ bool Account::isTlsEnable() const } = ///Return the account the TLS encryption method -KeyExchangeModel::Type Account::tlsMethod() const +TlsMethodModel::Type Account::tlsMethod() const { - const int value =3D accountDetail(TLS_METHOD).toInt(); - return value<=3D2?static_cast(value):KeyExchang= eModel::Type::NONE; + const QString value =3D accountDetail(TLS_METHOD); + return TlsMethodModel::fromDaemonName(value); +} + +///Return the key exchange mechanism +KeyExchangeModel::Type Account::keyExchange() const +{ + return KeyExchangeModel::fromDaemonName(accountDetail(ACCOUNT_KEY_EXCHA= NGE)); } = ///Return if the ringtone are enabled @@ -768,9 +774,16 @@ void Account::setRingtonePath(const QString& detail) } = ///Set the Tls method -void Account::setTlsMethod(KeyExchangeModel::Type detail) +void Account::setTlsMethod(TlsMethodModel::Type detail) +{ + = + setAccountDetail(TLS_METHOD ,TlsMethodModel::toDaemonName(detail)); +} + +///Set the Tls method +void Account::setKeyExchange(KeyExchangeModel::Type detail) { - setAccountDetail(TLS_METHOD ,QString::number(static_cast(detail))); + setAccountDetail(ACCOUNT_KEY_EXCHANGE ,KeyExchangeModel::toDaemonName(d= etail)); } = ///Set the account timeout, it will be renegotiated when that timeout occur @@ -931,7 +944,11 @@ void Account::setRoleData(int role, const QVariant& va= lue) setRingtonePath(value.toString()); case Account::Role::TlsMethod: { const int method =3D value.toInt(); - setTlsMethod(method<=3D2?static_cast(meth= od):KeyExchangeModel::Type::NONE); + setTlsMethod(method<=3DTlsMethodModel::instance()->rowCount()?sta= tic_cast(method):TlsMethodModel::Type::DEFAULT); + } + case Account::Role::KeyExchange: { + const int method =3D value.toInt(); + setKeyExchange(method<=3DKeyExchangeModel::instance()->rowCount()= ?static_cast(method):KeyExchangeModel::Type::NONE); } case Account::Role::RegistrationExpire: setRegistrationExpire(value.toInt()); diff --git a/src/lib/account.h b/src/lib/account.h index 63331c6..d50ce21 100644 --- a/src/lib/account.h +++ b/src/lib/account.h @@ -28,6 +28,7 @@ class QString; //SFLPhone #include "videocodecmodel.h" #include "keyexchangemodel.h" +#include "tlsmethodmodel.h" #include "sflphone_const.h" #include "typedefs.h" // #include "dbus/metatypes.h" @@ -70,8 +71,9 @@ class LIB_EXPORT Account : public QObject { 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(KeyExchangeModel::Type tlsMethod READ tlsMethod = WRITE setTlsMethod ) - Q_PROPERTY(int registrationExpire READ registratio= nExpire WRITE setRegistrationExpire ) + Q_PROPERTY(TlsMethodModel::Type tlsMethod READ tlsMethod = WRITE setTlsMethod ) + Q_PROPERTY(KeyExchangeModel::Type keyExchange READ keyExchange= WRITE setKeyExchange ) + 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 ) @@ -155,7 +157,8 @@ class LIB_EXPORT Account : public QObject { LocalInterface =3D 115, RingtonePath =3D 116, TlsMethod =3D 117, - RegistrationExpire =3D 118, + KeyExchange =3D 190, + RegistrationExpire =3D 118, TlsNegotiationTimeoutSec =3D 119, TlsNegotiationTimeoutMsec =3D 120, LocalPort =3D 121, @@ -282,7 +285,8 @@ class LIB_EXPORT Account : public QObject { DtmfType DTMFType () const; bool presenceStatus () const; QString presenceMessage () const; - KeyExchangeModel::Type tlsMethod () const; + TlsMethodModel::Type tlsMethod () const; + KeyExchangeModel::Type keyExchange () const; QVariant roleData (int role) const; = //Setters @@ -304,7 +308,8 @@ class LIB_EXPORT Account : public QObject { void setPublishedAddress (const QString& detail); void setLocalInterface (const QString& detail); void setRingtonePath (const QString& detail); - void setTlsMethod (KeyExchangeModel::Type detail= ); + void setTlsMethod (TlsMethodModel::Type detail= ); + void setKeyExchange (KeyExchangeModel::Type detail= ); void setRegistrationExpire (int detail); void setTlsNegotiationTimeoutSec (int detail); void setTlsNegotiationTimeoutMsec (int detail); diff --git a/src/lib/accountlistmodel.cpp b/src/lib/accountlistmodel.cpp index a2b3c90..e57824b 100644 --- a/src/lib/accountlistmodel.cpp +++ b/src/lib/accountlistmodel.cpp @@ -346,11 +346,11 @@ Account* AccountListModel::getAccountAt (int i) const ///Get account using its ID Account* AccountListModel::getAccountById(const QString& id) const { - if(id.isEmpty()) - return nullptr; - for (int i =3D 0; i < m_lAccounts.size(); ++i) { - if (!m_lAccounts[i]->isNew() && m_lAccounts[i]->id() =3D=3D id) - return m_lAccounts[i]; + Q_ASSERT(!id.isEmpty()); + for (int i =3D 0; i < m_lAccounts.size(); i++) { + Account* acc =3D m_lAccounts[i]; + if (acc && !acc->isNew() && acc->id() =3D=3D id) + return acc; } return nullptr; } @@ -359,29 +359,14 @@ Account* AccountListModel::getAccountById(const QStri= ng& id) const QVector AccountListModel::getAccountsByState(const QString& stat= e) { QVector v; - for (int i =3D 0; i < m_lAccounts.size(); ++i) { - if (m_lAccounts[i]->registrationStatus() =3D=3D state) - v +=3D m_lAccounts[i]; + for (int i =3D 0; i < m_lAccounts.size(); i++) { + Account* acc =3D m_lAccounts[i]; + if (acc->registrationStatus() =3D=3D state) + v +=3D acc; } return v; } = -///Get a list of all registerred account -QVector AccountListModel::registeredAccounts() const -{ - qDebug() << "registeredAccounts"; - QVector registeredAccountsVector; - Account* current; - for (int i =3D 0; i < m_lAccounts.count(); ++i) { - current =3D m_lAccounts[i]; - if(current->registrationStatus() =3D=3D Account::State::REGISTERED) { - qDebug() << current->alias() << " : " << current; - registeredAccountsVector.append(current); - } - } - return registeredAccountsVector; -} - ///Get the first registerred account (default account) Account* AccountListModel::firstRegisteredAccount() const { diff --git a/src/lib/accountlistmodel.h b/src/lib/accountlistmodel.h index 185a995..bf4aaaa 100644 --- a/src/lib/accountlistmodel.h +++ b/src/lib/accountlistmodel.h @@ -72,7 +72,6 @@ public: Q_INVOKABLE Account* addAccount ( const QString & alias ) = ; Q_INVOKABLE void removeAccount ( Account* account ) = ; void removeAccount ( QModelIndex index ) = ; - QVector registeredAccounts ( ) co= nst; void save ( ) = ; Q_INVOKABLE bool accountUp ( int index ) = ; Q_INVOKABLE bool accountDown ( int index ) = ; diff --git a/src/lib/call.cpp b/src/lib/call.cpp index e0a08f8..3f5d7ba 100644 --- a/src/lib/call.cpp +++ b/src/lib/call.cpp @@ -44,6 +44,7 @@ #include "phonenumber.h" #include "videorenderer.h" #include "historytimecategorymodel.h" +#include "tlsmethodmodel.h" = const TypedStateMachine< TypedStateMachine< Call::State , Call::Action> , = Call::State> Call::actionPerformedStateMap =3D {{ @@ -604,7 +605,7 @@ bool Call::isSecure() const { return false; } = - return m_Account && ((m_Account->isTlsEnable()) || (m_Account->tlsMetho= d() !=3D KeyExchangeModel::Type::NONE)); + return m_Account && ((m_Account->isTlsEnable()) || (m_Account->tlsMetho= d() !=3D TlsMethodModel::Type::DEFAULT)); } //isSecure = ///Return the renderer associated with this call or nullptr diff --git a/src/lib/keyexchangemodel.cpp b/src/lib/keyexchangemodel.cpp index 67938ae..735db10 100644 --- a/src/lib/keyexchangemodel.cpp +++ b/src/lib/keyexchangemodel.cpp @@ -71,7 +71,36 @@ KeyExchangeModel* KeyExchangeModel::instance() } = ///Translate enum type to QModelIndex -QModelIndex KeyExchangeModel::toIndex(KeyExchangeModel::Type type) +QModelIndex KeyExchangeModel::toIndex(KeyExchangeModel::Type type) const { return index(static_cast(type),0,QModelIndex()); } + +///Translate enum to daemon name +const char* KeyExchangeModel::toDaemonName(KeyExchangeModel::Type type) +{ + switch (type) { + case KeyExchangeModel::Type::NONE: + return KeyExchangeModel::DaemonName::NONE; + break; + case KeyExchangeModel::Type::ZRTP: + return KeyExchangeModel::DaemonName::ZRTP; + break; + case KeyExchangeModel::Type::SDES: + return KeyExchangeModel::DaemonName::SDES; + break; + }; + return nullptr; //Cannot heppen +} + +KeyExchangeModel::Type KeyExchangeModel::fromDaemonName(const QString& nam= e) +{ + if (name.isEmpty()) + return KeyExchangeModel::Type::NONE; + else if (name =3D=3D KeyExchangeModel::DaemonName::SDES) + return KeyExchangeModel::Type::SDES; + else if (name =3D=3D KeyExchangeModel::DaemonName::ZRTP) + return KeyExchangeModel::Type::ZRTP; + qDebug() << "Undefined Key exchange mechanism" << name; + return KeyExchangeModel::Type::NONE; +} diff --git a/src/lib/keyexchangemodel.h b/src/lib/keyexchangemodel.h index 2cf9e06..f3a2013 100644 --- a/src/lib/keyexchangemodel.h +++ b/src/lib/keyexchangemodel.h @@ -38,7 +38,14 @@ public: = class Name { public: - constexpr static const char* NONE =3D "none"; + constexpr static const char* NONE =3D "None"; + constexpr static const char* ZRTP =3D "ZRTP"; + constexpr static const char* SDES =3D "SDES"; + }; + + class DaemonName { + public: + constexpr static const char* NONE =3D "" ; constexpr static const char* ZRTP =3D "zrtp"; constexpr static const char* SDES =3D "sdes"; }; @@ -53,7 +60,9 @@ public: virtual bool setData ( const QModelIndex& index, const QVariant &valu= e, int role) ; = //Getters - QModelIndex toIndex (KeyExchangeModel::Type type); + QModelIndex toIndex (KeyExchangeModel::Type typ= e) const; + static const char* toDaemonName (KeyExchangeModel::Type typ= e) ; + static KeyExchangeModel::Type fromDaemonName(const QString& name = ) ; = //Singleton static KeyExchangeModel* instance(); diff --git a/src/lib/tlsmethodmodel.cpp b/src/lib/tlsmethodmodel.cpp new file mode 100644 index 0000000..1e3bd75 --- /dev/null +++ b/src/lib/tlsmethodmodel.cpp @@ -0,0 +1,105 @@ +/*************************************************************************= *** + * 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 "tlsmethodmodel.h" + +#include + +TlsMethodModel* TlsMethodModel::m_spInstance =3D nullptr; + +TlsMethodModel::TlsMethodModel() : QAbstractListModel(QCoreApplication::in= stance()) {} + +//Model functions +QVariant TlsMethodModel::data( const QModelIndex& index, int role) const +{ + if (!index.isValid()) return QVariant(); + TlsMethodModel::Type method =3D static_cast(index= .row()); + if (role =3D=3D Qt::DisplayRole) { + switch (method) { + case TlsMethodModel::Type::DEFAULT: + return TlsMethodModel::Name::DEFAULT; + case TlsMethodModel::Type::TLSv1: + return TlsMethodModel::Name::TLSv1; + case TlsMethodModel::Type::SSLv3: + return TlsMethodModel::Name::SSLv3; + case TlsMethodModel::Type::SSLv23: + return TlsMethodModel::Name::SSLv23; + }; + } + return QVariant(); +} + +int TlsMethodModel::rowCount( const QModelIndex& parent ) const +{ + return parent.isValid()?0:4; +} + +Qt::ItemFlags TlsMethodModel::flags( const QModelIndex& index ) const +{ + if (!index.isValid()) return Qt::NoItemFlags; + return Qt::ItemIsEnabled|Qt::ItemIsSelectable; +} + +bool TlsMethodModel::setData( const QModelIndex& index, const QVariant &va= lue, int role) +{ + Q_UNUSED(index) + Q_UNUSED(value) + Q_UNUSED(role ) + return false; +} + +TlsMethodModel* TlsMethodModel::instance() +{ + if (!m_spInstance) + m_spInstance =3D new TlsMethodModel(); + return m_spInstance; +} + +///Translate enum type to QModelIndex +QModelIndex TlsMethodModel::toIndex(TlsMethodModel::Type type) +{ + return index(static_cast(type),0,QModelIndex()); +} + +const char* TlsMethodModel::toDaemonName(TlsMethodModel::Type type) +{ + switch (type) { + case TlsMethodModel::Type::DEFAULT: + return TlsMethodModel::DaemonName::DEFAULT; + case TlsMethodModel::Type::TLSv1: + return TlsMethodModel::DaemonName::TLSv1; + case TlsMethodModel::Type::SSLv3: + return TlsMethodModel::DaemonName::SSLv3; + case TlsMethodModel::Type::SSLv23: + return TlsMethodModel::DaemonName::SSLv23; + }; + return TlsMethodModel::DaemonName::DEFAULT; +} + +TlsMethodModel::Type TlsMethodModel::fromDaemonName(const QString& name) +{ + if (name.isEmpty() || name =3D=3D TlsMethodModel::DaemonName::DEFAULT) + return TlsMethodModel::Type::DEFAULT; + else if (name =3D=3D TlsMethodModel::DaemonName::TLSv1) + return TlsMethodModel::Type::TLSv1; + else if (name =3D=3D TlsMethodModel::DaemonName::SSLv3) + return TlsMethodModel::Type::SSLv3; + else if (name =3D=3D TlsMethodModel::DaemonName::SSLv23) + return TlsMethodModel::Type::SSLv23; + qDebug() << "Unknown TLS method" << name; + return TlsMethodModel::Type::DEFAULT; +} diff --git a/src/lib/keyexchangemodel.h b/src/lib/tlsmethodmodel.h similarity index 68% copy from src/lib/keyexchangemodel.h copy to src/lib/tlsmethodmodel.h index 2cf9e06..057eb67 100644 --- a/src/lib/keyexchangemodel.h +++ b/src/lib/tlsmethodmodel.h @@ -15,14 +15,14 @@ * 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 +#ifndef TLSMETHODMODEL_H +#define TLSMETHODMODEL_H = #include "typedefs.h" #include = ///Static model for handling encryption types -class LIB_EXPORT KeyExchangeModel : public QAbstractListModel { +class LIB_EXPORT TlsMethodModel : public QAbstractListModel { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" Q_OBJECT @@ -31,20 +31,30 @@ class LIB_EXPORT KeyExchangeModel : public QAbstractLis= tModel { public: ///@enum Type Every supported encryption types enum class Type { - NONE =3D 0, - ZRTP =3D 1, - SDES =3D 2, + DEFAULT =3D 0, + TLSv1 =3D 1, + SSLv3 =3D 2, + SSLv23 =3D 3, }; = class Name { public: - constexpr static const char* NONE =3D "none"; - constexpr static const char* ZRTP =3D "zrtp"; - constexpr static const char* SDES =3D "sdes"; + constexpr static const char* DEFAULT =3D "Default"; + constexpr static const char* TLSv1 =3D "TLSv1" ; + constexpr static const char* SSLv3 =3D "SSLv3" ; + constexpr static const char* SSLv23 =3D "SSLv23" ; + }; + + class DaemonName { + public: + constexpr static const char* DEFAULT =3D "Default"; + constexpr static const char* TLSv1 =3D "TLSv1" ; + constexpr static const char* SSLv3 =3D "SSLv3" ; + constexpr static const char* SSLv23 =3D "SSLv23" ; }; = //Private constructor, can only be called by 'Account' - explicit KeyExchangeModel(); + explicit TlsMethodModel(); = //Model functions QVariant data ( const QModelIndex& index, int role =3D Qt::Dis= playRole ) const; @@ -53,13 +63,15 @@ public: virtual bool setData ( const QModelIndex& index, const QVariant &valu= e, int role) ; = //Getters - QModelIndex toIndex (KeyExchangeModel::Type type); + QModelIndex toIndex (TlsMethodModel::Type type); + static const char* toDaemonName(TlsMethodModel::Type type); + static TlsMethodModel::Type fromDaemonName(const QString& name); = //Singleton - static KeyExchangeModel* instance(); + static TlsMethodModel* instance(); = private: - static KeyExchangeModel* m_spInstance; + static TlsMethodModel* m_spInstance; }; -Q_DECLARE_METATYPE(KeyExchangeModel*) +Q_DECLARE_METATYPE(TlsMethodModel*) #endif diff --git a/src/sflphoneview.cpp b/src/sflphoneview.cpp index b235ad9..35f7018 100644 --- a/src/sflphoneview.cpp +++ b/src/sflphoneview.cpp @@ -23,10 +23,11 @@ //Qt #include #include -#include #include #include #include +#include +#include = //KDE #include @@ -995,37 +996,6 @@ void SFLPhoneView::on_toolButton_sndVol_clicked(bool c= hecked) updateVolumeButton(); } = -///There is a right click menu request -void SFLPhoneView::contextMenuEvent(QContextMenuEvent *event) -{ - KMenu menu(this); - - SFLPhone * window =3D SFLPhone::app(); - QList callActions =3D window->callActions(); - - menu.addAction ( callActions.at((int) SFLPhone::Accept) ); - menu.addAction ( callActions[ SFLPhone::Refuse ] ); - menu.addAction ( callActions[ SFLPhone::Hold ] ); - menu.addAction ( callActions[ SFLPhone::Transfer ] ); - menu.addAction ( callActions[ SFLPhone::Record ] ); - menu.addSeparator(); - - QAction* action =3D new ActionSetAccountFirst(nullptr, &menu); -// action->setChecked(AccountListModel::getPriorAccount() =3D=3D nullpt= r); - connect(action, SIGNAL(setFirst(Account*)), this , SLOT(setAccountFi= rst(Account*))); - menu.addAction(action); - - const QVector accounts =3D AccountListModel::instance()->reg= isteredAccounts(); - for (int i =3D 0 ; i < accounts.size() ; i++) { - Account* account =3D accounts.at(i); - QAction* action =3D new ActionSetAccountFirst(account, &menu); -// action->setChecked(account =3D=3D AccountListModel::getPriorAccou= nt()); - connect(action, SIGNAL(setFirst(Account*)), this , SLOT(setAccountF= irst(Account*))); - menu.addAction(action); - } - menu.exec(event->globalPos()); -} //contextMenuEvent - ///Pick the default account and load it void SFLPhoneView::setAccountFirst(Account * account) { diff --git a/src/sflphoneview.h b/src/sflphoneview.h index 4d41a11..7c4ea38 100644 --- a/src/sflphoneview.h +++ b/src/sflphoneview.h @@ -61,14 +61,6 @@ private: ConferenceDelegate* m_pConfDelegate; HistoryDelegate* m_pHistoryDelegate; = -protected: - - /** - * override context menu handling - * @param event - */ - void contextMenuEvent(QContextMenuEvent *event); - public: //Constructors & Destructors /**