1 | #ifndef CS_GPGOP_H
|
---|
2 | #define CS_GPGOP_H
|
---|
3 |
|
---|
4 | #include"openpgp.h"
|
---|
5 |
|
---|
6 | class GpgOp : public QObject
|
---|
7 | {
|
---|
8 | Q_OBJECT
|
---|
9 | public:
|
---|
10 | enum { Check = 0, SecretKeyringFile, PublicKeyringFile, SecretKeys, PublicKeys, Encrypt, Decrypt, Sign, Verify };
|
---|
11 | GpgOp(const QString &bin, QObject *parent=0);
|
---|
12 | ~GpgOp();
|
---|
13 |
|
---|
14 | bool isActive() const;
|
---|
15 | int op() const;
|
---|
16 | const OpenPGP::KeyList & keys() const;
|
---|
17 | const QString & keyringFile() const;
|
---|
18 | const QString & keyID() const;
|
---|
19 | const QDateTime & timestamp() const;
|
---|
20 | int verifyResult() const;
|
---|
21 | bool badPassphrase() const;
|
---|
22 | const QString & encrypted() const;
|
---|
23 | const QByteArray & decrypted() const;
|
---|
24 | const QString & signature() const;
|
---|
25 |
|
---|
26 | void doCheck();
|
---|
27 | void doSecretKeyringFile();
|
---|
28 | void doPublicKeyringFile();
|
---|
29 | void doSecretKeys();
|
---|
30 | void doPublicKeys();
|
---|
31 | void doEncrypt(const QByteArray &in, const QStringList &keys);
|
---|
32 | void doDecrypt(const QString &in);
|
---|
33 | void doSign(const QByteArray &in, const QString &keyID);
|
---|
34 | void doVerify(const QByteArray &in, const QString &sig);
|
---|
35 | void stop();
|
---|
36 |
|
---|
37 | void submitPassphrase(const QString &);
|
---|
38 | void setTryAgent(bool);
|
---|
39 |
|
---|
40 | signals:
|
---|
41 | void finished(bool);
|
---|
42 | void needPassphrase();
|
---|
43 |
|
---|
44 | private slots:
|
---|
45 | void proc_readyReadStdout();
|
---|
46 | void proc_readyReadStderr();
|
---|
47 | void proc_wroteToStdin();
|
---|
48 | void proc_statusLine(const QString &);
|
---|
49 | void proc_processExited();
|
---|
50 |
|
---|
51 | void doFail();
|
---|
52 |
|
---|
53 | private:
|
---|
54 | class Private;
|
---|
55 | Private *d;
|
---|
56 |
|
---|
57 | void reset();
|
---|
58 |
|
---|
59 | bool launchGPG(const QStringList &, bool useExtra=true);
|
---|
60 | void processResult(bool clean, int code, const QByteArray &out, const QByteArray &err);
|
---|
61 |
|
---|
62 | QString fixIncomingLines(const QString &);
|
---|
63 | QString fixOutgoingLines(const QString &);
|
---|
64 | bool stringToKeyList(const QString &, OpenPGP::KeyList *, QString *);
|
---|
65 | bool findKeyringFilename(const QString &, QString *);
|
---|
66 | };
|
---|
67 |
|
---|
68 | #endif
|
---|