soc.2008.masterpassword: 5f3def4c: Correctly namespace these keyring errors...

qulogic at pidgin.im qulogic at pidgin.im
Mon Nov 7 02:37:39 EST 2011


----------------------------------------------------------------------
Revision: 5f3def4cdd54981255b8e59a9f9c3b3978465581
Parent:   1616095ec6741ad37fbacb4c8356b142aefda18b
Author:   qulogic at pidgin.im
Date:     11/05/11 23:10:13
Branch:   im.pidgin.soc.2008.masterpassword
URL: http://d.pidgin.im/viewmtn/revision/info/5f3def4cdd54981255b8e59a9f9c3b3978465581

Changelog: 

Correctly namespace these keyring errors.

Changes against parent 1616095ec6741ad37fbacb4c8356b142aefda18b

  patched  libpurple/keyring.c
  patched  libpurple/keyring.h
  patched  libpurple/plugins/keyrings/gnomekeyring.c
  patched  libpurple/plugins/keyrings/internalkeyring.c

-------------- next part --------------
============================================================
--- libpurple/keyring.h	ea1a6f8bf75478a8371b2029a73bcc3c9fd80a98
+++ libpurple/keyring.h	cf2278c01833a108cd3ed6cedf0720eb4ae1bd50
@@ -416,23 +416,23 @@ void purple_keyring_set_export_password(
  * Error domain GQuark.
  * See @ref purple_keyring_error_domain .
  */
-#define ERR_PIDGINKEYRING 	purple_keyring_error_domain()
+#define PURPLE_KEYRING_ERROR purple_keyring_error_domain()
 /** stuff here too */
 GQuark purple_keyring_error_domain(void);
 
 /** error codes for keyrings. */
 enum PurpleKeyringError
 {
-	ERR_OK = 0,         /**< No error. */
-	ERR_NOPASSWD = 1,   /**< No stored password. */
-	ERR_NOACCOUNT,      /**< Account not found. */
-	ERR_WRONGPASS,      /**< User submitted wrong password when prompted. */
-	ERR_WRONGFORMAT,    /**< Data passed is not in suitable format. */
-	ERR_NOKEYRING,      /**< No keyring configured. */
-	ERR_NOCHANNEL,      /**< Failed to communicate with the backend */
-	ERR_INVALID,        /**< Invalid input */
-	ERR_NOCAP,          /**< Keyring doesn't support this */
-	ERR_UNKNOWN         /**< Unknown error */
+	PURPLE_KEYRING_ERROR_OK = 0,         /**< No error. */
+	PURPLE_KEYRING_ERROR_NOPASSWD = 1,   /**< No stored password. */
+	PURPLE_KEYRING_ERROR_NOACCOUNT,      /**< Account not found. */
+	PURPLE_KEYRING_ERROR_WRONGPASS,      /**< User submitted wrong password when prompted. */
+	PURPLE_KEYRING_ERROR_WRONGFORMAT,    /**< Data passed is not in suitable format. */
+	PURPLE_KEYRING_ERROR_NOKEYRING,      /**< No keyring configured. */
+	PURPLE_KEYRING_ERROR_NOCHANNEL,      /**< Failed to communicate with the backend */
+	PURPLE_KEYRING_ERROR_INVALID,        /**< Invalid input */
+	PURPLE_KEYRING_ERROR_NOCAP,          /**< Keyring doesn't support this */
+	PURPLE_KEYRING_ERROR_UNKNOWN         /**< Unknown error */
 };
 
 /*}@*/
============================================================
--- libpurple/keyring.c	4ebbc373246ec1818337ae994df25e90509722aa
+++ libpurple/keyring.c	3291abe379f8fdcc9e129c9f95dfc720214ae634
@@ -365,23 +365,23 @@ purple_keyring_set_inuse_check_error_cb(
 
 	name = purple_account_get_username(account);
 
-	if ((error != NULL) && (error->domain == ERR_PIDGINKEYRING)) {
+	if ((error != NULL) && (error->domain == PURPLE_KEYRING_ERROR)) {
 		tracker->error = error;
 
 		switch(error->code) {
-			case ERR_NOCAP:
+			case PURPLE_KEYRING_ERROR_NOCAP:
 				purple_debug_info("keyring",
 					"Keyring could not save password for account %s : %s\n",
 					name, error->message);
 				break;
 
-			case ERR_NOPASSWD:
+			case PURPLE_KEYRING_ERROR_NOPASSWD:
 				purple_debug_info("keyring",
 					"No password found while changing keyring for account %s : %s\n",
 					name, error->message);
 				break;
 
-			case ERR_NOCHANNEL:
+			case PURPLE_KEYRING_ERROR_NOCHANNEL:
 				purple_debug_info("keyring",
 					"Failed to communicate with backend while changing keyring for account %s : %s Aborting changes.\n",
 					name, error->message);
@@ -464,8 +464,8 @@ purple_keyring_set_inuse_got_pw_cb(Purpl
 	g_return_if_fail(tracker->abort == FALSE);
 
 	if (error != NULL) {
-		if (error->code == ERR_NOPASSWD ||
-		    error->code == ERR_NOACCOUNT ||
+		if (error->code == PURPLE_KEYRING_ERROR_NOPASSWD ||
+		    error->code == PURPLE_KEYRING_ERROR_NOACCOUNT ||
 		    tracker->force == TRUE) {
 			/* don't save password, and directly trigger callback */
 			purple_keyring_set_inuse_check_error_cb(account, error, data);
@@ -487,7 +487,7 @@ purple_keyring_set_inuse_got_pw_cb(Purpl
 			     purple_keyring_set_inuse_check_error_cb, tracker);
 
 		} else {
-			error = g_error_new(ERR_PIDGINKEYRING, ERR_NOCAP,
+			error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
 				"cannot store passwords in new keyring");
 			purple_keyring_set_inuse_check_error_cb(account, error, data);
 			g_error_free(error);
@@ -520,7 +520,7 @@ purple_keyring_set_inuse(const PurpleKey
 
 		if (read == NULL) {
 			/*
-			error = g_error_new(ERR_PIDGINKEYRING, ERR_NOCAP,
+			error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
 				"Existing keyring cannot read passwords");
 			*/
 			purple_debug_info("keyring", "Existing keyring cannot read passwords");
@@ -696,7 +696,7 @@ purple_keyring_import_password(PurpleAcc
 	inuse = purple_keyring_get_inuse();
 
 	if (inuse == NULL) {
-		*error = g_error_new(ERR_PIDGINKEYRING , ERR_NOKEYRING,
+		*error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOKEYRING,
 			"No keyring configured, cannot import password info");
 		purple_debug_info("Keyring",
 			"No keyring configured, cannot import password info for account %s (%s).\n",
@@ -713,7 +713,7 @@ purple_keyring_import_password(PurpleAcc
 	if ((keyringid != NULL && g_strcmp0(realid, keyringid) != 0) ||
 	    (keyringid == NULL && g_strcmp0(PURPLE_DEFAULT_KEYRING, realid))) {
 
-		*error = g_error_new(ERR_PIDGINKEYRING , ERR_INVALID,
+		*error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INVALID,
 			"Specified keyring id does not match the configured one.");
 		purple_debug_info("keyring",
 			"Specified keyring id does not match the configured one (%s vs. %s). Data will be lost.\n",
@@ -723,7 +723,7 @@ purple_keyring_import_password(PurpleAcc
 
 	import = purple_keyring_get_import_password(inuse);
 	if (import == NULL) {
-		*error = g_error_new(ERR_PIDGINKEYRING , ERR_NOCAP,
+		*error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
 			"Keyring cannot import password info.");
 		purple_debug_info("Keyring", "Configured keyring cannot import password info. This might be normal.");
 		return FALSE;
@@ -746,7 +746,7 @@ purple_keyring_export_password(PurpleAcc
 	inuse = purple_keyring_get_inuse();
 
 	if (inuse == NULL) {
-		*error = g_error_new(ERR_PIDGINKEYRING , ERR_NOKEYRING,
+		*error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOKEYRING,
 			"No keyring configured, cannot export password info");
 		purple_debug_info("keyring",
 			"No keyring configured, cannot export password info");
@@ -762,7 +762,7 @@ purple_keyring_export_password(PurpleAcc
 		*keyringid);
 
 	if (*keyringid == NULL) {
-		*error = g_error_new(ERR_PIDGINKEYRING , ERR_INVALID,
+		*error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INVALID,
 			"Plugin does not have a keyring id");
 		purple_debug_info("keyring",
 			"Configured keyring does not have a keyring id, cannot export password");
@@ -772,7 +772,7 @@ purple_keyring_export_password(PurpleAcc
 	export = purple_keyring_get_export_password(inuse);
 
 	if (export == NULL) {
-		*error = g_error_new(ERR_PIDGINKEYRING , ERR_NOCAP,
+		*error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
 			"Keyring cannot export password info.");
 		purple_debug_info("keyring",
 			"Keyring cannot export password info. This might be normal");
@@ -792,7 +792,7 @@ purple_keyring_get_password(PurpleAccoun
 	PurpleKeyringRead read;
 
 	if (account == NULL) {
-		error = g_error_new(ERR_PIDGINKEYRING, ERR_INVALID,
+		error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INVALID,
 			"No account passed to the function.");
 
 		if (cb != NULL)
@@ -804,7 +804,7 @@ purple_keyring_get_password(PurpleAccoun
 		inuse = purple_keyring_get_inuse();
 
 		if (inuse == NULL) {
-			error = g_error_new(ERR_PIDGINKEYRING, ERR_NOKEYRING,
+			error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOKEYRING,
 				"No keyring configured.");
 
 			if (cb != NULL)
@@ -816,7 +816,7 @@ purple_keyring_get_password(PurpleAccoun
 			read = purple_keyring_get_read_password(inuse);
 
 			if (read == NULL) {
-				error = g_error_new(ERR_PIDGINKEYRING, ERR_NOCAP,
+				error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
 					"Keyring cannot read password.");
 
 				if (cb != NULL)
@@ -871,7 +871,7 @@ purple_keyring_set_password(PurpleAccoun
 
 	inuse = purple_keyring_get_inuse();
 	if (inuse == NULL) {
-		error = g_error_new(ERR_PIDGINKEYRING, ERR_NOKEYRING,
+		error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOKEYRING,
 			"No keyring configured.");
 		if (cb != NULL)
 			cb(account, error, data);
@@ -880,7 +880,7 @@ purple_keyring_set_password(PurpleAccoun
 	} else {
 		save = purple_keyring_get_save_password(inuse);
 		if (save == NULL) {
-			error = g_error_new(ERR_PIDGINKEYRING, ERR_NOCAP,
+			error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
 				"Keyring cannot save password.");
 			if (cb != NULL)
 				cb(account, error, data);
@@ -901,14 +901,14 @@ purple_keyring_close(PurpleKeyring *keyr
 	PurpleKeyringClose close;
 
 	if (keyring == NULL) {
-		*error = g_error_new(ERR_PIDGINKEYRING, ERR_INVALID,
+		*error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INVALID,
 			"No keyring passed to the function.");
 
 	} else {
 		close = purple_keyring_get_close_keyring(keyring);
 
 		if (close == NULL) {
-			*error = g_error_new(ERR_PIDGINKEYRING, ERR_NOCAP,
+			*error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
 				"Keyring doesn't support being closed.");
 
 		} else {
@@ -930,7 +930,7 @@ purple_keyring_change_master(PurpleKeyri
 	inuse = purple_keyring_get_inuse();
 
 	if (inuse == NULL) {
-		error = g_error_new(ERR_PIDGINKEYRING, ERR_NOCAP,
+		error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
 			"Keyring doesn't support master passwords.");
 		if (cb)
 			cb(FALSE, error, data);
@@ -940,7 +940,7 @@ purple_keyring_change_master(PurpleKeyri
 		change = purple_keyring_get_change_master(inuse);
 
 		if (change == NULL) {
-			error = g_error_new(ERR_PIDGINKEYRING, ERR_NOCAP,
+			error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
 				"Keyring doesn't support master passwords.");
 			if (cb)
 				cb(FALSE, error, data);
============================================================
--- libpurple/plugins/keyrings/gnomekeyring.c	b85dcf6b589a44fed7bdb6e7cd8d6094aecca8de
+++ libpurple/plugins/keyrings/gnomekeyring.c	72501d7cb67ce48d84651ac30abc76ce2e8266c1
@@ -92,7 +92,8 @@ gkp_read_continue(GnomeKeyringResult res
 		switch(result) {
 			case GNOME_KEYRING_RESULT_NO_MATCH:
 				error = g_error_new(ERR_GNOMEKEYRINGPLUGIN,
-					ERR_NOPASSWD, "no password found for account : %s",
+					PURPLE_KEYRING_ERROR_NOPASSWD,
+					"No password found for account : %s",
 					purple_account_get_username(account));
 				if(cb != NULL)
 					cb(account, NULL, error, storage->user_data);
@@ -102,7 +103,8 @@ gkp_read_continue(GnomeKeyringResult res
 			case GNOME_KEYRING_RESULT_NO_KEYRING_DAEMON:
 			case GNOME_KEYRING_RESULT_IO_ERROR:
 				error = g_error_new(ERR_GNOMEKEYRINGPLUGIN,
-					ERR_NOCHANNEL, "Failed to communicate with gnome keyring (account : %s).",
+					PURPLE_KEYRING_ERROR_NOCHANNEL,
+					"Failed to communicate with gnome keyring (account : %s).",
 					purple_account_get_username(account));
 				if(cb != NULL)
 					cb(account, NULL, error, storage->user_data);
@@ -111,7 +113,8 @@ gkp_read_continue(GnomeKeyringResult res
 
 			default:
 				error = g_error_new(ERR_GNOMEKEYRINGPLUGIN,
-					ERR_NOCHANNEL, "Unknown error (account : %s).",
+					PURPLE_KEYRING_ERROR_NOCHANNEL,
+					"Unknown error (account : %s).",
 					purple_account_get_username(account));
 				if(cb != NULL)
 					cb(account, NULL, error, storage->user_data);
@@ -168,7 +171,8 @@ gkp_save_continue(GnomeKeyringResult res
 					purple_account_get_username(account),
 					purple_account_get_protocol_id(account));
 				error = g_error_new(ERR_GNOMEKEYRINGPLUGIN,
-					ERR_NOPASSWD, "Could not update password for %s : not found",
+					PURPLE_KEYRING_ERROR_NOPASSWD,
+					"Could not update password for %s : not found",
 					purple_account_get_username(account));
 				if(cb != NULL)
 					cb(account, error, storage->user_data);
@@ -182,7 +186,8 @@ gkp_save_continue(GnomeKeyringResult res
 					purple_account_get_username(account),
 					purple_account_get_protocol_id(account));
 				error = g_error_new(ERR_GNOMEKEYRINGPLUGIN,
-					ERR_NOCHANNEL, "Failed to communicate with gnome keyring (account : %s).",
+					PURPLE_KEYRING_ERROR_NOCHANNEL,
+					"Failed to communicate with gnome keyring (account : %s).",
 					purple_account_get_username(account));
 				if(cb != NULL)
 					cb(account, error, storage->user_data);
@@ -195,7 +200,8 @@ gkp_save_continue(GnomeKeyringResult res
 					purple_account_get_username(account),
 					purple_account_get_protocol_id(account));
 				error = g_error_new(ERR_GNOMEKEYRINGPLUGIN,
-					ERR_NOCHANNEL, "Unknown error (account : %s).",
+					PURPLE_KEYRING_ERROR_NOCHANNEL,
+					"Unknown error (account : %s).",
 					purple_account_get_username(account));
 				if(cb != NULL)
 					cb(account, error, storage->user_data);
============================================================
--- libpurple/plugins/keyrings/internalkeyring.c	6b0799045d0842d1a2bd47c0fcdadef9ead6ce01
+++ libpurple/plugins/keyrings/internalkeyring.c	937e604ebea8227c7dc34c269a1ce202d11ac891
@@ -94,8 +94,8 @@ internal_keyring_read(PurpleAccount *acc
 		if (cb != NULL)
 			cb(account, password, NULL, data);
 	} else {
-		error = g_error_new(ERR_PIDGINKEYRING,
-			ERR_NOPASSWD, "password not found");
+		error = g_error_new(PURPLE_KEYRING_ERROR,
+			PURPLE_KEYRING_ERROR_NOPASSWD, "password not found");
 		if (cb != NULL)
 			cb(account, NULL, error, data);
 		g_error_free(error);
@@ -163,7 +163,7 @@ internal_keyring_import_password(PurpleA
 		return TRUE;
 
 	} else {
-		*error = g_error_new(ERR_PIDGINKEYRING, ERR_NOPASSWD, "no password for account");
+		*error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOPASSWD, "no password for account");
 		return FALSE;
 
 	}


More information about the Commits mailing list