[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [sflphone-kde] src: [ #30848 ] Make TLS and SRTP feature work again
From: Emmanuel Lepage Vallee <emmanuel.lepage () savoirfairelinux ! com>
Date: 2013-09-30 19:50:52
Message-ID: E1VQjUa-0006P3-32 () scm ! kde ! org
[Download RAW message or body]
Git commit addfbbcde9b67d3c9cc53cad0b1e8ee871fc92ad by Emmanuel Lepage Vallee.
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 = 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(QString)) , this , \
SLOT(changedAccountList()) ); /**/connect(file_tls_private_key, \
SIGNAL(textChanged(QString)) , this , SLOT(changedAccountList()) ); \
/**/connect(combo_tls_method, SIGNAL(currentIndexChanged(int)) , this , \
SLOT(changedAccountList()) ); + /**/connect(combo_security_STRP, \
SIGNAL(currentIndexChanged(int)) , this , SLOT(changedAccountList()) ); \
/**/connect(edit_tls_cipher, SIGNAL(textEdited(QString)) , this , \
SLOT(changedAccountList()) ); /**/connect(edit_tls_outgoing, \
SIGNAL(textEdited(QString)) , 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->text() \
);
- /**/account->setTlsMethod ( \
static_cast<KeyExchangeModel::Type>(combo_tls_method->currentIndex()) ); + /**/account->setTlsMethod \
( static_cast<TlsMethodModel::Type>(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_security_STRP->currentIndex()) \
); + /**/account->setKeyExchange ( \
static_cast<KeyExchangeModel::Type>(combo_security_STRP->currentIndex()) ); \
/**/account->setTlsVerifyServer ( check_tls_incoming->isChecked() \
); /**/account->setTlsVerifyClient ( check_tls_answer->isChecked() \
); /**/account->setTlsRequireClientCertificate ( check_tls_requier_cert->isChecked() \
); @@ -319,7 +322,7 @@ void DlgAccounts::loadAccount(QModelIndex item)
disconnect(this,SLOT(aliasChanged(QString)));
connect(account,SIGNAL(aliasChanged(QString)),this,SLOT(aliasChanged(QString)));
- 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->isTlsRequireClientCertificate ());
/**/group_security_tls->setChecked ( account->isTlsEnable ());
/**/m_pAutoAnswer->setChecked ( account->isAutoAnswer ());
- /**/combo_security_STRP->setCurrentIndex ( \
KeyExchangeModel::instance()->toIndex(account->tlsMethod()).row()); + \
/**/combo_security_STRP->setCurrentIndex ( \
KeyExchangeModel::instance()->toIndex(account->keyExchange()).row()); /* \
*/
m_pDTMFOverRTP->setChecked(account->DTMFType()==DtmfType::OverRtp);
@@ -437,8 +440,7 @@ void DlgAccounts::loadAccount(QModelIndex item)
const QString ringtonePath = KStandardDirs::realFilePath(account->ringtonePath());
m_pRingTonePath->setUrl( ringtonePath );
-
- combo_tls_method->setCurrentIndex( KeyExchangeModel::instance()->toIndex(account->tlsMethod()).row() \
); + combo_tls_method->setCurrentIndex( TlsMethodModel::instance()->toIndex(account->tlsMethod()).row() \
); ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
m_pRingtoneListLW->clear();
@@ -784,22 +786,22 @@ void DlgAccounts::selectedCodecChanged(const QModelIndex& current,const QModelIn
void DlgAccounts::updateCombo(int value)
{
Q_UNUSED(value)
- switch (combo_security_STRP->currentIndex()) {
- case 0: //KEY_EXCHANGE_NONE
+ switch (static_cast<KeyExchangeModel::Type>(combo_security_STRP->currentIndex())) {
+ 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 @@
</size>
</property>
<property name="currentIndex">
- <number>0</number>
+ <number>4</number>
</property>
<widget class="QWidget" name="tab_basic">
<attribute name="title">
@@ -1011,7 +1011,7 @@
<property name="geometry">
<rect>
<x>0</x>
- <y>0</y>
+ <y>-168</y>
<width>539</width>
<height>666</height>
</rect>
@@ -1126,33 +1126,7 @@
</widget>
</item>
<item row="5" column="1" colspan="3">
- <widget class="KComboBox" name="combo_tls_method">
- <item>
- <property name="text">
- <string comment="Default TLS method">Default</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>TLSv1</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>SSLv2</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>SSLv3</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>SSLv23</string>
- </property>
- </item>
- </widget>
+ <widget class="KComboBox" name="combo_tls_method"/>
</item>
<item row="5" column="4" colspan="5">
<spacer name="horizontalSpacer_5">
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 = accountDetail(TLS_METHOD).toInt();
- return value<=2?static_cast<KeyExchangeModel::Type>(value):KeyExchangeModel::Type::NONE;
+ const QString value = accountDetail(TLS_METHOD);
+ return TlsMethodModel::fromDaemonName(value);
+}
+
+///Return the key exchange mechanism
+KeyExchangeModel::Type Account::keyExchange() const
+{
+ return KeyExchangeModel::fromDaemonName(accountDetail(ACCOUNT_KEY_EXCHANGE));
}
///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<int>(detail)));
+ setAccountDetail(ACCOUNT_KEY_EXCHANGE ,KeyExchangeModel::toDaemonName(detail));
}
///Set the account timeout, it will be renegotiated when that timeout occur
@@ -931,7 +944,11 @@ void Account::setRoleData(int role, const QVariant& value)
setRingtonePath(value.toString());
case Account::Role::TlsMethod: {
const int method = value.toInt();
- setTlsMethod(method<=2?static_cast<KeyExchangeModel::Type>(method):KeyExchangeModel::Type::NONE);
+ setTlsMethod(method<=TlsMethodModel::instance()->rowCount()?static_cast<TlsMethodModel::Type>(method):TlsMethodModel::Type::DEFAULT);
+ }
+ case Account::Role::KeyExchange: {
+ const int method = value.toInt();
+ setKeyExchange(method<=KeyExchangeModel::instance()->rowCount()?static_cast<KeyExchangeModel::Type>(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 publishedAddress WRITE \
setPublishedAddress ) Q_PROPERTY(QString localInterface READ \
localInterface WRITE setLocalInterface ) Q_PROPERTY(QString \
ringtonePath READ ringtonePath WRITE setRingtonePath \
)
- Q_PROPERTY(KeyExchangeModel::Type tlsMethod READ tlsMethod WRITE \
setTlsMethod )
- Q_PROPERTY(int registrationExpire READ registrationExpire 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 registrationExpire WRITE setRegistrationExpire ) \
Q_PROPERTY(int tlsNegotiationTimeoutSec READ tlsNegotiationTimeoutSec WRITE \
setTlsNegotiationTimeoutSec ) Q_PROPERTY(int tlsNegotiationTimeoutMsec READ \
tlsNegotiationTimeoutMsec WRITE setTlsNegotiationTimeoutMsec ) Q_PROPERTY(int localPort \
READ localPort WRITE setLocalPort ) @@ -155,7 +157,8 @@ class \
LIB_EXPORT Account : public QObject { LocalInterface = 115,
RingtonePath = 116,
TlsMethod = 117,
- RegistrationExpire = 118,
+ KeyExchange = 190,
+ RegistrationExpire = 118,
TlsNegotiationTimeoutSec = 119,
TlsNegotiationTimeoutMsec = 120,
LocalPort = 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 = 0; i < m_lAccounts.size(); ++i) {
- if (!m_lAccounts[i]->isNew() && m_lAccounts[i]->id() == id)
- return m_lAccounts[i];
+ Q_ASSERT(!id.isEmpty());
+ for (int i = 0; i < m_lAccounts.size(); i++) {
+ Account* acc = m_lAccounts[i];
+ if (acc && !acc->isNew() && acc->id() == id)
+ return acc;
}
return nullptr;
}
@@ -359,29 +359,14 @@ Account* AccountListModel::getAccountById(const QString& id) const
QVector<Account*> AccountListModel::getAccountsByState(const QString& state)
{
QVector<Account *> v;
- for (int i = 0; i < m_lAccounts.size(); ++i) {
- if (m_lAccounts[i]->registrationStatus() == state)
- v += m_lAccounts[i];
+ for (int i = 0; i < m_lAccounts.size(); i++) {
+ Account* acc = m_lAccounts[i];
+ if (acc->registrationStatus() == state)
+ v += acc;
}
return v;
}
-///Get a list of all registerred account
-QVector<Account*> AccountListModel::registeredAccounts() const
-{
- qDebug() << "registeredAccounts";
- QVector<Account*> registeredAccountsVector;
- Account* current;
- for (int i = 0; i < m_lAccounts.count(); ++i) {
- current = m_lAccounts[i];
- if(current->registrationStatus() == 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<Account*> registeredAccounts ( ) const;
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 = {{
@@ -604,7 +605,7 @@ bool Call::isSecure() const {
return false;
}
- return m_Account && ((m_Account->isTlsEnable()) || (m_Account->tlsMethod() != \
KeyExchangeModel::Type::NONE)); + return m_Account && ((m_Account->isTlsEnable()) || \
(m_Account->tlsMethod() != 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<int>(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& name)
+{
+ if (name.isEmpty())
+ return KeyExchangeModel::Type::NONE;
+ else if (name == KeyExchangeModel::DaemonName::SDES)
+ return KeyExchangeModel::Type::SDES;
+ else if (name == 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 = "none";
+ constexpr static const char* NONE = "None";
+ constexpr static const char* ZRTP = "ZRTP";
+ constexpr static const char* SDES = "SDES";
+ };
+
+ class DaemonName {
+ public:
+ constexpr static const char* NONE = "" ;
constexpr static const char* ZRTP = "zrtp";
constexpr static const char* SDES = "sdes";
};
@@ -53,7 +60,9 @@ public:
virtual bool setData ( const QModelIndex& index, const QVariant &value, int role) ;
//Getters
- QModelIndex toIndex (KeyExchangeModel::Type type);
+ QModelIndex toIndex (KeyExchangeModel::Type type) const;
+ static const char* toDaemonName (KeyExchangeModel::Type type) ;
+ 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 <emmanuel.lepage@savoirfairelinux.com> *
+ * *
+ * 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 <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+#include "tlsmethodmodel.h"
+
+#include <QtCore/QCoreApplication>
+
+TlsMethodModel* TlsMethodModel::m_spInstance = nullptr;
+
+TlsMethodModel::TlsMethodModel() : QAbstractListModel(QCoreApplication::instance()) {}
+
+//Model functions
+QVariant TlsMethodModel::data( const QModelIndex& index, int role) const
+{
+ if (!index.isValid()) return QVariant();
+ TlsMethodModel::Type method = static_cast<TlsMethodModel::Type>(index.row());
+ if (role == 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 &value, int role)
+{
+ Q_UNUSED(index)
+ Q_UNUSED(value)
+ Q_UNUSED(role )
+ return false;
+}
+
+TlsMethodModel* TlsMethodModel::instance()
+{
+ if (!m_spInstance)
+ m_spInstance = new TlsMethodModel();
+ return m_spInstance;
+}
+
+///Translate enum type to QModelIndex
+QModelIndex TlsMethodModel::toIndex(TlsMethodModel::Type type)
+{
+ return index(static_cast<int>(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 == TlsMethodModel::DaemonName::DEFAULT)
+ return TlsMethodModel::Type::DEFAULT;
+ else if (name == TlsMethodModel::DaemonName::TLSv1)
+ return TlsMethodModel::Type::TLSv1;
+ else if (name == TlsMethodModel::DaemonName::SSLv3)
+ return TlsMethodModel::Type::SSLv3;
+ else if (name == 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 <http://www.gnu.org/licenses/>. *
***************************************************************************/
-#ifndef KEYEXCHANGEMODEL_H
-#define KEYEXCHANGEMODEL_H
+#ifndef TLSMETHODMODEL_H
+#define TLSMETHODMODEL_H
#include "typedefs.h"
#include <QtCore/QAbstractListModel>
///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 QAbstractListModel {
public:
///@enum Type Every supported encryption types
enum class Type {
- NONE = 0,
- ZRTP = 1,
- SDES = 2,
+ DEFAULT = 0,
+ TLSv1 = 1,
+ SSLv3 = 2,
+ SSLv23 = 3,
};
class Name {
public:
- constexpr static const char* NONE = "none";
- constexpr static const char* ZRTP = "zrtp";
- constexpr static const char* SDES = "sdes";
+ constexpr static const char* DEFAULT = "Default";
+ constexpr static const char* TLSv1 = "TLSv1" ;
+ constexpr static const char* SSLv3 = "SSLv3" ;
+ constexpr static const char* SSLv23 = "SSLv23" ;
+ };
+
+ class DaemonName {
+ public:
+ constexpr static const char* DEFAULT = "Default";
+ constexpr static const char* TLSv1 = "TLSv1" ;
+ constexpr static const char* SSLv3 = "SSLv3" ;
+ constexpr static const char* SSLv23 = "SSLv23" ;
};
//Private constructor, can only be called by 'Account'
- explicit KeyExchangeModel();
+ explicit TlsMethodModel();
//Model functions
QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const;
@@ -53,13 +63,15 @@ public:
virtual bool setData ( const QModelIndex& index, const QVariant &value, 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 <QtCore/QString>
#include <QtCore/QPointer>
-#include <QtGui/QContextMenuEvent>
#include <QtGui/QPalette>
#include <QtGui/QWidget>
#include <QtGui/QClipboard>
+#include <QtGui/QKeyEvent>
+#include <QtGui/QDropEvent>
//KDE
#include <KLocale>
@@ -995,37 +996,6 @@ void SFLPhoneView::on_toolButton_sndVol_clicked(bool checked)
updateVolumeButton();
}
-///There is a right click menu request
-void SFLPhoneView::contextMenuEvent(QContextMenuEvent *event)
-{
- KMenu menu(this);
-
- SFLPhone * window = SFLPhone::app();
- QList<QAction *> callActions = 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 = new ActionSetAccountFirst(nullptr, &menu);
-// action->setChecked(AccountListModel::getPriorAccount() == nullptr);
- connect(action, SIGNAL(setFirst(Account*)), this , SLOT(setAccountFirst(Account*)));
- menu.addAction(action);
-
- const QVector<Account *> accounts = AccountListModel::instance()->registeredAccounts();
- for (int i = 0 ; i < accounts.size() ; i++) {
- Account* account = accounts.at(i);
- QAction* action = new ActionSetAccountFirst(account, &menu);
-// action->setChecked(account == AccountListModel::getPriorAccount());
- connect(action, SIGNAL(setFirst(Account*)), this , SLOT(setAccountFirst(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
/**
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic