Changeset ba16895


Ignore:
Timestamp:
2009-10-10T13:48:44Z (15 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
037b66a
Parents:
fa295e36
Message:

More Yahoo! fixes: Adding and removing buddies works, and for the first
time buddy add requests are actually handled; from what I can see this
simply didn't exist in libyahoo2 yet so far. :-(

I melded pieces of changes from http://geny.sf.net/ to make this stuff
work.

Location:
protocols/yahoo
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • protocols/yahoo/libyahoo2.c

    rfa295e36 rba16895  
    212212        YAHOO_SERVICE_CHATPING,
    213213        YAHOO_SERVICE_COMMENT = 0xa8,
    214         YAHOO_SERVICE_GAME_INVITE = 0xb7,
    215         YAHOO_SERVICE_STEALTH_PERM = 0xb9,
    216         YAHOO_SERVICE_STEALTH_SESSION = 0xba,
    217         YAHOO_SERVICE_AVATAR = 0xbc,
     214        YAHOO_SERVICE_STEALTH = 0xb9,
    218215        YAHOO_SERVICE_PICTURE_CHECKSUM = 0xbd,
    219216        YAHOO_SERVICE_PICTURE = 0xbe,
    220217        YAHOO_SERVICE_PICTURE_UPDATE = 0xc1,
    221218        YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2,
    222         YAHOO_SERVICE_YAB_UPDATE = 0xc4,
    223         YAHOO_SERVICE_Y6_VISIBLE_TOGGLE = 0xc5, /* YMSG13, key 13: 2 = invisible, 1 = visible */
    224         YAHOO_SERVICE_Y6_STATUS_UPDATE = 0xc6,  /* YMSG13 */
    225         YAHOO_SERVICE_PICTURE_STATUS = 0xc7,    /* YMSG13, key 213: 0 = none, 1 = avatar, 2 = picture */
    226         YAHOO_SERVICE_VERIFY_ID_EXISTS = 0xc8,
    227         YAHOO_SERVICE_AUDIBLE = 0xd0,
    228         YAHOO_SERVICE_Y7_PHOTO_SHARING = 0xd2,
    229         YAHOO_SERVICE_Y7_CONTACT_DETAILS = 0xd3,/* YMSG13 */
    230         YAHOO_SERVICE_Y7_CHAT_SESSION = 0xd4,
    231         YAHOO_SERVICE_Y7_AUTHORIZATION = 0xd6,  /* YMSG13 */
    232         YAHOO_SERVICE_Y7_FILETRANSFER = 0xdc,   /* YMSG13 */
    233         YAHOO_SERVICE_Y7_FILETRANSFERINFO,      /* YMSG13 */
    234         YAHOO_SERVICE_Y7_FILETRANSFERACCEPT,    /* YMSG13 */
    235         YAHOO_SERVICE_Y7_MINGLE = 0xe1, /* YMSG13 */
    236         YAHOO_SERVICE_Y7_CHANGE_GROUP = 0xe7, /* YMSG13 */
    237         YAHOO_SERVICE_Y8_STATUS = 0xf0,                 /* YMSG15 */
    238         YAHOO_SERVICE_Y8_LIST = 0Xf1,                   /* YMSG15 */
    239         YAHOO_SERVICE_WEBLOGIN = 0x0226,
    240         YAHOO_SERVICE_SMS_MSG = 0x02ea
     219        YAHOO_SERVICE_Y6_VISIBILITY=0xc5,
     220        YAHOO_SERVICE_Y6_STATUS_UPDATE=0xc6,
     221        YAHOO_PHOTOSHARE_INIT=0xd2,     
     222        YAHOO_SERVICE_CONTACT_YMSG13=0xd6,
     223        YAHOO_PHOTOSHARE_PREV=0xd7,
     224        YAHOO_PHOTOSHARE_KEY=0xd8,
     225        YAHOO_PHOTOSHARE_TRANS=0xda,
     226        YAHOO_FILE_TRANSFER_INIT_YMSG13=0xdc,
     227        YAHOO_FILE_TRANSFER_GET_YMSG13=0xdd,
     228        YAHOO_FILE_TRANSFER_PUT_YMSG13=0xde,
     229        YAHOO_SERVICE_YMSG15_STATUS=0xf0,
     230        YAHOO_SERVICE_YMSG15_BUDDY_LIST=0xf1,
    241231};
    242232
     
    776766                yahoo_send_data(yid->fd, data, len);
    777767        else
    778         yahoo_add_to_send_queue(yid, data, len);
     768                yahoo_add_to_send_queue(yid, data, len);
    779769        FREE(data);
    780770}
     
    14961486
    14971487                if (u->name != NULL) {
    1498                         if (pkt->service == YAHOO_SERVICE_LOGOFF || u->flags == 0) {
     1488                        if (pkt->service == YAHOO_SERVICE_LOGOFF) { /* || u->flags == 0) { Not in YMSG16 */
    14991489                                YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0);
    15001490                        } else {
     1491                                /* Key 47 always seems to be 1 for YMSG16 */
     1492                                if(!u->state)
     1493                                        u->away = 0;
     1494                                else
     1495                                        u->away = 1;
     1496
    15011497                                YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, u->state, u->msg, u->away, u->idle, u->mobile);
    15021498                        }
     
    25152511               
    25162512                yd->buddies = y_list_append(yd->buddies, bud);
    2517                
     2513       
    25182514                /* Possibly called already, but at least the call above doesn't
    25192515                   seem to happen every time (not anytime I tried). */
     
    25222518
    25232519/*      YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, who, status, NULL, (status==YAHOO_STATUS_AVAILABLE?0:1)); */
     2520}
     2521
     2522static void yahoo_process_contact_ymsg13(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
     2523{
     2524        char* who=NULL;
     2525        char* me=NULL; 
     2526        char* msg=NULL;
     2527        YList *l;
     2528        for (l = pkt->hash; l; l = l->next) {
     2529                struct yahoo_pair *pair = l->data;
     2530                if (pair->key == 4)
     2531                        who = pair->value;
     2532                else if (pair->key == 5)
     2533                        me = pair->value;
     2534                else
     2535                        DEBUG_MSG(("unknown key: %d = %s", pair->key, pair->value));
     2536        }
     2537
     2538        if(pkt->status==3)
     2539                YAHOO_CALLBACK(ext_yahoo_contact_auth_request)(yid->yd->client_id, me, who, msg);
    25242540}
    25252541
     
    27352751
    27362752        YList *l;
    2737         yahoo_dump_unhandled(pkt);
     2753        // yahoo_dump_unhandled(pkt);
    27382754        for (l = pkt->hash; l; l = l->next) {
    27392755                struct yahoo_pair *pair = l->data;
     
    27572773{
    27582774        DEBUG_MSG(("yahoo_packet_process: 0x%02x", pkt->service));
     2775        yahoo_dump_unhandled(pkt);
    27592776        switch (pkt->service)
    27602777        {
     
    27692786        case YAHOO_SERVICE_IDDEACT:
    27702787        case YAHOO_SERVICE_Y6_STATUS_UPDATE:
    2771         case YAHOO_SERVICE_Y8_STATUS:
     2788        case YAHOO_SERVICE_YMSG15_STATUS:
    27722789                yahoo_process_status(yid, pkt);
    27732790                break;
     
    27832800                yahoo_process_mail(yid, pkt);
    27842801                break;
     2802        case YAHOO_SERVICE_REJECTCONTACT:
    27852803        case YAHOO_SERVICE_NEWCONTACT:
    27862804                yahoo_process_contact(yid, pkt);
     
    28232841                yahoo_process_buddyadd(yid, pkt);
    28242842                break;
     2843        case YAHOO_SERVICE_CONTACT_YMSG13:
     2844                yahoo_process_contact_ymsg13(yid,pkt);
     2845                break;
    28252846        case YAHOO_SERVICE_REMBUDDY:
    28262847                yahoo_process_buddydel(yid, pkt);
     
    28512872        case YAHOO_SERVICE_CHATLOGOFF:
    28522873        case YAHOO_SERVICE_CHATMSG:
    2853         case YAHOO_SERVICE_REJECTCONTACT:
    28542874        case YAHOO_SERVICE_PEERTOPEER:
    28552875                WARNING(("unhandled service 0x%02x", pkt->service));
     
    28652885                yahoo_process_picture_upload(yid, pkt);
    28662886                break; 
    2867         case YAHOO_SERVICE_Y8_LIST:     /* Buddy List */
     2887        case YAHOO_SERVICE_YMSG15_BUDDY_LIST:   /* Buddy List */
    28682888                yahoo_process_buddy_list(yid, pkt);
    28692889        default:
     
    40454065
    40464066        yahoo_packet_hash(pkt, 5, who);
    4047         yahoo_packet_hash(pkt, 4, from?from:yd->user);
     4067        yahoo_packet_hash(pkt, 1, from?from:yd->user);
    40484068        yahoo_packet_hash(pkt, 14, " ");
    40494069        yahoo_packet_hash(pkt, 13, typ ? "1" : "0");
     
    43474367                return;
    43484368
    4349         pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, yd->session_id);
    4350         yahoo_packet_hash(pkt, 1, yd->user);
    4351         yahoo_packet_hash(pkt, 7, who);
    4352         yahoo_packet_hash(pkt, 65, group);
     4369        pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YPACKET_STATUS_DEFAULT, yd->session_id);
     4370
    43534371        if (msg != NULL) /* add message/request "it's me add me" */
    43544372                yahoo_packet_hash(pkt, 14, msg);
     4373        else
     4374                yahoo_packet_hash(pkt,14,"");
     4375
     4376        yahoo_packet_hash(pkt, 65, group);
     4377        yahoo_packet_hash(pkt, 97, "1");
     4378        yahoo_packet_hash(pkt, 1, yd->user);
     4379        yahoo_packet_hash(pkt, 302, "319");
     4380        yahoo_packet_hash(pkt, 300, "319");
     4381        yahoo_packet_hash(pkt, 7, who);
     4382        yahoo_packet_hash(pkt, 334, "0");
     4383        yahoo_packet_hash(pkt, 301, "319");
     4384        yahoo_packet_hash(pkt, 303, "319");
     4385
     4386
    43554387        yahoo_send_packet(yid, pkt, 0);
    43564388        yahoo_packet_free(pkt);
     
    43744406        yahoo_send_packet(yid, pkt, 0);
    43754407        yahoo_packet_free(pkt);
     4408}
     4409
     4410void yahoo_accept_buddy_ymsg13(int id,const char* me,const char* who){
     4411        struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4412        struct yahoo_data *yd;
     4413
     4414        if(!yid)
     4415                return;
     4416        yd = yid->yd;
     4417
     4418        struct yahoo_packet* pkt=NULL;
     4419        pkt= yahoo_packet_new(YAHOO_SERVICE_CONTACT_YMSG13,YAHOO_STATUS_AVAILABLE,0);
     4420
     4421        yahoo_packet_hash(pkt,1,me ?: yd->user);       
     4422        yahoo_packet_hash(pkt,5,who);
     4423        yahoo_packet_hash(pkt,13,"1");
     4424        yahoo_packet_hash(pkt,334,"0");
     4425        yahoo_send_packet(yid, pkt, 0);
     4426        yahoo_packet_free(pkt);
     4427}
     4428
     4429void yahoo_reject_buddy_ymsg13(int id,const char* me,const char* who,const char* msg){
     4430        struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4431        struct yahoo_data *yd;
     4432
     4433        if(!yid)
     4434                return;
     4435        yd = yid->yd;
     4436
     4437        struct yahoo_packet* pkt=NULL;
     4438        pkt= yahoo_packet_new(YAHOO_SERVICE_CONTACT_YMSG13,YAHOO_STATUS_AVAILABLE,0);
     4439
     4440        yahoo_packet_hash(pkt,1,me ?: yd->user);       
     4441        yahoo_packet_hash(pkt,5,who);
     4442//      yahoo_packet_hash(pkt,241,YAHOO_PROTO_VER);
     4443        yahoo_packet_hash(pkt,13,"2");
     4444        yahoo_packet_hash(pkt,334,"0");
     4445        yahoo_packet_hash(pkt,97,"1");
     4446        yahoo_packet_hash(pkt,14,msg?:"");
     4447
     4448        yahoo_send_packet(yid, pkt, 0);
     4449        yahoo_packet_free(pkt);
     4450
    43764451}
    43774452
     
    44314506                return;
    44324507
    4433         pkt = yahoo_packet_new(YAHOO_SERVICE_STEALTH_PERM, YAHOO_STATUS_AVAILABLE, yd->session_id);
     4508        pkt = yahoo_packet_new(YAHOO_SERVICE_STEALTH, YAHOO_STATUS_AVAILABLE, yd->session_id);
    44344509        yahoo_packet_hash(pkt, 1, yd->user);
    44354510        yahoo_packet_hash(pkt, 7, who);
  • protocols/yahoo/yahoo.c

    rfa295e36 rba16895  
    348348}
    349349
     350static void byahoo_auth_allow( struct im_connection *ic, const char *who )
     351{
     352        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
     353       
     354        yahoo_accept_buddy_ymsg13( yd->y2_id, NULL, who );
     355}
     356
     357static void byahoo_auth_deny( struct im_connection *ic, const char *who )
     358{
     359        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
     360       
     361        yahoo_reject_buddy_ymsg13( yd->y2_id, NULL, who, NULL );
     362}
     363
    350364void byahoo_initmodule( )
    351365{
     
    372386
    373387        ret->handle_cmp = g_strcasecmp;
     388       
     389        ret->auth_allow = byahoo_auth_allow;
     390        ret->auth_deny = byahoo_auth_deny;
    374391       
    375392        register_protocol(ret);
     
    922939}
    923940
     941void ext_yahoo_contact_auth_request( int id, const char *myid, const char *who, const char *msg )
     942{
     943        struct im_connection *ic = byahoo_get_ic_by_id( id );
     944       
     945        imcb_ask_auth( ic, who, NULL );
     946}
     947
    924948void ext_yahoo_contact_added( int id, const char *myid, const char *who, const char *msg )
    925949{
    926         /* Groups schmoups. If I want to handle groups properly I can get the
    927            buddy data from some internal libyahoo2 structure. */
    928         imcb_add_buddy( byahoo_get_ic_by_id( id ), (char*) who, NULL );
     950        struct im_connection *ic = byahoo_get_ic_by_id( id );
     951       
     952        imcb_add_buddy( ic, (char*) who, NULL );
    929953}
    930954
  • protocols/yahoo/yahoo2.h

    rfa295e36 rba16895  
    217217void yahoo_buddyicon_request(int id, const char *who);
    218218
     219void yahoo_accept_buddy_ymsg13(int,const char*,const char*);
     220void yahoo_reject_buddy_ymsg13(int,const char*,const char*,const char*);
     221
    219222#include "yahoo_httplib.h"
    220223
  • protocols/yahoo/yahoo2_callbacks.h

    rfa295e36 rba16895  
    361361
    362362/*
     363 * Name: ext_yahoo_contact_auth_request
     364 *      Called when a contact wants to add you to his/her contact list
     365 * Params:
     366 *      id   - the id that identifies the server connection
     367 *      myid - the identity s/he added
     368 *      who  - who did it
     369 *      msg  - any message sent
     370 */
     371void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_auth_request)(int id, const char *myid, const char *who, const char *msg);
     372
     373
     374/*
    363375 * Name: ext_yahoo_contact_added
    364376 *      Called when a contact is added to your list
  • protocols/yahoo/yahoo2_types.h

    rfa295e36 rba16895  
    5757        YAHOO_LOGIN_LOCK = 14,
    5858        YAHOO_LOGIN_DUPL = 99,
    59         YAHOO_LOGIN_SOCK = -1
     59        YAHOO_LOGIN_SOCK = -1,
     60};
     61
     62enum ypacket_status {
     63        YPACKET_STATUS_DISCONNECTED = -1,
     64        YPACKET_STATUS_DEFAULT = 0,
     65        YPACKET_STATUS_SERVERACK = 1,
     66        YPACKET_STATUS_GAME     = 0x2,
     67        YPACKET_STATUS_AWAY     = 0x4,
     68        YPACKET_STATUS_CONTINUED = 0x5,
     69        YPACKET_STATUS_INVISIBLE = 12,
     70        YPACKET_STATUS_NOTIFY = 0x16, /* TYPING */
     71        YPACKET_STATUS_WEBLOGIN = 0x5a55aa55,
     72        YPACKET_STATUS_OFFLINE = 0x5a55aa56
    6073};
    6174
     
    133146#define YAHOO_CHAT_MALE 0x8000
    134147#define YAHOO_CHAT_FEMALE 0x10000
    135 #define YAHOO_CHAT_FEMALE 0x10000
    136148#define YAHOO_CHAT_DUNNO 0x400
    137149#define YAHOO_CHAT_WEBCAM 0x10
Note: See TracChangeset for help on using the changeset viewer.