• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

libkpgp

kpgpbase.h

Go to the documentation of this file.
00001 /*
00002     kpgpbase.h
00003 
00004     Copyright (C) 2001,2002 the KPGP authors
00005     See file AUTHORS.kpgp for details
00006 
00007     This file is part of KPGP, the KDE PGP/GnuPG support library.
00008 
00009     KPGP is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program; if not, write to the Free Software Foundation,
00016     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
00017  */
00018 
00019 #ifndef KPGPBASE_H
00020 #define KPGPBASE_H
00021 
00022 #include "kpgpkey.h"
00023 #include "kpgpblock.h"
00024 
00025 #include <QtCore/QString>
00026 #include <QtCore/QStringList>
00027 
00028 namespace Kpgp {
00029 
00030 class Base
00031 {
00032 public:
00033 
00035   Base();
00036   virtual ~Base();
00037 
00038 
00040   virtual int encrypt( Block& , const KeyIDList& ) { return OK; }
00041 
00043   virtual int clearsign( Block& , const char *) { return OK; }
00044 
00046   virtual int encsign( Block& , const KeyIDList& ,
00047                       const char * = 0) { return OK; }
00048 
00050   virtual int decrypt( Block& , const char * = 0) { return OK; }
00051 
00053   virtual int verify( Block& block ) { return decrypt( block, 0 ); }
00054 
00055 
00061   virtual Key* readPublicKey( const KeyID&, const bool = false,
00062                               Key* = 0 )
00063     { return 0; }
00064 
00066   virtual KeyList publicKeys( const QStringList & = QStringList() )
00067  { return KeyList(); }
00068 
00070   virtual KeyList secretKeys( const QStringList & = QStringList() )
00071  { return KeyList(); }
00072 
00075   virtual QByteArray getAsciiPublicKey(const KeyID& ) { return QByteArray(); }
00076 
00079   virtual int signKey(const KeyID& , const char *) { return OK; }
00080 
00081 
00084   virtual QString lastErrorMessage() const;
00085 
00086 
00087 protected:
00088   virtual int run( const char *cmd, const char *passphrase = 0,
00089                    bool onlyReadFromPGP = false );
00090   virtual int runGpg( const char *cmd, const char *passphrase = 0,
00091                       bool onlyReadFromGnuPG = false );
00092   virtual void clear();
00093 
00094   QByteArray addUserId();
00095 
00096   QByteArray input;
00097   QByteArray output;
00098   QByteArray error;
00099   QString errMsg;
00100 
00101   QByteArray mVersion;
00102 
00103   int status;
00104 
00105 };
00106 
00107 // ---------------------------------------------------------------------------
00108 
00109 class Base2 : public Base
00110 {
00111 
00112 public:
00113   Base2();
00114   virtual ~Base2();
00115 
00116   virtual int encrypt( Block& block, const KeyIDList& recipients );
00117   virtual int clearsign( Block& block, const char *passphrase );
00118   virtual int encsign( Block& block, const KeyIDList& recipients,
00119                        const char *passphrase = 0 );
00120   virtual int decrypt( Block& block, const char *passphrase = 0 );
00121   virtual int verify( Block& block ) { return decrypt( block, 0 ); }
00122 
00123   virtual Key* readPublicKey( const KeyID& keyID,
00124                               const bool readTrust = false,
00125                               Key* key = 0 );
00126   virtual KeyList publicKeys( const QStringList & patterns = QStringList() );
00127   virtual KeyList secretKeys( const QStringList & patterns = QStringList() );
00128   virtual QByteArray getAsciiPublicKey( const KeyID& keyID );
00129   virtual int signKey( const KeyID& keyID, const char *passphrase );
00130 
00131 protected:
00132   KeyList doGetPublicKeys( const QByteArray & cmd,
00133                            const QStringList & patterns );
00134   virtual KeyList parseKeyList( const QByteArray&, bool );
00135 
00136 private:
00137   Key* parsePublicKeyData( const QByteArray& output, Key* key = 0 );
00138   void parseTrustDataForKey( Key* key, const QByteArray& str );
00139 };
00140 
00141 class BaseG : public Base
00142 {
00143 
00144 public:
00145   BaseG();
00146   virtual ~BaseG();
00147 
00148   virtual int encrypt( Block& block, const KeyIDList& recipients );
00149   virtual int clearsign( Block& block, const char *passphrase );
00150   virtual int encsign( Block& block, const KeyIDList& recipients,
00151                        const char *passphrase = 0 );
00152   virtual int decrypt( Block& block, const char *passphrase = 0 );
00153   virtual int verify( Block& block ) { return decrypt( block, 0 ); }
00154 
00155   virtual Key* readPublicKey( const KeyID& keyID,
00156                               const bool readTrust = false,
00157                               Key* key = 0 );
00158   virtual KeyList publicKeys( const QStringList & patterns = QStringList() );
00159   virtual KeyList secretKeys( const QStringList & patterns = QStringList() );
00160   virtual QByteArray getAsciiPublicKey( const KeyID& keyID );
00161   virtual int signKey( const KeyID& keyID, const char *passphrase );
00162 
00163 private:
00164   Key* parseKeyData( const QByteArray& output, int& offset, Key* key = 0 );
00165   KeyList parseKeyList( const QByteArray&, bool );
00166 };
00167 
00168 
00169 class Base5 : public Base
00170 {
00171 
00172 public:
00173   Base5();
00174   virtual ~Base5();
00175 
00176   virtual int encrypt( Block& block, const KeyIDList& recipients );
00177   virtual int clearsign( Block& block, const char *passphrase );
00178   virtual int encsign( Block& block, const KeyIDList& recipients,
00179                        const char *passphrase = 0 );
00180   virtual int decrypt( Block& block, const char *passphrase = 0 );
00181   virtual int verify( Block& block ) { return decrypt( block, 0 ); }
00182 
00183   virtual Key* readPublicKey( const KeyID& keyID,
00184                               const bool readTrust = false,
00185                               Key* key = 0 );
00186   virtual KeyList publicKeys( const QStringList & patterns = QStringList() );
00187   virtual KeyList secretKeys( const QStringList & patterns = QStringList() );
00188   virtual QByteArray getAsciiPublicKey( const KeyID& keyID );
00189   virtual int signKey( const KeyID& keyID, const char *passphrase );
00190 
00191 private:
00192   Key* parseKeyData( const QByteArray& output, int& offset, Key* key = 0 );
00193   Key* parseSingleKey( const QByteArray& output, Key* key = 0 );
00194   KeyList parseKeyList( const QByteArray& output, bool );
00195   void parseTrustDataForKey( Key* key, const QByteArray& str );
00196 };
00197 
00198 
00199 class Base6 : public Base2
00200 {
00201 
00202 public:
00203   Base6();
00204   virtual ~Base6();
00205 
00206   virtual int decrypt( Block& block, const char *passphrase = 0 );
00207   virtual int verify( Block& block ) { return decrypt( block, 0 ); }
00208 
00209   virtual Key* readPublicKey( const KeyID& keyID,
00210                               const bool readTrust = false,
00211                               Key* key = 0 );
00212   virtual KeyList publicKeys( const QStringList & patterns = QStringList() );
00213   virtual KeyList secretKeys( const QStringList & patterns = QStringList() );
00214 
00215   virtual int isVersion6();
00216 
00217 protected:
00218   virtual KeyList parseKeyList( const QByteArray &, bool );
00219 
00220 private:
00221   Key* parseKeyData( const QByteArray& output, int& offset, Key* key = 0 );
00222   Key* parseSingleKey( const QByteArray& output, Key* key = 0 );
00223   void parseTrustDataForKey( Key* key, const QByteArray& str );
00224 };
00225 
00226 // ---------------------------------------------------------------------------
00227 // inlined functions
00228 
00229 inline QString
00230 Base::lastErrorMessage() const
00231 {
00232   return errMsg;
00233 }
00234 
00235 
00236 } // namespace Kpgp
00237 
00238 #endif

libkpgp

Skip menu "libkpgp"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal