changeset 27168:463ed40d4031

Deal with buddies on MSN more gracefully. Look ahead to see if we have information about the protocol of the buddy, because by the time we process the protocol, we may have done too many other things, e.g. update status, set idleness etc., which means the real buddy doesn't get updated properly.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 24 Jun 2009 08:17:33 +0000
parents e3150217e1b4
children fa2fb12b0fcc
files libpurple/protocols/yahoo/yahoo.c
diffstat 1 files changed, 21 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/yahoo.c	Wed Jun 24 08:15:22 2009 +0000
+++ b/libpurple/protocols/yahoo/yahoo.c	Wed Jun 24 08:17:33 2009 +0000
@@ -182,8 +182,28 @@
 			name = message = NULL;
 			f = NULL;
 			if (pair->value && g_utf8_validate(pair->value, -1, NULL)) {
+				GSList *tmplist;
+				int protocol = 0;
+
 				name = pair->value;
+
+				/* Look ahead to see if we have the protocol info about the buddy */
+				for (tmplist = l->next; tmplist; tmplist = tmplist->next) {
+					struct yahoo_pair *p = tmplist->data;
+					if (p->key == 7)
+						break;
+					if (p->key == 241) {
+						if(strtol(p->value, NULL, 10) == 2) {
+							g_free(msn_name);
+							msn_name = g_strconcat("msn/", name, NULL);
+							name = msn_name;
+							protocol = 2;
+						}
+						break;
+					}
+				}
 				f = yahoo_friend_find_or_new(gc, name);
+				f->protocol = protocol;
 			}
 			break;
 		case 10: /* state */
@@ -331,12 +351,7 @@
 				f->version_id = strtol(pair->value, NULL, 10);
 			break;
 		case 241: /* protocol buddy belongs to */
-			if(strtol(pair->value, NULL, 10) == 2) {
-				g_free(msn_name);
-				msn_name = g_strconcat("msn/", name, NULL);
-				name = msn_name;
-			}
-			break;
+			break;  /* We process this when get '7' */
 		default:
 			purple_debug_warning("yahoo",
 					   "Unknown status key %d\n", pair->key);