}
}
+
+
ClientSideEncryption::ClientSideEncryption() = default;
void ClientSideEncryption::setAccount(AccountPtr account)
job->start();
}
-void ClientSideEncryption::scheduleFolderEncryptedStatusJob(const QString &path)
-{
- auto getEncryptedStatus = new GetFolderEncryptStatusJob(_account, path, this);
- connect(getEncryptedStatus, &GetFolderEncryptStatusJob::encryptStatusReceived,
- this, &ClientSideEncryption::folderEncryptedStatusFetched);
- connect(getEncryptedStatus, &GetFolderEncryptStatusJob::encryptStatusError,
- this, &ClientSideEncryption::folderEncryptedStatusError);
- getEncryptedStatus->start();
-
- _folderStatusJobs.append(getEncryptedStatus);
-}
-
-void ClientSideEncryption::fetchFolderEncryptedStatus()
-{
- _refreshingEncryptionStatus = true;
- _folder2encryptedStatus.clear();
- scheduleFolderEncryptedStatusJob(QString());
-}
-
-void ClientSideEncryption::folderEncryptedStatusFetched(const QHash<QString, bool>& result)
-{
- auto job = static_cast<GetFolderEncryptStatusJob *>(sender());
- Q_ASSERT(job);
-
- _folderStatusJobs.removeAll(job);
-
- qCDebug(lcCse) << "Retrieved correctly the encrypted status of the folders for" << job->folder() << result;
-
- // FIXME: Can be replaced by _folder2encryptedStatus.insert(result); once we depend on Qt 5.15
- for (auto it = result.constKeyValueBegin(); it != result.constKeyValueEnd(); ++it) {
- _folder2encryptedStatus.insert((*it).first, (*it).second);
- }
-
- for (const auto &folder : result.keys()) {
- if (folder == job->folder()) {
- continue;
- }
- scheduleFolderEncryptedStatusJob(folder);
- }
-
- if (_folderStatusJobs.isEmpty()) {
- _refreshingEncryptionStatus = false;
- emit folderEncryptedStatusFetchDone(_folder2encryptedStatus);
- }
-}
-
-void ClientSideEncryption::folderEncryptedStatusError(int error)
-{
- auto job = static_cast<GetFolderEncryptStatusJob *>(sender());
- Q_ASSERT(job);
-
- qCDebug(lcCse) << "Failed to retrieve the status of the folders for" << job->folder() << error;
-
- _folderStatusJobs.removeAll(job);
-
- if (_folderStatusJobs.isEmpty()) {
- _refreshingEncryptionStatus = false;
- emit folderEncryptedStatusFetchDone(_folder2encryptedStatus);
- }
-}
-
FolderMetadata::FolderMetadata(AccountPtr account, const QByteArray& metadata, int statusCode) : _account(account)
{
if (metadata.isEmpty() || statusCode == 404) {
namespace OCC {
-class GetFolderEncryptStatusJob;
-
QString baseUrl();
namespace EncryptionHelper {
void generateKeyPair();
void generateCSR(EVP_PKEY *keyPair);
void encryptPrivateKey();
- void fetchFolderEncryptedStatus();
void forgetSensitiveData();
void slotRequestMnemonic();
private slots:
- void folderEncryptedStatusFetched(const QHash<QString, bool> &values);
- void folderEncryptedStatusError(int error);
-
void publicKeyFetched(QKeychain::Job *incoming);
void privateKeyFetched(QKeychain::Job *incoming);
void mnemonicKeyFetched(QKeychain::Job *incoming);
void initializationFinished();
void mnemonicGenerated(const QString& mnemonic);
void showMnemonic(const QString& mnemonic);
- void folderEncryptedStatusFetchDone(const QHash<QString, bool> &values);
private:
- void scheduleFolderEncryptedStatusJob(const QString &path);
void getPrivateKeyFromServer();
void getPublicKeyFromServer();
void decryptPrivateKey(const QByteArray &key);
AccountPtr _account;
bool isInitialized = false;
- bool _refreshingEncryptionStatus = false;
- //TODO: Save this on disk.
- QHash<QString, bool> _folder2encryptedStatus;
- QVector<GetFolderEncryptStatusJob*> _folderStatusJobs;
public:
//QSslKey _privateKey;