| 59 /** |
59 /** |
| 60 * Callback for once a password is read. |
60 * Callback for once a password is read. |
| 61 * |
61 * |
| 62 * If there was a problem, the password will be NULL, and the error set. |
62 * If there was a problem, the password will be NULL, and the error set. |
| 63 * |
63 * |
| 64 * @param account The account. |
64 * @account: The account. |
| 65 * @param password The password. |
65 * @password: The password. |
| 66 * @param error Error that may have occurred. |
66 * @error: Error that may have occurred. |
| 67 * @param data Data passed to the callback. |
67 * @data: Data passed to the callback. |
| 68 */ |
68 */ |
| 69 typedef void (*PurpleKeyringReadCallback)(PurpleAccount *account, |
69 typedef void (*PurpleKeyringReadCallback)(PurpleAccount *account, |
| 70 const gchar *password, GError *error, gpointer data); |
70 const gchar *password, GError *error, gpointer data); |
| 71 |
71 |
| 72 /** |
72 /** |
| 73 * Callback for once a password has been stored. |
73 * Callback for once a password has been stored. |
| 74 * |
74 * |
| 75 * If there was a problem, the error will be set. |
75 * If there was a problem, the error will be set. |
| 76 * |
76 * |
| 77 * @param account The account. |
77 * @account: The account. |
| 78 * @param error Error that may have occurred. |
78 * @error: Error that may have occurred. |
| 79 * @param data Data passed to the callback. |
79 * @data: Data passed to the callback. |
| 80 */ |
80 */ |
| 81 typedef void (*PurpleKeyringSaveCallback)(PurpleAccount *account, GError *error, |
81 typedef void (*PurpleKeyringSaveCallback)(PurpleAccount *account, GError *error, |
| 82 gpointer data); |
82 gpointer data); |
| 83 |
83 |
| 84 /** |
84 /** |
| 85 * Callback for once the master password for a keyring has been changed. |
85 * Callback for once the master password for a keyring has been changed. |
| 86 * |
86 * |
| 87 * @param error Error that has occurred. |
87 * @error: Error that has occurred. |
| 88 * @param data Data passed to the callback. |
88 * @data: Data passed to the callback. |
| 89 */ |
89 */ |
| 90 typedef void (*PurpleKeyringChangeMasterCallback)(GError *error, gpointer data); |
90 typedef void (*PurpleKeyringChangeMasterCallback)(GError *error, gpointer data); |
| 91 |
91 |
| 92 /** |
92 /** |
| 93 * Callback for when we change the keyring. |
93 * Callback for when we change the keyring. |
| 94 * |
94 * |
| 95 * @param error An error that might have occurred. |
95 * @error: An error that might have occurred. |
| 96 * @param data A pointer to user supplied data. |
96 * @data: A pointer to user supplied data. |
| 97 */ |
97 */ |
| 98 typedef void (*PurpleKeyringSetInUseCallback)(GError *error, gpointer data); |
98 typedef void (*PurpleKeyringSetInUseCallback)(GError *error, gpointer data); |
| 99 |
99 |
| 100 /*@}*/ |
100 /*@}*/ |
| 101 |
101 |
| 105 /*@{*/ |
105 /*@{*/ |
| 106 |
106 |
| 107 /** |
107 /** |
| 108 * Read the password for an account. |
108 * Read the password for an account. |
| 109 * |
109 * |
| 110 * @param account The account. |
110 * @account: The account. |
| 111 * @param cb A callback for once the password is found. |
111 * @cb: A callback for once the password is found. |
| 112 * @param data Data to be passed to the callback. |
112 * @data: Data to be passed to the callback. |
| 113 */ |
113 */ |
| 114 typedef void (*PurpleKeyringRead)(PurpleAccount *account, |
114 typedef void (*PurpleKeyringRead)(PurpleAccount *account, |
| 115 PurpleKeyringReadCallback cb, gpointer data); |
115 PurpleKeyringReadCallback cb, gpointer data); |
| 116 |
116 |
| 117 /** |
117 /** |
| 118 * Store a password in the keyring. |
118 * Store a password in the keyring. |
| 119 * |
119 * |
| 120 * @param account The account. |
120 * @account: The account. |
| 121 * @param password The password to be stored. If the password is NULL, this |
121 * @password: The password to be stored. If the password is NULL, this |
| 122 * means that the keyring should forget about that password. |
122 * means that the keyring should forget about that password. |
| 123 * @param cb A callback for once the password is saved. |
123 * @cb: A callback for once the password is saved. |
| 124 * @param data Data to be passed to the callback. |
124 * @data: Data to be passed to the callback. |
| 125 */ |
125 */ |
| 126 typedef void (*PurpleKeyringSave)(PurpleAccount *account, const gchar *password, |
126 typedef void (*PurpleKeyringSave)(PurpleAccount *account, const gchar *password, |
| 127 PurpleKeyringSaveCallback cb, gpointer data); |
127 PurpleKeyringSaveCallback cb, gpointer data); |
| 128 |
128 |
| 129 /** |
129 /** |
| 145 * Import serialized (and maybe encrypted) password. |
145 * Import serialized (and maybe encrypted) password. |
| 146 * |
146 * |
| 147 * This is not async because it is not meant to prompt for a master password and |
147 * This is not async because it is not meant to prompt for a master password and |
| 148 * decrypt passwords. |
148 * decrypt passwords. |
| 149 * |
149 * |
| 150 * @param account The account. |
150 * @account: The account. |
| 151 * @param mode A keyring specific option that was stored. Can be NULL. |
151 * @mode: A keyring specific option that was stored. Can be NULL. |
| 152 * @param data Data that was stored. Can be NULL. |
152 * @data: Data that was stored. Can be NULL. |
| 153 * |
153 * |
| 154 * @return TRUE on success, FALSE on failure. |
154 * Returns: TRUE on success, FALSE on failure. |
| 155 */ |
155 */ |
| 156 typedef gboolean (*PurpleKeyringImportPassword)(PurpleAccount *account, |
156 typedef gboolean (*PurpleKeyringImportPassword)(PurpleAccount *account, |
| 157 const gchar *mode, const gchar *data, GError **error); |
157 const gchar *mode, const gchar *data, GError **error); |
| 158 |
158 |
| 159 /** |
159 /** |
| 160 * Export serialized (and maybe encrypted) password. |
160 * Export serialized (and maybe encrypted) password. |
| 161 * |
161 * |
| 162 * @param account The account. |
162 * @account: The account. |
| 163 * @param mode An option field that can be used by the plugin. This is |
163 * @mode: An option field that can be used by the plugin. This is |
| 164 * expected to be a static string. |
164 * expected to be a static string. |
| 165 * @param data The data to be stored in the XML node. This string will be |
165 * @data: The data to be stored in the XML node. This string will be |
| 166 * freed using destroy() once not needed anymore. |
166 * freed using destroy() once not needed anymore. |
| 167 * @param error Will be set if a problem occured. |
167 * @error: Will be set if a problem occured. |
| 168 * @param destroy A function to be called, if non NULL, to free data. |
168 * @destroy: A function to be called, if non NULL, to free data. |
| 169 * |
169 * |
| 170 * @return TRUE on success, FALSE on failure. |
170 * Returns: TRUE on success, FALSE on failure. |
| 171 */ |
171 */ |
| 172 typedef gboolean (*PurpleKeyringExportPassword)(PurpleAccount *account, |
172 typedef gboolean (*PurpleKeyringExportPassword)(PurpleAccount *account, |
| 173 const gchar **mode, gchar **data, GError **error, |
173 const gchar **mode, gchar **data, GError **error, |
| 174 GDestroyNotify *destroy); |
174 GDestroyNotify *destroy); |
| 175 |
175 |
| 176 /** |
176 /** |
| 177 * Read keyring settings. |
177 * Read keyring settings. |
| 178 * |
178 * |
| 179 * @return New copy of current settings (must be free'd with |
179 * Returns: New copy of current settings (must be free'd with |
| 180 * purple_request_fields_destroy). |
180 * purple_request_fields_destroy). |
| 181 */ |
181 */ |
| 182 typedef PurpleRequestFields * (*PurpleKeyringReadSettings)(void); |
182 typedef PurpleRequestFields * (*PurpleKeyringReadSettings)(void); |
| 183 |
183 |
| 184 /** |
184 /** |
| 185 * Applies modified keyring settings. |
185 * Applies modified keyring settings. |
| 186 * |
186 * |
| 187 * @param notify_handle A handle that can be passed to purple_notify_message. |
187 * @notify_handle: A handle that can be passed to purple_notify_message. |
| 188 * @param fields Modified settings (originally taken from |
188 * @fields: Modified settings (originally taken from |
| 189 * PurpleKeyringReadSettings). |
189 * PurpleKeyringReadSettings). |
| 190 * @return TRUE, if succeeded, FALSE otherwise. |
190 * Returns: TRUE, if succeeded, FALSE otherwise. |
| 191 */ |
191 */ |
| 192 typedef gboolean (*PurpleKeyringApplySettings)(void *notify_handle, |
192 typedef gboolean (*PurpleKeyringApplySettings)(void *notify_handle, |
| 193 PurpleRequestFields *fields); |
193 PurpleRequestFields *fields); |
| 194 |
194 |
| 195 /*@}*/ |
195 /*@}*/ |
| 223 * |
223 * |
| 224 * If it fails, it will cancel all changes, close the new keyring, and notify |
224 * If it fails, it will cancel all changes, close the new keyring, and notify |
| 225 * the callback. If it succeeds, it will remove all passwords from the old safe |
225 * the callback. If it succeeds, it will remove all passwords from the old safe |
| 226 * and close that safe. |
226 * and close that safe. |
| 227 * |
227 * |
| 228 * @param newkeyring The new keyring to use. |
228 * @newkeyring: The new keyring to use. |
| 229 * @param force FALSE if the change can be cancelled. If this is TRUE and |
229 * @force: FALSE if the change can be cancelled. If this is TRUE and |
| 230 * an error occurs, data might be lost. |
230 * an error occurs, data might be lost. |
| 231 * @param cb A callback for once the change is complete. |
231 * @cb: A callback for once the change is complete. |
| 232 * @param data Data to be passed to the callback. |
232 * @data: Data to be passed to the callback. |
| 233 */ |
233 */ |
| 234 void |
234 void |
| 235 purple_keyring_set_inuse(PurpleKeyring *newkeyring, gboolean force, |
235 purple_keyring_set_inuse(PurpleKeyring *newkeyring, gboolean force, |
| 236 PurpleKeyringSetInUseCallback cb, gpointer data); |
236 PurpleKeyringSetInUseCallback cb, gpointer data); |
| 237 |
237 |
| 238 /** |
238 /** |
| 239 * Register a keyring plugin. |
239 * Register a keyring plugin. |
| 240 * |
240 * |
| 241 * @param keyring The keyring to register. |
241 * @keyring: The keyring to register. |
| 242 */ |
242 */ |
| 243 void |
243 void |
| 244 purple_keyring_register(PurpleKeyring *keyring); |
244 purple_keyring_register(PurpleKeyring *keyring); |
| 245 |
245 |
| 246 /** |
246 /** |
| 247 * Unregister a keyring plugin. |
247 * Unregister a keyring plugin. |
| 248 * |
248 * |
| 249 * In case the keyring is in use, passwords will be moved to a fallback safe, |
249 * In case the keyring is in use, passwords will be moved to a fallback safe, |
| 250 * and the keyring to unregister will be properly closed. |
250 * and the keyring to unregister will be properly closed. |
| 251 * |
251 * |
| 252 * @param keyring The keyring to unregister. |
252 * @keyring: The keyring to unregister. |
| 253 */ |
253 */ |
| 254 void |
254 void |
| 255 purple_keyring_unregister(PurpleKeyring *keyring); |
255 purple_keyring_unregister(PurpleKeyring *keyring); |
| 256 |
256 |
| 257 /** |
257 /** |
| 258 * Returns a GList containing the IDs and names of the registered |
258 * Returns a GList containing the IDs and names of the registered |
| 259 * keyrings. |
259 * keyrings. |
| 260 * |
260 * |
| 261 * @return The list of IDs and names. |
261 * Returns: The list of IDs and names. |
| 262 */ |
262 */ |
| 263 GList * |
263 GList * |
| 264 purple_keyring_get_options(void); |
264 purple_keyring_get_options(void); |
| 265 |
265 |
| 266 /*@}*/ |
266 /*@}*/ |
| 273 /** |
273 /** |
| 274 * Import serialized (and maybe encrypted) password into current keyring. |
274 * Import serialized (and maybe encrypted) password into current keyring. |
| 275 * |
275 * |
| 276 * It's used by account.c while reading a password from xml. |
276 * It's used by account.c while reading a password from xml. |
| 277 * |
277 * |
| 278 * @param account The account. |
278 * @account: The account. |
| 279 * @param keyring_id The plugin ID that was stored in the xml file. Can be NULL. |
279 * @keyring_id: The plugin ID that was stored in the xml file. Can be NULL. |
| 280 * @param mode A keyring specific option that was stored. Can be NULL. |
280 * @mode: A keyring specific option that was stored. Can be NULL. |
| 281 * @param data Data that was stored, can be NULL. |
281 * @data: Data that was stored, can be NULL. |
| 282 * |
282 * |
| 283 * @return TRUE if the input was accepted, FALSE otherwise. |
283 * Returns: TRUE if the input was accepted, FALSE otherwise. |
| 284 */ |
284 */ |
| 285 gboolean |
285 gboolean |
| 286 purple_keyring_import_password(PurpleAccount *account, const gchar *keyring_id, |
286 purple_keyring_import_password(PurpleAccount *account, const gchar *keyring_id, |
| 287 const gchar *mode, const gchar *data, GError **error); |
287 const gchar *mode, const gchar *data, GError **error); |
| 288 |
288 |
| 289 /** |
289 /** |
| 290 * Export serialized (and maybe encrypted) password out of current keyring. |
290 * Export serialized (and maybe encrypted) password out of current keyring. |
| 291 * |
291 * |
| 292 * It's used by account.c while syncing accounts to xml. |
292 * It's used by account.c while syncing accounts to xml. |
| 293 * |
293 * |
| 294 * @param account The account for which we want the info. |
294 * @account: The account for which we want the info. |
| 295 * @param keyring_id The plugin id to be stored in the XML node. This will be |
295 * @keyring_id: The plugin id to be stored in the XML node. This will be |
| 296 * NULL or a string that can be considered static. |
296 * NULL or a string that can be considered static. |
| 297 * @param mode An option field that can be used by the plugin. This will |
297 * @mode: An option field that can be used by the plugin. This will |
| 298 * be NULL or a string that can be considered static. |
298 * be NULL or a string that can be considered static. |
| 299 * @param data The data to be stored in the XML node. This string must be |
299 * @data: The data to be stored in the XML node. This string must be |
| 300 * freed using destroy() once not needed anymore if it is not |
300 * freed using destroy() once not needed anymore if it is not |
| 301 * NULL. |
301 * NULL. |
| 302 * @param error Will be set if a problem occured. |
302 * @error: Will be set if a problem occured. |
| 303 * @param destroy A function to be called, if non NULL, to free data. |
303 * @destroy: A function to be called, if non NULL, to free data. |
| 304 * |
304 * |
| 305 * @return TRUE if the info was exported successfully, FALSE otherwise. |
305 * Returns: TRUE if the info was exported successfully, FALSE otherwise. |
| 306 */ |
306 */ |
| 307 gboolean |
307 gboolean |
| 308 purple_keyring_export_password(PurpleAccount *account, const gchar **keyring_id, |
308 purple_keyring_export_password(PurpleAccount *account, const gchar **keyring_id, |
| 309 const gchar **mode, gchar **data, GError **error, |
309 const gchar **mode, gchar **data, GError **error, |
| 310 GDestroyNotify *destroy); |
310 GDestroyNotify *destroy); |
| 311 |
311 |
| 312 /** |
312 /** |
| 313 * Read a password from the current keyring. |
313 * Read a password from the current keyring. |
| 314 * |
314 * |
| 315 * @param account The account. |
315 * @account: The account. |
| 316 * @param cb A callback for once the password is read. |
316 * @cb: A callback for once the password is read. |
| 317 * @param data Data passed to the callback. |
317 * @data: Data passed to the callback. |
| 318 */ |
318 */ |
| 319 void |
319 void |
| 320 purple_keyring_get_password(PurpleAccount *account, |
320 purple_keyring_get_password(PurpleAccount *account, |
| 321 PurpleKeyringReadCallback cb, gpointer data); |
321 PurpleKeyringReadCallback cb, gpointer data); |
| 322 |
322 |
| 323 /** |
323 /** |
| 324 * Save a password to the current keyring. |
324 * Save a password to the current keyring. |
| 325 * |
325 * |
| 326 * @param account The account. |
326 * @account: The account. |
| 327 * @param password The password to save. |
327 * @password: The password to save. |
| 328 * @param cb A callback for once the password is saved. |
328 * @cb: A callback for once the password is saved. |
| 329 * @param data Data to be passed to the callback. |
329 * @data: Data to be passed to the callback. |
| 330 */ |
330 */ |
| 331 void |
331 void |
| 332 purple_keyring_set_password(PurpleAccount *account, const gchar *password, |
332 purple_keyring_set_password(PurpleAccount *account, const gchar *password, |
| 333 PurpleKeyringSaveCallback cb, gpointer data); |
333 PurpleKeyringSaveCallback cb, gpointer data); |
| 334 |
334 |
| 335 /** |
335 /** |
| 336 * Reads settings from current keyring. |
336 * Reads settings from current keyring. |
| 337 * |
337 * |
| 338 * @return New copy of current settings (must be free'd with |
338 * Returns: New copy of current settings (must be free'd with |
| 339 * purple_request_fields_destroy). |
339 * purple_request_fields_destroy). |
| 340 */ |
340 */ |
| 341 PurpleRequestFields * |
341 PurpleRequestFields * |
| 342 purple_keyring_read_settings(void); |
342 purple_keyring_read_settings(void); |
| 343 |
343 |
| 344 /** |
344 /** |
| 345 * Applies modified settings to current keyring. |
345 * Applies modified settings to current keyring. |
| 346 * |
346 * |
| 347 * @param notify_handle A handle that can be passed to purple_notify_message. |
347 * @notify_handle: A handle that can be passed to purple_notify_message. |
| 348 * @param fields Modified settings (originally taken from |
348 * @fields: Modified settings (originally taken from |
| 349 * PurpleKeyringReadSettings). |
349 * PurpleKeyringReadSettings). |
| 350 * @return TRUE, if succeeded, FALSE otherwise. |
350 * Returns: TRUE, if succeeded, FALSE otherwise. |
| 351 */ |
351 */ |
| 352 gboolean |
352 gboolean |
| 353 purple_keyring_apply_settings(void *notify_handle, PurpleRequestFields *fields); |
353 purple_keyring_apply_settings(void *notify_handle, PurpleRequestFields *fields); |
| 354 |
354 |
| 355 /*@}*/ |
355 /*@}*/ |
| 423 /** |
423 /** |
| 424 * Sets friendly user name. |
424 * Sets friendly user name. |
| 425 * |
425 * |
| 426 * This field is required. |
426 * This field is required. |
| 427 * |
427 * |
| 428 * @param keyring The keyring. |
428 * @keyring: The keyring. |
| 429 * @param name Friendly user name. |
429 * @name: Friendly user name. |
| 430 */ |
430 */ |
| 431 void |
431 void |
| 432 purple_keyring_set_name(PurpleKeyring *keyring, const gchar *name); |
432 purple_keyring_set_name(PurpleKeyring *keyring, const gchar *name); |
| 433 |
433 |
| 434 /** |
434 /** |
| 435 * Sets keyring ID. |
435 * Sets keyring ID. |
| 436 * |
436 * |
| 437 * This field is required. |
437 * This field is required. |
| 438 * |
438 * |
| 439 * @param keyring The keyring. |
439 * @keyring: The keyring. |
| 440 * @param name Keyring ID. |
440 * @name: Keyring ID. |
| 441 */ |
441 */ |
| 442 void |
442 void |
| 443 purple_keyring_set_id(PurpleKeyring *keyring, const gchar *id); |
443 purple_keyring_set_id(PurpleKeyring *keyring, const gchar *id); |
| 444 |
444 |
| 445 /** |
445 /** |
| 446 * Sets read password method. |
446 * Sets read password method. |
| 447 * |
447 * |
| 448 * This field is required. |
448 * This field is required. |
| 449 * |
449 * |
| 450 * @param keyring The keyring. |
450 * @keyring: The keyring. |
| 451 * @param read_cb Read password method. |
451 * @read_cb: Read password method. |
| 452 */ |
452 */ |
| 453 void |
453 void |
| 454 purple_keyring_set_read_password(PurpleKeyring *keyring, |
454 purple_keyring_set_read_password(PurpleKeyring *keyring, |
| 455 PurpleKeyringRead read_cb); |
455 PurpleKeyringRead read_cb); |
| 456 |
456 |
| 457 /** |
457 /** |
| 458 * Sets save password method. |
458 * Sets save password method. |
| 459 * |
459 * |
| 460 * This field is required. |
460 * This field is required. |
| 461 * |
461 * |
| 462 * @param keyring The keyring. |
462 * @keyring: The keyring. |
| 463 * @param save_cb Save password method. |
463 * @save_cb: Save password method. |
| 464 */ |
464 */ |
| 465 void |
465 void |
| 466 purple_keyring_set_save_password(PurpleKeyring *keyring, |
466 purple_keyring_set_save_password(PurpleKeyring *keyring, |
| 467 PurpleKeyringSave save_cb); |
467 PurpleKeyringSave save_cb); |
| 468 |
468 |