[balsa] New option to configure GMime-2.4 or 2.6.
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] New option to configure GMime-2.4 or 2.6.
- Date: Sat, 20 Feb 2010 01:44:58 +0000 (UTC)
commit bffdd37969c10e34264ef0632a3a2187e9a43967
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Fri Feb 19 20:44:13 2010 -0500
New option to configure GMime-2.4 or 2.6.
* configure.in: option to configure GMime-2.4 or 2.6.
* libbalsa/gmime-gpgme-context.c (g_mime_gpgme_context_finalize),
(g_mime_session_passphrase), (g_mime_gpgme_context_new):
* libbalsa/gmime-gpgme-context.h: use it.
* libbalsa/gmime-stream-gio.c: ditto.
* libbalsa/mailbox_mbox.c: ditto.
* libbalsa/rfc3156.c (password_request_func),
(libbalsa_sign_mime_object), (libbalsa_encrypt_mime_object),
(libbalsa_body_check_signature), (libbalsa_body_decrypt),
(libbalsa_rfc2440_sign_encrypt), (libbalsa_rfc2440_verify),
(libbalsa_rfc2440_decrypt): ditto.
ChangeLog | 14 ++++
configure.in | 19 +++++-
libbalsa/gmime-gpgme-context.c | 27 ++++++++
libbalsa/gmime-gpgme-context.h | 8 +++
libbalsa/gmime-stream-gio.c | 8 +++
libbalsa/mailbox_mbox.c | 6 --
libbalsa/rfc3156.c | 128 ++++++++++++++++++++++++++++++++++++++++
7 files changed, 202 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index def9198..87c8db1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2010-02-19 Peter Bloomfield
+
+ * configure.in: option to configure GMime-2.4 or 2.6.
+ * libbalsa/gmime-gpgme-context.c (g_mime_gpgme_context_finalize),
+ (g_mime_session_passphrase), (g_mime_gpgme_context_new):
+ * libbalsa/gmime-gpgme-context.h: use it.
+ * libbalsa/gmime-stream-gio.c: ditto.
+ * libbalsa/mailbox_mbox.c: ditto.
+ * libbalsa/rfc3156.c (password_request_func),
+ (libbalsa_sign_mime_object), (libbalsa_encrypt_mime_object),
+ (libbalsa_body_check_signature), (libbalsa_body_decrypt),
+ (libbalsa_rfc2440_sign_encrypt), (libbalsa_rfc2440_verify),
+ (libbalsa_rfc2440_decrypt): ditto.
+
2010-02-17 Albrecht DreÃ?
* libbalsa/imap/imap-commands.c: implement QUOTA, MYRIGHTS and GETACL
diff --git a/configure.in b/configure.in
index cfb4eea..be1a7c0 100644
--- a/configure.in
+++ b/configure.in
@@ -193,6 +193,11 @@ AC_ARG_WITH(unique,
[Use libUnique instead of BonoboActivation (default=no)]),
[with_unique=$withval],[with_unique=no])
+AC_ARG_WITH(gmime,
+ AC_HELP_STRING([--with-gmime],
+ [Version of GMime (default=2.4)]),
+ [with_gmime=$withval],[with_gmime=2.4])
+
AC_ARG_ENABLE(more-warnings,
AC_HELP_STRING([--enable-more-warnings],
[Enable maximum compiler warnings (default=yes)]),
@@ -304,7 +309,7 @@ dnl #####################################################################
PKG_CHECK_MODULES(BALSA, [
glib-2.0 >= 2.16.0
gtk+-2.0 >= 2.14.0
-gmime-2.4
+gmime-$with_gmime
gio-2.0
gnome-icon-theme
$gnome_extras
@@ -313,7 +318,7 @@ $gnome_extras
PKG_CHECK_MODULES(BALSA_AB, [
glib-2.0 >= 2.6.0
gtk+-2.0 >= 2.6.0
- gmime-2.4
+ gmime-$with_gmime
$gnome_extras
])
@@ -807,6 +812,15 @@ else
AC_MSG_RESULT([no])
fi
+# GMime configuration
+#
+case $with_gmime in
+ 2.4) ;;
+ 2.6) AC_DEFINE([HAVE_GMIME_2_6], [1],
+ [Defined to build with GMime version 2.5 or 2.6]) ;;
+ *) AC_MSG_ERROR([unknown GMime version $with_gmime]) ;;
+esac
+
dnl #####################################################################
dnl 5. Headers.
dnl #####################################################################
@@ -1005,6 +1019,7 @@ echo " Use GtkSourceView: $with_gtksourceview"
echo " Use Compface: $with_compface"
echo " Install extra MIME icons: $install_mimeicons"
echo " Configure for Touch UI: $enable_touch_ui"
+echo " GMime version: $with_gmime"
dnl echo " Use SASL: $need_sasl"
echo ""
diff --git a/libbalsa/gmime-gpgme-context.c b/libbalsa/gmime-gpgme-context.c
index fe3df58..24b140b 100644
--- a/libbalsa/gmime-gpgme-context.c
+++ b/libbalsa/gmime-gpgme-context.c
@@ -189,7 +189,9 @@ g_mime_gpgme_context_finalize(GObject * object)
ctx->sig_state = NULL;
}
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(GMIME_CIPHER_CONTEXT(ctx)->session);
+#endif /* HAVE_GMIME_2_6 */
G_OBJECT_CLASS(parent_class)->finalize(object);
}
@@ -278,6 +280,17 @@ g_mime_session_passphrase(void *HOOK, const char *UID_HINT,
int FD)
{
GMimeCipherContext *ctx = GMIME_CIPHER_CONTEXT(HOOK);
+#if defined(HAVE_GMIME_2_6)
+ GMimeStream *stream;
+ gboolean rc;
+
+ stream = g_mime_stream_fs_new(FD);
+ rc = (*ctx->request_passwd) (ctx, UID_HINT, PASSPHRASE_INFO,
+ PREV_WAS_BAD, stream, NULL);
+ g_object_unref(stream);
+
+ return rc ? GPG_ERR_NO_ERROR : GPG_ERR_CANCELED;
+#else /* HAVE_GMIME_2_6 */
GMimeSession *session = ctx->session;
gchar *msg, *passphrase;
@@ -305,6 +318,7 @@ g_mime_session_passphrase(void *HOOK, const char *UID_HINT,
perror(__func__);
return GPG_ERR_CANCELED;
}
+#endif /* HAVE_GMIME_2_6 */
}
@@ -727,15 +741,24 @@ g_mime_gpgme_decrypt(GMimeCipherContext * context, GMimeStream * istream,
* NULL and set error.
*/
GMimeCipherContext *
+#if defined(HAVE_GMIME_2_6)
+g_mime_gpgme_context_new(GMimePasswordRequestFunc request_passwd,
+ gpgme_protocol_t protocol, GError ** error)
+#else /* HAVE_GMIME_2_6 */
g_mime_gpgme_context_new(GMimeSession * session,
gpgme_protocol_t protocol, GError ** error)
+#endif /* HAVE_GMIME_2_6 */
{
GMimeCipherContext *cipher;
GMimeGpgmeContext *ctx;
gpgme_error_t err;
gpgme_ctx_t gpgme_ctx;
+#if defined(HAVE_GMIME_2_6)
+ g_return_val_if_fail(request_passwd, NULL);
+#else /* HAVE_GMIME_2_6 */
g_return_val_if_fail(GMIME_IS_SESSION(session), NULL);
+#endif /* HAVE_GMIME_2_6 */
/* creating the gpgme context may fail, so do this first to get the info */
if ((err = gpgme_new(&gpgme_ctx)) != GPG_ERR_NO_ERROR) {
@@ -761,8 +784,12 @@ g_mime_gpgme_context_new(GMimeSession * session,
}
/* setup according to requested protocol */
+#if defined(HAVE_GMIME_2_6)
+ cipher->request_passwd = request_passwd;
+#else /* HAVE_GMIME_2_6 */
cipher->session = session;
g_object_ref(session);
+#endif /* HAVE_GMIME_2_6 */
gpgme_set_protocol(gpgme_ctx, protocol);
if (protocol == GPGME_PROTOCOL_OpenPGP) {
cipher->sign_protocol = "application/pgp-signature";
diff --git a/libbalsa/gmime-gpgme-context.h b/libbalsa/gmime-gpgme-context.h
index e484f76..585d927 100644
--- a/libbalsa/gmime-gpgme-context.h
+++ b/libbalsa/gmime-gpgme-context.h
@@ -25,6 +25,7 @@
#include <gmime/gmime.h>
#include <gpgme.h>
#include "gmime-gpgme-signature.h"
+#include "config.h"
#ifdef __cplusplus
@@ -84,9 +85,16 @@ struct _GMimeGpgmeContextClass {
GType g_mime_gpgme_context_get_type(void);
+#if defined(HAVE_GMIME_2_6)
+GMimeCipherContext *g_mime_gpgme_context_new(GMimePasswordRequestFunc
+ request_passwd,
+ gpgme_protocol_t protocol,
+ GError ** error);
+#else /* HAVE_GMIME_2_6 */
GMimeCipherContext *g_mime_gpgme_context_new(GMimeSession * session,
gpgme_protocol_t protocol,
GError ** error);
+#endif /* HAVE_GMIME_2_6 */
#ifdef __cplusplus
diff --git a/libbalsa/gmime-stream-gio.c b/libbalsa/gmime-stream-gio.c
index bb6ed16..214c785 100644
--- a/libbalsa/gmime-stream-gio.c
+++ b/libbalsa/gmime-stream-gio.c
@@ -51,7 +51,11 @@ static gint64 stream_seek(GMimeStream *stream,
gint64 offset,
GMimeSeekWhence whence);
static gint64 stream_tell(GMimeStream *stream);
+#if defined(HAVE_GMIME_2_6)
+static gint64 stream_length(GMimeStream *stream);
+#else /* HAVE_GMIME_2_6 */
static ssize_t stream_length(GMimeStream *stream);
+#endif /* HAVE_GMIME_2_6 */
static GMimeStream *stream_substream(GMimeStream *stream,
gint64 start,
gint64 end);
@@ -379,7 +383,11 @@ stream_tell (GMimeStream *stream)
return stream->position;
}
+#if defined(HAVE_GMIME_2_6)
+static gint64
+#else /* HAVE_GMIME_2_6 */
static ssize_t
+#endif /* HAVE_GMIME_2_6 */
stream_length(GMimeStream *stream)
{
goffset bound_end;
diff --git a/libbalsa/mailbox_mbox.c b/libbalsa/mailbox_mbox.c
index 946b553..b77d7f5 100644
--- a/libbalsa/mailbox_mbox.c
+++ b/libbalsa/mailbox_mbox.c
@@ -1843,12 +1843,6 @@ static void update_message_status_headers(GMimeMessage *message,
g_string_free(new_header, TRUE);
}
-#if defined(GMIME_MAJOR_VERSION)
-# if GMIME_CHECK_VERSION(2, 6, 0)
-# define HAVE_GMIME_2_6 TRUE
-# endif /* GMIME_CHECK_VERSION(2, 6, 0) */
-#endif /* defined(GMIME_MAJOR_VERSION) */
-
#if !defined(HAVE_GMIME_2_6)
/*
* Encode text parts as quoted-printable.
diff --git a/libbalsa/rfc3156.c b/libbalsa/rfc3156.c
index 78cd2f2..bc15700 100644
--- a/libbalsa/rfc3156.c
+++ b/libbalsa/rfc3156.c
@@ -260,6 +260,36 @@ libbalsa_message_body_protection(LibBalsaMessageBody * body)
return result;
}
+#if defined(HAVE_GMIME_2_6)
+static gboolean
+password_request_func(GMimeCipherContext * ctx, const char *user_id,
+ const char *prompt_ctx, gboolean reprompt,
+ GMimeStream * response, GError ** err)
+{
+ gint fd;
+ gchar *name_used;
+ gboolean rc;
+
+ fd = g_file_open_tmp(NULL, &name_used, NULL);
+ if (fd < 0)
+ return FALSE;
+
+ rc = get_passphrase_cb(ctx, user_id, prompt_ctx, reprompt, fd)
+ == GPG_ERR_NO_ERROR;
+ if (rc) {
+ GMimeStream *stream = g_mime_stream_fs_new(fd);
+ g_mime_stream_reset(stream);
+ g_mime_stream_write_to_stream(response, stream);
+
+ g_object_unref(stream);
+ }
+
+ unlink(name_used);
+ g_free(name_used);
+
+ return rc;
+}
+#endif /* HAVE_GMIME_2_6 */
/* === RFC 2633/ RFC 3156 crypto routines === */
/*
@@ -275,7 +305,9 @@ libbalsa_sign_mime_object(GMimeObject ** content, const gchar * rfc822_for,
gpgme_protocol_t protocol, GtkWindow * parent,
GError ** error)
{
+#if !defined(HAVE_GMIME_2_6)
GMimeSession *session;
+#endif /* HAVE_GMIME_2_6 */
GMimeGpgmeContext *ctx;
GMimeMultipartSigned *mps;
@@ -290,6 +322,13 @@ libbalsa_sign_mime_object(GMimeObject ** content, const gchar * rfc822_for,
if (protocol == GPGME_PROTOCOL_OpenPGP && gpg_updates_trustdb())
return FALSE;
+#if defined(HAVE_GMIME_2_6)
+ /* create a GMimeGpgmeContext */
+ ctx = GMIME_GPGME_CONTEXT(g_mime_gpgme_context_new
+ (password_request_func, protocol, error));
+ if (ctx == NULL)
+ return FALSE;
+#else /* HAVE_GMIME_2_6 */
/* create a session and a GMimeGpgmeContext */
session = g_object_new(g_mime_session_get_type(), NULL, NULL);
ctx = GMIME_GPGME_CONTEXT(g_mime_gpgme_context_new(session, protocol,
@@ -298,6 +337,7 @@ libbalsa_sign_mime_object(GMimeObject ** content, const gchar * rfc822_for,
g_object_unref(session);
return FALSE;
}
+#endif /* HAVE_GMIME_2_6 */
/* set the callbacks for the passphrase entry and the key selection */
if (g_getenv("GPG_AGENT_INFO"))
@@ -314,7 +354,9 @@ libbalsa_sign_mime_object(GMimeObject ** content, const gchar * rfc822_for,
/* call gpgme to create the signature */
if (!(mps = g_mime_multipart_signed_new())) {
g_object_unref(ctx);
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
return FALSE;
}
@@ -323,7 +365,9 @@ libbalsa_sign_mime_object(GMimeObject ** content, const gchar * rfc822_for,
GMIME_CIPHER_HASH_DEFAULT, error) != 0) {
g_object_unref(mps);
g_object_unref(ctx);
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
return FALSE;
}
@@ -332,7 +376,9 @@ libbalsa_sign_mime_object(GMimeObject ** content, const gchar * rfc822_for,
g_object_unref(G_OBJECT(*content));
*content = GMIME_OBJECT(mps);
g_object_unref(ctx);
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
return TRUE;
}
@@ -347,7 +393,9 @@ libbalsa_encrypt_mime_object(GMimeObject ** content, GList * rfc822_for,
gpgme_protocol_t protocol, gboolean always_trust,
GtkWindow * parent, GError ** error)
{
+#if !defined(HAVE_GMIME_2_6)
GMimeSession *session;
+#endif /* HAVE_GMIME_2_6 */
GMimeGpgmeContext *ctx;
GMimeObject *encrypted_obj = NULL;
GPtrArray *recipients;
@@ -364,6 +412,7 @@ libbalsa_encrypt_mime_object(GMimeObject ** content, GList * rfc822_for,
if (protocol == GPGME_PROTOCOL_OpenPGP && gpg_updates_trustdb())
return FALSE;
+#if !defined(HAVE_GMIME_2_6)
/* create a session and a GMimeGpgmeContext */
session = g_object_new(g_mime_session_get_type(), NULL, NULL);
ctx = GMIME_GPGME_CONTEXT(g_mime_gpgme_context_new(session, protocol,
@@ -371,7 +420,16 @@ libbalsa_encrypt_mime_object(GMimeObject ** content, GList * rfc822_for,
if (ctx == NULL) {
g_object_unref(session);
return FALSE;
+#else /* HAVE_GMIME_2_6 */
+ /* create a GMimeGpgmeContext */
+ ctx = GMIME_GPGME_CONTEXT(g_mime_gpgme_context_new
+ (password_request_func, protocol, error));
+ if (ctx == NULL)
+ return FALSE;
+#endif /* HAVE_GMIME_2_6 */
+#if !defined(HAVE_GMIME_2_6)
}
+#endif /* HAVE_GMIME_2_6 */
/* set the callback for the key selection (no secret needed here) */
ctx->key_select_cb = select_key_from_list;
@@ -417,7 +475,9 @@ libbalsa_encrypt_mime_object(GMimeObject ** content, GList * rfc822_for,
if (result != 0) {
g_ptr_array_free(recipients, FALSE);
g_object_unref(ctx);
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
g_object_unref(encrypted_obj);
return FALSE;
}
@@ -426,7 +486,9 @@ libbalsa_encrypt_mime_object(GMimeObject ** content, GList * rfc822_for,
g_object_unref(G_OBJECT(*content));
*content = GMIME_OBJECT(encrypted_obj);
g_object_unref(ctx);
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
return TRUE;
}
@@ -494,7 +556,9 @@ gboolean
libbalsa_body_check_signature(LibBalsaMessageBody * body,
gpgme_protocol_t protocol)
{
+#if !defined(HAVE_GMIME_2_6)
GMimeSession *session;
+#endif /* HAVE_GMIME_2_6 */
GMimeCipherContext *ctx;
GMimeSignatureValidity *valid;
GError *error = NULL;
@@ -520,8 +584,13 @@ libbalsa_body_check_signature(LibBalsaMessageBody * body,
g_object_unref(G_OBJECT(body->parts->next->sig_info));
/* try to create GMimeGpgMEContext */
+#if !defined(HAVE_GMIME_2_6)
session = g_object_new(g_mime_session_get_type(), NULL, NULL);
ctx = g_mime_gpgme_context_new(session, protocol, &error);
+#else /* HAVE_GMIME_2_6 */
+ ctx =
+ g_mime_gpgme_context_new(password_request_func, protocol, &error);
+#endif /* HAVE_GMIME_2_6 */
if (ctx == NULL) {
if (error) {
libbalsa_information(LIBBALSA_INFORMATION_ERROR, "%s: %s",
@@ -531,7 +600,9 @@ libbalsa_body_check_signature(LibBalsaMessageBody * body,
} else
libbalsa_information(LIBBALSA_INFORMATION_ERROR,
_("creating a gpgme context failed"));
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
body->parts->next->sig_info = g_mime_gpgme_sigstat_new();
body->parts->next->sig_info->status = GPGME_SIG_STAT_ERROR;
return FALSE;
@@ -571,7 +642,9 @@ libbalsa_body_check_signature(LibBalsaMessageBody * body,
}
g_mime_signature_validity_free(valid);
g_object_unref(ctx);
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
return TRUE;
}
@@ -585,7 +658,9 @@ LibBalsaMessageBody *
libbalsa_body_decrypt(LibBalsaMessageBody * body,
gpgme_protocol_t protocol, GtkWindow * parent)
{
+#if !defined(HAVE_GMIME_2_6)
GMimeSession *session;
+#endif /* HAVE_GMIME_2_6 */
GMimeGpgmeContext *ctx;
GMimeObject *mime_obj = NULL;
GError *error = NULL;
@@ -628,10 +703,16 @@ libbalsa_body_decrypt(LibBalsaMessageBody * body,
}
#endif
+#if !defined(HAVE_GMIME_2_6)
/* create a session and a GMimeGpgmeContext */
session = g_object_new(g_mime_session_get_type(), NULL, NULL);
ctx = GMIME_GPGME_CONTEXT(g_mime_gpgme_context_new(session, protocol,
&error));
+#else /* HAVE_GMIME_2_6 */
+ /* create a GMimeGpgmeContext */
+ ctx = GMIME_GPGME_CONTEXT(g_mime_gpgme_context_new
+ (password_request_func, protocol, &error));
+#endif /* HAVE_GMIME_2_6 */
if (ctx == NULL) {
if (error) {
libbalsa_information(LIBBALSA_INFORMATION_ERROR, "%s: %s",
@@ -641,7 +722,9 @@ libbalsa_body_decrypt(LibBalsaMessageBody * body,
} else
libbalsa_information(LIBBALSA_INFORMATION_ERROR,
_("creating a gpgme context failed"));
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
return body;
}
@@ -692,7 +775,9 @@ libbalsa_body_decrypt(LibBalsaMessageBody * body,
libbalsa_information(LIBBALSA_INFORMATION_ERROR,
_("decryption failed"));
g_object_unref(ctx);
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
return body;
}
message = body->message;
@@ -713,7 +798,9 @@ libbalsa_body_decrypt(LibBalsaMessageBody * body,
body->sig_info = ctx->sig_state;
}
g_object_unref(ctx);
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
return body;
}
@@ -726,7 +813,9 @@ libbalsa_rfc2440_sign_encrypt(GMimePart * part, const gchar * sign_for,
GList * encrypt_for, gboolean always_trust,
GtkWindow * parent, GError ** error)
{
+#if !defined(HAVE_GMIME_2_6)
GMimeSession *session;
+#endif /* HAVE_GMIME_2_6 */
GMimeGpgmeContext *ctx;
GPtrArray *recipients;
gint result;
@@ -739,6 +828,7 @@ libbalsa_rfc2440_sign_encrypt(GMimePart * part, const gchar * sign_for,
if (gpg_updates_trustdb())
return FALSE;
+#if !defined(HAVE_GMIME_2_6)
/* create a session and a GMimeGpgmeContext */
session = g_object_new(g_mime_session_get_type(), NULL, NULL);
ctx = GMIME_GPGME_CONTEXT(g_mime_gpgme_context_new(session,
@@ -746,8 +836,16 @@ libbalsa_rfc2440_sign_encrypt(GMimePart * part, const gchar * sign_for,
error));
if (ctx == NULL) {
g_object_unref(session);
+#else /* HAVE_GMIME_2_6 */
+ /* create a GMimeGpgmeContext */
+ ctx = GMIME_GPGME_CONTEXT(g_mime_gpgme_context_new
+ (password_request_func, GPGME_PROTOCOL_OpenPGP, error));
+ if (ctx == NULL)
+#endif /* HAVE_GMIME_2_6 */
return FALSE;
+#if !defined(HAVE_GMIME_2_6)
}
+#endif /* HAVE_GMIME_2_6 */
/* set the callback for the key selection and the passphrase */
if (sign_for) {
@@ -784,7 +882,9 @@ libbalsa_rfc2440_sign_encrypt(GMimePart * part, const gchar * sign_for,
if (recipients)
g_ptr_array_free(recipients, FALSE);
g_object_unref(ctx);
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
return (result == 0) ? TRUE : FALSE;
}
@@ -796,7 +896,9 @@ libbalsa_rfc2440_sign_encrypt(GMimePart * part, const gchar * sign_for,
gpgme_error_t
libbalsa_rfc2440_verify(GMimePart * part, GMimeGpgmeSigstat ** sig_info)
{
+#if !defined(HAVE_GMIME_2_6)
GMimeSession *session;
+#endif /* HAVE_GMIME_2_6 */
GMimeGpgmeContext *ctx;
GMimeSignatureValidity *valid;
GError *error = NULL;
@@ -815,11 +917,17 @@ libbalsa_rfc2440_verify(GMimePart * part, GMimeGpgmeSigstat ** sig_info)
if (gpg_updates_trustdb())
return GPG_ERR_TRY_AGAIN;
+#if !defined(HAVE_GMIME_2_6)
/* create a session and a GMimeGpgmeContext */
session = g_object_new(g_mime_session_get_type(), NULL, NULL);
ctx = GMIME_GPGME_CONTEXT(g_mime_gpgme_context_new(session,
GPGME_PROTOCOL_OpenPGP,
&error));
+#else /* HAVE_GMIME_2_6 */
+ /* create a GMimeGpgmeContext */
+ ctx = GMIME_GPGME_CONTEXT(g_mime_gpgme_context_new
+ (password_request_func, GPGME_PROTOCOL_OpenPGP, &error));
+#endif /* HAVE_GMIME_2_6 */
if (ctx == NULL) {
if (error) {
libbalsa_information(LIBBALSA_INFORMATION_ERROR, "%s: %s",
@@ -829,7 +937,9 @@ libbalsa_rfc2440_verify(GMimePart * part, GMimeGpgmeSigstat ** sig_info)
} else
libbalsa_information(LIBBALSA_INFORMATION_ERROR,
_("creating a gpgme context failed"));
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
return FALSE;
}
@@ -849,7 +959,9 @@ libbalsa_rfc2440_verify(GMimePart * part, GMimeGpgmeSigstat ** sig_info)
retval = GPG_ERR_GENERAL;
}
g_object_unref(ctx);
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
return retval;
}
@@ -863,7 +975,9 @@ libbalsa_rfc2440_verify(GMimePart * part, GMimeGpgmeSigstat ** sig_info)
g_mime_signature_validity_free(valid);
retval = ctx->sig_state->status;
g_object_unref(ctx);
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
return retval;
}
@@ -877,7 +991,9 @@ gpgme_error_t
libbalsa_rfc2440_decrypt(GMimePart * part, GMimeGpgmeSigstat ** sig_info,
GtkWindow * parent)
{
+#if !defined(HAVE_GMIME_2_6)
GMimeSession *session;
+#endif /* HAVE_GMIME_2_6 */
GMimeGpgmeContext *ctx;
GError *error = NULL;
gpgme_error_t retval;
@@ -895,11 +1011,17 @@ libbalsa_rfc2440_decrypt(GMimePart * part, GMimeGpgmeSigstat ** sig_info,
if (gpg_updates_trustdb())
return GPG_ERR_TRY_AGAIN;
+#if !defined(HAVE_GMIME_2_6)
/* create a session and a GMimeGpgmeContext */
session = g_object_new(g_mime_session_get_type(), NULL, NULL);
ctx =
GMIME_GPGME_CONTEXT(g_mime_gpgme_context_new
(session, GPGME_PROTOCOL_OpenPGP, &error));
+#else /* HAVE_GMIME_2_6 */
+ /* create a GMimeGpgmeContext */
+ ctx = GMIME_GPGME_CONTEXT(g_mime_gpgme_context_new
+ (password_request_func, GPGME_PROTOCOL_OpenPGP, &error));
+#endif /* HAVE_GMIME_2_6 */
if (ctx == NULL) {
if (error) {
libbalsa_information(LIBBALSA_INFORMATION_ERROR, "%s: %s",
@@ -909,7 +1031,9 @@ libbalsa_rfc2440_decrypt(GMimePart * part, GMimeGpgmeSigstat ** sig_info,
} else
libbalsa_information(LIBBALSA_INFORMATION_ERROR,
_("creating a gpgme context failed"));
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
return GPG_ERR_GENERAL;
}
@@ -939,7 +1063,9 @@ libbalsa_rfc2440_decrypt(GMimePart * part, GMimeGpgmeSigstat ** sig_info,
retval = GPG_ERR_GENERAL;
}
g_object_unref(ctx);
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
return retval;
}
@@ -955,7 +1081,9 @@ libbalsa_rfc2440_decrypt(GMimePart * part, GMimeGpgmeSigstat ** sig_info,
/* clean up */
g_object_unref(ctx);
+#if !defined(HAVE_GMIME_2_6)
g_object_unref(session);
+#endif /* HAVE_GMIME_2_6 */
return retval;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]