Changeset 0da65d5 for protocols/yahoo


Ignore:
Timestamp:
2007-03-31T05:40:45Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
aef4828
Parents:
fa29d093
Message:

s/gaim_connection/im_connection/ and some other minor API changes. The rest
will come tomorrow. It compiles, I'll leave the real testing up to someone
else. ;-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/yahoo/yahoo.c

    rfa29d093 r0da65d5  
    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
     
    123123static void byahoo_login( account_t *acc )
    124124{
    125         struct gaim_connection *gc = new_gaim_conn( acc );
    126         struct byahoo_data *yd = gc->proto_data = g_new0( struct byahoo_data, 1 );
     125        struct im_connection *ic = new_gaim_conn( acc );
     126        struct byahoo_data *yd = ic->proto_data = g_new0( struct byahoo_data, 1 );
    127127       
    128128        yd->logged_in = FALSE;
    129129        yd->current_status = YAHOO_STATUS_AVAILABLE;
    130130       
    131         set_login_progress( gc, 1, "Connecting" );
     131        set_login_progress( ic, 1, "Connecting" );
    132132        yd->y2_id = yahoo_init( acc->user, acc->pass );
    133133        yahoo_login( yd->y2_id, yd->current_status );
    134134}
    135135
    136 static void byahoo_close( struct gaim_connection *gc )
    137 {
    138         struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
     136static void byahoo_logout( struct im_connection *ic )
     137{
     138        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
    139139        GSList *l;
    140140       
    141         while( gc->conversations )
    142                 serv_got_chat_left( gc->conversations );
     141        while( ic->conversations )
     142                serv_got_chat_left( ic->conversations );
    143143       
    144144        for( l = yd->buddygroups; l; l = l->next )
     
    160160}
    161161
    162 static void byahoo_get_info(struct gaim_connection *gc, char *who)
     162static void byahoo_get_info(struct im_connection *ic, char *who)
    163163{
    164164        /* Just make an URL and let the user fetch the info */
    165         serv_got_crap(gc, "%s\n%s: %s%s", _("User Info"),
     165        serv_got_crap(ic, "%s\n%s: %s%s", _("User Info"),
    166166                        _("For now, fetch yourself"), yahoo_get_profile_url(),
    167167                        who);
    168168}
    169169
    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;
     170static int byahoo_send_im( struct im_connection *ic, char *who, char *what, int flags )
     171{
     172        struct byahoo_data *yd = ic->proto_data;
    173173       
    174174        yahoo_send_im( yd->y2_id, NULL, who, what, 1 );
     
    177177}
    178178
    179 static int byahoo_send_typing( struct gaim_connection *gc, char *who, int typing )
    180 {
    181         struct byahoo_data *yd = gc->proto_data;
     179static int byahoo_send_typing( struct im_connection *ic, char *who, int typing )
     180{
     181        struct byahoo_data *yd = ic->proto_data;
    182182       
    183183        yahoo_send_typing( yd->y2_id, NULL, who, typing );
     
    186186}
    187187
    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;
     188static void byahoo_set_away( struct im_connection *ic, char *state, char *msg )
     189{
     190        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
     191       
     192        ic->away = NULL;
    193193       
    194194        if( state && msg && g_strcasecmp( state, msg ) != 0 )
    195195        {
    196196                yd->current_status = YAHOO_STATUS_CUSTOM;
    197                 gc->away = "";
     197                ic->away = "";
    198198        }
    199199        else if( state )
     
    204204                msg = NULL;
    205205               
    206                 gc->away = "";
     206                ic->away = "";
    207207                if( g_strcasecmp( state, "Available" ) == 0 )
    208208                {
    209209                        yd->current_status = YAHOO_STATUS_AVAILABLE;
    210                         gc->away = NULL;
     210                        ic->away = NULL;
    211211                }
    212212                else if( g_strcasecmp( state, "Be Right Back" ) == 0 )
     
    234234                        yd->current_status = YAHOO_STATUS_AVAILABLE;
    235235                       
    236                         gc->away = NULL;
     236                        ic->away = NULL;
    237237                }
    238238        }
     
    240240                yd->current_status = YAHOO_STATUS_AVAILABLE;
    241241       
    242         yahoo_set_away( yd->y2_id, yd->current_status, msg, gc->away != NULL );
    243 }
    244 
    245 static GList *byahoo_away_states( struct gaim_connection *gc )
     242        yahoo_set_away( yd->y2_id, yd->current_status, msg, ic->away != NULL );
     243}
     244
     245static GList *byahoo_away_states( struct im_connection *ic )
    246246{
    247247        GList *m = NULL;
     
    263263}
    264264
    265 static void byahoo_keepalive( struct gaim_connection *gc )
    266 {
    267         struct byahoo_data *yd = gc->proto_data;
     265static void byahoo_keepalive( struct im_connection *ic )
     266{
     267        struct byahoo_data *yd = ic->proto_data;
    268268       
    269269        yahoo_keepalive( yd->y2_id );
    270270}
    271271
    272 static void byahoo_add_buddy( struct gaim_connection *gc, char *who )
    273 {
    274         struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
    275        
    276         yahoo_add_buddy( yd->y2_id, who, BYAHOO_DEFAULT_GROUP );
    277 }
    278 
    279 static void byahoo_remove_buddy( struct gaim_connection *gc, char *who, char *group )
    280 {
    281         struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
     272static void byahoo_add_buddy( struct im_connection *ic, char *who, char *group )
     273{
     274        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
     275       
     276        yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP );
     277}
     278
     279static void byahoo_remove_buddy( struct im_connection *ic, char *who, char *group )
     280{
     281        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
    282282        GSList *bgl;
    283283       
     
    293293}
    294294
    295 static char *byahoo_get_status_string( struct gaim_connection *gc, int stat )
     295static char *byahoo_get_status_string( struct im_connection *ic, int stat )
    296296{
    297297        enum yahoo_status a = stat >> 1;
     
    332332}
    333333
    334 static int byahoo_chat_send( struct conversation *c, char *message )
    335 {
    336         struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data;
     334static void byahoo_chat_send( struct groupchat *c, char *message, int flags )
     335{
     336        struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data;
    337337       
    338338        yahoo_conference_message( yd->y2_id, NULL, c->data, c->title, message, 1 );
    339        
    340         return( 0 );
    341 }
    342 
    343 static void byahoo_chat_invite( struct conversation *c, char *msg, char *who )
    344 {
    345         struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data;
     339}
     340
     341static void byahoo_chat_invite( struct groupchat *c, char *msg, char *who )
     342{
     343        struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data;
    346344       
    347345        yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg );
    348346}
    349347
    350 static void byahoo_chat_leave( struct conversation *c )
    351 {
    352         struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data;
     348static void byahoo_chat_leave( struct groupchat *c )
     349{
     350        struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data;
    353351       
    354352        yahoo_conference_logoff( yd->y2_id, NULL, c->data, c->title );
     
    356354}
    357355
    358 static struct conversation *byahoo_chat_open( struct gaim_connection *gc, char *who )
    359 {
    360         struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
    361         struct conversation *c;
     356static struct groupchat *byahoo_chat_with( struct im_connection *ic, char *who )
     357{
     358        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
     359        struct groupchat *c;
    362360        char *roomname;
    363361        YList *members;
    364362       
    365         roomname = g_new0( char, strlen( gc->username ) + 16 );
    366         g_snprintf( roomname, strlen( gc->username ) + 16, "%s-Bee-%d", gc->username, byahoo_chat_id );
    367        
    368         c = serv_got_joined_chat( gc, roomname );
    369         add_chat_buddy( c, gc->username );
     363        roomname = g_new0( char, strlen( ic->username ) + 16 );
     364        g_snprintf( roomname, strlen( ic->username ) + 16, "%s-Bee-%d", ic->username, byahoo_chat_id );
     365       
     366        c = serv_got_joined_chat( ic, roomname );
     367        add_chat_buddy( c, ic->username );
    370368       
    371369        /* FIXME: Free this thing when the chat's destroyed. We can't *always*
     
    381379}
    382380
    383 void byahoo_init( )
     381void byahoo_initmodule( )
    384382{
    385383        struct prpl *ret = g_new0(struct prpl, 1);
     
    387385       
    388386        ret->login = byahoo_login;
    389         ret->close = byahoo_close;
     387        ret->keepalive = byahoo_keepalive;
     388        ret->logout = byahoo_logout;
     389       
    390390        ret->send_im = byahoo_send_im;
    391391        ret->get_info = byahoo_get_info;
    392392        ret->away_states = byahoo_away_states;
    393393        ret->set_away = byahoo_set_away;
    394         ret->keepalive = byahoo_keepalive;
    395394        ret->add_buddy = byahoo_add_buddy;
    396395        ret->remove_buddy = byahoo_remove_buddy;
     
    401400        ret->chat_invite = byahoo_chat_invite;
    402401        ret->chat_leave = byahoo_chat_leave;
    403         ret->chat_open = byahoo_chat_open;
     402        ret->chat_with = byahoo_chat_with;
    404403
    405404        ret->handle_cmp = g_strcasecmp;
     
    408407}
    409408
    410 static struct gaim_connection *byahoo_get_gc_by_id( int id )
     409static struct im_connection *byahoo_get_ic_by_id( int id )
    411410{
    412411        GSList *l;
    413         struct gaim_connection *gc;
     412        struct im_connection *ic;
    414413        struct byahoo_data *yd;
    415414       
    416415        for( l = get_connections(); l; l = l->next )
    417416        {
    418                 gc = l->data;
    419                 yd = gc->proto_data;
    420                
    421                 if( strcmp( gc->acc->prpl->name, "yahoo" ) == 0 && yd->y2_id == id )
    422                         return( gc );
     417                ic = l->data;
     418                yd = ic->proto_data;
     419               
     420                if( strcmp( ic->acc->prpl->name, "yahoo" ) == 0 && yd->y2_id == id )
     421                        return( ic );
    423422        }
    424423       
     
    441440        struct byahoo_connect_callback_data *d = data;
    442441       
    443         if( !byahoo_get_gc_by_id( d->id ) )
     442        if( !byahoo_get_ic_by_id( d->id ) )
    444443        {
    445444                g_free( d );
     
    463462        struct byahoo_read_ready_data *d = data;
    464463       
    465         if( !byahoo_get_gc_by_id( d->id ) )
     464        if( !byahoo_get_ic_by_id( d->id ) )
    466465                /* WTF doesn't libyahoo clean this up? */
    467466                return FALSE;
     
    484483        struct byahoo_write_ready_data *d = data;
    485484       
    486         if( !byahoo_get_gc_by_id( d->id ) )
     485        if( !byahoo_get_ic_by_id( d->id ) )
    487486                /* WTF doesn't libyahoo clean this up? */
    488487                return FALSE;
     
    495494void ext_yahoo_login_response( int id, int succ, char *url )
    496495{
    497         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
     496        struct im_connection *ic = byahoo_get_ic_by_id( id );
    498497        struct byahoo_data *yd = NULL;
    499498       
    500         if( gc == NULL )
     499        if( ic == NULL )
    501500        {
    502501                /* libyahoo2 seems to call this one twice when something
     
    508507        }
    509508       
    510         yd = (struct byahoo_data *) gc->proto_data;
     509        yd = (struct byahoo_data *) ic->proto_data;
    511510       
    512511        if( succ == YAHOO_LOGIN_OK )
    513512        {
    514                 account_online( gc );
     513                account_online( ic );
    515514               
    516515                yd->logged_in = TRUE;
     
    532531                {
    533532                        errstr = "Logged in on a different machine or device";
    534                         gc->wants_to_die = TRUE;
     533                        ic->wants_to_die = TRUE;
    535534                }
    536535                else if( succ == YAHOO_LOGIN_SOCK )
     
    551550               
    552551                if( yd->logged_in )
    553                         hide_login_progress_error( gc, s );
     552                        hide_login_progress_error( ic, s );
    554553                else
    555                         hide_login_progress( gc, s );
     554                        hide_login_progress( ic, s );
    556555               
    557556                g_free( s );
    558557               
    559                 signoff( gc );
     558                signoff( ic );
    560559        }
    561560}
     
    563562void ext_yahoo_got_buddies( int id, YList *buds )
    564563{
    565         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    566         struct byahoo_data *yd = gc->proto_data;
     564        struct im_connection *ic = byahoo_get_ic_by_id( id );
     565        struct byahoo_data *yd = ic->proto_data;
    567566        YList *bl = buds;
    568567       
     
    581580                }
    582581               
    583                 add_buddy( gc, b->group, b->id, b->real_name );
     582                add_buddy( ic, b->group, b->id, b->real_name );
    584583                bl = bl->next;
    585584        }
     
    600599void ext_yahoo_status_changed( int id, char *who, int stat, char *msg, int away )
    601600{
    602         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    603        
    604         serv_got_update( gc, who, stat != YAHOO_STATUS_OFFLINE, 0, 0,
     601        struct im_connection *ic = byahoo_get_ic_by_id( id );
     602       
     603        serv_got_update( ic, who, stat != YAHOO_STATUS_OFFLINE, 0, 0,
    605604                         ( stat == YAHOO_STATUS_IDLE ) ? away : 0,
    606605                         ( stat != YAHOO_STATUS_AVAILABLE ) | ( stat << 1 ), 0 );
     
    609608void ext_yahoo_got_im( int id, char *who, char *msg, long tm, int stat, int utf8 )
    610609{
    611         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
     610        struct im_connection *ic = byahoo_get_ic_by_id( id );
    612611        char *m = byahoo_strip( msg );
    613612       
    614         serv_got_im( gc, who, m, 0, 0, strlen( m ) );
     613        serv_got_im( ic, who, m, 0, 0, strlen( m ) );
    615614        g_free( m );
    616615}
     
    618617void ext_yahoo_got_file( int id, char *who, char *url, long expires, char *msg, char *fname, unsigned long fesize )
    619618{
    620         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    621        
    622         serv_got_crap( gc, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who );
     619        struct im_connection *ic = byahoo_get_ic_by_id( id );
     620       
     621        serv_got_crap( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who );
    623622}
    624623
    625624void ext_yahoo_typing_notify( int id, char *who, int stat )
    626625{
    627         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
     626        struct im_connection *ic = byahoo_get_ic_by_id( id );
    628627        if (stat == 1) {
    629628                /* User is typing */
    630                 serv_got_typing( gc, who, 1, 1 );
     629                serv_got_typing( ic, who, 1, 1 );
    631630        }
    632631        else {
    633632                /* User stopped typing */
    634                 serv_got_typing( gc, who, 1, 0 );
     633                serv_got_typing( ic, who, 1, 0 );
    635634        }
    636635}
     
    638637void ext_yahoo_system_message( int id, char *msg )
    639638{
    640         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    641        
    642         serv_got_crap( gc, "Yahoo! system message: %s", msg );
     639        struct im_connection *ic = byahoo_get_ic_by_id( id );
     640       
     641        serv_got_crap( ic, "Yahoo! system message: %s", msg );
    643642}
    644643
    645644void ext_yahoo_webcam_invite( int id, char *from )
    646645{
    647         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    648        
    649         serv_got_crap( gc, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from );
     646        struct im_connection *ic = byahoo_get_ic_by_id( id );
     647       
     648        serv_got_crap( ic, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from );
    650649}
    651650
    652651void ext_yahoo_error( int id, char *err, int fatal )
    653652{
    654         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
     653        struct im_connection *ic = byahoo_get_ic_by_id( id );
    655654       
    656655        if( fatal )
    657656        {
    658                 hide_login_progress_error( gc, err );
    659                 signoff( gc );
     657                hide_login_progress_error( ic, err );
     658                signoff( ic );
    660659        }
    661660        else
    662661        {
    663                 do_error_dialog( gc, err, "Yahoo! error" );
     662                do_error_dialog( ic, err, "Yahoo! error" );
    664663        }
    665664}
     
    788787{
    789788        yahoo_conference_logon( inv->yid, NULL, inv->members, inv->name );
    790         add_chat_buddy( inv->c, inv->gc->username );
     789        add_chat_buddy( inv->c, inv->ic->username );
    791790        g_free( inv->name );
    792791        g_free( inv );
     
    803802void ext_yahoo_got_conf_invite( int id, char *who, char *room, char *msg, YList *members )
    804803{
    805         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
     804        struct im_connection *ic = byahoo_get_ic_by_id( id );
    806805        struct byahoo_conf_invitation *inv;
    807806        char txt[1024];
     
    811810        memset( inv, 0, sizeof( struct byahoo_conf_invitation ) );
    812811        inv->name = g_strdup( room );
    813         inv->c = serv_got_joined_chat( gc, room );
     812        inv->c = serv_got_joined_chat( ic, room );
    814813        inv->c->data = members;
    815814        inv->yid = id;
    816815        inv->members = members;
    817         inv->gc = gc;
     816        inv->ic = ic;
    818817       
    819818        for( m = members; m; m = m->next )
    820                 if( g_strcasecmp( m->data, gc->username ) != 0 )
     819                if( g_strcasecmp( m->data, ic->username ) != 0 )
    821820                        add_chat_buddy( inv->c, m->data );
    822821       
    823822        g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", room, who, msg );
    824823       
    825         do_ask_dialog( gc, txt, inv, byahoo_accept_conf, byahoo_reject_conf );
     824        do_ask_dialog( ic, txt, inv, byahoo_accept_conf, byahoo_reject_conf );
    826825}
    827826
    828827void ext_yahoo_conf_userdecline( int id, char *who, char *room, char *msg )
    829828{
    830         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    831        
    832         serv_got_crap( gc, "Invite to chatroom %s rejected by %s: %s", room, who, msg );
     829        struct im_connection *ic = byahoo_get_ic_by_id( id );
     830       
     831        serv_got_crap( ic, "Invite to chatroom %s rejected by %s: %s", room, who, msg );
    833832}
    834833
    835834void ext_yahoo_conf_userjoin( int id, char *who, char *room )
    836835{
    837         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    838         struct conversation *c;
    839        
    840         for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next );
     836        struct im_connection *ic = byahoo_get_ic_by_id( id );
     837        struct groupchat *c;
     838       
     839        for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next );
    841840       
    842841        if( c )
     
    846845void ext_yahoo_conf_userleave( int id, char *who, char *room )
    847846{
    848         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    849         struct conversation *c;
    850        
    851         for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next );
     847        struct im_connection *ic = byahoo_get_ic_by_id( id );
     848        struct groupchat *c;
     849       
     850        for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next );
    852851       
    853852        if( c )
     
    857856void ext_yahoo_conf_message( int id, char *who, char *room, char *msg, int utf8 )
    858857{
    859         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
     858        struct im_connection *ic = byahoo_get_ic_by_id( id );
    860859        char *m = byahoo_strip( msg );
    861         struct conversation *c;
    862        
    863         for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next );
     860        struct groupchat *c;
     861       
     862        for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next );
    864863       
    865864        if( c )
     
    910909void ext_yahoo_mail_notify( int id, char *from, char *subj, int cnt )
    911910{
    912         struct gaim_connection *gc = byahoo_get_gc_by_id( id );
     911        struct im_connection *ic = byahoo_get_ic_by_id( id );
    913912       
    914913        if( from && subj )
    915                 serv_got_crap( gc, "Received e-mail message from %s with subject `%s'", from, subj );
     914                serv_got_crap( ic, "Received e-mail message from %s with subject `%s'", from, subj );
    916915        else if( cnt > 0 )
    917                 serv_got_crap( gc, "Received %d new e-mails", cnt );
     916                serv_got_crap( ic, "Received %d new e-mails", cnt );
    918917}
    919918
Note: See TracChangeset for help on using the changeset viewer.