diff libpurple/protocols/jabber/jabber.c @ 27894:f3477b0d32f4

improved "now listening" status support.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 03 Oct 2008 12:17:03 +0000
parents d477b5b53660
children 7cda79469830
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c	Sat Sep 27 14:21:37 2008 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Fri Oct 03 12:17:03 2008 +0000
@@ -1498,7 +1498,7 @@
 {
 	char *ret = NULL;
 	JabberBuddy *jb = NULL;
-	
+
 	if (b->account->gc && b->account->gc->proto_data)
 		jb = jabber_buddy_find(b->account->gc->proto_data, b->name, FALSE);
 
@@ -1507,13 +1507,21 @@
 	} else if(jb && !PURPLE_BUDDY_IS_ONLINE(b) && jb->error_msg) {
 		ret = g_strdup(jb->error_msg);
 	} else {
-		char *stripped;
+		char *stripped = NULL;
 
 		if(!(stripped = purple_markup_strip_html(jabber_buddy_get_status_msg(jb)))) {
 			PurplePresence *presence = purple_buddy_get_presence(b);
 			if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
-				PurpleStatus *status = purple_presence_get_status(presence, "tune");
-				stripped = g_strdup(purple_status_get_attr_string(status, PURPLE_TUNE_TITLE));
+				PurpleStatus *status;
+				const char *title, *artist;
+
+				status = purple_presence_get_status(presence, "tune");
+				title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE);
+				artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST);
+
+				stripped = g_strdup_printf("%s%s%s", title, artist ? " - " : "",
+							   artist ? artist : "");
+
 			}
 		}
 
@@ -1584,6 +1592,7 @@
 				const char *title = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE);
 				const char *artist = purple_status_get_attr_string(tune, PURPLE_TUNE_ARTIST);
 				const char *album = purple_status_get_attr_string(tune, PURPLE_TUNE_ALBUM);
+
 				char *playing = purple_util_format_song_info(title, artist, album, NULL);
 				if (playing) {
 					purple_notify_user_info_add_pair(user_info, _("Now Listening"), playing);