KGPGFile Class Reference

#include <kgpgfile.h>

Inheritance diagram for KGPGFile:

Collaboration diagram for KGPGFile:

Collaboration graph

List of all members.

Public Member Functions

 KGPGFile (const QString &fname="", const QString &homedir="~/.gnupg", const QString &options="")
 ~KGPGFile ()
virtual bool open (int mode)
virtual void close (void)
virtual void flush (void)
virtual Offset size (void) const
virtual Q_LONG readBlock (char *data, Q_ULONG maxlen)
virtual Q_LONG writeBlock (const char *data, Q_ULONG maxlen)
virtual QByteArray readAll (void)
virtual int getch (void)
virtual int putch (int c)
virtual int ungetch (int c)
void addRecipient (const QCString &recipient)
void setName (const QString &fn)
void setComment (const QString &txt)
const QCString errmsg (void) const
int exitStatus (void) const

Static Public Member Functions

static bool GPGAvailable (void)
static bool keyAvailable (const QString &name)
static void secretKeyList (QStringList &list)
static void publicKeyList (QStringList &list, const QString &pattern=QString())

Protected Slots

void slotGPGExited (KProcess *)
void slotDataFromGPG (KProcess *, char *buf, int len)
void slotErrorFromGPG (KProcess *, char *buf, int len)
void slotSendDataToGPG (KProcess *)

Private Member Functions

void init (void)
bool startProcess (const QStringList &args)
Q_LONG _writeBlock (const char *data, Q_ULONG maxlen)
bool open (int mode, const QString &, bool skipPasswd)

Private Attributes

QString m_fn
QString m_pubring
QString m_secring
QString m_options
QString m_comment
QString m_homedir
KShellProcess * m_process
QValueList< QCString > m_recipient
QCString m_ungetchBuffer
QCString m_errmsg
int m_exitStatus
Q_LONG m_readRemain
char * m_ptrRemain
bool m_needExitLoop

Detailed Description

A class for reading and writing data to/from an encrypted e.g. file.

This class presents a QFile based object to the application but reads/writes data from/to the file through an instance of GPG.

  +------------------+   write  +-----------+     stdin +-------+     +--------+
  |                  |--------->|\          |---------->|       |---->|        |
  | Application code |   read   | QFile     |    stdout |  GPG  |     |  File  |
  |                  |<---------|/          |<----------|       |<----|        |
  +------------------+          |  KGPGFile |           +-------+     +--------+
                |        control|           |
                +-------------->|           |

The write interface contains methods as writeBlock() and putch(), the read interface the methods readBlock(), getch() and ungetch(). The control interface special methods only available with KGPGFile e.g. addRecipient(), keyAvailable() and GPGAvailable(). Other, more general methods such as open(), close() and flush() are not shown in the above picture.

Constructor & Destructor Documentation

KGPGFile::KGPGFile ( const QString &  fname = "",
const QString &  homedir = "~/.gnupg",
const QString &  options = "" 

KGPGFile::~KGPGFile (  ) 

Member Function Documentation

virtual bool KGPGFile::open ( int  mode  )  [virtual]

virtual void KGPGFile::close ( void   )  [virtual]

virtual void KGPGFile::flush ( void   )  [virtual]

virtual Offset KGPGFile::size ( void   )  const [inline, virtual]

virtual Q_LONG KGPGFile::readBlock ( char *  data,
Q_ULONG  maxlen 
) [virtual]

virtual Q_LONG KGPGFile::writeBlock ( const char *  data,
Q_ULONG  maxlen 
) [virtual]

virtual QByteArray KGPGFile::readAll ( void   )  [virtual]

virtual int KGPGFile::getch ( void   )  [virtual]

virtual int KGPGFile::putch ( int  c  )  [virtual]

virtual int KGPGFile::ungetch ( int  c  )  [virtual]

void KGPGFile::addRecipient ( const QCString &  recipient  ) 

Adds a recipient for whom the file should be encrypted. At least one recipient must be specified using this method before the file can be written to. recipient must contain a valid name as defined by GPG. See the GPG documentation for more information.

recipient recipients identification (e.g. e-mail address)

void KGPGFile::setName ( const QString &  fn  ) 

sets the name of the file to fn. This method must be called prior to open().

void KGPGFile::setComment ( const QString &  txt  ) 

const QCString KGPGFile::errmsg ( void   )  const [inline]

int KGPGFile::exitStatus ( void   )  const [inline]

static bool KGPGFile::GPGAvailable ( void   )  [static]

Checks whether GPG is available or not

Return values:
true GPG can be started and returns a version number
false GPG is not available

static bool KGPGFile::keyAvailable ( const QString &  name  )  [static]

Checks whether a key for a given user-id name exists.

name the user-id to be checked. name can be any reference understood by GPG (e.g. an e-mail address or a key-id)
Return values:
true key for user-id name was found
false key for user-id not available

static void KGPGFile::secretKeyList ( QStringList &  list  )  [static]

This function returns a list of the secret keys contained in the keyring. Each list item is devided into two fields separated by a colon (':'). The first field contains the key id, the second field the name. The list may contain multiple entries with the same key-id and different names.

Example of an entry in the list:

"9C59DB40B75DD3BA:Thomas Baumgart <>"

static void KGPGFile::publicKeyList ( QStringList &  list,
const QString &  pattern = QString() 
) [static]

This function returns a list of the public keys contained in the keyring. Each list item is devided into two fields separated by a colon (':'). The first field contains the key id, the second field the name. The list may contain multiple entries with the same key-id and different names.

Example of an entry in the list:

"9C59DB40B75DD3BA:Thomas Baumgart <>"

void KGPGFile::slotGPGExited ( KProcess *   )  [protected, slot]

void KGPGFile::slotDataFromGPG ( KProcess *  ,
char *  buf,
int  len 
) [protected, slot]

void KGPGFile::slotErrorFromGPG ( KProcess *  ,
char *  buf,
int  len 
) [protected, slot]

void KGPGFile::slotSendDataToGPG ( KProcess *   )  [protected, slot]

void KGPGFile::init ( void   )  [private]

bool KGPGFile::startProcess ( const QStringList &  args  )  [private]

Q_LONG KGPGFile::_writeBlock ( const char *  data,
Q_ULONG  maxlen 
) [private]

bool KGPGFile::open ( int  mode,
const QString &  ,
bool  skipPasswd 
) [private]

Member Data Documentation

QString KGPGFile::m_fn [private]

QString KGPGFile::m_pubring [private]

QString KGPGFile::m_secring [private]

QString KGPGFile::m_options [private]

QString KGPGFile::m_comment [private]

QString KGPGFile::m_homedir [private]

KShellProcess* KGPGFile::m_process [private]

QValueList<QCString> KGPGFile::m_recipient [private]

QCString KGPGFile::m_ungetchBuffer [private]

QCString KGPGFile::m_errmsg [private]

int KGPGFile::m_exitStatus [private]

Q_LONG KGPGFile::m_readRemain [private]

char* KGPGFile::m_ptrRemain [private]

bool KGPGFile::m_needExitLoop [private]

The documentation for this class was generated from the following file:

Generated on Wed Jan 26 13:07:33 2011 for KMyMoney by  doxygen 1.5.6