diff --git a/src/account.cpp b/src/account.cpp index 4383ce95ea1fda71ce9781eac70c5f1c246d95aa..8a2741f020a4d73ebc709520a36fea52f554b8d4 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -68,8 +68,9 @@ const account_function AccountPrivate::stateMachineActionsOnState[6][7] = { AccountPrivate::AccountPrivate(Account* acc) : QObject(acc),q_ptr(acc),m_pCredentials(nullptr),m_pAudioCodecs(nullptr), m_pVideoCodecs(nullptr),m_LastErrorCode(-1),m_VoiceMailCount(0),m_pRingToneModel(nullptr), m_CurrentState(Account::EditState::READY), -m_pAccountNumber(nullptr),m_pKeyExchangeModel(nullptr),m_pSecurityValidationModel(nullptr),m_pCaCert(nullptr),m_pTlsCert(nullptr), -m_pPrivateKey(nullptr),m_isLoaded(true),m_pCipherModel(nullptr),m_pStatusModel(nullptr),m_LastTransportCode(0) +m_pAccountNumber(nullptr),m_pKeyExchangeModel(nullptr),m_pSecurityValidationModel(nullptr),m_pTlsMethodModel(nullptr), +m_pCaCert(nullptr),m_pTlsCert(nullptr),m_pPrivateKey(nullptr),m_isLoaded(true),m_pCipherModel(nullptr), +m_pStatusModel(nullptr),m_LastTransportCode(0) { Q_Q(Account); } @@ -378,6 +379,14 @@ SecurityValidationModel* Account::securityValidationModel() const return d_ptr->m_pSecurityValidationModel; } +TlsMethodModel* Account::tlsMethodModel() const +{ + if (!d_ptr->m_pTlsMethodModel ) { + d_ptr->m_pTlsMethodModel = new TlsMethodModel(const_cast<Account*>(this)); + } + return d_ptr->m_pTlsMethodModel; +} + void Account::setAlias(const QString& detail) { const bool accChanged = detail != alias(); @@ -594,13 +603,6 @@ bool Account::isTlsEnabled() const return (d_ptr->accountDetail(DRing::Account::ConfProperties::TLS::ENABLED) IS_TRUE); } -///Return the account the TLS encryption method -TlsMethodModel::Type Account::tlsMethod() const -{ - const QString value = d_ptr->accountDetail(DRing::Account::ConfProperties::TLS::METHOD); - return TlsMethodModel::fromDaemonName(value); -} - ///Return the key exchange mechanism KeyExchangeModel::Type Account::keyExchange() const { @@ -788,8 +790,6 @@ QVariant Account::roleData(int role) const return localInterface(); case Account::Role::RingtonePath: return ringtonePath(); - case Account::Role::TlsMethod: - return static_cast<int>(tlsMethod()); case Account::Role::RegistrationExpire: return registrationExpire(); case Account::Role::TlsNegotiationTimeoutSec: @@ -1028,12 +1028,6 @@ void Account::setLastErrorCode(int code) d_ptr->m_LastErrorCode = code; } -///Set the Tls method -void Account::setTlsMethod(TlsMethodModel::Type detail) -{ - d_ptr->setAccountProperty(DRing::Account::ConfProperties::TLS::METHOD ,TlsMethodModel::toDaemonName(detail)); -} - ///Set the Tls method void Account::setKeyExchange(KeyExchangeModel::Type detail) { @@ -1289,11 +1283,6 @@ void Account::setRoleData(int role, const QVariant& value) case Account::Role::RingtonePath: setRingtonePath(value.toString()); break; - case Account::Role::TlsMethod: { - const int method = value.toInt(); - setTlsMethod(method<=TlsMethodModel::instance()->rowCount()?static_cast<TlsMethodModel::Type>(method):TlsMethodModel::Type::DEFAULT); - break; - } case Account::Role::KeyExchange: { const int method = value.toInt(); setKeyExchange(method<=keyExchangeModel()->rowCount()?static_cast<KeyExchangeModel::Type>(method):KeyExchangeModel::Type::NONE); diff --git a/src/account.h b/src/account.h index 14277c564dc319671051d4de9e7e04d4187a4ac6..0df58fcd995e198d80607af51c4676dbf8d62c69 100644 --- a/src/account.h +++ b/src/account.h @@ -33,7 +33,7 @@ class QString; #include "typedefs.h" class CredentialModel ; class RingToneModel ; -class ContactMethod ; +class ContactMethod ; class SecurityValidationModel; class Certificate ; class CipherModel ; @@ -64,6 +64,7 @@ class LIB_EXPORT Account : public QObject { Q_OBJECT #pragma GCC diagnostic pop + //The account class delegate all properties part of "sets" to children models friend class AccountModel; friend class AccountModelPrivate; friend class AccountPlaceHolder; @@ -71,6 +72,8 @@ class LIB_EXPORT Account : public QObject { friend class CipherModel; friend class AccountStatusModelPrivate; friend class AccountStatusModel; + friend class TlsMethodModelPrivate; + friend class TlsMethodModel; //Properties Q_PROPERTY(QString alias READ alias WRITE setAlias ) @@ -89,7 +92,6 @@ class LIB_EXPORT Account : public QObject { Q_PROPERTY(QString localInterface READ localInterface WRITE setLocalInterface ) Q_PROPERTY(QString ringtonePath READ ringtonePath WRITE setRingtonePath ) Q_PROPERTY(QString lastErrorMessage READ lastErrorMessage WRITE setLastErrorMessage ) - Q_PROPERTY(TlsMethodModel::Type tlsMethod READ tlsMethod WRITE setTlsMethod ) Q_PROPERTY(KeyExchangeModel::Type keyExchange READ keyExchange WRITE setKeyExchange ) Q_PROPERTY(int lastErrorCode READ lastErrorCode WRITE setLastErrorCode ) Q_PROPERTY(int registrationExpire READ registrationExpire WRITE setRegistrationExpire ) @@ -182,7 +184,6 @@ class LIB_EXPORT Account : public QObject { PublishedAddress = 114, LocalInterface = 115, RingtonePath = 116, - TlsMethod = 117, KeyExchange = 190, RegistrationExpire = 118, TlsNegotiationTimeoutSec = 119, @@ -251,6 +252,7 @@ class LIB_EXPORT Account : public QObject { Q_INVOKABLE CipherModel* cipherModel () const; Q_INVOKABLE AccountStatusModel* statusModel () const; Q_INVOKABLE SecurityValidationModel* securityValidationModel() const; + Q_INVOKABLE TlsMethodModel* tlsMethodModel () const; //Getters QString hostname () const; @@ -306,7 +308,6 @@ class LIB_EXPORT Account : public QObject { QString lastTransportErrorMessage () const; QString userAgent () const; Account::Protocol protocol () const; - TlsMethodModel::Type tlsMethod () const; KeyExchangeModel::Type keyExchange () const; QVariant roleData (int role) const; @@ -329,7 +330,6 @@ class LIB_EXPORT Account : public QObject { void setLocalInterface (const QString& detail ); void setRingtonePath (const QString& detail ); void setLastErrorMessage (const QString& message ); - void setTlsMethod (TlsMethodModel::Type detail); void setKeyExchange (KeyExchangeModel::Type detail); void setLastErrorCode (int code ); void setVoiceMailCount (int count ); diff --git a/src/accountmodel.cpp b/src/accountmodel.cpp index 7c18b2f24347c92a480d790bfca8e693d7546aad..0a524cb358bed5c95a59c1709fff7d6213cd8919 100644 --- a/src/accountmodel.cpp +++ b/src/accountmodel.cpp @@ -94,7 +94,7 @@ void AccountModelPrivate::init() connect(&callManager , SIGNAL(voiceMailNotify(QString,int)) ,this , SLOT(slotVoiceMailNotify(QString,int)) ); connect(&configurationManager, SIGNAL(volatileAccountDetailsChanged(QString,MapStringString)),this, - SLOT(slotVolatileAccountDetailsChange(QString,int))); + SLOT(slotVolatileAccountDetailsChange(QString,MapStringString))); } @@ -130,7 +130,6 @@ QHash<int,QByteArray> AccountModel::roleNames() const roles.insert(Account::Role::PublishedAddress ,QByteArray("publishedAddress" )); roles.insert(Account::Role::LocalInterface ,QByteArray("localInterface" )); roles.insert(Account::Role::RingtonePath ,QByteArray("ringtonePath" )); - roles.insert(Account::Role::TlsMethod ,QByteArray("tlsMethod" )); roles.insert(Account::Role::RegistrationExpire ,QByteArray("registrationExpire" )); roles.insert(Account::Role::TlsNegotiationTimeoutSec ,QByteArray("tlsNegotiationTimeoutSec" )); roles.insert(Account::Role::TlsNegotiationTimeoutMsec,QByteArray("tlsNegotiationTimeoutMsec" )); diff --git a/src/audio/managermodel.cpp b/src/audio/managermodel.cpp index 72981a2560421d182ab5f2e31faa34f15b61a160..39cbed3322f7826e53f2e847879a1bc5cdfc2dce 100644 --- a/src/audio/managermodel.cpp +++ b/src/audio/managermodel.cpp @@ -17,6 +17,9 @@ ***************************************************************************/ #include "managermodel.h" +//Qt +#include <QtCore/QItemSelectionModel> + //Ring #include "dbus/configurationmanager.h" #include "settings.h" @@ -35,14 +38,19 @@ public: QStringList m_lDeviceList; QList<Audio::ManagerModel::Manager> m_lSupportedManagers; + mutable QItemSelectionModel* m_pSelectionModel; private: Audio::ManagerModel* q_ptr; + +public Q_SLOTS: + void slotSelectionChanged(const QModelIndex& idx); }; -ManagerModelPrivate::ManagerModelPrivate(Audio::ManagerModel* parent) : q_ptr(parent) +ManagerModelPrivate::ManagerModelPrivate(Audio::ManagerModel* parent) : q_ptr(parent), + m_pSelectionModel(nullptr) { - + } ///Constructor @@ -123,62 +131,61 @@ bool Audio::ManagerModel::setData( const QModelIndex& index, const QVariant &val } /** - * Return the current audio manager - * @warning Changes to the current index model will invalid Input/Output/Ringtone devices models + * This model allow automatic synchronisation of the audio manager */ -QModelIndex Audio::ManagerModel::currentManagerIndex() const +QItemSelectionModel* Audio::ManagerModel::selectionModel() const { - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - const QString manager = configurationManager.getAudioManager(); + if (!d_ptr->m_pSelectionModel) { + d_ptr->m_pSelectionModel = new QItemSelectionModel(const_cast<Audio::ManagerModel*>(this)); + connect(d_ptr->m_pSelectionModel,&QItemSelectionModel::currentChanged,d_ptr.data(),&ManagerModelPrivate::slotSelectionChanged); + + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + const QString manager = configurationManager.getAudioManager(); + if (manager == ManagerModelPrivate::ManagerName::PULSEAUDIO) - return index((int)Manager::PULSE,0); + d_ptr->m_pSelectionModel->setCurrentIndex( index((int)Manager::PULSE,0) , QItemSelectionModel::ClearAndSelect ); else if (manager == ManagerModelPrivate::ManagerName::ALSA) - return index((int)Manager::ALSA,0); + d_ptr->m_pSelectionModel->setCurrentIndex( index((int)Manager::ALSA,0) , QItemSelectionModel::ClearAndSelect ); else if (manager == ManagerModelPrivate::ManagerName::JACK) - return index((int)Manager::JACK,0); - return QModelIndex(); -} + d_ptr->m_pSelectionModel->setCurrentIndex( index((int)Manager::JACK,0) , QItemSelectionModel::ClearAndSelect ); + } -Audio::ManagerModel::Manager Audio::ManagerModel::currentManager() const -{ - return d_ptr->m_lSupportedManagers[currentManagerIndex().row()]; + return d_ptr->m_pSelectionModel; } -///Set current audio manager -bool Audio::ManagerModel::setCurrentManager(const QModelIndex& idx) +void ManagerModelPrivate::slotSelectionChanged(const QModelIndex& idx) { if (!idx.isValid()) - return false; + return; bool ret = true; ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - switch (d_ptr->m_lSupportedManagers[idx.row()]) { - case Manager::PULSE: + switch (m_lSupportedManagers[idx.row()]) { + case Audio::ManagerModel::Manager::PULSE: ret = configurationManager.setAudioManager(ManagerModelPrivate::ManagerName::PULSEAUDIO); Audio::Settings::instance()->reload(); break; - case Manager::ALSA: + case Audio::ManagerModel::Manager::ALSA: ret = configurationManager.setAudioManager(ManagerModelPrivate::ManagerName::ALSA); Audio::Settings::instance()->reload(); break; - case Manager::JACK: + case Audio::ManagerModel::Manager::JACK: ret = configurationManager.setAudioManager(ManagerModelPrivate::ManagerName::JACK); Audio::Settings::instance()->reload(); break; + case Audio::ManagerModel::Manager::ERROR: + break; }; if (!ret) { - const QModelIndex& newIdx = currentManagerIndex(); - emit currentManagerChanged(currentManager()); - emit currentManagerChanged(newIdx); - emit currentManagerChanged(newIdx.row()); + emit q_ptr->currentManagerChanged(q_ptr->currentManager()); } - return ret; + return; } -///QCombobox -> QModelIndex shim -bool Audio::ManagerModel::setCurrentManager(int idx) +Audio::ManagerModel::Manager Audio::ManagerModel::currentManager() const { - return setCurrentManager(index(idx,0)); + const int idx = selectionModel()->currentIndex().row(); + return idx>=0 ? d_ptr->m_lSupportedManagers[idx] : Manager::ERROR; } #include <managermodel.moc> diff --git a/src/audio/managermodel.h b/src/audio/managermodel.h index 40217217d407d7f7175beb90c3f920cdf19bf9d9..df60347fe66edab9b614b46f983ee33421eae068 100644 --- a/src/audio/managermodel.h +++ b/src/audio/managermodel.h @@ -22,6 +22,7 @@ //Qt #include <QtCore/QStringList> +class QItemSelectionModel; //Ring #include "../typedefs.h" @@ -38,6 +39,7 @@ public: ALSA =0, PULSE=1, JACK =2, + ERROR=3, }; explicit ManagerModel(const QObject* parent); virtual ~ManagerModel(); @@ -50,19 +52,11 @@ public: virtual QHash<int,QByteArray> roleNames() const override; //Getters - QModelIndex currentManagerIndex() const; - Manager currentManager() const; - - //Setters - bool setCurrentManager(const QModelIndex& index); - -public Q_SLOTS: - bool setCurrentManager(int idx); + QItemSelectionModel* selectionModel() const; + Manager currentManager() const; Q_SIGNALS: void currentManagerChanged(Manager); - void currentManagerChanged(int); - void currentManagerChanged(const QModelIndex&); private: QScopedPointer<ManagerModelPrivate> d_ptr; diff --git a/src/call.cpp b/src/call.cpp index 48f8652fff930b44eefaba805cb912f03d252ae5..c927f8f4be6d3737db11959756bef8c3503cc69d 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -769,12 +769,14 @@ Call::LegacyHistoryState Call::historyState() const bool Call::isSecure() const { - if (!d_ptr->m_Account) { + /*if (!d_ptr->m_Account) { qDebug() << "Account not set, can't check security"; return false; } //BUG this doesn't work - return d_ptr->m_Account && ((d_ptr->m_Account->isTlsEnabled()) || (d_ptr->m_Account->tlsMethod() != TlsMethodModel::Type::DEFAULT)); + return d_ptr->m_Account && ((d_ptr->m_Account->isTlsEnabled()) || (d_ptr->m_Account->tlsMethod() != TlsMethodModel::Type::DEFAULT));*/ + + return false; //No, it is not and cannot be } //isSecure ///Return the renderer associated with this call or nullptr diff --git a/src/private/account_p.h b/src/private/account_p.h index 0276e0c61f94934496417bb7cf111e0f1d301302..947a6c6d0f939c8fe241b238647b23043d1cc1f0 100644 --- a/src/private/account_p.h +++ b/src/private/account_p.h @@ -26,6 +26,7 @@ class AccountPrivate; class ContactMethod; class CipherModel; class AccountStatusModel; +class TlsMethodModel; typedef void (AccountPrivate::*account_function)(); @@ -48,6 +49,8 @@ public: friend class CipherModel; friend class AccountStatusModelPrivate; friend class AccountStatusModel; + friend class TlsMethodModelPrivate; + friend class TlsMethodModel; //Constructor AccountPrivate(Account* acc); @@ -98,6 +101,7 @@ public: CipherModel* m_pCipherModel ; AccountStatusModel* m_pStatusModel ; SecurityValidationModel* m_pSecurityValidationModel; + TlsMethodModel* m_pTlsMethodModel ; Account::EditState m_CurrentState; // State machines diff --git a/src/tlsmethodmodel.cpp b/src/tlsmethodmodel.cpp index 00936a01950b8f787ea2b8583710a23e93e5126d..bf7f589aa75bc1d7799c2c85b90029303ecdca1e 100644 --- a/src/tlsmethodmodel.cpp +++ b/src/tlsmethodmodel.cpp @@ -17,19 +17,58 @@ ***************************************************************************/ #include "tlsmethodmodel.h" +//Qt #include <QtCore/QCoreApplication> +#include <QtCore/QItemSelectionModel> -TlsMethodModel* TlsMethodModel::m_spInstance = nullptr; +//Ring daemon +#include <account_const.h> -const char* TlsMethodModel::Name::DEFAULT = qPrintable(tr("Default", "Default TLS protocol version")); +//Ring +#include <account.h> +#include <private/account_p.h> class TlsMethodModelPrivate : public QObject { Q_OBJECT public: + + TlsMethodModelPrivate(Account* a); + + class Name { + public: + static const QString 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" ; + }; + + static const char* toDaemonName(TlsMethodModel::Type type); + static TlsMethodModel::Type fromDaemonName(const QString& name); + + mutable QItemSelectionModel* m_pSelectionModel; + Account* m_pAccount; + +public Q_SLOTS: + void slotSelectionChanged(const QModelIndex& idx); }; -TlsMethodModel::TlsMethodModel() : QAbstractListModel(QCoreApplication::instance()), -d_ptr(new TlsMethodModelPrivate()) +const QString TlsMethodModelPrivate::Name::DEFAULT = tr("Default", "Default TLS protocol version"); + +TlsMethodModelPrivate::TlsMethodModelPrivate(Account* a) : m_pSelectionModel(nullptr), m_pAccount(a) +{ + +} + +TlsMethodModel::TlsMethodModel(Account* a) : QAbstractListModel(QCoreApplication::instance()), +d_ptr(new TlsMethodModelPrivate(a)) { } @@ -53,13 +92,13 @@ QVariant TlsMethodModel::data( const QModelIndex& index, int role) const if (role == Qt::DisplayRole) { switch (method) { case TlsMethodModel::Type::DEFAULT: - return TlsMethodModel::Name::DEFAULT; + return TlsMethodModelPrivate::Name::DEFAULT; case TlsMethodModel::Type::TLSv1: - return TlsMethodModel::Name::TLSv1; + return TlsMethodModelPrivate::Name::TLSv1; case TlsMethodModel::Type::SSLv3: - return TlsMethodModel::Name::SSLv3; + return TlsMethodModelPrivate::Name::SSLv3; case TlsMethodModel::Type::SSLv23: - return TlsMethodModel::Name::SSLv23; + return TlsMethodModelPrivate::Name::SSLv23; }; } return QVariant(); @@ -84,45 +123,61 @@ bool TlsMethodModel::setData( const QModelIndex& index, const QVariant &value, i return false; } -TlsMethodModel* TlsMethodModel::instance() +///Translate enum type to QModelIndex +QModelIndex TlsMethodModel::toIndex(TlsMethodModel::Type type) const { - if (!m_spInstance) - m_spInstance = new TlsMethodModel(); - return m_spInstance; + return index(static_cast<int>(type),0,QModelIndex()); } -///Translate enum type to QModelIndex -QModelIndex TlsMethodModel::toIndex(TlsMethodModel::Type type) +QItemSelectionModel* TlsMethodModel::selectionModel() const { - return index(static_cast<int>(type),0,QModelIndex()); + if (!d_ptr->m_pSelectionModel) { + d_ptr->m_pSelectionModel = new QItemSelectionModel(const_cast<TlsMethodModel*>(this)); + const QString value = d_ptr->m_pAccount->d_ptr->accountDetail(DRing::Account::ConfProperties::TLS::METHOD); + const QModelIndex& idx = toIndex(TlsMethodModelPrivate::fromDaemonName(value)); + d_ptr->m_pSelectionModel->setCurrentIndex(idx,QItemSelectionModel::ClearAndSelect); + + connect(d_ptr->m_pSelectionModel,&QItemSelectionModel::currentChanged,d_ptr,&TlsMethodModelPrivate::slotSelectionChanged); + } + + return d_ptr->m_pSelectionModel; +} + +void TlsMethodModelPrivate::slotSelectionChanged(const QModelIndex& idx) +{ + if (!idx.isValid()) + return; + + const char* value = toDaemonName(static_cast<TlsMethodModel::Type>(idx.row())); + m_pAccount->d_ptr->setAccountProperty(DRing::Account::ConfProperties::TLS::METHOD , value); } ///Convert a TlsMethodModel::Type enum to the string expected by the daemon API -const char* TlsMethodModel::toDaemonName(TlsMethodModel::Type type) +const char* TlsMethodModelPrivate::toDaemonName(TlsMethodModel::Type type) { switch (type) { case TlsMethodModel::Type::DEFAULT: - return TlsMethodModel::DaemonName::DEFAULT; + return TlsMethodModelPrivate::DaemonName::DEFAULT; case TlsMethodModel::Type::TLSv1: - return TlsMethodModel::DaemonName::TLSv1; + return TlsMethodModelPrivate::DaemonName::TLSv1; case TlsMethodModel::Type::SSLv3: - return TlsMethodModel::DaemonName::SSLv3; + return TlsMethodModelPrivate::DaemonName::SSLv3; case TlsMethodModel::Type::SSLv23: - return TlsMethodModel::DaemonName::SSLv23; + return TlsMethodModelPrivate::DaemonName::SSLv23; }; - return TlsMethodModel::DaemonName::DEFAULT; + return TlsMethodModelPrivate::DaemonName::DEFAULT; } ///Convert a Daemon API string to a TlsMethodModel::Type enum -TlsMethodModel::Type TlsMethodModel::fromDaemonName(const QString& name) +TlsMethodModel::Type TlsMethodModelPrivate::fromDaemonName(const QString& name) { - if (name.isEmpty() || name == TlsMethodModel::DaemonName::DEFAULT) + if (name.isEmpty() || name == TlsMethodModelPrivate::DaemonName::DEFAULT) return TlsMethodModel::Type::DEFAULT; - else if (name == TlsMethodModel::DaemonName::TLSv1) + else if (name == TlsMethodModelPrivate::DaemonName::TLSv1) return TlsMethodModel::Type::TLSv1; - else if (name == TlsMethodModel::DaemonName::SSLv3) + else if (name == TlsMethodModelPrivate::DaemonName::SSLv3) return TlsMethodModel::Type::SSLv3; - else if (name == TlsMethodModel::DaemonName::SSLv23) + else if (name == TlsMethodModelPrivate::DaemonName::SSLv23) return TlsMethodModel::Type::SSLv23; qDebug() << "Unknown TLS method" << name; return TlsMethodModel::Type::DEFAULT; diff --git a/src/tlsmethodmodel.h b/src/tlsmethodmodel.h index 03c28190abc3b6dbadd0147e0712f1e8f87df789..11a91213c16d5494f5c78217333752d7a713ab4b 100644 --- a/src/tlsmethodmodel.h +++ b/src/tlsmethodmodel.h @@ -21,10 +21,15 @@ #include "typedefs.h" #include <QtCore/QAbstractListModel> +//Qt +class QItemSelectionModel; + +//Ring class TlsMethodModelPrivate; +class Account; /**Static model for handling encryption types - * + * * This model can be used as a bridge between the Daemon API name (strings) * and combobox indexes. It can also be used to translate "default" to the * user locales @@ -44,24 +49,8 @@ public: SSLv23 = 3, }; - class Name { - public: - static const char* 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 TlsMethodModel(); + explicit TlsMethodModel(Account* a); //Model functions virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const override; @@ -71,16 +60,10 @@ public: virtual QHash<int,QByteArray> roleNames() const override; //Getters - QModelIndex toIndex (TlsMethodModel::Type type); - static const char* toDaemonName(TlsMethodModel::Type type); - static TlsMethodModel::Type fromDaemonName(const QString& name); - - //Singleton - static TlsMethodModel* instance(); + QModelIndex toIndex (TlsMethodModel::Type type) const; + QItemSelectionModel* selectionModel() const; private: - static TlsMethodModel* m_spInstance; - TlsMethodModelPrivate* d_ptr; Q_DECLARE_PRIVATE(TlsMethodModel);