Cleaned up documentation and macros around deprecated password access. soc.2008.masterpassword

Wed, 27 Aug 2008 13:10:59 +0000

author
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
date
Wed, 27 Aug 2008 13:10:59 +0000
branch
soc.2008.masterpassword
changeset 34013
988e67e95a6a
parent 34012
43d0c66ef588
child 34014
647e174899a9

Cleaned up documentation and macros around deprecated password access.

libpurple/account.c file | annotate | diff | comparison | revisions
libpurple/account.h file | annotate | diff | comparison | revisions
libpurple/keyring.h file | annotate | diff | comparison | revisions
--- a/libpurple/account.c	Wed Aug 27 10:00:45 2008 +0000
+++ b/libpurple/account.c	Wed Aug 27 13:10:59 2008 +0000
@@ -1619,7 +1619,7 @@
 	account->password = g_strdup(password);
 
 	if (purple_account_get_remember_password(account) == TRUE)
-		purple_keyring_set_password_async(account, account->password, NULL, NULL, NULL);
+		purple_keyring_set_password_async(account, g_strdup(password), g_free, NULL, NULL);
 }
 
 void 
--- a/libpurple/account.h	Wed Aug 27 10:00:45 2008 +0000
+++ b/libpurple/account.h	Wed Aug 27 13:10:59 2008 +0000
@@ -322,18 +322,28 @@
  */
 void purple_account_set_username(PurpleAccount *account, const char *username);
 
+#ifndef PURPLE_DISABLE_DEPRECATED
 /**
  * Sets the account's password.
  *
  * @param account  The account.
  * @param password The password.
+ *
+ * @deprecated You should use either purple_account_set_password_async() instead.
+ * This functions is just a wrapper for the async code anyway.
  */
 void purple_account_set_password(PurpleAccount *account, const char *password);
+#endif
 
 /**
- * Set a password to be remembered.
+ * Set the account's password, and call the callback
  * This should be renamed purple_account_set_password() when getting
  * to 3.0. This calls the keyring function and syncs the accounts.xml
+ *
+ * The password in the keyring might not be immediatly updated, but the cache
+ * version will be, and it is therefore safe to read the password back before
+ * the callback has been triggered. One can also set a NULL calback.
+ *
  * @param account The account for which the password is to be saved.
  * @param password The password to save.
  * @param destroypassword A function called to free the password. Can be NULL.
@@ -565,14 +575,22 @@
  */
 const char *purple_account_get_username(const PurpleAccount *account);
 
+#ifndef PURPLE_DISABLE_DEPRECATED
 /**
- * Returns the account's password (deprecated, use async code instead).
+ * Returns the account's password.
  *
  * @param account The account.
  *
  * @return The password.
+ *
+ * @deprecated This might return NULL if the password has not been cached yet,
+ * and the keyring doesn't support sync access. It might also hang libpurple
+ * while the keyring is prompting for a password. Use purple_account_get_password_async()
+ * or purple_connection_get_password() instead (depending on the part of the code you are
+ * calling from.
  */
 const char *purple_account_get_password(PurpleAccount *account);
+#endif
 
 /**
  * Reads the password for the account and passes it to the callback
--- a/libpurple/keyring.h	Wed Aug 27 10:00:45 2008 +0000
+++ b/libpurple/keyring.h	Wed Aug 27 13:10:59 2008 +0000
@@ -357,29 +357,37 @@
 				  GDestroyNotify destroypassword,
 				  PurpleKeyringSaveCallback cb,
 				  gpointer data);
-
+#ifndef PURPLE_DISABLE_DEPRECATED
 /**
  * Read a password in a synchronous way.
- * This is here only for compatibility reasons. Keyrings are not
- * expected to support this (and shouldn't), and new code should
- * use purple_keyring_get_password_async() instead.
+ *
  * @param account The account for which we want the password.
- * @return A pointer to the the password.
+ *
+ * @return A pointer to the the password
+ *
+ * @deprecated This is here only for compatibility reasons. Keyrings
+ * are not expected to support this, and you should use 
+ * purple_keyring_get_password_async() instead.
  */
 const char * 
 purple_keyring_get_password_sync(const PurpleAccount * account);
+#endif
 
+#ifndef PURPLE_DISABLE_DEPRECATED
 /**
  * Save a password in a synchronous way.
- * This is here only for compatibility reasons. Keyrings are not
- * expected to support this (and shouldn't), and new code should
- * use purple_keyring_set_password_async() instead.
+ *
  * @param account The account for which we want the password.
  * @param password The password to save.
+ *
+ * @deprecated This is here only for compatibility reasons. Keyrings are not
+ * expected to support this, and you should use
+ * purple_keyring_set_password_async() instead.
  */
 void 
 purple_keyring_set_password_sync(PurpleAccount * account,
 				 const char *password);
+#endif
 
 /**
  * Close a safe.

mercurial