pidgin: 6ab9f5ff: Optionally show certificates using GCR's...

qulogic at pidgin.im qulogic at pidgin.im
Fri Dec 23 05:26:30 EST 2011


----------------------------------------------------------------------
Revision: 6ab9f5ff810acde3c06a2add7b8df2bd75cce6e3
Parent:   382188391af2bb6bf77ff59357f2170c8994d118
Author:   qulogic at pidgin.im
Date:     12/22/11 22:59:39
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/6ab9f5ff810acde3c06a2add7b8df2bd75cce6e3

Changelog: 

Optionally show certificates using GCR's widgets. These are much
more functional than the prompts we used to show. However, this is
only applied to the Certificate Viewer, and not any errors, etc.

I think we'll have to make a change to the request API for showing
certificates in a dialog and have the UI decide how to show them,
but that's for later.

This was written for Fedora 14, which I no longer have. I made some
tweaks and cleanup since I just added the _get_der_data function,
but I can't guarantee this still works.

Changes against parent 382188391af2bb6bf77ff59357f2170c8994d118

  patched  configure.ac
  patched  pidgin/Makefile.am
  patched  pidgin/gtkcertmgr.c

-------------- next part --------------
============================================================
--- configure.ac	e4c8977b7fe74a94525880f574890f3251e5a235
+++ configure.ac	146e991fb67000dc69168ef834a34418d93738d8
@@ -407,6 +407,10 @@ AC_ARG_ENABLE(gestures,
 	[AC_HELP_STRING([--disable-gestures],
 		[compile without the gestures plugin])],
 	enable_gestures="$enableval", enable_gestures="yes")
+AC_ARG_ENABLE(gcr,
+	[AC_HELP_STRING([--enable-gcr],
+		[compile with GCR certificate widgets])],
+	enable_gcr="$enableval", enable_gcr="no")
 
 AC_PATH_XTRA
 # We can't assume that $x_libraries will be set, because autoconf does not
@@ -620,9 +624,26 @@ Use --disable-cap if you do not need the
 ])
 			fi])
 	fi
-        
 
+	dnl #######################################################################
+	dnl # Check for GCR for its certificate widgets
+	dnl #######################################################################
+	if test "x$enable_gcr" = "xyes"; then
+		PKG_CHECK_MODULES(GCR, gcr-0, [
+			AC_DEFINE(ENABLE_GCR, 1, [Define to 1 if GCR is found.])], [
+			AC_MSG_RESULT(no)
+			enable_gcr="no"
+			if test "x$force_deps" = "xyes" ; then
+				AC_MSG_ERROR([
+GCR development headers not found.
+Use --disable-gcr if you do not need GCR certificate widgets.
+])
+			fi])
+	fi
+
+
 else # GTK
+	enable_gcr=no
 	enable_cap=no
 	enable_gevolution=no
 	enable_gtkspell=no
@@ -635,6 +656,7 @@ AM_CONDITIONAL(ENABLE_GESTURES, test "x$
 AM_CONDITIONAL(BUILD_GEVOLUTION, test "x$enable_gevolution" = "xyes")
 AM_CONDITIONAL(ENABLE_CAP, test "x$enable_cap" = "xyes")
 AM_CONDITIONAL(ENABLE_GESTURES, test "x$enable_gestures" = "xyes")
+AM_CONDITIONAL(ENABLE_GCR, test "x$enable_gcr" = "xyes")
 
 
 dnl #######################################################################
@@ -2594,6 +2616,7 @@ echo Build with GtkSpell support... : $e
 echo Use X Session Management...... : $enable_sm
 echo Use startup notification...... : $enable_startup_notification
 echo Build with GtkSpell support... : $enable_gtkspell
+echo Build with GCR widgets........ : $enable_gcr
 echo
 echo Build with plugin support..... : $enable_plugins
 echo Build with Mono support....... : $enable_mono
============================================================
--- pidgin/Makefile.am	68dd3f1334db395aac8d0303a7c7c0c6cc6595c4
+++ pidgin/Makefile.am	1873a723b808906764c8056eefb56ac135071035
@@ -156,6 +156,7 @@ pidgin_LDADD = \
 pidgin_LDADD = \
 	@LIBOBJS@ \
 	$(GLIB_LIBS) \
+	$(GCR_LIBS) \
 	$(DBUS_LIBS) \
 	$(GSTREAMER_LIBS) \
 	$(XSS_LIBS) \
@@ -181,6 +182,7 @@ AM_CPPFLAGS = \
 	-I$(top_builddir) \
 	-I$(top_srcdir) \
 	$(GLIB_CFLAGS) \
+	$(GCR_CFLAGS) \
 	$(GSTREAMER_CFLAGS) \
 	$(DEBUG_CFLAGS) \
 	$(GTK_CFLAGS) \
============================================================
--- pidgin/gtkcertmgr.c	32b18d62da8c0e426c2f1d5810c7c01cc04c9a7a
+++ pidgin/gtkcertmgr.c	602d3840590d2f5907757b9b24235487fd601dc5
@@ -40,6 +40,12 @@
 
 #include "gtkcertmgr.h"
 
+#ifdef ENABLE_GCR
+#define GCR_API_SUBJECT_TO_CHANGE
+#include <gcr/gcr.h>
+#include <gcr/gcr-simple-certificate.h>
+#endif
+
 /*****************************************************************************
  * X.509 tls_peers management interface                                      *
  *****************************************************************************/
@@ -310,6 +316,13 @@ tls_peers_mgmt_info_cb(GtkWidget *button
 	GtkTreeModel *model;
 	gchar *id;
 	PurpleCertificate *crt;
+#ifdef ENABLE_GCR
+	GByteArray *der;
+	GcrCertificate *gcrt;
+	char *title;
+	GtkWidget *dialog;
+	GcrCertificateBasicsWidget *cert_widget;
+#endif
 
 	/* See if things are selected */
 	if (!gtk_tree_selection_get_selected(select, &model, &iter)) {
@@ -325,11 +338,38 @@ tls_peers_mgmt_info_cb(GtkWidget *button
 	crt = purple_certificate_pool_retrieve(tpm_dat->tls_peers, id);
 	g_return_if_fail(crt);
 
+#ifdef ENABLE_GCR
+	der = purple_certificate_get_der_data(crt);
+	g_return_if_fail(der);
+
+	gcrt = gcr_simple_certificate_new(der->data, der->len);
+	g_return_if_fail(gcrt);
+
 	/* Fire the notification */
+	title = g_strdup_printf(_("Certificate Information for %s"), id);
+	dialog = gtk_dialog_new_with_buttons(title,
+	                                     NULL,
+	                                     0,
+	                                     GTK_STOCK_OK,
+	                                     GTK_RESPONSE_ACCEPT,
+	                                     NULL);
+	cert_widget = gcr_certificate_basics_widget_new(gcrt);
+	gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
+	                   GTK_WIDGET(cert_widget), TRUE, TRUE, 0);
+	g_signal_connect_swapped(dialog, "response",
+	                         G_CALLBACK(gtk_widget_destroy),
+	                         dialog);
+	gtk_widget_show_all(dialog);
+
+	g_byte_array_free(der, TRUE);
+	g_object_unref(G_OBJECT(gcrt));
+#else
+	/* Fire the notification */
 	purple_certificate_display_x509(crt);
 
 	g_free(id);
 	purple_certificate_destroy(crt);
+#endif
 }
 
 static void


More information about the Commits mailing list