From 9318c487b9b8c5e34a605ab218380907fa6e023d Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 24 Aug 2017 15:53:26 +0200 Subject: [PATCH] [CSE] Display menu for encrytp / decryot folders If the server supports client syde encryption, display a menu on right click that should display encrypt and decrypt. ideally it would show the encrypt if the folder is decrypted, and decrypt if the folder is encrypted but currently there's no way for the client to know that. --- src/gui/accountsettings.cpp | 26 ++++++++++++++++++++++++++ src/gui/folder.h | 2 ++ src/libsync/account.cpp | 9 +++++++++ src/libsync/account.h | 4 ++++ src/libsync/connectionvalidator.cpp | 2 +- 5 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index 23b287244..696a97f0a 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -275,6 +275,23 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos) ac->setEnabled(false); } + qCInfo(lcAccountSettings) << "Display Client Side Encryption Options" + << accountsState()->account()->hasClientSideEncryption(); + + if (accountsState()->account()->hasClientSideEncryption()) { + ac = menu->addAction(tr("Encrypt")); + connect(ac, &QAction::triggered, [this, &index](bool triggered) { + Q_UNUSED(triggered); + + }); + + ac = menu->addAction(tr("Decrypt")); + connect(ac, &QAction::triggered, [this, &index](bool triggered) { + Q_UNUSED(triggered); + + }); + + } menu->exec(QCursor::pos()); return; @@ -701,6 +718,15 @@ void AccountSettings::slotAccountStateChanged() _toggleSignInOutAction->setText(tr("Log out")); } } + + if (state == AccountState::State::Connected) { + /* TODO: We should probably do something better here. + * Verify if the user has a private key already uploaded to the server, + * if it has, do not offer to create one. + */ + qCInfo(lcAccountSettings) << "Accout" << accountsState()->account()->displayName() + << "Client Side Encryption" << accountsState()->account()->hasClientSideEncryption(); + } } void AccountSettings::slotLinkActivated(const QString &link) diff --git a/src/gui/folder.h b/src/gui/folder.h index 7b503a6d6..0ac050c0d 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -62,6 +62,8 @@ public: bool paused; /// whether the folder syncs hidden files bool ignoreHiddenFiles; + /// the folder has client side encryption + bool isClientSideEncrypted; /// Saves the folder definition, creating a new settings group. static void save(QSettings &settings, const FolderDefinition &folder); diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index 0c2e44dbe..dbe8b0019 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -484,5 +484,14 @@ void Account::setNonShib(bool nonShib) } } +bool Account::hasClientSideEncryption() const +{ + return _hasClientSideEncryption; +} + +void Account::setHasClientSideEncryption(bool cse) +{ + _hasClientSideEncryption = cse; +} } // namespace OCC diff --git a/src/libsync/account.h b/src/libsync/account.h index aa1009287..e33d8baac 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -225,6 +225,9 @@ public: /// Called by network jobs on credential errors, emits invalidCredentials() void handleInvalidCredentials(); + bool hasClientSideEncryption() const; + void setHasClientSideEncryption(bool cse); + public slots: /// Used when forgetting credentials void clearQNAMCache(); @@ -275,6 +278,7 @@ private: QSharedPointer _am; QScopedPointer _credentials; bool _http2Supported = false; + bool _hasClientSideEncryption; /// Certificates that were explicitly rejected by the user QList _rejectedCertificates; diff --git a/src/libsync/connectionvalidator.cpp b/src/libsync/connectionvalidator.cpp index 75a2ff23f..c0de1cb6c 100644 --- a/src/libsync/connectionvalidator.cpp +++ b/src/libsync/connectionvalidator.cpp @@ -263,7 +263,7 @@ void ConnectionValidator::checkClientSideEncryption() } } - // _account->setHasClientSideEncryption(hasClientSideEncryption); + _account->setHasClientSideEncryption(hasClientSideEncryption); }); job->start(); } -- 2.30.2