1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
/***************************************************************************
gpg.h - description
-------------------
begin : Sun Mar 17 2002
copyright : (C) 2002 by Vladimir Shutoff
email : vovan@shutoff.ru
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef _GPG_H
#define _GPG_H
#include <qobject.h>
#include <qstring.h>
#include <qvaluelist.h>
#include "cfg.h"
#include "event.h"
#include "plugins.h"
const unsigned long MessageGPGKey = 0x5000;
const unsigned long MessageGPGUse = 0x5001;
struct GpgData
{
SIM::Data GPG;
SIM::Data Home;
SIM::Data GenKey;
SIM::Data PublicList;
SIM::Data SecretList;
SIM::Data Import;
SIM::Data Export;
SIM::Data Encrypt;
SIM::Data Decrypt;
SIM::Data Key;
SIM::Data Passphrases;
SIM::Data Keys;
SIM::Data nPassphrases;
SIM::Data SavePassphrase;
};
struct GpgUserData
{
SIM::Data Key;
SIM::Data Use;
};
class QProcess;
struct DecryptMsg
{
SIM::Message *msg;
QProcess *process;
QString infile;
QString outfile;
unsigned contact;
QString passphrase;
QString key;
};
struct KeyMsg
{
QString key;
SIM::Message *msg;
};
class GpgPlugin : public QObject, public SIM::Plugin, public SIM::EventReceiver
{
Q_OBJECT
public:
GpgPlugin(unsigned, Buffer*);
virtual ~GpgPlugin();
PROP_STR(GPG);
PROP_STR(Home);
PROP_STR(GenKey);
PROP_STR(PublicList);
PROP_STR(SecretList);
PROP_STR(Import);
PROP_STR(Export);
PROP_STR(Encrypt);
PROP_STR(Decrypt);
PROP_STR(Key);
PROP_UTFLIST(Passphrases);
PROP_STRLIST(Keys);
PROP_ULONG(nPassphrases);
PROP_BOOL(SavePassphrase);
QString GPG();
void reset();
static GpgPlugin *plugin;
QValueList<KeyMsg> m_sendKeys;
unsigned long user_data_id;
QString getHomeDir();
protected slots:
void decryptReady();
void importReady();
void publicReady();
void clear();
void passphraseFinished();
void passphraseApply(const QString&);
protected:
virtual QWidget *createConfigWindow(QWidget *parent);
virtual QCString getConfig();
virtual bool processEvent(SIM::Event *e);
void registerMessage();
void unregisterMessage();
void askPassphrase();
bool decode(SIM::Message *msg, const QString &pass, const QString &key);
bool m_bMessage;
QValueList<DecryptMsg> m_decrypt;
QValueList<DecryptMsg> m_import;
QValueList<DecryptMsg> m_public;
QValueList<DecryptMsg> m_wait;
class PassphraseDlg *m_passphraseDlg;
GpgData data;
};
class MsgEdit;
class MsgGPGKey : public QObject, public SIM::EventReceiver
{
Q_OBJECT
public:
MsgGPGKey(MsgEdit *parent, SIM::Message *msg);
~MsgGPGKey();
protected slots:
void init();
void exportReady();
protected:
virtual bool processEvent(SIM::Event *e);
QString m_client;
QString m_key;
MsgEdit *m_edit;
QProcess *m_process;
};
#endif
|