[evolution] Bug #508744 - Select PGP key from a list in mail account properties
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug #508744 - Select PGP key from a list in mail account properties
- Date: Mon, 24 Mar 2014 15:04:09 +0000 (UTC)
commit fbf3bd0056d742b3b660f2c30e8c8582ff0efe50
Author: Milan Crha <mcrha redhat com>
Date: Mon Mar 24 16:03:47 2014 +0100
Bug #508744 - Select PGP key from a list in mail account properties
configure.ac | 29 ++++++++++++
mail/Makefile.am | 2 +
mail/e-mail-config-security-page.c | 89 ++++++++++++++++++++++++++++++++++++
3 files changed, 120 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 238a6a4..f4c9f70 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 edde57b..2237185 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 3250576..47d10ca 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",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]