Mercurial > pidgin
changeset 27320:87586d7bdbbd
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.
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Mon, 06 Jul 2009 05:48:30 +0000 |
parents | 430eb9e9042a |
children | 76a13febd641 |
files | ChangeLog.API libpurple/account.c libpurple/account.h |
diffstat | 3 files changed, 53 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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;
--- 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.