From 8dbe021fab08902eb202da8da26d183cb0832fca Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 5 Apr 2008 00:13:07 +0100 Subject: Don't pass an account_t pointer directly to query_add() since query_del() wants to free it! Passing an indirect pointer instead. --- root_commands.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 9a60b5af..2bccc465 100644 --- a/root_commands.c +++ b/root_commands.c @@ -205,22 +205,24 @@ static void cmd_drop( irc_t *irc, char **cmd ) void cmd_account_del_yes( gpointer w, void *data ) { - account_t *a = data; - irc_t *irc = a->irc; + account_t **aptr = data; + irc_t *irc = (*aptr)->irc; - if( a->ic ) + if( (*aptr)->ic ) { irc_usermsg( irc, "Account is still logged in, can't delete" ); } else { - account_del( irc, a ); + account_del( irc, (*aptr) ); irc_usermsg( irc, "Account deleted" ); } + g_free( aptr ); } void cmd_account_del_no( gpointer w, void *data ) { + g_free( data ); } static void cmd_account( irc_t *irc, char **cmd ) @@ -277,14 +279,18 @@ static void cmd_account( irc_t *irc, char **cmd ) } else { + account_t **aptr; char *msg; + aptr = g_malloc( sizeof( aptr ) ); + *aptr = a; + msg = g_strdup_printf( "If you remove this account (%s(%s)), BitlBee will " "also forget all your saved nicknames. If you want " "to change your username/password, use the `account " "set' command. Are you sure you want to delete this " "account?", a->prpl->name, a->user ); - query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, a ); + query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, aptr ); g_free( msg ); } } -- cgit v1.2.3 From f35aee7fdfc66138d0525a0a7b9e02ccb1aaaec7 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 5 Apr 2008 13:36:13 +0100 Subject: Fixed #386. --- root_commands.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 2bccc465..aec91455 100644 --- a/root_commands.c +++ b/root_commands.c @@ -203,24 +203,36 @@ static void cmd_drop( irc_t *irc, char **cmd ) } } -void cmd_account_del_yes( gpointer w, void *data ) +struct cmd_account_del_data { - account_t **aptr = data; - irc_t *irc = (*aptr)->irc; + account_t *a; + irc_t *irc; +}; + +void cmd_account_del_yes( void *data ) +{ + struct cmd_account_del_data *cad = data; + account_t *a; - if( (*aptr)->ic ) + for( a = cad->irc->accounts; a && a != cad->a; a = a->next ); + + if( a == NULL ) + { + irc_usermsg( cad->irc, "Account already deleted" ); + } + else if( a->ic ) { - irc_usermsg( irc, "Account is still logged in, can't delete" ); + irc_usermsg( cad->irc, "Account is still logged in, can't delete" ); } else { - account_del( irc, (*aptr) ); - irc_usermsg( irc, "Account deleted" ); + account_del( cad->irc, a ); + irc_usermsg( cad->irc, "Account deleted" ); } - g_free( aptr ); + g_free( data ); } -void cmd_account_del_no( gpointer w, void *data ) +void cmd_account_del_no( void *data ) { g_free( data ); } @@ -279,18 +291,19 @@ static void cmd_account( irc_t *irc, char **cmd ) } else { - account_t **aptr; + struct cmd_account_del_data *cad; char *msg; - aptr = g_malloc( sizeof( aptr ) ); - *aptr = a; + cad = g_malloc( sizeof( struct cmd_account_del_data ) ); + cad->a = a; + cad->irc = irc; msg = g_strdup_printf( "If you remove this account (%s(%s)), BitlBee will " "also forget all your saved nicknames. If you want " "to change your username/password, use the `account " "set' command. Are you sure you want to delete this " "account?", a->prpl->name, a->user ); - query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, aptr ); + query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, cad ); g_free( msg ); } } -- cgit v1.2.3 From 1195cecc99315c9c38e05c8dd0981792e7663583 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 5 Apr 2008 14:03:31 +0100 Subject: Changed root nicknames are now saved. (Bug #378) --- root_commands.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index aec91455..4b27afe3 100644 --- a/root_commands.c +++ b/root_commands.c @@ -602,6 +602,9 @@ static void cmd_rename( irc_t *irc, char **cmd ) { g_free( irc->mynick ); irc->mynick = g_strdup( cmd[2] ); + + if( strcmp( cmd[0], "set_rename" ) != 0 ) + set_setstr( &irc->set, "root_nick", cmd[2] ); } else if( u->send_handler == buddy_send_handler ) { @@ -612,6 +615,20 @@ static void cmd_rename( irc_t *irc, char **cmd ) } } +char *set_eval_root_nick( set_t *set, char *new_nick ) +{ + irc_t *irc = set->data; + + if( strcmp( irc->mynick, new_nick ) != 0 ) + { + char *cmd[] = { "set_rename", irc->mynick, new_nick, NULL }; + + cmd_rename( irc, cmd ); + } + + return strcmp( irc->mynick, new_nick ) == 0 ? new_nick : NULL; +} + static void cmd_remove( irc_t *irc, char **cmd ) { user_t *u; -- cgit v1.2.3 From 23c4e648e3d38336f949498d0b93e5b399087e44 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 11 May 2008 12:37:34 -0700 Subject: Fixed NULL point dereference in "account set -del" code. --- root_commands.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 4b27afe3..f55c4b5e 100644 --- a/root_commands.c +++ b/root_commands.c @@ -422,6 +422,12 @@ static void cmd_account( irc_t *irc, char **cmd ) else acc_handle = g_strdup( cmd[2] ); + if( !acc_handle ) + { + irc_usermsg( irc, "Not enough parameters given (need %d)", 3 ); + return; + } + if( ( tmp = strchr( acc_handle, '/' ) ) ) { *tmp = 0; -- cgit v1.2.3