From 0fe26da113ab89d8d76dd0358f12f038b00a8f04 Mon Sep 17 00:00:00 2001
From: Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com>
Date: Fri, 3 Jul 2015 18:21:02 -0400
Subject: [PATCH] cipher: Fix deserialization

A line of code was downright missing

This commit also update account rolestates to disable
more settings (including ciphers) for Ring-DHT accounts

Refs #76885

Change-Id: Ic3d64f5e7db752cdc98cbdf39655b0e7863afe09
---
 src/account.cpp     |  6 +++++-
 src/ciphermodel.cpp | 18 ++++++++++--------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/account.cpp b/src/account.cpp
index 40730b3c..2f658454 100644
--- a/src/account.cpp
+++ b/src/account.cpp
@@ -1998,8 +1998,12 @@ Account::RoleState Account::roleState(Account::Role role) const
             case Account::Role::HasCustomUserAgent:
             case Account::Role::HasProxy          :
             case Account::Role::Proxy             :
+            case Account::Role::CipherModel       :
                return Account::RoleState::UNAVAILABLE;
-            case Account::Role::Username          :
+            case Account::Role::Username                :
+            case Account::Role::TlsCaListCertificate    :
+            case Account::Role::TlsCertificate          :
+            case Account::Role::TlsPrivateKeyCertificate:
                return Account::RoleState::READ_ONLY;
             default:
                break;
diff --git a/src/ciphermodel.cpp b/src/ciphermodel.cpp
index 6a347fc9..409e18b9 100644
--- a/src/ciphermodel.cpp
+++ b/src/ciphermodel.cpp
@@ -34,26 +34,28 @@ public:
    ~CipherModelPrivate();
 
    //Attributes
-   bool*                      m_lChecked          ;
-   Account*                   m_pAccount          ;
-   static QVector<QByteArray> m_slSupportedCiphers;
-   static QHash<QString,int>  m_shMapping         ;
-   static bool                m_sIsLoaded         ;
-   bool                       m_UseDefault        ;
+   bool*                            m_lChecked          ;
+   Account*                         m_pAccount          ;
+   static QVector<QByteArray>       m_slSupportedCiphers;
+   static QHash<const QString,int>  m_shMapping         ;
+   static bool                      m_sIsLoaded         ;
+   bool                             m_UseDefault        ;
 
    static void loadCiphers();
 };
 
 bool CipherModelPrivate::m_sIsLoaded = false;
 QVector<QByteArray> CipherModelPrivate::m_slSupportedCiphers;
-QHash<QString,int>  CipherModelPrivate::m_shMapping;
+QHash<const QString,int>  CipherModelPrivate::m_shMapping;
 
 CipherModelPrivate::CipherModelPrivate(Account* parent) : m_pAccount(parent),m_UseDefault(true)
 {
    if (!CipherModelPrivate::m_sIsLoaded) {
       const QStringList cs = DBus::ConfigurationManager::instance().getSupportedCiphers(DRing::Account::ProtocolNames::IP2IP);
-      foreach(const QString& c, cs)
+      foreach(const QString& c, cs) {
+         m_shMapping[c] = m_slSupportedCiphers.size();
          m_slSupportedCiphers << c.toLatin1();
+      }
       m_sIsLoaded = true;
    }
 
-- 
GitLab