Changeset 0da65d5 for protocols/nogaim.c


Ignore:
Timestamp:
2007-03-31T05:40:45Z (17 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/nogaim.c

    rfa29d093 r0da65d5  
    3636#include <ctype.h>
    3737
    38 static int remove_chat_buddy_silent( struct conversation *b, char *handle );
     38static int remove_chat_buddy_silent( struct groupchat *b, char *handle );
    3939
    4040GSList *connections;
     
    115115void nogaim_init()
    116116{
    117         extern void msn_init();
    118         extern void oscar_init();
    119         extern void byahoo_init();
    120         extern void jabber_init();
     117        extern void msn_initmodule();
     118        extern void oscar_initmodule();
     119        extern void byahoo_initmodule();
     120        extern void jabber_initmodule();
    121121
    122122#ifdef WITH_MSN
    123         msn_init();
     123        msn_initmodule();
    124124#endif
    125125
    126126#ifdef WITH_OSCAR
    127         oscar_init();
     127        oscar_initmodule();
    128128#endif
    129129       
    130130#ifdef WITH_YAHOO
    131         byahoo_init();
     131        byahoo_initmodule();
    132132#endif
    133133       
    134134#ifdef WITH_JABBER
    135         jabber_init();
     135        jabber_initmodule();
    136136#endif
    137137
     
    145145/* multi.c */
    146146
    147 struct gaim_connection *new_gaim_conn( account_t *acc )
    148 {
    149         struct gaim_connection *gc;
    150        
    151         gc = g_new0( struct gaim_connection, 1 );
     147struct im_connection *new_gaim_conn( account_t *acc )
     148{
     149        struct im_connection *ic;
     150       
     151        ic = g_new0( struct im_connection, 1 );
    152152       
    153153        /* Maybe we should get rid of this memory waste later. ;-) */
    154         g_snprintf( gc->username, sizeof( gc->username ), "%s", acc->user );
    155         g_snprintf( gc->password, sizeof( gc->password ), "%s", acc->pass );
    156        
    157         gc->irc = acc->irc;
    158         gc->acc = acc;
    159         acc->gc = gc;
    160        
    161         connections = g_slist_append( connections, gc );
    162        
    163         return( gc );
    164 }
    165 
    166 void destroy_gaim_conn( struct gaim_connection *gc )
     154        g_snprintf( ic->username, sizeof( ic->username ), "%s", acc->user );
     155        g_snprintf( ic->password, sizeof( ic->password ), "%s", acc->pass );
     156       
     157        ic->irc = acc->irc;
     158        ic->acc = acc;
     159        acc->ic = ic;
     160       
     161        connections = g_slist_append( connections, ic );
     162       
     163        return( ic );
     164}
     165
     166void destroy_gaim_conn( struct im_connection *ic )
    167167{
    168168        account_t *a;
    169169       
    170170        /* Destroy the pointer to this connection from the account list */
    171         for( a = gc->irc->accounts; a; a = a->next )
    172                 if( a->gc == gc )
    173                 {
    174                         a->gc = NULL;
     171        for( a = ic->irc->accounts; a; a = a->next )
     172                if( a->ic == ic )
     173                {
     174                        a->ic = NULL;
    175175                        break;
    176176                }
    177177       
    178         connections = g_slist_remove( connections, gc );
    179         g_free( gc );
    180 }
    181 
    182 void set_login_progress( struct gaim_connection *gc, int step, char *msg )
    183 {
    184         serv_got_crap( gc, "Logging in: %s", msg );
     178        connections = g_slist_remove( connections, ic );
     179        g_free( ic );
     180}
     181
     182void set_login_progress( struct im_connection *ic, int step, char *msg )
     183{
     184        serv_got_crap( ic, "Logging in: %s", msg );
    185185}
    186186
    187187/* Errors *while* logging in */
    188 void hide_login_progress( struct gaim_connection *gc, char *msg )
    189 {
    190         serv_got_crap( gc, "Login error: %s", msg );
     188void hide_login_progress( struct im_connection *ic, char *msg )
     189{
     190        serv_got_crap( ic, "Login error: %s", msg );
    191191}
    192192
    193193/* Errors *after* logging in */
    194 void hide_login_progress_error( struct gaim_connection *gc, char *msg )
    195 {
    196         serv_got_crap( gc, "Logged out: %s", msg );
    197 }
    198 
    199 void serv_got_crap( struct gaim_connection *gc, char *format, ... )
     194void hide_login_progress_error( struct im_connection *ic, char *msg )
     195{
     196        serv_got_crap( ic, "Logged out: %s", msg );
     197}
     198
     199void serv_got_crap( struct im_connection *ic, char *format, ... )
    200200{
    201201        va_list params;
     
    207207        va_end( params );
    208208
    209         if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||
    210             ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )
     209        if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
     210            ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
    211211                strip_html( text );
    212212       
    213213        /* Try to find a different connection on the same protocol. */
    214         for( a = gc->irc->accounts; a; a = a->next )
    215                 if( a->prpl == gc->acc->prpl && a->gc != gc )
     214        for( a = ic->irc->accounts; a; a = a->next )
     215                if( a->prpl == ic->acc->prpl && a->ic != ic )
    216216                        break;
    217217       
    218218        /* If we found one, include the screenname in the message. */
    219219        if( a )
    220                 irc_usermsg( gc->irc, "%s(%s) - %s", gc->acc->prpl->name, gc->username, text );
     220                irc_usermsg( ic->irc, "%s(%s) - %s", ic->acc->prpl->name, ic->username, text );
    221221        else
    222                 irc_usermsg( gc->irc, "%s - %s", gc->acc->prpl->name, text );
     222                irc_usermsg( ic->irc, "%s - %s", ic->acc->prpl->name, text );
    223223       
    224224        g_free( text );
     
    227227static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond )
    228228{
    229         struct gaim_connection *gc = d;
    230        
    231         if( gc->acc->prpl->keepalive )
    232                 gc->acc->prpl->keepalive( gc );
     229        struct im_connection *ic = d;
     230       
     231        if( ic->acc->prpl->keepalive )
     232                ic->acc->prpl->keepalive( ic );
    233233       
    234234        return TRUE;
    235235}
    236236
    237 void account_online( struct gaim_connection *gc )
     237void account_online( struct im_connection *ic )
    238238{
    239239        user_t *u;
     
    242242           the whole login sequence again, so these "late" calls to this
    243243           function should be handled correctly. (IOW, ignored) */
    244         if( gc->flags & OPT_LOGGED_IN )
     244        if( ic->flags & OPT_LOGGED_IN )
    245245                return;
    246246       
    247         u = user_find( gc->irc, gc->irc->nick );
    248        
    249         serv_got_crap( gc, "Logged in" );
    250        
    251         gc->keepalive = b_timeout_add( 60000, send_keepalive, gc );
    252         gc->flags |= OPT_LOGGED_IN;
     247        u = user_find( ic->irc, ic->irc->nick );
     248       
     249        serv_got_crap( ic, "Logged in" );
     250       
     251        ic->keepalive = b_timeout_add( 60000, send_keepalive, ic );
     252        ic->flags |= OPT_LOGGED_IN;
    253253       
    254254        /* Also necessary when we're not away, at least for some of the
    255255           protocols. */
    256         bim_set_away( gc, u->away );
     256        bim_set_away( ic, u->away );
    257257}
    258258
     
    274274}
    275275
    276 void signoff( struct gaim_connection *gc )
    277 {
    278         irc_t *irc = gc->irc;
     276void signoff( struct im_connection *ic )
     277{
     278        irc_t *irc = ic->irc;
    279279        user_t *t, *u = irc->users;
    280280        account_t *a;
     
    282282        /* Nested calls might happen sometimes, this is probably the best
    283283           place to catch them. */
    284         if( gc->flags & OPT_LOGGING_OUT )
     284        if( ic->flags & OPT_LOGGING_OUT )
    285285                return;
    286286        else
    287                 gc->flags |= OPT_LOGGING_OUT;
    288        
    289         serv_got_crap( gc, "Signing off.." );
    290        
    291         b_event_remove( gc->keepalive );
    292         gc->keepalive = 0;
    293         gc->acc->prpl->close( gc );
    294         b_event_remove( gc->inpa );
     287                ic->flags |= OPT_LOGGING_OUT;
     288       
     289        serv_got_crap( ic, "Signing off.." );
     290       
     291        b_event_remove( ic->keepalive );
     292        ic->keepalive = 0;
     293        ic->acc->prpl->logout( ic );
     294        b_event_remove( ic->inpa );
    295295       
    296296        while( u )
    297297        {
    298                 if( u->gc == gc )
     298                if( u->ic == ic )
    299299                {
    300300                        t = u->next;
     
    306306        }
    307307       
    308         query_del_by_gc( gc->irc, gc );
     308        query_del_by_conn( ic->irc, ic );
    309309       
    310310        for( a = irc->accounts; a; a = a->next )
    311                 if( a->gc == gc )
     311                if( a->ic == ic )
    312312                        break;
    313313       
     
    316316                /* Uhm... This is very sick. */
    317317        }
    318         else if( !gc->wants_to_die && set_getbool( &irc->set, "auto_reconnect" ) &&
     318        else if( !ic->wants_to_die && set_getbool( &irc->set, "auto_reconnect" ) &&
    319319                 set_getbool( &a->set, "auto_reconnect" ) )
    320320        {
    321321                int delay = set_getint( &irc->set, "auto_reconnect_delay" );
    322322               
    323                 serv_got_crap( gc, "Reconnecting in %d seconds..", delay );
     323                serv_got_crap( ic, "Reconnecting in %d seconds..", delay );
    324324                a->reconnect = b_timeout_add( delay * 1000, auto_reconnect, a );
    325325        }
    326326       
    327         destroy_gaim_conn( gc );
     327        destroy_gaim_conn( ic );
    328328}
    329329
     
    331331/* dialogs.c */
    332332
    333 void do_error_dialog( struct gaim_connection *gc, char *msg, char *title )
     333void do_error_dialog( struct im_connection *ic, char *msg, char *title )
    334334{
    335335        if( msg && title )
    336                 serv_got_crap( gc, "Error: %s: %s", title, msg );
     336                serv_got_crap( ic, "Error: %s: %s", title, msg );
    337337        else if( msg )
    338                 serv_got_crap( gc, "Error: %s", msg );
     338                serv_got_crap( ic, "Error: %s", msg );
    339339        else if( title )
    340                 serv_got_crap( gc, "Error: %s", title );
     340                serv_got_crap( ic, "Error: %s", title );
    341341        else
    342                 serv_got_crap( gc, "Error" );
    343 }
    344 
    345 void do_ask_dialog( struct gaim_connection *gc, char *msg, void *data, void *doit, void *dont )
    346 {
    347         query_add( gc->irc, gc, msg, doit, dont, data );
     342                serv_got_crap( ic, "Error" );
     343}
     344
     345void do_ask_dialog( struct im_connection *ic, char *msg, void *data, void *doit, void *dont )
     346{
     347        query_add( ic->irc, ic, msg, doit, dont, data );
    348348}
    349349
     
    351351/* list.c */
    352352
    353 void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname )
     353void add_buddy( struct im_connection *ic, char *group, char *handle, char *realname )
    354354{
    355355        user_t *u;
    356356        char nick[MAX_NICK_LENGTH+1];
    357357        char *s;
    358         irc_t *irc = gc->irc;
     358        irc_t *irc = ic->irc;
    359359       
    360360        if( set_getbool( &irc->set, "debug" ) && 0 ) /* This message is too useless */
    361                 serv_got_crap( gc, "Receiving user add from handle: %s", handle );
    362        
    363         if( user_findhandle( gc, handle ) )
     361                serv_got_crap( ic, "Receiving user add from handle: %s", handle );
     362       
     363        if( user_findhandle( ic, handle ) )
    364364        {
    365365                if( set_getbool( &irc->set, "debug" ) )
    366                         serv_got_crap( gc, "User already exists, ignoring add request: %s", handle );
     366                        serv_got_crap( ic, "User already exists, ignoring add request: %s", handle );
    367367               
    368368                return;
     
    372372       
    373373        memset( nick, 0, MAX_NICK_LENGTH + 1 );
    374         strcpy( nick, nick_get( gc->acc, handle, realname ) );
    375        
    376         u = user_add( gc->irc, nick );
     374        strcpy( nick, nick_get( ic->acc, handle, realname ) );
     375       
     376        u = user_add( ic->irc, nick );
    377377       
    378378        if( !realname || !*realname ) realname = nick;
     
    384384                u->user = g_strndup( handle, s - handle );
    385385        }
    386         else if( gc->acc->server )
     386        else if( ic->acc->server )
    387387        {
    388388                char *colon;
    389389               
    390                 if( ( colon = strchr( gc->acc->server, ':' ) ) )
    391                         u->host = g_strndup( gc->acc->server,
    392                                              colon - gc->acc->server );
     390                if( ( colon = strchr( ic->acc->server, ':' ) ) )
     391                        u->host = g_strndup( ic->acc->server,
     392                                             colon - ic->acc->server );
    393393                else
    394                         u->host = g_strdup( gc->acc->server );
     394                        u->host = g_strdup( ic->acc->server );
    395395               
    396396                u->user = g_strdup( handle );
     
    403403        else
    404404        {
    405                 u->host = g_strdup( gc->acc->prpl->name );
     405                u->host = g_strdup( ic->acc->prpl->name );
    406406                u->user = g_strdup( handle );
    407407        }
    408408       
    409         u->gc = gc;
     409        u->ic = ic;
    410410        u->handle = g_strdup( handle );
    411411        if( group ) u->group = g_strdup( group );
     
    414414}
    415415
    416 struct buddy *find_buddy( struct gaim_connection *gc, char *handle )
     416struct buddy *find_buddy( struct im_connection *ic, char *handle )
    417417{
    418418        static struct buddy b[1];
    419419        user_t *u;
    420420       
    421         u = user_findhandle( gc, handle );
     421        u = user_findhandle( ic, handle );
    422422       
    423423        if( !u )
     
    428428        strncpy( b->show, u->realname, BUDDY_ALIAS_MAXLEN );
    429429        b->present = u->online;
    430         b->gc = u->gc;
     430        b->ic = u->ic;
    431431       
    432432        return( b );
    433433}
    434434
    435 void signoff_blocked( struct gaim_connection *gc )
     435void signoff_blocked( struct im_connection *ic )
    436436{
    437437        return; /* Make all blocked users look invisible (TODO?) */
     
    439439
    440440
    441 void serv_buddy_rename( struct gaim_connection *gc, char *handle, char *realname )
    442 {
    443         user_t *u = user_findhandle( gc, handle );
     441void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname )
     442{
     443        user_t *u = user_findhandle( ic, handle );
    444444       
    445445        if( !u ) return;
     
    451451                u->realname = g_strdup( realname );
    452452               
    453                 if( ( gc->flags & OPT_LOGGED_IN ) && set_getbool( &gc->irc->set, "display_namechanges" ) )
    454                         serv_got_crap( gc, "User `%s' changed name to `%s'", u->nick, u->realname );
     453                if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) )
     454                        serv_got_crap( ic, "User `%s' changed name to `%s'", u->nick, u->realname );
    455455        }
    456456}
     
    461461struct show_got_added_data
    462462{
    463         struct gaim_connection *gc;
     463        struct im_connection *ic;
    464464        char *handle;
    465465};
     
    473473void show_got_added_yes( gpointer w, struct show_got_added_data *data )
    474474{
    475         data->gc->acc->prpl->add_buddy( data->gc, data->handle );
    476         add_buddy( data->gc, NULL, data->handle, data->handle );
     475        data->ic->acc->prpl->add_buddy( data->ic, data->handle, NULL );
     476        add_buddy( data->ic, NULL, data->handle, data->handle );
    477477       
    478478        return show_got_added_no( w, data );
    479479}
    480480
    481 void show_got_added( struct gaim_connection *gc, char *handle, const char *realname )
     481void show_got_added( struct im_connection *ic, char *handle, const char *realname )
    482482{
    483483        struct show_got_added_data *data = g_new0( struct show_got_added_data, 1 );
     
    485485       
    486486        /* TODO: Make a setting for this! */
    487         if( user_findhandle( gc, handle ) != NULL )
     487        if( user_findhandle( ic, handle ) != NULL )
    488488                return;
    489489       
    490490        s = g_strdup_printf( "The user %s is not in your buddy list yet. Do you want to add him/her now?", handle );
    491491       
    492         data->gc = gc;
     492        data->ic = ic;
    493493        data->handle = g_strdup( handle );
    494         query_add( gc->irc, gc, s, show_got_added_yes, show_got_added_no, data );
     494        query_add( ic->irc, ic, s, show_got_added_yes, show_got_added_no, data );
    495495}
    496496
     
    498498/* server.c */                   
    499499
    500 void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps )
     500void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps )
    501501{
    502502        user_t *u;
    503503        int oa, oo;
    504504       
    505         u = user_findhandle( gc, handle );
     505        u = user_findhandle( ic, handle );
    506506       
    507507        if( !u )
    508508        {
    509                 if( g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "add" ) == 0 )
    510                 {
    511                         add_buddy( gc, NULL, handle, NULL );
    512                         u = user_findhandle( gc, handle );
     509                if( g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "add" ) == 0 )
     510                {
     511                        add_buddy( ic, NULL, handle, NULL );
     512                        u = user_findhandle( ic, handle );
    513513                }
    514514                else
    515515                {
    516                         if( set_getbool( &gc->irc->set, "debug" ) || g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "ignore" ) != 0 )
     516                        if( set_getbool( &ic->irc->set, "debug" ) || g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "ignore" ) != 0 )
    517517                        {
    518                                 serv_got_crap( gc, "serv_got_update() for handle %s:", handle );
    519                                 serv_got_crap( gc, "loggedin = %d, type = %d", loggedin, type );
     518                                serv_got_crap( ic, "serv_got_update() for handle %s:", handle );
     519                                serv_got_crap( ic, "loggedin = %d, type = %d", loggedin, type );
    520520                        }
    521521                       
     
    537537        if( loggedin && !u->online )
    538538        {
    539                 irc_spawn( gc->irc, u );
     539                irc_spawn( ic->irc, u );
    540540                u->online = 1;
    541541        }
    542542        else if( !loggedin && u->online )
    543543        {
    544                 struct conversation *c;
    545                
    546                 irc_kill( gc->irc, u );
     544                struct groupchat *c;
     545               
     546                irc_kill( ic->irc, u );
    547547                u->online = 0;
    548548               
    549549                /* Remove him/her from the conversations to prevent PART messages after he/she QUIT already */
    550                 for( c = gc->conversations; c; c = c->next )
     550                for( c = ic->conversations; c; c = c->next )
    551551                        remove_chat_buddy_silent( c, handle );
    552552        }
    553553       
    554         if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "oscar" ) == 0 || strcmp( gc->acc->prpl->name, "icq" ) == 0 ) )
     554        if( ( type & UC_UNAVAILABLE ) && ( strcmp( ic->acc->prpl->name, "oscar" ) == 0 || strcmp( ic->acc->prpl->name, "icq" ) == 0 ) )
    555555        {
    556556                u->away = g_strdup( "Away" );
    557557        }
    558         else if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "jabber" ) == 0 ) )
     558        else if( ( type & UC_UNAVAILABLE ) && ( strcmp( ic->acc->prpl->name, "jabber" ) == 0 ) )
    559559        {
    560560                if( type & UC_DND )
     
    565565                        u->away = g_strdup( "Away" );
    566566        }
    567         else if( ( type & UC_UNAVAILABLE ) && gc->acc->prpl->get_status_string )
    568         {
    569                 u->away = g_strdup( gc->acc->prpl->get_status_string( gc, type ) );
     567        else if( ( type & UC_UNAVAILABLE ) && ic->acc->prpl->get_status_string )
     568        {
     569                u->away = g_strdup( ic->acc->prpl->get_status_string( ic, type ) );
    570570        }
    571571        else
     
    573573       
    574574        /* LISPy... */
    575         if( ( set_getbool( &gc->irc->set, "away_devoice" ) ) &&         /* Don't do a thing when user doesn't want it */
     575        if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) &&         /* Don't do a thing when user doesn't want it */
    576576            ( u->online ) &&                                            /* Don't touch offline people */
    577577            ( ( ( u->online != oo ) && !u->away ) ||                    /* Voice joining people */
    578578              ( ( u->online == oo ) && ( oa == !u->away ) ) ) )         /* (De)voice people changing state */
    579579        {
    580                 irc_write( gc->irc, ":%s MODE %s %cv %s", gc->irc->myhost,
    581                                                                 gc->irc->channel, u->away?'-':'+', u->nick );
    582         }
    583 }
    584 
    585 void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 flags, time_t mtime, gint len )
    586 {
    587         irc_t *irc = gc->irc;
     580                irc_write( ic->irc, ":%s MODE %s %cv %s", ic->irc->myhost,
     581                                                                ic->irc->channel, u->away?'-':'+', u->nick );
     582        }
     583}
     584
     585void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 flags, time_t mtime, gint len )
     586{
     587        irc_t *irc = ic->irc;
    588588        user_t *u;
    589589       
    590         u = user_findhandle( gc, handle );
     590        u = user_findhandle( ic, handle );
    591591       
    592592        if( !u )
     
    597597                {
    598598                        if( set_getbool( &irc->set, "debug" ) )
    599                                 serv_got_crap( gc, "Ignoring message from unknown handle %s", handle );
     599                                serv_got_crap( ic, "Ignoring message from unknown handle %s", handle );
    600600                       
    601601                        return;
     
    613613                        }
    614614                       
    615                         add_buddy( gc, NULL, handle, NULL );
    616                         u = user_findhandle( gc, handle );
     615                        add_buddy( ic, NULL, handle, NULL );
     616                        u = user_findhandle( ic, handle );
    617617                        u->is_private = private;
    618618                }
    619619                else
    620620                {
    621                         serv_got_crap( gc, "Message from unknown handle %s:", handle );
     621                        serv_got_crap( ic, "Message from unknown handle %s:", handle );
    622622                        u = user_find( irc, irc->mynick );
    623623                }
    624624        }
    625625       
    626         if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||
    627             ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )
     626        if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
     627            ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
    628628                strip_html( msg );
    629629
     
    661661}
    662662
    663 void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int type )
     663void serv_got_typing( struct im_connection *ic, char *handle, int timeout, int type )
    664664{
    665665        user_t *u;
    666666       
    667         if( !set_getbool( &gc->irc->set, "typing_notice" ) )
     667        if( !set_getbool( &ic->irc->set, "typing_notice" ) )
    668668                return;
    669669       
    670         if( ( u = user_findhandle( gc, handle ) ) ) {
     670        if( ( u = user_findhandle( ic, handle ) ) ) {
    671671                /* If type is:
    672672                 * 0: user has stopped typing
     
    677677                        char buf[256];
    678678                        g_snprintf(buf, 256, "\1TYPING %d\1", type);
    679                         irc_privmsg( gc->irc, u, "PRIVMSG", gc->irc->nick, NULL, buf );
    680                 }
    681         }
    682 }
    683 
    684 void serv_got_chat_left( struct conversation *c )
    685 {
    686         struct gaim_connection *gc = c->gc;
    687         struct conversation *l = NULL;
     679                        irc_privmsg( ic->irc, u, "PRIVMSG", ic->irc->nick, NULL, buf );
     680                }
     681        }
     682}
     683
     684void serv_got_chat_left( struct groupchat *c )
     685{
     686        struct im_connection *ic = c->ic;
     687        struct groupchat *l = NULL;
    688688        GList *ir;
    689689       
    690         if( set_getbool( &gc->irc->set, "debug" ) )
    691                 serv_got_crap( gc, "You were removed from conversation 0x%x", (int) c );
     690        if( set_getbool( &ic->irc->set, "debug" ) )
     691                serv_got_crap( ic, "You were removed from conversation 0x%x", (int) c );
    692692       
    693693        if( c )
     
    697697                        user_t *u, *r;
    698698                       
    699                         r = user_find( gc->irc, gc->irc->mynick );
    700                         irc_privmsg( gc->irc, r, "PRIVMSG", c->channel, "", "Cleaning up channel, bye!" );
     699                        r = user_find( ic->irc, ic->irc->mynick );
     700                        irc_privmsg( ic->irc, r, "PRIVMSG", c->channel, "", "Cleaning up channel, bye!" );
    701701                       
    702                         u = user_find( gc->irc, gc->irc->nick );
    703                         irc_kick( gc->irc, u, c->channel, r );
    704                         /* irc_part( gc->irc, u, c->channel ); */
     702                        u = user_find( ic->irc, ic->irc->nick );
     703                        irc_kick( ic->irc, u, c->channel, r );
     704                        /* irc_part( ic->irc, u, c->channel ); */
    705705                }
    706706               
     
    708708                        l->next = c->next;
    709709                else
    710                         gc->conversations = c->next;
     710                        ic->conversations = c->next;
    711711               
    712712                for( ir = c->in_room; ir; ir = ir->next )
     
    719719}
    720720
    721 void serv_got_chat_in( struct conversation *c, char *who, int whisper, char *msg, time_t mtime )
    722 {
    723         struct gaim_connection *gc = c->gc;
     721void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, time_t mtime )
     722{
     723        struct im_connection *ic = c->ic;
    724724        user_t *u;
    725725       
    726726        /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */
    727         if( g_strcasecmp( who, gc->username ) == 0 )
     727        if( g_strcasecmp( who, ic->username ) == 0 )
    728728                return;
    729729       
    730         u = user_findhandle( gc, who );
    731        
    732         if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||
    733             ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )
     730        u = user_findhandle( ic, who );
     731       
     732        if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
     733            ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
    734734                strip_html( msg );
    735735       
    736736        if( c && u )
    737                 irc_privmsg( gc->irc, u, "PRIVMSG", c->channel, "", msg );
     737                irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", msg );
    738738        else
    739                 serv_got_crap( gc, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg );
    740 }
    741 
    742 struct conversation *serv_got_joined_chat( struct gaim_connection *gc, char *handle )
    743 {
    744         struct conversation *c;
     739                serv_got_crap( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg );
     740}
     741
     742struct groupchat *serv_got_joined_chat( struct im_connection *ic, char *handle )
     743{
     744        struct groupchat *c;
    745745       
    746746        /* This one just creates the conversation structure, user won't see anything yet */
    747747       
    748         if( gc->conversations )
    749         {
    750                 for( c = gc->conversations; c->next; c = c->next );
    751                 c = c->next = g_new0( struct conversation, 1 );
     748        if( ic->conversations )
     749        {
     750                for( c = ic->conversations; c->next; c = c->next );
     751                c = c->next = g_new0( struct groupchat, 1 );
    752752        }
    753753        else
    754                 gc->conversations = c = g_new0( struct conversation, 1 );
    755        
    756         c->gc = gc;
     754                ic->conversations = c = g_new0( struct groupchat, 1 );
     755       
     756        c->ic = ic;
    757757        c->title = g_strdup( handle );
    758         c->channel = g_strdup_printf( "&chat_%03d", gc->irc->c_id++ );
    759        
    760         if( set_getbool( &gc->irc->set, "debug" ) )
    761                 serv_got_crap( gc, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle );
     758        c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ );
     759       
     760        if( set_getbool( &ic->irc->set, "debug" ) )
     761                serv_got_crap( ic, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle );
    762762       
    763763        return c;
     
    767767/* buddy_chat.c */
    768768
    769 void add_chat_buddy( struct conversation *b, char *handle )
    770 {
    771         user_t *u = user_findhandle( b->gc, handle );
     769void add_chat_buddy( struct groupchat *b, char *handle )
     770{
     771        user_t *u = user_findhandle( b->ic, handle );
    772772        int me = 0;
    773773       
    774         if( set_getbool( &b->gc->irc->set, "debug" ) )
    775                 serv_got_crap( b->gc, "User %s added to conversation 0x%x", handle, (int) b );
     774        if( set_getbool( &b->ic->irc->set, "debug" ) )
     775                serv_got_crap( b->ic, "User %s added to conversation 0x%x", handle, (int) b );
    776776       
    777777        /* It might be yourself! */
    778         if( b->gc->acc->prpl->handle_cmp( handle, b->gc->username ) == 0 )
    779         {
    780                 u = user_find( b->gc->irc, b->gc->irc->nick );
     778        if( b->ic->acc->prpl->handle_cmp( handle, b->ic->username ) == 0 )
     779        {
     780                u = user_find( b->ic->irc, b->ic->irc->nick );
    781781                if( !b->joined )
    782                         irc_join( b->gc->irc, u, b->channel );
     782                        irc_join( b->ic->irc, u, b->channel );
    783783                b->joined = me = 1;
    784784        }
     
    788788        if( !u )
    789789        {
    790                 add_buddy( b->gc, NULL, handle, NULL );
    791                 u = user_findhandle( b->gc, handle );
     790                add_buddy( b->ic, NULL, handle, NULL );
     791                u = user_findhandle( b->ic, handle );
    792792        }
    793793       
     
    796796        {
    797797                if( b->joined )
    798                         irc_join( b->gc->irc, u, b->channel );
     798                        irc_join( b->ic->irc, u, b->channel );
    799799                b->in_room = g_list_append( b->in_room, g_strdup( handle ) );
    800800        }
    801801}
    802802
    803 void remove_chat_buddy( struct conversation *b, char *handle, char *reason )
     803void remove_chat_buddy( struct groupchat *b, char *handle, char *reason )
    804804{
    805805        user_t *u;
    806806        int me = 0;
    807807       
    808         if( set_getbool( &b->gc->irc->set, "debug" ) )
    809                 serv_got_crap( b->gc, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" );
     808        if( set_getbool( &b->ic->irc->set, "debug" ) )
     809                serv_got_crap( b->ic, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" );
    810810       
    811811        /* It might be yourself! */
    812         if( g_strcasecmp( handle, b->gc->username ) == 0 )
    813         {
    814                 u = user_find( b->gc->irc, b->gc->irc->nick );
     812        if( g_strcasecmp( handle, b->ic->username ) == 0 )
     813        {
     814                u = user_find( b->ic->irc, b->ic->irc->nick );
    815815                b->joined = 0;
    816816                me = 1;
     
    818818        else
    819819        {
    820                 u = user_findhandle( b->gc, handle );
     820                u = user_findhandle( b->ic, handle );
    821821        }
    822822       
    823823        if( remove_chat_buddy_silent( b, handle ) )
    824824                if( ( b->joined || me ) && u )
    825                         irc_part( b->gc->irc, u, b->channel );
    826 }
    827 
    828 static int remove_chat_buddy_silent( struct conversation *b, char *handle )
     825                        irc_part( b->ic->irc, u, b->channel );
     826}
     827
     828static int remove_chat_buddy_silent( struct groupchat *b, char *handle )
    829829{
    830830        GList *i;
     
    850850/* Misc. BitlBee stuff which shouldn't really be here */
    851851
    852 struct conversation *chat_by_channel( char *channel )
    853 {
    854         struct gaim_connection *gc;
    855         struct conversation *c;
     852struct groupchat *chat_by_channel( char *channel )
     853{
     854        struct im_connection *ic;
     855        struct groupchat *c;
    856856        GSList *l;
    857857       
     
    859859        for( l = connections; l; l = l->next )
    860860        {
    861                 gc = l->data;
    862                 for( c = gc->conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next );
     861                ic = l->data;
     862                for( c = ic->conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next );
    863863                if( c )
    864864                        return c;
     
    899899                while( u )
    900900                {
    901                         if( u->gc && u->online && !u->away )
     901                        if( u->ic && u->online && !u->away )
    902902                        {
    903903                                if( ( strlen( list ) + strlen( u->nick ) ) >= 79 )
     
    933933   them all from some wrappers. We'll start to define some down here: */
    934934
    935 int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags )
     935int bim_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags )
    936936{
    937937        char *buf = NULL;
    938938        int st;
    939939       
    940         if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
     940        if( ( ic->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
    941941        {
    942942                buf = escape_html( msg );
     
    944944        }
    945945       
    946         st = gc->acc->prpl->send_im( gc, handle, msg, strlen( msg ), flags );
     946        st = ic->acc->prpl->send_im( ic, handle, msg, flags );
    947947        g_free( buf );
    948948       
     
    950950}
    951951
    952 int bim_chat_msg( struct conversation *c, char *msg )
     952int bim_chat_msg( struct groupchat *c, char *msg, int flags )
    953953{
    954954        char *buf = NULL;
    955955        int st;
    956956       
    957         if( ( c->gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
     957        if( ( c->ic->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
    958958        {
    959959                buf = escape_html( msg );
     
    961961        }
    962962       
    963         st = c->gc->acc->prpl->chat_send( c, msg );
     963        c->ic->acc->prpl->chat_send( c, msg, flags );
    964964        g_free( buf );
    965965       
    966         return st;
     966        return 1;
    967967}
    968968
    969969static char *bim_away_alias_find( GList *gcm, char *away );
    970970
    971 int bim_set_away( struct gaim_connection *gc, char *away )
     971int bim_set_away( struct im_connection *ic, char *away )
    972972{
    973973        GList *m, *ms;
     
    975975       
    976976        if( !away ) away = "";
    977         ms = m = gc->acc->prpl->away_states( gc );
     977        ms = m = ic->acc->prpl->away_states( ic );
    978978       
    979979        while( m )
     
    996996        if( m )
    997997        {
    998                 gc->acc->prpl->set_away( gc, m->data, *away ? away : NULL );
     998                ic->acc->prpl->set_away( ic, m->data, *away ? away : NULL );
    999999        }
    10001000        else
     
    10031003                if( s )
    10041004                {
    1005                         gc->acc->prpl->set_away( gc, s, away );
    1006                         if( set_getbool( &gc->irc->set, "debug" ) )
    1007                                 serv_got_crap( gc, "Setting away state to %s", s );
     1005                        ic->acc->prpl->set_away( ic, s, away );
     1006                        if( set_getbool( &ic->irc->set, "debug" ) )
     1007                                serv_got_crap( ic, "Setting away state to %s", s );
    10081008                }
    10091009                else
    1010                         gc->acc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );
     1010                        ic->acc->prpl->set_away( ic, GAIM_AWAY_CUSTOM, away );
    10111011        }
    10121012       
     
    10561056}
    10571057
    1058 void bim_add_allow( struct gaim_connection *gc, char *handle )
    1059 {
    1060         if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) == NULL )
    1061         {
    1062                 gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) );
    1063         }
    1064        
    1065         gc->acc->prpl->add_permit( gc, handle );
    1066 }
    1067 
    1068 void bim_rem_allow( struct gaim_connection *gc, char *handle )
     1058void bim_add_allow( struct im_connection *ic, char *handle )
     1059{
     1060        if( g_slist_find_custom( ic->permit, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) == NULL )
     1061        {
     1062                ic->permit = g_slist_prepend( ic->permit, g_strdup( handle ) );
     1063        }
     1064       
     1065        ic->acc->prpl->add_permit( ic, handle );
     1066}
     1067
     1068void bim_rem_allow( struct im_connection *ic, char *handle )
    10691069{
    10701070        GSList *l;
    10711071       
    1072         if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) ) )
     1072        if( ( l = g_slist_find_custom( ic->permit, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) ) )
    10731073        {
    10741074                g_free( l->data );
    1075                 gc->permit = g_slist_delete_link( gc->permit, l );
    1076         }
    1077        
    1078         gc->acc->prpl->rem_permit( gc, handle );
    1079 }
    1080 
    1081 void bim_add_block( struct gaim_connection *gc, char *handle )
    1082 {
    1083         if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) == NULL )
    1084         {
    1085                 gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) );
    1086         }
    1087        
    1088         gc->acc->prpl->add_deny( gc, handle );
    1089 }
    1090 
    1091 void bim_rem_block( struct gaim_connection *gc, char *handle )
     1075                ic->permit = g_slist_delete_link( ic->permit, l );
     1076        }
     1077       
     1078        ic->acc->prpl->rem_permit( ic, handle );
     1079}
     1080
     1081void bim_add_block( struct im_connection *ic, char *handle )
     1082{
     1083        if( g_slist_find_custom( ic->deny, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) == NULL )
     1084        {
     1085                ic->deny = g_slist_prepend( ic->deny, g_strdup( handle ) );
     1086        }
     1087       
     1088        ic->acc->prpl->add_deny( ic, handle );
     1089}
     1090
     1091void bim_rem_block( struct im_connection *ic, char *handle )
    10921092{
    10931093        GSList *l;
    10941094       
    1095         if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) ) )
     1095        if( ( l = g_slist_find_custom( ic->deny, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) ) )
    10961096        {
    10971097                g_free( l->data );
    1098                 gc->deny = g_slist_delete_link( gc->deny, l );
    1099         }
    1100        
    1101         gc->acc->prpl->rem_deny( gc, handle );
    1102 }
     1098                ic->deny = g_slist_delete_link( ic->deny, l );
     1099        }
     1100       
     1101        ic->acc->prpl->rem_deny( ic, handle );
     1102}
Note: See TracChangeset for help on using the changeset viewer.