Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    rcca0692 r573dab0  
    3838#include "chat.h"
    3939
    40 static int remove_chat_buddy_silent( struct groupchat *b, const char *handle );
    41 static char *format_timestamp( irc_t *irc, time_t msg_ts );
    42 
    4340GSList *connections;
    4441
     
    9289}
    9390#endif
    94 
    95 /* nogaim.c */
    9691
    9792GList *protocols = NULL;
     
    126121}
    127122
    128 /* nogaim.c */
    129123void nogaim_init()
    130124{
     
    133127        extern void byahoo_initmodule();
    134128        extern void jabber_initmodule();
    135         extern void twitter_initmodule();
    136129
    137130#ifdef WITH_MSN
     
    151144#endif
    152145
    153 #ifdef WITH_TWITTER
    154         twitter_initmodule();
    155 #endif
    156 
    157146#ifdef WITH_PLUGINS
    158147        load_plugins();
     
    162151GSList *get_connections() { return connections; }
    163152
    164 /* multi.c */
    165 
    166153struct im_connection *imcb_new( account_t *acc )
    167154{
     
    170157        ic = g_new0( struct im_connection, 1 );
    171158       
    172         ic->irc = acc->irc;
     159        ic->bee = acc->bee;
    173160        ic->acc = acc;
    174161        acc->ic = ic;
     
    184171       
    185172        /* Destroy the pointer to this connection from the account list */
    186         for( a = ic->irc->accounts; a; a = a->next )
     173        for( a = ic->bee->accounts; a; a = a->next )
    187174                if( a->ic == ic )
    188175                {
     
    205192        va_end( params );
    206193
    207         if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
    208             ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
     194        if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) ||
     195            ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) )
    209196                strip_html( text );
    210197       
    211198        /* Try to find a different connection on the same protocol. */
    212         for( a = ic->irc->accounts; a; a = a->next )
     199        for( a = ic->bee->accounts; a; a = a->next )
    213200                if( a->prpl == ic->acc->prpl && a->ic != ic )
    214201                        break;
     
    216203        /* If we found one, include the screenname in the message. */
    217204        if( a )
    218                 irc_usermsg( ic->irc, "%s(%s) - %s", ic->acc->prpl->name, ic->acc->user, text );
     205                /* FIXME(wilmer): ui_log callback or so */
     206                irc_usermsg( ic->bee->ui_data, "%s(%s) - %s", ic->acc->prpl->name, ic->acc->user, text );
    219207        else
    220                 irc_usermsg( ic->irc, "%s - %s", ic->acc->prpl->name, text );
     208                irc_usermsg( ic->bee->ui_data, "%s - %s", ic->acc->prpl->name, text );
    221209       
    222210        g_free( text );
     
    269257void imcb_connected( struct im_connection *ic )
    270258{
    271         irc_t *irc = ic->irc;
    272         struct chat *c;
    273         user_t *u;
    274        
    275259        /* MSN servers sometimes redirect you to a different server and do
    276260           the whole login sequence again, so these "late" calls to this
     
    279263                return;
    280264       
    281         u = user_find( ic->irc, ic->irc->nick );
    282        
    283265        imcb_log( ic, "Logged in" );
    284266       
     
    293275        ic->acc->auto_reconnect_delay = 0;
    294276       
     277        /*
    295278        for( c = irc->chatrooms; c; c = c->next )
    296279        {
     
    301284                        chat_join( irc, c, NULL );
    302285        }
     286        */
    303287}
    304288
     
    308292       
    309293        a->reconnect = 0;
    310         account_on( a->irc, a );
     294        account_on( a->bee, a );
    311295       
    312296        return( FALSE );        /* Only have to run the timeout once */
     
    321305void imc_logout( struct im_connection *ic, int allow_reconnect )
    322306{
    323         irc_t *irc = ic->irc;
    324         user_t *t, *u;
     307        bee_t *bee = ic->bee;
    325308        account_t *a;
     309        GSList *l;
    326310        int delay;
    327311       
     
    343327        ic->away = NULL;
    344328       
    345         u = irc->users;
    346         while( u )
    347         {
    348                 if( u->ic == ic )
    349                 {
    350                         t = u->next;
    351                         user_del( irc, u->nick );
    352                         u = t;
    353                 }
    354                 else
    355                         u = u->next;
    356         }
    357        
    358         query_del_by_conn( ic->irc, ic );
    359        
    360         for( a = irc->accounts; a; a = a->next )
     329        for( l = bee->users; l; )
     330        {
     331                bee_user_t *bu = l->data;
     332                GSList *next = l->next;
     333               
     334                if( bu->ic == ic )
     335                        bee_user_free( bee, bu );
     336               
     337                l = next;
     338        }
     339       
     340        //query_del_by_conn( ic->irc, ic );
     341       
     342        for( a = bee->accounts; a; a = a->next )
    361343                if( a->ic == ic )
    362344                        break;
     
    366348                /* Uhm... This is very sick. */
    367349        }
    368         else if( allow_reconnect && set_getbool( &irc->set, "auto_reconnect" ) &&
     350        else if( allow_reconnect && set_getbool( &bee->set, "auto_reconnect" ) &&
    369351                 set_getbool( &a->set, "auto_reconnect" ) &&
    370352                 ( delay = account_reconnect_delay( a ) ) > 0 )
     
    377359}
    378360
    379 
    380 /* dialogs.c */
    381 
    382361void imcb_ask( struct im_connection *ic, char *msg, void *data,
    383362               query_callback doit, query_callback dont )
    384363{
    385         query_add( ic->irc, ic, msg, doit, dont, data );
    386 }
    387 
    388 
    389 /* list.c */
     364        query_add( (irc_t *) ic->bee->ui_data, ic, msg, doit, dont, data );
     365}
    390366
    391367void imcb_add_buddy( struct im_connection *ic, const char *handle, const char *group )
    392368{
    393         user_t *u;
    394         char nick[MAX_NICK_LENGTH+1], *s;
    395         irc_t *irc = ic->irc;
    396        
    397         if( user_findhandle( ic, handle ) )
    398         {
    399                 if( set_getbool( &irc->set, "debug" ) )
     369        bee_user_t *bu;
     370        bee_t *bee = ic->bee;
     371       
     372        if( bee_user_by_handle( bee, ic, handle ) )
     373        {
     374                if( set_getbool( &bee->set, "debug" ) )
    400375                        imcb_log( ic, "User already exists, ignoring add request: %s", handle );
    401376               
     
    408383        }
    409384       
    410         memset( nick, 0, MAX_NICK_LENGTH + 1 );
    411         strcpy( nick, nick_get( ic->acc, handle ) );
    412        
    413         u = user_add( ic->irc, nick );
    414        
    415 //      if( !realname || !*realname ) realname = nick;
    416 //      u->realname = g_strdup( realname );
    417        
    418         if( ( s = strchr( handle, '@' ) ) )
    419         {
    420                 u->host = g_strdup( s + 1 );
    421                 u->user = g_strndup( handle, s - handle );
    422         }
    423         else if( ic->acc->server )
    424         {
    425                 u->host = g_strdup( ic->acc->server );
    426                 u->user = g_strdup( handle );
    427                
    428                 /* s/ /_/ ... important for AOL screennames */
    429                 for( s = u->user; *s; s ++ )
    430                         if( *s == ' ' )
    431                                 *s = '_';
    432         }
    433         else
    434         {
    435                 u->host = g_strdup( ic->acc->prpl->name );
    436                 u->user = g_strdup( handle );
    437         }
    438        
    439         u->ic = ic;
    440         u->handle = g_strdup( handle );
    441         if( group ) u->group = g_strdup( group );
    442         u->send_handler = buddy_send_handler;
    443         u->last_typing_notice = 0;
    444 }
    445 
    446 struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle )
    447 {
    448         static struct buddy b[1];
    449         user_t *u;
    450        
    451         u = user_findhandle( ic, handle );
    452        
    453         if( !u )
    454                 return( NULL );
    455        
    456         memset( b, 0, sizeof( b ) );
    457         strncpy( b->name, handle, 80 );
    458         strncpy( b->show, u->realname, BUDDY_ALIAS_MAXLEN );
    459         b->present = u->online;
    460         b->ic = u->ic;
    461        
    462         return( b );
    463 }
    464 
    465 void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *realname )
    466 {
    467         user_t *u = user_findhandle( ic, handle );
    468         char *set;
    469        
    470         if( !u || !realname ) return;
    471        
    472         if( g_strcasecmp( u->realname, realname ) != 0 )
    473         {
    474                 if( u->realname != u->nick ) g_free( u->realname );
    475                
    476                 u->realname = g_strdup( realname );
    477                
    478                 if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) )
    479                         imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname );
    480         }
    481        
    482         set = set_getstr( &ic->acc->set, "nick_source" );
    483         if( strcmp( set, "handle" ) != 0 )
    484         {
    485                 char *name = g_strdup( realname );
    486                
    487                 if( strcmp( set, "first_name" ) == 0 )
    488                 {
    489                         int i;
    490                         for( i = 0; name[i] && !isspace( name[i] ); i ++ ) {}
    491                         name[i] = '\0';
    492                 }
    493                
    494                 imcb_buddy_nick_hint( ic, handle, name );
    495                
    496                 g_free( name );
     385        bu = bee_user_new( bee, ic, handle );
     386        bu->group = g_strdup( group );
     387}
     388
     389void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *fullname )
     390{
     391        bee_t *bee = ic->bee;
     392        bee_user_t *bu = bee_user_by_handle( bee, ic, handle );
     393       
     394        if( !bu || !fullname ) return;
     395       
     396        if( !bu->fullname || strcmp( bu->fullname, fullname ) != 0 )
     397        {
     398                g_free( bu->fullname );
     399                bu->fullname = g_strdup( fullname );
     400               
     401                if( bee->ui->user_fullname )
     402                        bee->ui->user_fullname( bee, bu );
    497403        }
    498404}
     
    500406void imcb_remove_buddy( struct im_connection *ic, const char *handle, char *group )
    501407{
    502         user_t *u;
    503        
    504         if( ( u = user_findhandle( ic, handle ) ) )
    505                 user_del( ic->irc, u->nick );
     408        bee_user_free( ic->bee, bee_user_by_handle( ic->bee, ic, handle ) );
    506409}
    507410
     
    510413void imcb_buddy_nick_hint( struct im_connection *ic, const char *handle, const char *nick )
    511414{
     415#if 0
    512416        user_t *u = user_findhandle( ic, handle );
    513417        char newnick[MAX_NICK_LENGTH+1], *orig_nick;
     
    524428                /* Some processing to make sure this string is a valid IRC nickname. */
    525429                nick_strip( newnick );
    526                 if( set_getbool( &ic->irc->set, "lcnicks" ) )
     430                if( set_getbool( &ic->bee->set, "lcnicks" ) )
    527431                        nick_lc( newnick );
    528432               
     
    541445                }
    542446        }
     447#endif
    543448}
    544449
     
    585490        data->ic = ic;
    586491        data->handle = g_strdup( handle );
    587         query_add( ic->irc, ic, s, imcb_ask_auth_cb_yes, imcb_ask_auth_cb_no, data );
     492        query_add( (irc_t *) ic->bee->ui_data, ic, s,
     493                   imcb_ask_auth_cb_yes, imcb_ask_auth_cb_no, data );
    588494}
    589495
     
    610516       
    611517        /* TODO: Make a setting for this! */
    612         if( user_findhandle( ic, handle ) != NULL )
     518        if( bee_user_by_handle( ic->bee, ic, handle ) != NULL )
    613519                return;
    614520       
     
    617523        data->ic = ic;
    618524        data->handle = g_strdup( handle );
    619         query_add( ic->irc, ic, s, imcb_ask_add_cb_yes, imcb_ask_add_cb_no, data );
    620 }
    621 
    622 
    623 /* server.c */                   
    624 
    625 void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message )
    626 {
    627         user_t *u;
    628         int oa, oo;
    629        
    630         u = user_findhandle( ic, (char*) handle );
    631        
    632         if( !u )
    633         {
    634                 if( g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "add" ) == 0 )
    635                 {
    636                         imcb_add_buddy( ic, (char*) handle, NULL );
    637                         u = user_findhandle( ic, (char*) handle );
    638                 }
    639                 else
    640                 {
    641                         if( set_getbool( &ic->irc->set, "debug" ) || g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "ignore" ) != 0 )
    642                         {
    643                                 imcb_log( ic, "imcb_buddy_status() for unknown handle %s:", handle );
    644                                 imcb_log( ic, "flags = %d, state = %s, message = %s", flags,
    645                                           state ? state : "NULL", message ? message : "NULL" );
    646                         }
    647                        
    648                         return;
    649                 }
    650         }
    651        
    652         oa = u->away != NULL;
    653         oo = u->online;
    654        
    655         g_free( u->away );
    656         g_free( u->status_msg );
    657         u->away = u->status_msg = NULL;
    658        
    659         if( ( flags & OPT_LOGGED_IN ) && !u->online )
    660         {
    661                 irc_spawn( ic->irc, u );
    662                 u->online = 1;
    663         }
    664         else if( !( flags & OPT_LOGGED_IN ) && u->online )
    665         {
    666                 struct groupchat *c;
    667                
    668                 irc_kill( ic->irc, u );
    669                 u->online = 0;
    670                
    671                 /* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */
    672                 for( c = ic->groupchats; c; c = c->next )
    673                         remove_chat_buddy_silent( c, handle );
    674         }
    675        
    676         if( flags & OPT_AWAY )
    677         {
    678                 if( state && message )
    679                 {
    680                         u->away = g_strdup_printf( "%s (%s)", state, message );
    681                 }
    682                 else if( state )
    683                 {
    684                         u->away = g_strdup( state );
    685                 }
    686                 else if( message )
    687                 {
    688                         u->away = g_strdup( message );
    689                 }
    690                 else
    691                 {
    692                         u->away = g_strdup( "Away" );
    693                 }
    694         }
    695         else
    696         {
    697                 u->status_msg = g_strdup( message );
    698         }
    699        
    700         /* LISPy... */
    701         if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) &&         /* Don't do a thing when user doesn't want it */
    702             ( u->online ) &&                                            /* Don't touch offline people */
    703             ( ( ( u->online != oo ) && !u->away ) ||                    /* Voice joining people */
    704               ( ( u->online == oo ) && ( oa == !u->away ) ) ) )         /* (De)voice people changing state */
    705         {
    706                 char *from;
    707                
    708                 if( set_getbool( &ic->irc->set, "simulate_netsplit" ) )
    709                 {
    710                         from = g_strdup( ic->irc->myhost );
    711                 }
    712                 else
    713                 {
    714                         from = g_strdup_printf( "%s!%s@%s", ic->irc->mynick, ic->irc->mynick,
    715                                                             ic->irc->myhost );
    716                 }
    717                 irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel,
    718                                                           u->away?'-':'+', u->nick );
    719                 g_free( from );
    720         }
    721 }
    722 
    723 void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at )
    724 {
    725         irc_t *irc = ic->irc;
    726         char *wrapped, *ts = NULL;
    727         user_t *u;
    728        
    729         u = user_findhandle( ic, handle );
    730        
    731         if( !u )
    732         {
    733                 char *h = set_getstr( &irc->set, "handle_unknown" );
    734                
    735                 if( g_strcasecmp( h, "ignore" ) == 0 )
    736                 {
    737                         if( set_getbool( &irc->set, "debug" ) )
    738                                 imcb_log( ic, "Ignoring message from unknown handle %s", handle );
    739                        
    740                         return;
    741                 }
    742                 else if( g_strncasecmp( h, "add", 3 ) == 0 )
    743                 {
    744                         int private = set_getbool( &irc->set, "private" );
    745                        
    746                         if( h[3] )
    747                         {
    748                                 if( g_strcasecmp( h + 3, "_private" ) == 0 )
    749                                         private = 1;
    750                                 else if( g_strcasecmp( h + 3, "_channel" ) == 0 )
    751                                         private = 0;
    752                         }
    753                        
    754                         imcb_add_buddy( ic, handle, NULL );
    755                         u = user_findhandle( ic, handle );
    756                         u->is_private = private;
    757                 }
    758                 else
    759                 {
    760                         imcb_log( ic, "Message from unknown handle %s:", handle );
    761                         u = user_find( irc, irc->mynick );
    762                 }
    763         }
    764        
    765         if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
    766             ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
    767                 strip_html( msg );
    768        
    769         if( set_getbool( &ic->irc->set, "display_timestamps" ) &&
    770             ( ts = format_timestamp( irc, sent_at ) ) )
    771         {
    772                 char *new = g_strconcat( ts, msg, NULL );
    773                 g_free( ts );
    774                 ts = msg = new;
    775         }
    776        
    777         wrapped = word_wrap( msg, 425 );
    778         irc_msgfrom( irc, u->nick, wrapped );
    779         g_free( wrapped );
    780         g_free( ts );
    781 }
    782 
    783 void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags )
    784 {
    785         user_t *u;
    786        
    787         if( !set_getbool( &ic->irc->set, "typing_notice" ) )
    788                 return;
    789        
    790         if( ( u = user_findhandle( ic, handle ) ) )
    791         {
    792                 char buf[256];
    793                
    794                 g_snprintf( buf, 256, "\1TYPING %d\1", ( flags >> 8 ) & 3 );
    795                 irc_privmsg( ic->irc, u, "PRIVMSG", ic->irc->nick, NULL, buf );
    796         }
     525        query_add( (irc_t *) ic->bee->ui_data, ic, s,
     526                   imcb_ask_add_cb_yes, imcb_ask_add_cb_no, data );
     527}
     528
     529struct bee_user *imcb_buddy_by_handle( struct im_connection *ic, const char *handle )
     530{
     531        return bee_user_by_handle( ic->bee, ic, handle );
    797532}
    798533
    799534struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle )
    800535{
     536#if 0
    801537        struct groupchat *c;
    802538       
     
    816552        c->topic = g_strdup_printf( "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->title );
    817553       
    818         if( set_getbool( &ic->irc->set, "debug" ) )
     554        if( set_getbool( &ic->bee->set, "debug" ) )
    819555                imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle );
    820556       
    821557        return c;
    822 }
    823 
    824 void imcb_chat_name_hint( struct groupchat *c, const char *name )
    825 {
    826         if( !c->joined )
    827         {
    828                 struct im_connection *ic = c->ic;
    829                 char stripped[MAX_NICK_LENGTH+1], *full_name;
    830                
    831                 strncpy( stripped, name, MAX_NICK_LENGTH );
    832                 stripped[MAX_NICK_LENGTH] = '\0';
    833                 nick_strip( stripped );
    834                 if( set_getbool( &ic->irc->set, "lcnicks" ) )
    835                         nick_lc( stripped );
    836                
    837                 full_name = g_strdup_printf( "&%s", stripped );
    838                
    839                 if( stripped[0] &&
    840                     nick_cmp( stripped, ic->irc->channel + 1 ) != 0 &&
    841                     irc_chat_by_channel( ic->irc, full_name ) == NULL )
    842                 {
    843                         g_free( c->channel );
    844                         c->channel = full_name;
    845                 }
    846                 else
    847                 {
    848                         g_free( full_name );
    849                 }
    850         }
     558#endif
     559        return NULL;
    851560}
    852561
    853562void imcb_chat_free( struct groupchat *c )
    854563{
     564#if 0
    855565        struct im_connection *ic = c->ic;
    856566        struct groupchat *l;
    857567        GList *ir;
    858568       
    859         if( set_getbool( &ic->irc->set, "debug" ) )
     569        if( set_getbool( &ic->bee->set, "debug" ) )
    860570                imcb_log( ic, "You were removed from conversation %p", c );
    861571       
     
    890600                g_free( c );
    891601        }
     602#endif
    892603}
    893604
    894605void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at )
    895606{
     607#if 0
    896608        struct im_connection *ic = c->ic;
    897609        char *wrapped;
     
    904616        u = user_findhandle( ic, who );
    905617       
    906         if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
    907             ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
     618        if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) ||
     619            ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) )
    908620                strip_html( msg );
    909621       
     
    911623        if( c && u )
    912624        {
    913                 char *ts = NULL;
    914                 if( set_getbool( &ic->irc->set, "display_timestamps" ) )
    915                         ts = format_timestamp( ic->irc, sent_at );
    916                 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, ts ? : "", wrapped );
    917                 g_free( ts );
     625                irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", wrapped );
    918626        }
    919627        else
     
    922630        }
    923631        g_free( wrapped );
     632#endif
    924633}
    925634
    926635void imcb_chat_log( struct groupchat *c, char *format, ... )
    927636{
     637#if 0
    928638        irc_t *irc = c->ic->irc;
    929639        va_list params;
     
    940650       
    941651        g_free( text );
     652#endif
    942653}
    943654
    944655void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at )
    945656{
     657#if 0
    946658        struct im_connection *ic = c->ic;
    947659        user_t *u = NULL;
     
    954666                u = user_findhandle( ic, who );
    955667       
    956         if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
    957             ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
     668        if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) ||
     669            ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) )
    958670                strip_html( topic );
    959671       
     
    963675        if( c->joined && u )
    964676                irc_write( ic->irc, ":%s!%s@%s TOPIC %s :%s", u->nick, u->user, u->host, c->channel, topic );
    965 }
    966 
    967 
    968 /* buddy_chat.c */
     677#endif
     678}
    969679
    970680void imcb_chat_add_buddy( struct groupchat *b, const char *handle )
    971681{
     682#if 0
    972683        user_t *u = user_findhandle( b->ic, handle );
    973684        int me = 0;
    974685       
    975         if( set_getbool( &b->ic->irc->set, "debug" ) )
     686        if( set_getbool( &b->ic->bee->set, "debug" ) )
    976687                imcb_log( b->ic, "User %s added to conversation %p", handle, b );
    977688       
     
    1000711                b->in_room = g_list_append( b->in_room, g_strdup( handle ) );
    1001712        }
     713#endif
    1002714}
    1003715
     
    1005717void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char *reason )
    1006718{
     719#if 0
    1007720        user_t *u;
    1008721        int me = 0;
    1009722       
    1010         if( set_getbool( &b->ic->irc->set, "debug" ) )
     723        if( set_getbool( &b->ic->bee->set, "debug" ) )
    1011724                imcb_log( b->ic, "User %s removed from conversation %p (%s)", handle, b, reason ? reason : "" );
    1012725       
     
    1028741        if( me || ( remove_chat_buddy_silent( b, handle ) && b->joined && u ) )
    1029742                irc_part( b->ic->irc, u, b->channel );
    1030 }
    1031 
     743#endif
     744}
     745
     746#if 0
    1032747static int remove_chat_buddy_silent( struct groupchat *b, const char *handle )
    1033748{
     
    1048763        }
    1049764       
    1050         return( 0 );
    1051 }
     765        return 0;
     766}
     767#endif
    1052768
    1053769
    1054770/* Misc. BitlBee stuff which shouldn't really be here */
    1055 
     771#if 0
    1056772char *set_eval_away_devoice( set_t *set, char *value )
    1057773{
     
    1066782        /* Horror.... */
    1067783       
    1068         if( st != set_getbool( &irc->set, "away_devoice" ) )
     784        if( st != set_getbool( &irc->b->set, "away_devoice" ) )
    1069785        {
    1070786                char list[80] = "";
     
    1108824        return value;
    1109825}
    1110 
    1111 char *set_eval_timezone( set_t *set, char *value )
    1112 {
    1113         char *s;
    1114        
    1115         if( strcmp( value, "local" ) == 0 ||
    1116             strcmp( value, "gmt" ) == 0 || strcmp( value, "utc" ) == 0 )
    1117                 return value;
    1118        
    1119         /* Otherwise: +/- at the beginning optional, then one or more numbers,
    1120            possibly followed by a colon and more numbers. Don't bother bound-
    1121            checking them since users are free to shoot themselves in the foot. */
    1122         s = value;
    1123         if( *s == '+' || *s == '-' )
    1124                 s ++;
    1125        
    1126         /* \d+ */
    1127         if( !isdigit( *s ) )
    1128                 return SET_INVALID;
    1129         while( *s && isdigit( *s ) ) s ++;
    1130        
    1131         /* EOS? */
    1132         if( *s == '\0' )
    1133                 return value;
    1134        
    1135         /* Otherwise, colon */
    1136         if( *s != ':' )
    1137                 return SET_INVALID;
    1138         s ++;
    1139        
    1140         /* \d+ */
    1141         if( !isdigit( *s ) )
    1142                 return SET_INVALID;
    1143         while( *s && isdigit( *s ) ) s ++;
    1144        
    1145         /* EOS */
    1146         return *s == '\0' ? value : SET_INVALID;
    1147 }
    1148 
    1149 static char *format_timestamp( irc_t *irc, time_t msg_ts )
    1150 {
    1151         time_t now_ts = time( NULL );
    1152         struct tm now, msg;
    1153         char *set;
    1154        
    1155         /* If the timestamp is <= 0 or less than a minute ago, discard it as
    1156            it doesn't seem to add to much useful info and/or might be noise. */
    1157         if( msg_ts <= 0 || msg_ts > now_ts - 60 )
    1158                 return NULL;
    1159        
    1160         set = set_getstr( &irc->set, "timezone" );
    1161         if( strcmp( set, "local" ) == 0 )
    1162         {
    1163                 localtime_r( &now_ts, &now );
    1164                 localtime_r( &msg_ts, &msg );
    1165         }
    1166         else
    1167         {
    1168                 int hr, min = 0, sign = 60;
    1169                
    1170                 if( set[0] == '-' )
    1171                 {
    1172                         sign *= -1;
    1173                         set ++;
    1174                 }
    1175                 else if( set[0] == '+' )
    1176                 {
    1177                         set ++;
    1178                 }
    1179                
    1180                 if( sscanf( set, "%d:%d", &hr, &min ) >= 1 )
    1181                 {
    1182                         msg_ts += sign * ( hr * 60 + min );
    1183                         now_ts += sign * ( hr * 60 + min );
    1184                 }
    1185                
    1186                 gmtime_r( &now_ts, &now );
    1187                 gmtime_r( &msg_ts, &msg );
    1188         }
    1189        
    1190         if( msg.tm_year == now.tm_year && msg.tm_yday == now.tm_yday )
    1191                 return g_strdup_printf( "\x02[\x02\x02\x02%02d:%02d:%02d\x02]\x02 ",
    1192                                         msg.tm_hour, msg.tm_min, msg.tm_sec );
    1193         else
    1194                 return g_strdup_printf( "\x02[\x02\x02\x02%04d-%02d-%02d "
    1195                                         "%02d:%02d:%02d\x02]\x02 ",
    1196                                         msg.tm_year + 1900, msg.tm_mon, msg.tm_mday,
    1197                                         msg.tm_hour, msg.tm_min, msg.tm_sec );
    1198 }
     826#endif
     827
     828
    1199829
    1200830/* The plan is to not allow straight calls to prpl functions anymore, but do
    1201831   them all from some wrappers. We'll start to define some down here: */
    1202832
    1203 int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags )
     833int imc_chat_msg( struct groupchat *c, char *msg, int flags )
    1204834{
    1205835        char *buf = NULL;
    1206         int st;
    1207        
    1208         if( ( ic->flags & OPT_DOES_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
     836       
     837        if( ( c->ic->flags & OPT_DOES_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
    1209838        {
    1210839                buf = escape_html( msg );
     
    1212841        }
    1213842       
    1214         st = ic->acc->prpl->buddy_msg( ic, handle, msg, flags );
    1215         g_free( buf );
    1216        
    1217         return st;
    1218 }
    1219 
    1220 int imc_chat_msg( struct groupchat *c, char *msg, int flags )
    1221 {
    1222         char *buf = NULL;
    1223        
    1224         if( ( c->ic->flags & OPT_DOES_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
    1225         {
    1226                 buf = escape_html( msg );
    1227                 msg = buf;
    1228         }
    1229        
    1230843        c->ic->acc->prpl->chat_msg( c, msg, flags );
    1231844        g_free( buf );
     
    1240853        char *away, *msg = NULL;
    1241854       
    1242         if( ic->acc->prpl->away_states == NULL ||
    1243             ic->acc->prpl->set_away == NULL )
    1244                 return 0;
    1245        
    1246855        away = set_getstr( &ic->acc->set, "away" ) ?
    1247              : set_getstr( &ic->irc->set, "away" );
     856             : set_getstr( &ic->bee->set, "away" );
    1248857        if( away && *away )
    1249858        {
     
    1256865                away = NULL;
    1257866                msg = set_getstr( &ic->acc->set, "status" ) ?
    1258                     : set_getstr( &ic->irc->set, "status" );
     867                    : set_getstr( &ic->bee->set, "status" );
    1259868        }
    1260869       
Note: See TracChangeset for help on using the changeset viewer.