qgpgmejob.h
1/*
2 qgpgmejob.h
3
4 This file is part of libkleopatra, the KDE keymanagement library
5 Copyright (c) 2004 Klarälvdalens Datakonsult AB
6
7 Libkleopatra is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
11
12 Libkleopatra is distributed in the hope that it will be useful,
13 but 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.
16
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
20
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 TQt library by Trolltech AS, Norway (or with modified versions
24 of TQt that use the same license as TQt), 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 TQt. 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.
31*/
32
33#ifndef __KLEO_TQGPGMEJOB_H__
34#define __KLEO_TQGPGMEJOB_H__
35
36#include <gpgmepp/interfaces/progressprovider.h>
37#include <gpgmepp/interfaces/passphraseprovider.h>
38
39#include <gpgmepp/key.h>
40#include <gpgmepp/context.h>
41
42#include <tqcstring.h>
43#include <tqstring.h>
44
45#include <vector>
46#include <tdemacros.h>
47
48namespace GpgME {
49 class Data;
50}
51
52namespace Kleo {
53 class Job;
54}
55
56namespace QGpgME {
57 class TQByteArrayDataProvider;
58}
59
60class TQString;
61class TQStringList;
62
63namespace Kleo {
64
78 class TDE_EXPORT QGpgMEJob : public GpgME::ProgressProvider, public GpgME::PassphraseProvider {
79 public:
80 QGpgMEJob( Kleo::Job * _this, GpgME::Context * context );
81 ~QGpgMEJob();
82
83 protected:
86 virtual void doOperationDoneEvent( const GpgME::Error & e ) = 0;
88 void hookupContextToEventLoopInteractor();
90 void setPatterns( const TQStringList & sl, bool allowEmpty=false );
92 unsigned int numPatterns() const { return mNumPatterns; }
94 const char* * nextChunk();
96 const char* * patterns() const;
98 void setChunkSize( unsigned int size );
100 unsigned int chunkSize() const { return mChunkSize; }
102 void createOutData();
105 void createInData( const TQByteArray & in );
107 GpgME::Error setSigningKeys( const std::vector<GpgME::Key> & signers );
109 void doSlotOperationDoneEvent( GpgME::Context * context, const GpgME::Error & e );
111 void getAuditLog();
112
113 //
114 // only boring stuff below this line...
115 //
116
117 protected:
118 virtual void doEmitProgressSignal( const TQString & what, int current, int total ) = 0;
119 virtual void doEmitDoneSignal() = 0;
120 void doSlotCancel();
121 TQString auditLogAsHtml() const { return mAuditLogAsHtml; }
122 GpgME::Error auditLogError() const { return mAuditLogError; }
123
124 private:
126 void showProgress( const char * what, int type, int current, int total );
127 char * getPassphrase( const char * useridHint, const char * description,
128 bool previousWasBad, bool & canceled );
129 void deleteAllPatterns();
130
131 public:
132 void checkInvariants() const;
133
134 protected:
135 Kleo::Job * mThis;
136 GpgME::Context * mCtx;
137 GpgME::Data * mInData;
138 QGpgME::TQByteArrayDataProvider * mInDataDataProvider;
139 GpgME::Data * mOutData;
140 QGpgME::TQByteArrayDataProvider * mOutDataDataProvider;
141 private:
142 const char* * mPatterns;
143 // holds the entry - if any - in mPattern that was replaced with
144 // NULL to create a temporary end-of-array marker for gpgme:
145 const char * mReplacedPattern;
146 unsigned int mNumPatterns;
147 unsigned int mChunkSize;
148 unsigned int mPatternStartIndex, mPatternEndIndex;
149 GpgME::Error mAuditLogError;
150 TQString mAuditLogAsHtml;
151 };
152
153}
154
155#define make_slot_cancel private: void slotCancel() { QGpgMEJob::doSlotCancel(); }
156#define make_progress_emitter private: void doEmitProgressSignal( const TQString & what, int cur, int tot ) { emit progress( what, cur, tot ); }
157#define make_done_emitter private: void doEmitDoneSignal() { emit done(); }
158#define make_auditLogAsHtml private: TQString auditLogAsHtml() const { return QGpgMEJob::auditLogAsHtml(); } GpgME::Error auditLogError() const { return QGpgMEJob::auditLogError(); }
159#define TQGPGME_JOB make_slot_cancel make_progress_emitter make_done_emitter make_auditLogAsHtml
160
161#endif // __KLEO_TQGPGMEJOB_H__
An abstract base class for asynchronous crypto operations.
Definition: job.h:64
This is a hackish helper class to avoid code duplication in this backend's Kleo::Job subclasses.
Definition: qgpgmejob.h:78
virtual void doOperationDoneEvent(const GpgME::Error &e)=0
unsigned int numPatterns() const
Definition: qgpgmejob.h:92
unsigned int chunkSize() const
Definition: qgpgmejob.h:100