Framework for looking up contacts directly in nepomuk in addition to going through...
[kdepim.git] / messageviewer / objecttreeparser_p.h
blob6d665a1bc5620208a051be60dbb17bc9033773e0
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2 objecttreeparser_p.h
4 This file is part of KMail, the KDE mail client.
5 Copyright (C) 2009 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.net
6 Copyright (c) 2009 Andras Mantia <andras@kdab.net>
8 KMail is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License, version 2, as
10 published by the Free Software Foundation.
12 KMail is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 In addition, as a special exception, the copyright holders give
22 permission to link the code of this program with any edition of
23 the Qt library by Trolltech AS, Norway (or with modified versions
24 of Qt that use the same license as Qt), and distribute linked
25 combinations including the two. You must obey the GNU General
26 Public License in all respects for all of the code used other than
27 Qt. If you modify this file, you may extend this exception to
28 your version of the file, but you are not obligated to do so. If
29 you do not wish to do so, delete this exception statement from
30 your version.
33 #ifndef _MESSAGEVIEWER_OBJECTTREEPARSER_P_H_
34 #define _MESSAGEVIEWER_OBJECTTREEPARSER_P_H_
36 #include <gpgme++/verificationresult.h>
37 #include <gpgme++/decryptionresult.h>
38 #include <gpgme++/key.h>
40 #include <QObject>
41 #include <QString>
42 #include <QPointer>
44 #include "interfaces/bodypart.h"
45 #include "viewer.h"
47 namespace Kleo {
48 class DecryptVerifyJob;
49 class VerifyDetachedJob;
50 class VerifyOpaqueJob;
51 class KeyListJob;
54 class QStringList;
56 namespace MessageViewer {
58 class CryptoBodyPartMemento
59 : public QObject,
60 public Interface::BodyPartMemento
62 Q_OBJECT
63 public:
64 CryptoBodyPartMemento();
65 ~CryptoBodyPartMemento();
67 bool isRunning() const { return m_running; }
69 const QString & auditLogAsHtml() const { return m_auditLog; }
70 GpgME::Error auditLogError() const { return m_auditLogError; }
72 void detach();
74 signals:
75 void update(MessageViewer::Viewer::UpdateMode);
77 protected slots:
78 void notify() {
79 emit update(Viewer::Force);
82 protected:
83 void setAuditLog( const GpgME::Error & err, const QString & log );
84 void setRunning( bool running );
86 private:
87 bool m_running;
88 QString m_auditLog;
89 GpgME::Error m_auditLogError;
92 class DecryptVerifyBodyPartMemento
93 : public CryptoBodyPartMemento
95 Q_OBJECT
96 public:
97 DecryptVerifyBodyPartMemento( Kleo::DecryptVerifyJob * job, const QByteArray & cipherText );
98 ~DecryptVerifyBodyPartMemento();
100 bool start();
101 void exec();
103 const QByteArray & plainText() const { return m_plainText; }
104 const GpgME::DecryptionResult & decryptResult() const { return m_dr; }
105 const GpgME::VerificationResult & verifyResult() const { return m_vr; }
107 private slots:
108 void slotResult( const GpgME::DecryptionResult & dr,
109 const GpgME::VerificationResult & vr,
110 const QByteArray & plainText );
112 private:
113 void saveResult( const GpgME::DecryptionResult &,
114 const GpgME::VerificationResult &,
115 const QByteArray & );
116 private:
117 // input:
118 const QByteArray m_cipherText;
119 QPointer<Kleo::DecryptVerifyJob> m_job;
120 // output:
121 GpgME::DecryptionResult m_dr;
122 GpgME::VerificationResult m_vr;
123 QByteArray m_plainText;
127 class VerifyDetachedBodyPartMemento
128 : public CryptoBodyPartMemento
130 Q_OBJECT
131 public:
132 VerifyDetachedBodyPartMemento( Kleo::VerifyDetachedJob * job,
133 Kleo::KeyListJob * klj,
134 const QByteArray & signature,
135 const QByteArray & plainText );
136 ~VerifyDetachedBodyPartMemento();
138 bool start();
139 void exec();
141 const GpgME::VerificationResult & verifyResult() const { return m_vr; }
142 const GpgME::Key & signingKey() const { return m_key; }
144 private slots:
145 void slotResult( const GpgME::VerificationResult & vr );
146 void slotKeyListJobDone();
147 void slotNextKey( const GpgME::Key & );
149 private:
150 void saveResult( const GpgME::VerificationResult & );
151 bool canStartKeyListJob() const;
152 QStringList keyListPattern() const;
153 bool startKeyListJob();
154 private:
155 // input:
156 const QByteArray m_signature;
157 const QByteArray m_plainText;
158 QPointer<Kleo::VerifyDetachedJob> m_job;
159 QPointer<Kleo::KeyListJob> m_keylistjob;
160 // output:
161 GpgME::VerificationResult m_vr;
162 GpgME::Key m_key;
166 class VerifyOpaqueBodyPartMemento
167 : public CryptoBodyPartMemento
169 Q_OBJECT
170 public:
171 VerifyOpaqueBodyPartMemento( Kleo::VerifyOpaqueJob * job,
172 Kleo::KeyListJob * klj,
173 const QByteArray & signature );
174 ~VerifyOpaqueBodyPartMemento();
176 bool start();
177 void exec();
179 const QByteArray & plainText() const { return m_plainText; }
180 const GpgME::VerificationResult & verifyResult() const { return m_vr; }
181 const GpgME::Key & signingKey() const { return m_key; }
183 private slots:
184 void slotResult( const GpgME::VerificationResult & vr,
185 const QByteArray & plainText );
186 void slotKeyListJobDone();
187 void slotNextKey( const GpgME::Key & );
189 private:
190 void saveResult( const GpgME::VerificationResult &,
191 const QByteArray & );
192 bool canStartKeyListJob() const;
193 QStringList keyListPattern() const;
194 bool startKeyListJob();
195 private:
196 // input:
197 const QByteArray m_signature;
198 QPointer<Kleo::VerifyOpaqueJob> m_job;
199 QPointer<Kleo::KeyListJob> m_keylistjob;
200 // output:
201 GpgME::VerificationResult m_vr;
202 QByteArray m_plainText;
203 GpgME::Key m_key;
209 #endif // _KMAIL_OBJECTTREEPARSER_H_