Changeset 2288705 for protocols/nogaim.c


Ignore:
Timestamp:
2009-12-07T21:54:19Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
1c3008a
Parents:
aac4017 (diff), 36cf9fd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merging head.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    raac4017 r2288705  
    3333
    3434#define BITLBEE_CORE
     35#include <ctype.h>
     36
    3537#include "nogaim.h"
    36 #include <ctype.h>
     38#include "chat.h"
    3739
    3840static int remove_chat_buddy_silent( struct groupchat *b, const char *handle );
     
    249251void imcb_connected( struct im_connection *ic )
    250252{
     253        irc_t *irc = ic->irc;
     254        struct chat *c;
    251255        user_t *u;
    252256       
     
    271275           exponential backoff timer. */
    272276        ic->acc->auto_reconnect_delay = 0;
     277       
     278        for( c = irc->chatrooms; c; c = c->next )
     279        {
     280                if( c->acc != ic->acc )
     281                        continue;
     282               
     283                if( set_getbool( &c->set, "auto_join" ) )
     284                        chat_join( irc, c, NULL );
     285        }
    273286}
    274287
     
    309322        ic->acc->prpl->logout( ic );
    310323        b_event_remove( ic->inpa );
     324       
     325        g_free( ic->away );
     326        ic->away = NULL;
    311327       
    312328        u = irc->users;
     
    492508}
    493509
    494 /* prpl.c */
    495 
    496 struct show_got_added_data
     510
     511struct imcb_ask_cb_data
    497512{
    498513        struct im_connection *ic;
     
    500515};
    501516
    502 void show_got_added_no( void *data )
    503 {
    504         g_free( ((struct show_got_added_data*)data)->handle );
     517static void imcb_ask_auth_cb_no( void *data )
     518{
     519        struct imcb_ask_cb_data *cbd = data;
     520       
     521        cbd->ic->acc->prpl->auth_deny( cbd->ic, cbd->handle );
     522       
     523        g_free( cbd->handle );
     524        g_free( cbd );
     525}
     526
     527static void imcb_ask_auth_cb_yes( void *data )
     528{
     529        struct imcb_ask_cb_data *cbd = data;
     530       
     531        cbd->ic->acc->prpl->auth_allow( cbd->ic, cbd->handle );
     532       
     533        g_free( cbd->handle );
     534        g_free( cbd );
     535}
     536
     537void imcb_ask_auth( struct im_connection *ic, const char *handle, const char *realname )
     538{
     539        struct imcb_ask_cb_data *data = g_new0( struct imcb_ask_cb_data, 1 );
     540        char *s, *realname_ = NULL;
     541       
     542        if( realname != NULL )
     543                realname_ = g_strdup_printf( " (%s)", realname );
     544       
     545        s = g_strdup_printf( "The user %s%s wants to add you to his/her buddy list.",
     546                             handle, realname_ ?: "" );
     547       
     548        g_free( realname_ );
     549       
     550        data->ic = ic;
     551        data->handle = g_strdup( handle );
     552        query_add( ic->irc, ic, s, imcb_ask_auth_cb_yes, imcb_ask_auth_cb_no, data );
     553}
     554
     555
     556static void imcb_ask_add_cb_no( void *data )
     557{
     558        g_free( ((struct imcb_ask_cb_data*)data)->handle );
    505559        g_free( data );
    506560}
    507561
    508 void show_got_added_yes( void *data )
    509 {
    510         struct show_got_added_data *sga = data;
    511        
    512         sga->ic->acc->prpl->add_buddy( sga->ic, sga->handle, NULL );
    513         /* imcb_add_buddy( sga->ic, NULL, sga->handle, sga->handle ); */
    514        
    515         return show_got_added_no( data );
    516 }
    517 
    518 void imcb_ask_add( struct im_connection *ic, char *handle, const char *realname )
    519 {
    520         struct show_got_added_data *data = g_new0( struct show_got_added_data, 1 );
     562static void imcb_ask_add_cb_yes( void *data )
     563{
     564        struct imcb_ask_cb_data *cbd = data;
     565       
     566        cbd->ic->acc->prpl->add_buddy( cbd->ic, cbd->handle, NULL );
     567       
     568        return imcb_ask_add_cb_no( data );
     569}
     570
     571void imcb_ask_add( struct im_connection *ic, const char *handle, const char *realname )
     572{
     573        struct imcb_ask_cb_data *data = g_new0( struct imcb_ask_cb_data, 1 );
    521574        char *s;
    522575       
     
    529582        data->ic = ic;
    530583        data->handle = g_strdup( handle );
    531         query_add( ic->irc, ic, s, show_got_added_yes, show_got_added_no, data );
     584        query_add( ic->irc, ic, s, imcb_ask_add_cb_yes, imcb_ask_add_cb_no, data );
    532585}
    533586
     
    699752}
    700753
    701 struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle )
     754struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle )
    702755{
    703756        struct groupchat *c;
     
    928981        int st;
    929982       
    930         if( ( g_strcasecmp( value, "true" ) == 0 ) || ( g_strcasecmp( value, "yes" ) == 0 ) || ( g_strcasecmp( value, "on" ) == 0 ) )
    931                 st = 1;
    932         else if( ( g_strcasecmp( value, "false" ) == 0 ) || ( g_strcasecmp( value, "no" ) == 0 ) || ( g_strcasecmp( value, "off" ) == 0 ) )
    933                 st = 0;
    934         else if( sscanf( value, "%d", &st ) != 1 )
    935                 return( NULL );
    936        
    937         st = st != 0;
     983        if( !is_bool( value ) )
     984                return SET_INVALID;
     985       
     986        st = bool2int( value );
    938987       
    939988        /* Horror.... */
     
    9791028        }
    9801029       
    981         return( set_eval_bool( set, value ) );
     1030        return value;
    9821031}
    9831032
Note: See TracChangeset for help on using the changeset viewer.