libpurple/keyring.c

Sun, 28 Apr 2013 02:26:38 +0200

author
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
date
Sun, 28 Apr 2013 02:26:38 +0200
branch
soc.2008.masterpassword
changeset 34159
c47b85d03439
parent 34158
166870f3adf8
child 34160
8f0843214194
permissions
-rw-r--r--

keyring.c refactoring - order up function implementations

33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
1 /**
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
2 * @file keyring.c Keyring API
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
3 * @ingroup core
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
4 */
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
5
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
6 /* purple
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
7 *
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
8 * Purple is the legal property of its developers, whose names are too numerous
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
10 * source distribution.
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
11 *
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
15 * (at your option) any later version.
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
16 *
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
20 * GNU General Public License for more details.
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
21 *
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
23 * along with this program ; if not, write to the Free Software
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
25 */
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
26
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
27 #include <glib.h>
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
28 #include <string.h>
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
29 #include "account.h"
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
30 #include "keyring.h"
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
31 #include "signals.h"
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
32 #include "core.h"
33982
58a0de711782 Added support for the PURPLE_PLUGIN_FLAG_AUTOLOAD flag, corrected a few bugs and crashed. The compatibility plugin is automatically loaded at startup, and works nicely in compatibility mode (read_sync, write_sync, import, export). Also, I played unsuccessfully with makefiles, so i moved the keyring up one directory. I've finally gotten to the point where I run "make && sudo make install" every now and then.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33981
diff changeset
33 #include "debug.h"
33998
5fcfc69be362 Added support for master password in pidgin's pref interface.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33997
diff changeset
34 #include "internal.h"
34110
bda1c52322fe Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34066
diff changeset
35 #include "dbus-maybe.h"
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
36
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
37 struct _PurpleKeyring
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
38 {
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
39 char *name;
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
40 char *id;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
41 PurpleKeyringRead read_password;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
42 PurpleKeyringSave save_password;
34138
2bda8642afa3 Early cancelling password requests before quitting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34137
diff changeset
43 PurpleKeyringCancelRequests cancel_requests;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
44 PurpleKeyringClose close_keyring;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
45 PurpleKeyringChangeMaster change_master;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
46 PurpleKeyringImportPassword import_password;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
47 PurpleKeyringExportPassword export_password;
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
48 };
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
49
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
50 typedef struct
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
51 {
34137
d53bf5bde2c0 Fix use-after-free in error reporting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
52 GError *error;
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
53 PurpleKeyringSetInUseCallback cb;
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
54 gpointer cb_data;
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
55 PurpleKeyring *new;
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
56 PurpleKeyring *old;
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
57
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
58 /**
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
59 * We are done when finished is positive and read_outstanding is zero.
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
60 */
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
61 gboolean finished;
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
62 int read_outstanding;
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
63
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
64 gboolean abort;
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
65 gboolean force;
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
66 gboolean succeeded;
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
67 } PurpleKeyringChangeTracker;
33991
0eb45874d73a Made more calls asynch, enhanced error checking and reporting.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33987
diff changeset
68
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
69 typedef void (*PurpleKeyringDropCallback)(gpointer data);
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
70
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
71 typedef struct
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
72 {
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
73 PurpleKeyringDropCallback cb;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
74 gpointer cb_data;
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
75
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
76 gboolean finished;
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
77 int drop_outstanding;
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
78 } PurpleKeyringDropTracker;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
79
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
80 typedef struct
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
81 {
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
82 PurpleKeyringSaveCallback cb;
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
83 gpointer cb_data;
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
84 } PurpleKeyringSetPasswordData;
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
85
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
86 typedef struct
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
87 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
88 gchar *keyring_id;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
89 gchar *mode;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
90 gchar *data;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
91 } PurpleKeyringFailedImport;
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
92
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
93 static void
34137
d53bf5bde2c0 Fix use-after-free in error reporting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
94 purple_keyring_change_tracker_free(PurpleKeyringChangeTracker *tracker)
d53bf5bde2c0 Fix use-after-free in error reporting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
95 {
d53bf5bde2c0 Fix use-after-free in error reporting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
96 if (tracker->error)
d53bf5bde2c0 Fix use-after-free in error reporting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
97 g_error_free(tracker->error);
d53bf5bde2c0 Fix use-after-free in error reporting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
98 g_free(tracker);
d53bf5bde2c0 Fix use-after-free in error reporting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
99 }
d53bf5bde2c0 Fix use-after-free in error reporting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
100
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
101 static void
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
102 purple_keyring_failed_import_free(PurpleKeyringFailedImport *import)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
103 {
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
104 g_return_if_fail(import != NULL);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
105
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
106 g_free(import->keyring_id);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
107 g_free(import->mode);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
108 g_free(import->data);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
109 g_free(import);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
110 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
111
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
112 static void
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
113 purple_keyring_close(PurpleKeyring *keyring);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
114
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
115 static GList *purple_keyring_keyrings; /* list of available keyrings */
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
116 static PurpleKeyring *purple_keyring_inuse; /* keyring being used */
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
117 static char *purple_keyring_to_use;
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
118 static guint purple_keyring_pref_cb_id;
34116
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
119 static GList *purple_keyring_loaded_plugins = NULL;
34139
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34138
diff changeset
120 static PurpleKeyringChangeTracker *current_change_tracker = NULL;
34140
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
121 static gboolean purple_keyring_is_quitting = FALSE;
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
122 static GHashTable *purple_keyring_failed_imports = NULL;
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
123
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
124
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
125 /**************************************************************************/
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
126 /* Setting used keyrings */
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
127 /**************************************************************************/
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
128
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
129 PurpleKeyring *
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
130 purple_keyring_find_keyring_by_id(const char *id)
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
131 {
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
132 GList *l;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
133 PurpleKeyring *keyring;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
134 const char *curr_id;
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
135
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
136 for (l = purple_keyring_keyrings; l != NULL; l = l->next) {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
137 keyring = l->data;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
138 curr_id = purple_keyring_get_id(keyring);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
139
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
140 if (g_strcmp0(id, curr_id) == 0)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
141 return keyring;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
142 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
143
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
144 return NULL;
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
145 }
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
146
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
147 static void
34032
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
148 purple_keyring_pref_cb(const char *pref,
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
149 PurplePrefType type,
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
150 gconstpointer id,
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
151 gpointer data)
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
152 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
153 PurpleKeyring *new;
34032
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
154
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
155 g_return_if_fail(g_strcmp0(pref, "/purple/keyring/active") == 0);
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
156 g_return_if_fail(type == PURPLE_PREF_STRING);
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
157 g_return_if_fail(id != NULL);
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
158
34042
c79b32c07390 Remove duplicate function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34041
diff changeset
159 new = purple_keyring_find_keyring_by_id(id);
34032
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
160 g_return_if_fail(new != NULL);
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
161
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
162 purple_keyring_set_inuse(new, FALSE, NULL, data);
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
163 }
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
164
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
165 PurpleKeyring *
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
166 purple_keyring_get_inuse(void)
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
167 {
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
168 return purple_keyring_inuse;
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
169 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
170
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
171 static void
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
172 purple_keyring_drop_passwords_cb(PurpleAccount *account, GError *error,
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
173 gpointer _tracker)
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
174 {
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
175 PurpleKeyringDropTracker *tracker = _tracker;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
176
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
177 tracker->drop_outstanding--;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
178
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
179 if (!tracker->finished || tracker->drop_outstanding > 0)
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
180 return;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
181
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
182 if (tracker->cb)
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
183 tracker->cb(tracker->cb_data);
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
184 g_free(tracker);
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
185 }
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
186
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
187 static void
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
188 purple_keyring_drop_passwords(PurpleKeyring *keyring,
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
189 PurpleKeyringDropCallback cb, gpointer data)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
190 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
191 GList *cur;
34153
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
192 PurpleKeyringSave save_cb;
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
193 PurpleKeyringDropTracker *tracker;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
194
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
195 g_return_if_fail(keyring != NULL);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
196
34153
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
197 save_cb = purple_keyring_get_save_password(keyring);
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
198 g_return_if_fail(save_cb != NULL);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
199
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
200 tracker = g_new0(PurpleKeyringDropTracker, 1);
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
201 tracker->cb = cb;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
202 tracker->cb_data = data;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
203
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
204 for (cur = purple_accounts_get_all(); cur != NULL; cur = cur->next) {
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
205 tracker->drop_outstanding++;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
206 if (cur->next == NULL)
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
207 tracker->finished = TRUE;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
208
34153
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
209 save_cb(cur->data, NULL, purple_keyring_drop_passwords_cb,
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
210 tracker);
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
211 }
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
212 }
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
213
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
214 static void
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
215 purple_keyring_set_inuse_drop_cb(gpointer _tracker)
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
216 {
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
217 PurpleKeyringChangeTracker *tracker = _tracker;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
218
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
219 g_return_if_fail(tracker != NULL);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
220
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
221 if (tracker->succeeded) {
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
222 purple_keyring_close(tracker->old);
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
223
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
224 purple_debug_info("keyring", "Successfully changed keyring.\n");
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
225
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
226 purple_keyring_inuse = tracker->new;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
227 current_change_tracker = NULL;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
228
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
229 if (tracker->cb != NULL)
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
230 tracker->cb(tracker->new, NULL, tracker->cb_data);
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
231 } else {
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
232 purple_debug_error("keyring",
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
233 "Failed to change keyring, aborting.\n");
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
234
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
235 purple_keyring_close(tracker->new);
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
236
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
237 purple_prefs_disconnect_callback(purple_keyring_pref_cb_id);
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
238 purple_prefs_set_string("/purple/keyring/active",
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
239 purple_keyring_get_id(tracker->old));
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
240 purple_keyring_pref_cb_id = purple_prefs_connect_callback(NULL,
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
241 "/purple/keyring/active", purple_keyring_pref_cb, NULL);
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
242
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
243 current_change_tracker = NULL;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
244
34143
a57368227f78 Get rid of redundant parameters
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34142
diff changeset
245 if (tracker->error == NULL) {
a57368227f78 Get rid of redundant parameters
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34142
diff changeset
246 tracker->error = g_error_new(PURPLE_KEYRING_ERROR,
a57368227f78 Get rid of redundant parameters
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34142
diff changeset
247 PURPLE_KEYRING_ERROR_UNKNOWN,
a57368227f78 Get rid of redundant parameters
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34142
diff changeset
248 "Unknown error has occured");
a57368227f78 Get rid of redundant parameters
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34142
diff changeset
249 }
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
250 if (tracker->cb != NULL)
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
251 tracker->cb(tracker->old, tracker->error, tracker->cb_data);
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
252 }
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
253
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
254 purple_keyring_change_tracker_free(tracker);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
255 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
256
33981
8c8fe2e5bbcd dded import/export in account.c, new version of internalkeyring.c, and added stuff to makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33978
diff changeset
257 static void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
258 purple_keyring_set_inuse_check_error_cb(PurpleAccount *account,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
259 GError *error,
33970
4b6a0141a242 Fixed syntax and types error. keyring.c and keyring.h will now compile, but will issue warnings with -Wall
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33969
diff changeset
260 gpointer data)
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
261 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
262 const char *name;
34041
75204e58b8ca Fix const-ness of strings, and silly strdups.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34039
diff changeset
263 PurpleKeyringChangeTracker *tracker;
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
264
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
265 tracker = (PurpleKeyringChangeTracker *)data;
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
266
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
267 tracker->read_outstanding--;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
268
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
269 name = purple_account_get_username(account);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
270
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
271 if ((error != NULL) && (error->domain == PURPLE_KEYRING_ERROR)) {
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
272 switch(error->code) {
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
273 case PURPLE_KEYRING_ERROR_NOPASSWORD:
34129
52b91b4b8314 Proper error handling when doing a password migration, fixes reverting it.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34127
diff changeset
274 if (purple_debug_is_verbose()) {
52b91b4b8314 Proper error handling when doing a password migration, fixes reverting it.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34127
diff changeset
275 purple_debug_misc("keyring",
52b91b4b8314 Proper error handling when doing a password migration, fixes reverting it.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34127
diff changeset
276 "No password found while changing keyring for account %s: %s.\n",
52b91b4b8314 Proper error handling when doing a password migration, fixes reverting it.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34127
diff changeset
277 name, error->message);
52b91b4b8314 Proper error handling when doing a password migration, fixes reverting it.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34127
diff changeset
278 }
33970
4b6a0141a242 Fixed syntax and types error. keyring.c and keyring.h will now compile, but will issue warnings with -Wall
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33969
diff changeset
279 break;
4b6a0141a242 Fixed syntax and types error. keyring.c and keyring.h will now compile, but will issue warnings with -Wall
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33969
diff changeset
280
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
281 case PURPLE_KEYRING_ERROR_CANCELLED:
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
282 purple_debug_info("keyring",
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
283 "Operation cancelled while changing keyring for account %s: %s.\n",
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
284 name, error->message);
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
285 tracker->abort = TRUE;
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
286 if (tracker->error != NULL)
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
287 g_error_free(tracker->error);
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
288 tracker->error = g_error_copy(error);
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
289 break;
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
290
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
291 case PURPLE_KEYRING_ERROR_BACKENDFAIL:
34129
52b91b4b8314 Proper error handling when doing a password migration, fixes reverting it.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34127
diff changeset
292 purple_debug_error("keyring",
34127
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
293 "Failed to communicate with backend while changing keyring for account %s: %s. Aborting changes.\n",
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
294 name, error->message);
33981
8c8fe2e5bbcd dded import/export in account.c, new version of internalkeyring.c, and added stuff to makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33978
diff changeset
295 tracker->abort = TRUE;
34137
d53bf5bde2c0 Fix use-after-free in error reporting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
296 if (tracker->error != NULL)
d53bf5bde2c0 Fix use-after-free in error reporting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
297 g_error_free(tracker->error);
d53bf5bde2c0 Fix use-after-free in error reporting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
298 tracker->error = g_error_copy(error);
33970
4b6a0141a242 Fixed syntax and types error. keyring.c and keyring.h will now compile, but will issue warnings with -Wall
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33969
diff changeset
299 break;
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
300
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
301 default:
34129
52b91b4b8314 Proper error handling when doing a password migration, fixes reverting it.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34127
diff changeset
302 purple_debug_error("keyring",
52b91b4b8314 Proper error handling when doing a password migration, fixes reverting it.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34127
diff changeset
303 "Unknown error while changing keyring for account %s: %s. Aborting changes.\n",
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
304 name, error->message);
34129
52b91b4b8314 Proper error handling when doing a password migration, fixes reverting it.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34127
diff changeset
305 tracker->abort = TRUE;
34137
d53bf5bde2c0 Fix use-after-free in error reporting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
306 if (tracker->error == NULL)
d53bf5bde2c0 Fix use-after-free in error reporting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
307 tracker->error = g_error_copy(error);
33970
4b6a0141a242 Fixed syntax and types error. keyring.c and keyring.h will now compile, but will issue warnings with -Wall
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33969
diff changeset
308 break;
4b6a0141a242 Fixed syntax and types error. keyring.c and keyring.h will now compile, but will issue warnings with -Wall
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33969
diff changeset
309 }
4b6a0141a242 Fixed syntax and types error. keyring.c and keyring.h will now compile, but will issue warnings with -Wall
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33969
diff changeset
310 }
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
311
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
312 /**
34056
07643afffcdc Replace one hack with another. Maybe we want to think about something
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34055
diff changeset
313 * This is kind of hackish. It will schedule an account save.
07643afffcdc Replace one hack with another. Maybe we want to think about something
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34055
diff changeset
314 *
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
315 * Another way to do this would be to expose the
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
316 * schedule_accounts_save() function, but other such functions
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
317 * are not exposed. So these was done for consistency.
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
318 */
34056
07643afffcdc Replace one hack with another. Maybe we want to think about something
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34055
diff changeset
319 purple_account_set_remember_password(account,
07643afffcdc Replace one hack with another. Maybe we want to think about something
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34055
diff changeset
320 purple_account_get_remember_password(account));
34141
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
321
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
322 /* if this was the last one */
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
323 if (tracker->finished && tracker->read_outstanding == 0) {
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
324 if (tracker->abort && !tracker->force) {
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
325 tracker->succeeded = FALSE;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
326 purple_keyring_drop_passwords(tracker->new, purple_keyring_set_inuse_drop_cb, tracker);
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
327 } else {
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
328 tracker->succeeded = TRUE;
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
329 purple_keyring_drop_passwords(tracker->old, purple_keyring_set_inuse_drop_cb, tracker);
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
330 }
9d90967f2485 Don't close a keyring before dropping all passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34140
diff changeset
331 }
33970
4b6a0141a242 Fixed syntax and types error. keyring.c and keyring.h will now compile, but will issue warnings with -Wall
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33969
diff changeset
332 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
333
33981
8c8fe2e5bbcd dded import/export in account.c, new version of internalkeyring.c, and added stuff to makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33978
diff changeset
334 static void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
335 purple_keyring_set_inuse_got_pw_cb(PurpleAccount *account,
34046
b9329fa36c70 One more missing const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34042
diff changeset
336 const gchar *password,
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
337 GError *error,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
338 gpointer data)
33970
4b6a0141a242 Fixed syntax and types error. keyring.c and keyring.h will now compile, but will issue warnings with -Wall
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33969
diff changeset
339 {
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
340 PurpleKeyring *new;
34153
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
341 PurpleKeyringSave save_cb;
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
342 PurpleKeyringChangeTracker *tracker;
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
343
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
344 tracker = (PurpleKeyringChangeTracker *)data;
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
345 new = tracker->new;
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
346
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
347 g_return_if_fail(tracker != NULL);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
348 if (tracker->abort) {
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
349 purple_keyring_set_inuse_check_error_cb(account, NULL, data);
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
350 return;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
351 }
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
352
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
353 if (error != NULL) {
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
354 if (error->code == PURPLE_KEYRING_ERROR_NOPASSWORD ||
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
355 tracker->force == TRUE) {
34129
52b91b4b8314 Proper error handling when doing a password migration, fixes reverting it.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34127
diff changeset
356 /* don't save password, and ignore it */
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
357 } else {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
358 /* fatal error, abort all */
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
359 tracker->abort = TRUE;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
360 }
34129
52b91b4b8314 Proper error handling when doing a password migration, fixes reverting it.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34127
diff changeset
361 purple_keyring_set_inuse_check_error_cb(account, error, data);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
362 } else {
34153
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
363 save_cb = purple_keyring_get_save_password(new);
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
364 g_return_if_fail(save_cb != NULL);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
365
34153
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
366 save_cb(account, password, purple_keyring_set_inuse_check_error_cb,
34142
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
367 tracker);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
368 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
369 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
370
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
371 void
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
372 purple_keyring_set_inuse(PurpleKeyring *newkeyring,
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
373 gboolean force,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
374 PurpleKeyringSetInUseCallback cb,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
375 gpointer data)
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
376 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
377 GList *cur;
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
378 PurpleKeyring *oldkeyring;
34153
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
379 PurpleKeyringRead read_cb = NULL;
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
380 PurpleKeyringChangeTracker *tracker;
33981
8c8fe2e5bbcd dded import/export in account.c, new version of internalkeyring.c, and added stuff to makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33978
diff changeset
381
34131
e56d3dd7b0e4 Track migrating passwords in prefs window
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
382 oldkeyring = purple_keyring_get_inuse();
e56d3dd7b0e4 Track migrating passwords in prefs window
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
383
34139
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34138
diff changeset
384 if (current_change_tracker != NULL) {
34132
ecbcce03ecbc Don't let two concurrent password migrations being run
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34131
diff changeset
385 GError *error;
ecbcce03ecbc Don't let two concurrent password migrations being run
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34131
diff changeset
386 purple_debug_error("keyring", "There is password migration "
ecbcce03ecbc Don't let two concurrent password migrations being run
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34131
diff changeset
387 "session already running.\n");
ecbcce03ecbc Don't let two concurrent password migrations being run
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34131
diff changeset
388 if (cb == NULL)
ecbcce03ecbc Don't let two concurrent password migrations being run
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34131
diff changeset
389 return;
ecbcce03ecbc Don't let two concurrent password migrations being run
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34131
diff changeset
390 error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
391 PURPLE_KEYRING_ERROR_INTERNAL,
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
392 "There is a password migration session already running");
34143
a57368227f78 Get rid of redundant parameters
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34142
diff changeset
393 cb(oldkeyring, error, data);
34132
ecbcce03ecbc Don't let two concurrent password migrations being run
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34131
diff changeset
394 g_error_free(error);
ecbcce03ecbc Don't let two concurrent password migrations being run
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34131
diff changeset
395 return;
ecbcce03ecbc Don't let two concurrent password migrations being run
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34131
diff changeset
396 }
ecbcce03ecbc Don't let two concurrent password migrations being run
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34131
diff changeset
397
34131
e56d3dd7b0e4 Track migrating passwords in prefs window
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
398 if (oldkeyring == newkeyring) {
34145
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34143
diff changeset
399 if (purple_debug_is_verbose()) {
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34143
diff changeset
400 purple_debug_misc("keyring",
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34143
diff changeset
401 "Old and new keyring are the same: %s.\n",
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34143
diff changeset
402 (newkeyring != NULL) ?
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34143
diff changeset
403 newkeyring->id : "(null)");
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34143
diff changeset
404 }
34131
e56d3dd7b0e4 Track migrating passwords in prefs window
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
405 if (cb != NULL)
34143
a57368227f78 Get rid of redundant parameters
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34142
diff changeset
406 cb(newkeyring, NULL, data);
34131
e56d3dd7b0e4 Track migrating passwords in prefs window
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
407 return;
e56d3dd7b0e4 Track migrating passwords in prefs window
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
408 }
e56d3dd7b0e4 Track migrating passwords in prefs window
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34129
diff changeset
409
34127
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
410 purple_debug_info("keyring", "Attempting to set new keyring: %s.\n",
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
411 (newkeyring != NULL) ? newkeyring->id : "(null)");
33982
58a0de711782 Added support for the PURPLE_PLUGIN_FLAG_AUTOLOAD flag, corrected a few bugs and crashed. The compatibility plugin is automatically loaded at startup, and works nicely in compatibility mode (read_sync, write_sync, import, export). Also, I played unsuccessfully with makefiles, so i moved the keyring up one directory. I've finally gotten to the point where I run "make && sudo make install" every now and then.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33981
diff changeset
412
33983
317cd0a252c2 Fixed a bunch of bugs/errors, worked on making calls async, on configuration UI, and on Makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33982
diff changeset
413 if (oldkeyring != NULL) {
34153
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
414 read_cb = purple_keyring_get_read_password(oldkeyring);
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
415 g_return_if_fail(read_cb != NULL);
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
416
34142
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
417 purple_debug_misc("keyring", "Starting migration from: %s.\n",
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
418 oldkeyring->id);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
419
34142
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
420 tracker = g_new(PurpleKeyringChangeTracker, 1);
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
421 current_change_tracker = tracker;
34126
a479dca0f05b Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34125
diff changeset
422
34142
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
423 tracker->cb = cb;
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
424 tracker->cb_data = data;
34142
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
425 tracker->new = newkeyring;
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
426 tracker->old = oldkeyring;
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
427 tracker->read_outstanding = 0;
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
428 tracker->finished = FALSE;
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
429 tracker->abort = FALSE;
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
430 tracker->force = force;
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
431 tracker->error = NULL;
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
432
34142
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
433 for (cur = purple_accounts_get_all(); cur != NULL;
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
434 cur = cur->next) {
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
435
34142
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
436 if (tracker->abort) {
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
437 tracker->finished = TRUE;
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
438 break;
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
439 }
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
440 tracker->read_outstanding++;
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
441
34142
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
442 if (cur->next == NULL)
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
443 tracker->finished = TRUE;
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
444
34153
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
445 read_cb(cur->data, purple_keyring_set_inuse_got_pw_cb, tracker);
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
446 }
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
447 } else { /* no keyring was set before. */
34127
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
448 if (purple_debug_is_verbose()) {
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
449 purple_debug_misc("keyring", "Setting keyring for the "
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
450 "first time: %s.\n", newkeyring->id);
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
451 }
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
452
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
453 purple_keyring_inuse = newkeyring;
34139
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34138
diff changeset
454 g_assert(current_change_tracker == NULL);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
455 if (cb != NULL)
34143
a57368227f78 Get rid of redundant parameters
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34142
diff changeset
456 cb(newkeyring, NULL, data);
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
457 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
458 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
459
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
460 void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
461 purple_keyring_register(PurpleKeyring *keyring)
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
462 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
463 const char *keyring_id;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
464
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
465 g_return_if_fail(keyring != NULL);
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
466
33983
317cd0a252c2 Fixed a bunch of bugs/errors, worked on making calls async, on configuration UI, and on Makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33982
diff changeset
467 keyring_id = purple_keyring_get_id(keyring);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
468
34142
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
469 purple_debug_info("keyring", "Registering keyring: %s.\n",
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
470 keyring->id ? keyring->id : "(null)");
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
471
34142
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
472 if (purple_keyring_get_id(keyring) == NULL ||
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
473 purple_keyring_get_name(keyring) == NULL ||
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
474 purple_keyring_get_read_password(keyring) == NULL ||
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
475 purple_keyring_get_save_password(keyring) == NULL) {
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
476 purple_debug_error("keyring", "Invalid keyring %s, some "
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
477 "required fields are missing.\n",
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
478 keyring->id ? keyring->id : "(null)");
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
479 return;
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
480 }
33983
317cd0a252c2 Fixed a bunch of bugs/errors, worked on making calls async, on configuration UI, and on Makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33982
diff changeset
481
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
482 /* If this is the configured keyring, use it. */
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
483 if (purple_keyring_inuse == NULL &&
33982
58a0de711782 Added support for the PURPLE_PLUGIN_FLAG_AUTOLOAD flag, corrected a few bugs and crashed. The compatibility plugin is automatically loaded at startup, and works nicely in compatibility mode (read_sync, write_sync, import, export). Also, I played unsuccessfully with makefiles, so i moved the keyring up one directory. I've finally gotten to the point where I run "make && sudo make install" every now and then.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33981
diff changeset
484 g_strcmp0(keyring_id, purple_keyring_to_use) == 0) {
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
485
33983
317cd0a252c2 Fixed a bunch of bugs/errors, worked on making calls async, on configuration UI, and on Makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33982
diff changeset
486 purple_debug_info("keyring", "Keyring %s matches keyring to use, using it.\n",
317cd0a252c2 Fixed a bunch of bugs/errors, worked on making calls async, on configuration UI, and on Makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33982
diff changeset
487 keyring->id);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
488 purple_keyring_set_inuse(keyring, TRUE, NULL, NULL);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
489
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
490 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
491
34110
bda1c52322fe Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34066
diff changeset
492 PURPLE_DBUS_REGISTER_POINTER(keyring, PurpleKeyring);
34127
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
493 purple_signal_emit(purple_keyring_get_handle(), "keyring-register",
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
494 keyring_id, keyring);
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
495 if (purple_debug_is_verbose()) {
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
496 purple_debug_info("keyring", "Registered keyring: %s.\n",
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
497 keyring_id);
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
498 }
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
499
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
500 purple_keyring_keyrings = g_list_prepend(purple_keyring_keyrings,
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
501 keyring);
33976
ff88d1340abe Cleaned up keyring.h, updating it to the latest API ideas. Minor changes in other files. Also wrote doxygen documentation for most of the functions in keyring.h.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33973
diff changeset
502 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
503
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
504 void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
505 purple_keyring_unregister(PurpleKeyring *keyring)
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
506 {
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
507 PurpleKeyring *inuse;
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
508 PurpleKeyring *fallback;
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
509 const char *keyring_id;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
510
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
511 g_return_if_fail(keyring != NULL);
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
512
34127
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
513 purple_debug_info("keyring", "Unregistering keyring: %s.\n",
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
514 purple_keyring_get_id(keyring));
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
515
33983
317cd0a252c2 Fixed a bunch of bugs/errors, worked on making calls async, on configuration UI, and on Makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33982
diff changeset
516 keyring_id = purple_keyring_get_id(keyring);
34127
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
517 purple_signal_emit(purple_keyring_get_handle(), "keyring-unregister",
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
518 keyring_id, keyring);
34110
bda1c52322fe Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34066
diff changeset
519 PURPLE_DBUS_UNREGISTER_POINTER(keyring);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
520
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
521 inuse = purple_keyring_get_inuse();
34036
bf17ffca901d Give this a better name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34034
diff changeset
522 fallback = purple_keyring_find_keyring_by_id(PURPLE_DEFAULT_KEYRING);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
523
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
524 if (inuse == keyring) {
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
525 if (inuse != fallback) {
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
526 purple_keyring_set_inuse(fallback, TRUE, NULL, NULL);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
527
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
528 } else {
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
529 fallback = NULL;
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
530 purple_keyring_set_inuse(NULL, TRUE, NULL, NULL);
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
531 }
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
532 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
533
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
534 purple_keyring_keyrings = g_list_remove(purple_keyring_keyrings,
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
535 keyring);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
536 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
537
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
538 GList *
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
539 purple_keyring_get_options(void)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
540 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
541 const GList *keyrings;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
542 PurpleKeyring *keyring;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
543 GList *list = NULL;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
544 static char currentDisabledName[40];
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
545
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
546 if (purple_keyring_get_inuse() == NULL && purple_keyring_to_use != NULL
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
547 && purple_keyring_to_use[0] != '\0') {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
548 g_snprintf(currentDisabledName, sizeof(currentDisabledName),
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
549 _("%s (disabled)"), purple_keyring_to_use);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
550 list = g_list_append(list, currentDisabledName);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
551 list = g_list_append(list, purple_keyring_to_use);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
552 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
553
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
554 for (keyrings = purple_keyring_keyrings; keyrings != NULL;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
555 keyrings = keyrings->next) {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
556
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
557 keyring = keyrings->data;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
558 list = g_list_append(list, keyring->name);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
559 list = g_list_append(list, keyring->id);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
560 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
561
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
562 return list;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
563 }
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
564
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
565
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
566 /**************************************************************************/
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
567 /* Keyring plugin wrappers */
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
568 /**************************************************************************/
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
569
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
570 static void
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
571 purple_keyring_close(PurpleKeyring *keyring)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
572 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
573 PurpleKeyringClose close_cb;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
574
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
575 g_return_if_fail(keyring != NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
576
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
577 close_cb = purple_keyring_get_close_keyring(keyring);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
578
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
579 if (close_cb != NULL)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
580 close_cb();
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
581 }
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
582
33981
8c8fe2e5bbcd dded import/export in account.c, new version of internalkeyring.c, and added stuff to makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33978
diff changeset
583 gboolean
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
584 purple_keyring_import_password(PurpleAccount *account,
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
585 const char *keyring_id,
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
586 const char *mode,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
587 const char *data,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
588 GError **error)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
589 {
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
590 PurpleKeyring *inuse;
33971
96eff57a4349 Fixed warnings
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33970
diff changeset
591 PurpleKeyringImportPassword import;
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
592 const char *realid;
33971
96eff57a4349 Fixed warnings
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33970
diff changeset
593
34127
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
594 purple_debug_misc("keyring", "Importing password for account %s (%s) to keyring %s.\n",
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
595 purple_account_get_username(account),
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
596 purple_account_get_protocol_id(account),
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
597 keyring_id);
33982
58a0de711782 Added support for the PURPLE_PLUGIN_FLAG_AUTOLOAD flag, corrected a few bugs and crashed. The compatibility plugin is automatically loaded at startup, and works nicely in compatibility mode (read_sync, write_sync, import, export). Also, I played unsuccessfully with makefiles, so i moved the keyring up one directory. I've finally gotten to the point where I run "make && sudo make install" every now and then.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33981
diff changeset
598
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
599 inuse = purple_keyring_get_inuse();
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
600
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
601 if (inuse == NULL) {
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
602 PurpleKeyringFailedImport *import;
34125
34c3dbf12e95 Fix some memleaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34123
diff changeset
603 if (error != NULL) {
34c3dbf12e95 Fix some memleaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34123
diff changeset
604 *error = g_error_new(PURPLE_KEYRING_ERROR,
34c3dbf12e95 Fix some memleaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34123
diff changeset
605 PURPLE_KEYRING_ERROR_NOKEYRING,
34c3dbf12e95 Fix some memleaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34123
diff changeset
606 "No keyring configured, cannot import password "
34c3dbf12e95 Fix some memleaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34123
diff changeset
607 "info");
34c3dbf12e95 Fix some memleaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34123
diff changeset
608 }
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
609 purple_debug_warning("Keyring",
33983
317cd0a252c2 Fixed a bunch of bugs/errors, worked on making calls async, on configuration UI, and on Makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33982
diff changeset
610 "No keyring configured, cannot import password info for account %s (%s).\n",
317cd0a252c2 Fixed a bunch of bugs/errors, worked on making calls async, on configuration UI, and on Makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33982
diff changeset
611 purple_account_get_username(account), purple_account_get_protocol_id(account));
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
612
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
613 import = g_new0(PurpleKeyringFailedImport, 1);
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
614 import->keyring_id = g_strdup(keyring_id);
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
615 import->mode = g_strdup(mode);
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
616 import->data = g_strdup(data);
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
617 g_hash_table_insert(purple_keyring_failed_imports, account, import);
33981
8c8fe2e5bbcd dded import/export in account.c, new version of internalkeyring.c, and added stuff to makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33978
diff changeset
618 return FALSE;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
619 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
620
33983
317cd0a252c2 Fixed a bunch of bugs/errors, worked on making calls async, on configuration UI, and on Makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33982
diff changeset
621 realid = purple_keyring_get_id(inuse);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
622 /*
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
623 * we want to be sure that either :
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
624 * - there is a keyring_id specified and it matches the one configured
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
625 * - or the configured keyring is the fallback, compatible one.
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
626 */
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
627 if ((keyring_id != NULL && g_strcmp0(realid, keyring_id) != 0) ||
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
628 (keyring_id == NULL && g_strcmp0(PURPLE_DEFAULT_KEYRING, realid))) {
34125
34c3dbf12e95 Fix some memleaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34123
diff changeset
629 if (error != NULL) {
34c3dbf12e95 Fix some memleaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34123
diff changeset
630 *error = g_error_new(PURPLE_KEYRING_ERROR,
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
631 PURPLE_KEYRING_ERROR_INTERNAL,
34125
34c3dbf12e95 Fix some memleaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34123
diff changeset
632 "Specified keyring id does not match the "
34c3dbf12e95 Fix some memleaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34123
diff changeset
633 "configured one.");
34c3dbf12e95 Fix some memleaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34123
diff changeset
634 }
33983
317cd0a252c2 Fixed a bunch of bugs/errors, worked on making calls async, on configuration UI, and on Makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33982
diff changeset
635 purple_debug_info("keyring",
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
636 "Specified keyring id does not match the configured one (%s vs. %s). Data will be lost.\n",
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
637 keyring_id, realid);
33981
8c8fe2e5bbcd dded import/export in account.c, new version of internalkeyring.c, and added stuff to makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33978
diff changeset
638 return FALSE;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
639 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
640
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
641 import = purple_keyring_get_import_password(inuse);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
642 if (import == NULL) {
34134
fda68dc6481c Don't require implementing import/export of password
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34133
diff changeset
643 if (purple_debug_is_verbose()) {
fda68dc6481c Don't require implementing import/export of password
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34133
diff changeset
644 purple_debug_misc("Keyring", "Configured keyring "
fda68dc6481c Don't require implementing import/export of password
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34133
diff changeset
645 "cannot import password info. This might be "
fda68dc6481c Don't require implementing import/export of password
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34133
diff changeset
646 "normal.\n");
34125
34c3dbf12e95 Fix some memleaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34123
diff changeset
647 }
34134
fda68dc6481c Don't require implementing import/export of password
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34133
diff changeset
648 return TRUE;
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
649 }
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
650
33981
8c8fe2e5bbcd dded import/export in account.c, new version of internalkeyring.c, and added stuff to makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33978
diff changeset
651 return import(account, mode, data, error);
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
652 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
653
33981
8c8fe2e5bbcd dded import/export in account.c, new version of internalkeyring.c, and added stuff to makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33978
diff changeset
654 gboolean
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
655 purple_keyring_export_password(PurpleAccount *account,
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
656 const char **keyring_id,
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
657 const char **mode,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
658 char **data,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
659 GError **error,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
660 GDestroyNotify *destroy)
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
661 {
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
662 PurpleKeyring *inuse;
33971
96eff57a4349 Fixed warnings
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33970
diff changeset
663 PurpleKeyringExportPassword export;
96eff57a4349 Fixed warnings
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33970
diff changeset
664
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
665 inuse = purple_keyring_get_inuse();
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
666
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
667 if (inuse == NULL) {
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
668 PurpleKeyringFailedImport *import = g_hash_table_lookup(
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
669 purple_keyring_failed_imports, account);
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
670
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
671 if (import == NULL) {
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
672 *error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOKEYRING,
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
673 "No keyring configured, cannot export password info");
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
674 purple_debug_warning("keyring",
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
675 "No keyring configured, cannot export password info.\n");
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
676 return FALSE;
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
677 } else {
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
678 purple_debug_info("keyring", "No keyring configured, getting fallback export data for %s (%s).\n",
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
679 purple_account_get_username(account),
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
680 purple_account_get_protocol_id(account));
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
681
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
682 *keyring_id = import->keyring_id;
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
683 *mode = import->mode;
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
684 *data = g_strdup(import->data);
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
685 *destroy = g_free;
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
686 return TRUE;
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
687 }
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
688 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
689
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
690 *keyring_id = purple_keyring_get_id(inuse);
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
691
34127
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
692 if (purple_debug_is_verbose()) {
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
693 purple_debug_misc("keyring",
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
694 "Exporting password for account %s (%s) from keyring "
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
695 "%s...\n",
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
696 purple_account_get_username(account),
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
697 purple_account_get_protocol_id(account), *keyring_id);
34127
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
698 }
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
699
34157
c67266e97d75 Don't drop exported passwords, when keyring plugin is not loadable
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
700 if (*keyring_id == NULL) {
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
701 *error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INTERNAL,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
702 "Plugin does not have a keyring id");
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
703 purple_debug_info("keyring",
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
704 "Configured keyring does not have a keyring id, cannot export password.\n");
33981
8c8fe2e5bbcd dded import/export in account.c, new version of internalkeyring.c, and added stuff to makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33978
diff changeset
705 return FALSE;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
706 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
707
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
708 export = purple_keyring_get_export_password(inuse);
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
709
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
710 if (export == NULL) {
34134
fda68dc6481c Don't require implementing import/export of password
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34133
diff changeset
711 if (purple_debug_is_verbose()) {
fda68dc6481c Don't require implementing import/export of password
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34133
diff changeset
712 purple_debug_misc("Keyring", "Configured keyring "
fda68dc6481c Don't require implementing import/export of password
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34133
diff changeset
713 "cannot export password info. This might be "
fda68dc6481c Don't require implementing import/export of password
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34133
diff changeset
714 "normal.\n");
fda68dc6481c Don't require implementing import/export of password
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34133
diff changeset
715 }
fda68dc6481c Don't require implementing import/export of password
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34133
diff changeset
716 *mode = NULL;
fda68dc6481c Don't require implementing import/export of password
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34133
diff changeset
717 *data = NULL;
fda68dc6481c Don't require implementing import/export of password
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34133
diff changeset
718 *destroy = NULL;
fda68dc6481c Don't require implementing import/export of password
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34133
diff changeset
719 return TRUE;
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
720 }
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
721
33981
8c8fe2e5bbcd dded import/export in account.c, new version of internalkeyring.c, and added stuff to makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33978
diff changeset
722 return export(account, mode, data, error, destroy);
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
723 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
724
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
725 void
34028
a3050b6df38e Remove deprecated API since we're targeting 3.0.0 here. Don't mind the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34027
diff changeset
726 purple_keyring_get_password(PurpleAccount *account,
a3050b6df38e Remove deprecated API since we're targeting 3.0.0 here. Don't mind the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34027
diff changeset
727 PurpleKeyringReadCallback cb,
a3050b6df38e Remove deprecated API since we're targeting 3.0.0 here. Don't mind the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34027
diff changeset
728 gpointer data)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
729 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
730 GError *error = NULL;
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
731 PurpleKeyring *inuse;
34153
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
732 PurpleKeyringRead read_cb;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
733
34140
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
734 if (purple_keyring_is_quitting) {
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
735 purple_debug_error("keyring", "Cannot request a password while quitting.\n");
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
736 error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INTERNAL,
34140
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
737 "Cannot request a password while quitting.");
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
738 if (cb != NULL)
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
739 cb(account, NULL, error, data);
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
740 g_error_free(error);
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
741 return;
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
742 }
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
743
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
744 if (account == NULL) {
34116
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
745 purple_debug_error("keyring", "No account passed to the function.\n");
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
746 error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INTERNAL,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
747 "No account passed to the function.");
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
748
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
749 if (cb != NULL)
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
750 cb(account, NULL, error, data);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
751
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
752 g_error_free(error);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
753
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
754 } else {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
755 inuse = purple_keyring_get_inuse();
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
756
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
757 if (inuse == NULL) {
34116
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
758 purple_debug_error("keyring", "No keyring configured.\n");
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
759 error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOKEYRING,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
760 "No keyring configured.");
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
761
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
762 if (cb != NULL)
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
763 cb(account, NULL, error, data);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
764
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
765 g_error_free(error);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
766
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
767 } else {
34153
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
768 read_cb = purple_keyring_get_read_password(inuse);
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
769 g_return_if_fail(read_cb != NULL);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
770
34142
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
771 purple_debug_info("keyring", "Reading password for account %s (%s)...\n",
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
772 purple_account_get_username(account),
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
773 purple_account_get_protocol_id(account));
34153
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
774 read_cb(account, cb, data);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
775 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
776 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
777 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
778
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
779 static void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
780 purple_keyring_set_password_async_cb(PurpleAccount *account,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
781 GError *error,
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
782 gpointer _sp_data)
34032
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
783 {
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
784 PurpleKeyringSetPasswordData *sp_data = _sp_data;
34032
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
785
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
786 g_return_if_fail(account != NULL);
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
787 g_return_if_fail(sp_data != NULL);
34032
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
788
34127
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
789 if (error == NULL && purple_debug_is_verbose()) {
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
790 purple_debug_misc("keyring", "Password for account %s (%s) "
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
791 "saved successfully.\n",
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
792 purple_account_get_username(account),
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
793 purple_account_get_protocol_id(account));
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
794 } else if (purple_debug_is_verbose()) {
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
795 purple_debug_warning("keyring", "Password for account %s (%s) "
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
796 "not saved successfully.\n",
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
797 purple_account_get_username(account),
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
798 purple_account_get_protocol_id(account));
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
799 }
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
800
34032
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
801 if (error != NULL) {
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
802 purple_notify_error(NULL, _("Keyrings"),
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
803 _("Failed to save password in keyring."),
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
804 error->message);
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
805 }
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
806
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
807 if (sp_data->cb != NULL)
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
808 sp_data->cb(account, error, sp_data->cb_data);
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
809 g_free(sp_data);
34032
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
810 }
2eeafc43c7f2 Rearrange code so we can drop the prototypes. Most of it was already
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34031
diff changeset
811
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
812 void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
813 purple_keyring_set_password(PurpleAccount *account,
34029
059c1270db1f Remove the silly destroy argument from purple_account_set_password and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34028
diff changeset
814 const gchar *password,
34028
a3050b6df38e Remove deprecated API since we're targeting 3.0.0 here. Don't mind the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34027
diff changeset
815 PurpleKeyringSaveCallback cb,
a3050b6df38e Remove deprecated API since we're targeting 3.0.0 here. Don't mind the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34027
diff changeset
816 gpointer data)
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
817 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
818 GError *error = NULL;
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
819 PurpleKeyring *inuse;
34153
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
820 PurpleKeyringSave save_cb;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
821
33997
035d8594b66a Wrote a caching system that uses account->password to store password.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33996
diff changeset
822 g_return_if_fail(account != NULL);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
823
34140
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
824 if (purple_keyring_is_quitting) {
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
825 purple_debug_error("keyring", "Cannot save a password while quitting.\n");
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
826 error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INTERNAL,
34140
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
827 "Cannot save a password while quitting.");
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
828 if (cb != NULL)
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
829 cb(account, error, data);
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
830 g_error_free(error);
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
831 return;
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
832 }
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
833
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
834 if (current_change_tracker != NULL) {
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
835 purple_debug_error("keyring", "Cannot save a password during password migration.\n");
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
836 error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INTERNAL,
34140
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
837 "Cannot save a password during password migration.");
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
838 if (cb != NULL)
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
839 cb(account, error, data);
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
840 g_error_free(error);
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
841 return;
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
842 }
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
843
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
844 inuse = purple_keyring_get_inuse();
33997
035d8594b66a Wrote a caching system that uses account->password to store password.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33996
diff changeset
845 if (inuse == NULL) {
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
846 error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOKEYRING,
33997
035d8594b66a Wrote a caching system that uses account->password to store password.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33996
diff changeset
847 "No keyring configured.");
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
848 if (cb != NULL)
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
849 cb(account, error, data);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
850 g_error_free(error);
33971
96eff57a4349 Fixed warnings
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33970
diff changeset
851
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
852 } else {
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
853 PurpleKeyringSetPasswordData *sp_data;
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
854
34153
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
855 save_cb = purple_keyring_get_save_password(inuse);
d90e86be44f7 Fix master password branch for win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
856 g_return_if_fail(save_cb != NULL);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
857
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
858 sp_data = g_new(PurpleKeyringSetPasswordData, 1);
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
859 sp_data->cb = cb;
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
860 sp_data->cb_data = data;
34146
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34145
diff changeset
861 purple_debug_info("keyring", "%s password for account %s (%s)...\n",
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34145
diff changeset
862 (password ? "Saving" : "Removing"),
34142
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
863 purple_account_get_username(account),
544f05bc883d Don't allow registering invalid keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34141
diff changeset
864 purple_account_get_protocol_id(account));
34158
166870f3adf8 keyring.c refactoring - internal structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34157
diff changeset
865 save_cb(account, password, purple_keyring_set_password_async_cb, sp_data);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
866 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
867 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
868
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
869 void
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
870 purple_keyring_change_master(PurpleKeyringChangeMasterCallback cb,
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
871 gpointer data)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
872 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
873 GError *error = NULL;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
874 PurpleKeyringChangeMaster change;
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
875 PurpleKeyring *inuse;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
876
34140
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
877 inuse = purple_keyring_get_inuse();
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
878
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
879 if (purple_keyring_is_quitting || current_change_tracker != NULL) {
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
880 purple_debug_error("keyring", "Cannot change a master password at the moment.\n");
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
881 error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INTERNAL,
34140
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
882 "Cannot change a master password at the moment.");
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
883 if (cb != NULL)
34143
a57368227f78 Get rid of redundant parameters
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34142
diff changeset
884 cb(error, data);
34140
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
885 g_error_free(error);
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
886 return;
2fd6b1439c56 Don't allow sensitive operations while quitting or migrating passwords
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
887 }
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
888
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
889 if (inuse == NULL) {
34120
50bc553c8c52 Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
890 error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOKEYRING,
50bc553c8c52 Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
891 "No keyring configured, cannot change master password.");
34127
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
892 purple_debug_error("keyring", "No keyring configured, cannot change master password.\n");
33998
5fcfc69be362 Added support for master password in pidgin's pref interface.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33997
diff changeset
893 if (cb)
34143
a57368227f78 Get rid of redundant parameters
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34142
diff changeset
894 cb(error, data);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
895 g_error_free(error);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
896
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
897 } else {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
898 change = purple_keyring_get_change_master(inuse);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
899
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
900 if (change == NULL) {
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34153
diff changeset
901 error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_BACKENDFAIL,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
902 "Keyring doesn't support master passwords.");
33998
5fcfc69be362 Added support for master password in pidgin's pref interface.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33997
diff changeset
903 if (cb)
34143
a57368227f78 Get rid of redundant parameters
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34142
diff changeset
904 cb(error, data);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
905
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
906 g_error_free(error);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
907
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
908 } else {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
909 change(cb, data);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
910
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
911 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
912 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
913 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
914
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
915
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
916 /**************************************************************************/
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
917 /* PurpleKeyring accessors */
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
918 /**************************************************************************/
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
919
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
920 PurpleKeyring *
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
921 purple_keyring_new(void)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
922 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
923 return g_new0(PurpleKeyring, 1);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
924 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
925
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
926 void
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
927 purple_keyring_free(PurpleKeyring *keyring)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
928 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
929 g_return_if_fail(keyring != NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
930
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
931 g_free(keyring->name);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
932 g_free(keyring->id);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
933 g_free(keyring);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
934 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
935
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
936 const char *
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
937 purple_keyring_get_name(const PurpleKeyring *keyring)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
938 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
939 g_return_val_if_fail(keyring != NULL, NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
940
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
941 return keyring->name;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
942 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
943
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
944 const char *
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
945 purple_keyring_get_id(const PurpleKeyring *keyring)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
946 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
947 g_return_val_if_fail(keyring != NULL, NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
948
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
949 return keyring->id;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
950 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
951
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
952 PurpleKeyringRead
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
953 purple_keyring_get_read_password(const PurpleKeyring *keyring)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
954 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
955 g_return_val_if_fail(keyring != NULL, NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
956
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
957 return keyring->read_password;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
958 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
959
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
960 PurpleKeyringSave
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
961 purple_keyring_get_save_password(const PurpleKeyring *keyring)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
962 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
963 g_return_val_if_fail(keyring != NULL, NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
964
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
965 return keyring->save_password;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
966 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
967
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
968 PurpleKeyringCancelRequests
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
969 purple_keyring_get_cancel_requests(const PurpleKeyring *keyring)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
970 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
971 g_return_val_if_fail(keyring != NULL, NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
972
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
973 return keyring->cancel_requests;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
974 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
975
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
976 PurpleKeyringClose
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
977 purple_keyring_get_close_keyring(const PurpleKeyring *keyring)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
978 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
979 g_return_val_if_fail(keyring != NULL, NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
980
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
981 return keyring->close_keyring;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
982 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
983
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
984 PurpleKeyringChangeMaster
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
985 purple_keyring_get_change_master(const PurpleKeyring *keyring)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
986 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
987 g_return_val_if_fail(keyring != NULL, NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
988
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
989 return keyring->change_master;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
990 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
991
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
992 PurpleKeyringImportPassword
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
993 purple_keyring_get_import_password(const PurpleKeyring *keyring)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
994 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
995 g_return_val_if_fail(keyring != NULL, NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
996
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
997 return keyring->import_password;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
998 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
999
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1000 PurpleKeyringExportPassword
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1001 purple_keyring_get_export_password(const PurpleKeyring *keyring)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1002 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1003 g_return_val_if_fail(keyring != NULL, NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1004
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1005 return keyring->export_password;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1006 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1007
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1008 void
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1009 purple_keyring_set_name(PurpleKeyring *keyring, const char *name)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1010 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1011 g_return_if_fail(keyring != NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1012 g_return_if_fail(name != NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1013
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1014 g_free(keyring->name);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1015 keyring->name = g_strdup(name);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1016 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1017
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1018 void
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1019 purple_keyring_set_id(PurpleKeyring *keyring, const char *id)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1020 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1021 g_return_if_fail(keyring != NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1022 g_return_if_fail(id != NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1023
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1024 g_free(keyring->id);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1025 keyring->id = g_strdup(id);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1026 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1027
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1028 void
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1029 purple_keyring_set_read_password(PurpleKeyring *keyring,
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1030 PurpleKeyringRead read_cb)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1031 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1032 g_return_if_fail(keyring != NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1033 g_return_if_fail(read_cb != NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1034
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1035 keyring->read_password = read_cb;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1036 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1037
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1038 void
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1039 purple_keyring_set_save_password(PurpleKeyring *keyring,
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1040 PurpleKeyringSave save_cb)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1041 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1042 g_return_if_fail(keyring != NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1043 g_return_if_fail(save_cb != NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1044
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1045 keyring->save_password = save_cb;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1046 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1047
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1048 void
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1049 purple_keyring_set_cancel_requests(PurpleKeyring *keyring,
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1050 PurpleKeyringCancelRequests cancel_requests)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1051 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1052 g_return_if_fail(keyring != NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1053
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1054 keyring->cancel_requests = cancel_requests;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1055 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1056
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1057 void
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1058 purple_keyring_set_close_keyring(PurpleKeyring *keyring,
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1059 PurpleKeyringClose close_cb)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1060 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1061 g_return_if_fail(keyring != NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1062
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1063 keyring->close_keyring = close_cb;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1064 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1065
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1066 void
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1067 purple_keyring_set_change_master(PurpleKeyring *keyring,
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1068 PurpleKeyringChangeMaster change_master)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1069 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1070 g_return_if_fail(keyring != NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1071
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1072 keyring->change_master = change_master;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1073 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1074
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1075 void
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1076 purple_keyring_set_import_password(PurpleKeyring *keyring,
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1077 PurpleKeyringImportPassword import_password)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1078 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1079 g_return_if_fail(keyring != NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1080
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1081 keyring->import_password = import_password;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1082 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1083
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1084 void
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1085 purple_keyring_set_export_password(PurpleKeyring *keyring,
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1086 PurpleKeyringExportPassword export_password)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1087 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1088 g_return_if_fail(keyring != NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1089
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1090 keyring->export_password = export_password;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1091 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
1092
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
1093
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1094 /**************************************************************************/
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1095 /* Error Codes */
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1096 /**************************************************************************/
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
1097
33981
8c8fe2e5bbcd dded import/export in account.c, new version of internalkeyring.c, and added stuff to makefiles.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33978
diff changeset
1098 GQuark purple_keyring_error_domain(void)
33970
4b6a0141a242 Fixed syntax and types error. keyring.c and keyring.h will now compile, but will issue warnings with -Wall
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33969
diff changeset
1099 {
33998
5fcfc69be362 Added support for master password in pidgin's pref interface.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33997
diff changeset
1100 return g_quark_from_static_string("libpurple keyring");
33970
4b6a0141a242 Fixed syntax and types error. keyring.c and keyring.h will now compile, but will issue warnings with -Wall
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33969
diff changeset
1101 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
1102
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1103 /**************************************************************************/
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1104 /* Keyring Subsystem */
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1105 /**************************************************************************/
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1106
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1107 static void purple_keyring_core_initialized_cb(void)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1108 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1109 if (purple_keyring_inuse == NULL) {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1110 purple_notify_error(NULL, _("Keyrings"),
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1111 _("Failed to load selected keyring."),
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1112 _("Check your system configuration or select another "
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1113 "one in Preferences dialog."));
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1114 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1115 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1116
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1117 static void purple_keyring_core_quitting_cb()
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1118 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1119 if (current_change_tracker != NULL) {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1120 PurpleKeyringChangeTracker *tracker;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1121 PurpleKeyringCancelRequests cancel = NULL;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1122
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1123 tracker = current_change_tracker;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1124 tracker->abort = TRUE;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1125 if (tracker->old) {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1126 cancel = purple_keyring_get_cancel_requests(
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1127 tracker->old);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1128 if (cancel)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1129 cancel();
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1130 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1131 if (current_change_tracker == tracker && tracker->new) {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1132 cancel = purple_keyring_get_cancel_requests(
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1133 tracker->new);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1134 if (cancel)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1135 cancel();
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1136 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1137 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1138 purple_keyring_is_quitting = TRUE;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1139 if (purple_keyring_inuse != NULL) {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1140 PurpleKeyringCancelRequests cancel;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1141 cancel = purple_keyring_get_cancel_requests(
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1142 purple_keyring_inuse);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1143 if (cancel)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1144 cancel();
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1145 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1146 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1147
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1148 void
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1149 purple_keyring_init(void)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1150 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1151 const char *touse;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1152 GList *it;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1153
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1154 purple_keyring_keyrings = NULL;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1155 purple_keyring_inuse = NULL;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1156
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1157 purple_keyring_failed_imports = g_hash_table_new_full(g_direct_hash,
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1158 g_direct_equal, NULL,
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1159 (GDestroyNotify)purple_keyring_failed_import_free);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1160
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1161 purple_signal_register(purple_keyring_get_handle(),
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1162 "keyring-register",
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1163 purple_marshal_VOID__POINTER_POINTER,
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1164 NULL, 2,
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1165 purple_value_new(PURPLE_TYPE_STRING), /* keyring ID */
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1166 purple_value_new(PURPLE_TYPE_BOXED, "PurpleKeyring *")); /* a pointer to the keyring */
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1167
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1168 purple_signal_register(purple_keyring_get_handle(),
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1169 "keyring-unregister",
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1170 purple_marshal_VOID__POINTER_POINTER,
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1171 NULL, 2,
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1172 purple_value_new(PURPLE_TYPE_STRING), /* keyring ID */
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1173 purple_value_new(PURPLE_TYPE_BOXED, "PurpleKeyring *")); /* a pointer to the keyring */
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1174
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1175 /* see what keyring we want to use */
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1176 touse = purple_prefs_get_string("/purple/keyring/active");
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
1177
34159
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1178 if (touse == NULL) {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1179 purple_prefs_add_none("/purple/keyring");
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1180 purple_prefs_add_string("/purple/keyring/active", PURPLE_DEFAULT_KEYRING);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1181 purple_keyring_to_use = g_strdup(PURPLE_DEFAULT_KEYRING);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1182 } else {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1183 purple_keyring_to_use = g_strdup(touse);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1184 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1185
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1186 purple_keyring_pref_cb_id = purple_prefs_connect_callback(NULL,
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1187 "/purple/keyring/active", purple_keyring_pref_cb, NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1188
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1189 for (it = purple_plugins_get_all(); it != NULL; it = it->next)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1190 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1191 PurplePlugin *plugin = (PurplePlugin *)it->data;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1192
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1193 if (plugin->info == NULL || plugin->info->id == NULL)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1194 continue;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1195 if (strncmp(plugin->info->id, "keyring-", 8) != 0)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1196 continue;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1197
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1198 if (purple_plugin_is_loaded(plugin))
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1199 continue;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1200
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1201 if (purple_plugin_load(plugin))
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1202 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1203 purple_keyring_loaded_plugins = g_list_append(
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1204 purple_keyring_loaded_plugins, plugin);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1205 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1206 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1207
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1208 if (purple_keyring_inuse == NULL)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1209 purple_debug_error("keyring", "selected keyring failed to load\n");
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1210
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1211 purple_signal_connect(purple_get_core(), "core-initialized",
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1212 purple_keyring_get_handle(),
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1213 PURPLE_CALLBACK(purple_keyring_core_initialized_cb), NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1214 purple_signal_connect(purple_get_core(), "quitting",
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1215 purple_keyring_get_handle(),
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1216 PURPLE_CALLBACK(purple_keyring_core_quitting_cb), NULL);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1217 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1218
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1219 void
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1220 purple_keyring_uninit(void)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1221 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1222 GList *it;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1223
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1224 g_free(purple_keyring_to_use);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1225 purple_keyring_inuse = NULL;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1226
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1227 for (it = g_list_first(purple_keyring_loaded_plugins); it != NULL;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1228 it = g_list_next(it))
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1229 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1230 PurplePlugin *plugin = (PurplePlugin *)it->data;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1231 if (g_list_find(purple_plugins_get_loaded(), plugin) == NULL)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1232 continue;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1233 purple_plugin_unload(plugin);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1234 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1235 g_list_free(purple_keyring_loaded_plugins);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1236 purple_keyring_loaded_plugins = NULL;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1237
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1238 purple_signals_unregister_by_instance(purple_keyring_get_handle());
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1239 purple_signals_disconnect_by_handle(purple_keyring_get_handle());
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1240 purple_prefs_disconnect_callback(purple_keyring_pref_cb_id);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1241 purple_keyring_pref_cb_id = 0;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1242
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1243 g_hash_table_destroy(purple_keyring_failed_imports);
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1244 purple_keyring_failed_imports = NULL;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1245 }
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1246
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1247 void *
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1248 purple_keyring_get_handle(void)
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1249 {
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1250 static int handle;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1251
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1252 return &handle;
c47b85d03439 keyring.c refactoring - order up function implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34158
diff changeset
1253 }

mercurial