Ran qt3to4
[basket4.git] / src / kgpgme.h
blob6dcbab507062a41e95209f3e73a2ab57570240eb
1 /***************************************************************************
2 * Copyright (C) 2006 by Petri Damsten *
3 * damu@iki.fi *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20 #ifndef KGPGME_H
21 #define KGPGME_H
23 #include <config.h>
24 //Added by qt3to4:
25 #include <Q3CString>
26 #include <Q3ValueList>
28 #ifdef HAVE_LIBGPGME
30 #include <gpgme.h>
31 #include <qstringlist.h>
33 /**
34 @author Petri Damsten <damu@iki.fi>
37 class KGpgKey
39 public:
40 QString id;
41 QString name;
42 QString email;
45 typedef Q3ValueList< KGpgKey > KGpgKeyList;
47 class KGpgMe
49 public:
50 KGpgMe();
51 ~KGpgMe();
53 QString selectKey(QString previous = QString::null);
54 KGpgKeyList keys(bool privateKeys = false) const;
55 void setText(QString text, bool saving) { m_text = text; m_saving = saving; };
56 void setUseGnuPGAgent(bool use) { m_useGnuPGAgent = use; setPassphraseCb(); };
57 QString text() const { return m_text; };
58 bool saving() const { return m_saving; };
59 void clearCache();
61 bool encrypt(const QByteArray& inBuffer, Q_ULONG length,
62 QByteArray* outBuffer, QString keyid = QString::null);
63 bool decrypt(const QByteArray& inBuffer, QByteArray* outBuffer);
65 static QString checkForUtf8(QString txt);
66 static bool isGnuPGAgentAvailable();
68 private:
69 gpgme_ctx_t m_ctx;
70 QString m_text;
71 bool m_saving;
72 bool m_useGnuPGAgent;
73 Q3CString m_cache;
75 void init(gpgme_protocol_t proto);
76 gpgme_error_t readToBuffer(gpgme_data_t in, QByteArray* outBuffer) const;
77 void setPassphraseCb();
78 static gpgme_error_t passphraseCb(void *hook, const char *uid_hint,
79 const char *passphrase_info,
80 int last_was_bad, int fd);
81 gpgme_error_t passphrase(const char *uid_hint,
82 const char *passphrase_info,
83 int last_was_bad, int fd);
85 #endif // HAVE_LIBGPGME
86 #endif // KGPGME_H