Przeglądaj źródła

[CSE] Move the e2e object to the Account

This is important as a lot of the code would start
to rely in direct access to the client side encryption
and there are different keys for different accounts.
Tomaz Canabrava 8 lat temu
rodzic
commit
a0f0e5617a

+ 9 - 0
src/libsync/account.cpp

@@ -50,9 +50,18 @@ AccountPtr Account::create()
 {
     AccountPtr acc = AccountPtr(new Account);
     acc->setSharedThis(acc);
+
+		//TODO: This probably needs to have a better
+		// coupling, but it should work for now.
+		acc->e2e().setAccount(acc);
     return acc;
 }
 
+ClientSideEncryption& Account::e2e()
+{
+	return _e2e;
+}
+
 Account::~Account()
 {
 }

+ 4 - 0
src/libsync/account.h

@@ -226,6 +226,8 @@ public:
     /// Called by network jobs on credential errors, emits invalidCredentials()
     void handleInvalidCredentials();
 
+		ClientSideEncryption& e2e();
+
 public slots:
     /// Used when forgetting credentials
     void clearQNAMCache();
@@ -283,6 +285,8 @@ private:
     static QString _configFileName;
 
     QString _davPath; // defaults to value from theme, might be overwritten in brandings
+    ClientSideEncryption _e2e;
+
     friend class AccountManager;
 };
 }

+ 2 - 3
src/libsync/connectionvalidator.cpp

@@ -326,9 +326,8 @@ void ConnectionValidator::slotUserFetched(const QJsonDocument &json)
 void ConnectionValidator::slotAvatarImage(const QImage &img)
 {
     _account->setAvatar(img);
-    cse.setAccount(_account);
-    connect(&cse, &ClientSideEncryption::initializationFinished, this, &ConnectionValidator::reportConnected);
-    cse.initialize();
+    connect(&_account->e2e(), &ClientSideEncryption::initializationFinished, this, &ConnectionValidator::reportConnected);
+    _account->e2e().initialize();
 }
 
 void ConnectionValidator::reportConnected() {

+ 0 - 1
src/libsync/connectionvalidator.h

@@ -144,7 +144,6 @@ private:
     QStringList _errors;
     AccountPtr _account;
     bool _isCheckingServerAndAuth;
-    ClientSideEncryption cse;
 };
 }