diff libpurple/protocols/yahoo/yahoo_friend.c @ 28364:61856d0a2714

Handle adding Lotus Sametime and Microsoft OCS buddies to Yahoo! accounts. Fixes #9814, #9983 committer: John Bailey <rekkanoryo@rekkanoryo.org>
author kryojenik23-pidgin@steltek.com
date Mon, 12 Oct 2009 05:01:17 +0000
parents 908be3822215
children d1cecbc467c6
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/yahoo_friend.c	Sat Oct 10 22:58:28 2009 +0000
+++ b/libpurple/protocols/yahoo/yahoo_friend.c	Mon Oct 12 05:01:17 2009 +0000
@@ -151,9 +151,8 @@
 	char *temp = NULL;
 	char *who = NULL;
 	int value = 0;
-	int protocol = 0;
-	gboolean msn = FALSE;
-
+	YahooFederation fed = YAHOO_FEDERATION_NONE;
+	
 	while (l) {
 		struct yahoo_pair *pair = l->data;
 
@@ -165,8 +164,7 @@
 				value = strtol(pair->value, NULL, 10);
 				break;
 			case 241:
-				protocol = strtol(pair->value, NULL, 10);
-				msn = TRUE;
+				fed = strtol(pair->value, NULL, 10);
 				break;
 		}
 
@@ -177,12 +175,21 @@
 		purple_debug_error("yahoo", "Received unknown value for presence key: %d\n", value);
 		return;
 	}
-
-	if(msn)
-		who = g_strconcat("msn/", temp, NULL);
-	else
-		who = g_strdup(temp);
-
+	
+	switch (fed) {
+		case YAHOO_FEDERATION_MSN:
+			who = g_strconcat("msn/", temp, NULL);
+			break;
+		case YAHOO_FEDERATION_OCS:
+			who = g_strconcat("ocs/", temp, NULL);
+			break;
+		case YAHOO_FEDERATION_IBM:
+			who = g_strconcat("ibm/", temp, NULL);
+			break;
+		case YAHOO_FEDERATION_NONE:
+			who = g_strdup(temp);
+			break;
+	}
 	g_return_if_fail(who != NULL);
 
 	f = yahoo_friend_find(gc, who);
@@ -228,12 +235,12 @@
 	f = yahoo_friend_find(gc, name);
 	if (!f)
 		return;
-
-	if(f->protocol == 2)
+	
+	if(f->fed != YAHOO_FEDERATION_NONE)
 		temp = name+4;
 	else
 		temp = name;
-
+    
 	/* No need to change the value if it is already correct */
 	if (f->presence == presence) {
 		purple_debug_info("yahoo", "Not setting presence because there are no changes.\n");
@@ -258,12 +265,12 @@
 		if (f->presence == YAHOO_PRESENCE_PERM_OFFLINE) {
 			pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_PERM,
 					YAHOO_STATUS_AVAILABLE, yd->session_id);
-			if(f->protocol)
+			if(f->fed)
 				yahoo_packet_hash(pkt, "ssssssiss",
 					1, purple_connection_get_display_name(gc),
 					31, "2", 13, "2",
 					302, "319", 300, "319",
-					7, temp, 241, f->protocol,
+					7, temp, 241, f->fed,
 					301, "319", 303, "319");
 			else
 				yahoo_packet_hash(pkt, "ssssssss",
@@ -285,12 +292,12 @@
 		pkt = yahoo_packet_new(service,
 				YAHOO_STATUS_AVAILABLE, yd->session_id);
 
-		if(f->protocol)
+		if(f->fed)
 			yahoo_packet_hash(pkt, "ssssssiss",
 				1, purple_connection_get_display_name(gc),
 				31, thirtyone, 13, thirteen,
 				302, "319", 300, "319",
-				7, temp, 241, f->protocol,
+				7, temp, 241, f->fed,
 				301, "319", 303, "319");
 		else
 			yahoo_packet_hash(pkt, "ssssssss",