libpurple/keyring.c

Mon, 18 Mar 2013 22:21:54 +0100

author
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
date
Mon, 18 Mar 2013 22:21:54 +0100
branch
soc.2008.masterpassword
changeset 34116
825c98f8c7f6
parent 34110
bda1c52322fe
child 34117
543818e9829a
permissions
-rw-r--r--

Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD

33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
1 /**
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
2 * @file keyring.c Keyring plugin 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
33991
0eb45874d73a Made more calls asynch, enhanced error checking and reporting.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33987
diff changeset
4 * @todo ? : add dummy callback to all calls to prevent poorly written
0eb45874d73a Made more calls asynch, enhanced error checking and reporting.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33987
diff changeset
5 * plugins from segfaulting on NULL callback ?
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
6 */
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
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
9 *
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
10 * 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
11 * 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
12 * source distribution.
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
13 *
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
14 * 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
15 * 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
16 * 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
17 * (at your option) any later version.
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
18 *
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
19 * 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
20 * 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
21 * 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
22 * 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
23 *
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
24 * 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
25 * along with this program ; if not, write to the Free Software
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
27 */
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
28
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
29 #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
30 #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
31 #include "account.h"
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
32 #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
33 #include "signals.h"
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
34 #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
35 #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
36 #include "internal.h"
34110
bda1c52322fe Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34066
diff changeset
37 #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
38
33991
0eb45874d73a Made more calls asynch, enhanced error checking and reporting.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33987
diff changeset
39 typedef struct _PurpleKeyringCbInfo PurpleKeyringCbInfo;
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
40 typedef struct _PurpleKeyringChangeTracker PurpleKeyringChangeTracker;
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
41
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
42 /******************************************/
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
43 /** @name PurpleKeyring */
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
44 /******************************************/
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
45 /*@{*/
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
46
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
47 struct _PurpleKeyring
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
48 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
49 char *name; /* a user friendly name */
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
50 char *id; /* same as plugin id */
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
51 PurpleKeyringRead read_password;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
52 PurpleKeyringSave save_password;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
53 PurpleKeyringClose close_keyring;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
54 PurpleKeyringChangeMaster change_master;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
55 PurpleKeyringImportPassword import_password;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
56 PurpleKeyringExportPassword export_password;
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
57 };
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
58
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
59 struct _PurpleKeyringChangeTracker
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
60 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
61 GError *error; /* could probably be dropped */
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
62 PurpleKeyringSetInUseCallback cb;
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
63 gpointer data;
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
64 const PurpleKeyring *new;
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
65 const PurpleKeyring *old; /* we are done when: finished == TRUE && read_outstanding == 0 */
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
66 int read_outstanding;
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
67 gboolean finished;
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
68 gboolean abort;
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
69 gboolean force;
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
70 };
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
71
33991
0eb45874d73a Made more calls asynch, enhanced error checking and reporting.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33987
diff changeset
72 struct _PurpleKeyringCbInfo
0eb45874d73a Made more calls asynch, enhanced error checking and reporting.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33987
diff changeset
73 {
0eb45874d73a Made more calls asynch, enhanced error checking and reporting.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33987
diff changeset
74 gpointer cb;
0eb45874d73a Made more calls asynch, enhanced error checking and reporting.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33987
diff changeset
75 gpointer data;
0eb45874d73a Made more calls asynch, enhanced error checking and reporting.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33987
diff changeset
76 };
0eb45874d73a Made more calls asynch, enhanced error checking and reporting.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33987
diff changeset
77
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
78 /* Constructor */
34030
a313b9660f6f Remove padding in the PurpleKeyring structure. It's never allocated or
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34029
diff changeset
79 PurpleKeyring *
a313b9660f6f Remove padding in the PurpleKeyring structure. It's never allocated or
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34029
diff changeset
80 purple_keyring_new(void)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
81 {
34030
a313b9660f6f Remove padding in the PurpleKeyring structure. It's never allocated or
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34029
diff changeset
82 return g_new0(PurpleKeyring, 1);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
83 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
84
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
85 /* Destructor */
34030
a313b9660f6f Remove padding in the PurpleKeyring structure. It's never allocated or
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34029
diff changeset
86 void
a313b9660f6f Remove padding in the PurpleKeyring structure. It's never allocated or
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34029
diff changeset
87 purple_keyring_free(PurpleKeyring *keyring)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
88 {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
89 g_free(keyring);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
90 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
91
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
92 /* Accessors */
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
93 const char *
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
94 purple_keyring_get_name(const PurpleKeyring *keyring)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
95 {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
96 g_return_val_if_fail(keyring != NULL, NULL);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
97
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
98 return keyring->name;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
99 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
100
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
101 const char *
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
102 purple_keyring_get_id(const PurpleKeyring *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
103 {
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
104 g_return_val_if_fail(keyring != NULL, NULL);
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
105
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
106 return keyring->id;
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
107 }
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
108
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
109 PurpleKeyringRead
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
110 purple_keyring_get_read_password(const PurpleKeyring *keyring)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
111 {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
112 g_return_val_if_fail(keyring != NULL, NULL);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
113
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
114 return keyring->read_password;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
115 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
116
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
117 PurpleKeyringSave
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
118 purple_keyring_get_save_password(const PurpleKeyring *keyring)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
119 {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
120 g_return_val_if_fail(keyring != NULL, NULL);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
121
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
122 return keyring->save_password;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
123 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
124
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
125 PurpleKeyringClose
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
126 purple_keyring_get_close_keyring(const PurpleKeyring *keyring)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
127 {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
128 g_return_val_if_fail(keyring != NULL, NULL);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
129
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
130 return keyring->close_keyring;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
131 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
132
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
133 PurpleKeyringChangeMaster
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
134 purple_keyring_get_change_master(const PurpleKeyring *keyring)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
135 {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
136 g_return_val_if_fail(keyring != NULL, NULL);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
137
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
138 return keyring->change_master;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
139 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
140
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
141 PurpleKeyringImportPassword
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
142 purple_keyring_get_import_password(const PurpleKeyring *keyring)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
143 {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
144 g_return_val_if_fail(keyring != NULL, NULL);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
145
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
146 return keyring->import_password;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
147 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
148
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
149 PurpleKeyringExportPassword
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
150 purple_keyring_get_export_password(const PurpleKeyring *keyring)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
151 {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
152 g_return_val_if_fail(keyring != NULL, NULL);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
153
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
154 return keyring->export_password;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
155 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
156
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
157 void
34041
75204e58b8ca Fix const-ness of strings, and silly strdups.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34039
diff changeset
158 purple_keyring_set_name(PurpleKeyring *keyring, const char *name)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
159 {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
160 g_return_if_fail(keyring != NULL);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
161
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
162 g_free(keyring->name);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
163 keyring->name = g_strdup(name);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
164 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
165
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
166 void
34041
75204e58b8ca Fix const-ness of strings, and silly strdups.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34039
diff changeset
167 purple_keyring_set_id(PurpleKeyring *keyring, const char *id)
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
168 {
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
169 g_return_if_fail(keyring != NULL);
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
170
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
171 g_free(keyring->id);
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
172 keyring->id = g_strdup(id);
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
173 }
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
174
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
175 void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
176 purple_keyring_set_read_password(PurpleKeyring *keyring, PurpleKeyringRead read)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
177 {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
178 g_return_if_fail(keyring != NULL);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
179
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
180 keyring->read_password = read;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
181 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
182
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
183 void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
184 purple_keyring_set_save_password(PurpleKeyring *keyring, PurpleKeyringSave save)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
185 {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
186 g_return_if_fail(keyring != NULL);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
187
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
188 keyring->save_password = save;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
189 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
190
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
191 void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
192 purple_keyring_set_close_keyring(PurpleKeyring *keyring, PurpleKeyringClose close)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
193 {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
194 g_return_if_fail(keyring != NULL);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
195
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
196 keyring->close_keyring = close;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
197 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
198
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
199 void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
200 purple_keyring_set_change_master(PurpleKeyring *keyring, PurpleKeyringChangeMaster change)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
201 {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
202 g_return_if_fail(keyring != NULL);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
203
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
204 keyring->change_master = change;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
205 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
206
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
207 void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
208 purple_keyring_set_import_password(PurpleKeyring *keyring, PurpleKeyringImportPassword import)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
209 {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
210 g_return_if_fail(keyring != NULL);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
211
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
212 keyring->import_password = import;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
213 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
214
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
215 void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
216 purple_keyring_set_export_password(PurpleKeyring *keyring, PurpleKeyringExportPassword export)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
217 {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
218 g_return_if_fail(keyring != NULL);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
219
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
220 keyring->export_password = export;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
221 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
222
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
223 /*@}*/
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
224
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
225
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
226 /***************************************/
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
227 /** @name Keyring API */
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
228 /***************************************/
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
229 /*@{*/
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
230
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
231 static GList *purple_keyring_keyrings; /* list of available keyrings */
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
232 static const PurpleKeyring *purple_keyring_inuse; /* keyring being used */
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
233 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
234 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
235 static GList *purple_keyring_loaded_plugins = NULL;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
236
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
237 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
238 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
239 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
240 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
241 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
242 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
243 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
244
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
245 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
246 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
247 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
248
34042
c79b32c07390 Remove duplicate function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34041
diff changeset
249 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
250 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
251
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
252 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
253 }
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
254
34116
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
255 void purple_keyring_load_plugins(void)
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
256 {
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
257 GList *it;
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
258
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
259 for (it = purple_plugins_get_all(); it != NULL; it = it->next)
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
260 {
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
261 PurplePlugin *plugin = (PurplePlugin *)it->data;
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
262
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
263 if (plugin->info == NULL || plugin->info->id == NULL)
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
264 continue;
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
265 if (strncmp(plugin->info->id, "keyring-", 8) != 0)
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
266 continue;
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
267
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
268 if (purple_plugin_is_loaded(plugin))
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
269 continue;
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
270
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
271 if (purple_plugin_load(plugin))
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
272 {
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
273 purple_keyring_loaded_plugins = g_list_append(
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
274 purple_keyring_loaded_plugins, plugin);
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
275 }
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
276 }
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
277 }
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
278
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
279 void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
280 purple_keyring_init(void)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
281 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
282 PurpleCore *core;
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
283 const char *touse;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
284
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
285 /* Make sure we don't have junk */
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
286 purple_keyring_keyrings = NULL;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
287 purple_keyring_inuse = NULL;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
288
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
289 /* register signals */
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
290 core = purple_get_core();
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
291
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
292 purple_signal_register(core, "keyring-register",
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
293 purple_marshal_VOID__POINTER_POINTER,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
294 NULL, 2,
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
295 purple_value_new(PURPLE_TYPE_STRING), /* keyring ID */
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
296 purple_value_new(PURPLE_TYPE_BOXED, "PurpleKeyring *")); /* a pointer to the keyring */
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
297
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
298 purple_signal_register(core, "keyring-unregister",
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
299 purple_marshal_VOID__POINTER_POINTER,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
300 NULL, 2,
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
301 purple_value_new(PURPLE_TYPE_STRING), /* keyring ID */
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
302 purple_value_new(PURPLE_TYPE_BOXED, "PurpleKeyring *")); /* a pointer to the keyring */
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
303
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
304 /* see what keyring we want to use */
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
305 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
306
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
307 if (touse == NULL) {
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
308 purple_prefs_add_none("/purple/keyring");
34036
bf17ffca901d Give this a better name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34034
diff changeset
309 purple_prefs_add_string("/purple/keyring/active", PURPLE_DEFAULT_KEYRING);
bf17ffca901d Give this a better name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34034
diff changeset
310 purple_keyring_to_use = g_strdup(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
311 } else {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
312 purple_keyring_to_use = g_strdup(touse);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
313 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
314
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
315 purple_keyring_pref_cb_id = purple_prefs_connect_callback(NULL,
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
316 "/purple/keyring/active", purple_keyring_pref_cb, NULL);
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
317
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
318 purple_debug_info("keyring", "purple_keyring_init() done, selected keyring is : %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
319 purple_keyring_to_use);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
320 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
321
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
322 void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
323 purple_keyring_uninit(void)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
324 {
34116
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
325 GList *it;
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
326
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
327 g_free(purple_keyring_to_use);
34116
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
328
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
329 for (it = g_list_first(purple_keyring_loaded_plugins); it != NULL;
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
330 it = g_list_next(it))
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
331 {
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
332 PurplePlugin *plugin = (PurplePlugin *)it->data;
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
333 if (g_list_find(purple_plugins_get_loaded(), plugin) == NULL)
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
334 continue;
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
335 purple_plugin_unload(plugin);
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
336 }
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
337 g_list_free(purple_keyring_loaded_plugins);
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
338 purple_keyring_loaded_plugins = NULL;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
339 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
340
34042
c79b32c07390 Remove duplicate function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34041
diff changeset
341 PurpleKeyring *
34041
75204e58b8ca Fix const-ness of strings, and silly strdups.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34039
diff changeset
342 purple_keyring_find_keyring_by_id(const char *id)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
343 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
344 GList *l;
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
345 PurpleKeyring *keyring;
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
346 const char *curr_id;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
347
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
348 for (l = purple_keyring_keyrings; l != NULL; l = l->next) {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
349 keyring = l->data;
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
350 curr_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
351
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
352 if (g_strcmp0(id, curr_id) == 0)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
353 return keyring;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
354 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
355
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
356 return NULL;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
357 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
358
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
359 const GList *
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
360 purple_keyring_get_keyrings(void)
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
361 {
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
362 return purple_keyring_keyrings;
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
363 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
364
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
365 const PurpleKeyring *
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
366 purple_keyring_get_inuse(void)
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
367 {
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
368 return purple_keyring_inuse;
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
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
371
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
372 /* fire and forget */
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
373 static void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
374 purple_keyring_drop_passwords(const PurpleKeyring *keyring)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
375 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
376 GList *cur;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
377 PurpleKeyringSave save;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
378
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
379 save = purple_keyring_get_save_password(keyring);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
380
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 g_return_if_fail(save != NULL);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
382
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
383 for (cur = purple_accounts_get_all();
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
384 cur != NULL;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
385 cur = cur->next)
34029
059c1270db1f Remove the silly destroy argument from purple_account_set_password and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34028
diff changeset
386 save(cur->data, NULL, NULL, NULL);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
387 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
388
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
389 static void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
390 purple_keyring_set_inuse_check_error_cb(PurpleAccount *account,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
391 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
392 gpointer data)
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
393 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
394 const char *name;
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
395 PurpleKeyringClose close;
34041
75204e58b8ca Fix const-ness of strings, and silly strdups.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34039
diff changeset
396 PurpleKeyringChangeTracker *tracker;
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
397
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
398 tracker = (PurpleKeyringChangeTracker *)data;
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
399
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
400 g_return_if_fail(tracker->abort == FALSE);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
401
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
402 tracker->read_outstanding--;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
403
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
404 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
405
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
406 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
407 tracker->error = 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
408
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
409 switch(error->code) {
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
410 case PURPLE_KEYRING_ERROR_NOCAP:
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
411 purple_debug_info("keyring",
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
412 "Keyring could not save password for account %s : %s.\n",
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
413 name, error->message);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
414 break;
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
415
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
416 case PURPLE_KEYRING_ERROR_NOPASSWD:
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
417 purple_debug_info("keyring",
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
418 "No password found while changing keyring for account %s : %s.\n",
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
419 name, error->message);
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
420 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
421
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
422 case PURPLE_KEYRING_ERROR_NOCHANNEL:
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
423 purple_debug_info("keyring",
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
424 "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
425 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
426 tracker->abort = TRUE;
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
427 break;
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
428
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
429 default:
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
430 purple_debug_info("keyring",
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
431 "Unknown error while changing keyring for account %s : %s.\n",
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
432 name, error->message);
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
433 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
434 }
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
435 }
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
436
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
437 /* if this was the last one */
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
438 if (tracker->finished == TRUE && tracker->read_outstanding == 0) {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
439 if (tracker->abort == TRUE && tracker->force == FALSE) {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
440 if (tracker->cb != NULL)
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
441 tracker->cb(tracker->old, FALSE, tracker->error, tracker->data);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
442
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
443 purple_keyring_drop_passwords(tracker->new);
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
444
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
445 close = purple_keyring_get_close_keyring(tracker->new);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
446 if (close != NULL)
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
447 close(NULL);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
448
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
449 purple_debug_info("keyring",
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
450 "Failed to change keyring, aborting.\n");
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
451
33998
5fcfc69be362 Added support for master password in pidgin's pref interface.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33997
diff changeset
452 purple_notify_error(NULL, _("Keyrings"), _("Failed to change the keyring."),
5fcfc69be362 Added support for master password in pidgin's pref interface.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33997
diff changeset
453 _("Aborting changes."));
5fcfc69be362 Added support for master password in pidgin's pref interface.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33997
diff changeset
454 purple_keyring_inuse = tracker->old;
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
455 purple_prefs_disconnect_callback(purple_keyring_pref_cb_id);
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
456 purple_prefs_set_string("/purple/keyring/active",
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
457 purple_keyring_get_id(tracker->old));
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
458 purple_keyring_pref_cb_id = purple_prefs_connect_callback(NULL,
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
459 "/purple/keyring/active", purple_keyring_pref_cb, NULL);
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
460
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
461 } else {
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
462 close = purple_keyring_get_close_keyring(tracker->old);
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
463 if (close != NULL)
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
464 close(&error);
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
465
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
466 purple_keyring_drop_passwords(tracker->old);
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
467
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
468 purple_debug_info("keyring", "Successfully changed keyring.\n");
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
469
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
470 if (tracker->cb != NULL)
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
471 tracker->cb(tracker->new, TRUE, error, tracker->data);
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
472 }
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
473
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
474 g_free(tracker);
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
475 }
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
476
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
477 /**
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
478 * 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
479 *
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
480 * 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
481 * 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
482 * 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
483 */
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
484 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
485 purple_account_get_remember_password(account));
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
486 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
487
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
488 static void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
489 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
490 const gchar *password,
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
491 GError *error,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
492 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
493 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
494 const PurpleKeyring *new;
33971
96eff57a4349 Fixed warnings
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33970
diff changeset
495 PurpleKeyringSave save;
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
496 PurpleKeyringChangeTracker *tracker;
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
497
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
498 tracker = (PurpleKeyringChangeTracker *)data;
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
499 new = tracker->new;
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
500
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
501 g_return_if_fail(tracker->abort == FALSE);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
502
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
503 if (error != NULL) {
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
504 if (error->code == PURPLE_KEYRING_ERROR_NOPASSWD ||
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
505 error->code == PURPLE_KEYRING_ERROR_NOACCOUNT ||
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
506 tracker->force == TRUE) {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
507 /* don't save password, and directly trigger callback */
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
508 purple_keyring_set_inuse_check_error_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
509
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
510 } else {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
511 /* 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
512 tracker->abort = TRUE;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
513 }
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
514
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
515 } else {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
516 save = purple_keyring_get_save_password(new);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
517
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
518 if (save != NULL) {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
519 /* this test is probably totally useless, since there's no point
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
520 * in having a keyring that can't store passwords, but it
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
521 * will prevent crash with invalid keyrings
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
522 */
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
523 save(account, password,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
524 purple_keyring_set_inuse_check_error_cb, tracker);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
525
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
526 } else {
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
527 error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
528 "cannot store passwords in new keyring");
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
529 purple_keyring_set_inuse_check_error_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
530 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
531 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
532 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
533 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
534
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
535 void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
536 purple_keyring_set_inuse(const PurpleKeyring *newkeyring,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
537 gboolean force,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
538 PurpleKeyringSetInUseCallback cb,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
539 gpointer data)
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
540 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
541 GList *cur;
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
542 const PurpleKeyring *oldkeyring;
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
543 PurpleKeyringRead read = NULL;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
544 PurpleKeyringClose close;
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
545 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
546
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
547 if (newkeyring != NULL)
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
548 purple_debug_info("keyring", "Attempting to set new keyring : %s.\n",
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
549 newkeyring->id);
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
550 else
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
551 purple_debug_info("keyring", "Attempting to set new keyring : NULL.\n");
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
552
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
553 oldkeyring = purple_keyring_get_inuse();
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
554
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
555 if (oldkeyring != 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
556 read = purple_keyring_get_read_password(oldkeyring);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
557
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
558 if (read == NULL) {
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
559 /*
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
560 error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
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
561 "Existing keyring cannot read passwords");
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
562 */
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
563 purple_debug_info("keyring", "Existing keyring cannot read passwords.\n");
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
564
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
565 /* at this point, we know the keyring won't let us
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
566 * read passwords, so there no point in copying them.
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
567 * therefore we just cleanup the old and setup the new
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
568 * one later.
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
569 */
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
570
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
571 purple_keyring_drop_passwords(oldkeyring);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
572
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
573 close = purple_keyring_get_close_keyring(oldkeyring);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
574
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
575 if (close != NULL)
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
576 close(NULL); /* we can't do much about errors at this point */
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
577
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
578 } else {
34039
52379a0a335d Use g_new() where a struct is malloc'd.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34036
diff changeset
579 tracker = g_new(PurpleKeyringChangeTracker, 1);
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
580
33998
5fcfc69be362 Added support for master password in pidgin's pref interface.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33997
diff changeset
581 purple_keyring_inuse = newkeyring;
5fcfc69be362 Added support for master password in pidgin's pref interface.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33997
diff changeset
582
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
583 tracker->cb = cb;
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
584 tracker->data = data;
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
585 tracker->new = newkeyring;
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
586 tracker->old = oldkeyring;
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
587 tracker->read_outstanding = 0;
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
588 tracker->finished = FALSE;
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
589 tracker->abort = FALSE;
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
590 tracker->force = force;
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
591 tracker->error = NULL;
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
592
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
593 for (cur = purple_accounts_get_all();
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
594 (cur != NULL) && (tracker->abort == FALSE);
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
595 cur = cur->next) {
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
596
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
597 tracker->read_outstanding++;
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
598
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
599 if (cur->next == NULL)
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
600 tracker->finished = TRUE;
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
601
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
602 read(cur->data, purple_keyring_set_inuse_got_pw_cb, tracker);
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
603 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
604 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
605
33973
b193c0e9044b Fixed problem in async purple_peyring_set_inuse()
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33972
diff changeset
606 } else { /* no keyring was set before. */
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
607 purple_debug_info("keyring", "Setting keyring for the first time : %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
608 newkeyring->id);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
609 purple_keyring_inuse = newkeyring;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
610
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
611 if (cb != 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
612 cb(newkeyring, TRUE, NULL, data);
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
613 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
614 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
615
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
616 GList *
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
617 purple_keyring_get_options(void)
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
618 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
619 const GList *keyrings;
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
620 PurpleKeyring *keyring;
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
621 GList *list = NULL;
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
622
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
623 for (keyrings = purple_keyring_get_keyrings();
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
624 keyrings != NULL;
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
625 keyrings = keyrings->next) {
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
626
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
627 keyring = keyrings->data;
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
628 list = g_list_append(list, keyring->name);
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
629 list = g_list_append(list, keyring->id);
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
630 }
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
631
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
632 return list;
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
633 }
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
634
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
635 void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
636 purple_keyring_register(PurpleKeyring *keyring)
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
637 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
638 const char *keyring_id;
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
639 PurpleCore *core;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
640
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
641 g_return_if_fail(keyring != NULL);
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
642
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
643 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
644
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
645 /* keyring with no ID. Add error handling ? */
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
646 g_return_if_fail(keyring_id != NULL);
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
647
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
648 purple_debug_info("keyring", "Registering keyring : %s.\n",
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
649 keyring->id);
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
650
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
651 /* 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
652 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
653 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
654
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
655 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
656 keyring->id);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
657 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
658
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
659 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
660
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
661 core = purple_get_core();
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
662
34110
bda1c52322fe Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34066
diff changeset
663 PURPLE_DBUS_REGISTER_POINTER(keyring, PurpleKeyring);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
664 purple_signal_emit(core, "keyring-register", keyring_id, keyring);
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
665 purple_debug_info("keyring", "Registered keyring : %s.\n", keyring_id);
33978
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 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
668 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
669 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
670
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
671 void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
672 purple_keyring_unregister(PurpleKeyring *keyring)
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
673 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
674 PurpleCore *core;
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
675 const PurpleKeyring *inuse;
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
676 PurpleKeyring *fallback;
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
677 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
678
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
679 g_return_if_fail(keyring != NULL);
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
680
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
681 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
682 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
683
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
684 core = purple_get_core();
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
685 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
686 purple_signal_emit(core, "keyring-unregister", keyring_id, keyring);
34110
bda1c52322fe Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34066
diff changeset
687 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
688
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
689 inuse = purple_keyring_get_inuse();
34036
bf17ffca901d Give this a better name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34034
diff changeset
690 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
691
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
692 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
693 if (inuse != fallback) {
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
694 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
695
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
696 } else {
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
697 fallback = NULL;
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
698 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
699 }
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
700 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
701
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
702 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
703 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
704
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
705 purple_debug_info("keyring", "Keyring %s unregistered.\n", keyring->id);
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 /*@}*/
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
709
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
710
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
711 /***************************************/
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
712 /** @name Keyring plugin wrappers */
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
713 /***************************************/
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
714 /*@{*/
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
715
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
716 gboolean
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
717 purple_keyring_import_password(PurpleAccount *account,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
718 const char *keyringid,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
719 const char *mode,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
720 const char *data,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
721 GError **error)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
722 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
723 const PurpleKeyring *inuse;
33971
96eff57a4349 Fixed warnings
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33970
diff changeset
724 PurpleKeyringImportPassword import;
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
725 const char *realid;
33971
96eff57a4349 Fixed warnings
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33970
diff changeset
726
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
727 purple_debug_info("keyring", "Importing password for account %s (%s) to keyring %s.\n",
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
728 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
729 purple_account_get_protocol_id(account),
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
730 keyringid);
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
731
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
732 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
733
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
734 if (inuse == NULL) {
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
735 *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
736 "No keyring configured, cannot import password info");
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
737 purple_debug_info("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
738 "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
739 purple_account_get_username(account), purple_account_get_protocol_id(account));
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
740 return FALSE;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
741 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
742
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
743 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
744 /*
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
745 * we want to be sure that either :
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
746 * - there is a keyringid specified and it matches the one configured
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
747 * - 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
748 */
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
749 if ((keyringid != NULL && g_strcmp0(realid, keyringid) != 0) ||
34036
bf17ffca901d Give this a better name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34034
diff changeset
750 (keyringid == NULL && g_strcmp0(PURPLE_DEFAULT_KEYRING, realid))) {
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
751
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
752 *error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INVALID,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
753 "Specified keyring id does not match the configured one.");
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
754 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
755 "Specified keyring id does not match the configured one (%s vs. %s). Data will be lost.\n",
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
756 keyringid, 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
757 return FALSE;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
758 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
759
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
760 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
761 if (import == NULL) {
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
762 *error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
763 "Keyring cannot import password info.");
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
764 purple_debug_info("Keyring", "Configured keyring cannot import password info. This might be normal.\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
765 return FALSE;
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
766 }
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
767
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
768 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
769 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
770
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
771 gboolean
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
772 purple_keyring_export_password(PurpleAccount *account,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
773 const char **keyringid,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
774 const char **mode,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
775 char **data,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
776 GError **error,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
777 GDestroyNotify *destroy)
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
778 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
779 const PurpleKeyring *inuse;
33971
96eff57a4349 Fixed warnings
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33970
diff changeset
780 PurpleKeyringExportPassword export;
96eff57a4349 Fixed warnings
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33970
diff changeset
781
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
782 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
783
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
784 if (inuse == NULL) {
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
785 *error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOKEYRING,
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
786 "No keyring configured, cannot export password info");
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
787 purple_debug_info("keyring",
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
788 "No keyring configured, cannot export password info.\n");
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
789 return FALSE;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
790 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
791
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
792 *keyringid = purple_keyring_get_id(inuse);
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
793
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
794 purple_debug_info("keyring",
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
795 "Exporting password for account %s (%s) from keyring %s.\n",
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
796 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
797 purple_account_get_protocol_id(account),
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
798 *keyringid);
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
799
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
800 if (*keyringid == NULL) {
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
801 *error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INVALID,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
802 "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
803 purple_debug_info("keyring",
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
804 "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
805 return FALSE;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
806 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
807
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
808 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
809
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
810 if (export == NULL) {
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
811 *error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
812 "Keyring cannot export password info.");
33987
9beebdbf44d6 Fixed many bugs and crashes in the keyring subsystem.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33983
diff changeset
813 purple_debug_info("keyring",
34048
2d14a219c886 Make stuff consistent.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34047
diff changeset
814 "Keyring cannot export password info. This might be normal.\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
815 return FALSE;
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
816 }
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
817
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
818 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
819 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
820
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
821 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
822 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
823 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
824 gpointer data)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
825 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
826 GError *error = NULL;
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
827 const PurpleKeyring *inuse;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
828 PurpleKeyringRead read;
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
829
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
830 if (account == NULL) {
34116
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
831 purple_debug_error("keyring", "No account passed to the function.\n");
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
832 error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INVALID,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
833 "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
834
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
835 if (cb != NULL)
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
836 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
837
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
838 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
839
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
840 } else {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
841 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
842
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
843 if (inuse == NULL) {
34116
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
844 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
845 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
846 "No keyring configured.");
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
847
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, NULL, error, data);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
850
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
851 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
852
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
853 } else {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
854 read = purple_keyring_get_read_password(inuse);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
855
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
856 if (read == NULL) {
34116
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
857 purple_debug_warning("keyring", "Keyring cannot read password.\n");
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
858 error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
859 "Keyring cannot read password.");
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
860
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
861 if (cb != NULL)
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
862 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
863
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
864 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
865
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
866 } else {
34110
bda1c52322fe Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34066
diff changeset
867 purple_debug_info("keyring", "Reading password for account %s (%s).\n",
bda1c52322fe Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34066
diff changeset
868 purple_account_get_username(account),
bda1c52322fe Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34066
diff changeset
869 purple_account_get_protocol_id(account));
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
870 read(account, cb, data);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
871 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
872 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
873 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
874 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
875
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
876 static void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
877 purple_keyring_set_password_async_cb(PurpleAccount *account,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
878 GError *error,
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
879 gpointer 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
880 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
881 PurpleKeyringCbInfo *cbinfo;
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
882 PurpleKeyringSaveCallback cb;
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
883
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
884 g_return_if_fail(data != 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
885 g_return_if_fail(account != 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
886
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
887 cbinfo = 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
888 cb = cbinfo->cb;
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
889
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
890 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
891 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
892 _("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
893 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
894 }
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
895
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
896 if (cb != 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
897 cb(account, error, cbinfo->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
898 g_free(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
899 }
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
900
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
901 void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
902 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
903 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
904 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
905 gpointer data)
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
906 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
907 GError *error = NULL;
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
908 const PurpleKeyring *inuse;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
909 PurpleKeyringSave save;
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
910 PurpleKeyringCbInfo *cbinfo;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
911
33997
035d8594b66a Wrote a caching system that uses account->password to store password.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33996
diff changeset
912 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
913
33997
035d8594b66a Wrote a caching system that uses account->password to store password.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33996
diff changeset
914 inuse = purple_keyring_get_inuse();
035d8594b66a Wrote a caching system that uses account->password to store password.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33996
diff changeset
915 if (inuse == NULL) {
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
916 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
917 "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
918 if (cb != NULL)
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
919 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
920 g_error_free(error);
33971
96eff57a4349 Fixed warnings
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33970
diff changeset
921
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
922 } else {
33997
035d8594b66a Wrote a caching system that uses account->password to store password.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33996
diff changeset
923 save = purple_keyring_get_save_password(inuse);
035d8594b66a Wrote a caching system that uses account->password to store password.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33996
diff changeset
924 if (save == NULL) {
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
925 error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
33997
035d8594b66a Wrote a caching system that uses account->password to store password.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33996
diff changeset
926 "Keyring cannot save password.");
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
927 if (cb != NULL)
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
928 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
929 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
930
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
931 } else {
34039
52379a0a335d Use g_new() where a struct is malloc'd.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34036
diff changeset
932 cbinfo = g_new(PurpleKeyringCbInfo, 1);
33997
035d8594b66a Wrote a caching system that uses account->password to store password.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33996
diff changeset
933 cbinfo->cb = cb;
035d8594b66a Wrote a caching system that uses account->password to store password.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33996
diff changeset
934 cbinfo->data = data;
34066
2365500028c7 Fix a typo in purple_keyring_set_password pointed out by Etan.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34056
diff changeset
935 save(account, password, purple_keyring_set_password_async_cb, cbinfo);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
936 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
937 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
938 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
939
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
940 void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
941 purple_keyring_close(PurpleKeyring *keyring, GError **error)
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
942 {
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
943 PurpleKeyringClose close;
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
944
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
945 if (keyring == NULL) {
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
946 *error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INVALID,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
947 "No keyring 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
948
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
949 } else {
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
950 close = purple_keyring_get_close_keyring(keyring);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
951
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
952 if (close == NULL) {
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
953 *error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
954 "Keyring doesn't support being closed.");
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
955
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
956 } else {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
957 close(error);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
958
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
959 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
960 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
961 }
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
962
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
963
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
964 void
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
965 purple_keyring_change_master(PurpleKeyringChangeMasterCallback cb,
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
966 gpointer data)
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
967 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
968 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
969 PurpleKeyringChangeMaster change;
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
970 const PurpleKeyring *inuse;
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
971
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
972 inuse = purple_keyring_get_inuse();
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
973
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
974 if (inuse == NULL) {
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
975 error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
976 "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
977 if (cb)
5fcfc69be362 Added support for master password in pidgin's pref interface.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33997
diff changeset
978 cb(FALSE, error, data);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
979 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
980
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
981 } else {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
982 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
983
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
984 if (change == NULL) {
34047
c2e68ddbf27c Correctly namespace these keyring errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34046
diff changeset
985 error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
986 "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
987 if (cb)
5fcfc69be362 Added support for master password in pidgin's pref interface.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33997
diff changeset
988 cb(FALSE, error, data);
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
989
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
990 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
991
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
992 } else {
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
993 change(cb, data);
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
994
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
995 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
996 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
997 }
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
998
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
999 /*@}*/
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
1000
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
1001
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
1002 /***************************************/
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
1003 /** @name Error Codes */
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
1004 /***************************************/
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
1005 /*@{*/
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
1006
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
1007 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
1008 {
33998
5fcfc69be362 Added support for master password in pidgin's pref interface.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33997
diff changeset
1009 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
1010 }
33969
cd9387938af8 added files that were'nt in workspace
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
1011
33978
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
1012 /*}@*/
2c649fae664e Final version of the API, corrected, cleaned, and documented.
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 33976
diff changeset
1013

mercurial