cpw.rekkanoryo.yahoo.separate_prpls: b3d7d5a5: Migrate Yahoo! JAPAN accounts to the new...

rekkanoryo at pidgin.im rekkanoryo at pidgin.im
Mon Jul 6 01:50:22 EDT 2009


-----------------------------------------------------------------
Revision: b3d7d5a5132b08750646012cb9572749d5c5a14e
Ancestor: 6e2a3847439a5a1607c9e848c8c929bb53b47a87
Author: rekkanoryo at pidgin.im
Date: 2009-07-06T05:48:30
Branch: im.pidgin.cpw.rekkanoryo.yahoo.separate_prpls
URL: http://d.pidgin.im/viewmtn/revision/info/b3d7d5a5132b08750646012cb9572749d5c5a14e

Modified files:
        ChangeLog.API libpurple/account.c libpurple/account.h

ChangeLog: 

Migrate Yahoo! JAPAN accounts to the new prpl (in theory).  This also adds
new API, purple_account_remove_setting.  I'm amazed no one had wanted this
yet.

-------------- next part --------------
============================================================
--- ChangeLog.API	0e129efceee81152a9954e46b34a0f624c693bfc
+++ ChangeLog.API	ca3fff477f20418952d112351a8f68051d8feed7
@@ -16,6 +16,7 @@ version 2.6.0 (??/??/2009):
 		* blist-node-added and blist-node-removed signals (see
 		  blist-signals.dox)
 		* Jabber plugin signals (see jabber-signals.dox)
+		* purple_account_remove_setting
 		* purple_buddy_destroy
 		* purple_buddy_get_protocol_data
 		* purple_buddy_set_protocol_data
============================================================
--- libpurple/account.c	d13791279aeb1972e500aaac359bfcf5e18b5f6f
+++ libpurple/account.c	3a56ab4a954d8c38fa2c2d12272c1c6d22f3c0fc
@@ -481,7 +481,36 @@ schedule_accounts_save(void)
 /*********************************************************************
  * Reading from disk                                                 *
  *********************************************************************/
+static void
+migrate_yahoo_japan(PurpleAccount *account)
+{
+	/* detect a Yahoo! JAPAN account that existed prior to 2.6.0 and convert it
+	 * to use the new prpl-yahoojp.  Also remove the account-specific settings
+	 * we no longer need */
 
+	if(purple_strequal(purple_account_get_protocol_id(account), "prpl-yahoo")) {
+		if(purple_account_get_bool(account, "yahoojp", FALSE)) {
+			const char *serverjp = purple_account_get_string(account, "serverjp", NULL);
+			const char *xferjp_host = purple_account_get_string(account, "xferjp_host", NULL);
+
+			g_return_if_fail(serverjp != NULL);
+			g_return_if_fail(xferjp_host != NULL);
+
+			purple_account_set_string(account, "server", serverjp);
+			purple_account_set_string(account, "xfer_host", xferjp_host);
+
+			purple_account_set_protocol_id(account, "prpl-yahoojp");
+		}
+
+		/* these should always be nuked */
+		purple_account_remove_setting(account, "serverjp");
+		purple_account_remove_setting(account, "xferjp_host");
+
+	}
+
+	return;
+}
+
 static void
 parse_settings(xmlnode *node, PurpleAccount *account)
 {
@@ -545,6 +574,10 @@ parse_settings(xmlnode *node, PurpleAcco
 
 		g_free(data);
 	}
+
+	/* we do this here because we need access to account settings to determine
+	 * if we can/should migrate an old Yahoo! JAPAN account */
+	migrate_yahoo_japan(account);
 }
 
 static GList *
@@ -1725,6 +1758,15 @@ void
 }
 
 void
+purple_account_remove_setting(PurpleAccount *account, const char *setting)
+{
+	g_return_if_fail(account != NULL);
+	g_return_if_fail(setting != NULL);
+
+	g_hash_table_remove(account->settings, setting);
+}
+
+void
 purple_account_set_int(PurpleAccount *account, const char *name, int value)
 {
 	PurpleAccountSetting *setting;
============================================================
--- libpurple/account.h	9b08f5687265f22f391b0c71cb1631fd360b1681
+++ libpurple/account.h	ea27697ac2f242986507da6d4844daf5af06dbc2
@@ -459,6 +459,16 @@ void purple_account_clear_settings(Purpl
 void purple_account_clear_settings(PurpleAccount *account);
 
 /**
+ * Removes an account-specific setting by name.
+ *
+ * @param account The account.
+ * @param setting The setting to remove.
+ *
+ * @since 2.6.0
+ */
+void purple_account_remove_setting(PurpleAccount *account, const char *setting);
+
+/**
  * Sets a protocol-specific integer setting for an account.
  *
  * @param account The account.


More information about the Commits mailing list