# HG changeset patch # User Elliott Sales de Andrade # Date 1324612779 0 # Node ID 466efc330d3d2ff629f5eb537872b286864984f9 # Parent 066823e80669ad4fc7f3bdb37deacfc80d11417e 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. diff -r 066823e80669 -r 466efc330d3d configure.ac --- a/configure.ac Fri Dec 23 02:13:20 2011 +0000 +++ b/configure.ac Fri Dec 23 03:59:39 2011 +0000 @@ -407,6 +407,10 @@ [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 @@ ]) 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(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 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 diff -r 066823e80669 -r 466efc330d3d pidgin/Makefile.am --- a/pidgin/Makefile.am Fri Dec 23 02:13:20 2011 +0000 +++ b/pidgin/Makefile.am Fri Dec 23 03:59:39 2011 +0000 @@ -156,6 +156,7 @@ pidgin_LDADD = \ @LIBOBJS@ \ $(GLIB_LIBS) \ + $(GCR_LIBS) \ $(DBUS_LIBS) \ $(GSTREAMER_LIBS) \ $(XSS_LIBS) \ @@ -181,6 +182,7 @@ -I$(top_builddir) \ -I$(top_srcdir) \ $(GLIB_CFLAGS) \ + $(GCR_CFLAGS) \ $(GSTREAMER_CFLAGS) \ $(DEBUG_CFLAGS) \ $(GTK_CFLAGS) \ diff -r 066823e80669 -r 466efc330d3d pidgin/gtkcertmgr.c --- a/pidgin/gtkcertmgr.c Fri Dec 23 02:13:20 2011 +0000 +++ b/pidgin/gtkcertmgr.c Fri Dec 23 03:59:39 2011 +0000 @@ -40,6 +40,12 @@ #include "gtkcertmgr.h" +#ifdef ENABLE_GCR +#define GCR_API_SUBJECT_TO_CHANGE +#include +#include +#endif + /***************************************************************************** * X.509 tls_peers management interface * *****************************************************************************/ @@ -310,6 +316,13 @@ 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 @@ 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