updated on Fri Jan 20 20:16:25 UTC 2012
[aur-mirror.git] / pidgin-gnome / pidgin-01-gnome-keyring.diff
blob866ca3160d1b86f3f914db39ab0a653897c1a9f9
1 --- configure.ac
2 +++ configure.ac
3 @@ -2267,6 +2267,20 @@
4 LDFLAGS="$orig_LDFLAGS"
5 fi
7 +dnl #######################################################################
8 +dnl # Check for gnome-keyring
9 +dnl #--enable-gnome-keyring=(yes|no)
10 +dnl #######################################################################
11 +AC_ARG_ENABLE(gnome-keyring,
12 + AC_HELP_STRING([--enable-gnome-keyring],
13 + [use gnome keyring for storing password [default=no]]),,
14 + enable_gnome_keyring=no)
15 +if test "x$enable_gnome_keyring" = "xyes"; then
16 + PKG_CHECK_MODULES(GAIM_KEYRING,
17 + gnome-keyring-1,
18 + AC_DEFINE(GAIM_ENABLE_KEYRING, [], [Set if we should use gnome-keyring]))
19 +fi
21 AC_MSG_CHECKING(for me pot o' gold)
22 AC_MSG_RESULT(no)
23 AC_CHECK_FUNCS(gethostid lrand48)
24 --- libpurple/Makefile.am
25 +++ libpurple/Makefile.am
26 @@ -246,6 +246,7 @@
27 $(DBUS_LIBS) \
28 $(GLIB_LIBS) \
29 $(LIBXML_LIBS) \
30 + $(GAIM_KEYRING_LIBS) \
31 $(NETWORKMANAGER_LIBS) \
32 $(INTLLIBS) \
33 -lm
34 @@ -259,6 +260,7 @@
35 $(GLIB_CFLAGS) \
36 $(DEBUG_CFLAGS) \
37 $(DBUS_CFLAGS) \
38 + $(GAIM_KEYRING_CFLAGS) \
39 $(LIBXML_CFLAGS) \
40 $(NETWORKMANAGER_CFLAGS)
42 --- libpurple/account.c
43 +++ libpurple/account.c
44 @@ -49,6 +49,13 @@
45 #define PURPLE_ACCOUNT_GET_PRIVATE(account) \
46 ((PurpleAccountPrivate *) (account->priv))
48 +#ifdef GAIM_ENABLE_KEYRING
49 +#include <gnome-keyring.h>
51 +static char * gaim_account_get_password_from_keyring (const char *_prpl, const char *_user);
52 +static gboolean gaim_account_set_password_in_keyring (const char *_prpl, const char *_user, const char *password);
53 +#endif
55 /* TODO: Should use PurpleValue instead of this? What about "ui"? */
56 typedef struct
58 @@ -380,8 +387,13 @@
59 if (purple_account_get_remember_password(account) &&
60 ((tmp = purple_account_get_password(account)) != NULL))
62 +#ifdef GAIM_ENABLE_KEYRING
63 + gaim_account_set_password_in_keyring( purple_account_get_protocol_id(account),
64 + purple_account_get_username(account), tmp);
65 +#else
66 child = xmlnode_new_child(node, "password");
67 xmlnode_insert_data(child, tmp, -1);
68 +#endif
71 if ((tmp = purple_account_get_alias(account)) != NULL)
72 @@ -796,17 +808,30 @@
75 ret = purple_account_new(name, _purple_oscar_convert(name, protocol_id)); /* XXX: */
76 - g_free(name);
77 - g_free(protocol_id);
79 - /* Read the password */
80 - child = xmlnode_get_child(node, "password");
81 - if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
82 - {
83 - purple_account_set_remember_password(ret, TRUE);
84 - purple_account_set_password(ret, data);
85 - g_free(data);
86 - }
87 + gboolean got_pwd = FALSE;
88 +#ifdef GAIM_ENABLE_KEYRING
89 + data = gaim_account_get_password_from_keyring(protocol_id, name);
90 + if (data)
91 + {
92 + got_pwd = TRUE;
93 + purple_account_set_remember_password(ret, TRUE);
94 + purple_account_set_password(ret, data);
95 + g_free(data);
96 + }
97 +#endif
98 + if (!got_pwd)
99 + {
100 + /* Read the password */
101 + child = xmlnode_get_child(node, "password");
102 + if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
104 + purple_account_set_remember_password(ret, TRUE);
105 + purple_account_set_password(ret, data);
106 + g_free(data);
109 + g_free(name);
110 + g_free(protocol_id);
112 /* Read the alias */
113 child = xmlnode_get_child(node, "alias");
114 @@ -2797,3 +2822,65 @@
115 purple_signals_disconnect_by_handle(handle);
116 purple_signals_unregister_by_instance(handle);
119 +#ifdef GAIM_ENABLE_KEYRING
120 +static char *
121 +gaim_account_get_password_from_keyring(const char *_prpl, const char *_user)
123 + GnomeKeyringNetworkPasswordData *found_item;
124 + GnomeKeyringResult result;
125 + GList *matches;
126 + char *password;
128 + matches = NULL;
130 + result = gnome_keyring_find_network_password_sync (
131 + _user, /* user */
132 + NULL, /* domain */
133 + "gaim.local", /* server */
134 + NULL, /* object */
135 + _prpl, /* protocol */
136 + NULL, /* authtype */
137 + 1863, /* port */
138 + &matches);
140 + if (result != GNOME_KEYRING_RESULT_OK)
141 + return NULL;
143 + if (matches == NULL || matches->data == NULL)
144 + return NULL;
146 + found_item = (GnomeKeyringNetworkPasswordData *) matches->data;
148 + password = g_strdup (found_item->password);
150 + gnome_keyring_network_password_list_free (matches);
152 + return password;
155 +void my_GnomeKeyringOperationGetIntCallback(GnomeKeyringResult result, guint32 val, gpointer data)
157 + return;
160 +static gboolean
161 +gaim_account_set_password_in_keyring (const char *_prpl, const char *_user, const char *_password)
163 + GnomeKeyringResult result;
164 + guint32 item_id;
166 + gpointer req = gnome_keyring_set_network_password (
167 + NULL, /* default keyring */
168 + _user, /* user */
169 + NULL, /* domain */
170 + "gaim.local", /* server */
171 + NULL, /* object */
172 + _prpl, /* protocol */
173 + NULL, /* authtype */
174 + 1863, /* port */
175 + _password, /* password */
176 + my_GnomeKeyringOperationGetIntCallback, NULL, NULL);
177 + return TRUE;
179 +#endif
180 --- pidgin/Makefile.am
181 +++ pidgin/Makefile.am
182 @@ -196,6 +196,7 @@
183 $(GTKSPELL_LIBS) \
184 $(STARTUP_NOTIFICATION_LIBS) \
185 $(LIBXML_LIBS) \
186 + $(GAIM_KEYRING_LIBS) \
187 $(GTK_LIBS) \
188 $(top_builddir)/libpurple/libpurple.la
190 @@ -217,6 +218,7 @@
191 $(GSTREAMER_CFLAGS) \
192 $(DEBUG_CFLAGS) \
193 $(GTK_CFLAGS) \
194 + $(GAIM_KEYRING_CFLAGS) \
195 $(DBUS_CFLAGS) \
196 $(GTKSPELL_CFLAGS) \
197 $(STARTUP_NOTIFICATION_CFLAGS) \
198 --- pidgin/gtkmain.c
199 +++ pidgin/gtkmain.c
200 @@ -69,6 +69,10 @@
201 #include "pidginstock.h"
202 #include "gtkwhiteboard.h"
204 +#ifdef GAIM_ENABLE_KEYRING
205 +#include <gnome-keyring.h>
206 +#endif
208 #ifdef HAVE_SIGNAL_H
209 # include <signal.h>
210 #endif
211 @@ -699,6 +703,12 @@
212 gtk_rc_add_default_file(search_path);
213 g_free(search_path);
215 +#ifdef GAIM_ENABLE_KEYRING
216 + GnomeKeyringResult rtn = gnome_keyring_unlock_sync(NULL, NULL);
217 + // if (rtn == GNOME_KEYRING_RESULT_DENIED)
218 + // return 0;
219 +#endif
221 gui_check = gtk_init_check(&argc, &argv);
222 if (!gui_check) {
223 char *display = gdk_get_display();