/cpw/tomkiewicz/masterpassword: cb2fe6b04447: Initial support fo...
Tomasz Wasilczyk
tomkiewicz at cpw.pidgin.im
Sat May 11 09:34:59 EDT 2013
Changeset: cb2fe6b0444735c5e6277a83da80b4175659e1d7
Author: Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date: 2013-05-11 15:34 +0200
Branch: soc.2008.masterpassword
URL: https://hg.pidgin.im/cpw/tomkiewicz/masterpassword/rev/cb2fe6b04447
Description:
Initial support for keyring settings
diffstat:
libpurple/keyring.c | 134 +++++++++-------
libpurple/keyring.h | 55 +++---
libpurple/plugins/keyrings/internalkeyring.c | 29 +++
libpurple/request.h | 2 +
pidgin/gtkprefs.c | 212 ++++++++++++++++++++------
5 files changed, 293 insertions(+), 139 deletions(-)
diffs (truncated from 667 to 300 lines):
diff --git a/libpurple/keyring.c b/libpurple/keyring.c
--- a/libpurple/keyring.c
+++ b/libpurple/keyring.c
@@ -42,9 +42,10 @@ struct _PurpleKeyring
PurpleKeyringSave save_password;
PurpleKeyringCancelRequests cancel_requests;
PurpleKeyringClose close_keyring;
- PurpleKeyringChangeMaster change_master;
PurpleKeyringImportPassword import_password;
PurpleKeyringExportPassword export_password;
+ PurpleKeyringReadSettings read_settings;
+ PurpleKeyringApplySettings apply_settings;
};
typedef struct
@@ -896,61 +897,59 @@ purple_keyring_set_password(PurpleAccoun
save_cb(account, password, purple_keyring_set_password_save_cb, set_data);
}
-/* TODO: is it usable at all? */
-void
-purple_keyring_change_master(PurpleKeyringChangeMasterCallback cb,
- gpointer data)
+PurpleRequestFields *
+purple_keyring_read_settings(void)
{
- GError *error;
PurpleKeyring *inuse;
- PurpleKeyringChangeMaster change;
+ PurpleKeyringReadSettings read_settings;
if (purple_keyring_is_quitting || current_change_tracker != NULL) {
- purple_debug_error("keyring", "Cannot change a master password "
- "at the moment.\n");
- if (cb == NULL)
- return;
- error = g_error_new(PURPLE_KEYRING_ERROR,
- PURPLE_KEYRING_ERROR_INTERNAL,
- "Cannot change a master password at the moment.");
- cb(error, data);
- g_error_free(error);
- return;
+ purple_debug_error("keyring", "Cannot read settngs at the "
+ "moment.\n");
+ return NULL;
}
inuse = purple_keyring_get_inuse();
if (inuse == NULL) {
- purple_debug_error("keyring", "No keyring configured, cannot "
- "change master password.\n");
- if (cb == NULL)
- return;
- error = g_error_new(PURPLE_KEYRING_ERROR,
- PURPLE_KEYRING_ERROR_NOKEYRING,
- "No keyring configured, cannot change master "
- "password.");
- cb(error, data);
- g_error_free(error);
- return;
+ purple_debug_error("keyring", "No keyring in use.\n");
+ return NULL;
}
- change = purple_keyring_get_change_master(inuse);
- if (change == NULL) {
- purple_debug_error("keyring", "Keyring doesn't support master "
- "passwords.\n");
- if (cb == NULL)
- return;
- error = g_error_new(PURPLE_KEYRING_ERROR,
- PURPLE_KEYRING_ERROR_BACKENDFAIL,
- "Keyring doesn't support master passwords.");
- cb(error, data);
- g_error_free(error);
- return;
+ read_settings = purple_keyring_get_read_settings(inuse);
+ if (read_settings == NULL)
+ return NULL;
+ return read_settings();
+}
+
+gboolean
+purple_keyring_apply_settings(PurpleRequestFields *fields)
+{
+ PurpleKeyring *inuse;
+ PurpleKeyringApplySettings apply_settings;
+
+ g_return_val_if_fail(fields != NULL, FALSE);
+
+ if (purple_keyring_is_quitting || current_change_tracker != NULL) {
+ purple_debug_error("keyring", "Cannot apply settngs at the "
+ "moment.\n");
+ return FALSE;
}
- change(cb, data);
+ inuse = purple_keyring_get_inuse();
+ if (inuse == NULL) {
+ purple_debug_error("keyring", "No keyring in use.\n");
+ return FALSE;
+ }
+
+ apply_settings = purple_keyring_get_apply_settings(inuse);
+ if (apply_settings == NULL) {
+ purple_debug_warning("keyring", "Applying settings not "
+ "supported.\n");
+ return FALSE;
+ }
+ return apply_settings(fields);
}
-
/**************************************************************************/
/* PurpleKeyring accessors */
/**************************************************************************/
@@ -1019,14 +1018,6 @@ purple_keyring_get_close_keyring(const P
return keyring->close_keyring;
}
-PurpleKeyringChangeMaster
-purple_keyring_get_change_master(const PurpleKeyring *keyring)
-{
- g_return_val_if_fail(keyring != NULL, NULL);
-
- return keyring->change_master;
-}
-
PurpleKeyringImportPassword
purple_keyring_get_import_password(const PurpleKeyring *keyring)
{
@@ -1043,6 +1034,22 @@ purple_keyring_get_export_password(const
return keyring->export_password;
}
+PurpleKeyringReadSettings
+purple_keyring_get_read_settings(const PurpleKeyring *keyring)
+{
+ g_return_val_if_fail(keyring != NULL, NULL);
+
+ return keyring->read_settings;
+}
+
+PurpleKeyringApplySettings
+purple_keyring_get_apply_settings(const PurpleKeyring *keyring)
+{
+ g_return_val_if_fail(keyring != NULL, NULL);
+
+ return keyring->apply_settings;
+}
+
void
purple_keyring_set_name(PurpleKeyring *keyring, const gchar *name)
{
@@ -1102,15 +1109,6 @@ purple_keyring_set_close_keyring(PurpleK
}
void
-purple_keyring_set_change_master(PurpleKeyring *keyring,
- PurpleKeyringChangeMaster change_master)
-{
- g_return_if_fail(keyring != NULL);
-
- keyring->change_master = change_master;
-}
-
-void
purple_keyring_set_import_password(PurpleKeyring *keyring,
PurpleKeyringImportPassword import_password)
{
@@ -1128,6 +1126,24 @@ purple_keyring_set_export_password(Purpl
keyring->export_password = export_password;
}
+void
+purple_keyring_set_read_settings(PurpleKeyring *keyring,
+PurpleKeyringReadSettings read_settings)
+{
+ g_return_if_fail(keyring != NULL);
+
+ keyring->read_settings = read_settings;
+}
+
+void
+purple_keyring_set_apply_settings(PurpleKeyring *keyring,
+PurpleKeyringApplySettings apply_settings)
+{
+ g_return_if_fail(keyring != NULL);
+
+ keyring->apply_settings = apply_settings;
+}
+
/**************************************************************************/
/* Error Codes */
diff --git a/libpurple/keyring.h b/libpurple/keyring.h
--- a/libpurple/keyring.h
+++ b/libpurple/keyring.h
@@ -28,6 +28,7 @@
#define _PURPLE_KEYRING_H_
#include "account.h"
+#include "request.h"
/**
* Default keyring ID.
@@ -139,15 +140,6 @@ typedef void (*PurpleKeyringCancelReques
typedef void (*PurpleKeyringClose)(void);
/**
- * Change the master password for the keyring.
- *
- * @param cb A callback for once the master password has been changed.
- * @param data Data to be passed to the callback.
- */
-typedef void (*PurpleKeyringChangeMaster)(PurpleKeyringChangeMasterCallback cb,
- gpointer data);
-
-/**
* Import serialized (and maybe encrypted) password.
*
* This is not async because it is not meant to prompt for a master password and
@@ -179,6 +171,12 @@ typedef gboolean (*PurpleKeyringExportPa
const gchar **mode, gchar **data, GError **error,
GDestroyNotify *destroy);
+/* TODO: documentation */
+typedef PurpleRequestFields * (*PurpleKeyringReadSettings)(void);
+
+/* TODO: documentation */
+typedef gboolean (*PurpleKeyringApplySettings)(PurpleRequestFields *fields);
+
/*@}*/
G_BEGIN_DECLS
@@ -319,17 +317,13 @@ void
purple_keyring_set_password(PurpleAccount *account, const gchar *password,
PurpleKeyringSaveCallback cb, gpointer data);
-/**
- * Change the master password for a safe (if the safe supports it).
- *
- * @param cb A callback for once the master password has been changed.
- * @param data Data to be passed to the callback.
- *
- * @todo Where is the master password string, that is being changed?
- */
-void
-purple_keyring_change_master(PurpleKeyringChangeMasterCallback cb,
- gpointer data);
+/* TODO: documentation */
+PurpleRequestFields *
+purple_keyring_read_settings(void);
+
+/* TODO: documentation */
+gboolean
+purple_keyring_apply_settings(PurpleRequestFields *fields);
/*@}*/
@@ -382,15 +376,18 @@ purple_keyring_get_cancel_requests(const
PurpleKeyringClose
purple_keyring_get_close_keyring(const PurpleKeyring *keyring);
-PurpleKeyringChangeMaster
-purple_keyring_get_change_master(const PurpleKeyring *keyring);
-
PurpleKeyringImportPassword
purple_keyring_get_import_password(const PurpleKeyring *keyring);
PurpleKeyringExportPassword
purple_keyring_get_export_password(const PurpleKeyring *keyring);
+PurpleKeyringReadSettings
+purple_keyring_get_read_settings(const PurpleKeyring *keyring);
+
+PurpleKeyringApplySettings
+purple_keyring_get_apply_settings(const PurpleKeyring *keyring);
+
/**
* Sets friendly user name.
*
@@ -446,10 +443,6 @@ purple_keyring_set_close_keyring(PurpleK
PurpleKeyringClose close_cb);
void
-purple_keyring_set_change_master(PurpleKeyring *keyring,
- PurpleKeyringChangeMaster change_master);
-
-void
purple_keyring_set_import_password(PurpleKeyring *keyring,
PurpleKeyringImportPassword import_password);
@@ -457,6 +450,14 @@ void
purple_keyring_set_export_password(PurpleKeyring *keyring,
PurpleKeyringExportPassword export_password);
+void
+purple_keyring_set_read_settings(PurpleKeyring *keyring,
+PurpleKeyringReadSettings read_settings);
More information about the Commits
mailing list