Mercurial > pidgin.yaz
changeset 19299:b3a5e7c45b5c
Allow you to authorize msn buddies to add your yahoo account.
Allow you to add msn buddies to your list if you're previously
have conversed with them.
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Sun, 22 Jul 2007 07:30:50 +0000 |
parents | 2ec9d975a37d |
children | c4d72aa4a52d |
files | libpurple/protocols/yahoo/yahoo.c libpurple/protocols/yahoo/yahoo_packet.h |
diffstat | 2 files changed, 68 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/yahoo.c Fri Aug 17 00:35:12 2007 +0000 +++ b/libpurple/protocols/yahoo/yahoo.c Sun Jul 22 07:30:50 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 00:35:12 2007 +0000 +++ b/libpurple/protocols/yahoo/yahoo_packet.h Sun Jul 22 07:30:50 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,