aboutsummaryrefslogtreecommitdiffstats
path: root/root_commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'root_commands.c')
-rw-r--r--root_commands.c60
1 files changed, 51 insertions, 9 deletions
diff --git a/root_commands.c b/root_commands.c
index 9a60b5af..f55c4b5e 100644
--- a/root_commands.c
+++ b/root_commands.c
@@ -203,24 +203,38 @@ 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 *a = data;
- irc_t *irc = a->irc;
+ account_t *a;
+ irc_t *irc;
+};
+
+void cmd_account_del_yes( void *data )
+{
+ struct cmd_account_del_data *cad = data;
+ account_t *a;
+
+ for( a = cad->irc->accounts; a && a != cad->a; a = a->next );
- if( a->ic )
+ if( a == NULL )
{
- irc_usermsg( irc, "Account is still logged in, can't delete" );
+ irc_usermsg( cad->irc, "Account already deleted" );
+ }
+ else if( a->ic )
+ {
+ irc_usermsg( cad->irc, "Account is still logged in, can't delete" );
}
else
{
- account_del( irc, a );
- irc_usermsg( irc, "Account deleted" );
+ account_del( cad->irc, a );
+ irc_usermsg( cad->irc, "Account deleted" );
}
+ g_free( data );
}
-void cmd_account_del_no( gpointer w, void *data )
+void cmd_account_del_no( void *data )
{
+ g_free( data );
}
static void cmd_account( irc_t *irc, char **cmd )
@@ -277,14 +291,19 @@ static void cmd_account( irc_t *irc, char **cmd )
}
else
{
+ struct cmd_account_del_data *cad;
char *msg;
+ 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, a );
+ query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, cad );
g_free( msg );
}
}
@@ -403,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;
@@ -583,6 +608,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 )
{
@@ -593,6 +621,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;