1 /*
2  * Copyright (C) by Kevin Ottens <kevin.ottens@nextcloud.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12  * for more details.
13  */
14 #pragma once
15 
16 #include <QObject>
17 
18 #include "account.h"
19 
20 namespace OCC {
21 class SyncJournalDb;
22 
23 class OWNCLOUDSYNC_EXPORT EncryptFolderJob : public QObject
24 {
25     Q_OBJECT
26 public:
27     enum Status {
28         Success = 0,
29         Error,
30     };
31     Q_ENUM(Status)
32 
33     explicit EncryptFolderJob(const AccountPtr &account, SyncJournalDb *journal, const QString &path, const QByteArray &fileId, QObject *parent = nullptr);
34     void start();
35 
36     QString errorString() const;
37 
38 signals:
39     void finished(int status);
40 
41 private slots:
42     void slotEncryptionFlagSuccess(const QByteArray &folderId);
43     void slotEncryptionFlagError(const QByteArray &folderId, int httpReturnCode);
44     void slotLockForEncryptionSuccess(const QByteArray &folderId, const QByteArray &token);
45     void slotLockForEncryptionError(const QByteArray &folderId, int httpReturnCode);
46     void slotUnlockFolderSuccess(const QByteArray &folderId);
47     void slotUnlockFolderError(const QByteArray &folderId, int httpReturnCode);
48     void slotUploadMetadataSuccess(const QByteArray &folderId);
49     void slotUpdateMetadataError(const QByteArray &folderId, int httpReturnCode);
50 
51 private:
52     AccountPtr _account;
53     SyncJournalDb *_journal;
54     QString _path;
55     QByteArray _fileId;
56     QByteArray _folderToken;
57     QString _errorString;
58 };
59 }
60