Ignore:
Timestamp:
2008-04-02T14:22:57Z (16 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
f9dbc99
Parents:
875ad42 (diff), dd34575 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/yahoo/yahoo.c

    r875ad42 r85d7b85  
    5858{
    5959        char *name;
    60         struct conversation *c;
     60        struct groupchat *c;
    6161        int yid;
    6262        YList *members;
    63         struct gaim_connection *gc;
     63        struct im_connection *ic;
    6464};
    6565
     
    6767static int byahoo_chat_id = 0;
    6868
    69 static char *byahoo_strip( char *in )
     69static char *byahoo_strip( const char *in )
    7070{
    7171        int len;
    7272       
    73         /* This should get rid of HTML tags at the beginning of the string. */
     73        /* This should get rid of the markup noise at the beginning of the string. */
    7474        while( *in )
    7575        {
     
    8686                else if( strncmp( in, "\e[", 2 ) == 0 )
    8787                {
    88                         char *s;
     88                        const char *s;
    8989                       
    9090                        for( s = in + 2; *s && *s != 'm'; s ++ );
     
    101101        }
    102102       
    103         /* This is supposed to get rid of the closing HTML tags at the end of the line. */
     103        /* This is supposed to get rid of the noise at the end of the line. */
    104104        len = strlen( in );
    105         while( len > 0 && in[len-1] == '>' )
     105        while( len > 0 && ( in[len-1] == '>' || in[len-1] == 'm' ) )
    106106        {
    107107                int blen = len;
    108                
    109                 len --;
    110                 while( len > 0 && ( in[len] != '<' || in[len+1] != '/' ) )
     108                const char *search;
     109               
     110                if( in[len-1] == '>' )
     111                        search = "</";
     112                else
     113                        search = "\e[";
     114               
     115                len -= 3;
     116                while( len > 0 && strncmp( in + len, search, 2 ) != 0 )
    111117                        len --;
    112118               
    113                 if( len == 0 && ( in[len] != '<' || in[len+1] != '/' ) )
     119                if( len <= 0 && strncmp( in, search, 2 ) != 0 )
    114120                {
    115121                        len = blen;
     
    121127}
    122128
    123 static void byahoo_login( struct aim_user *user )
    124 {
    125         struct gaim_connection *gc = new_gaim_conn( user );
    126         struct byahoo_data *yd = gc->proto_data = g_new0( struct byahoo_data, 1 );
     129static void byahoo_init( account_t *acc )
     130{
     131        set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
     132}
     133
     134static void byahoo_login( account_t *acc )
     135{
     136        struct im_connection *ic = imcb_new( acc );
     137        struct byahoo_data *yd = ic->proto_data = g_new0( struct byahoo_data, 1 );
    127138       
    128139        yd->logged_in = FALSE;
    129140        yd->current_status = YAHOO_STATUS_AVAILABLE;
    130141       
    131         set_login_progress( gc, 1, "Connecting" );
    132         yd->y2_id = yahoo_init( user->username, user->password );
     142        imcb_log( ic, "Connecting" );
     143        yd->y2_id = yahoo_init( acc->user, acc->pass );
    133144        yahoo_login( yd->y2_id, yd->current_status );
    134145}
    135146
    136 static void byahoo_close( struct gaim_connection *gc )
    137 {
    138         struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
     147static void byahoo_logout( struct im_connection *ic )
     148{
     149        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
    139150        GSList *l;
    140151       
    141         while( gc->conversations )
    142                 serv_got_chat_left( gc, gc->conversations->id );
     152        while( ic->groupchats )
     153                imcb_chat_free( ic->groupchats );
    143154       
    144155        for( l = yd->buddygroups; l; l = l->next )
     
    160171}
    161172
    162 static void byahoo_get_info(struct gaim_connection *gc, char *who)
     173static void byahoo_get_info(struct im_connection *ic, char *who)
    163174{
    164175        /* Just make an URL and let the user fetch the info */
    165         serv_got_crap(gc, "%s\n%s: %s%s", _("User Info"),
     176        imcb_log(ic, "%s\n%s: %s%s", _("User Info"),
    166177                        _("For now, fetch yourself"), yahoo_get_profile_url(),
    167178                        who);
    168179}
    169180
    170 static int byahoo_send_im( struct gaim_connection *gc, char *who, char *what, int len, int flags )
    171 {
    172         struct byahoo_data *yd = gc->proto_data;
    173        
    174         yahoo_send_im( yd->y2_id, NULL, who, what, 1 );
     181static int byahoo_buddy_msg( struct im_connection *ic, char *who, char *what, int flags )
     182{
     183        struct byahoo_data *yd = ic->proto_data;
     184       
     185        yahoo_send_im( yd->y2_id, NULL, who, what, 1, 0 );
    175186       
    176187        return 1;
    177188}
    178189
    179 static int byahoo_send_typing( struct gaim_connection *gc, char *who, int typing )
    180 {
    181         struct byahoo_data *yd = gc->proto_data;
    182        
    183         yahoo_send_typing( yd->y2_id, NULL, who, typing );
     190static int byahoo_send_typing( struct im_connection *ic, char *who, int typing )
     191{
     192        struct byahoo_data *yd = ic->proto_data;
     193       
     194        yahoo_send_typing( yd->y2_id, NULL, who, ( typing & OPT_TYPING ) != 0 );
    184195       
    185196        return 1;
    186197}
    187198
    188 static void byahoo_set_away( struct gaim_connection *gc, char *state, char *msg )
    189 {
    190         struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
    191        
    192         gc->away = NULL;
    193        
    194         if( msg )
     199static void byahoo_set_away( struct im_connection *ic, char *state, char *msg )
     200{
     201        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
     202       
     203        ic->away = NULL;
     204       
     205        if( state && msg && g_strcasecmp( state, msg ) != 0 )
    195206        {
    196207                yd->current_status = YAHOO_STATUS_CUSTOM;
    197                 gc->away = "";
    198         }
    199         if( state )
    200         {
    201                 gc->away = "";
     208                ic->away = "";
     209        }
     210        else if( state )
     211        {
     212                /* Set msg to NULL since (if it isn't NULL already) it's equal
     213                   to state. msg must be empty if we want to use an existing
     214                   away state. */
     215                msg = NULL;
     216               
     217                ic->away = "";
    202218                if( g_strcasecmp( state, "Available" ) == 0 )
    203219                {
    204220                        yd->current_status = YAHOO_STATUS_AVAILABLE;
    205                         gc->away = NULL;
     221                        ic->away = NULL;
    206222                }
    207223                else if( g_strcasecmp( state, "Be Right Back" ) == 0 )
     
    229245                        yd->current_status = YAHOO_STATUS_AVAILABLE;
    230246                       
    231                         gc->away = NULL;
     247                        ic->away = NULL;
    232248                }
    233249        }
     
    235251                yd->current_status = YAHOO_STATUS_AVAILABLE;
    236252       
    237         if( yd->current_status == YAHOO_STATUS_INVISIBLE )
    238                 yahoo_set_away( yd->y2_id, yd->current_status, NULL, gc->away != NULL );
    239         else
    240                 yahoo_set_away( yd->y2_id, yd->current_status, msg, gc->away != NULL );
    241 }
    242 
    243 static GList *byahoo_away_states( struct gaim_connection *gc )
     253        yahoo_set_away( yd->y2_id, yd->current_status, msg, ic->away != NULL ? 2 : 0 );
     254}
     255
     256static GList *byahoo_away_states( struct im_connection *ic )
    244257{
    245258        GList *m = NULL;
     
    261274}
    262275
    263 static void byahoo_keepalive( struct gaim_connection *gc )
    264 {
    265         struct byahoo_data *yd = gc->proto_data;
     276static void byahoo_keepalive( struct im_connection *ic )
     277{
     278        struct byahoo_data *yd = ic->proto_data;
    266279       
    267280        yahoo_keepalive( yd->y2_id );
    268281}
    269282
    270 static void byahoo_add_buddy( struct gaim_connection *gc, char *who )
    271 {
    272         struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
    273        
    274         yahoo_add_buddy( yd->y2_id, who, BYAHOO_DEFAULT_GROUP );
    275 }
    276 
    277 static void byahoo_remove_buddy( struct gaim_connection *gc, char *who, char *group )
    278 {
    279         struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
     283static void byahoo_add_buddy( struct im_connection *ic, char *who, char *group )
     284{
     285        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
     286       
     287        yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL );
     288}
     289
     290static void byahoo_remove_buddy( struct im_connection *ic, char *who, char *group )
     291{
     292        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
    280293        GSList *bgl;
    281294       
     
    291304}
    292305
    293 static char *byahoo_get_status_string( struct gaim_connection *gc, int stat )
    294 {
    295         enum yahoo_status a = stat >> 1;
    296        
    297         switch (a)
    298         {
    299         case YAHOO_STATUS_BRB:
    300                 return "Be Right Back";
    301         case YAHOO_STATUS_BUSY:
    302                 return "Busy";
    303         case YAHOO_STATUS_NOTATHOME:
    304                 return "Not At Home";
    305         case YAHOO_STATUS_NOTATDESK:
    306                 return "Not At Desk";
    307         case YAHOO_STATUS_NOTINOFFICE:
    308                 return "Not In Office";
    309         case YAHOO_STATUS_ONPHONE:
    310                 return "On Phone";
    311         case YAHOO_STATUS_ONVACATION:
    312                 return "On Vacation";
    313         case YAHOO_STATUS_OUTTOLUNCH:
    314                 return "Out To Lunch";
    315         case YAHOO_STATUS_STEPPEDOUT:
    316                 return "Stepped Out";
    317         case YAHOO_STATUS_INVISIBLE:
    318                 return "Invisible";
    319         case YAHOO_STATUS_CUSTOM:
    320                 return "Away";
    321         case YAHOO_STATUS_IDLE:
    322                 return "Idle";
    323         case YAHOO_STATUS_OFFLINE:
    324                 return "Offline";
    325         case YAHOO_STATUS_NOTIFY:
    326                 return "Notify";
    327         default:
    328                 return "Away";
    329         }
    330 }
    331 
    332 static int byahoo_chat_send( struct gaim_connection *gc, int id, char *message )
    333 {
    334         struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
    335         struct conversation *c;
    336        
    337         for( c = gc->conversations; c && c->id != id; c = c->next );
    338 
     306static void byahoo_chat_msg( struct groupchat *c, char *message, int flags )
     307{
     308        struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data;
     309       
    339310        yahoo_conference_message( yd->y2_id, NULL, c->data, c->title, message, 1 );
    340        
    341         return( 0 );
    342 }
    343 
    344 static void byahoo_chat_invite( struct gaim_connection *gc, int id, char *msg, char *who )
    345 {
    346         struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
    347         struct conversation *c;
    348        
    349         for( c = gc->conversations; c && c->id != id; c = c->next );
    350        
    351         yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg );
    352 }
    353 
    354 static void byahoo_chat_leave( struct gaim_connection *gc, int id )
    355 {
    356         struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
    357         struct conversation *c;
    358        
    359         for( c = gc->conversations; c && c->id != id; c = c->next );
     311}
     312
     313static void byahoo_chat_invite( struct groupchat *c, char *who, char *msg )
     314{
     315        struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data;
     316       
     317        yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg ? msg : "" );
     318}
     319
     320static void byahoo_chat_leave( struct groupchat *c )
     321{
     322        struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data;
    360323       
    361324        yahoo_conference_logoff( yd->y2_id, NULL, c->data, c->title );
    362         serv_got_chat_left( gc, c->id );
    363 }
    364 
    365 static int byahoo_chat_open( struct gaim_connection *gc, char *who )
    366 {
    367         struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
    368         struct conversation *c;
     325        imcb_chat_free( c );
     326}
     327
     328static struct groupchat *byahoo_chat_with( struct im_connection *ic, char *who )
     329{
     330        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
     331        struct groupchat *c;
    369332        char *roomname;
    370333        YList *members;
    371334       
    372         roomname = g_new0( char, strlen( gc->username ) + 16 );
    373         g_snprintf( roomname, strlen( gc->username ) + 16, "%s-Bee-%d", gc->username, byahoo_chat_id );
    374        
    375         c = serv_got_joined_chat( gc, ++byahoo_chat_id, roomname );
    376         add_chat_buddy( c, gc->username );
     335        roomname = g_strdup_printf( "%s-Bee-%d", ic->acc->user, byahoo_chat_id );
     336       
     337        c = imcb_chat_new( ic, roomname );
     338        imcb_chat_add_buddy( c, ic->acc->user );
    377339       
    378340        /* FIXME: Free this thing when the chat's destroyed. We can't *always*
     
    385347        g_free( roomname );
    386348       
    387         return( 1 );
    388 }
    389 
    390 void byahoo_init( )
     349        return c;
     350}
     351
     352void byahoo_initmodule( )
    391353{
    392354        struct prpl *ret = g_new0(struct prpl, 1);
    393355        ret->name = "yahoo";
     356        ret->init = byahoo_init;
    394357       
    395358        ret->login = byahoo_login;
    396         ret->close = byahoo_close;
    397         ret->send_im = byahoo_send_im;
     359        ret->keepalive = byahoo_keepalive;
     360        ret->logout = byahoo_logout;
     361       
     362        ret->buddy_msg = byahoo_buddy_msg;
    398363        ret->get_info = byahoo_get_info;
    399364        ret->away_states = byahoo_away_states;
    400365        ret->set_away = byahoo_set_away;
    401         ret->keepalive = byahoo_keepalive;
    402366        ret->add_buddy = byahoo_add_buddy;
    403367        ret->remove_buddy = byahoo_remove_buddy;
    404         ret->get_status_string = byahoo_get_status_string;
    405368        ret->send_typing = byahoo_send_typing;
    406369       
    407         ret->chat_send = byahoo_chat_send;
     370        ret->chat_msg = byahoo_chat_msg;
    408371        ret->chat_invite = byahoo_chat_invite;
    409372        ret->chat_leave = byahoo_chat_leave;
    410         ret->chat_open = byahoo_chat_open;
    411         ret->cmp_buddynames = g_strcasecmp;
     373        ret->chat_with = byahoo_chat_with;
     374
     375        ret->handle_cmp = g_strcasecmp;
    412376       
    413377        register_protocol(ret);
    414378}
    415379
    416 static struct gaim_connection *byahoo_get_gc_by_id( int id )
     380static struct im_connection *byahoo_get_ic_by_id( int id )
    417381{
    418382        GSList *l;
    419         struct gaim_connection *gc;
     383        struct im_connection *ic;
    420384        struct byahoo_data *yd;
    421385       
    422386        for( l = get_connections(); l; l = l->next )
    423387        {
    424                 gc = l->data;
    425                 yd = gc->proto_data;
    426                
    427                 if( !strcmp(gc->prpl->name, "yahoo") && yd->y2_id == id )
    428                         return( gc );
     388                ic = l->data;
     389                yd = ic->proto_data;
     390               
     391                if( strcmp( ic->acc->prpl->name, "yahoo" ) == 0 && yd->y2_id == id )
     392                        return( ic );
    429393        }
    430394       
     
    443407};
    444408
    445 void byahoo_connect_callback( gpointer data, gint source, GaimInputCondition cond )
     409void byahoo_connect_callback( gpointer data, gint source, b_input_condition cond )
    446410{
    447411        struct byahoo_connect_callback_data *d = data;
    448412       
    449         if( !byahoo_get_gc_by_id( d->id ) )
     413        if( !byahoo_get_ic_by_id( d->id ) )
    450414        {
    451415                g_free( d );
     
    465429};
    466430
    467 void byahoo_read_ready_callback( gpointer data, gint source, GaimInputCondition cond )
     431gboolean byahoo_read_ready_callback( gpointer data, gint source, b_input_condition cond )
    468432{
    469433        struct byahoo_read_ready_data *d = data;
    470434       
    471         if( !byahoo_get_gc_by_id( d->id ) )
    472         {
     435        if( !byahoo_get_ic_by_id( d->id ) )
    473436                /* WTF doesn't libyahoo clean this up? */
    474                 ext_yahoo_remove_handler( d->id, d->tag );
    475                 return;
    476         }
     437                return FALSE;
    477438       
    478439        yahoo_read_ready( d->id, d->fd, d->data );
     440       
     441        return TRUE;
    479442}
    480443
     
    487450};
    488451
    489 void byahoo_write_ready_callback( gpointer data, gint source, GaimInputCondition cond )
     452gboolean byahoo_write_ready_callback( gpointer data, gint source, b_input_condition cond )
    490453{
    491454        struct byahoo_write_ready_data *d = data;
    492455       
    493         if( !byahoo_get_gc_by_id( d->id ) )
    494         {
     456        if( !byahoo_get_ic_by_id( d->id ) )
    495457                /* WTF doesn't libyahoo clean this up? */
    496                 ext_yahoo_remove_handler( d->id, d->tag );
    497                 return;
    498         }
     458                return FALSE;
    499459       
    500460        yahoo_write_ready( d->id, d->fd, d->data );
    501 }
    502 
    503 void ext_yahoo_login_response( int id, int succ, char *url )
    504 {
    505         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
     461       
     462        return FALSE;
     463}
     464
     465void ext_yahoo_login_response( int id, int succ, const char *url )
     466{
     467        struct im_connection *ic = byahoo_get_ic_by_id( id );
    506468        struct byahoo_data *yd = NULL;
    507469       
    508         if( gc == NULL )
     470        if( ic == NULL )
    509471        {
    510472                /* libyahoo2 seems to call this one twice when something
     
    516478        }
    517479       
    518         yd = (struct byahoo_data *) gc->proto_data;
     480        yd = (struct byahoo_data *) ic->proto_data;
    519481       
    520482        if( succ == YAHOO_LOGIN_OK )
    521483        {
    522                 account_online( gc );
     484                imcb_connected( ic );
    523485               
    524486                yd->logged_in = TRUE;
     
    527489        {
    528490                char *errstr;
    529                 char *s;
     491                int allow_reconnect = TRUE;
    530492               
    531493                yd->logged_in = FALSE;
     
    540502                {
    541503                        errstr = "Logged in on a different machine or device";
    542                         gc->wants_to_die = TRUE;
     504                        allow_reconnect = FALSE;
    543505                }
    544506                else if( succ == YAHOO_LOGIN_SOCK )
     
    548510               
    549511                if( url && *url )
    550                 {
    551                         s = g_malloc( strlen( "Error %d (%s). See %s for more information." ) + strlen( url ) + strlen( errstr ) + 16 );
    552                         sprintf( s, "Error %d (%s). See %s for more information.", succ, errstr, url );
    553                 }
     512                        imcb_error( ic, "Error %d (%s). See %s for more information.", succ, errstr, url );
    554513                else
    555                 {
    556                         s = g_malloc( strlen( "Error %d (%s)" ) + strlen( errstr ) + 16 );
    557                         sprintf( s, "Error %d (%s)", succ, errstr );
    558                 }
    559                
    560                 if( yd->logged_in )
    561                         hide_login_progress_error( gc, s );
    562                 else
    563                         hide_login_progress( gc, s );
    564                
    565                 g_free( s );
    566                
    567                 signoff( gc );
     514                        imcb_error( ic, "Error %d (%s)", succ, errstr );
     515               
     516                imc_logout( ic, allow_reconnect );
    568517        }
    569518}
     
    571520void ext_yahoo_got_buddies( int id, YList *buds )
    572521{
    573         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    574         struct byahoo_data *yd = gc->proto_data;
     522        struct im_connection *ic = byahoo_get_ic_by_id( id );
     523        struct byahoo_data *yd = ic->proto_data;
    575524        YList *bl = buds;
    576525       
     
    589538                }
    590539               
    591                 add_buddy( gc, b->group, b->id, b->real_name );
     540                imcb_add_buddy( ic, b->id, b->group );
     541                imcb_rename_buddy( ic, b->id, b->real_name );
     542               
    592543                bl = bl->next;
    593544        }
     
    606557}
    607558
    608 void ext_yahoo_status_changed( int id, char *who, int stat, char *msg, int away )
    609 {
    610         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    611        
    612         serv_got_update( gc, who, stat != YAHOO_STATUS_OFFLINE, 0, 0,
    613                          ( stat == YAHOO_STATUS_IDLE ) ? away : 0,
    614                          ( stat != YAHOO_STATUS_AVAILABLE ) | ( stat << 1 ), 0 );
    615 }
    616 
    617 void ext_yahoo_got_im( int id, char *who, char *msg, long tm, int stat, int utf8 )
    618 {
    619         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    620         char *m = byahoo_strip( msg );
    621        
    622         serv_got_im( gc, who, m, 0, 0, strlen( m ) );
    623         g_free( m );
    624 }
    625 
    626 void ext_yahoo_got_file( int id, char *who, char *url, long expires, char *msg, char *fname, unsigned long fesize )
    627 {
    628         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    629        
    630         serv_got_crap( gc, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who );
    631 }
    632 
    633 void ext_yahoo_typing_notify( int id, char *who, int stat )
    634 {
    635         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    636         if (stat == 1) {
    637                 /* User is typing */
    638                 serv_got_typing( gc, who, 1, 1 );
    639         }
    640         else {
    641                 /* User stopped typing */
    642                 serv_got_typing( gc, who, 1, 0 );
    643         }
    644 }
    645 
    646 void ext_yahoo_system_message( int id, char *msg )
    647 {
    648         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    649        
    650         serv_got_crap( gc, "Yahoo! system message: %s", msg );
    651 }
    652 
    653 void ext_yahoo_webcam_invite( int id, char *from )
    654 {
    655         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    656        
    657         serv_got_crap( gc, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from );
    658 }
    659 
    660 void ext_yahoo_error( int id, char *err, int fatal )
    661 {
    662         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
     559void ext_yahoo_status_changed( int id, const char *who, int stat, const char *msg, int away, int idle, int mobile )
     560{
     561        struct im_connection *ic = byahoo_get_ic_by_id( id );
     562        char *state_string = NULL;
     563        int flags = OPT_LOGGED_IN;
     564       
     565        if( away )
     566                flags |= OPT_AWAY;
     567       
     568        switch (stat)
     569        {
     570        case YAHOO_STATUS_BRB:
     571                state_string = "Be Right Back";
     572                break;
     573        case YAHOO_STATUS_BUSY:
     574                state_string = "Busy";
     575                break;
     576        case YAHOO_STATUS_NOTATHOME:
     577                state_string = "Not At Home";
     578                break;
     579        case YAHOO_STATUS_NOTATDESK:
     580                state_string = "Not At Desk";
     581                break;
     582        case YAHOO_STATUS_NOTINOFFICE:
     583                state_string = "Not In Office";
     584                break;
     585        case YAHOO_STATUS_ONPHONE:
     586                state_string = "On Phone";
     587                break;
     588        case YAHOO_STATUS_ONVACATION:
     589                state_string = "On Vacation";
     590                break;
     591        case YAHOO_STATUS_OUTTOLUNCH:
     592                state_string = "Out To Lunch";
     593                break;
     594        case YAHOO_STATUS_STEPPEDOUT:
     595                state_string = "Stepped Out";
     596                break;
     597        case YAHOO_STATUS_INVISIBLE:
     598                state_string = "Invisible";
     599                break;
     600        case YAHOO_STATUS_CUSTOM:
     601                state_string = "Away";
     602                break;
     603        case YAHOO_STATUS_IDLE:
     604                state_string = "Idle";
     605                break;
     606        case YAHOO_STATUS_OFFLINE:
     607                state_string = "Offline";
     608                flags = 0;
     609                break;
     610        case YAHOO_STATUS_NOTIFY:
     611                state_string = "Notify";
     612                break;
     613        }
     614       
     615        imcb_buddy_status( ic, who, flags, state_string, msg );
     616       
     617        /* Not implemented yet...
     618        if( stat == YAHOO_STATUS_IDLE )
     619                imcb_buddy_times( ic, who, 0, away );
     620        */
     621}
     622
     623void ext_yahoo_got_im( int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8 )
     624{
     625        struct im_connection *ic = byahoo_get_ic_by_id( id );
     626        char *m;
     627       
     628        if( msg )
     629        {
     630                m = byahoo_strip( msg );
     631                imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 );
     632                g_free( m );
     633        }
     634}
     635
     636void ext_yahoo_got_file( int id,
     637                         const char *ignored,
     638                         const char *who, const char *url, long expires, const char *msg, const char *fname, unsigned long fesize )
     639{
     640        struct im_connection *ic = byahoo_get_ic_by_id( id );
     641       
     642        imcb_log( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who );
     643}
     644
     645void ext_yahoo_typing_notify( int id, const char *ignored, const char *who, int stat )
     646{
     647        struct im_connection *ic = byahoo_get_ic_by_id( id );
     648       
     649        if( stat == 1 )
     650                imcb_buddy_typing( ic, (char*) who, OPT_TYPING );
     651        else
     652                imcb_buddy_typing( ic, (char*) who, 0 );
     653}
     654
     655void ext_yahoo_system_message( int id, const char *msg )
     656{
     657        struct im_connection *ic = byahoo_get_ic_by_id( id );
     658       
     659        imcb_log( ic, "Yahoo! system message: %s", msg );
     660}
     661
     662void ext_yahoo_webcam_invite( int id, const char *ignored, const char *from )
     663{
     664        struct im_connection *ic = byahoo_get_ic_by_id( id );
     665       
     666        imcb_log( ic, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from );
     667}
     668
     669void ext_yahoo_error( int id, const char *err, int fatal, int num )
     670{
     671        struct im_connection *ic = byahoo_get_ic_by_id( id );
     672       
     673        imcb_error( ic, "%s", err );
    663674       
    664675        if( fatal )
    665         {
    666                 hide_login_progress_error( gc, err );
    667                 signoff( gc );
    668         }
    669         else
    670         {
    671                 do_error_dialog( gc, err, "Yahoo! error" );
    672         }
     676                imc_logout( ic, TRUE );
    673677}
    674678
     
    687691               
    688692                inp->d = d;
    689                 d->tag = inp->h = gaim_input_add( fd, GAIM_INPUT_READ, (GaimInputFunction) byahoo_read_ready_callback, (gpointer) d );
     693                d->tag = inp->h = b_input_add( fd, GAIM_INPUT_READ, (b_event_handler) byahoo_read_ready_callback, (gpointer) d );
    690694        }
    691695        else if( cond == YAHOO_INPUT_WRITE )
     
    698702               
    699703                inp->d = d;
    700                 d->tag = inp->h = gaim_input_add( fd, GAIM_INPUT_WRITE, (GaimInputFunction) byahoo_write_ready_callback, (gpointer) d );
     704                d->tag = inp->h = b_input_add( fd, GAIM_INPUT_WRITE, (b_event_handler) byahoo_write_ready_callback, (gpointer) d );
    701705        }
    702706        else
     
    729733        }
    730734       
    731         gaim_input_remove( tag );
    732 }
    733 
    734 int ext_yahoo_connect_async( int id, char *host, int port, yahoo_connect_callback callback, void *data )
     735        b_event_remove( tag );
     736}
     737
     738int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_callback callback, void *data )
    735739{
    736740        struct byahoo_connect_callback_data *d;
     
    738742       
    739743        d = g_new0( struct byahoo_connect_callback_data, 1 );
    740         if( ( fd = proxy_connect( host, port, (GaimInputFunction) byahoo_connect_callback, (gpointer) d ) ) < 0 )
     744        if( ( fd = proxy_connect( host, port, (b_event_handler) byahoo_connect_callback, (gpointer) d ) ) < 0 )
    741745        {
    742746                g_free( d );
     
    753757/* Because we don't want asynchronous connects in BitlBee, and because
    754758   libyahoo doesn't seem to use this one anyway, this one is now defunct. */
    755 int ext_yahoo_connect(char *host, int port)
     759int ext_yahoo_connect(const char *host, int port)
    756760{
    757761#if 0
     
    796800{
    797801        yahoo_conference_logon( inv->yid, NULL, inv->members, inv->name );
    798         add_chat_buddy( inv->c, inv->gc->username );
     802        imcb_chat_add_buddy( inv->c, inv->ic->acc->user );
    799803        g_free( inv->name );
    800804        g_free( inv );
     
    804808{
    805809        yahoo_conference_decline( inv->yid, NULL, inv->members, inv->name, "User rejected groupchat" );
    806         serv_got_chat_left( inv->gc, inv->c->id );
     810        imcb_chat_free( inv->c );
    807811        g_free( inv->name );
    808812        g_free( inv );
    809813}
    810814
    811 void ext_yahoo_got_conf_invite( int id, char *who, char *room, char *msg, YList *members )
    812 {
    813         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
     815void ext_yahoo_got_conf_invite( int id, const char *ignored,
     816                                const char *who, const char *room, const char *msg, YList *members )
     817{
     818        struct im_connection *ic = byahoo_get_ic_by_id( id );
    814819        struct byahoo_conf_invitation *inv;
    815820        char txt[1024];
     
    819824        memset( inv, 0, sizeof( struct byahoo_conf_invitation ) );
    820825        inv->name = g_strdup( room );
    821         inv->c = serv_got_joined_chat( gc, ++byahoo_chat_id, room );
     826        inv->c = imcb_chat_new( ic, (char*) room );
    822827        inv->c->data = members;
    823828        inv->yid = id;
    824829        inv->members = members;
    825         inv->gc = gc;
     830        inv->ic = ic;
    826831       
    827832        for( m = members; m; m = m->next )
    828                 if( g_strcasecmp( m->data, gc->username ) != 0 )
    829                         add_chat_buddy( inv->c, m->data );
     833                if( g_strcasecmp( m->data, ic->acc->user ) != 0 )
     834                        imcb_chat_add_buddy( inv->c, m->data );
    830835       
    831836        g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", room, who, msg );
    832837       
    833         do_ask_dialog( gc, txt, inv, byahoo_accept_conf, byahoo_reject_conf );
    834 }
    835 
    836 void ext_yahoo_conf_userdecline( int id, char *who, char *room, char *msg )
    837 {
    838         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    839        
    840         serv_got_crap( gc, "Invite to chatroom %s rejected by %s: %s", room, who, msg );
    841 }
    842 
    843 void ext_yahoo_conf_userjoin( int id, char *who, char *room )
    844 {
    845         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    846         struct conversation *c;
    847        
    848         for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next );
     838        imcb_ask( ic, txt, inv, byahoo_accept_conf, byahoo_reject_conf );
     839}
     840
     841void ext_yahoo_conf_userdecline( int id, const char *ignored, const char *who, const char *room, const char *msg )
     842{
     843        struct im_connection *ic = byahoo_get_ic_by_id( id );
     844       
     845        imcb_log( ic, "Invite to chatroom %s rejected by %s: %s", room, who, msg );
     846}
     847
     848void ext_yahoo_conf_userjoin( int id, const char *ignored, const char *who, const char *room )
     849{
     850        struct im_connection *ic = byahoo_get_ic_by_id( id );
     851        struct groupchat *c;
     852       
     853        for( c = ic->groupchats; c && strcmp( c->title, room ) != 0; c = c->next );
    849854       
    850855        if( c )
    851                 add_chat_buddy( c, who );
    852 }
    853 
    854 void ext_yahoo_conf_userleave( int id, char *who, char *room )
    855 {
    856         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    857         struct conversation *c;
    858        
    859         for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next );
     856                imcb_chat_add_buddy( c, (char*) who );
     857}
     858
     859void ext_yahoo_conf_userleave( int id, const char *ignored, const char *who, const char *room )
     860
     861{
     862        struct im_connection *ic = byahoo_get_ic_by_id( id );
     863        struct groupchat *c;
     864       
     865        for( c = ic->groupchats; c && strcmp( c->title, room ) != 0; c = c->next );
    860866       
    861867        if( c )
    862                 remove_chat_buddy( c, who, "" );
    863 }
    864 
    865 void ext_yahoo_conf_message( int id, char *who, char *room, char *msg, int utf8 )
    866 {
    867         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
     868                imcb_chat_remove_buddy( c, (char*) who, "" );
     869}
     870
     871void ext_yahoo_conf_message( int id, const char *ignored, const char *who, const char *room, const char *msg, int utf8 )
     872{
     873        struct im_connection *ic = byahoo_get_ic_by_id( id );
    868874        char *m = byahoo_strip( msg );
    869         struct conversation *c;
    870        
    871         for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next );
    872        
    873         serv_got_chat_in( gc, c ? c->id : 0, who, 0, m, 0 );
     875        struct groupchat *c;
     876       
     877        for( c = ic->groupchats; c && strcmp( c->title, room ) != 0; c = c->next );
     878       
     879        if( c )
     880                imcb_chat_msg( c, (char*) who, (char*) m, 0, 0 );
    874881        g_free( m );
    875882}
    876883
    877 void ext_yahoo_chat_cat_xml( int id, char *xml )
    878 {
    879 }
    880 
    881 void ext_yahoo_chat_join( int id, char *room, char *topic, YList *members, int fd )
    882 {
    883 }
    884 
    885 void ext_yahoo_chat_userjoin( int id, char *room, struct yahoo_chat_member *who )
    886 {
    887 }
    888 
    889 void ext_yahoo_chat_userleave( int id, char *room, char *who )
    890 {
    891 }
    892 
    893 void ext_yahoo_chat_message( int id, char *who, char *room, char *msg, int msgtype, int utf8 )
    894 {
    895 }
    896 
    897 void ext_yahoo_chat_yahoologout( int id )
    898 {
    899 }
    900 
    901 void ext_yahoo_chat_yahooerror( int id )
    902 {
    903 }
    904 
    905 void ext_yahoo_contact_added( int id, char *myid, char *who, char *msg )
    906 {
    907 }
    908 
    909 void ext_yahoo_rejected( int id, char *who, char *msg )
    910 {
    911 }
    912 
    913 void ext_yahoo_game_notify( int id, char *who, int stat )
    914 {
    915 }
    916 
    917 void ext_yahoo_mail_notify( int id, char *from, char *subj, int cnt )
    918 {
    919         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    920        
    921         if( from && subj )
    922                 serv_got_crap( gc, "Received e-mail message from %s with subject `%s'", from, subj );
     884void ext_yahoo_chat_cat_xml( int id, const char *xml )
     885{
     886}
     887
     888void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, int fd )
     889{
     890}
     891
     892void ext_yahoo_chat_userjoin( int id, const char *me, const char *room, struct yahoo_chat_member *who )
     893{
     894        free(who->id);
     895        free(who->alias);
     896        free(who->location);
     897        free(who);
     898}
     899
     900void ext_yahoo_chat_userleave( int id, const char *me, const char *room, const char *who )
     901{
     902}
     903
     904void ext_yahoo_chat_message( int id, const char *me, const char *who, const char *room, const char *msg, int msgtype, int utf8 )
     905{
     906}
     907
     908void ext_yahoo_chat_yahoologout( int id, const char *me )
     909{
     910}
     911
     912void ext_yahoo_chat_yahooerror( int id, const char *me )
     913{
     914}
     915
     916void ext_yahoo_contact_added( int id, const char *myid, const char *who, const char *msg )
     917{
     918        /* Groups schmoups. If I want to handle groups properly I can get the
     919           buddy data from some internal libyahoo2 structure. */
     920        imcb_add_buddy( byahoo_get_ic_by_id( id ), (char*) who, NULL );
     921}
     922
     923void ext_yahoo_rejected( int id, const char *who, const char *msg )
     924{
     925}
     926
     927void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat )
     928{
     929}
     930
     931void ext_yahoo_mail_notify( int id, const char *from, const char *subj, int cnt )
     932{
     933        struct im_connection *ic = byahoo_get_ic_by_id( id );
     934       
     935        if( !set_getbool( &ic->acc->set, "mail_notifications" ) )
     936                ; /* The user doesn't care. */
     937        else if( from && subj )
     938                imcb_log( ic, "Received e-mail message from %s with subject `%s'", from, subj );
    923939        else if( cnt > 0 )
    924                 serv_got_crap( gc, "Received %d new e-mails", cnt );
    925 }
    926 
    927 void ext_yahoo_webcam_invite_reply( int id, char *from, int accept )
    928 {
    929 }
    930 
    931 void ext_yahoo_webcam_closed( int id, char *who, int reason )
     940                imcb_log( ic, "Received %d new e-mails", cnt );
     941}
     942
     943void ext_yahoo_webcam_invite_reply( int id, const char *me, const char *from, int accept )
     944{
     945}
     946
     947void ext_yahoo_webcam_closed( int id, const char *who, int reason )
    932948{
    933949}
     
    937953}
    938954
    939 void ext_yahoo_webcam_viewer( int id, char *who, int connect )
     955void ext_yahoo_webcam_viewer( int id, const char *who, int connect )
    940956{
    941957}
     
    945961}
    946962
    947 int ext_yahoo_log( char *fmt, ... )
     963int ext_yahoo_log( const char *fmt, ... )
    948964{
    949965        return( 0 );
     
    953969{
    954970}
     971
     972void ext_yahoo_got_ping( int id, const char *msg)
     973{
     974}
     975
     976void ext_yahoo_got_buddyicon (int id, const char *me, const char *who, const char *url, int checksum) {}
     977void ext_yahoo_got_buddyicon_checksum (int id, const char *me,const char *who, int checksum) {}
     978
     979void ext_yahoo_got_buddyicon_request(int id, const char *me, const char *who){}
     980void ext_yahoo_buddyicon_uploaded(int id, const char *url){}
Note: See TracChangeset for help on using the changeset viewer.