Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    r823de9d rfa295e36  
    249249void imcb_connected( struct im_connection *ic )
    250250{
     251        irc_t *irc = ic->irc;
     252        struct chat *c;
    251253        user_t *u;
    252254       
     
    271273           exponential backoff timer. */
    272274        ic->acc->auto_reconnect_delay = 0;
     275       
     276        for( c = irc->chatrooms; c; c = c->next )
     277        {
     278                if( c->acc != ic->acc )
     279                        continue;
     280               
     281                if( set_getbool( &c->set, "auto_join" ) )
     282                        chat_join( irc, c, NULL );
     283        }
    273284}
    274285
     
    309320        ic->acc->prpl->logout( ic );
    310321        b_event_remove( ic->inpa );
     322       
     323        g_free( ic->away );
     324        ic->away = NULL;
    311325       
    312326        u = irc->users;
     
    492506}
    493507
    494 /* prpl.c */
    495 
    496 struct show_got_added_data
     508
     509struct imcb_ask_cb_data
    497510{
    498511        struct im_connection *ic;
     
    500513};
    501514
    502 void show_got_added_no( void *data )
    503 {
    504         g_free( ((struct show_got_added_data*)data)->handle );
     515static void imcb_ask_auth_cb_no( void *data )
     516{
     517        struct imcb_ask_cb_data *cbd = data;
     518       
     519        cbd->ic->acc->prpl->auth_deny( cbd->ic, cbd->handle );
     520       
     521        g_free( cbd->handle );
     522        g_free( cbd );
     523}
     524
     525static void imcb_ask_auth_cb_yes( void *data )
     526{
     527        struct imcb_ask_cb_data *cbd = data;
     528       
     529        cbd->ic->acc->prpl->auth_allow( cbd->ic, cbd->handle );
     530       
     531        g_free( cbd->handle );
     532        g_free( cbd );
     533}
     534
     535void imcb_ask_auth( struct im_connection *ic, const char *handle, const char *realname )
     536{
     537        struct imcb_ask_cb_data *data = g_new0( struct imcb_ask_cb_data, 1 );
     538        char *s, *realname_ = NULL;
     539       
     540        if( realname != NULL )
     541                realname_ = g_strdup_printf( " (%s)", realname );
     542       
     543        s = g_strdup_printf( "The user %s%s wants to add you to his/her buddy list.",
     544                             handle, realname_ ?: "" );
     545       
     546        g_free( realname_ );
     547       
     548        data->ic = ic;
     549        data->handle = g_strdup( handle );
     550        query_add( ic->irc, ic, s, imcb_ask_auth_cb_yes, imcb_ask_auth_cb_no, data );
     551}
     552
     553
     554static void imcb_ask_add_cb_no( void *data )
     555{
     556        g_free( ((struct imcb_ask_cb_data*)data)->handle );
    505557        g_free( data );
    506558}
    507559
    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 );
     560static void imcb_ask_add_cb_yes( void *data )
     561{
     562        struct imcb_ask_cb_data *cbd = data;
     563       
     564        cbd->ic->acc->prpl->add_buddy( cbd->ic, cbd->handle, NULL );
     565       
     566        return imcb_ask_add_cb_no( data );
     567}
     568
     569void imcb_ask_add( struct im_connection *ic, const char *handle, const char *realname )
     570{
     571        struct imcb_ask_cb_data *data = g_new0( struct imcb_ask_cb_data, 1 );
    521572        char *s;
    522573       
     
    529580        data->ic = ic;
    530581        data->handle = g_strdup( handle );
    531         query_add( ic->irc, ic, s, show_got_added_yes, show_got_added_no, data );
     582        query_add( ic->irc, ic, s, imcb_ask_add_cb_yes, imcb_ask_add_cb_no, data );
    532583}
    533584
     
    610661       
    611662        /* LISPy... */
    612         if( ( u->online ) &&                                            /* Don't touch offline people */
    613             ( ( ( u->online != oo ) && !u->away ) ||                    /* Do joining people */
    614               ( ( u->online == oo ) && ( oa == !u->away ) ) ) )         /* Do people changing state */
     663        if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) &&         /* Don't do a thing when user doesn't want it */
     664            ( u->online ) &&                                            /* Don't touch offline people */
     665            ( ( ( u->online != oo ) && !u->away ) ||                    /* Voice joining people */
     666              ( ( u->online == oo ) && ( oa == !u->away ) ) ) )         /* (De)voice people changing state */
    615667        {
    616668                char *from;
     
    625677                                                            ic->irc->myhost );
    626678                }
    627                 if(!strcmp(set_getstr(&ic->irc->set, "voice_buddies"), "notaway")) {
    628                         irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel,
    629                                                                  u->away?'-':'+', u->nick );
    630                 }
    631                 if(!strcmp(set_getstr(&ic->irc->set, "halfop_buddies"), "notaway")) {
    632                         irc_write( ic->irc, ":%s MODE %s %ch %s", from, ic->irc->channel,
    633                                                                  u->away?'-':'+', u->nick );
    634                 }
    635                 if(!strcmp(set_getstr(&ic->irc->set, "op_buddies"), "notaway")) {
    636                         irc_write( ic->irc, ":%s MODE %s %co %s", from, ic->irc->channel,
    637                                                                  u->away?'-':'+', u->nick );
    638                 }
     679                irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel,
     680                                                          u->away?'-':'+', u->nick );
    639681                g_free( from );
    640682        }
     
    646688        char *wrapped;
    647689        user_t *u;
    648 
    649         /* pass the message through OTR */
    650         msg = otr_handle_message(ic, handle, msg);
    651         if(!msg) {
    652                 /* this was an internal OTR protocol message */
    653                 return;
    654         }
    655 
     690       
    656691        u = user_findhandle( ic, handle );
     692       
    657693        if( !u )
    658694        {
     
    664700                                imcb_log( ic, "Ignoring message from unknown handle %s", handle );
    665701                       
    666                         g_free(msg);
    667702                        return;
    668703                }
     
    697732        irc_msgfrom( irc, u->nick, wrapped );
    698733        g_free( wrapped );
    699         g_free( msg );
    700734}
    701735
     
    716750}
    717751
    718 struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle )
     752struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle )
    719753{
    720754        struct groupchat *c;
     
    938972
    939973
     974/* Misc. BitlBee stuff which shouldn't really be here */
     975
     976char *set_eval_away_devoice( set_t *set, char *value )
     977{
     978        irc_t *irc = set->data;
     979        int st;
     980       
     981        if( !is_bool( value ) )
     982                return SET_INVALID;
     983       
     984        st = bool2int( value );
     985       
     986        /* Horror.... */
     987       
     988        if( st != set_getbool( &irc->set, "away_devoice" ) )
     989        {
     990                char list[80] = "";
     991                user_t *u = irc->users;
     992                int i = 0, count = 0;
     993                char pm;
     994                char v[80];
     995               
     996                if( st )
     997                        pm = '+';
     998                else
     999                        pm = '-';
     1000               
     1001                while( u )
     1002                {
     1003                        if( u->ic && u->online && !u->away )
     1004                        {
     1005                                if( ( strlen( list ) + strlen( u->nick ) ) >= 79 )
     1006                                {
     1007                                        for( i = 0; i < count; v[i++] = 'v' ); v[i] = 0;
     1008                                        irc_write( irc, ":%s MODE %s %c%s%s",
     1009                                                   irc->myhost,
     1010                                                   irc->channel, pm, v, list );
     1011                                       
     1012                                        *list = 0;
     1013                                        count = 0;
     1014                                }
     1015                               
     1016                                sprintf( list + strlen( list ), " %s", u->nick );
     1017                                count ++;
     1018                        }
     1019                        u = u->next;
     1020                }
     1021               
     1022                /* $v = 'v' x $i */
     1023                for( i = 0; i < count; v[i++] = 'v' ); v[i] = 0;
     1024                irc_write( irc, ":%s MODE %s %c%s%s", irc->myhost,
     1025                                                            irc->channel, pm, v, list );
     1026        }
     1027       
     1028        return value;
     1029}
     1030
     1031
     1032
     1033
    9401034/* The plan is to not allow straight calls to prpl functions anymore, but do
    9411035   them all from some wrappers. We'll start to define some down here: */
     
    9511045                msg = buf;
    9521046        }
    953 
    954         /* if compiled without otr support, this just calls the prpl buddy_msg */
    955         st = otr_send_message(ic, handle, msg, flags);
    956        
    957         g_free(buf);
     1047       
     1048        st = ic->acc->prpl->buddy_msg( ic, handle, msg, flags );
     1049        g_free( buf );
     1050       
    9581051        return st;
    9591052}
Note: See TracChangeset for help on using the changeset viewer.