Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/yahoo/yahoo.c

    rc495217 r56699f0  
    22 * libyahoo2 wrapper to BitlBee
    33 *
    4  * Mostly Copyright 2004-2010 Wilmer van der Gaast <wilmer@gaast.net>
     4 * Mostly Copyright 2004 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         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 );
     273       
     274        yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL );
    299275}
    300276
     
    365341        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
    366342       
    367         yahoo_confirm_buddy( yd->y2_id, who, 0, "" );
     343        yahoo_accept_buddy_ymsg13( yd->y2_id, NULL, who );
    368344}
    369345
     
    372348        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
    373349       
    374         yahoo_confirm_buddy( yd->y2_id, who, 1, "" );
     350        yahoo_reject_buddy_ymsg13( yd->y2_id, NULL, who, NULL );
    375351}
    376352
     
    445421        }
    446422       
    447         d->callback( NULL + d->fd, 0, d->data );
     423        d->callback( d->fd, 0, d->data );
    448424        g_free( d );
    449425}
     
    465441                return FALSE;
    466442       
    467         yahoo_read_ready( d->id, NULL + d->fd, d->data );
     443        yahoo_read_ready( d->id, d->fd, d->data );
    468444       
    469445        return TRUE;
     
    482458        struct byahoo_write_ready_data *d = data;
    483459       
    484         return yahoo_write_ready( d->id, NULL + d->fd, d->data );
     460        return yahoo_write_ready( d->id, d->fd, d->data );
    485461}
    486462
     
    511487        {
    512488                char *errstr;
    513                 int allow_reconnect = FALSE;
     489                int allow_reconnect = TRUE;
    514490               
    515491                yd->logged_in = FALSE;
     
    521497                else if( succ == YAHOO_LOGIN_LOCK )
    522498                        errstr = "Yahoo! account locked";
    523                 else if( succ == 1236 )
    524                         errstr = "Yahoo! account locked or machine temporarily banned";
    525499                else if( succ == YAHOO_LOGIN_DUPL )
     500                {
    526501                        errstr = "Logged in on a different machine or device";
     502                        allow_reconnect = FALSE;
     503                }
    527504                else if( succ == YAHOO_LOGIN_SOCK )
    528                 {
    529505                        errstr = "Socket problem";
    530                         allow_reconnect = TRUE;
    531                 }
    532506                else
    533507                        errstr = "Unknown error";
     
    632606                flags = 0;
    633607                break;
     608        case YAHOO_STATUS_NOTIFY:
     609                state_string = "Notify";
     610                break;
    634611        }
    635612       
     
    638615        if( stat == YAHOO_STATUS_IDLE )
    639616                imcb_buddy_times( ic, who, 0, idle );
    640 }
    641 
    642 void ext_yahoo_got_buzz( int id, const char *me, const char *who, long tm )
    643 {
    644617}
    645618
     
    657630}
    658631
    659 void ext_yahoo_got_file( int id, const char *ignored, const char *who, const char *msg,
    660                          const char *fname, unsigned long fesize, char *trid )
     632void 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 )
    661635{
    662636        struct im_connection *ic = byahoo_get_ic_by_id( id );
    663637       
    664638        imcb_log( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who );
    665 }
    666 
    667 void ext_yahoo_got_ft_data( int id, const unsigned char *in, int len, void *data )
    668 {
    669 }
    670 
    671 void ext_yahoo_file_transfer_done( int id, int result, void *data )
    672 {
    673639}
    674640
     
    683649}
    684650
    685 void ext_yahoo_system_message( int id, const char *me, const char *who, const char *msg )
     651void ext_yahoo_system_message( int id, const char *msg )
    686652{
    687653        struct im_connection *ic = byahoo_get_ic_by_id( id );
     
    705671
    706672/* TODO: Clear up the mess of inp and d structures */
    707 int ext_yahoo_add_handler( int id, void *fd_, yahoo_input_condition cond, void *data )
     673int ext_yahoo_add_handler( int id, int fd, yahoo_input_condition cond, void *data )
    708674{
    709675        struct byahoo_input_data *inp = g_new0( struct byahoo_input_data, 1 );
    710         int fd = (int) fd_;
    711676       
    712677        if( cond == YAHOO_INPUT_READ )
     
    735700        {
    736701                g_free( inp );
    737                 return -1;
     702                return( -1 );
    738703                /* Panic... */
    739704        }
    740705       
    741706        byahoo_inputs = g_slist_append( byahoo_inputs, inp );
    742         return inp->h;
     707        return( inp->h );
    743708}
    744709
     
    764729}
    765730
    766 int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_callback callback, void *data, int use_ssl )
     731int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_callback callback, void *data )
    767732{
    768733        struct byahoo_connect_callback_data *d;
     
    780745        d->id = id;
    781746       
    782         return fd;
    783 }
    784 
    785 char *ext_yahoo_get_ip_addr( const char *domain )
    786 {
    787         return NULL;
    788 }
    789 
    790 int ext_yahoo_write( void *fd, char *buf, int len )
    791 {
    792         return write( (int) fd, buf, len );
    793 }
    794 
    795 int ext_yahoo_read( void *fd, char *buf, int len )
    796 {
    797         return read( (int) fd, buf, len );
    798 }
    799 
    800 void ext_yahoo_close( void *fd )
    801 {
    802         close( (int) fd );
    803 }
    804 
    805 void 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 );
     747        return( fd );
    811748}
    812749
     
    815752int ext_yahoo_connect(const char *host, int port)
    816753{
     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
    817789        return -1;
    818790}
     
    926898}
    927899
    928 void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, void *fd )
     900void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, int fd )
    929901{
    930902}
     
    954926}
    955927
     928void 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
    956935void ext_yahoo_contact_added( int id, const char *myid, const char *who, const char *msg )
    957936{
    958937        struct im_connection *ic = byahoo_get_ic_by_id( id );
    959938       
    960         imcb_ask_auth( ic, who, msg );
     939        imcb_add_buddy( ic, (char*) who, NULL );
    961940}
    962941
     
    965944}
    966945
    967 void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat, const char *msg )
     946void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat )
    968947{
    969948}
     
    1010989}
    1011990
    1012 void ext_yahoo_got_ping( int id, const char *msg )
     991void ext_yahoo_got_ping( int id, const char *msg)
    1013992{
    1014993}
Note: See TracChangeset for help on using the changeset viewer.