diff libpurple/protocols/myspace/myspace.c @ 19429:5e2a2fc55631

Lookup a user's information when their status changes to anything but offline. Now their information (including buddy icon, if any) will be available without explicitly requesting it with Get Info. Closes #2724.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Sun, 26 Aug 2007 01:08:39 +0000
parents 1fa10842eb83
children 0104035fd510
line wrap: on
line diff
--- a/libpurple/protocols/myspace/myspace.c	Sat Aug 25 23:05:57 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Sun Aug 26 01:08:39 2007 +0000
@@ -2712,7 +2712,8 @@
 				NULL, 0, NULL);
 			return;
 		}
-		
+	
+		/* TODO: use ETag for checksum */
 		previous_url = purple_buddy_icons_get_checksum_for_user(user->buddy);
 
 		/* Only download if URL changed */
@@ -3053,9 +3054,9 @@
 			break;
 
 		default:
-				purple_debug_info("msim", "msim_status for %s, unknown status code %d, treating as available\n",
+			purple_debug_info("msim", "msim_status for %s, unknown status code %d, treating as available\n",
 						username, status_code);
-				purple_status_code = PURPLE_STATUS_AVAILABLE;
+			purple_status_code = PURPLE_STATUS_AVAILABLE;
 	}
 
 	purple_prpl_got_user_status(session->account, username, purple_primitive_get_id_from_type(purple_status_code), NULL);
@@ -3075,6 +3076,14 @@
 	}
 #endif
 
+	if (status_code != MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN) {
+		/* Get information when they come online.
+		 * TODO: periodically refresh?
+		 */
+		purple_debug_info("msim_incoming_status", "%s came online, looking up\n", username);
+		msim_lookup_user(session, username, NULL, NULL);
+	}
+
 	g_free(username);
 	msim_msg_list_free(list);
 
@@ -3764,8 +3773,7 @@
  */
 /* TODO: change to not use callbacks */
 static void 
-msim_lookup_user(MsimSession *session, const gchar *user, 
-		MSIM_USER_LOOKUP_CB cb, gpointer data)
+msim_lookup_user(MsimSession *session, const gchar *user, MSIM_USER_LOOKUP_CB cb, gpointer data)
 {
 	MsimMessage *body;
 	gchar *field_name;
@@ -3773,7 +3781,8 @@
 
 	g_return_if_fail(MSIM_SESSION_VALID(session));
 	g_return_if_fail(user != NULL);
-	g_return_if_fail(cb != NULL);
+	/* Callback can be null to not call anything, just lookup & store information. */
+	/*g_return_if_fail(cb != NULL);*/
 
 	purple_debug_info("msim", "msim_lookup_userid: "
 			"asynchronously looking up <%s>\n", user);