Mercurial > pidgin-audacious
changeset 2:f1dc959e4706
modify process_alias to follow recent changes.
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Fri, 29 Jun 2007 01:42:55 +0900 |
parents | 46071692f191 |
children | e7f2d7bb0381 19782faf1f00 |
files | pidgin-audacious.c |
diffstat | 1 files changed, 28 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin-audacious.c Thu Jun 28 21:36:17 2007 +0900 +++ b/pidgin-audacious.c Fri Jun 29 01:42:55 2007 +0900 @@ -271,15 +271,13 @@ static void aud_process_alias(PurpleConnection *gc, gchar *aud_info) { - gchar *new; - const gchar *old, *proto; + gchar *new = NULL, *key = NULL; + const gchar *current, *seed, *pushed, *proto; PurpleAccount *account; PurplePlugin *prpl; PurplePluginProtocolInfo *prpl_info; - gpointer val; // for hash - glong bytes; - gchar *key; + glong bytes; account = purple_connection_get_account(gc); @@ -290,57 +288,54 @@ prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); g_return_if_fail(prpl_info != NULL); - /* retrieve the old alias */ -// old = purple_url_decode(purple_account_get_alias(account)); - old = purple_account_get_alias(account); - if(old == NULL || strlen(old) == 0) { - aud_error("couldn't get old alias\n"); + /* generate key for hash table*/ + key = g_strdup_printf("%s %s", account->username, account->protocol_id); + + /* retrieve current alias */ +// current = purple_url_decode(purple_account_get_alias(account)); + current = purple_account_get_alias(account); + if(current == NULL || strlen(current) == 0) { + aud_error("couldn't get current alias\n"); + g_free(key); return; } - aud_debug("old alias = %s\n", old); + aud_debug("current alias = %s\n", current); - /* generate key for hash table*/ - key = g_strdup_printf("%s %s", account->username, account->protocol_id); -// aud_debug("alias key = %s\n", key); + /* pop pushed_alias */ + pushed = g_hash_table_lookup(pushed_alias, key); - val = g_hash_table_lookup(pushed_alias, key); - - /* if current alias differs from pushed_alias or contains token, replace seed with this. */ - if( (val && g_ascii_strcasecmp(old, val)) || strstr(old, SONG_TOKEN) ) { - g_hash_table_replace(seed_alias, g_strdup(key), g_strdup(old)); + /* if current alias differs from pushed_alias or contains token, replace seed with current. */ + if( (pushed && g_ascii_strcasecmp(current, pushed)) || strstr(current, SONG_TOKEN) ) { + g_hash_table_replace(seed_alias, g_strdup(key), g_strdup(current)); +// g_hash_table_replace(pushed_alias, g_strdup(key), g_strdup(current)); //XXX should do? } /* construct new status message */ - val = g_hash_table_lookup(seed_alias, key); - g_return_if_fail(val != NULL); + seed = g_hash_table_lookup(seed_alias, key); + g_return_if_fail(seed != NULL); + aud_debug("alias: seed = %s\n", (gchar *)seed); - bytes = strlen(val); + bytes = strlen(seed); bytes -= strlen(SONG_TOKEN); aud_debug("alias: bytes = %ld", bytes); - aud_debug("alias: stored = %s\n", (gchar *)val); - if(aud_info){ gchar *tmp = g_malloc0(BUDDY_ALIAS_MAXLEN); glong utflen = g_utf8_strlen(aud_info, BUDDY_ALIAS_MAXLEN/3 - bytes - 1); g_utf8_strncpy(tmp, aud_info, utflen); -// aud_debug("alias: utflen = %ld tmp = %s\n", utflen, tmp); - new = purple_strreplace(val, SONG_TOKEN, tmp); -// aud_debug("alias: new bytes = %ld new = %s\n", strlen(new), new); + new = purple_strreplace(seed, SONG_TOKEN, tmp); g_free(tmp); } else { - new = purple_strreplace(val, SONG_TOKEN, NO_SONG_MESSAGE); + new = purple_strreplace(seed, SONG_TOKEN, NO_SONG_MESSAGE); } - g_return_if_fail(new != NULL); /* set user info only if text has been changed */ - val = g_hash_table_lookup(pushed_alias, key); - aud_debug("alias pushed = %s\n", (gchar *)val); + pushed = g_hash_table_lookup(pushed_alias, key); + aud_debug("alias pushed = %s\n", (gchar *)pushed); - if (!val || g_ascii_strcasecmp(val, new) != 0) { - //gint result; + if (!pushed || g_ascii_strcasecmp(pushed, new) != 0) { gboolean ok = FALSE; PurplePlugin *msn_plugin = NULL; msn_plugin = purple_plugins_find_with_id("prpl-msn");