aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2014-03-24 23:03:47 +0800
committerMilan Crha <mcrha@redhat.com>2014-03-24 23:04:28 +0800
commitfbf3bd0056d742b3b660f2c30e8c8582ff0efe50 (patch)
treebe9e8057b96d52e27d4f024e506b4f6a5956f270
parentebd4f15a91ee24f20463d6893652b31c4b0614da (diff)
downloadgsoc2013-evolution-fbf3bd0056d742b3b660f2c30e8c8582ff0efe50.tar
gsoc2013-evolution-fbf3bd0056d742b3b660f2c30e8c8582ff0efe50.tar.gz
gsoc2013-evolution-fbf3bd0056d742b3b660f2c30e8c8582ff0efe50.tar.bz2
gsoc2013-evolution-fbf3bd0056d742b3b660f2c30e8c8582ff0efe50.tar.lz
gsoc2013-evolution-fbf3bd0056d742b3b660f2c30e8c8582ff0efe50.tar.xz
gsoc2013-evolution-fbf3bd0056d742b3b660f2c30e8c8582ff0efe50.tar.zst
gsoc2013-evolution-fbf3bd0056d742b3b660f2c30e8c8582ff0efe50.zip
Bug #508744 - Select PGP key from a list in mail account properties
-rw-r--r--configure.ac29
-rw-r--r--mail/Makefile.am2
-rw-r--r--mail/e-mail-config-security-page.c89
3 files changed, 120 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 238a6a4d8f..f4c9f7007f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -858,6 +858,34 @@ AC_SUBST(MANUAL_NSPR_LIBS)
AC_SUBST(MANUAL_NSS_CFLAGS)
AC_SUBST(MANUAL_NSS_LIBS)
+dnl ******************************
+dnl libcryptui, aka Seahorse
+dnl ******************************
+AC_ARG_ENABLE([libcryptui],
+ [AS_HELP_STRING([--enable-libcryptui],
+ [Enable libcryptui usage @<:@default=yes@:>@])],
+ [enable_libcryptui="$enableval"], [enable_libcryptui=yes])
+
+if test "x$enable_libcryptui" = "xyes"; then
+ PKG_CHECK_MODULES(
+ [LIBCRYPTUI],
+ [cryptui-0.0],,
+ [AC_MSG_ERROR([
+
+ cryptui-0.0 not found
+
+ If you want to disable support libcryptui usage,
+ please append --disable-libcryptui to configure.
+
+ ])])
+
+ AC_DEFINE(HAVE_LIBCRYPTUI, 1, [Define if using libcryptui])
+else
+ enable_libcryptui=no
+fi
+AC_SUBST(LIBCRYPTUI_CFLAGS)
+AC_SUBST(LIBCRYPTUI_LIBS)
+
dnl *****************
dnl killall or pkill?
dnl *****************
@@ -1555,6 +1583,7 @@ fi
echo "
LDAP support: $msg_ldap
Contact Maps: $enable_contact_maps
+ Libcryptui: $enable_libcryptui
Libnotify: $HAVE_LIBNOTIFY
SSL support: $msg_ssl
SMIME support: $msg_smime
diff --git a/mail/Makefile.am b/mail/Makefile.am
index edde57b0ac..22371859ef 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -47,6 +47,7 @@ libevolution_mail_la_CPPFLAGS = \
$(CERT_UI_CFLAGS) \
$(CANBERRA_CFLAGS) \
$(GTKHTML_CFLAGS) \
+ $(LIBCRYPTUI_CFLAGS) \
$(LIBSOUP_CFLAGS)
mailinclude_HEADERS = \
@@ -223,6 +224,7 @@ libevolution_mail_la_LIBADD = \
$(CANBERRA_LIBS) \
$(GTKHTML_LIBS) \
$(SMIME_LIBS) \
+ $(LIBCRYPTUI_LIBS) \
$(LIBSOUP_LIBS) \
$(NULL)
diff --git a/mail/e-mail-config-security-page.c b/mail/e-mail-config-security-page.c
index 3250576f75..47d10ca5c6 100644
--- a/mail/e-mail-config-security-page.c
+++ b/mail/e-mail-config-security-page.c
@@ -27,6 +27,12 @@
#include <smime/gui/e-cert-selector.h>
#endif /* HAVE_NSS */
+#ifdef HAVE_LIBCRYPTUI
+#define LIBCRYPTUI_API_SUBJECT_TO_CHANGE
+#include <libcryptui/cryptui.h>
+#undef LIBCRYPTUI_API_SUBJECT_TO_CHANGE
+#endif /* HAVE_LIBCRYPTUI */
+
#define E_MAIL_CONFIG_SECURITY_PAGE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_MAIL_CONFIG_SECURITY_PAGE, EMailConfigSecurityPagePrivate))
@@ -201,6 +207,78 @@ mail_config_security_page_dispose (GObject *object)
dispose (object);
}
+#ifdef HAVE_LIBCRYPTUI
+static GtkWidget *
+mail_security_page_get_openpgpg_combo (void)
+{
+ GtkWidget *widget;
+ GtkListStore *store;
+ CryptUIKeyset *keyset;
+ GtkCellRenderer *cell;
+ GList *keys, *kiter;
+
+ store = GTK_LIST_STORE (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING));
+
+ keyset = cryptui_keyset_new ("openpgp", FALSE);
+ cryptui_keyset_set_expand_keys (keyset, TRUE);
+
+ keys = cryptui_keyset_get_keys (keyset);
+ for (kiter = keys; kiter; kiter = g_list_next (kiter)) {
+ const gchar *key = kiter->data;
+ guint flags;
+
+ flags = cryptui_keyset_key_flags (keyset, key);
+
+ if ((flags & CRYPTUI_FLAG_CAN_SIGN) != 0 &&
+ (flags & CRYPTUI_FLAG_IS_VALID) != 0 &&
+ (flags & (CRYPTUI_FLAG_EXPIRED | CRYPTUI_FLAG_REVOKED | CRYPTUI_FLAG_DISABLED)) == 0) {
+ gchar *keyid, *display_name, *display_id, *description;
+
+ keyid = cryptui_keyset_key_raw_keyid (keyset, key);
+ if (keyid && *keyid) {
+ GtkTreeIter iter;
+
+ display_name = cryptui_keyset_key_display_name (keyset, key);
+ display_id = cryptui_keyset_key_display_id (keyset, key);
+
+ if (!display_id || !*display_id) {
+ g_free (display_id);
+ display_id = g_strdup (keyid);
+ }
+
+ /* Translators: This string is to describe a PGP key in a combo box in mail account's preferences.
+ The first '%s' is a key ID, the second '%s' is a display name of the key. */
+ description = g_strdup_printf (C_("PGPKeyDescription", "%s - %s"), display_id, display_name);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ 0, keyid,
+ 1, description,
+ -1);
+
+ g_free (display_name);
+ g_free (display_id);
+ g_free (description);
+ }
+
+ g_free (keyid);
+ }
+ }
+
+ widget = gtk_combo_box_new_with_model_and_entry (GTK_TREE_MODEL (store));
+ g_object_unref (store);
+
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (widget), 0);
+ gtk_cell_layout_clear (GTK_CELL_LAYOUT (widget));
+
+ cell = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget), cell, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), cell, "text", 1, NULL);
+
+ return widget;
+}
+#endif /* HAVE_LIBCRYPTUI */
+
static void
mail_config_security_page_constructed (GObject *object)
{
@@ -307,12 +385,23 @@ mail_config_security_page_constructed (GObject *object)
label = GTK_LABEL (widget);
+#ifdef HAVE_LIBCRYPTUI
+ widget = mail_security_page_get_openpgpg_combo ();
+#else /* HAVE_LIBCRYPTUI */
widget = gtk_entry_new ();
+#endif /* HAVE_LIBCRYPTUI */
+
gtk_widget_set_hexpand (widget, TRUE);
gtk_label_set_mnemonic_widget (label, widget);
gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 1, 1);
gtk_widget_show (widget);
+#ifdef HAVE_LIBCRYPTUI
+ /* There's expected an entry, thus provide it. */
+ widget = gtk_bin_get_child (GTK_BIN (widget));
+ g_warn_if_fail (GTK_IS_ENTRY (widget));
+#endif /* HAVE_LIBCRYPTUI */
+
g_object_bind_property (
openpgp_ext, "key-id",
widget, "text",