changeset 14258:cb2714fdf274

[gaim-migrate @ 16940] up the protocol version, handle the new buddy list message (which i renamed the service for again), pretend auth type 2 is auth type 1, note when a buddy is an msn buddy, and possibly even send msn buddy messages correctly. I haven't really tested if everything works with the new protocol version, but I can always lower it again if bad things start happening and I don't have time to fix them before the release. I don't know if sending messages to msn users really works or not, it seems to be down server side at the moment. Someone test when msn gets it working again :P There's no way to add msn contacts to your yahoo account from within gaim. Not sure how we'll do the UI for that. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Mon, 21 Aug 2006 04:12:07 +0000
parents 14933d9055a0
children 0ac0f16aa006
files libgaim/protocols/yahoo/yahoo.c libgaim/protocols/yahoo/yahoo_friend.h libgaim/protocols/yahoo/yahoo_packet.h
diffstat 3 files changed, 71 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libgaim/protocols/yahoo/yahoo.c	Mon Aug 21 04:06:33 2006 +0000
+++ b/libgaim/protocols/yahoo/yahoo.c	Mon Aug 21 04:12:07 2006 +0000
@@ -469,6 +469,65 @@
 	}
 }
 
+static void yahoo_process_list_15(GaimConnection *gc, struct yahoo_packet *pkt)
+{
+	GSList *l = pkt->hash;
+
+	GaimAccount *account = gaim_connection_get_account(gc);
+	GHashTable *ht;
+	char *grp = NULL;
+	char *norm_bud = NULL;
+
+	ht = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_slist_free);
+
+	while (l) {
+		struct yahoo_pair *pair = l->data;
+		YahooFriend *f = NULL; /* It's your friends. They're going to want you to share your StarBursts. */
+		                       /* But what if you had no friends? */
+		GaimBuddy *b;
+		GaimGroup *g;
+
+
+		l = l->next;
+
+		switch (pair->key) {
+		case 302: /* what is this? it's always 318 before a group, 319 before a s/n */
+		case 300: /* ditto */
+			break;
+		case 65: /* This is the group */
+			g_free(grp);
+			grp = yahoo_string_decode(gc, pair->value, FALSE);
+			break;
+		case 7: /* buddy's s/n */
+			g_free(norm_bud);
+			norm_bud = g_strdup(gaim_normalize(account, pair->value));
+			f = yahoo_friend_find_or_new(gc, norm_bud);
+			if (!(b = gaim_find_buddy(account, norm_bud))) {
+				if (!(g = gaim_find_group(grp))) {
+					g = gaim_group_new(grp);
+					gaim_blist_add_group(g, NULL);
+				}
+				b = gaim_buddy_new(account, norm_bud, NULL);
+				gaim_blist_add_buddy(b, NULL, g, NULL);
+			}
+			yahoo_do_group_check(account, ht, norm_bud, grp);
+
+			break;
+		case 241: /* msn user */
+			if (f && *pair->value == '1')
+				f->msn = TRUE;
+			break;
+		/* case 242: */ /* this seems related to 241 */
+			/* break; */
+		}
+	}
+
+	g_hash_table_foreach(ht, yahoo_do_group_cleanup, NULL);
+	g_hash_table_destroy(ht);
+	g_free(grp);
+	g_free(norm_bud);
+}
+
 static void yahoo_process_list(GaimConnection *gc, struct yahoo_packet *pkt)
 {
 	GSList *l = pkt->hash;
@@ -1710,6 +1769,7 @@
 			yahoo_process_auth_old(gc, seed);
 			break;
 		case 1:
+		case 2: /* This case seems to work, could probably use testing */
 			yahoo_process_auth_new(gc, seed);
 			break;
 		default:
@@ -2042,6 +2102,7 @@
 	case YAHOO_SERVICE_CHATLOGON:
 	case YAHOO_SERVICE_CHATLOGOFF:
 	case YAHOO_SERVICE_Y6_STATUS_UPDATE:
+	case YAHOO_SERVICE_STATUS_15:
 		yahoo_process_status(gc, pkt);
 		break;
 	case YAHOO_SERVICE_NOTIFY:
@@ -2067,6 +2128,9 @@
 	case YAHOO_SERVICE_LIST:
 		yahoo_process_list(gc, pkt);
 		break;
+	case YAHOO_SERVICE_LIST_15:
+		yahoo_process_list_15(gc, pkt);
+		break;
 	case YAHOO_SERVICE_AUTH:
 		yahoo_process_auth(gc, pkt);
 		break;
@@ -3121,10 +3185,14 @@
 	gboolean utf8 = TRUE;
 	GaimWhiteboard *wb;
 	int ret = 1;
+	YahooFriend *f = NULL;
 
 	msg2 = yahoo_string_encode(gc, msg, &utf8);
 
 	yahoo_packet_hash(pkt, "ss", 1, gaim_connection_get_display_name(gc), 5, who);
+	if ((f = yahoo_friend_find(gc, who)) && f->msn)
+		yahoo_packet_hash_str(pkt, 241, "1");
+
 	if (utf8)
 		yahoo_packet_hash_str(pkt, 97, "1");
 	yahoo_packet_hash_str(pkt, 14, msg2);
--- a/libgaim/protocols/yahoo/yahoo_friend.h	Mon Aug 21 04:06:33 2006 +0000
+++ b/libgaim/protocols/yahoo/yahoo_friend.h	Mon Aug 21 04:12:07 2006 +0000
@@ -47,6 +47,7 @@
 	char *ip;
 	gboolean bicon_sent_request;
 	YahooPresenceVisibility presence;
+	gboolean msn;
 } YahooFriend;
 
 YahooFriend *yahoo_friend_find(GaimConnection *gc, const char *name);
--- a/libgaim/protocols/yahoo/yahoo_packet.h	Mon Aug 21 04:06:33 2006 +0000
+++ b/libgaim/protocols/yahoo/yahoo_packet.h	Mon Aug 21 04:12:07 2006 +0000
@@ -98,7 +98,7 @@
 	YAHOO_SERVICE_VERIFY_ID_EXISTS = 0xc8,
 	YAHOO_SERVICE_AUDIBLE = 0xd0,
 	YAHOO_SERVICE_STATUS_15 = 0xf0,
-	YAHOO_SERVICE_BUDDYLIST_15 = 0Xf1,
+	YAHOO_SERVICE_LIST_15 = 0Xf1,
 	YAHOO_SERVICE_WEBLOGIN = 0x0226,
 	YAHOO_SERVICE_SMS_MSG = 0x02ea
 };
@@ -116,7 +116,7 @@
 };
 
 #define YAHOO_WEBMESSENGER_PROTO_VER 0x0065
-#define YAHOO_PROTO_VER 0x000c
+#define YAHOO_PROTO_VER 0x000f
 
 #define YAHOO_PACKET_HDRLEN (4 + 2 + 2 + 2 + 2 + 4 + 4)