changeset 19301:5f2c062cc40c

merge of '248776630a5ac63bd46aba2e4fd73d05f06098e0' and '94297ecf31d12a6bbabd789e067e758d486a69f3'
author Luke Schierer <lschiere@pidgin.im>
date Fri, 17 Aug 2007 12:45:10 +0000
parents c4d72aa4a52d (diff) b748d2408661 (current diff)
children 83ede25a3491 9e9f3442764c
files
diffstat 3 files changed, 69 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Aug 17 04:29:36 2007 +0000
+++ b/ChangeLog	Fri Aug 17 12:45:10 2007 +0000
@@ -6,7 +6,7 @@
 	* Added support for Unicode status messages in Yahoo.
 	* Server-stored aliases for Yahoo. (John Moody)
 	* Fixed support for Yahoo! doodling.
-	* Support for MSN Messenger contacts
+	* Limited support for MSN Messenger contacts
 	
 	Bonjour:
 	* Bonjour plugin uses native Avahi instead of Howl
--- a/libpurple/protocols/yahoo/yahoo.c	Fri Aug 17 04:29:36 2007 +0000
+++ b/libpurple/protocols/yahoo/yahoo.c	Fri Aug 17 12:45:10 2007 +0000
@@ -950,11 +950,21 @@
 	char *id;
 	char *who;
 	char *msg;
+	int protocol;
 };
 
 static void
 yahoo_buddy_add_authorize_cb(gpointer data) {
 	struct yahoo_add_request *add_req = data;
+
+	struct yahoo_packet *pkt;
+	struct yahoo_data *yd = add_req->gc->proto_data;
+
+	pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, YAHOO_STATUS_AVAILABLE, 0);
+	yahoo_packet_hash(pkt, "ssiii", 1, add_req->id, 5, add_req->who, 241, add_req->protocol,
+	                  13, 1, 334, 0);
+	yahoo_packet_send_and_free(pkt, yd);
+	
 	g_free(add_req->id);
 	g_free(add_req->who);
 	g_free(add_req->msg);
@@ -1008,6 +1018,54 @@
 			add_req);
 }
 
+static void yahoo_buddy_auth_req_15(PurpleConnection *gc, struct yahoo_packet *pkt) {
+	struct yahoo_add_request *add_req;
+	char *msg = NULL;
+	GSList *l = pkt->hash;
+
+	add_req = g_new0(struct yahoo_add_request, 1);
+	add_req->gc = gc;
+
+	while (l) {
+		struct yahoo_pair *pair = l->data;
+
+		switch (pair->key) {
+		case 5:
+			add_req->id = g_strdup(pair->value);
+			break;
+		case 4:
+			add_req->who = g_strdup(pair->value);
+			break;
+		case 241:
+			add_req->protocol = strtol(pair->value, NULL, 10);
+			break;
+		case 14:
+			msg = pair->value;
+			break;
+		}
+		l = l->next;
+	}
+
+	if (add_req->id) {
+		if (msg)
+			add_req->msg = yahoo_string_decode(gc, msg, FALSE);
+
+		/* DONE! this is almost exactly the same as what MSN does,
+		 * this should probably be moved to the core.
+		 */
+		 purple_account_request_authorization(purple_connection_get_account(gc), add_req->who, add_req->id,
+                                                    NULL, add_req->msg, purple_find_buddy(purple_connection_get_account(gc),add_req->who) != NULL,
+						    yahoo_buddy_add_authorize_cb,
+						    yahoo_buddy_add_deny_reason_cb,
+                                                    add_req);
+	} else {
+		g_free(add_req->id);
+		g_free(add_req->who);
+		/*g_free(add_req->msg);*/
+		g_free(add_req);
+	}
+}
+
 static void yahoo_buddy_added_us(PurpleConnection *gc, struct yahoo_packet *pkt) {
 	struct yahoo_add_request *add_req;
 	char *msg = NULL;
@@ -2205,6 +2263,9 @@
 	case YAHOO_SERVICE_AUTH:
 		yahoo_process_auth(gc, pkt);
 		break;
+	case YAHOO_SERVICE_AUTH_REQ_15:
+		yahoo_buddy_auth_req_15(gc, pkt);
+		break;	       
 	case YAHOO_SERVICE_ADDBUDDY:
 		yahoo_process_addbuddy(gc, pkt);
 		break;
@@ -3664,13 +3725,16 @@
 	PurpleGroup *g;
 	char *group = NULL;
 	char *group2 = NULL;
-
+	YahooFriend *f;
+	
 	if (!yd->logged_in)
 		return;
 
 	if (!yahoo_privacy_check(gc, purple_buddy_get_name(buddy)))
 		return;
 
+	f = yahoo_friend_find(gc, purple_buddy_get_name(buddy));
+	
 	if (foo)
 		group = foo->name;
 	if (!group) {
@@ -3695,6 +3759,8 @@
 	                  301, "319",
 	                  303, "319"
 	);
+	if (f && f->protocol)
+		yahoo_packet_hash_int(pkt, 241, f->protocol);
 	yahoo_packet_send_and_free(pkt, yd);
 	g_free(group2);
 }
--- a/libpurple/protocols/yahoo/yahoo_packet.h	Fri Aug 17 04:29:36 2007 +0000
+++ b/libpurple/protocols/yahoo/yahoo_packet.h	Fri Aug 17 12:45:10 2007 +0000
@@ -98,6 +98,7 @@
 	YAHOO_SERVICE_AVATAR_UPDATE = 0xc7,
 	YAHOO_SERVICE_VERIFY_ID_EXISTS = 0xc8,
 	YAHOO_SERVICE_AUDIBLE = 0xd0,
+	YAHOO_SERVICE_AUTH_REQ_15 = 0xd6,
 	YAHOO_SERVICE_CHGRP_15 = 0xe7,
 	YAHOO_SERVICE_STATUS_15 = 0xf0,
 	YAHOO_SERVICE_LIST_15 = 0Xf1,