# HG changeset patch # User John Bailey # Date 1246859310 0 # Node ID 87586d7bdbbd62444f0bf114f53b2cb5822775da # Parent 430eb9e9042a019b991ce936ddc75b28bb7128d2 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. diff -r 430eb9e9042a -r 87586d7bdbbd ChangeLog.API --- a/ChangeLog.API Mon Jul 06 00:16:00 2009 +0000 +++ b/ChangeLog.API Mon Jul 06 05:48:30 2009 +0000 @@ -16,6 +16,7 @@ * 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 diff -r 430eb9e9042a -r 87586d7bdbbd libpurple/account.c --- a/libpurple/account.c Mon Jul 06 00:16:00 2009 +0000 +++ b/libpurple/account.c Mon Jul 06 05:48:30 2009 +0000 @@ -481,6 +481,35 @@ /********************************************************************* * 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 @@ 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 +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; diff -r 430eb9e9042a -r 87586d7bdbbd libpurple/account.h --- a/libpurple/account.h Mon Jul 06 00:16:00 2009 +0000 +++ b/libpurple/account.h Mon Jul 06 05:48:30 2009 +0000 @@ -459,6 +459,16 @@ 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.