libkpgp
kpgpblock.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef KPGPBLOCK_H
00020 #define KPGPBLOCK_H
00021
00022 #include <qcstring.h>
00023 #include <qstring.h>
00024 #include <qstrlist.h>
00025
00026 #include <kdepimmacros.h>
00027
00028
00029 class QStringList;
00030
00031 #include "kpgp.h"
00032
00033 namespace Kpgp {
00034
00035 typedef enum {
00036 UnknownBlock = -1,
00037 NoPgpBlock = 0,
00038 PgpMessageBlock = 1,
00039 MultiPgpMessageBlock = 2,
00040 SignatureBlock = 3,
00041 ClearsignedBlock = 4,
00042 PublicKeyBlock = 5,
00043 PrivateKeyBlock = 6
00044 } BlockType;
00045
00046 typedef enum {
00047 OK = 0x0000,
00048 CLEARTEXT = 0x0000,
00049 RUN_ERR = 0x0001,
00050 ERROR = 0x0001,
00051 ENCRYPTED = 0x0002,
00052 SIGNED = 0x0004,
00053 GOODSIG = 0x0008,
00054 ERR_SIGNING = 0x0010,
00055 UNKNOWN_SIG = 0x0020,
00056 BADPHRASE = 0x0040,
00057 BADKEYS = 0x0080,
00058 NO_SEC_KEY = 0x0100,
00059 MISSINGKEY = 0x0200,
00060 CANCEL = 0x8000
00061 } MessageStatus;
00062
00063 class Base;
00064 class Module;
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 class KDE_EXPORT Block
00094 {
00095 public:
00096
00097 Block( const QCString& str = QCString() );
00098 ~Block();
00099
00100 QCString text() const;
00101 void setText( const QCString& str );
00102
00103 void setProcessedText( const QCString& str );
00104
00105 int status() const;
00106 void setStatus( const int status );
00107
00108 BlockType type();
00109
00111 bool isEncrypted() const;
00112
00114 bool isSigned() const;
00115
00117 bool goodSignature() const;
00118
00121 QString signatureUserId() const;
00122 void setSignatureUserId( const QString& userId );
00123
00125 QCString signatureKeyId() const;
00126 void setSignatureKeyId( const QCString& keyId );
00127
00130 QCString signatureDate() const;
00131 void setSignatureDate( const QCString& date );
00132
00134 const QStrList encryptedFor() const;
00135
00138 QString requiredKey() const;
00139 void setRequiredKey( const QCString& keyId );
00140
00141 QString requiredUserId() const;
00142 void setRequiredUserId( const QString& userId );
00143
00144 QCString error() const;
00145 void setError( const QCString& str );
00146
00148 void reset();
00149
00152 bool decrypt();
00153
00155 bool verify();
00156
00163 Kpgp::Result clearsign( const QCString& keyId,
00164 const QCString& charset = QCString() );
00165
00172 Kpgp::Result encrypt( const QStringList& receivers, const QCString& keyId,
00173 const bool sign, const QCString& charset = QCString() );
00174
00175 private:
00176 void clear();
00177
00178 BlockType determineType() const;
00179
00180 QCString mText;
00181 QCString mProcessedText;
00182 QCString mError;
00183 QString mSignatureUserId;
00184 QCString mSignatureKeyId;
00185 QCString mSignatureDate;
00186 QCString mRequiredKey;
00187 QString mRequiredUserId;
00188 QStrList mEncryptedFor;
00189 int mStatus;
00190 bool mHasBeenProcessed;
00191 BlockType mType;
00192 };
00193
00194
00195
00196 inline QCString
00197 Block::text() const
00198 {
00199 if( mHasBeenProcessed )
00200 return mProcessedText;
00201 else
00202 return mText;
00203 }
00204
00205 inline void
00206 Block::setText( const QCString& str )
00207 {
00208 clear();
00209 mText = str;
00210 }
00211
00212 inline void
00213 Block::setProcessedText( const QCString& str )
00214 {
00215 mProcessedText = str;
00216 mHasBeenProcessed = true;
00217 }
00218
00219 inline QCString
00220 Block::error() const
00221 {
00222 return mError;
00223 }
00224
00225 inline void
00226 Block::setError( const QCString& str )
00227 {
00228 mError = str;
00229 }
00230
00231 inline int
00232 Block::status() const
00233 {
00234 return mStatus;
00235 }
00236
00237 inline void
00238 Block::setStatus( const int status )
00239 {
00240 mStatus = status;
00241 }
00242
00243 inline BlockType
00244 Block::type()
00245 {
00246 if( mType == NoPgpBlock )
00247 mType = determineType();
00248 return mType;
00249 }
00250
00251 inline QString
00252 Block::signatureUserId() const
00253 {
00254 return mSignatureUserId;
00255 }
00256
00257 inline void
00258 Block::setSignatureUserId( const QString& userId )
00259 {
00260 mSignatureUserId = userId;
00261 }
00262
00263 inline QCString
00264 Block::signatureKeyId() const
00265 {
00266 return mSignatureKeyId;
00267 }
00268
00269 inline void
00270 Block::setSignatureKeyId( const QCString& keyId )
00271 {
00272 mSignatureKeyId = keyId;
00273 }
00274
00275 inline QCString
00276 Block::signatureDate() const
00277 {
00278 return mSignatureDate;
00279 }
00280
00281 inline void
00282 Block::setSignatureDate( const QCString& date )
00283 {
00284 mSignatureDate = date;
00285 }
00286
00287 inline QString
00288 Block::requiredKey() const
00289 {
00290 return mRequiredKey;
00291 }
00292
00293 inline void
00294 Block::setRequiredKey( const QCString& keyId )
00295 {
00296 mRequiredKey = keyId;
00297 }
00298
00299 inline QString
00300 Block::requiredUserId() const
00301 {
00302 return mRequiredUserId;
00303 }
00304
00305 inline void
00306 Block::setRequiredUserId( const QString& userId )
00307 {
00308 mRequiredUserId = userId;
00309 }
00310
00311 inline const QStrList
00312 Block::encryptedFor() const
00313 {
00314 return mEncryptedFor;
00315 }
00316
00317 inline bool
00318 Block::isEncrypted() const
00319 {
00320 if( mStatus & ENCRYPTED )
00321 return true;
00322 return false;
00323 }
00324
00325 inline bool
00326 Block::isSigned() const
00327 {
00328 if( mStatus & SIGNED )
00329 return true;
00330 return false;
00331 }
00332
00333 inline bool
00334 Block::goodSignature() const
00335 {
00336 if( mStatus & GOODSIG )
00337 return true;
00338 return false;
00339 }
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353 }
00354
00355 #endif
00356
|