libpurple/plugins/keyrings/gnomekeyring.c

Mon, 27 Jan 2014 04:41:33 +0530

author
Ankit Vani <a@nevitus.org>
date
Mon, 27 Jan 2014 04:41:33 +0530
changeset 35190
5986ee34c476
parent 34456
d69aa7d3530c
child 35362
a6223370667b
child 37015
28ee14bbe0ab
permissions
-rw-r--r--

libpurple: Fix build and warnings with glib 2.24

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"
35190
5986ee34c476 libpurple: Fix build and warnings with glib 2.24
Ankit Vani <a@nevitus.org>
parents: 34456
diff changeset
30 #include "glibcompat.h"
34076
64e389ae5cc3 Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34050
diff changeset
31 #include "keyring.h"
64e389ae5cc3 Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34050
diff changeset
32 #include "plugin.h"
64e389ae5cc3 Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34050
diff changeset
33 #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
34
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
35 #include <gnome-keyring.h>
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
36 #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
37
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
38 #define GNOMEKEYRING_NAME N_("GNOME Keyring")
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
39 #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
40 "GNOME Keyring.")
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
41 #define GNOMEKEYRING_AUTHOR "Tomek Wasilczyk (tomkiewicz@cpw.pidgin.im)"
34093
c8197603fa20 Use better keyring IDs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34081
diff changeset
42 #define GNOMEKEYRING_ID "keyring-gnomekeyring"
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
43
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
44 static PurpleKeyring *keyring_handler = NULL;
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
45 static GList *request_queue = NULL;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
46 static gpointer current_request = NULL;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
47
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
48 typedef struct
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 enum
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 GNOMEKEYRING_REQUEST_READ,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
53 GNOMEKEYRING_REQUEST_SAVE
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
54 } type;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
55 PurpleAccount *account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
56 gchar *password;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
57 union
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
58 {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
59 PurpleKeyringReadCallback read;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
60 PurpleKeyringSaveCallback save;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
61 } cb;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
62 gpointer cb_data;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
63 gboolean handled;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
64 } gnomekeyring_request;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
65
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
66 static void gnomekeyring_cancel_queue(void);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
67 static void gnomekeyring_process_queue(void);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
68
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
69 static void gnomekeyring_request_free(gnomekeyring_request *req)
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 if (req->password != NULL) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
72 memset(req->password, 0, strlen(req->password));
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
73 gnome_keyring_memory_free(req->password);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
74 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
75 g_free(req);
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
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
78 static void
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
79 gnomekeyring_enqueue(gnomekeyring_request *req)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
80 {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
81 request_queue = g_list_append(request_queue, req);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
82 gnomekeyring_process_queue();
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
83 }
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
84
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
85 static void
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
86 gnomekeyring_read_cb(GnomeKeyringResult result, const char *password,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
87 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
88 {
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
89 gnomekeyring_request *req = _req;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
90 PurpleAccount *account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
91 GError *error = NULL;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
92
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
93 g_return_if_fail(req != 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 current_request = NULL;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
96 account = req->account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
97
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
98 if (result == GNOME_KEYRING_RESULT_OK) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
99 error = NULL;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
100 } else if (result == GNOME_KEYRING_RESULT_NO_MATCH) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
101 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
102 PURPLE_KEYRING_ERROR_NOPASSWORD,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
103 _("No password found for account."));
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
104 } else if (result == GNOME_KEYRING_RESULT_DENIED ||
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
105 result == GNOME_KEYRING_RESULT_CANCELLED) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
106 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
107 PURPLE_KEYRING_ERROR_ACCESSDENIED,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
108 _("Access denied."));
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
109 gnomekeyring_cancel_queue();
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
110 } 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
111 result == GNOME_KEYRING_RESULT_IO_ERROR) {
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
112 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
113 PURPLE_KEYRING_ERROR_BACKENDFAIL,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
114 _("Communication with GNOME Keyring failed."));
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
115 } else {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
116 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
117 PURPLE_KEYRING_ERROR_BACKENDFAIL,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
118 _("Unknown error (code: %d)."), result);
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
119 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
120
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
121 if (error == NULL && password == NULL) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
122 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
123 PURPLE_KEYRING_ERROR_BACKENDFAIL,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
124 _("Unknown error (password empty)."));
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
125 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
126
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
127 if (error == NULL) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
128 purple_debug_misc("keyring-gnome",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
129 "Got password for account %s (%s).\n",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
130 purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
131 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
132 } 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
133 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
134 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
135 "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
136 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
137 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
138 }
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
139 } else {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
140 password = NULL;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
141 purple_debug_warning("keyring-gnome", "Failed to read "
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
142 "password for account %s (%s), code: %d.\n",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
143 purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
144 purple_account_get_protocol_id(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
145 result);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
146 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
147
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
148 if (req->cb.read != NULL)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
149 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
150 req->handled = TRUE;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
151
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
152 if (error)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
153 g_error_free(error);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
154
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
155 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
156 }
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
157
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
158 static void
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
159 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
160 {
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
161 gnomekeyring_request *req = _req;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
162 PurpleAccount *account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
163 GError *error = NULL;
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
164 gboolean already_removed = FALSE;
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
165
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
166 g_return_if_fail(req != NULL);
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 current_request = NULL;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
169 account = req->account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
170
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
171 if (result == GNOME_KEYRING_RESULT_OK) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
172 error = NULL;
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
173 } 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
174 req->password == NULL) {
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
175 error = NULL;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
176 already_removed = TRUE;
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
177 } else if (result == GNOME_KEYRING_RESULT_DENIED ||
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
178 result == GNOME_KEYRING_RESULT_CANCELLED) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
179 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
180 PURPLE_KEYRING_ERROR_ACCESSDENIED,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
181 _("Access denied."));
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
182 gnomekeyring_cancel_queue();
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
183 } 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
184 result == GNOME_KEYRING_RESULT_IO_ERROR) {
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
185 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
186 PURPLE_KEYRING_ERROR_BACKENDFAIL,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
187 _("Communication with GNOME Keyring failed."));
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
188 } else {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
189 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
190 PURPLE_KEYRING_ERROR_BACKENDFAIL,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
191 _("Unknown error (code: %d)."), result);
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
192 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
193
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
194 if (already_removed) {
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
195 /* no operation */
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
196 } else if (error == NULL) {
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
197 purple_debug_misc("keyring-gnome",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
198 "Password %s for account %s (%s).\n",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
199 req->password ? "saved" : "removed",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
200 purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
201 purple_account_get_protocol_id(account));
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
202 } else {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
203 purple_debug_warning("keyring-gnome", "Failed updating "
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
204 "password for account %s (%s), code: %d.\n",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
205 purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
206 purple_account_get_protocol_id(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
207 result);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
208 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
209
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
210 if (req->cb.save != NULL)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
211 req->cb.save(account, error, req->cb_data);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
212 req->handled = TRUE;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
213
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
214 if (error)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
215 g_error_free(error);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
216
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
217 gnomekeyring_process_queue();
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
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
220 static void
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
221 gnomekeyring_request_cancel(gpointer _req)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
222 {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
223 gnomekeyring_request *req = _req;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
224 PurpleAccount *account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
225 GError *error;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
226
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
227 g_return_if_fail(req != NULL);
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 if (req->handled) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
230 gnomekeyring_request_free(req);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
231 return;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
232 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
233
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
234 purple_debug_warning("keyring-gnome",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
235 "operation cancelled (%d %s:%s)\n", req->type,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
236 purple_account_get_protocol_id(req->account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
237 purple_account_get_username(req->account));
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
238
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
239 account = req->account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
240 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
241 PURPLE_KEYRING_ERROR_CANCELLED,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
242 _("Operation cancelled."));
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
243 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
244 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
245 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
246 req->cb.save(account, error, req->cb_data);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
247 g_error_free(error);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
248
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
249 gnomekeyring_request_free(req);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
250 gnomekeyring_process_queue();
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
251 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
252
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
253 static void
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
254 gnomekeyring_cancel_queue(void)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
255 {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
256 GList *cancel_list = request_queue;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
257
34139
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34138
diff changeset
258 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
259 return;
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34138
diff changeset
260
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
261 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
262 request_queue = NULL;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
263
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
264 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
265 }
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
266
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
267 static void
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
268 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
269 {
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
270 gnomekeyring_request *req;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
271 PurpleAccount *account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
272 GList *first;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
273
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
274 if (request_queue == NULL)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
275 return;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
276
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
277 if (current_request) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
278 if (purple_debug_is_verbose())
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
279 purple_debug_misc("keyring-gnome", "busy...\n");
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
280 return;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
281 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
282
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
283 first = g_list_first(request_queue);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
284 req = first->data;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
285 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
286 account = req->account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
287
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
288 if (purple_debug_is_verbose()) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
289 purple_debug_misc("keyring-gnome",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
290 "%s password for account %s (%s)\n",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
291 req->type == GNOMEKEYRING_REQUEST_READ ? "reading" :
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
292 (req->password == NULL ? "removing" : "updating"),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
293 purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
294 purple_account_get_protocol_id(account));
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
295 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
296
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
297 if (req->type == GNOMEKEYRING_REQUEST_READ) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
298 current_request = gnome_keyring_find_password(
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
299 GNOME_KEYRING_NETWORK_PASSWORD, gnomekeyring_read_cb,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
300 req, gnomekeyring_request_cancel,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
301 "user", purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
302 "protocol", purple_account_get_protocol_id(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
303 NULL);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
304 } else if (req->type == GNOMEKEYRING_REQUEST_SAVE &&
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
305 req->password != NULL) {
34170
94102637e7c7 Coding style and entry description for GNOME Keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
306 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
307 _("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
308 purple_account_get_username(account));
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
309 current_request = gnome_keyring_store_password(
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
310 GNOME_KEYRING_NETWORK_PASSWORD, GNOME_KEYRING_DEFAULT,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
311 display_name, req->password, gnomekeyring_save_cb, req,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
312 gnomekeyring_request_cancel,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
313 "user", purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
314 "protocol", purple_account_get_protocol_id(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
315 NULL);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
316 g_free(display_name);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
317 } else if (req->type == GNOMEKEYRING_REQUEST_SAVE &&
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
318 req->password == NULL) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
319 current_request = gnome_keyring_delete_password(
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
320 GNOME_KEYRING_NETWORK_PASSWORD, gnomekeyring_save_cb,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
321 req, gnomekeyring_request_cancel,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
322 "user", purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
323 "protocol", purple_account_get_protocol_id(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
324 NULL);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
325 } else {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
326 g_return_if_reached();
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
327 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
328 }
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 static void
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
331 gnomekeyring_read(PurpleAccount *account, PurpleKeyringReadCallback cb,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
332 gpointer data)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
333 {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
334 gnomekeyring_request *req;
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 g_return_if_fail(account != NULL);
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 req = g_new0(gnomekeyring_request, 1);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
339 req->type = GNOMEKEYRING_REQUEST_READ;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
340 req->account = account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
341 req->cb.read = cb;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
342 req->cb_data = data;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
343
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
344 gnomekeyring_enqueue(req);
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
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
347 static void
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
348 gnomekeyring_save(PurpleAccount *account, const gchar *password,
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
349 PurpleKeyringSaveCallback cb, gpointer data)
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
350 {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
351 gnomekeyring_request *req;
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 g_return_if_fail(account != NULL);
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 req = g_new0(gnomekeyring_request, 1);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
356 req->type = GNOMEKEYRING_REQUEST_SAVE;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
357 req->account = account;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
358 req->password = gnome_keyring_memory_strdup(password);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
359 req->cb.save = cb;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
360 req->cb_data = data;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
361
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
362 gnomekeyring_enqueue(req);
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
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
365 static void
34139
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34138
diff changeset
366 gnomekeyring_cancel(void)
34138
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
367 {
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
368 gnomekeyring_cancel_queue();
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
369 if (current_request) {
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
370 gnome_keyring_cancel_request(current_request);
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
371 while (g_main_iteration(FALSE));
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
372 }
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
373 }
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 static void
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
376 gnomekeyring_close(void)
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
377 {
34138
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
378 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
379 }
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
380
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
381 static gboolean
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
382 gnomekeyring_load(PurplePlugin *plugin)
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
383 {
34294
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
384 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
385
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
386 /* 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
387 * termination.
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
388 */
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
389 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
390 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
391 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
392 "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
393 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
394 }
f07214b611a4 Fix a crash in case of Ctrl+C while booting (libgnomekeyring bug)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34281
diff changeset
395 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
396
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
397 if (!gnome_keyring_is_available()) {
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
398 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
399 "disabled\n");
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
400 return FALSE;
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
401 }
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
402
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
403 keyring_handler = purple_keyring_new();
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
404
34281
ad957d0a467a Keyring (and some GTK): fix translation callbacks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34199
diff changeset
405 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
406 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
407 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
408 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
409 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
410 gnomekeyring_cancel);
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
411 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
412
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
413 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
414
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
415 return TRUE;
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
416 }
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
417
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
418 static gboolean
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
419 gnomekeyring_unload(PurplePlugin *plugin)
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
420 {
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
421 if (purple_keyring_get_inuse() == keyring_handler) {
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
422 purple_debug_warning("keyring-gnome",
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
423 "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
424 return FALSE;
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
425 }
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
426
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
427 gnomekeyring_close();
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
428
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33984
diff changeset
429 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
430 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
431 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
432
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
433 return TRUE;
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
434 }
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
435
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
436 PurplePluginInfo plugininfo =
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
437 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
438 PURPLE_PLUGIN_MAGIC, /* magic */
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
439 PURPLE_MAJOR_VERSION, /* major_version */
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
440 PURPLE_MINOR_VERSION, /* minor_version */
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
441 PURPLE_PLUGIN_STANDARD, /* type */
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
442 NULL, /* ui_requirement */
34116
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34098
diff changeset
443 PURPLE_PLUGIN_FLAG_INVISIBLE, /* flags */
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
444 NULL, /* dependencies */
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
445 PURPLE_PRIORITY_DEFAULT, /* priority */
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
446 GNOMEKEYRING_ID, /* id */
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
447 GNOMEKEYRING_NAME, /* name */
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
448 DISPLAY_VERSION, /* version */
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
449 "GNOME Keyring Plugin", /* summary */
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
450 GNOMEKEYRING_DESCRIPTION, /* description */
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
451 GNOMEKEYRING_AUTHOR, /* author */
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
452 PURPLE_WEBSITE, /* homepage */
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
453 gnomekeyring_load, /* load */
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34135
diff changeset
454 gnomekeyring_unload, /* unload */
34135
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
455 NULL, /* destroy */
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
456 NULL, /* ui_info */
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
457 NULL, /* extra_info */
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
458 NULL, /* prefs_info */
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
459 NULL, /* actions */
528b3084b3b3 Initial version of re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
460 NULL, NULL, NULL, NULL /* padding */
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
461 };
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
462
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
463 static void
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
464 init_plugin(PurplePlugin *plugin)
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
465 {
33984
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
466 }
7459475b1495 Added the gnome keyring plugin, and finally got makefiles to work.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
467
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33998
diff changeset
468 PURPLE_INIT_PLUGIN(gnome_keyring, init_plugin, plugininfo)

mercurial