pidgin-01-gnome-keyring.patch revision 5089
5089N/A# date:2006-11-16 owner:elaine type:branding bugster:6439103
5089N/A# Bug 15335933 SUNBT6439103 gaim must use gnome-keyring
5089N/A#
5089N/A# Changes should be submitted upstream.
5089N/A
5089N/A--- pidgin-2.7.11/libpurple/Makefile.am.orig 2011-03-11 10:20:27.000000000 +0800
5089N/A+++ pidgin-2.7.11/libpurple/Makefile.am 2011-03-14 09:45:48.768422314 +0800
5089N/A@@ -305,6 +305,7 @@
5089N/A $(DBUS_LIBS) \
5089N/A $(GLIB_LIBS) \
5089N/A $(LIBXML_LIBS) \
5089N/A+ $(GAIM_KEYRING_LIBS) \
5089N/A $(NETWORKMANAGER_LIBS) \
5089N/A $(INTLLIBS) \
5089N/A $(FARSTREAM_LIBS) \
5089N/A@@ -322,6 +323,7 @@
5089N/A $(GLIB_CFLAGS) \
5089N/A $(DEBUG_CFLAGS) \
5089N/A $(DBUS_CFLAGS) \
5089N/A+ $(GAIM_KEYRING_CFLAGS) \
5089N/A $(LIBXML_CFLAGS) \
5089N/A $(FARSTREAM_CFLAGS) \
5089N/A $(GSTREAMER_CFLAGS) \
5089N/A--- pidgin-2.7.11/pidgin/gtkmain.c.orig 2011-03-11 10:20:28.000000000 +0800
5089N/A+++ pidgin-2.7.11/pidgin/gtkmain.c 2011-03-14 09:45:48.767697192 +0800
5089N/A@@ -70,6 +70,10 @@
5089N/A #include "pidginstock.h"
5089N/A #include "gtkwhiteboard.h"
5089N/A
5089N/A+#ifdef GAIM_ENABLE_KEYRING
5089N/A+#include <gnome-keyring.h>
5089N/A+#endif
5089N/A+
5089N/A #ifdef HAVE_SIGNAL_H
5089N/A # include <signal.h>
5089N/A #endif
5089N/A@@ -742,6 +746,12 @@
5089N/A gtk_rc_add_default_file(search_path);
5089N/A g_free(search_path);
5089N/A
5089N/A+#ifdef GAIM_ENABLE_KEYRING
5089N/A+ GnomeKeyringResult rtn = gnome_keyring_unlock_sync(NULL, NULL);
5089N/A+ // if (rtn == GNOME_KEYRING_RESULT_DENIED)
5089N/A+ // return 0;
5089N/A+#endif
5089N/A+
5089N/A gui_check = gtk_init_check(&argc, &argv);
5089N/A if (!gui_check) {
5089N/A char *display = gdk_get_display();
5089N/A--- pidgin-2.7.11/pidgin/Makefile.am.orig 2011-03-11 10:20:28.000000000 +0800
5089N/A+++ pidgin-2.7.11/pidgin/Makefile.am 2011-03-14 09:45:48.768028256 +0800
5089N/A@@ -177,6 +177,7 @@
5089N/A $(GSTREAMER_CFLAGS) \
5089N/A $(DEBUG_CFLAGS) \
5089N/A $(GTK_CFLAGS) \
5089N/A+ $(GAIM_KEYRING_CFLAGS) \
5089N/A $(DBUS_CFLAGS) \
5089N/A $(GTKSPELL_CFLAGS) \
5089N/A $(LIBXML_CFLAGS) \
5089N/A--- pidgin-2.7.11/configure.ac.orig 2011-03-11 10:20:27.000000000 +0800
5089N/A+++ pidgin-2.7.11/configure.ac 2011-03-14 09:45:48.770550233 +0800
5089N/A@@ -2382,6 +2382,20 @@
5089N/A LDFLAGS="$orig_LDFLAGS"
5089N/A fi
5089N/A
5089N/A+dnl #######################################################################
5089N/A+dnl # Check for gnome-keyring
5089N/A+dnl #--enable-gnome-keyring=(yes|no)
5089N/A+dnl #######################################################################
5089N/A+AC_ARG_ENABLE(gnome-keyring,
5089N/A+ AC_HELP_STRING([--enable-gnome-keyring],
5089N/A+ [use gnome keyring for storing password [default=no]]),,
5089N/A+ enable_gnome_keyring=no)
5089N/A+if test "x$enable_gnome_keyring" = "xyes"; then
5089N/A+ PKG_CHECK_MODULES(GAIM_KEYRING,
5089N/A+ gnome-keyring-1,
5089N/A+ AC_DEFINE(GAIM_ENABLE_KEYRING, [], [Set if we should use gnome-keyring]))
5089N/A+fi
5089N/A+
5089N/A AC_MSG_CHECKING(for me pot o' gold)
5089N/A AC_MSG_RESULT(no)
5089N/A AC_CHECK_FUNCS(gethostid lrand48 timegm)
5089N/A--- pidgin-2.10.11/libpurple/account.c.orig Tue Feb 17 15:27:17 2015
5089N/A+++ pidgin-2.10.11/libpurple/account.c Tue Feb 17 15:27:17 2015
5089N/A@@ -54,6 +54,14 @@
5089N/A #define PURPLE_ACCOUNT_GET_PRIVATE(account) \
5089N/A ((PurpleAccountPrivate *) (account->priv))
5089N/A
5089N/A+#ifdef GAIM_ENABLE_KEYRING
5089N/A+#include <gnome-keyring.h>
5089N/A+
5089N/A+static char * gaim_account_get_password_from_keyring (const char *_prpl, const char *_user);
5089N/A+static gboolean gaim_account_set_password_in_keyring (const char *_prpl, const char *_user, const char *password);
5089N/A+#endif
5089N/A+
5089N/A+
5089N/A /* TODO: Should use PurpleValue instead of this? What about "ui"? */
5089N/A typedef struct
5089N/A {
5089N/A@@ -393,8 +401,13 @@
5089N/A if (purple_account_get_remember_password(account) &&
5089N/A ((tmp = purple_account_get_password(account)) != NULL))
5089N/A {
5089N/A+#ifdef GAIM_ENABLE_KEYRING
5089N/A+ gaim_account_set_password_in_keyring( purple_account_get_protocol_id(account),
5089N/A+ purple_account_get_username(account), tmp);
5089N/A+#else
5089N/A child = xmlnode_new_child(node, "password");
5089N/A xmlnode_insert_data(child, tmp, -1);
5089N/A+#endif
5089N/A } else if (_purple_account_is_password_encrypted(account)) {
5089N/A const char *keyring = NULL;
5089N/A const char *mode = NULL;
5089N/A@@ -909,27 +925,37 @@
5089N/A }
5089N/A
5089N/A ret = purple_account_new(name, _purple_oscar_convert(name, protocol_id)); /* XXX: */
5089N/A- g_free(name);
5089N/A- g_free(protocol_id);
5089N/A+ gboolean got_pwd = FALSE;
5089N/A+#ifdef GAIM_ENABLE_KEYRING
5089N/A+ data = gaim_account_get_password_from_keyring(protocol_id, name);
5089N/A+ if (data)
5089N/A+ {
5089N/A+ got_pwd = TRUE;
5089N/A+ purple_account_set_remember_password(ret, TRUE);
5089N/A+ purple_account_set_password(ret, data);
5089N/A+ g_free(data);
5089N/A+ }
5089N/A+#endif
5089N/A+ if (!got_pwd)
5089N/A+ {
5089N/A+ /* Read the password */
5089N/A+ child = xmlnode_get_child(node, "password");
5089N/A+ if (child != NULL) {
5089N/A+ const char *keyring_id = xmlnode_get_attrib(child, "keyring_id");
5089N/A+ const char *mode = xmlnode_get_attrib(child, "mode");
5089N/A+ gboolean is_plaintext;
5089N/A
5089N/A- /* Read the password */
5089N/A- child = xmlnode_get_child(node, "password");
5089N/A- if (child != NULL) {
5089N/A- const char *keyring_id = xmlnode_get_attrib(child, "keyring_id");
5089N/A- const char *mode = xmlnode_get_attrib(child, "mode");
5089N/A- gboolean is_plaintext;
5089N/A+ data = xmlnode_get_data(child);
5089N/A
5089N/A- data = xmlnode_get_data(child);
5089N/A+ if (keyring_id == NULL || keyring_id[0] == '\0')
5089N/A+ is_plaintext = TRUE;
5089N/A+ else if (g_strcmp0(keyring_id, "keyring-internal") != 0)
5089N/A+ is_plaintext = FALSE;
5089N/A+ else if (mode == NULL || mode[0] == '\0' || g_strcmp0(mode, "cleartext") == 0)
5089N/A+ is_plaintext = TRUE;
5089N/A+ else
5089N/A+ is_plaintext = FALSE;
5089N/A
5089N/A- if (keyring_id == NULL || keyring_id[0] == '\0')
5089N/A- is_plaintext = TRUE;
5089N/A- else if (g_strcmp0(keyring_id, "keyring-internal") != 0)
5089N/A- is_plaintext = FALSE;
5089N/A- else if (mode == NULL || mode[0] == '\0' || g_strcmp0(mode, "cleartext") == 0)
5089N/A- is_plaintext = TRUE;
5089N/A- else
5089N/A- is_plaintext = FALSE;
5089N/A-
5089N/A if (is_plaintext) {
5089N/A purple_account_set_remember_password(ret, TRUE);
5089N/A purple_account_set_password(ret, data);
5089N/A@@ -940,6 +966,9 @@
5089N/A }
5089N/A g_free(data);
5089N/A }
5089N/A+ }
5089N/A+ g_free(name);
5089N/A+ g_free(protocol_id);
5089N/A
5089N/A /* Read the alias */
5089N/A child = xmlnode_get_child(node, "alias");
5089N/A@@ -3350,3 +3378,66 @@
5089N/A
5089N/A return (priv->password_keyring != NULL);
5089N/A }
5089N/A+
5089N/A+#ifdef GAIM_ENABLE_KEYRING
5089N/A+static char *
5089N/A+gaim_account_get_password_from_keyring(const char *_prpl, const char *_user)
5089N/A+{
5089N/A+ GnomeKeyringNetworkPasswordData *found_item;
5089N/A+ GnomeKeyringResult result;
5089N/A+ GList *matches;
5089N/A+ char *password;
5089N/A+
5089N/A+ matches = NULL;
5089N/A+
5089N/A+ result = gnome_keyring_find_network_password_sync (
5089N/A+ _user, /* user */
5089N/A+ NULL, /* domain */
5089N/A+ "gaim.local", /* server */
5089N/A+ NULL, /* object */
5089N/A+ _prpl, /* protocol */
5089N/A+ NULL, /* authtype */
5089N/A+ 1863, /* port */
5089N/A+ &matches);
5089N/A+
5089N/A+ if (result != GNOME_KEYRING_RESULT_OK)
5089N/A+ return NULL;
5089N/A+
5089N/A+ if (matches == NULL || matches->data == NULL)
5089N/A+ return NULL;
5089N/A+
5089N/A+ found_item = (GnomeKeyringNetworkPasswordData *) matches->data;
5089N/A+
5089N/A+ password = g_strdup (found_item->password);
5089N/A+
5089N/A+ gnome_keyring_network_password_list_free (matches);
5089N/A+
5089N/A+ return password;
5089N/A+}
5089N/A+
5089N/A+void my_GnomeKeyringOperationGetIntCallback(GnomeKeyringResult result, guint32 val, gpointer data)
5089N/A+{
5089N/A+ return;
5089N/A+}
5089N/A+
5089N/A+static gboolean
5089N/A+gaim_account_set_password_in_keyring (const char *_prpl, const char *_user, const char *_password)
5089N/A+{
5089N/A+ GnomeKeyringResult result;
5089N/A+ guint32 item_id;
5089N/A+
5089N/A+ gpointer req = gnome_keyring_set_network_password (
5089N/A+ NULL, /* default keyring */
5089N/A+ _user, /* user */
5089N/A+ NULL, /* domain */
5089N/A+ "gaim.local", /* server */
5089N/A+ NULL, /* object */
5089N/A+ _prpl, /* protocol */
5089N/A+ NULL, /* authtype */
5089N/A+ 1863, /* port */
5089N/A+ _password, /* password */
5089N/A+ my_GnomeKeyringOperationGetIntCallback, NULL, NULL);
5089N/A+ return TRUE;
5089N/A+}
5089N/A+#endif
5089N/A+