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

ciphers: Add 'useDefault' option

Refs #71337
parent 8bc888e4
Branches
Tags
No related merge requests found
...@@ -39,6 +39,7 @@ public: ...@@ -39,6 +39,7 @@ public:
static QVector<QByteArray> m_slSupportedCiphers; static QVector<QByteArray> m_slSupportedCiphers;
static QHash<QString,int> m_shMapping ; static QHash<QString,int> m_shMapping ;
static bool m_sIsLoaded ; static bool m_sIsLoaded ;
bool m_UseDefault ;
static void loadCiphers(); static void loadCiphers();
}; };
...@@ -47,7 +48,7 @@ bool CipherModelPrivate::m_sIsLoaded = false; ...@@ -47,7 +48,7 @@ bool CipherModelPrivate::m_sIsLoaded = false;
QVector<QByteArray> CipherModelPrivate::m_slSupportedCiphers; QVector<QByteArray> CipherModelPrivate::m_slSupportedCiphers;
QHash<QString,int> CipherModelPrivate::m_shMapping; QHash<QString,int> CipherModelPrivate::m_shMapping;
CipherModelPrivate::CipherModelPrivate(Account* parent) : m_pAccount(parent) CipherModelPrivate::CipherModelPrivate(Account* parent) : m_pAccount(parent),m_UseDefault(true)
{ {
if (!CipherModelPrivate::m_sIsLoaded) { if (!CipherModelPrivate::m_sIsLoaded) {
const QStringList cs = DBus::ConfigurationManager::instance().getSupportedCiphers(DRing::Account::ProtocolNames::IP2IP); const QStringList cs = DBus::ConfigurationManager::instance().getSupportedCiphers(DRing::Account::ProtocolNames::IP2IP);
...@@ -60,6 +61,7 @@ CipherModelPrivate::CipherModelPrivate(Account* parent) : m_pAccount(parent) ...@@ -60,6 +61,7 @@ CipherModelPrivate::CipherModelPrivate(Account* parent) : m_pAccount(parent)
foreach(const QString& cipher, parent->d_ptr->accountDetail(DRing::Account::ConfProperties::TLS::CIPHERS).split(' ')) { foreach(const QString& cipher, parent->d_ptr->accountDetail(DRing::Account::ConfProperties::TLS::CIPHERS).split(' ')) {
m_lChecked[m_shMapping[cipher]] = true; m_lChecked[m_shMapping[cipher]] = true;
m_UseDefault = false;
} }
} }
...@@ -133,3 +135,19 @@ bool CipherModel::setData( const QModelIndex& index, const QVariant &value, int ...@@ -133,3 +135,19 @@ bool CipherModel::setData( const QModelIndex& index, const QVariant &value, int
} }
return false; return false;
} }
bool CipherModel::useDefault() const
{
return d_ptr->m_UseDefault;
}
void CipherModel::setUseDefault(bool value)
{
d_ptr->m_UseDefault = value;
if (value) {
for (int i =0; i < d_ptr->m_slSupportedCiphers.size();i++) {
d_ptr->m_lChecked[i] = false;
}
emit dataChanged(index(0,0),index(d_ptr->m_slSupportedCiphers.size()-1,0));
}
}
...@@ -42,6 +42,8 @@ class LIB_EXPORT CipherModel : public QAbstractListModel { ...@@ -42,6 +42,8 @@ class LIB_EXPORT CipherModel : public QAbstractListModel {
public: public:
Q_PROPERTY(bool useDefault READ useDefault WRITE setUseDefault)
//Model functions //Model functions
virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const override; virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const override;
virtual int rowCount ( const QModelIndex& parent = QModelIndex() ) const override; virtual int rowCount ( const QModelIndex& parent = QModelIndex() ) const override;
...@@ -49,6 +51,12 @@ public: ...@@ -49,6 +51,12 @@ public:
virtual bool setData ( const QModelIndex& index, const QVariant &value, int role) override; virtual bool setData ( const QModelIndex& index, const QVariant &value, int role) override;
virtual QHash<int,QByteArray> roleNames() const override; virtual QHash<int,QByteArray> roleNames() const override;
//Getter
bool useDefault() const;
//Setter
void setUseDefault(bool value);
private: private:
//Private constructor, can only be called by 'Account' //Private constructor, can only be called by 'Account'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment