Automatically enable the pidgin-gnome-keyring plugin so that account
passwords can be saved in the system keyring rather than as cleartext
in ~/.purple/accounts.xml

See PSARC/2016/385 for more details.

This patch will not be submitted upsteam.

--- pidgin-2.11.0/configure.ac.orig	2016-08-17 07:39:38.956248926 -0700
+++ pidgin-2.11.0/configure.ac	2016-08-17 07:41:48.502561778 -0700
@@ -2469,6 +2469,18 @@
 	LDFLAGS="$orig_LDFLAGS"
 fi
 
+dnl #######################################################################
+dnl # Check for gnome-keyring
+dnl #--enable-gnome-keyring=(yes|no)
+dnl #######################################################################
+AC_ARG_ENABLE(gnome-keyring,
+AC_HELP_STRING([--enable-gnome-keyring],
+               [use gnome keyring for storing password [default=no]]),,
+               enable_gnome_keyring=no)
+if test "x$enable_gnome_keyring" = "xyes"; then
+    AC_DEFINE(GAIM_ENABLE_KEYRING, [], [Set if we should use gnome-keyring])
+fi
+
 AC_MSG_CHECKING(for me pot o' gold)
 AC_MSG_RESULT(no)
 AC_CHECK_FUNCS(gethostid lrand48 timegm)
--- pidgin-2.11.0/libpurple/core.c.orig	2016-08-17 08:59:22.042425765 -0700
+++ pidgin-2.11.0/libpurple/core.c	2016-08-17 09:48:56.584454917 -0700
@@ -161,6 +161,12 @@
 	purple_connections_init();
 
 	purple_accounts_init();
+
+	/* Potentially load the gnome keyring plugin here because we need to
+	 * have had a couple signals registered by purple_accounts_init() first.
+	 */
+	purple_plugin_load_gnome_keyring_plugin();
+
 	purple_savedstatuses_init();
 	purple_notify_init();
 	purple_certificate_init();
--- pidgin-2.11.0/libpurple/plugin.h.orig	2016-08-17 09:08:26.448023611 -0700
+++ pidgin-2.11.0/libpurple/plugin.h	2016-08-17 09:49:20.857940837 -0700
@@ -733,6 +733,12 @@
  */
 void purple_plugin_action_free(PurplePluginAction *action);
 
+/**
+ * Potentially load the gnome keyring plugin.
+ */
+
+void purple_plugin_load_gnome_keyring_plugin(void);
+
 #ifdef __cplusplus
 }
 #endif
--- pidgin-2.11.0/libpurple/plugin.c.orig	2016-08-17 07:42:35.456904439 -0700
+++ pidgin-2.11.0/libpurple/plugin.c	2016-08-17 12:05:29.285059614 -0700
@@ -54,6 +54,10 @@
 
 } PurplePluginIpcCommand;
 
+#ifdef GAIM_ENABLE_KEYRING
+static PurplePlugin *gnome_keyring_plugin = NULL;
+#endif
+
 static GList *search_paths     = NULL;
 static GList *plugins          = NULL;
 static GList *loaded_plugins   = NULL;
@@ -207,6 +211,10 @@
 	gchar *basename = NULL;
 	gboolean (*purple_init_plugin)(PurplePlugin *);
 
+#ifdef GAIM_ENABLE_KEYRING
+	gboolean is_gnome_keyring = FALSE;
+#endif
+
 	purple_debug_misc("plugins", "probing %s\n", filename);
 	g_return_val_if_fail(filename != NULL, NULL);
 
@@ -216,6 +224,12 @@
 	/* If this plugin has already been probed then exit */
 	basename = purple_plugin_get_basename(filename);
 	plugin = purple_plugins_find_with_basename(basename);
+
+#ifdef GAIM_ENABLE_KEYRING
+	if (!strcmp(basename, "gnome-keyring"))
+		is_gnome_keyring = TRUE;
+#endif
+
 	g_free(basename);
 	if (plugin != NULL)
 	{
@@ -484,6 +498,13 @@
 		}
 	}
 
+#ifdef GAIM_ENABLE_KEYRING
+	if (is_gnome_keyring) {
+		purple_debug_misc("plugins", "setting gnome_keyring_plugin.\n");
+		gnome_keyring_plugin = plugin;
+	}
+#endif
+
 	return plugin;
 #else
 	return NULL;
@@ -1673,3 +1694,15 @@
 	g_free(action->label);
 	g_free(action);
 }
+
+void
+purple_plugin_load_gnome_keyring_plugin()
+{
+#ifdef GAIM_ENABLE_KEYRING
+	purple_debug_misc("plugins", "purple_plugin_load_gnome_keyring_plugin called.\n");
+	if (gnome_keyring_plugin != NULL) {
+		purple_debug_misc("plugins", "purple_plugin_load_gnome_keyring_plugin: calling purple_plugin_load.\n");
+		purple_plugin_load(gnome_keyring_plugin);
+	}
+#endif
+}