~ubuntu-branches/ubuntu/jaunty/psi/jaunty

« back to all changes in this revision

Viewing changes to third-party/qca/qca-gnupg/gpgop.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-04-14 18:57:30 UTC
  • mfrom: (2.1.9 hardy)
  • Revision ID: james.westby@ubuntu.com-20080414185730-528re3zp0m2hdlhi
Tags: 0.11-8
* added CONFIG -= link_prl to .pro files and removed dependencies
  which are made unnecessary by this change
* Fix segfault when closing last chat tab with qt4.4
  (This is from upstream svn, rev. 1101) (Closes: Bug#476122)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2003-2005  Justin Karneges <justin@affinix.com>
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2.1 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with this library; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
17
 *
 
18
 */
 
19
 
 
20
#ifndef GPGOP_H
 
21
#define GPGOP_H
 
22
 
 
23
#include <QtCrypto>
 
24
#include "qpipe.h"
 
25
 
 
26
namespace gpgQCAPlugin {
 
27
 
 
28
class GpgOp : public QObject
 
29
{
 
30
        Q_OBJECT
 
31
public:
 
32
        enum Type
 
33
        {
 
34
                Check,             // --version
 
35
                SecretKeyringFile, // --list-secret-keys
 
36
                PublicKeyringFile, // --list-public-keys
 
37
                SecretKeys,        // --fixed-list-mode --with-colons --list-secret-keys
 
38
                PublicKeys,        // --fixed-list-mode --with-colons --list-public-keys
 
39
                Encrypt,           // --encrypt
 
40
                Decrypt,           // --decrypt
 
41
                Sign,              // --sign
 
42
                SignAndEncrypt,    // --sign --encrypt
 
43
                SignClearsign,     // --clearsign
 
44
                SignDetached,      // --detach-sign
 
45
                Verify,            // --verify
 
46
                VerifyDetached,    // --verify
 
47
                Import,            // --import
 
48
                Export             // --export
 
49
        };
 
50
 
 
51
        enum VerifyResult
 
52
        {
 
53
                VerifyGood,        // good sig
 
54
                VerifyBad,         // bad sig
 
55
                VerifyNoKey        // we don't have signer's public key
 
56
        };
 
57
 
 
58
        enum Error
 
59
        {
 
60
                ErrorProcess,          // startup, process, or ipc error
 
61
                ErrorPassphrase,       // passphrase was either wrong or not provided
 
62
                ErrorFormat,           // input format was bad
 
63
                ErrorSignerExpired,    // signing key is expired
 
64
                ErrorEncryptExpired,   // encrypting key is expired
 
65
                ErrorEncryptUntrusted, // encrypting key is untrusted
 
66
                ErrorEncryptInvalid,   // encrypting key is invalid in some way
 
67
                ErrorDecryptNoKey,     // missing decrypt key
 
68
                ErrorUnknown           // other error
 
69
        };
 
70
 
 
71
        class Event
 
72
        {
 
73
        public:
 
74
                enum Type
 
75
                {
 
76
                        None,
 
77
                        ReadyRead,
 
78
                        BytesWritten,
 
79
                        Finished,
 
80
                        NeedPassphrase,
 
81
                        NeedCard,
 
82
                        ReadyReadDiagnosticText
 
83
                };
 
84
 
 
85
                Type type;
 
86
                int written;   // BytesWritten
 
87
                QString keyId; // NeedPassphrase
 
88
 
 
89
                Event() : type(None), written(0) {}
 
90
        };
 
91
 
 
92
        class KeyItem
 
93
        {
 
94
        public:
 
95
                enum Type
 
96
                {
 
97
                        RSA,
 
98
                        DSA,
 
99
                        ElGamal,
 
100
                        Unknown
 
101
                };
 
102
 
 
103
                enum Caps
 
104
                {
 
105
                        Encrypt = 0x01,
 
106
                        Sign    = 0x02,
 
107
                        Certify = 0x04,
 
108
                        Auth    = 0x08
 
109
                };
 
110
 
 
111
                QString id;
 
112
                Type type;
 
113
                int bits;
 
114
                QDateTime creationDate;
 
115
                QDateTime expirationDate;
 
116
                int caps; // flags OR'd together
 
117
                QString fingerprint;
 
118
 
 
119
                KeyItem() : type(Unknown), bits(0), caps(0) {}
 
120
        };
 
121
 
 
122
        class Key
 
123
        {
 
124
        public:
 
125
                QList<KeyItem> keyItems; // first item is primary
 
126
                QStringList userIds;
 
127
                bool isTrusted;
 
128
 
 
129
                Key() : isTrusted(false) {}
 
130
        };
 
131
        typedef QList<Key> KeyList;
 
132
 
 
133
        explicit GpgOp(const QString &bin, QObject *parent = 0);
 
134
        ~GpgOp();
 
135
 
 
136
        void reset();
 
137
 
 
138
        bool isActive() const;
 
139
        Type op() const;
 
140
 
 
141
        void setAsciiFormat(bool b);
 
142
        void setDisableAgent(bool b);
 
143
        void setAlwaysTrust(bool b);
 
144
        void setKeyrings(const QString &pubfile, const QString &secfile); // for keylists and import
 
145
 
 
146
        void doCheck();
 
147
        void doSecretKeyringFile();
 
148
        void doPublicKeyringFile();
 
149
        void doSecretKeys();
 
150
        void doPublicKeys();
 
151
        void doEncrypt(const QStringList &recip_ids);
 
152
        void doDecrypt();
 
153
        void doSign(const QString &signer_id);
 
154
        void doSignAndEncrypt(const QString &signer_id, const QStringList &recip_ids);
 
155
        void doSignClearsign(const QString &signer_id);
 
156
        void doSignDetached(const QString &signer_id);
 
157
        void doVerify();
 
158
        void doVerifyDetached(const QByteArray &sig);
 
159
        void doImport(const QByteArray &in);
 
160
        void doExport(const QString &key_id);
 
161
 
 
162
#ifdef QPIPE_SECURE
 
163
        void submitPassphrase(const QCA::SecureArray &a);
 
164
#else
 
165
        void submitPassphrase(const QByteArray &a);
 
166
#endif
 
167
        void cardOkay();
 
168
 
 
169
        // for encrypt, decrypt, sign, verify, export
 
170
        QByteArray read();
 
171
        void write(const QByteArray &in);
 
172
        void endWrite();
 
173
 
 
174
        QString readDiagnosticText();
 
175
 
 
176
        // for synchronous operation
 
177
        Event waitForEvent(int msecs = -1);
 
178
 
 
179
        // results
 
180
        bool success() const;
 
181
        Error errorCode() const;
 
182
        KeyList keys() const;              // Keys
 
183
        QString keyringFile() const;       // KeyringFile
 
184
        QString encryptedToId() const;     // Decrypt (for ErrorDecryptNoKey)
 
185
        bool wasSigned() const;            // Decrypt
 
186
        QString signerId() const;          // Verify
 
187
        QDateTime timestamp() const;       // Verify
 
188
        VerifyResult verifyResult() const; // Verify
 
189
 
 
190
Q_SIGNALS:
 
191
        void readyRead();
 
192
        void bytesWritten(int bytes);
 
193
        void finished();
 
194
        void needPassphrase(const QString &keyId);
 
195
        void needCard();
 
196
        void readyReadDiagnosticText();
 
197
 
 
198
private:
 
199
        class Private;
 
200
        friend class Private;
 
201
        Private *d;
 
202
};
 
203
 
 
204
}
 
205
 
 
206
#endif