tgpg.h - sailfish-safe - Sailfish frontend for safe(1)
(HTM) git clone git://git.z3bra.org/sailfish-safe.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
tgpg.h (2352B)
---
1 #ifndef GPG_H
2 #define GPG_H
3
4 #include <QObject>
5 #include <QVector>
6
7 namespace Gpg
8 {
9 class ListKeysTask;
10 class FindKeyTask;
11 class GetKeyTrustTask;
12 class UpdateKeyTrustTask;
13 class DecryptTask;
14 class EncryptTask;
15
16 struct Key {
17 enum class Trust {
18 Unknown = 1,
19 Never = 2,
20 Marginal = 3,
21 Full = 4,
22 Ultimate = 5
23 };
24
25 QString id;
26 };
27
28 GetKeyTrustTask *getKeyTrust(const Key &key);
29
30 UpdateKeyTrustTask *updateKeyTrust(const Key &key, Key::Trust trust);
31
32 DecryptTask *decrypt(const QString &file, const Key &key, const QString &passphrase);
33
34 EncryptTask *encrypt(const QString &data, const Key &key, const QString &file);
35
36
37 class Task : public QObject {
38 Q_OBJECT
39 public:
40 bool error() const;
41 QString errorString() const;
42
43 Q_SIGNALS:
44 void finished();
45
46 protected:
47 explicit Task(QObject *parent = nullptr);
48
49 virtual void run() = 0;
50
51 void setError(const QString &error);
52
53 private Q_SLOTS:
54 void start();
55
56 private:
57 QString mError;
58 };
59
60 class GetKeyTrustTask : public Task {
61 Q_OBJECT
62 friend GetKeyTrustTask *Gpg::getKeyTrust(const Key &);
63 public:
64 Gpg::Key::Trust trust() const;
65
66 protected:
67 void run() override;
68
69 private:
70 explicit GetKeyTrustTask(const Key &key);
71
72 Key mKey;
73 Key::Trust mTrust = Key::Trust::Never;
74 };
75
76 class UpdateKeyTrustTask : public Task {
77 Q_OBJECT
78 friend UpdateKeyTrustTask *Gpg::updateKeyTrust(const Key &, Key::Trust);
79 protected:
80 void run() override;
81
82 private:
83 UpdateKeyTrustTask(const Gpg::Key &key, Gpg::Key::Trust trust);
84
85 Key mKey;
86 Key::Trust mTrust = Key::Trust::Never;
87 };
88
89 class DecryptTask : public Task {
90 Q_OBJECT
91 friend DecryptTask *Gpg::decrypt(const QString &, const Key &, const QString &);
92 public:
93 QString content() const;
94
95 protected:
96 void run() override;
97
98 private:
99 DecryptTask(const QString &file, const Key &key, const QString &passphrase);
100
101 QString mFile;
102 QString mPassphrase;
103 Key mKey;
104 QString mContent;
105 };
106
107 class EncryptTask : public Task {
108 Q_OBJECT
109 friend EncryptTask *Gpg::encrypt(const QString &, const Key &, const QString &);
110 protected:
111 void run() override;
112
113 private:
114 EncryptTask(const QString &file, const Key &key, const QString &content);
115
116 QString mFile;
117 Key mKey;
118 QString mContent;
119 };
120
121 } // namespace Gpg
122
123 #endif // GPG_H