soc.2008.masterpassword: c9da84e0: Fixed the internal keyring, as well as a...

scrouaf at soc.pidgin.im scrouaf at soc.pidgin.im
Fri Jul 11 18:31:01 EDT 2008


-----------------------------------------------------------------
Revision: c9da84e0afb5696de10cd93b3eeb2b5dd37b7b75
Ancestor: b7bcba87086701ea048aeae49f4378f0716040b9
Author: scrouaf at soc.pidgin.im
Date: 2008-07-10T20:56:48
Branch: im.pidgin.soc.2008.masterpassword
URL: http://d.pidgin.im/viewmtn/revision/info/c9da84e0afb5696de10cd93b3eeb2b5dd37b7b75

Modified files:
        libpurple/keyring.c libpurple/keyring.h
        libpurple/plugins/keyrings/internalkeyring.c

ChangeLog: 

Fixed the internal keyring, as well as a couple typedefs.

-------------- next part --------------
============================================================
--- libpurple/keyring.c	241640ae8404938e9c56c7b9639a6a773e74199e
+++ libpurple/keyring.c	a29ee4ffdd7bbbcde64e133e8f4d21b67b0148f1
@@ -436,19 +436,19 @@ const char * 
 }
 
 const char * 
-purple_keyring_password_node_get_encryption(PurpleKeyringPasswordNode * info)
+purple_keyring_password_node_get_encryption(const PurpleKeyringPasswordNode * info)
 {
 	return info->encryption;
 }
 
 const char * 
-purple_keyring_password_node_get_mode(PurpleKeyringPasswordNode * info)
+purple_keyring_password_node_get_mode(const PurpleKeyringPasswordNode * info)
 {
 	return info->mode;
 }
 
 const char * 
-purple_keyring_password_node_get_data(PurpleKeyringPasswordNode * info)
+purple_keyring_password_node_get_data(const PurpleKeyringPasswordNode * info)
 {
 	return info->data;
 }
============================================================
--- libpurple/keyring.h	ef4ae6b655e7f04f91149f61c9a0b56055b4d331
+++ libpurple/keyring.h	de44b58d985308b68a39b9db9305e6274fd20ea0
@@ -53,7 +53,7 @@ typedef void (*PurpleKeyringImportCallba
 typedef void (*PurpleKeyringSaveCallback)(const PurpleAccount * account, GError ** error, gpointer data);
 typedef void (*PurpleKeyringChangeMasterCallback)(int result, GError * error, gpointer data);
 typedef void (*PurpleKeyringImportCallback)(GError ** error, gpointer data);	/* XXX add a gboolean result or just use error ? */
-typedef void (*PurpleKeyringExportCallback)(PurpleKeyringPasswordNode * result, GError * error, gpointer data);
+typedef void (*PurpleKeyringExportCallback)(PurpleKeyringPasswordNode * result, GError ** error, gpointer data);
 
 //gboolean purple_keyring_import_password(const PurpleKeyringPasswordNode * passwordnode);
 
@@ -74,7 +74,7 @@ typedef void (*PurpleKeyringImportPasswo
  */
 typedef void (*PurpleKeyringImportPassword)(const PurpleKeyringPasswordNode * nodeinfo, GError ** error, PurpleKeyringImportCallback cb, gpointer data);
 
-typedef PurpleKeyringPasswordNode * (*PurpleKeyringExportPassword)(PurpleAccount * account,GError ** error, PurpleKeyringImportCallback cb,     gpointer data);
+typedef void (*PurpleKeyringExportPassword)(const PurpleAccount * account,GError ** error, PurpleKeyringExportCallback cb,     gpointer data);
 
 /* information about a keyring */
 struct _PurpleKeyring
@@ -176,9 +176,9 @@ purple_keyring_password_node_get_account
 const PurpleAccount * 
 purple_keyring_password_node_get_account(const PurpleKeyringPasswordNode * info);
 
-const char * purple_keyring_password_node_get_encryption(PurpleKeyringPasswordNode * info);		/* info to be kept must be copied */
-const char * purple_keyring_password_node_get_mode(PurpleKeyringPasswordNode * info);			/* strings will be freed after use*/
-const char * purple_keyring_password_node_get_data(PurpleKeyringPasswordNode * info);			/* (in most cases) */
+const char * purple_keyring_password_node_get_encryption(const PurpleKeyringPasswordNode * info);		/* info to be kept must be copied */
+const char * purple_keyring_password_node_get_mode(const PurpleKeyringPasswordNode * info);			/* strings will be freed after use*/
+const char * purple_keyring_password_node_get_data(const PurpleKeyringPasswordNode * info);			/* (in most cases) */
 
 void purple_keyring_password_node_set_account(PurpleKeyringPasswordNode * info, PurpleAccount * account);
 void purple_keyring_password_node_set_encryption(PurpleKeyringPasswordNode * info, const char * encryption);
============================================================
--- libpurple/plugins/keyrings/internalkeyring.c	b74d038b1fafbed915b1e5563c4b9b86806ff22f
+++ libpurple/plugins/keyrings/internalkeyring.c	175baecfbfd72167d9bc7af89ebbc2717a7c1710
@@ -99,7 +99,7 @@ gboolean
 
 
 gboolean
-InternalKeyring_is_valid_cleartext(PurpleKeyringPasswordNode * node)
+InternalKeyring_is_valid_cleartext(const PurpleKeyringPasswordNode * node)
 {
 	const char * enc;
 	const char * mode;
@@ -218,7 +218,7 @@ void 
  * TODO : rewrite using Hashtable
  */
 void 
-InternalKeyring_Close(GError ** error)
+InternalKeyring_close(GError ** error)
 {
 	g_list_foreach(InternalKeyring_passwordlist,
 		InternalKeyring_free_passwordinfo_from_g_list, NULL);
@@ -243,8 +243,11 @@ InternalKeyring_free(gchar * password,
  *	  use accessors for PurpleKeyringPasswordNode (FIXME)
  *	  FIXME : REWRITE AS ASYNC
  */
-gboolean 
-InternalKeyring_import_password(PurpleKeyringPasswordNode * nodeinfo)
+void
+InternalKeyring_import_password(const PurpleKeyringPasswordNode * nodeinfo,
+				GError ** error,
+				PurpleKeyringImportCallback cb,
+				gpointer cbdata)
 {
 	InternalKeyring_PasswordInfo * pwinfo;
 	const char * data;
@@ -260,11 +263,11 @@ InternalKeyring_import_password(PurpleKe
 
 		pwinfo->account = purple_keyring_password_node_get_account(nodeinfo);
 
-		return TRUE;
+		//return TRUE;
 
 	} else {
 		/* invalid input */
-		return FALSE;
+		//return FALSE;
 	}		
 }
 
@@ -276,8 +279,11 @@ InternalKeyring_import_password(PurpleKe
  *	  use accessors for PurpleKeyringPasswordNode (FIXME)
  *	  FIXME : REWRITE AS ASYNC
  */
-PurpleKeyringPasswordNode * 
-InternalKeyring_export_password(PurpleAccount * account)
+void
+InternalKeyring_export_password(const PurpleAccount * account,
+				GError ** error,
+				PurpleKeyringExportCallback cb,
+				gpointer data)
 {
 	PurpleKeyringPasswordNode * nodeinfo;
 	InternalKeyring_PasswordInfo * pwinfo;
@@ -285,14 +291,19 @@ InternalKeyring_export_password(PurpleAc
 	nodeinfo = purple_keyring_password_node_new();
 	pwinfo = InternalKeyring_get_account_info(account);
 
-	if (pwinfo->password == NULL)
-		return NULL;
-	else {
+	if (pwinfo->password == NULL) {
+
+		cb(NULL, error, data);
+		return;
+
+	} else {
+
 		purple_keyring_password_node_set_encryption(nodeinfo, KEYRINGNAME);
 		purple_keyring_password_node_set_mode(nodeinfo, "cleartext");
 		purple_keyring_password_node_set_data(nodeinfo, pwinfo->password);
 
-		return nodeinfo;
+		cb(nodeinfo, error, data);
+		return;
 	}
 }
 
@@ -315,14 +326,14 @@ InternalKeyring_unload(PurplePlugin *plu
 gboolean 
 InternalKeyring_unload(PurplePlugin *plugin)
 {
-	InternalKeyring_Close(NULL);
+	InternalKeyring_close(NULL);
 	return TRUE;
 }
 
 void 
 InternalKeyring_destroy(PurplePlugin *plugin)
 {
-	InternalKeyring_Close(NULL);
+	InternalKeyring_close(NULL);
 	return;
 }
 
@@ -330,6 +341,23 @@ InternalKeyring_destroy(PurplePlugin *pl
 /** Generic plugin stuff      */
 /******************************/
 
+PurpleKeyring InternalKeyring_KeyringInfo =
+{
+	"internalkeyring",
+	InternalKeyring_read,
+	InternalKeyring_save,
+	InternalKeyring_close,
+	InternalKeyring_free,
+	NULL,				/* change_master */
+	InternalKeyring_import_password,
+	InternalKeyring_export_password,
+	NULL,				/* RESERVED */
+	NULL,				/* RESERVED */
+	NULL				/* RESERVED */
+};
+
+
+
 PurplePluginInfo plugininfo =
 {
 	PURPLE_PLUGIN_MAGIC,						/* magic */
@@ -349,7 +377,7 @@ PurplePluginInfo plugininfo =
 	"N/A",								/* homepage */
 	InternalKeyring_load,						/* load */
 	InternalKeyring_unload,						/* unload */
-	InternalKeyring_destroy,						/* destroy */
+	InternalKeyring_destroy,					/* destroy */
 	NULL,								/* ui_info */
 	NULL,								/* extra_info */
 	NULL,								/* prefs_info */


More information about the Commits mailing list