Changeset aef4828 for protocols/nogaim.c


Ignore:
Timestamp:
2007-04-06T05:20:31Z (15 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
552e641
Parents:
0da65d5
Message:

More cleanups, mainly in the callbacks. Replaced things like
do_error_dialog() and (set|hide)_login_progress(_error)?() with things
that hopefully make more sense.

Although it's still not really great...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    r0da65d5 raef4828  
    145145/* multi.c */
    146146
    147 struct im_connection *new_gaim_conn( account_t *acc )
     147struct im_connection *imc_new( account_t *acc )
    148148{
    149149        struct im_connection *ic;
     
    164164}
    165165
    166 void destroy_gaim_conn( struct im_connection *ic )
     166void imc_free( struct im_connection *ic )
    167167{
    168168        account_t *a;
     
    180180}
    181181
    182 void set_login_progress( struct im_connection *ic, int step, char *msg )
    183 {
    184         serv_got_crap( ic, "Logging in: %s", msg );
    185 }
    186 
    187 /* Errors *while* logging in */
    188 void hide_login_progress( struct im_connection *ic, char *msg )
    189 {
    190         serv_got_crap( ic, "Login error: %s", msg );
    191 }
    192 
    193 /* Errors *after* logging in */
    194 void hide_login_progress_error( struct im_connection *ic, char *msg )
    195 {
    196         serv_got_crap( ic, "Logged out: %s", msg );
    197 }
    198 
    199 void serv_got_crap( struct im_connection *ic, char *format, ... )
     182static void serv_got_crap( struct im_connection *ic, char *format, ... )
    200183{
    201184        va_list params;
     
    225208}
    226209
     210void imc_log( struct im_connection *ic, char *format, ... )
     211{
     212        va_list params;
     213        char *text;
     214       
     215        va_start( params, format );
     216        text = g_strdup_vprintf( format, params );
     217        va_end( params );
     218       
     219        if( ic->flags & OPT_LOGGED_IN )
     220                serv_got_crap( ic, "%s", text );
     221        else
     222                serv_got_crap( ic, "Logging in: %s", text );
     223       
     224        g_free( text );
     225}
     226
     227void imc_error( struct im_connection *ic, char *format, ... )
     228{
     229        va_list params;
     230        char *text;
     231       
     232        va_start( params, format );
     233        text = g_strdup_vprintf( format, params );
     234        va_end( params );
     235       
     236        if( ic->flags & OPT_LOGGED_IN )
     237                serv_got_crap( ic, "Error: %s", text );
     238        else
     239                serv_got_crap( ic, "Couldn't log in: %s", text );
     240       
     241        g_free( text );
     242}
     243
    227244static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond )
    228245{
     
    235252}
    236253
    237 void account_online( struct im_connection *ic )
     254void imc_connected( struct im_connection *ic )
    238255{
    239256        user_t *u;
     
    247264        u = user_find( ic->irc, ic->irc->nick );
    248265       
    249         serv_got_crap( ic, "Logged in" );
     266        imc_log( ic, "Logged in" );
    250267       
    251268        ic->keepalive = b_timeout_add( 60000, send_keepalive, ic );
     
    274291}
    275292
    276 void signoff( struct im_connection *ic )
     293void imc_logout( struct im_connection *ic )
    277294{
    278295        irc_t *irc = ic->irc;
     
    287304                ic->flags |= OPT_LOGGING_OUT;
    288305       
    289         serv_got_crap( ic, "Signing off.." );
     306        imc_log( ic, "Signing off.." );
    290307       
    291308        b_event_remove( ic->keepalive );
     
    321338                int delay = set_getint( &irc->set, "auto_reconnect_delay" );
    322339               
    323                 serv_got_crap( ic, "Reconnecting in %d seconds..", delay );
     340                imc_log( ic, "Reconnecting in %d seconds..", delay );
    324341                a->reconnect = b_timeout_add( delay * 1000, auto_reconnect, a );
    325342        }
    326343       
    327         destroy_gaim_conn( ic );
     344        imc_free( ic );
    328345}
    329346
    330347
    331348/* dialogs.c */
    332 
    333 void do_error_dialog( struct im_connection *ic, char *msg, char *title )
    334 {
    335         if( msg && title )
    336                 serv_got_crap( ic, "Error: %s: %s", title, msg );
    337         else if( msg )
    338                 serv_got_crap( ic, "Error: %s", msg );
    339         else if( title )
    340                 serv_got_crap( ic, "Error: %s", title );
    341         else
    342                 serv_got_crap( ic, "Error" );
    343 }
    344349
    345350void do_ask_dialog( struct im_connection *ic, char *msg, void *data, void *doit, void *dont )
     
    359364       
    360365        if( set_getbool( &irc->set, "debug" ) && 0 ) /* This message is too useless */
    361                 serv_got_crap( ic, "Receiving user add from handle: %s", handle );
     366                imc_log( ic, "Receiving user add from handle: %s", handle );
    362367       
    363368        if( user_findhandle( ic, handle ) )
    364369        {
    365370                if( set_getbool( &irc->set, "debug" ) )
    366                         serv_got_crap( ic, "User already exists, ignoring add request: %s", handle );
     371                        imc_log( ic, "User already exists, ignoring add request: %s", handle );
    367372               
    368373                return;
     
    452457               
    453458                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 );
     459                        imc_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname );
    455460        }
    456461}
     
    516521                        if( set_getbool( &ic->irc->set, "debug" ) || g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "ignore" ) != 0 )
    517522                        {
    518                                 serv_got_crap( ic, "serv_got_update() for handle %s:", handle );
    519                                 serv_got_crap( ic, "loggedin = %d, type = %d", loggedin, type );
     523                                imc_log( ic, "serv_got_update() for handle %s:", handle );
     524                                imc_log( ic, "loggedin = %d, type = %d", loggedin, type );
    520525                        }
    521526                       
     
    597602                {
    598603                        if( set_getbool( &irc->set, "debug" ) )
    599                                 serv_got_crap( ic, "Ignoring message from unknown handle %s", handle );
     604                                imc_log( ic, "Ignoring message from unknown handle %s", handle );
    600605                       
    601606                        return;
     
    619624                else
    620625                {
    621                         serv_got_crap( ic, "Message from unknown handle %s:", handle );
     626                        imc_log( ic, "Message from unknown handle %s:", handle );
    622627                        u = user_find( irc, irc->mynick );
    623628                }
     
    689694       
    690695        if( set_getbool( &ic->irc->set, "debug" ) )
    691                 serv_got_crap( ic, "You were removed from conversation 0x%x", (int) c );
     696                imc_log( ic, "You were removed from conversation 0x%x", (int) c );
    692697       
    693698        if( c )
     
    737742                irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", msg );
    738743        else
    739                 serv_got_crap( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg );
     744                imc_log( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg );
    740745}
    741746
     
    759764       
    760765        if( set_getbool( &ic->irc->set, "debug" ) )
    761                 serv_got_crap( ic, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle );
     766                imc_log( ic, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle );
    762767       
    763768        return c;
     
    773778       
    774779        if( set_getbool( &b->ic->irc->set, "debug" ) )
    775                 serv_got_crap( b->ic, "User %s added to conversation 0x%x", handle, (int) b );
     780                imc_log( b->ic, "User %s added to conversation 0x%x", handle, (int) b );
    776781       
    777782        /* It might be yourself! */
     
    807812       
    808813        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 : "" );
     814                imc_log( b->ic, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" );
    810815       
    811816        /* It might be yourself! */
     
    10051010                        ic->acc->prpl->set_away( ic, s, away );
    10061011                        if( set_getbool( &ic->irc->set, "debug" ) )
    1007                                 serv_got_crap( ic, "Setting away state to %s", s );
     1012                                imc_log( ic, "Setting away state to %s", s );
    10081013                }
    10091014                else
Note: See TracChangeset for help on using the changeset viewer.