changeset 17955:9e8943111022

Show official client build in buddy profiles.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Thu, 19 Jul 2007 04:33:40 +0000
parents 016f9b2d6ee0
children 60f40fc52aa4
files libpurple/protocols/myspace/myspace.c libpurple/protocols/myspace/myspace.h
diffstat 2 files changed, 37 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/myspace/myspace.c	Thu Jul 19 04:09:33 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Thu Jul 19 04:33:40 2007 +0000
@@ -1090,6 +1090,41 @@
     return markup;
 }
 
+/** Record the client version in the buddy list, from an incoming message. */
+gboolean
+msim_incoming_bm_record_cv(MsimSession *session, MsimMessage *msg)
+{
+    gchar *username, *cv;
+    gboolean ret;
+    PurpleBuddy *buddy;
+    gchar *client_info;
+
+
+    username = msim_msg_get_string(msg, "_username");
+    cv = msim_msg_get_string(msg, "cv");
+
+    g_return_val_if_fail(username != NULL, FALSE);
+    g_return_val_if_fail(cv != NULL, FALSE);
+
+    buddy = purple_find_buddy(session->account, username);
+
+    if (buddy)
+    {
+        client_info = g_strdup_printf("MySpaceIM build %s", cv);
+
+        purple_blist_node_set_string(&buddy->node, "client", client_info);
+        /* Do not free client_info - blist owns */
+        ret = TRUE;
+    } else {
+        ret = FALSE;
+    }
+
+    g_free(username);
+    g_free(cv);
+
+    return ret;
+}
+
 /** Handle an incoming buddy message. */
 gboolean
 msim_incoming_bm(MsimSession *session, MsimMessage *msg)
@@ -1098,11 +1133,7 @@
    
     bm = msim_msg_get_integer(msg, "bm");
 
-    if (msim_msg_get(msg, "cv"))
-    {
-        purple_debug_info("msim_incoming_bm", "cv=%s",
-                msim_msg_get_string(msg, "cv"));
-    }
+    msim_incoming_bm_record_cv(session, msg);
 
     switch (bm)
     {
--- a/libpurple/protocols/myspace/myspace.h	Thu Jul 19 04:09:33 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.h	Thu Jul 19 04:33:40 2007 +0000
@@ -241,6 +241,7 @@
 gchar *msim_markup_to_html(MsimSession *, const gchar *raw);
 gchar *html_to_msim_markup(MsimSession *, const gchar *raw);
 
+gboolean msim_incoming_bm_record_cv(MsimSession *session, MsimMessage *msg);
 gboolean msim_incoming_bm(MsimSession *session, MsimMessage *msg);
 gboolean msim_incoming_status(MsimSession *session, MsimMessage *msg);
 gboolean msim_incoming_im(MsimSession *session, MsimMessage *msg);