Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • root_commands.c

    r3064ea4 r23c4e64  
    2929#include "bitlbee.h"
    3030#include "help.h"
    31 #include "otr.h"
    3231
    3332#include <string.h>
     
    205204}
    206205
     206struct cmd_account_del_data
     207{
     208        account_t *a;
     209        irc_t *irc;
     210};
     211
     212void cmd_account_del_yes( void *data )
     213{
     214        struct cmd_account_del_data *cad = data;
     215        account_t *a;
     216       
     217        for( a = cad->irc->accounts; a && a != cad->a; a = a->next );
     218       
     219        if( a == NULL )
     220        {
     221                irc_usermsg( cad->irc, "Account already deleted" );
     222        }
     223        else if( a->ic )
     224        {
     225                irc_usermsg( cad->irc, "Account is still logged in, can't delete" );
     226        }
     227        else
     228        {
     229                account_del( cad->irc, a );
     230                irc_usermsg( cad->irc, "Account deleted" );
     231        }
     232        g_free( data );
     233}
     234
     235void cmd_account_del_no( void *data )
     236{
     237        g_free( data );
     238}
     239
    207240static void cmd_account( irc_t *irc, char **cmd )
    208241{
     
    242275               
    243276                irc_usermsg( irc, "Account successfully added" );
    244                
    245                 if(otr_check_for_key(a)) {
    246                         irc_usermsg(irc, "otr: you will be notified when it completes");
    247                 }
    248277        }
    249278        else if( g_strcasecmp( cmd[1], "del" ) == 0 )
     
    263292                else
    264293                {
    265                         account_del( irc, a );
    266                         irc_usermsg( irc, "Account deleted" );
     294                        struct cmd_account_del_data *cad;
     295                        char *msg;
     296                       
     297                        cad = g_malloc( sizeof( struct cmd_account_del_data ) );
     298                        cad->a = a;
     299                        cad->irc = irc;
     300                       
     301                        msg = g_strdup_printf( "If you remove this account (%s(%s)), BitlBee will "
     302                                               "also forget all your saved nicknames. If you want "
     303                                               "to change your username/password, use the `account "
     304                                               "set' command. Are you sure you want to delete this "
     305                                               "account?", a->prpl->name, a->user );
     306                        query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, cad );
     307                        g_free( msg );
    267308                }
    268309        }
     
    382423                        acc_handle = g_strdup( cmd[2] );
    383424               
     425                if( !acc_handle )
     426                {
     427                        irc_usermsg( irc, "Not enough parameters given (need %d)", 3 );
     428                        return;
     429                }
     430               
    384431                if( ( tmp = strchr( acc_handle, '/' ) ) )
    385432                {
     
    454501        {
    455502                add_on_server = 0;
    456                 cmd ++;         /* So evil... :-D */
     503                cmd ++;
    457504        }
    458505       
     
    486533        }
    487534       
    488         /* By making this optional, you can talk to people without having to
    489            add them to your *real* (server-side) contact list. */
    490535        if( add_on_server )
    491536                a->ic->acc->prpl->add_buddy( a->ic, cmd[2], NULL );
    492        
    493         /* add_buddy( a->ic, NULL, cmd[2], cmd[2] ); */
     537        else
     538                /* Yeah, officially this is a call-*back*... So if we just
     539                   called add_buddy, we'll wait for the IM server to respond
     540                   before we do this. */
     541                imcb_add_buddy( a->ic, cmd[2], NULL );
    494542       
    495543        irc_usermsg( irc, "Adding `%s' to your contact list", cmd[2]  );
     
    561609                        g_free( irc->mynick );
    562610                        irc->mynick = g_strdup( cmd[2] );
     611                       
     612                        if( strcmp( cmd[0], "set_rename" ) != 0 )
     613                                set_setstr( &irc->set, "root_nick", cmd[2] );
    563614                }
    564615                else if( u->send_handler == buddy_send_handler )
     
    569620                irc_usermsg( irc, "Nick successfully changed" );
    570621        }
     622}
     623
     624char *set_eval_root_nick( set_t *set, char *new_nick )
     625{
     626        irc_t *irc = set->data;
     627       
     628        if( strcmp( irc->mynick, new_nick ) != 0 )
     629        {
     630                char *cmd[] = { "set_rename", irc->mynick, new_nick, NULL };
     631               
     632                cmd_rename( irc, cmd );
     633        }
     634       
     635        return strcmp( irc->mynick, new_nick ) == 0 ? new_nick : NULL;
    571636}
    572637
     
    773838                else
    774839                        irc_usermsg( irc, "%s is empty", set_name );
     840
     841                if( strchr( set_name, '/' ) )
     842                        irc_usermsg( irc, "Warning: / found in setting name, you're probably looking for the `account set' command." );
    775843        }
    776844        else
     
    9961064        { "qlist",          0, cmd_qlist,          0 },
    9971065        { "join_chat",      2, cmd_join_chat,      0 },
    998         { "otr",            1, cmd_otr,            0 },
    9991066        { NULL }
    10001067};
Note: See TracChangeset for help on using the changeset viewer.