libpurple/plugins/keyrings/gnomekeyring.c

Sun, 06 Oct 2013 18:15:19 +0530

author
Ankit Vani <a@nevitus.org>
date
Sun, 06 Oct 2013 18:15:19 +0530
branch
soc.2013.gobjectification.plugins
changeset 36858
920cf8db7c68
parent 36653
4084c34c051d
parent 34456
d69aa7d3530c
child 37015
28ee14bbe0ab
permissions
-rw-r--r--

Merged soc.2013.gobjectification branch

33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
1 /**
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
2 * @file gnomekeyring.c Gnome keyring password storage
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
3 * @ingroup plugins
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
4 */
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
5
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
6 /* purple
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
7 *
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
8 * Purple is the legal property of its developers, whose names are too numerous
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
10 * source distribution.
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
11 *
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
15 * (at your option) any later version.
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
16 *
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
20 * GNU General Public License for more details.
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
21 *
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
23 * along with this program ; if not, write to the Free Software
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
25 */
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
26
34076
64e389ae5cc3 Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34050
diff changeset
27 #include "internal.h"
64e389ae5cc3 Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34050
diff changeset
28 #include "account.h"
64e389ae5cc3 Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34050
diff changeset
29 #include "debug.h"
64e389ae5cc3 Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34050
diff changeset
30 #include "keyring.h"
36367
891eea799578 Renamed plugin.[ch] to plugins.[ch], since we (will) no longer have a PurplePlugin structure.
Ankit Vani <a@nevitus.org>
parents: 34199
diff changeset
31 #include "plugins.h"
34076
64e389ae5cc3 Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34050
diff changeset
32 #include "version.h"
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
33
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
34 #include <gnome-keyring.h>
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
35 #include <gnome-keyring-memory.h>
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
36
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
37 #define GNOMEKEYRING_NAME N_("GNOME Keyring")
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
38 #define GNOMEKEYRING_DESCRIPTION N_("This plugin will store passwords in " \
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
39 "GNOME Keyring.")
34093
c8197603fa20 Use better keyring IDs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34081
diff changeset
40 #define GNOMEKEYRING_ID "keyring-gnomekeyring"
36642
b8ba53daa445 Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents: 36540
diff changeset
41 #define GNOMEKEYRING_AUTHORS \
b8ba53daa445 Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents: 36540
diff changeset
42 { "Tomek Wasilczyk (tomkiewicz@cpw.pidgin.im)", NULL }
b8ba53daa445 Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents: 36540
diff changeset
43
36502
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
44 #define GNOMEKEYRING_DOMAIN (g_quark_from_static_string(GNOMEKEYRING_ID))
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
45
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
46 static PurpleKeyring *keyring_handler = NULL;
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
47 static GList *request_queue = NULL;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
48 static gpointer current_request = NULL;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
49
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
50 typedef struct
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
51 {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
52 enum
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
53 {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
54 GNOMEKEYRING_REQUEST_READ,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
55 GNOMEKEYRING_REQUEST_SAVE
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
56 } type;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
57 PurpleAccount *account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
58 gchar *password;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
59 union
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
60 {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
61 PurpleKeyringReadCallback read;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
62 PurpleKeyringSaveCallback save;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
63 } cb;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
64 gpointer cb_data;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
65 gboolean handled;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
66 } gnomekeyring_request;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
67
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
68 static void gnomekeyring_cancel_queue(void);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
69 static void gnomekeyring_process_queue(void);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
70
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
71 static void gnomekeyring_request_free(gnomekeyring_request *req)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
72 {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
73 if (req->password != NULL) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
74 memset(req->password, 0, strlen(req->password));
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
75 gnome_keyring_memory_free(req->password);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
76 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
77 g_free(req);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
78 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
79
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
80 static void
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
81 gnomekeyring_enqueue(gnomekeyring_request *req)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
82 {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
83 request_queue = g_list_append(request_queue, req);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
84 gnomekeyring_process_queue();
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
85 }
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
86
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
87 static void
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
88 gnomekeyring_read_cb(GnomeKeyringResult result, const char *password,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
89 gpointer _req)
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
90 {
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
91 gnomekeyring_request *req = _req;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
92 PurpleAccount *account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
93 GError *error = NULL;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
94
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
95 g_return_if_fail(req != NULL);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
96
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
97 current_request = NULL;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
98 account = req->account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
99
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
100 if (result == GNOME_KEYRING_RESULT_OK) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
101 error = NULL;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
102 } else if (result == GNOME_KEYRING_RESULT_NO_MATCH) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
103 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
104 PURPLE_KEYRING_ERROR_NOPASSWORD,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
105 _("No password found for account."));
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
106 } else if (result == GNOME_KEYRING_RESULT_DENIED ||
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
107 result == GNOME_KEYRING_RESULT_CANCELLED) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
108 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
109 PURPLE_KEYRING_ERROR_ACCESSDENIED,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
110 _("Access denied."));
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
111 gnomekeyring_cancel_queue();
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
112 } else if (result == GNOME_KEYRING_RESULT_NO_KEYRING_DAEMON ||
34456
d69aa7d3530c Clang warnings: gnutls, gnome keyring and G_GNUC_*_IGNORE_DEPRECATIONS
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34294
diff changeset
113 result == GNOME_KEYRING_RESULT_IO_ERROR) {
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
114 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
115 PURPLE_KEYRING_ERROR_BACKENDFAIL,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
116 _("Communication with GNOME Keyring failed."));
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
117 } else {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
118 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
119 PURPLE_KEYRING_ERROR_BACKENDFAIL,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
120 _("Unknown error (code: %d)."), result);
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
121 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
122
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
123 if (error == NULL && password == NULL) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
124 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
125 PURPLE_KEYRING_ERROR_BACKENDFAIL,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
126 _("Unknown error (password empty)."));
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
127 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
128
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
129 if (error == NULL) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
130 purple_debug_misc("keyring-gnome",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
131 "Got password for account %s (%s).\n",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
132 purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
133 purple_account_get_protocol_id(account));
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
134 } else if (result == GNOME_KEYRING_RESULT_NO_MATCH) {
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
135 if (purple_debug_is_verbose()) {
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
136 purple_debug_info("keyring-gnome",
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
137 "Password for account %s (%s) isn't stored.\n",
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
138 purple_account_get_username(account),
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
139 purple_account_get_protocol_id(account));
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
140 }
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
141 } else {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
142 password = NULL;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
143 purple_debug_warning("keyring-gnome", "Failed to read "
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
144 "password for account %s (%s), code: %d.\n",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
145 purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
146 purple_account_get_protocol_id(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
147 result);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
148 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
149
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
150 if (req->cb.read != NULL)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
151 req->cb.read(account, password, error, req->cb_data);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
152 req->handled = TRUE;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
153
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
154 if (error)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
155 g_error_free(error);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
156
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
157 gnomekeyring_process_queue();
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
158 }
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
159
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
160 static void
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
161 gnomekeyring_save_cb(GnomeKeyringResult result, gpointer _req)
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
162 {
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
163 gnomekeyring_request *req = _req;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
164 PurpleAccount *account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
165 GError *error = NULL;
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
166 gboolean already_removed = FALSE;
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
167
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
168 g_return_if_fail(req != NULL);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
169
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
170 current_request = NULL;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
171 account = req->account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
172
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
173 if (result == GNOME_KEYRING_RESULT_OK) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
174 error = NULL;
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
175 } else if (result == GNOME_KEYRING_RESULT_NO_MATCH &&
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
176 req->password == NULL) {
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
177 error = NULL;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
178 already_removed = TRUE;
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
179 } else if (result == GNOME_KEYRING_RESULT_DENIED ||
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
180 result == GNOME_KEYRING_RESULT_CANCELLED) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
181 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
182 PURPLE_KEYRING_ERROR_ACCESSDENIED,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
183 _("Access denied."));
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
184 gnomekeyring_cancel_queue();
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
185 } else if (result == GNOME_KEYRING_RESULT_NO_KEYRING_DAEMON ||
34456
d69aa7d3530c Clang warnings: gnutls, gnome keyring and G_GNUC_*_IGNORE_DEPRECATIONS
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34294
diff changeset
186 result == GNOME_KEYRING_RESULT_IO_ERROR) {
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
187 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
188 PURPLE_KEYRING_ERROR_BACKENDFAIL,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
189 _("Communication with GNOME Keyring failed."));
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
190 } else {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
191 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
192 PURPLE_KEYRING_ERROR_BACKENDFAIL,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
193 _("Unknown error (code: %d)."), result);
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
194 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
195
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
196 if (already_removed) {
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
197 /* no operation */
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
198 } else if (error == NULL) {
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
199 purple_debug_misc("keyring-gnome",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
200 "Password %s for account %s (%s).\n",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
201 req->password ? "saved" : "removed",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
202 purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
203 purple_account_get_protocol_id(account));
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
204 } else {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
205 purple_debug_warning("keyring-gnome", "Failed updating "
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
206 "password for account %s (%s), code: %d.\n",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
207 purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
208 purple_account_get_protocol_id(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
209 result);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
210 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
211
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
212 if (req->cb.save != NULL)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
213 req->cb.save(account, error, req->cb_data);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
214 req->handled = TRUE;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
215
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
216 if (error)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
217 g_error_free(error);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
218
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
219 gnomekeyring_process_queue();
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
220 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
221
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
222 static void
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
223 gnomekeyring_request_cancel(gpointer _req)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
224 {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
225 gnomekeyring_request *req = _req;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
226 PurpleAccount *account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
227 GError *error;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
228
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
229 g_return_if_fail(req != NULL);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
230
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
231 if (req->handled) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
232 gnomekeyring_request_free(req);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
233 return;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
234 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
235
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
236 purple_debug_warning("keyring-gnome",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
237 "operation cancelled (%d %s:%s)\n", req->type,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
238 purple_account_get_protocol_id(req->account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
239 purple_account_get_username(req->account));
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
240
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
241 account = req->account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
242 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
243 PURPLE_KEYRING_ERROR_CANCELLED,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
244 _("Operation cancelled."));
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
245 if (req->type == GNOMEKEYRING_REQUEST_READ && req->cb.read)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
246 req->cb.read(account, NULL, error, req->cb_data);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
247 if (req->type == GNOMEKEYRING_REQUEST_SAVE && req->cb.save)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
248 req->cb.save(account, error, req->cb_data);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
249 g_error_free(error);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
250
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
251 gnomekeyring_request_free(req);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
252 gnomekeyring_process_queue();
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
253 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
254
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
255 static void
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
256 gnomekeyring_cancel_queue(void)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
257 {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
258 GList *cancel_list = request_queue;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
259
34139
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34138
diff changeset
260 if (request_queue == NULL)
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34138
diff changeset
261 return;
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34138
diff changeset
262
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
263 purple_debug_info("gnome-keyring", "cancelling all pending requests\n");
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
264 request_queue = NULL;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
265
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
266 g_list_free_full(cancel_list, gnomekeyring_request_cancel);
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
267 }
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
268
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
269 static void
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
270 gnomekeyring_process_queue(void)
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
271 {
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
272 gnomekeyring_request *req;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
273 PurpleAccount *account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
274 GList *first;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
275
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
276 if (request_queue == NULL)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
277 return;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
278
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
279 if (current_request) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
280 if (purple_debug_is_verbose())
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
281 purple_debug_misc("keyring-gnome", "busy...\n");
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
282 return;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
283 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
284
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
285 first = g_list_first(request_queue);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
286 req = first->data;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
287 request_queue = g_list_delete_link(request_queue, first);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
288 account = req->account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
289
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
290 if (purple_debug_is_verbose()) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
291 purple_debug_misc("keyring-gnome",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
292 "%s password for account %s (%s)\n",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
293 req->type == GNOMEKEYRING_REQUEST_READ ? "reading" :
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
294 (req->password == NULL ? "removing" : "updating"),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
295 purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
296 purple_account_get_protocol_id(account));
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
297 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
298
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
299 if (req->type == GNOMEKEYRING_REQUEST_READ) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
300 current_request = gnome_keyring_find_password(
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
301 GNOME_KEYRING_NETWORK_PASSWORD, gnomekeyring_read_cb,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
302 req, gnomekeyring_request_cancel,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
303 "user", purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
304 "protocol", purple_account_get_protocol_id(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
305 NULL);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
306 } else if (req->type == GNOMEKEYRING_REQUEST_SAVE &&
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
307 req->password != NULL) {
34170
94102637e7c7 Coding style and entry description for GNOME Keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
308 gchar *display_name = g_strdup_printf(
94102637e7c7 Coding style and entry description for GNOME Keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
309 _("Pidgin IM password for account %s"),
94102637e7c7 Coding style and entry description for GNOME Keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
310 purple_account_get_username(account));
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
311 current_request = gnome_keyring_store_password(
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
312 GNOME_KEYRING_NETWORK_PASSWORD, GNOME_KEYRING_DEFAULT,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
313 display_name, req->password, gnomekeyring_save_cb, req,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
314 gnomekeyring_request_cancel,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
315 "user", purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
316 "protocol", purple_account_get_protocol_id(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
317 NULL);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
318 g_free(display_name);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
319 } else if (req->type == GNOMEKEYRING_REQUEST_SAVE &&
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
320 req->password == NULL) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
321 current_request = gnome_keyring_delete_password(
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
322 GNOME_KEYRING_NETWORK_PASSWORD, gnomekeyring_save_cb,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
323 req, gnomekeyring_request_cancel,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
324 "user", purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
325 "protocol", purple_account_get_protocol_id(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
326 NULL);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
327 } else {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
328 g_return_if_reached();
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
329 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
330 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
331
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
332 static void
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
333 gnomekeyring_read(PurpleAccount *account, PurpleKeyringReadCallback cb,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
334 gpointer data)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
335 {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
336 gnomekeyring_request *req;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
337
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
338 g_return_if_fail(account != NULL);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
339
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
340 req = g_new0(gnomekeyring_request, 1);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
341 req->type = GNOMEKEYRING_REQUEST_READ;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
342 req->account = account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
343 req->cb.read = cb;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
344 req->cb_data = data;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
345
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
346 gnomekeyring_enqueue(req);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
347 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
348
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
349 static void
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
350 gnomekeyring_save(PurpleAccount *account, const gchar *password,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
351 PurpleKeyringSaveCallback cb, gpointer data)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
352 {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
353 gnomekeyring_request *req;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
354
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
355 g_return_if_fail(account != NULL);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
356
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
357 req = g_new0(gnomekeyring_request, 1);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
358 req->type = GNOMEKEYRING_REQUEST_SAVE;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
359 req->account = account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
360 req->password = gnome_keyring_memory_strdup(password);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
361 req->cb.save = cb;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
362 req->cb_data = data;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
363
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
364 gnomekeyring_enqueue(req);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
365 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
366
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
367 static void
34139
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34138
diff changeset
368 gnomekeyring_cancel(void)
34138
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
369 {
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
370 gnomekeyring_cancel_queue();
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
371 if (current_request) {
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
372 gnome_keyring_cancel_request(current_request);
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
373 while (g_main_iteration(FALSE));
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
374 }
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
375 }
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
376
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
377 static void
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
378 gnomekeyring_close(void)
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
379 {
34138
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
380 gnomekeyring_cancel();
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
381 }
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
382
36502
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
383 static PurplePluginInfo *
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
384 plugin_query(GError **error)
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
385 {
36642
b8ba53daa445 Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents: 36540
diff changeset
386 const gchar * const authors[] = GNOMEKEYRING_AUTHORS;
b8ba53daa445 Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents: 36540
diff changeset
387
36502
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
388 return purple_plugin_info_new(
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
389 "id", GNOMEKEYRING_ID,
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
390 "name", GNOMEKEYRING_NAME,
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
391 "version", DISPLAY_VERSION,
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
392 "category", N_("Keyring"),
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
393 "summary", "GNOME Keyring Plugin",
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
394 "description", GNOMEKEYRING_DESCRIPTION,
36642
b8ba53daa445 Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents: 36540
diff changeset
395 "authors", authors,
36502
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
396 "website", PURPLE_WEBSITE,
36505
60c161851325 Integrated purple ABI requirement into GPlugin's "abi-version" property
Ankit Vani <a@nevitus.org>
parents: 36502
diff changeset
397 "abi-version", PURPLE_ABI_VERSION,
36653
4084c34c051d Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
Ankit Vani <a@nevitus.org>
parents: 36642
diff changeset
398 "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL,
36502
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
399 NULL
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
400 );
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
401 }
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
402
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
403 static gboolean
36502
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
404 plugin_load(PurplePlugin *plugin, GError **error)
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
405 {
34294
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
406 GModule *gkr_module;
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
407
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
408 /* libgnome-keyring may crash, if was unloaded before glib main loop
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
409 * termination.
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
410 */
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
411 gkr_module = g_module_open("libgnome-keyring", 0);
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
412 if (gkr_module == NULL) {
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
413 purple_debug_info("keyring-gnome", "GNOME Keyring module not "
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
414 "found\n");
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
415 return FALSE;
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
416 }
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
417 g_module_make_resident(gkr_module);
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
418
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
419 if (!gnome_keyring_is_available()) {
36502
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
420 g_set_error(error, GNOMEKEYRING_DOMAIN, 0, "GNOME Keyring service is "
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
421 "disabled.");
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
422 purple_debug_info("keyring-gnome", "GNOME Keyring service is "
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
423 "disabled\n");
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
424 return FALSE;
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
425 }
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
426
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
427 keyring_handler = purple_keyring_new();
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
428
34281
ad957d0a467a Keyring (and some GTK): fix translation callbacks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34199
diff changeset
429 purple_keyring_set_name(keyring_handler, _(GNOMEKEYRING_NAME));
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
430 purple_keyring_set_id(keyring_handler, GNOMEKEYRING_ID);
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
431 purple_keyring_set_read_password(keyring_handler, gnomekeyring_read);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
432 purple_keyring_set_save_password(keyring_handler, gnomekeyring_save);
34170
94102637e7c7 Coding style and entry description for GNOME Keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
433 purple_keyring_set_cancel_requests(keyring_handler,
94102637e7c7 Coding style and entry description for GNOME Keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
434 gnomekeyring_cancel);
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
435 purple_keyring_set_close_keyring(keyring_handler, gnomekeyring_close);
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
436
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
437 purple_keyring_register(keyring_handler);
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
438
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
439 return TRUE;
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
440 }
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
441
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
442 static gboolean
36502
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
443 plugin_unload(PurplePlugin *plugin, GError **error)
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
444 {
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
445 if (purple_keyring_get_inuse() == keyring_handler) {
36502
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
446 g_set_error(error, GNOMEKEYRING_DOMAIN, 0, "The keyring is currently "
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
447 "in use.");
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
448 purple_debug_warning("keyring-gnome",
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
449 "keyring in use, cannot unload\n");
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
450 return FALSE;
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
451 }
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
452
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
453 gnomekeyring_close();
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
454
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33984
diff changeset
455 purple_keyring_unregister(keyring_handler);
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
456 purple_keyring_free(keyring_handler);
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
457 keyring_handler = NULL;
34096
3d28c3311ad0 Don't allow unloading a plugin if its keyring is active.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34095
diff changeset
458
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
459 return TRUE;
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
460 }
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
461
36502
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
462 PURPLE_PLUGIN_INIT(gnome_keyring, plugin_query, plugin_load, plugin_unload);

mercurial