summaryrefslogtreecommitdiff
blob: fec338ec34bcc55ec8a97ef8be1d2d40ef563b0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
diff -ur pidgin-2.7.1.orig/configure.ac pidgin-2.7.1/configure.ac
--- pidgin-2.7.1.orig/configure.ac	2010-05-29 21:23:56.000000000 -0400
+++ pidgin-2.7.1/configure.ac	2010-07-20 23:25:59.520998076 -0400
@@ -2393,6 +2393,20 @@
 	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
+    PKG_CHECK_MODULES(PIDGIN_KEYRING,
+                      gnome-keyring-1,
+                      AC_DEFINE(PIDGIN_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)
diff -ur pidgin-2.7.1.orig/libpurple/Makefile.am pidgin-2.7.1/libpurple/Makefile.am
--- pidgin-2.7.1.orig/libpurple/Makefile.am	2010-05-29 21:23:57.000000000 -0400
+++ pidgin-2.7.1/libpurple/Makefile.am	2010-07-20 23:25:59.529007791 -0400
@@ -307,6 +307,7 @@
 	$(DBUS_LIBS) \
 	$(GLIB_LIBS) \
 	$(LIBXML_LIBS) \
+	$(PIDGIN_KEYRING_LIBS) \
 	$(NETWORKMANAGER_LIBS) \
 	$(INTLLIBS) \
 	$(FARSIGHT_LIBS) \
@@ -323,6 +324,7 @@
 	$(GLIB_CFLAGS) \
 	$(DEBUG_CFLAGS) \
 	$(DBUS_CFLAGS) \
+	$(PIDGIN_KEYRING_CFLAGS) \
 	$(LIBXML_CFLAGS) \
 	$(FARSIGHT_CFLAGS) \
 	$(GSTREAMER_CFLAGS) \
diff -ur pidgin-2.7.1.orig/libpurple/account.c pidgin-2.7.1/libpurple/account.c
--- pidgin-2.7.1.orig/libpurple/account.c	2010-05-29 21:23:57.000000000 -0400
+++ pidgin-2.7.1/libpurple/account.c	2010-07-20 23:25:59.528013217 -0400
@@ -49,6 +49,13 @@
 #define PURPLE_ACCOUNT_GET_PRIVATE(account) \
 	((PurpleAccountPrivate *) (account->priv))
 
+#ifdef PIDGIN_ENABLE_KEYRING
+#include <gnome-keyring.h>
+
+static char * gaim_account_get_password_from_keyring (const char *_prpl, const char *_user);
+static gboolean gaim_account_set_password_in_keyring (const char *_prpl, const char *_user, const char *password);
+#endif
+
 /* TODO: Should use PurpleValue instead of this?  What about "ui"? */
 typedef struct
 {
@@ -378,8 +385,13 @@
 	if (purple_account_get_remember_password(account) &&
 		((tmp = purple_account_get_password(account)) != NULL))
 	{
+#ifdef PIDGIN_ENABLE_KEYRING
+                gaim_account_set_password_in_keyring( purple_account_get_protocol_id(account),
+                                          purple_account_get_username(account), tmp);
+#else
 		child = xmlnode_new_child(node, "password");
 		xmlnode_insert_data(child, tmp, -1);
+#endif
 	}
 
 	if ((tmp = purple_account_get_alias(account)) != NULL)
@@ -828,17 +840,30 @@
 	}
 
 	ret = purple_account_new(name, _purple_oscar_convert(name, protocol_id)); /* XXX: */
-	g_free(name);
-	g_free(protocol_id);
-
-	/* Read the password */
-	child = xmlnode_get_child(node, "password");
-	if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
-	{
-		purple_account_set_remember_password(ret, TRUE);
-		purple_account_set_password(ret, data);
-		g_free(data);
-	}
+        gboolean got_pwd = FALSE;
+#ifdef PIDGIN_ENABLE_KEYRING
+        data = gaim_account_get_password_from_keyring(protocol_id, name);
+        if (data)
+        {
+                got_pwd = TRUE;
+                purple_account_set_remember_password(ret, TRUE);
+                purple_account_set_password(ret, data);
+                g_free(data);
+        }
+#endif
+        if (!got_pwd)
+        {
+                /* Read the password */
+		child = xmlnode_get_child(node, "password");
+		if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
+		{
+			purple_account_set_remember_password(ret, TRUE);
+			purple_account_set_password(ret, data);
+			g_free(data);
+		}
+        }
+        g_free(name);
+        g_free(protocol_id);
 
 	/* Read the alias */
 	child = xmlnode_get_child(node, "alias");
@@ -3064,3 +3089,61 @@
 	purple_signals_disconnect_by_handle(handle);
 	purple_signals_unregister_by_instance(handle);
 }
+
+#ifdef PIDGIN_ENABLE_KEYRING
+static char *
+gaim_account_get_password_from_keyring(const char *_prpl, const char *_user)
+{
+  GnomeKeyringNetworkPasswordData *found_item;
+  GnomeKeyringResult               result;
+  GList                           *matches;
+  char                            *password;
+
+  matches = NULL;
+
+  result = gnome_keyring_find_network_password_sync (
+               _user,          /* user     */
+               NULL,           /* domain   */
+               "gaim.local",   /* server   */
+               NULL,           /* object   */
+               _prpl,          /* protocol */
+               NULL,           /* authtype */
+               1863,           /* port     */
+               &matches);
+
+  if (result != GNOME_KEYRING_RESULT_OK)
+    return NULL;
+
+  if (matches == NULL || matches->data == NULL)
+    return NULL;
+
+  found_item = (GnomeKeyringNetworkPasswordData *) matches->data;
+
+  password = g_strdup (found_item->password);
+
+  gnome_keyring_network_password_list_free (matches);
+
+  return password;
+}
+
+static gboolean
+gaim_account_set_password_in_keyring (const char *_prpl, const char *_user, const char *_password)
+{
+  GnomeKeyringResult result;
+  guint32            item_id;
+
+  result = gnome_keyring_set_network_password_sync (
+                NULL,           /* default keyring */
+                _user,          /* user            */
+                NULL,           /* domain          */
+                "gaim.local",   /* server          */
+                NULL,           /* object          */
+                _prpl,          /* protocol        */
+                NULL,           /* authtype        */
+                1863,           /* port            */
+                _password,       /* password        */
+                &item_id);
+
+  return result == GNOME_KEYRING_RESULT_OK;
+}
+#endif
diff -ur pidgin-2.7.1.orig/pidgin/Makefile.am pidgin-2.7.1/pidgin/Makefile.am
--- pidgin-2.7.1.orig/pidgin/Makefile.am	2010-05-29 21:24:00.000000000 -0400
+++ pidgin-2.7.1/pidgin/Makefile.am	2010-07-20 23:25:59.530998309 -0400
@@ -161,6 +161,7 @@
 	$(GTKSPELL_LIBS) \
 	$(STARTUP_NOTIFICATION_LIBS) \
 	$(LIBXML_LIBS) \
+	$(PIDGIN_KEYRING_LIBS) \
 	$(GTK_LIBS) \
 	$(top_builddir)/libpurple/libpurple.la
 
@@ -181,6 +182,7 @@
 	$(GSTREAMER_CFLAGS) \
 	$(DEBUG_CFLAGS) \
 	$(GTK_CFLAGS) \
+	$(PIDGIN_KEYRING_CFLAGS) \
 	$(DBUS_CFLAGS) \
 	$(GTKSPELL_CFLAGS) \
 	$(STARTUP_NOTIFICATION_CFLAGS) \
diff -ur pidgin-2.7.1.orig/pidgin/gtkmain.c pidgin-2.7.1/pidgin/gtkmain.c
--- pidgin-2.7.1.orig/pidgin/gtkmain.c	2010-05-29 21:24:00.000000000 -0400
+++ pidgin-2.7.1/pidgin/gtkmain.c	2010-07-20 23:25:59.529007791 -0400
@@ -70,6 +70,10 @@
 #include "pidginstock.h"
 #include "gtkwhiteboard.h"
 
+#ifdef PIDGIN_ENABLE_KEYRING
+#include <gnome-keyring.h>
+#endif
+
 #ifdef HAVE_SIGNAL_H
 # include <signal.h>
 #endif
@@ -793,6 +797,12 @@
 	gtk_rc_add_default_file(search_path);
 	g_free(search_path);
 
+#ifdef  PIDGIN_ENABLE_KEYRING
+	GnomeKeyringResult rtn = gnome_keyring_unlock_sync(NULL, NULL);
+	// if (rtn == GNOME_KEYRING_RESULT_DENIED)
+	//   return 0;
+#endif
+
 	gui_check = gtk_init_check(&argc, &argv);
 	if (!gui_check) {
 		char *display = gdk_get_display();