Mercurial > pidgin
changeset 21977:cacc01b50a23
Fixes for incorrectly displaying user tune emblem and empty current media.
We now send an empty tune when not listening to any music, don't interpret
empty tune information as valid tune info and deactivate the "tune" status
when receiving empty tune information.
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Thu, 03 Jan 2008 18:31:58 +0000 |
parents | a86c035be695 |
children | 4795260eb0bd |
files | libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/usertune.c |
diffstat | 2 files changed, 24 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c Thu Jan 03 11:12:36 2008 +0000 +++ b/libpurple/protocols/jabber/jabber.c Thu Jan 03 18:31:58 2008 +0000 @@ -614,7 +614,7 @@ js->user = jabber_id_new(purple_account_get_username(account)); js->next_id = g_random_int(); js->write_buffer = purple_circ_buffer_new(512); - js->old_length = -1; + js->old_length = 0; js->keepalive_timeout = -1; if(!js->user) { @@ -1100,7 +1100,7 @@ g_free, g_free); js->user = jabber_id_new(purple_account_get_username(account)); js->next_id = g_random_int(); - js->old_length = -1; + js->old_length = 0; if(!js->user) { purple_connection_error_reason (gc,
--- a/libpurple/protocols/jabber/usertune.c Thu Jan 03 11:12:36 2008 +0000 +++ b/libpurple/protocols/jabber/usertune.c Thu Jan 03 18:31:58 2008 +0000 @@ -35,11 +35,12 @@ xmlnode *tuneinfo, *tune; PurpleJabberTuneInfo tuneinfodata; JabberBuddyResource *resource; - + gboolean valid = FALSE; + /* ignore the tune of people not on our buddy list */ if (!buddy || !item) return; - + tuneinfodata.artist = NULL; tuneinfodata.title = NULL; tuneinfodata.album = NULL; @@ -58,36 +59,47 @@ if (!strcmp(tuneinfo->name, "artist")) { if (tuneinfodata.artist == NULL) /* only pick the first one */ tuneinfodata.artist = xmlnode_get_data(tuneinfo); + valid = TRUE; } else if (!strcmp(tuneinfo->name, "length")) { if (tuneinfodata.time == -1) { char *length = xmlnode_get_data(tuneinfo); if (length) tuneinfodata.time = strtol(length, NULL, 10); g_free(length); + if (tuneinfodata.time > 0) + valid = TRUE; } } else if (!strcmp(tuneinfo->name, "source")) { if (tuneinfodata.album == NULL) /* only pick the first one */ tuneinfodata.album = xmlnode_get_data(tuneinfo); + valid = TRUE; } else if (!strcmp(tuneinfo->name, "title")) { if (tuneinfodata.title == NULL) /* only pick the first one */ tuneinfodata.title = xmlnode_get_data(tuneinfo); + valid = TRUE; } else if (!strcmp(tuneinfo->name, "track")) { if (tuneinfodata.track == NULL) /* only pick the first one */ tuneinfodata.track = xmlnode_get_data(tuneinfo); + valid = TRUE; } else if (!strcmp(tuneinfo->name, "uri")) { if (tuneinfodata.url == NULL) /* only pick the first one */ tuneinfodata.url = xmlnode_get_data(tuneinfo); + valid = TRUE; } } } - purple_prpl_got_user_status(js->gc->account, from, "tune", - PURPLE_TUNE_ARTIST, tuneinfodata.artist, - PURPLE_TUNE_TITLE, tuneinfodata.title, - PURPLE_TUNE_ALBUM, tuneinfodata.album, - PURPLE_TUNE_TRACK, tuneinfodata.track, - PURPLE_TUNE_TIME, tuneinfodata.time, - PURPLE_TUNE_URL, tuneinfodata.url, NULL); + if (valid) { + purple_prpl_got_user_status(js->gc->account, from, "tune", + PURPLE_TUNE_ARTIST, tuneinfodata.artist, + PURPLE_TUNE_TITLE, tuneinfodata.title, + PURPLE_TUNE_ALBUM, tuneinfodata.album, + PURPLE_TUNE_TRACK, tuneinfodata.track, + PURPLE_TUNE_TIME, tuneinfodata.time, + PURPLE_TUNE_URL, tuneinfodata.url, NULL); + } else { + purple_prpl_got_user_status_deactive(js->gc->account, from, "tune"); + } g_free(tuneinfodata.artist); g_free(tuneinfodata.title); @@ -119,7 +131,7 @@ xmlnode_insert_data(xmlnode_new_child(tunenode, "source"),tuneinfo->album,-1); if(tuneinfo->url && tuneinfo->url[0] != '\0') xmlnode_insert_data(xmlnode_new_child(tunenode, "uri"),tuneinfo->url,-1); - if(tuneinfo->time >= 0) { + if(tuneinfo->time > 0) { char *length = g_strdup_printf("%d", tuneinfo->time); xmlnode_insert_data(xmlnode_new_child(tunenode, "length"),length,-1); g_free(length);