pidgin: 7e2bf94f: Don't create a temporary PurpleBuddy whe...

markdoliner at pidgin.im markdoliner at pidgin.im
Thu Dec 11 23:05:35 EST 2008


-----------------------------------------------------------------
Revision: 7e2bf94f266d33384815fb9d3128f997c7df6b97
Ancestor: e75b094fb3636667360c46a4eb03b6974912d0ac
Author: markdoliner at pidgin.im
Date: 2008-12-12T03:46:36
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/7e2bf94f266d33384815fb9d3128f997c7df6b97

Modified files:
        libpurple/protocols/myspace/myspace.c
        libpurple/protocols/myspace/user.c

ChangeLog: 

Don't create a temporary PurpleBuddy when getting info for someone not
on your buddy list.

This breaks two things:
* No more "View web profile" link when viewing info for people not
  in your buddy list.
* No song or band info when viewing info for people not in your buddy
  list

But I think it's for the best.  We could always implement those features
slightly differently and add the functionality back.

-------------- next part --------------
============================================================
--- libpurple/protocols/myspace/myspace.c	53e991fd71717ecc3d025854d2635039c5ed5696
+++ libpurple/protocols/myspace/myspace.c	092128494d76c42d7b21e5bf322d99d15d72ea64
@@ -980,15 +980,8 @@ msim_get_info_cb(MsimSession *session, M
 
 	if (!user) {
 		/* User isn't on blist, create a temporary user to store info. */
-		/* TODO: is this legit, or is it somehow responsible for #3444? */
-		PurpleBuddy *buddy;
-
 		user = g_new0(MsimUser, 1);
 		user->temporary_user = TRUE;
-
-		buddy = purple_buddy_new(session->account, username, NULL);
-		user->buddy = buddy;
-		buddy->proto_data = (gpointer)user;
 	}
 
 	/* Update user structure with new information */
@@ -1005,7 +998,6 @@ msim_get_info_cb(MsimSession *session, M
 	purple_notify_user_info_destroy(user_info);
 
 	if (user->temporary_user) {
-		purple_blist_remove_buddy(user->buddy);
 		g_free(user->client_info);
 		g_free(user->gender);
 		g_free(user->location);
============================================================
--- libpurple/protocols/myspace/user.c	801fecf4d8e08f68b1bbf3100a9e4732eef288b7
+++ libpurple/protocols/myspace/user.c	33a9e05ef8de35a7d658fda2e4761f614ebf523f
@@ -105,8 +105,6 @@ msim_append_user_info(MsimSession *sessi
 		purple_notify_user_info_add_pair(user_info, _("User"), user->username);
 	}
 
-	uid = purple_blist_node_get_int(&user->buddy->node, "UserID");
-
 	/* a/s/l...the vitals */
 	if (user->age) {
 		char age[16];
@@ -127,21 +125,23 @@ msim_append_user_info(MsimSession *sessi
 		purple_notify_user_info_add_pair(user_info, _("Headline"), user->headline);
 	}
 
-	presence = purple_buddy_get_presence(user->buddy);
+	if (user->buddy != NULL) {
+		presence = purple_buddy_get_presence(user->buddy);
 
-	if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
-		PurpleStatus *status;
-		const char *artist, *title;
-		
-		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);
+		if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
+			PurpleStatus *status;
+			const char *artist, *title;
 
-		str = msim_format_now_playing(artist, title);
-		if (str && *str) {
-			purple_notify_user_info_add_pair(user_info, _("Song"), str);
+			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);
+
+			str = msim_format_now_playing(artist, title);
+			if (str && *str) {
+				purple_notify_user_info_add_pair(user_info, _("Song"), str);
+			}
+			g_free(str);
 		}
-		g_free(str);
 	}
 
 	/* Note: total friends only available if looked up by uid, not username. */
@@ -170,6 +170,7 @@ msim_append_user_info(MsimSession *sessi
 		g_free(client);
 	}
 
+	uid = user->buddy ? purple_blist_node_get_int(&user->buddy->node, "UserID") : 0;
 	if (full && uid) {
 		/* TODO: link to username, if available */
 		char *profile;
@@ -199,12 +200,16 @@ static void msim_set_artist_or_title(Msi
 	PurplePresence *presence;
 	const char *prev_artist, *prev_title;
 
+	if (user->buddy == NULL)
+		/* User not on buddy list so nothing to do */
+		return;
+
 	prev_artist = NULL;
 	prev_title = NULL;
 
-	if (new_artist && !strlen(new_artist))
+	if (new_artist && !*new_artist)
 		new_artist = NULL;
-	if (new_title && !strlen(new_title))
+	if (new_title && !*new_title)
 		new_title = NULL;
 
 	if (!new_artist && !new_title) {


More information about the Commits mailing list