~ubuntu-branches/ubuntu/quantal/psi/quantal

« back to all changes in this revision

Viewing changes to cutestuff/openpgp/openpgp.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2006-01-20 00:20:36 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060120002036-7nw6yo6totip0ee5
Tags: 0.10-2
* Added upstream changelog (Closes: Bug#327748)
* Mention --no-gpg and --no-gpg-agent in manpage (Closes: Bug#204416)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * openpgp.h - OpenPGP base
3
 
 * Copyright (C) 2003  Justin Karneges
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or
6
 
 * modify it under the terms of the GNU General Public License
7
 
 * as published by the Free Software Foundation; either version 2
8
 
 * of the License, or (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this library; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 
 *
19
 
 */
20
 
 
21
 
#ifndef CS_OPENPGP_H
22
 
#define CS_OPENPGP_H
23
 
 
24
 
#include<qobject.h>
25
 
#include<qstring.h>
26
 
#include<qvaluelist.h>
27
 
#include<qdatetime.h>
28
 
#include<qpair.h>
29
 
 
30
 
namespace OpenPGP
31
 
{
32
 
        enum { None, Encrypt, Decrypt, Sign, Verify };
33
 
        enum { VerifyGood, VerifyBad, VerifyNoKey, VerifyError };
34
 
        class Engine;
35
 
 
36
 
        class Key
37
 
        {
38
 
        public:
39
 
                Key();
40
 
                ~Key();
41
 
 
42
 
                const QString & keyID() const;
43
 
                const QString & userID() const;
44
 
                void setKeyID(const QString &);
45
 
                void setUserID(const QString &);
46
 
 
47
 
        private:
48
 
                QString v_keyID;
49
 
                QString v_userID;
50
 
        };
51
 
 
52
 
        typedef QValueList<Key> KeyList;
53
 
 
54
 
        class Request : public QObject
55
 
        {
56
 
                Q_OBJECT
57
 
        public:
58
 
                Request(Engine *);
59
 
                ~Request();
60
 
 
61
 
                int type() const;
62
 
 
63
 
                void encrypt(const QByteArray &in, const QStringList &keys);
64
 
                void decrypt(const QString &in);
65
 
                void sign(const QByteArray &in, const QString &keyID);
66
 
                void verify(const QByteArray &in, const QString &sig);
67
 
 
68
 
                void submitPassphrase(const QString &);
69
 
 
70
 
                QString encrypted() const;
71
 
                QByteArray decrypted() const;
72
 
                QString signature() const;
73
 
                QString keyID() const;
74
 
                QDateTime timestamp() const;
75
 
                int verifyResult() const;
76
 
 
77
 
                bool badPassphrase() const;
78
 
 
79
 
        signals:
80
 
                void finished(bool);
81
 
                void needPassphrase();
82
 
 
83
 
        private:
84
 
                class Private;
85
 
                Private *d;
86
 
 
87
 
                friend class Engine;
88
 
                void op_encryptFinished(bool, const QString &);
89
 
                void op_decryptFinished(bool, const QByteArray &);
90
 
                void op_signFinished(bool, const QString &);
91
 
                void op_verifyFinished(int, const QString &, const QDateTime &);
92
 
                void op_needPassphrase();
93
 
                void op_setBadPassphrase(bool);
94
 
        };
95
 
 
96
 
        class Engine : public QObject
97
 
        {
98
 
                Q_OBJECT
99
 
        public:
100
 
                Engine(QObject *parent=0);
101
 
                virtual ~Engine()=0;
102
 
 
103
 
                virtual bool checkAvailability()=0;
104
 
                virtual QString id() const=0;
105
 
                virtual QString name() const=0;
106
 
 
107
 
                virtual void init()=0;
108
 
                virtual KeyList secretKeys() const=0;
109
 
                virtual KeyList publicKeys() const=0;
110
 
 
111
 
        signals:
112
 
                void initFinished(bool, const QString &);
113
 
                void keysUpdated();
114
 
 
115
 
        protected:
116
 
                friend class Request;
117
 
                virtual void encrypt(Request *, const QByteArray &, const QStringList &keys)=0;
118
 
                virtual void decrypt(Request *, const QString &)=0;
119
 
                virtual void sign(Request *, const QByteArray &, const QString &keyID)=0;
120
 
                virtual void verify(Request *, const QByteArray &, const QString &sig)=0;
121
 
                virtual void submitPassphrase(Request *, const QString &)=0;
122
 
                void encryptFinished(Request *, bool, const QString &);
123
 
                void decryptFinished(Request *, bool, const QByteArray &);
124
 
                void signFinished(Request *, bool, const QString &);
125
 
                void verifyFinished(Request *, int, const QString &, const QDateTime &);
126
 
                void needPassphrase(Request *);
127
 
                void setBadPassphrase(Request *, bool);
128
 
        };
129
 
 
130
 
        typedef QPair<QString,QString> EngineItem;
131
 
 
132
 
        QValueList<EngineItem> getAllEngines();
133
 
        QValueList<EngineItem> getAvailableEngines();
134
 
        Engine * createEngine(const QString &);
135
 
 
136
 
        QString stripHeaderFooter(const QString &);
137
 
        QString addHeaderFooter(const QString &, int);
138
 
}
139
 
 
140
 
#endif