soc.2008.yahoo: 18c8a3d8: MSN Interoperability, add, remove buddie...

sulabh at soc.pidgin.im sulabh at soc.pidgin.im
Wed Aug 20 17:45:56 EDT 2008


-----------------------------------------------------------------
Revision: 18c8a3d858cd631066dac2baa70d8ca8eacd19a2
Ancestor: bbdbeeeb5d58de71c36f7e97931e444706dc0db8
Author: sulabh at soc.pidgin.im
Date: 2008-08-20T21:11:56
Branch: im.pidgin.soc.2008.yahoo
URL: http://d.pidgin.im/viewmtn/revision/info/18c8a3d858cd631066dac2baa70d8ca8eacd19a2

Modified files:
        libpurple/protocols/yahoo/yahoo.c
        libpurple/protocols/yahoo/yahoo_friend.c

ChangeLog: 

MSN Interoperability, add, remove buddies, change group, send im, etc

-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/yahoo.c	ffa970fcb1cc342a8c23c3f0927fdcbf599821e7
+++ libpurple/protocols/yahoo/yahoo.c	28aed03da31c8370552476e9079a9c7456c5271d
@@ -2283,6 +2283,7 @@ static void yahoo_process_addbuddy(Purpl
 	YahooFriend *f;
 	GSList *l = pkt->hash;
 	struct yahoo_data *yd = gc->proto_data;
+	int protocol = 0;
 
 	while (l) {
 		struct yahoo_pair *pair = l->data;
@@ -2297,6 +2298,9 @@ static void yahoo_process_addbuddy(Purpl
 		case 65:
 			group = pair->value;
 			break;
+		case 241:
+			protocol = strtol(pair->value, NULL, 10);
+			break;
 		}
 
 		l = l->next;
@@ -2310,7 +2314,9 @@ static void yahoo_process_addbuddy(Purpl
 	if (!err || (err == 2)) { /* 0 = ok, 2 = already on serv list */
 		f = yahoo_friend_find_or_new(gc, who);
 		yahoo_update_status(gc, who, f);
-		
+		if(protocol)
+			f->protocol = protocol;
+
 		if( !g_hash_table_lookup(yd->peers, who) )	{
 			/* we are not connected as client, so set friend to not connected */
 			yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_NOT_CONNECTED);
@@ -4344,6 +4350,9 @@ static int yahoo_send_im(PurpleConnectio
 	yahoo_packet_hash(pkt, "ss", 1, purple_connection_get_display_name(gc), 5, who);
 	if ((f = yahoo_friend_find(gc, who)) && f->protocol)
 		yahoo_packet_hash_int(pkt, 241, f->protocol);
+	else
+		if(strchr(who,'@'))
+			yahoo_packet_hash_int(pkt, 241, 2);
 
 	if (utf8)
 		yahoo_packet_hash_str(pkt, 97, "1");
@@ -4664,18 +4673,36 @@ static void yahoo_add_buddy(PurpleConnec
 
 	group2 = yahoo_string_encode(gc, group, NULL);
 	pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0);
-	yahoo_packet_hash(pkt, "ssssssssss",
-	                  14, "",
-	                  65, group2,
-	                  97, "1",
-	                  1, purple_connection_get_display_name(gc),
-	                  302, "319",
-	                  300, "319",
-	                  7, buddy->name,
-	                  334, "0",
-	                  301, "319",
-	                  303, "319"
-	);
+	if(strchr(buddy->name, '@'))	{
+		yahoo_packet_hash(pkt, "sssssssssss",
+			14, "",
+			65, group2,
+			97, "1",
+			1, purple_connection_get_display_name(gc),
+			302, "319",
+			300, "319",
+			7, buddy->name,
+			241, "2",
+			334, "0",
+			301, "319",
+			303, "319"
+		);
+	}
+	else	{
+		yahoo_packet_hash(pkt, "ssssssssss",
+			14, "",
+			65, group2,
+			97, "1",
+			1, purple_connection_get_display_name(gc),
+			302, "319",
+			300, "319",
+			7, buddy->name,
+			334, "0",
+			301, "319",
+			303, "319"
+		);
+	}
+
 	if (f && f->protocol)
 		yahoo_packet_hash_int(pkt, 241, f->protocol);
 	yahoo_packet_send_and_free(pkt, yd);
@@ -4690,8 +4717,9 @@ static void yahoo_remove_buddy(PurpleCon
 	PurpleGroup *g;
 	gboolean remove = TRUE;
 	char *cg;
+	YahooFriend *f = yahoo_friend_find(gc, buddy->name);
 
-	if (!(yahoo_friend_find(gc, buddy->name)))
+	if (!f)
 		return;
 
 	buddies = purple_find_buddies(purple_connection_get_account(gc), buddy->name);
@@ -4712,6 +4740,8 @@ static void yahoo_remove_buddy(PurpleCon
 	pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0);
 	yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc),
 	                  7, buddy->name, 65, cg);
+	if(f->protocol)
+		yahoo_packet_hash_int(pkt, 241, f->protocol);
 	yahoo_packet_send_and_free(pkt, yd);
 	g_free(cg);
 }
@@ -4784,11 +4814,12 @@ static void yahoo_change_buddys_group(Pu
 	struct yahoo_data *yd = gc->proto_data;
 	struct yahoo_packet *pkt;
 	char *gpn, *gpo;
+	YahooFriend *f = yahoo_friend_find(gc, who);
 
 	/* Step 0:  If they aren't on the server list anyway,
 	 *          don't bother letting the server know.
 	 */
-	if (!yahoo_friend_find(gc, who))
+	if (!f)
 		return;
 
 	/* If old and new are the same, we would probably
@@ -4804,7 +4835,12 @@ static void yahoo_change_buddys_group(Pu
 	}
 
 	pkt = yahoo_packet_new(YAHOO_SERVICE_CHGRP_15, YAHOO_STATUS_AVAILABLE, 0);
-	yahoo_packet_hash(pkt, "ssssssss", 1, purple_connection_get_display_name(gc),
+	if(f->protocol)
+		yahoo_packet_hash(pkt, "ssssissss", 1, purple_connection_get_display_name(gc),
+	                  302, "240", 300, "240", 7, who, 241, f->protocol, 224, gpo, 264, gpn, 301,
+	                  "240", 303, "240");
+	else
+		yahoo_packet_hash(pkt, "ssssssss", 1, purple_connection_get_display_name(gc),
 	                  302, "240", 300, "240", 7, who, 224, gpo, 264, gpn, 301,
 	                  "240", 303, "240");
 	yahoo_packet_send_and_free(pkt, yd);
============================================================
--- libpurple/protocols/yahoo/yahoo_friend.c	aaa79a1b58850f099b567d97be629c2084fff795
+++ libpurple/protocols/yahoo/yahoo_friend.c	5333ac154a27e69f136b25d3cd583468cdb4d861
@@ -236,12 +236,21 @@ void yahoo_friend_update_presence(Purple
 		if (f->presence == YAHOO_PRESENCE_PERM_OFFLINE) {
 			pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_PERM,
 					YAHOO_STATUS_AVAILABLE, yd->session_id);
-			yahoo_packet_hash(pkt, "ssssssss",
+			if(f->protocol)
+				yahoo_packet_hash(pkt, "ssssssiss",
 					1, purple_connection_get_display_name(gc),
 					31, "2", 13, "2",
 					302, "319", 300, "319",
+					7, name, 241, f->protocol,
+					301, "319", 303, "319");
+			else
+				yahoo_packet_hash(pkt, "ssssssss",
+					1, purple_connection_get_display_name(gc),
+					31, "2", 13, "2",
+					302, "319", 300, "319",
 					7, name,
 					301, "319", 303, "319");
+
 			yahoo_packet_send_and_free(pkt, yd);
 		}
 
@@ -254,10 +263,18 @@ void yahoo_friend_update_presence(Purple
 		pkt = yahoo_packet_new(service,
 				YAHOO_STATUS_AVAILABLE, yd->session_id);
 
-		yahoo_packet_hash(pkt, "ssssssss",
+		if(f->protocol)
+			yahoo_packet_hash(pkt, "ssssssiss",
 				1, purple_connection_get_display_name(gc),
 				31, thirtyone, 13, thirteen,
 				302, "319", 300, "319",
+				7, name, 241, f->protocol,
+				301, "319", 303, "319");
+		else
+			yahoo_packet_hash(pkt, "ssssssss",
+				1, purple_connection_get_display_name(gc),
+				31, thirtyone, 13, thirteen,
+				302, "319", 300, "319",
 				7, name,
 				301, "319", 303, "319");
 


More information about the Commits mailing list