Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/yahoo/yahoo.c

    r56699f0 rc495217  
    22 * libyahoo2 wrapper to BitlBee
    33 *
    4  * Mostly Copyright 2004 Wilmer van der Gaast <wilmer@gaast.net>
     4 * Mostly Copyright 2004-2010 Wilmer van der Gaast <wilmer@gaast.net>
    55 *
    66 * This program is free software; you can redistribute it and/or modify
     
    271271{
    272272        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
    273        
    274         yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL );
     273        bee_user_t *bu;
     274       
     275        if( group && ( bu = bee_user_by_handle( ic->bee, ic, who ) ) && bu->group )
     276        {
     277                GSList *bgl;
     278               
     279                /* If the person is in our list already, this is a group change. */
     280                yahoo_change_buddy_group( yd->y2_id, who, bu->group->name, group );
     281               
     282                /* No idea how often people have people in multiple groups and
     283                   BitlBee doesn't currently support this anyway .. but keep
     284                   this struct up-to-date for now. */
     285                for( bgl = yd->buddygroups; bgl; bgl = bgl->next )
     286                {
     287                        struct byahoo_buddygroups *bg = bgl->data;
     288                       
     289                        if( g_strcasecmp( bg->buddy, who ) == 0 &&
     290                            g_strcasecmp( bg->group, bu->group->name ) == 0 )
     291                        {
     292                                g_free( bg->group );
     293                                bg->group = g_strdup( group );
     294                        }
     295                }
     296        }
     297        else
     298                yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL );
    275299}
    276300
     
    341365        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
    342366       
    343         yahoo_accept_buddy_ymsg13( yd->y2_id, NULL, who );
     367        yahoo_confirm_buddy( yd->y2_id, who, 0, "" );
    344368}
    345369
     
    348372        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
    349373       
    350         yahoo_reject_buddy_ymsg13( yd->y2_id, NULL, who, NULL );
     374        yahoo_confirm_buddy( yd->y2_id, who, 1, "" );
    351375}
    352376
     
    421445        }
    422446       
    423         d->callback( d->fd, 0, d->data );
     447        d->callback( NULL + d->fd, 0, d->data );
    424448        g_free( d );
    425449}
     
    441465                return FALSE;
    442466       
    443         yahoo_read_ready( d->id, d->fd, d->data );
     467        yahoo_read_ready( d->id, NULL + d->fd, d->data );
    444468       
    445469        return TRUE;
     
    458482        struct byahoo_write_ready_data *d = data;
    459483       
    460         return yahoo_write_ready( d->id, d->fd, d->data );
     484        return yahoo_write_ready( d->id, NULL + d->fd, d->data );
    461485}
    462486
     
    487511        {
    488512                char *errstr;
    489                 int allow_reconnect = TRUE;
     513                int allow_reconnect = FALSE;
    490514               
    491515                yd->logged_in = FALSE;
     
    497521                else if( succ == YAHOO_LOGIN_LOCK )
    498522                        errstr = "Yahoo! account locked";
     523                else if( succ == 1236 )
     524                        errstr = "Yahoo! account locked or machine temporarily banned";
    499525                else if( succ == YAHOO_LOGIN_DUPL )
     526                        errstr = "Logged in on a different machine or device";
     527                else if( succ == YAHOO_LOGIN_SOCK )
    500528                {
    501                         errstr = "Logged in on a different machine or device";
    502                         allow_reconnect = FALSE;
     529                        errstr = "Socket problem";
     530                        allow_reconnect = TRUE;
    503531                }
    504                 else if( succ == YAHOO_LOGIN_SOCK )
    505                         errstr = "Socket problem";
    506532                else
    507533                        errstr = "Unknown error";
     
    606632                flags = 0;
    607633                break;
    608         case YAHOO_STATUS_NOTIFY:
    609                 state_string = "Notify";
    610                 break;
    611634        }
    612635       
     
    615638        if( stat == YAHOO_STATUS_IDLE )
    616639                imcb_buddy_times( ic, who, 0, idle );
     640}
     641
     642void ext_yahoo_got_buzz( int id, const char *me, const char *who, long tm )
     643{
    617644}
    618645
     
    630657}
    631658
    632 void ext_yahoo_got_file( int id,
    633                          const char *ignored,
    634                          const char *who, const char *url, long expires, const char *msg, const char *fname, unsigned long fesize )
     659void ext_yahoo_got_file( int id, const char *ignored, const char *who, const char *msg,
     660                         const char *fname, unsigned long fesize, char *trid )
    635661{
    636662        struct im_connection *ic = byahoo_get_ic_by_id( id );
    637663       
    638664        imcb_log( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who );
     665}
     666
     667void ext_yahoo_got_ft_data( int id, const unsigned char *in, int len, void *data )
     668{
     669}
     670
     671void ext_yahoo_file_transfer_done( int id, int result, void *data )
     672{
    639673}
    640674
     
    649683}
    650684
    651 void ext_yahoo_system_message( int id, const char *msg )
     685void ext_yahoo_system_message( int id, const char *me, const char *who, const char *msg )
    652686{
    653687        struct im_connection *ic = byahoo_get_ic_by_id( id );
     
    671705
    672706/* TODO: Clear up the mess of inp and d structures */
    673 int ext_yahoo_add_handler( int id, int fd, yahoo_input_condition cond, void *data )
     707int ext_yahoo_add_handler( int id, void *fd_, yahoo_input_condition cond, void *data )
    674708{
    675709        struct byahoo_input_data *inp = g_new0( struct byahoo_input_data, 1 );
     710        int fd = (int) fd_;
    676711       
    677712        if( cond == YAHOO_INPUT_READ )
     
    700735        {
    701736                g_free( inp );
    702                 return( -1 );
     737                return -1;
    703738                /* Panic... */
    704739        }
    705740       
    706741        byahoo_inputs = g_slist_append( byahoo_inputs, inp );
    707         return( inp->h );
     742        return inp->h;
    708743}
    709744
     
    729764}
    730765
    731 int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_callback callback, void *data )
     766int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_callback callback, void *data, int use_ssl )
    732767{
    733768        struct byahoo_connect_callback_data *d;
     
    745780        d->id = id;
    746781       
    747         return( fd );
     782        return fd;
     783}
     784
     785char *ext_yahoo_get_ip_addr( const char *domain )
     786{
     787        return NULL;
     788}
     789
     790int ext_yahoo_write( void *fd, char *buf, int len )
     791{
     792        return write( (int) fd, buf, len );
     793}
     794
     795int ext_yahoo_read( void *fd, char *buf, int len )
     796{
     797        return read( (int) fd, buf, len );
     798}
     799
     800void ext_yahoo_close( void *fd )
     801{
     802        close( (int) fd );
     803}
     804
     805void ext_yahoo_got_buddy_change_group( int id, const char *me, const char *who,
     806                                       const char *old_group, const char *new_group )
     807{
     808        struct im_connection *ic = byahoo_get_ic_by_id( id );
     809       
     810        imcb_add_buddy( ic, who, new_group );
    748811}
    749812
     
    752815int ext_yahoo_connect(const char *host, int port)
    753816{
    754 #if 0
    755         struct sockaddr_in serv_addr;
    756         static struct hostent *server;
    757         static char last_host[256];
    758         int servfd;
    759         char **p;
    760 
    761         if(last_host[0] || g_strcasecmp(last_host, host)!=0) {
    762                 if(!(server = gethostbyname(host))) {
    763                         return -1;
    764                 }
    765                 strncpy(last_host, host, 255);
    766         }
    767 
    768         if((servfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    769                 return -1;
    770         }
    771 
    772         for (p = server->h_addr_list; *p; p++)
    773         {
    774                 memset(&serv_addr, 0, sizeof(serv_addr));
    775                 serv_addr.sin_family = AF_INET;
    776                 memcpy(&serv_addr.sin_addr.s_addr, *p, server->h_length);
    777                 serv_addr.sin_port = htons(port);
    778 
    779                 if(connect(servfd, (struct sockaddr *) &serv_addr,
    780                                         sizeof(serv_addr)) == -1) {
    781                         return -1;
    782                 } else {
    783                         return servfd;
    784                 }
    785         }
    786 
    787         closesocket(servfd);
    788 #endif
    789817        return -1;
    790818}
     
    898926}
    899927
    900 void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, int fd )
     928void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, void *fd )
    901929{
    902930}
     
    926954}
    927955
    928 void ext_yahoo_contact_auth_request( int id, const char *myid, const char *who, const char *msg )
    929 {
    930         struct im_connection *ic = byahoo_get_ic_by_id( id );
    931        
    932         imcb_ask_auth( ic, who, NULL );
    933 }
    934 
    935956void ext_yahoo_contact_added( int id, const char *myid, const char *who, const char *msg )
    936957{
    937958        struct im_connection *ic = byahoo_get_ic_by_id( id );
    938959       
    939         imcb_add_buddy( ic, (char*) who, NULL );
     960        imcb_ask_auth( ic, who, msg );
    940961}
    941962
     
    944965}
    945966
    946 void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat )
     967void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat, const char *msg )
    947968{
    948969}
     
    9891010}
    9901011
    991 void ext_yahoo_got_ping( int id, const char *msg)
     1012void ext_yahoo_got_ping( int id, const char *msg )
    9921013{
    9931014}
Note: See TracChangeset for help on using the changeset viewer.