aboutsummaryrefslogtreecommitdiffstats
path: root/context.h
diff options
context:
space:
mode:
authorubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2008-08-15 23:26:50 +0000
committerubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2008-08-15 23:26:50 +0000
commit34eea857ef69fe3210d3787f343ae2f84b04a0b1 (patch)
tree90b854a1efa0c5f0ff3e73bef6f8eb11510b9b01 /context.h
downloadgpg4usb-34eea857ef69fe3210d3787f343ae2f84b04a0b1.tar.gz
gpg4usb-34eea857ef69fe3210d3787f343ae2f84b04a0b1.zip
reorganized svn to support tags and branches
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@142 34ebc366-c3a9-4b3c-9f84-69acf7962910
Diffstat (limited to 'context.h')
-rw-r--r--context.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/context.h b/context.h
new file mode 100644
index 0000000..868b085
--- /dev/null
+++ b/context.h
@@ -0,0 +1,80 @@
+/*
+ * context.h
+ *
+ * Copyright 2008 gpg4usb-team <[email protected]>
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#ifndef __SGPGMEPP_CONTEXT_H__
+#define __SGPGMEPP_CONTEXT_H__
+
+#include <gpgme.h>
+#include <QByteArray>
+#include <QString>
+#include <QLinkedList>
+
+class GpgKey
+{
+public:
+ QString id;
+ QString name;
+ QString email;
+ int privkey;
+};
+
+typedef QLinkedList< GpgKey > GpgKeyList;
+
+namespace GpgME
+{
+
+class Context
+{
+
+public:
+ Context(); // Consttructor
+ ~Context(); // Destructor
+
+ void importKeyFromFile(QString pathToFile);
+ void importKey(QByteArray inBuffer);
+ GpgKeyList listKeys();
+ void deleteKeys(QList<QString> *uidList);
+ bool encrypt(QList<QString> *uidList, const QByteArray &inBuffer,
+ QByteArray *outBuffer);
+ bool decrypt(const QByteArray &inBuffer, QByteArray *outBuffer);
+ void clearCache();
+
+private:
+ gpgme_ctx_t m_ctx;
+ gpgme_data_t in, out;
+ gpgme_error_t err;
+ gpgme_error_t readToBuffer(gpgme_data_t in, QByteArray *outBuffer);
+ QByteArray m_cache;
+ bool debug;
+ void checkErr(gpgme_error_t err) const;
+ void checkErr(gpgme_error_t err, QString comment) const;
+
+ static gpgme_error_t passphraseCb(void *hook, const char *uid_hint,
+ const char *passphrase_info,
+ int last_was_bad, int fd);
+ gpgme_error_t passphrase(const char *uid_hint,
+ const char *passphrase_info,
+ int last_was_bad, int fd);
+
+};
+} // namespace GpgME
+
+#endif // __SGPGMEPP_CONTEXT_H__