/cpw/tomkiewicz/masterpassword: a479dca0f05b: Implement removal ...

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Thu Mar 21 17:21:58 EDT 2013


Changeset: a479dca0f05be2da4ec189691d434235baf5f8a3
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2013-03-21 22:21 +0100
Branch:	 soc.2008.masterpassword
URL: https://hg.pidgin.im/cpw/tomkiewicz/masterpassword/rev/a479dca0f05b

Description:

Implement removal of KWallet passwords (instead of setting them to blank)

diffstat:

 libpurple/keyring.c                    |   4 ++++
 libpurple/plugins/keyrings/kwallet.cpp |  21 ++++++++++++++++++---
 2 files changed, 22 insertions(+), 3 deletions(-)

diffs (66 lines):

diff --git a/libpurple/keyring.c b/libpurple/keyring.c
--- a/libpurple/keyring.c
+++ b/libpurple/keyring.c
@@ -593,6 +593,10 @@ purple_keyring_set_inuse(const PurpleKey
 				close(NULL);  /* we can't do much about errors at this point */
 
 		} else {
+			purple_debug_misc("keyring",
+				"Starting migration from: %s.\n",
+				oldkeyring->id);
+
 			tracker = g_new(PurpleKeyringChangeTracker, 1);
 
 			purple_keyring_inuse = newkeyring;
diff --git a/libpurple/plugins/keyrings/kwallet.cpp b/libpurple/plugins/keyrings/kwallet.cpp
--- a/libpurple/plugins/keyrings/kwallet.cpp
+++ b/libpurple/plugins/keyrings/kwallet.cpp
@@ -66,6 +66,7 @@ class request
 		gpointer data;
 		PurpleAccount *account;
 		QString password;
+		bool noPassword;
 };
 
 class engine : private QObject, private QQueue<request*>
@@ -318,6 +319,7 @@ KWalletPlugin::save_request::save_reques
 	data = userdata;
 	callback = cb;
 	password = QString(pw);
+	noPassword = (pw == NULL);
 }
 
 KWalletPlugin::read_request::read_request(PurpleAccount *acc,
@@ -387,7 +389,12 @@ KWalletPlugin::save_request::execute(KWa
 
 	g_return_if_fail(wallet != NULL);
 
-	result = wallet->writePassword(kwallet_account_key(account), password);
+	if (noPassword)
+		result = wallet->removeEntry(kwallet_account_key(account));
+	else {
+		result = wallet->writePassword(kwallet_account_key(account),
+			password);
+	}
 
 	if (result != 0) {
 		purple_debug_warning("keyring-kwallet",
@@ -420,8 +427,16 @@ static void
 kwallet_save(PurpleAccount *account, const char *password,
 	PurpleKeyringSaveCallback cb, gpointer data)
 {
-	KWalletPlugin::engine::instance()->queue(
-		new KWalletPlugin::save_request(account, password, cb, data));
+	if (password == NULL && KWallet::Wallet::keyDoesNotExist(
+		KWALLET_WALLET_NAME, KWALLET_FOLDER_NAME,
+		kwallet_account_key(account))) {
+		if (cb != NULL)
+			cb(account, NULL, data);
+	}
+	else
+		KWalletPlugin::engine::instance()->queue(
+			new KWalletPlugin::save_request(account, password, cb,
+			data));
 }
 
 static void



More information about the Commits mailing list