changeset 24511:7a5f6ddd11b1

Only get the artist and album if we are setting a Music mediatype.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Mon, 24 Nov 2008 06:05:01 +0000
parents e344426d7c28
children 9a3ed3b7ac4b
files libpurple/protocols/msn/msn.c libpurple/protocols/msn/state.c
diffstat 2 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/msn.c	Mon Nov 24 05:51:18 2008 +0000
+++ b/libpurple/protocols/msn/msn.c	Mon Nov 24 06:05:01 2008 +0000
@@ -705,11 +705,11 @@
 		if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
 			PurpleStatus *tune = purple_presence_get_status(presence, "tune");
 			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);
 			const char *game = purple_status_get_attr_string(tune, "game");
 			const char *office = purple_status_get_attr_string(tune, "office");
 			if (title && *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);
 				mediatype = _("Now Listening");
 				currentmedia = purple_util_format_song_info(title, artist, album, NULL);
 			} else if (game && *game) {
--- a/libpurple/protocols/msn/state.c	Mon Nov 24 05:51:18 2008 +0000
+++ b/libpurple/protocols/msn/state.c	Mon Nov 24 06:05:01 2008 +0000
@@ -209,25 +209,26 @@
 static char *
 create_media_string(PurplePresence *presence)
 {
-	const char *artist, *title, *album, *game, *office;
+	const char *title, *game, *office;
 	char *ret;
 	PurpleStatus *status = purple_presence_get_status(presence, "tune");
 	if (!status || !purple_status_is_active(status))
 		return g_strdup_printf("\\0Music\\00\\0\\0");
 
 	title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE);
-	artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST);
-	album = purple_status_get_attr_string(status, PURPLE_TUNE_ALBUM);
 	game = purple_status_get_attr_string(status, "game");
 	office = purple_status_get_attr_string(status, "office");
 
-	if (title && *title)
+	if (title && *title) {
+		const char *artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST);
+		const char *album = purple_status_get_attr_string(status, PURPLE_TUNE_ALBUM);
 		ret = g_strdup_printf("WMP\\0Music\\01\\0{0}%s%s\\0%s\\0%s\\0%s\\0",
 		                      artist ? " - {1}" : "",
 		                      album ? " ({2})" : "",
 		                      title,
 		                      artist ? artist : "",
 		                      album ? album : "");
+	}
 	else if (game && *game)
 		ret = g_strdup_printf("\\0Games\\01\\0Playing {0}\\0%s\\0", game);
 	else if (office && *office)