+2003-10-17 [christoph] 0.9.6claws32
+
+ * src/Makefile.am
+ * src/main.c
+ * src/mimeview.c
+ * src/noticeview.c
+ * src/pgpmime.[ch] ** NEW **
+ * src/privacy.[ch]
+ * src/rfc2015.c
+ * src/sgpgme.c ** NEW **
+ reimplement PGP/Mime signature checking (unfinished)
+
2003-10-15 [christoph] 0.9.6claws31
* src/procmime.[ch]
MICRO_VERSION=6
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=31
+EXTRA_VERSION=32
if test $EXTRA_VERSION -eq 0; then
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
else
sylpheed_SOURCES = \
account.c \
action.c \
- addr_compl.c \
addrbook.c \
addrcache.c \
addrclip.c \
+ addr_compl.c \
addressadd.c \
addressbook.c \
addrgather.c \
editbook.c \
editgroup.c \
editjpilot.c \
- editldap.c \
editldap_basedn.c \
+ editldap.c \
editvcard.c \
enriched.c \
exphtmldlg.c \
news.c \
noticeview.c \
passphrase.c \
+ pgpmime.c \
pine.c \
pop.c \
prefs_account.c \
prefs_common.c \
prefs_customheader.c \
prefs_display_header.c \
- prefs_filtering.c \
prefs_filtering_action.c \
+ prefs_filtering.c \
prefs_folder_item.c \
prefs_fonts.c \
prefs_gtk.c \
select-keys.c \
send_message.c \
setup.c \
+ sgpgme.c \
sigstatus.c \
simple-gettext.c \
sourcewindow.c \
account.h \
action.h \
adbookbase.h \
- addr_compl.h \
addrbook.h \
addrcache.h \
addrclip.h \
+ addr_compl.h \
addressadd.h \
addressbook.h \
addressitem.h \
editbook.h \
editgroup.h \
editjpilot.h \
- editldap.h \
editldap_basedn.h \
+ editldap.h \
editvcard.h \
enriched.h \
exphtmldlg.h \
matcher_parser.h \
matcher_parser_lex.h \
matcher_parser_parse.h \
- mbox.h \
mbox_folder.h \
+ mbox.h \
message_search.h \
messageview.h \
mh.h \
news.h \
noticeview.h \
passphrase.h \
+ pgpmime.h \
pine.h \
pop.h \
prefs_account.h \
prefs_common.h \
prefs_customheader.h \
prefs_display_header.h \
- prefs_filtering.h \
prefs_filtering_action.h \
+ prefs_filtering.h \
prefs_folder_item.h \
prefs_fonts.h \
prefs_gtk.h \
select-keys.h \
send_message.h \
setup.h \
+ sgpgme.h \
sigstatus.h \
sourcewindow.h \
ssl_manager.h \
#include "plugin.h"
#if USE_GPGME
-# include "rfc2015.h"
+# include "sgpgme.h"
+# include "pgpmime.h"
#endif
#if USE_OPENSSL
# include "ssl.h"
prefs_common_read_config();
#if USE_GPGME
- rfc2015_init();
+ sgpgme_init();
+ pgpmime_init();
#endif
prefs_fonts_init();
addressbook_destroy();
#ifdef USE_GPGME
- rfc2015_done();
+ pgpmime_done();
+ sgpgme_done();
#endif
prefs_fonts_done();
icon_list_clear(mimeview);
}
+static void check_signature_cb(GtkWidget *widget, gpointer user_data);
+
+static void update_signature_noticeview(MimeView *mimeview, MimeInfo *mimeinfo)
+{
+ if (privacy_mimeinfo_is_signed(mimeinfo)) {
+ gchar *text = NULL, *button_text = NULL;
+ GtkSignalFunc func = NULL;
+
+ switch (privacy_mimeinfo_get_sig_status(mimeinfo)) {
+ case SIGNATURE_UNCHECKED:
+ text = _("This part of the message has been signed");
+ button_text = _("Check");
+ func = check_signature_cb;
+ break;
+ case SIGNATURE_OK:
+ case SIGNATURE_WARN:
+ text = _("Signature is ok");
+ break;
+ case SIGNATURE_INVALID:
+ text = _("The signature of this part is invalid");
+ break;
+ case SIGNATURE_CHECK_FAILED:
+ text = _("Checking the signature failed");
+ button_text = _("Check again");
+ func = check_signature_cb;
+ default:
+ break;
+ }
+ noticeview_set_text(mimeview->siginfoview, text);
+ noticeview_set_button_text(mimeview->siginfoview, button_text);
+ noticeview_set_button_press_callback(
+ mimeview->siginfoview,
+ func,
+ (gpointer) mimeview);
+ noticeview_show(mimeview->siginfoview);
+ } else {
+ noticeview_hide(mimeview->siginfoview);
+ }
+}
+
+static void check_signature_cb(GtkWidget *widget, gpointer user_data)
+{
+ MimeView *mimeview = (MimeView *) user_data;
+ MimeInfo *mimeinfo = mimeview_get_selected_part(mimeview);
+
+ privacy_mimeinfo_check_signature(mimeinfo);
+ update_signature_noticeview(mimeview, mimeinfo);
+}
+
static void mimeview_selected(GtkCTree *ctree, GtkCTreeNode *node, gint column,
MimeView *mimeview)
{
mimeview->textview->default_text = FALSE;
- if (privacy_mimeinfo_is_signed(partinfo)) {
- noticeview_set_text(mimeview->siginfoview, "Signed Part");
- noticeview_show(mimeview->siginfoview);
- } else {
- noticeview_hide(mimeview->siginfoview);
- }
+ update_signature_noticeview(mimeview, partinfo);
if (!mimeview_show_part(mimeview, partinfo)) {
switch (partinfo->type) {
gtk_signal_connect(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(noticeview_button_pressed),
(gpointer) noticeview);
- gtk_widget_show(widget);
gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 4);
noticeview->vbox = vbox;
void noticeview_set_button_text(NoticeView *noticeview, const char *text)
{
g_return_if_fail(noticeview);
- gtk_label_set_text
- (GTK_LABEL(GTK_BIN(noticeview->button)->child), text);
+
+ if (text != NULL) {
+ gtk_label_set_text
+ (GTK_LABEL(GTK_BIN(noticeview->button)->child), text);
+ gtk_widget_show(noticeview->button);
+ } else
+ gtk_widget_hide(noticeview->button);
}
void noticeview_set_button_press_callback(NoticeView *noticeview,
noticeview->press(noticeview, noticeview->user_data);
}
}
-
--- /dev/null
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto & the Sylpheed-Claws team
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef USE_GPGME
+
+#include <glib.h>
+#include <gpgme.h>
+
+#include "defs.h"
+#include "utils.h"
+#include "privacy.h"
+#include "procmime.h"
+#include "pgpmime.h"
+#include "sgpgme.h"
+
+typedef struct _PrivacyDataPGP PrivacyDataPGP;
+
+struct _PrivacyDataPGP
+{
+ PrivacyData data;
+
+ gboolean done_sigtest;
+ gboolean is_signed;
+ GpgmeSigStat sigstatus;
+ GpgmeCtx ctx;
+};
+
+static PrivacySystem pgpmime_system;
+
+static PrivacyDataPGP *pgpmime_new_privacydata()
+{
+ PrivacyDataPGP *data;
+
+ data = g_new0(PrivacyDataPGP, 1);
+ data->data.system = &pgpmime_system;
+ data->done_sigtest = FALSE;
+ data->is_signed = FALSE;
+ data->sigstatus = GPGME_SIG_STAT_NONE;
+ gpgme_new(&data->ctx);
+
+ return data;
+}
+
+static void pgpmime_free_privacydata(PrivacyData *_data)
+{
+ PrivacyDataPGP *data = (PrivacyDataPGP *) _data;
+
+ g_free(data);
+}
+
+static gboolean pgpmime_is_signed(MimeInfo *mimeinfo)
+{
+ MimeInfo *parent;
+ MimeInfo *signature;
+ gchar *protocol;
+ PrivacyDataPGP *data = NULL;
+
+ g_return_val_if_fail(mimeinfo != NULL, FALSE);
+ if (mimeinfo->privacy != NULL) {
+ data = (PrivacyDataPGP *) mimeinfo->privacy;
+ if (data->done_sigtest)
+ return data->is_signed;
+ }
+
+ /* check parent */
+ parent = procmime_mimeinfo_parent(mimeinfo);
+ if (parent == NULL)
+ return FALSE;
+ if ((parent->type != MIMETYPE_MULTIPART) ||
+ g_strcasecmp(parent->subtype, "signed"))
+ return FALSE;
+ protocol = g_hash_table_lookup(parent->parameters, "protocol");
+ if ((protocol == NULL) || g_strcasecmp(protocol, "application/pgp-signature"))
+ return FALSE;
+
+ /* check if mimeinfo is the first child */
+ if (parent->node->children->data != mimeinfo)
+ return FALSE;
+
+ /* check signature */
+ signature = parent->node->children->next != NULL ?
+ (MimeInfo *) parent->node->children->next->data : NULL;
+ if (signature == NULL)
+ return FALSE;
+ if ((signature->type != MIMETYPE_APPLICATION) ||
+ g_strcasecmp(signature->subtype, "pgp-signature"))
+ return FALSE;
+
+ if (data == NULL) {
+ data = pgpmime_new_privacydata();
+ mimeinfo->privacy = (PrivacyData *) data;
+ }
+ data->done_sigtest = TRUE;
+ data->is_signed = TRUE;
+
+ return TRUE;
+}
+
+static gint pgpmime_check_signature(MimeInfo *mimeinfo)
+{
+ PrivacyDataPGP *data;
+ MimeInfo *parent, *signature;
+ FILE *fp;
+ gchar buf[BUFFSIZE];
+ gchar *boundary;
+ GString *textstr;
+ gint boundary_len;
+ GpgmeData sigdata, textdata;
+
+ g_return_val_if_fail(mimeinfo != NULL, -1);
+ g_return_val_if_fail(mimeinfo->privacy != NULL, -1);
+ data = (PrivacyDataPGP *) mimeinfo->privacy;
+
+ debug_print("Checking PGP/MIME signature\n");
+ parent = procmime_mimeinfo_parent(mimeinfo);
+
+ fp = fopen(parent->filename, "rb");
+ g_return_val_if_fail(fp != NULL, SIGNATURE_INVALID);
+
+ boundary = g_hash_table_lookup(parent->parameters, "boundary");
+ boundary_len = strlen(boundary);
+ while (fgets(buf, sizeof(buf), fp) != NULL)
+ if (IS_BOUNDARY(buf, boundary, boundary_len))
+ break;
+
+ textstr = g_string_new("");
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ if (IS_BOUNDARY(buf, boundary, boundary_len))
+ break;
+ gchar *buf2;
+
+ buf2 = canonicalize_str(buf);
+ g_string_append(textstr, buf2);
+ g_free(buf2);
+ }
+ g_string_truncate(textstr, textstr->len - 2);
+
+
+ gpgme_data_new_from_mem(&textdata, textstr->str, textstr->len, 0);
+ signature = (MimeInfo *) mimeinfo->node->next->data;
+ gpgme_data_new_from_filepart(&sigdata,
+ signature->filename,
+ NULL,
+ signature->offset,
+ signature->length);
+
+ data->sigstatus =
+ sgpgme_verify_signature (data->ctx, sigdata, textdata);
+
+ gpgme_data_release(sigdata);
+ gpgme_data_release(textdata);
+ g_string_free(textstr, TRUE);
+
+ printf("result: %d\n", data->sigstatus);
+
+ return 0;
+}
+
+static SignatureStatus pgpmime_get_sig_status(MimeInfo *mimeinfo)
+{
+ PrivacyDataPGP *data = (PrivacyDataPGP *) mimeinfo->privacy;
+
+ g_return_val_if_fail(data != NULL, SIGNATURE_INVALID);
+
+ return sgpgme_sigstat_gpgme_to_privacy(data->sigstatus);
+}
+
+static PrivacySystem pgpmime_system = {
+ "PGP/Mime", /* name */
+
+ pgpmime_free_privacydata, /* free_privacydata */
+
+ pgpmime_is_signed, /* is_signed(MimeInfo *) */
+ pgpmime_check_signature, /* check_signature(MimeInfo *) */
+ pgpmime_get_sig_status, /* get_sig_status(MimeInfo *) */
+ NULL, /* get_sig_info_short(MimeInfo *) */
+ NULL, /* get_sig_info_full(MimeInfo *) */
+
+ /* NOT YET */
+ NULL, /* is_encrypted(MimeInfo *) */
+ NULL, /* decrypt(MimeInfo *) */
+};
+
+void pgpmime_init()
+{
+ privacy_register_system(&pgpmime_system);
+}
+
+void pgpmime_done()
+{
+ privacy_unregister_system(&pgpmime_system);
+}
+
+#endif /* USE_GPGME */
--- /dev/null
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto & the Sylpheed-Claws team
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef PGPMIME_H
+#define PGPMIME_H 1
+
+void pgpmime_init(void);
+void pgpmime_done(void);
+
+#endif /* PGPMIME_H */
PrivacySystem *system = (PrivacySystem *) cur->data;
if(system->is_signed != NULL && system->is_signed(mimeinfo))
- return TRUE;
+ return TRUE;
}
return FALSE;
}
-const gchar *privacy_get_signer(MimeInfo *mimeinfo)
+gint privacy_mimeinfo_check_signature(MimeInfo *mimeinfo)
{
- g_return_val_if_fail(mimeinfo != NULL, NULL);
+ PrivacySystem *system;
+
+ g_return_val_if_fail(mimeinfo != NULL, -1);
+
+ if (mimeinfo->privacy == NULL)
+ privacy_mimeinfo_is_signed(mimeinfo);
+
+ if (mimeinfo->privacy == NULL)
+ return -1;
+
+ system = mimeinfo->privacy->system;
+ if (system->check_signature == NULL)
+ return -1;
+
+ return system->check_signature(mimeinfo);
+}
- return "Dummy";
+SignatureStatus privacy_mimeinfo_get_sig_status(MimeInfo *mimeinfo)
+{
+ PrivacySystem *system;
+
+ g_return_val_if_fail(mimeinfo != NULL, -1);
+
+ if (mimeinfo->privacy == NULL)
+ privacy_mimeinfo_is_signed(mimeinfo);
+
+ if (mimeinfo->privacy == NULL)
+ return SIGNATURE_UNCHECKED;
+
+ system = mimeinfo->privacy->system;
+ if (system->get_sig_status == NULL)
+ return SIGNATURE_UNCHECKED;
+
+ return system->get_sig_status(mimeinfo);
}
gboolean privacy_mimeinfo_is_encrypted(MimeInfo *mimeinfo)
typedef enum {
SIGNATURE_UNCHECKED,
SIGNATURE_OK,
+ SIGNATURE_WARN,
SIGNATURE_INVALID,
+ SIGNATURE_CHECK_FAILED,
} SignatureStatus;
#include <glib.h>
#include "procmime.h"
-void privacy_register_system (PrivacySystem *system);
-void privacy_unregister_system (PrivacySystem *system);
+void privacy_register_system (PrivacySystem *system);
+void privacy_unregister_system (PrivacySystem *system);
-void privacy_free_privacydata (PrivacyData *);
+void privacy_free_privacydata (PrivacyData *);
-gboolean privacy_mimeinfo_is_signed (MimeInfo *);
-const gchar *privacy_get_signer (MimeInfo *);
-SignatureStatus privacy_check_signature (MimeInfo *);
+gboolean privacy_mimeinfo_is_signed (MimeInfo *);
+gint privacy_mimeinfo_check_signature (MimeInfo *);
+SignatureStatus privacy_mimeinfo_get_sig_status (MimeInfo *);
#if 0 /* NOT YET */
-gboolean privacy_mimeinfo_is_encrypted (MimeInfo *);
-gint privacy_decrypt (MimeInfo *);
+gboolean privacy_mimeinfo_is_encrypted (MimeInfo *);
+gint privacy_decrypt (MimeInfo *);
#endif
struct _PrivacySystem {
void (*free_privacydata) (PrivacyData *);
gboolean (*is_signed) (MimeInfo *);
- const gchar *(*get_signer) (MimeInfo *);
- SignatureStatus (*check_signature) (MimeInfo *);
+ gint (*check_signature) (MimeInfo *);
+ SignatureStatus (*get_sig_status) (MimeInfo *);
+ const gchar *(*get_sig_info_short) (MimeInfo *);
+ const gchar *(*get_sig_info_full) (MimeInfo *);
/* NOT YET */
gboolean (*is_encrypted) (MimeInfo *);
}
#endif
-void
-rfc2015_disable_all (void)
-{
- /* FIXME: set a flag, so that we don't bother the user with failed
- * gpgme messages */
-}
-
-
void
rfc2015_secure_remove (const char *fname)
{
return plain;
}
-#if 0 /* UNUSED */
-MimeInfo * rfc2015_find_signature (MimeInfo *mimeinfo)
-{
- MimeInfo *partinfo;
- int n = 0;
-
- if (!mimeinfo)
- return NULL;
- if (!((mimeinfo->type == MIMETYPE_MULTIPART) && !g_strcasecmp(mimeinfo->subtype, "signed")))
- return NULL;
-
- debug_print ("** multipart/signed encountered\n");
-
- /* check that we have at least 2 parts of the correct type */
- for (partinfo = mimeinfo->children;
- partinfo != NULL; partinfo = partinfo->next) {
- if (++n > 1 && (partinfo->type == MIMETYPE_APPLICATION &&
- !g_strcasecmp (partinfo->subtype, "pgp-signature")))
- break;
- }
-
- return partinfo;
-}
-
-gboolean rfc2015_has_signature (MimeInfo *mimeinfo)
-{
- return rfc2015_find_signature (mimeinfo) != NULL;
-}
-
-void rfc2015_check_signature (MimeInfo *mimeinfo, FILE *fp)
-{
- MimeInfo *partinfo;
-
- partinfo = rfc2015_find_signature (mimeinfo);
- if (!partinfo)
- return;
-
-#if 0
- g_message ("** yep, it is a pgp signature");
- dump_mimeinfo ("gpg-signature", partinfo );
- dump_part (partinfo, fp );
- dump_mimeinfo ("signed text", mimeinfo->children );
- dump_part (mimeinfo->children, fp);
-#endif
-
- check_signature (mimeinfo, partinfo, fp);
-}
-#endif
-
int rfc2015_is_encrypted (MimeInfo *mimeinfo)
{
if (!mimeinfo || mimeinfo->type != MIMETYPE_MULTIPART)
return -1;
}
-static gboolean rfc2015_is_signed(MimeInfo *mimeinfo)
-{
- MimeInfo *parent;
- MimeInfo *signature;
- gchar *protocol;
-
- g_return_val_if_fail(mimeinfo != NULL, FALSE);
-
- /* check parent */
- parent = procmime_mimeinfo_parent(mimeinfo);
- if (parent == NULL)
- return FALSE;
- if ((parent->type != MIMETYPE_MULTIPART) ||
- g_strcasecmp(parent->subtype, "signed"))
- return FALSE;
- protocol = g_hash_table_lookup(parent->parameters, "protocol");
- if ((protocol == NULL) || g_strcasecmp(protocol, "application/pgp-signature"))
- return FALSE;
-
- /* check if mimeinfo is the first child */
- if (parent->node->children->data != mimeinfo)
- return FALSE;
-
- /* check signature */
- signature = parent->node->children->next != NULL ?
- (MimeInfo *) parent->node->children->next->data : NULL;
- if (signature == NULL)
- return FALSE;
- if ((signature->type != MIMETYPE_APPLICATION) ||
- g_strcasecmp(signature->subtype, "pgp-signature"))
- return FALSE;
-
- return TRUE;
-}
-
-static void idle_function_for_gpgme(void)
-{
- while (gtk_events_pending())
- gtk_main_iteration();
-}
-
-static PrivacySystem rfc2015_system = {
- "PGP/Mime", /* name */
-
- g_free, /* free_privacydata */
-
- rfc2015_is_signed, /* is_signed(MimeInfo *) */
- NULL, /* get_signer(MimeInfo *) */
- NULL, /* check_signature(MimeInfo *) */
-
- /* NOT YET */
- NULL, /* is_encrypted(MimeInfo *) */
- NULL, /* decrypt(MimeInfo *) */
-};
-
-void rfc2015_init()
-{
- if (gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP) !=
- GPGME_No_Error) { /* Also does some gpgme init */
- rfc2015_disable_all();
- debug_print("gpgme_engine_version:\n%s\n",
- gpgme_get_engine_info());
-
- if (prefs_common.gpg_warning) {
- AlertValue val;
-
- val = alertpanel_message_with_disable
- (_("Warning"),
- _("GnuPG is not installed properly, or needs to be upgraded.\n"
- "OpenPGP support disabled."));
- if (val & G_ALERTDISABLE)
- prefs_common.gpg_warning = FALSE;
- }
- } else
- privacy_register_system(&rfc2015_system);
-
- gpgme_register_idle(idle_function_for_gpgme);
-}
-
-void rfc2015_done()
-{
- privacy_unregister_system(&rfc2015_system);
- gpgmegtk_free_passphrase();
-}
-
#endif /* USE_GPGME */
--- /dev/null
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto & the Sylpheed-Claws team
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef USE_GPGME
+
+#include <gtk/gtk.h>
+#include <gpgme.h>
+
+#include "sgpgme.h"
+#include "privacy.h"
+#include "prefs_common.h"
+#include "utils.h"
+#include "alertpanel.h"
+#include "passphrase.h"
+#include "intl.h"
+
+static void idle_function_for_gpgme(void)
+{
+ while (gtk_events_pending())
+ gtk_main_iteration();
+}
+
+static void sgpgme_disable_all(void)
+{
+ /* FIXME: set a flag, so that we don't bother the user with failed
+ * gpgme messages */
+}
+
+GpgmeSigStat sgpgme_verify_signature(GpgmeCtx ctx, GpgmeData sig,
+ GpgmeData plain)
+{
+ GpgmeSigStat status;
+
+ if (gpgme_op_verify(ctx, sig, plain, &status) != GPGME_No_Error)
+ return GPGME_SIG_STAT_ERROR;
+
+ return status;
+}
+
+SignatureStatus sgpgme_sigstat_gpgme_to_privacy(GpgmeSigStat status)
+{
+ switch (status) {
+ case GPGME_SIG_STAT_GOOD:
+ return SIGNATURE_OK;
+ case GPGME_SIG_STAT_GOOD_EXP:
+ case GPGME_SIG_STAT_GOOD_EXPKEY:
+ case GPGME_SIG_STAT_DIFF:
+ return SIGNATURE_WARN;
+ case GPGME_SIG_STAT_BAD:
+ return SIGNATURE_INVALID;
+ case GPGME_SIG_STAT_NOKEY:
+ case GPGME_SIG_STAT_NOSIG:
+ case GPGME_SIG_STAT_ERROR:
+ return SIGNATURE_CHECK_FAILED;
+ case GPGME_SIG_STAT_NONE:
+ return SIGNATURE_UNCHECKED;
+ }
+ return SIGNATURE_CHECK_FAILED;
+}
+
+void sgpgme_init()
+{
+ if (gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP) !=
+ GPGME_No_Error) { /* Also does some gpgme init */
+ sgpgme_disable_all();
+ debug_print("gpgme_engine_version:\n%s\n",
+ gpgme_get_engine_info());
+
+ if (prefs_common.gpg_warning) {
+ AlertValue val;
+
+ val = alertpanel_message_with_disable
+ (_("Warning"),
+ _("GnuPG is not installed properly, or needs to be upgraded.\n"
+ "OpenPGP support disabled."));
+ if (val & G_ALERTDISABLE)
+ prefs_common.gpg_warning = FALSE;
+ }
+ }
+
+ gpgme_register_idle(idle_function_for_gpgme);
+}
+
+void sgpgme_done()
+{
+ gpgmegtk_free_passphrase();
+}
+
+#endif /* USE_GPGME */
--- /dev/null
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto & the Sylpheed-Claws team
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef SGPGME_H
+#define SGPGME_H 1
+
+#include <gpgme.h>
+
+#include "privacy.h"
+
+void sgpgme_init(void);
+void sgpgme_done(void);
+
+GpgmeSigStat sgpgme_verify_signature(GpgmeCtx ctx,
+ GpgmeData sig,
+ GpgmeData plain);
+SignatureStatus sgpgme_sigstat_gpgme_to_privacy(GpgmeSigStat status);
+
+#endif /* SGPGME_H */