From c121f8945f7249520342ad86ff00f4986642ca0a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 14 Jun 2006 22:30:25 +0200 Subject: xml_load() works pretty well now. --- root_commands.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 0e12e9ab..d44a36b7 100644 --- a/root_commands.c +++ b/root_commands.c @@ -141,8 +141,9 @@ static void cmd_identify( irc_t *irc, char **cmd ) irc_usermsg( irc, "Password accepted" ); irc_umode_set( irc, "+R", 1 ); break; + case STORAGE_OTHER_ERROR: default: - irc_usermsg( irc, "Something very weird happened" ); + irc_usermsg( irc, "Unknown error while loading configuration" ); break; } } -- cgit v1.2.3 From 79e826a028f4b4c62c0c16e20af1fb13a9636324 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 15 Jun 2006 14:22:17 +0200 Subject: Converted irc->status to binary flags. (This also fixes auto-save-on-quit that broke because of USTATUS_SHUTDOWN. :-( ) --- root_commands.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 0e12e9ab..d8611347 100644 --- a/root_commands.c +++ b/root_commands.c @@ -162,7 +162,7 @@ static void cmd_register( irc_t *irc, char **cmd ) break; case STORAGE_OK: - irc->status = USTATUS_IDENTIFIED; + irc->status |= USTATUS_IDENTIFIED; irc_umode_set( irc, "+R", 1 ); break; @@ -186,7 +186,7 @@ static void cmd_drop( irc_t *irc, char **cmd ) break; case STORAGE_OK: irc_setpass( irc, NULL ); - irc->status = USTATUS_LOGGED_IN; + irc->status &= ~USTATUS_IDENTIFIED; irc_umode_set( irc, "-R", 1 ); irc_usermsg( irc, "Account `%s' removed", irc->nick ); break; @@ -200,7 +200,7 @@ static void cmd_account( irc_t *irc, char **cmd ) { account_t *a; - if( global.conf->authmode == AUTHMODE_REGISTERED && irc->status < USTATUS_IDENTIFIED ) + if( global.conf->authmode == AUTHMODE_REGISTERED && ! irc->status & USTATUS_IDENTIFIED ) { irc_usermsg( irc, "This server only accepts registered users" ); return; -- cgit v1.2.3 From 3af70b06b2f0fb0fb41a041f6d86e3711b9eea3f Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 15 Jun 2006 14:37:05 +0200 Subject: !x&y == (!x)&y, not !(x&y). --- root_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index d8611347..3d3584b3 100644 --- a/root_commands.c +++ b/root_commands.c @@ -200,7 +200,7 @@ static void cmd_account( irc_t *irc, char **cmd ) { account_t *a; - if( global.conf->authmode == AUTHMODE_REGISTERED && ! irc->status & USTATUS_IDENTIFIED ) + if( global.conf->authmode == AUTHMODE_REGISTERED && !( irc->status & USTATUS_IDENTIFIED ) ) { irc_usermsg( irc, "This server only accepts registered users" ); return; -- cgit v1.2.3 From 2b14eef99faf7e113cc6c17d68bf6402f87ddd66 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 21 Jun 2006 00:14:46 +0200 Subject: Implemented handling of autoconnect attribute. --- root_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 225912b7..d263bb84 100644 --- a/root_commands.c +++ b/root_commands.c @@ -306,7 +306,7 @@ static void cmd_account( irc_t *irc, char **cmd ) irc_usermsg( irc, "Trying to get all accounts connected..." ); for( a = irc->accounts; a; a = a->next ) - if( !a->gc ) + if( !a->gc && a->auto_connect ) account_on( irc, a ); } else -- cgit v1.2.3 From 6ee9d2d65ec05d3871e69c2b03b860c6bdd509e9 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 25 Jun 2006 20:25:13 +0200 Subject: Forgot to initialize pass_rc4 (which caused memory management mess when trying to load a damaged XML-file). --- root_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index d263bb84..e69b9981 100644 --- a/root_commands.c +++ b/root_commands.c @@ -138,7 +138,7 @@ static void cmd_identify( irc_t *irc, char **cmd ) irc_usermsg( irc, "The nick is (probably) not registered" ); break; case STORAGE_OK: - irc_usermsg( irc, "Password accepted" ); + irc_usermsg( irc, "Password accepted, settings and accounts loaded" ); irc_umode_set( irc, "+R", 1 ); break; case STORAGE_OTHER_ERROR: -- cgit v1.2.3 From 90bbb0efeae19bcc6a1096d8c89fbf3981c83503 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 26 Jun 2006 18:50:47 +0200 Subject: Moved the call to "account on" to the right place. --- root_commands.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index e69b9981..47143531 100644 --- a/root_commands.c +++ b/root_commands.c @@ -126,9 +126,12 @@ static void cmd_help( irc_t *irc, char **cmd ) } } +static void cmd_account( irc_t *irc, char **cmd ); + static void cmd_identify( irc_t *irc, char **cmd ) { storage_status_t status = storage_load( irc->nick, cmd[1], irc ); + char *account_on[] = { "account", "on", NULL }; switch (status) { case STORAGE_INVALID_PASSWORD: @@ -140,6 +143,8 @@ static void cmd_identify( irc_t *irc, char **cmd ) case STORAGE_OK: irc_usermsg( irc, "Password accepted, settings and accounts loaded" ); irc_umode_set( irc, "+R", 1 ); + if( set_getint( irc, "auto_connect" ) ) + cmd_account( irc, account_on ); break; case STORAGE_OTHER_ERROR: default: -- cgit v1.2.3 From 5c9512ffa716f2bc8bbf9e2c31ee40624a0ff842 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 30 Jun 2006 11:17:18 +0200 Subject: Made set.c API more generic so it's not specific to irc_t structures anymore, but can be used for account_t structures too, for example. --- root_commands.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 47143531..815d618b 100644 --- a/root_commands.c +++ b/root_commands.c @@ -143,7 +143,7 @@ static void cmd_identify( irc_t *irc, char **cmd ) case STORAGE_OK: irc_usermsg( irc, "Password accepted, settings and accounts loaded" ); irc_umode_set( irc, "+R", 1 ); - if( set_getint( irc, "auto_connect" ) ) + if( set_getint( &irc->set, "auto_connect" ) ) cmd_account( irc, account_on ); break; case STORAGE_OTHER_ERROR: @@ -671,14 +671,14 @@ static void cmd_set( irc_t *irc, char **cmd ) { if( cmd[1] && cmd[2] ) { - set_setstr( irc, cmd[1], cmd[2] ); + set_setstr( &irc->set, cmd[1], cmd[2] ); if( ( strcmp( cmd[2], "=" ) ) == 0 && cmd[3] ) irc_usermsg( irc, "Warning: Correct syntax: \002set \002 (without =)" ); } if( cmd[1] ) /* else 'forgotten' on purpose.. Must show new value after changing */ { - char *s = set_getstr( irc, cmd[1] ); + char *s = set_getstr( &irc->set, cmd[1] ); if( s ) irc_usermsg( irc, "%s = `%s'", cmd[1], s ); } -- cgit v1.2.3 From 0a3c243b6659dc10efb227e507f324c2711d6dcd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 1 Jul 2006 01:18:56 +0200 Subject: Got rid of struct aim_user (now using account_t everywhere). Needs some more testing though. --- root_commands.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 815d618b..3bd80e5e 100644 --- a/root_commands.c +++ b/root_commands.c @@ -399,14 +399,14 @@ static void cmd_add( irc_t *irc, char **cmd ) } else { - nick_set( irc, cmd[2], a->gc->prpl, cmd[3] ); + nick_set( irc, cmd[2], a->gc->acc->prpl, cmd[3] ); } } /* By making this optional, you can talk to people without having to add them to your *real* (server-side) contact list. */ if( add_for_real ) - a->gc->prpl->add_buddy( a->gc, cmd[2] ); + a->gc->acc->prpl->add_buddy( a->gc, cmd[2] ); add_buddy( a->gc, NULL, cmd[2], cmd[2] ); @@ -440,13 +440,13 @@ static void cmd_info( irc_t *irc, char **cmd ) return; } - if( !gc->prpl->get_info ) + if( !gc->acc->prpl->get_info ) { irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); } else { - gc->prpl->get_info( gc, cmd[2] ); + gc->acc->prpl->get_info( gc, cmd[2] ); } } @@ -481,7 +481,7 @@ static void cmd_rename( irc_t *irc, char **cmd ) } else if( u->send_handler == buddy_send_handler ) { - nick_set( irc, u->handle, u->gc->prpl, cmd[2] ); + nick_set( irc, u->handle, u->gc->acc->prpl, cmd[2] ); } irc_usermsg( irc, "Nick successfully changed" ); @@ -500,7 +500,7 @@ static void cmd_remove( irc_t *irc, char **cmd ) } s = g_strdup( u->handle ); - u->gc->prpl->remove_buddy( u->gc, u->handle, NULL ); + u->gc->acc->prpl->remove_buddy( u->gc, u->handle, NULL ); user_del( irc, cmd[1] ); nick_del( irc, cmd[1] ); @@ -557,7 +557,7 @@ static void cmd_block( irc_t *irc, char **cmd ) return; } - if( !gc->prpl->add_deny || !gc->prpl->rem_permit ) + if( !gc->acc->prpl->add_deny || !gc->acc->prpl->rem_permit ) { irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); } @@ -616,7 +616,7 @@ static void cmd_allow( irc_t *irc, char **cmd ) return; } - if( !gc->prpl->rem_deny || !gc->prpl->add_permit ) + if( !gc->acc->prpl->rem_deny || !gc->acc->prpl->add_permit ) { irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); } @@ -732,7 +732,7 @@ static void cmd_blist( irc_t *irc, char **cmd ) { if( online == 1 ) { - g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); + g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); irc_usermsg( irc, format, u->nick, s, "Online" ); } @@ -743,7 +743,7 @@ static void cmd_blist( irc_t *irc, char **cmd ) { if( away == 1 ) { - g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); + g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); irc_usermsg( irc, format, u->nick, s, u->away ); } n_away ++; @@ -753,7 +753,7 @@ static void cmd_blist( irc_t *irc, char **cmd ) { if( offline == 1 ) { - g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); + g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); irc_usermsg( irc, format, u->nick, s, "Offline" ); } n_offline ++; @@ -778,7 +778,7 @@ static void cmd_nick( irc_t *irc, char **cmd ) { irc_usermsg( irc, "Your name is `%s'" , a->gc->displayname ? a->gc->displayname : "NULL" ); } - else if ( !a->gc->prpl->set_info ) + else if ( !a->prpl->set_info ) { irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); } @@ -786,7 +786,7 @@ static void cmd_nick( irc_t *irc, char **cmd ) { irc_usermsg( irc, "Setting your name to `%s'", cmd[2] ); - a->gc->prpl->set_info( a->gc, cmd[2] ); + a->prpl->set_info( a->gc, cmd[2] ); } } @@ -805,7 +805,7 @@ static void cmd_qlist( irc_t *irc, char **cmd ) for( num = 0; q; q = q->next, num ++ ) if( q->gc ) /* Not necessary yet, but it might come later */ - irc_usermsg( irc, "%d, %s(%s): %s", num, q->gc->prpl->name, q->gc->username, q->question ); + irc_usermsg( irc, "%d, %s(%s): %s", num, q->gc->acc->prpl->name, q->gc->username, q->question ); else irc_usermsg( irc, "%d, BitlBee: %s", num, q->question ); } @@ -833,10 +833,11 @@ static void cmd_import_buddies( irc_t *irc, char **cmd ) { user_t *u; + /* FIXME: Hmmm, this is actually pretty dangerous code... REMOVEME? :-) */ for( u = irc->users; u; u = u->next ) if( u->gc == gc ) { - u->gc->prpl->remove_buddy( u->gc, u->handle, NULL ); + u->gc->acc->prpl->remove_buddy( u->gc, u->handle, NULL ); user_del( irc, u->nick ); } @@ -851,9 +852,9 @@ static void cmd_import_buddies( irc_t *irc, char **cmd ) for( n = gc->irc->nicks; n; n = n->next ) { - if( n->proto == gc->prpl && !user_findhandle( gc, n->handle ) ) + if( n->proto == gc->acc->prpl && !user_findhandle( gc, n->handle ) ) { - gc->prpl->add_buddy( gc, n->handle ); + gc->acc->prpl->add_buddy( gc, n->handle ); add_buddy( gc, NULL, n->handle, NULL ); } } -- cgit v1.2.3 From 5100caa16bb707d89f1873aca99b5f87abc1dd56 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 1 Jul 2006 17:52:05 +0200 Subject: Added "account set" command. --- root_commands.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 3bd80e5e..b975b0f4 100644 --- a/root_commands.c +++ b/root_commands.c @@ -231,9 +231,8 @@ static void cmd_account( irc_t *irc, char **cmd ) } a = account_add( irc, prpl, cmd[3], cmd[4] ); - if( cmd[5] ) - a->server = g_strdup( cmd[5] ); + set_setstr( &a->set, "server", cmd[5] ); irc_usermsg( irc, "Account successfully added" ); } @@ -357,6 +356,68 @@ static void cmd_account( irc_t *irc, char **cmd ) return; } } + else if( g_strcasecmp( cmd[1], "set" ) == 0 ) + { + char *acc_handle, *set_name = NULL, *tmp; + + if( !cmd[2] ) + { + irc_usermsg( irc, "Not enough parameters given (need %d)", 2 ); + return; + } + + acc_handle = g_strdup( cmd[2] ); + if( ( tmp = strchr( acc_handle, '/' ) ) ) + { + *tmp = 0; + set_name = tmp + 1; + } + a = account_get( irc, acc_handle ); + + if( a == NULL ) + { + irc_usermsg( irc, "Invalid account" ); + return; + } + + if( cmd[3] ) + { + set_t *s = set_find( &a->set, set_name ); + + if( a->gc && s && s->flags & ACC_SET_OFFLINE_ONLY ) + { + irc_usermsg( irc, "This setting can only be changed when the account is off-line" ); + return; + } + + set_setstr( &a->set, set_name, cmd[3] ); + + if( ( strcmp( cmd[3], "=" ) ) == 0 && cmd[4] ) + irc_usermsg( irc, "Warning: Correct syntax: \002account set \002 (without =)" ); + } + if( set_name ) /* else 'forgotten' on purpose.. Must show new value after changing */ + { + char *s = set_getstr( &a->set, set_name ); + if( s ) + irc_usermsg( irc, "%s = `%s'", set_name, s ); + else + irc_usermsg( irc, "%s is empty", set_name ); + } + else + { + set_t *s = a->set; + while( s ) + { + if( s->value || s->def ) + irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def ); + else + irc_usermsg( irc, "%s is empty", s->key ); + s = s->next; + } + } + + g_free( acc_handle ); + } else { irc_usermsg( irc, "Unknown command: account %s. Please use \x02help commands\x02 to get a list of available commands.", cmd[1] ); @@ -681,6 +742,8 @@ static void cmd_set( irc_t *irc, char **cmd ) char *s = set_getstr( &irc->set, cmd[1] ); if( s ) irc_usermsg( irc, "%s = `%s'", cmd[1], s ); + else + irc_usermsg( irc, "%s is empty", cmd[1] ); } else { @@ -689,6 +752,8 @@ static void cmd_set( irc_t *irc, char **cmd ) { if( s->value || s->def ) irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def ); + else + irc_usermsg( irc, "%s is empty", s->key ); s = s->next; } } -- cgit v1.2.3 From 911f2eb7060f6af6fe8e4e02144cfb7c4bb4cc8b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 3 Jul 2006 01:20:27 +0200 Subject: Added display_name setting for MSN connections. (Should replace the nick command later.) --- root_commands.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index b975b0f4..42e113ed 100644 --- a/root_commands.c +++ b/root_commands.c @@ -386,7 +386,12 @@ static void cmd_account( irc_t *irc, char **cmd ) if( a->gc && s && s->flags & ACC_SET_OFFLINE_ONLY ) { - irc_usermsg( irc, "This setting can only be changed when the account is off-line" ); + irc_usermsg( irc, "This setting can only be changed when the account is %s-line", "off" ); + return; + } + else if( !a->gc && s && s->flags & ACC_SET_ONLINE_ONLY ) + { + irc_usermsg( irc, "This setting can only be changed when the account is %s-line", "on" ); return; } -- cgit v1.2.3 From 5b52a4895e5a59ff6509f7771f4d8665737688c3 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 3 Jul 2006 23:22:45 +0200 Subject: Implemented per-account nick lists instead of per-protocol nick lists. nick_t is dead, instead nicks are just saves in a per-account_t GLib hash table. While doing this, the import_buddies command finally died and text_save() disappeared, because the old file format can't handle most of the new features in this branch anyway. Still have to implement support for the new nick lists in text_load()! --- root_commands.c | 59 +++------------------------------------------------------ 1 file changed, 3 insertions(+), 56 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 42e113ed..2cf67134 100644 --- a/root_commands.c +++ b/root_commands.c @@ -465,7 +465,7 @@ static void cmd_add( irc_t *irc, char **cmd ) } else { - nick_set( irc, cmd[2], a->gc->acc->prpl, cmd[3] ); + nick_set( a, cmd[2], cmd[3] ); } } @@ -547,7 +547,7 @@ static void cmd_rename( irc_t *irc, char **cmd ) } else if( u->send_handler == buddy_send_handler ) { - nick_set( irc, u->handle, u->gc->acc->prpl, cmd[2] ); + nick_set( u->gc->acc, u->handle, cmd[2] ); } irc_usermsg( irc, "Nick successfully changed" ); @@ -568,7 +568,7 @@ static void cmd_remove( irc_t *irc, char **cmd ) u->gc->acc->prpl->remove_buddy( u->gc, u->handle, NULL ); user_del( irc, cmd[1] ); - nick_del( irc, cmd[1] ); + nick_del( u->gc->acc, u->handle ); irc_usermsg( irc, "Buddy `%s' (nick %s) removed from contact list", s, cmd[1] ); g_free( s ); @@ -880,58 +880,6 @@ static void cmd_qlist( irc_t *irc, char **cmd ) irc_usermsg( irc, "%d, BitlBee: %s", num, q->question ); } -static void cmd_import_buddies( irc_t *irc, char **cmd ) -{ - struct gaim_connection *gc; - account_t *a; - nick_t *n; - - if( !( a = account_get( irc, cmd[1] ) ) ) - { - irc_usermsg( irc, "Invalid account" ); - return; - } - else if( !( ( gc = a->gc ) && ( a->gc->flags & OPT_LOGGED_IN ) ) ) - { - irc_usermsg( irc, "That account is not on-line" ); - return; - } - - if( cmd[2] ) - { - if( g_strcasecmp( cmd[2], "clear" ) == 0 ) - { - user_t *u; - - /* FIXME: Hmmm, this is actually pretty dangerous code... REMOVEME? :-) */ - for( u = irc->users; u; u = u->next ) - if( u->gc == gc ) - { - u->gc->acc->prpl->remove_buddy( u->gc, u->handle, NULL ); - user_del( irc, u->nick ); - } - - irc_usermsg( irc, "Old buddy list cleared." ); - } - else - { - irc_usermsg( irc, "Invalid argument: %s", cmd[2] ); - return; - } - } - - for( n = gc->irc->nicks; n; n = n->next ) - { - if( n->proto == gc->acc->prpl && !user_findhandle( gc, n->handle ) ) - { - gc->acc->prpl->add_buddy( gc, n->handle ); - add_buddy( gc, NULL, n->handle, NULL ); - } - } - - irc_usermsg( irc, "Sent all add requests. Please wait for a while, the server needs some time to handle all the adds." ); -} - const command_t commands[] = { { "help", 0, cmd_help, 0 }, { "identify", 1, cmd_identify, 0 }, @@ -950,7 +898,6 @@ const command_t commands[] = { { "no", 0, cmd_yesno, 0 }, { "blist", 0, cmd_blist, 0 }, { "nick", 1, cmd_nick, 0 }, - { "import_buddies", 1, cmd_import_buddies, 0 }, { "qlist", 0, cmd_qlist, 0 }, { NULL } }; -- cgit v1.2.3 From 75a4b85ea060c5b63e9742ee9d1591bd618ba5c2 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 14 Jul 2006 11:25:48 +0200 Subject: Fixed a memory leak, added a check for valid Jabber handles, and updated documentation (added information about "account set" and sorted the list of settings because it was a bit too random). --- root_commands.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 2cf67134..389266eb 100644 --- a/root_commands.c +++ b/root_commands.c @@ -376,6 +376,7 @@ static void cmd_account( irc_t *irc, char **cmd ) if( a == NULL ) { + g_free( acc_handle ); irc_usermsg( irc, "Invalid account" ); return; } @@ -386,11 +387,13 @@ static void cmd_account( irc_t *irc, char **cmd ) if( a->gc && s && s->flags & ACC_SET_OFFLINE_ONLY ) { + g_free( acc_handle ); irc_usermsg( irc, "This setting can only be changed when the account is %s-line", "off" ); return; } else if( !a->gc && s && s->flags & ACC_SET_ONLINE_ONLY ) { + g_free( acc_handle ); irc_usermsg( irc, "This setting can only be changed when the account is %s-line", "on" ); return; } -- cgit v1.2.3 From 2811940d678bd9340055e08a0462c21e710d5714 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 27 Jul 2006 16:55:53 +0200 Subject: Copy-paste considered harmful + Fixed double handling of gc->permit/deny which actually broke the block/allow commands. --- root_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 3d3584b3..040d885c 100644 --- a/root_commands.c +++ b/root_commands.c @@ -579,7 +579,7 @@ static void cmd_allow( irc_t *irc, char **cmd ) format = "%-32.32s %-16.16s"; irc_usermsg( irc, format, "Handle", "Nickname" ); - for( l = a->gc->deny; l; l = l->next ) + for( l = a->gc->permit; l; l = l->next ) { user_t *u = user_findhandle( a->gc, l->data ); irc_usermsg( irc, format, l->data, u ? u->nick : "(none)" ); -- cgit v1.2.3 From d5ccd83c5235528df2481003502647b86b41fdc4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 13 Aug 2006 21:15:23 +0200 Subject: Extra comments in set.h and now properly using set_getbool() instead of set_getint(). --- root_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 389266eb..13567e8a 100644 --- a/root_commands.c +++ b/root_commands.c @@ -143,7 +143,7 @@ static void cmd_identify( irc_t *irc, char **cmd ) case STORAGE_OK: irc_usermsg( irc, "Password accepted, settings and accounts loaded" ); irc_umode_set( irc, "+R", 1 ); - if( set_getint( &irc->set, "auto_connect" ) ) + if( set_getbool( &irc->set, "auto_connect" ) ) cmd_account( irc, account_on ); break; case STORAGE_OTHER_ERROR: -- cgit v1.2.3 From 0383943c38ee308805798974bfccbd3327369c6a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 25 Aug 2006 00:06:52 +0200 Subject: Added message on successful creation of accounts and fixed "set password" command. --- root_commands.c | 1 + 1 file changed, 1 insertion(+) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 13567e8a..3097dc81 100644 --- a/root_commands.c +++ b/root_commands.c @@ -168,6 +168,7 @@ static void cmd_register( irc_t *irc, char **cmd ) break; case STORAGE_OK: + irc_usermsg( irc, "Account successfully created" ); irc->status |= USTATUS_IDENTIFIED; irc_umode_set( irc, "+R", 1 ); break; -- cgit v1.2.3 From 3ef6410bab141e5c6ea465730a37289991c38f9f Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Oct 2006 11:26:06 +0200 Subject: Removed a reference to an already free()d variable from cmd_remove(). --- root_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 3097dc81..64dc71b9 100644 --- a/root_commands.c +++ b/root_commands.c @@ -572,7 +572,7 @@ static void cmd_remove( irc_t *irc, char **cmd ) u->gc->acc->prpl->remove_buddy( u->gc, u->handle, NULL ); user_del( irc, cmd[1] ); - nick_del( u->gc->acc, u->handle ); + nick_del( u->gc->acc, s ); irc_usermsg( irc, "Buddy `%s' (nick %s) removed from contact list", s, cmd[1] ); g_free( s ); -- cgit v1.2.3 From aaaed5ea8950bbecee2f4b2d5ead108308c7a45f Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Oct 2006 23:42:28 +0200 Subject: A *working* fix for a memory access violation in cmd_remove(). --- root_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index e0cd15b9..116f1d06 100644 --- a/root_commands.c +++ b/root_commands.c @@ -571,8 +571,8 @@ static void cmd_remove( irc_t *irc, char **cmd ) s = g_strdup( u->handle ); u->gc->acc->prpl->remove_buddy( u->gc, u->handle, NULL ); + nick_del( u->gc->acc, u->handle ); user_del( irc, cmd[1] ); - nick_del( u->gc->acc, s ); irc_usermsg( irc, "Buddy `%s' (nick %s) removed from contact list", s, cmd[1] ); g_free( s ); -- cgit v1.2.3 From fa29d09342c79b886efacee4cfc3078be5f5a722 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 27 Mar 2007 22:53:11 -0700 Subject: Preparing for Jabber conference room support. --- root_commands.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 116f1d06..ff2d8b37 100644 --- a/root_commands.c +++ b/root_commands.c @@ -884,6 +884,53 @@ static void cmd_qlist( irc_t *irc, char **cmd ) irc_usermsg( irc, "%d, BitlBee: %s", num, q->question ); } +static void cmd_join_chat( irc_t *irc, char **cmd ) +{ + account_t *a; + struct gaim_connection *gc; + char *chat, *channel, *nick = NULL, *password = NULL; + struct conversation *c; + + if( !( a = account_get( irc, cmd[1] ) ) ) + { + irc_usermsg( irc, "Invalid account" ); + return; + } + else if( !( a->gc && ( a->gc->flags & OPT_LOGGED_IN ) ) ) + { + irc_usermsg( irc, "That account is not on-line" ); + return; + } + else if( a->prpl->chat_join == NULL ) + { + irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); + return; + } + gc = a->gc; + + chat = cmd[2]; + if( cmd[3] ) + { + channel = g_strdup( cmd[3] ); + } + else + { + char *s; + + channel = g_strdup( chat ); + if( ( s = strchr( channel, '@' ) ) ) + *s = 0; + } + if( cmd[3] && cmd[4] ) + nick = cmd[4]; + if( cmd[3] && cmd[4] && cmd[5] ) + password = cmd[5]; + + c = a->prpl->chat_join( gc, chat, nick, password ); + + g_free( channel ); +} + const command_t commands[] = { { "help", 0, cmd_help, 0 }, { "identify", 1, cmd_identify, 0 }, @@ -903,5 +950,6 @@ const command_t commands[] = { { "blist", 0, cmd_blist, 0 }, { "nick", 1, cmd_nick, 0 }, { "qlist", 0, cmd_qlist, 0 }, + { "join_chat", 2, cmd_join_chat, 0 }, { NULL } }; -- cgit v1.2.3 From 0da65d5fb37691ed4d31f7ab4058732f1440db6b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 30 Mar 2007 22:40:45 -0700 Subject: s/gaim_connection/im_connection/ and some other minor API changes. The rest will come tomorrow. It compiles, I'll leave the real testing up to someone else. ;-) --- root_commands.c | 120 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index ff2d8b37..ee6df91d 100644 --- a/root_commands.c +++ b/root_commands.c @@ -247,7 +247,7 @@ static void cmd_account( irc_t *irc, char **cmd ) { irc_usermsg( irc, "Invalid account" ); } - else if( a->gc ) + else if( a->ic ) { irc_usermsg( irc, "Account is still logged in, can't delete" ); } @@ -268,9 +268,9 @@ static void cmd_account( irc_t *irc, char **cmd ) { char *con; - if( a->gc && ( a->gc->flags & OPT_LOGGED_IN ) ) + if( a->ic && ( a->ic->flags & OPT_LOGGED_IN ) ) con = " (connected)"; - else if( a->gc ) + else if( a->ic ) con = " (connecting)"; else if( a->reconnect ) con = " (awaiting reconnect)"; @@ -289,7 +289,7 @@ static void cmd_account( irc_t *irc, char **cmd ) { if( ( a = account_get( irc, cmd[2] ) ) ) { - if( a->gc ) + if( a->ic ) { irc_usermsg( irc, "Account already online" ); return; @@ -311,7 +311,7 @@ static void cmd_account( irc_t *irc, char **cmd ) irc_usermsg( irc, "Trying to get all accounts connected..." ); for( a = irc->accounts; a; a = a->next ) - if( !a->gc && a->auto_connect ) + if( !a->ic && a->auto_connect ) account_on( irc, a ); } else @@ -328,7 +328,7 @@ static void cmd_account( irc_t *irc, char **cmd ) for( a = irc->accounts; a; a = a->next ) { - if( a->gc ) + if( a->ic ) account_off( irc, a ); else if( a->reconnect ) cancel_auto_reconnect( a ); @@ -336,7 +336,7 @@ static void cmd_account( irc_t *irc, char **cmd ) } else if( ( a = account_get( irc, cmd[2] ) ) ) { - if( a->gc ) + if( a->ic ) { account_off( irc, a ); } @@ -386,13 +386,13 @@ static void cmd_account( irc_t *irc, char **cmd ) { set_t *s = set_find( &a->set, set_name ); - if( a->gc && s && s->flags & ACC_SET_OFFLINE_ONLY ) + if( a->ic && s && s->flags & ACC_SET_OFFLINE_ONLY ) { g_free( acc_handle ); irc_usermsg( irc, "This setting can only be changed when the account is %s-line", "off" ); return; } - else if( !a->gc && s && s->flags & ACC_SET_ONLINE_ONLY ) + else if( !a->ic && s && s->flags & ACC_SET_ONLINE_ONLY ) { g_free( acc_handle ); irc_usermsg( irc, "This setting can only be changed when the account is %s-line", "on" ); @@ -449,7 +449,7 @@ static void cmd_add( irc_t *irc, char **cmd ) irc_usermsg( irc, "Invalid account" ); return; } - else if( !( a->gc && ( a->gc->flags & OPT_LOGGED_IN ) ) ) + else if( !( a->ic && ( a->ic->flags & OPT_LOGGED_IN ) ) ) { irc_usermsg( irc, "That account is not on-line" ); return; @@ -476,27 +476,27 @@ static void cmd_add( irc_t *irc, char **cmd ) /* By making this optional, you can talk to people without having to add them to your *real* (server-side) contact list. */ if( add_for_real ) - a->gc->acc->prpl->add_buddy( a->gc, cmd[2] ); + a->ic->acc->prpl->add_buddy( a->ic, cmd[2], NULL ); - add_buddy( a->gc, NULL, cmd[2], cmd[2] ); + add_buddy( a->ic, NULL, cmd[2], cmd[2] ); - irc_usermsg( irc, "User `%s' added to your contact list as `%s'", cmd[2], user_findhandle( a->gc, cmd[2] )->nick ); + irc_usermsg( irc, "User `%s' added to your contact list as `%s'", cmd[2], user_findhandle( a->ic, cmd[2] )->nick ); } static void cmd_info( irc_t *irc, char **cmd ) { - struct gaim_connection *gc; + struct im_connection *ic; account_t *a; if( !cmd[2] ) { user_t *u = user_find( irc, cmd[1] ); - if( !u || !u->gc ) + if( !u || !u->ic ) { irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); return; } - gc = u->gc; + ic = u->ic; cmd[2] = u->handle; } else if( !( a = account_get( irc, cmd[1] ) ) ) @@ -504,19 +504,19 @@ static void cmd_info( irc_t *irc, char **cmd ) irc_usermsg( irc, "Invalid account" ); return; } - else if( !( ( gc = a->gc ) && ( a->gc->flags & OPT_LOGGED_IN ) ) ) + else if( !( ( ic = a->ic ) && ( a->ic->flags & OPT_LOGGED_IN ) ) ) { irc_usermsg( irc, "That account is not on-line" ); return; } - if( !gc->acc->prpl->get_info ) + if( !ic->acc->prpl->get_info ) { irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); } else { - gc->acc->prpl->get_info( gc, cmd[2] ); + ic->acc->prpl->get_info( ic, cmd[2] ); } } @@ -551,7 +551,7 @@ static void cmd_rename( irc_t *irc, char **cmd ) } else if( u->send_handler == buddy_send_handler ) { - nick_set( u->gc->acc, u->handle, cmd[2] ); + nick_set( u->ic->acc, u->handle, cmd[2] ); } irc_usermsg( irc, "Nick successfully changed" ); @@ -563,15 +563,15 @@ static void cmd_remove( irc_t *irc, char **cmd ) user_t *u; char *s; - if( !( u = user_find( irc, cmd[1] ) ) || !u->gc ) + if( !( u = user_find( irc, cmd[1] ) ) || !u->ic ) { irc_usermsg( irc, "Buddy `%s' not found", cmd[1] ); return; } s = g_strdup( u->handle ); - u->gc->acc->prpl->remove_buddy( u->gc, u->handle, NULL ); - nick_del( u->gc->acc, u->handle ); + u->ic->acc->prpl->remove_buddy( u->ic, u->handle, NULL ); + nick_del( u->ic->acc, u->handle ); user_del( irc, cmd[1] ); irc_usermsg( irc, "Buddy `%s' (nick %s) removed from contact list", s, cmd[1] ); @@ -582,10 +582,10 @@ static void cmd_remove( irc_t *irc, char **cmd ) static void cmd_block( irc_t *irc, char **cmd ) { - struct gaim_connection *gc; + struct im_connection *ic; account_t *a; - if( !cmd[2] && ( a = account_get( irc, cmd[1] ) ) && a->gc ) + if( !cmd[2] && ( a = account_get( irc, cmd[1] ) ) && a->ic ) { char *format; GSList *l; @@ -596,9 +596,9 @@ static void cmd_block( irc_t *irc, char **cmd ) format = "%-32.32s %-16.16s"; irc_usermsg( irc, format, "Handle", "Nickname" ); - for( l = a->gc->deny; l; l = l->next ) + for( l = a->ic->deny; l; l = l->next ) { - user_t *u = user_findhandle( a->gc, l->data ); + user_t *u = user_findhandle( a->ic, l->data ); irc_usermsg( irc, format, l->data, u ? u->nick : "(none)" ); } irc_usermsg( irc, "End of list." ); @@ -608,12 +608,12 @@ static void cmd_block( irc_t *irc, char **cmd ) else if( !cmd[2] ) { user_t *u = user_find( irc, cmd[1] ); - if( !u || !u->gc ) + if( !u || !u->ic ) { irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); return; } - gc = u->gc; + ic = u->ic; cmd[2] = u->handle; } else if( !( a = account_get( irc, cmd[1] ) ) ) @@ -621,30 +621,30 @@ static void cmd_block( irc_t *irc, char **cmd ) irc_usermsg( irc, "Invalid account" ); return; } - else if( !( ( gc = a->gc ) && ( a->gc->flags & OPT_LOGGED_IN ) ) ) + else if( !( ( ic = a->ic ) && ( a->ic->flags & OPT_LOGGED_IN ) ) ) { irc_usermsg( irc, "That account is not on-line" ); return; } - if( !gc->acc->prpl->add_deny || !gc->acc->prpl->rem_permit ) + if( !ic->acc->prpl->add_deny || !ic->acc->prpl->rem_permit ) { irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); } else { - bim_rem_allow( gc, cmd[2] ); - bim_add_block( gc, cmd[2] ); + bim_rem_allow( ic, cmd[2] ); + bim_add_block( ic, cmd[2] ); irc_usermsg( irc, "Buddy `%s' moved from your allow- to your block-list", cmd[2] ); } } static void cmd_allow( irc_t *irc, char **cmd ) { - struct gaim_connection *gc; + struct im_connection *ic; account_t *a; - if( !cmd[2] && ( a = account_get( irc, cmd[1] ) ) && a->gc ) + if( !cmd[2] && ( a = account_get( irc, cmd[1] ) ) && a->ic ) { char *format; GSList *l; @@ -655,9 +655,9 @@ static void cmd_allow( irc_t *irc, char **cmd ) format = "%-32.32s %-16.16s"; irc_usermsg( irc, format, "Handle", "Nickname" ); - for( l = a->gc->permit; l; l = l->next ) + for( l = a->ic->permit; l; l = l->next ) { - user_t *u = user_findhandle( a->gc, l->data ); + user_t *u = user_findhandle( a->ic, l->data ); irc_usermsg( irc, format, l->data, u ? u->nick : "(none)" ); } irc_usermsg( irc, "End of list." ); @@ -667,12 +667,12 @@ static void cmd_allow( irc_t *irc, char **cmd ) else if( !cmd[2] ) { user_t *u = user_find( irc, cmd[1] ); - if( !u || !u->gc ) + if( !u || !u->ic ) { irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); return; } - gc = u->gc; + ic = u->ic; cmd[2] = u->handle; } else if( !( a = account_get( irc, cmd[1] ) ) ) @@ -680,20 +680,20 @@ static void cmd_allow( irc_t *irc, char **cmd ) irc_usermsg( irc, "Invalid account" ); return; } - else if( !( ( gc = a->gc ) && ( a->gc->flags & OPT_LOGGED_IN ) ) ) + else if( !( ( ic = a->ic ) && ( a->ic->flags & OPT_LOGGED_IN ) ) ) { irc_usermsg( irc, "That account is not on-line" ); return; } - if( !gc->acc->prpl->rem_deny || !gc->acc->prpl->add_permit ) + if( !ic->acc->prpl->rem_deny || !ic->acc->prpl->add_permit ) { irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); } else { - bim_rem_block( gc, cmd[2] ); - bim_add_allow( gc, cmd[2] ); + bim_rem_block( ic, cmd[2] ); + bim_add_allow( ic, cmd[2] ); irc_usermsg( irc, "Buddy `%s' moved from your block- to your allow-list", cmd[2] ); } @@ -802,32 +802,32 @@ static void cmd_blist( irc_t *irc, char **cmd ) irc_usermsg( irc, format, "Nick", "User/Host/Network", "Status" ); - for( u = irc->users; u; u = u->next ) if( u->gc && u->online && !u->away ) + for( u = irc->users; u; u = u->next ) if( u->ic && u->online && !u->away ) { if( online == 1 ) { - g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); + g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->ic->acc->prpl->name ); irc_usermsg( irc, format, u->nick, s, "Online" ); } n_online ++; } - for( u = irc->users; u; u = u->next ) if( u->gc && u->online && u->away ) + for( u = irc->users; u; u = u->next ) if( u->ic && u->online && u->away ) { if( away == 1 ) { - g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); + g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->ic->acc->prpl->name ); irc_usermsg( irc, format, u->nick, s, u->away ); } n_away ++; } - for( u = irc->users; u; u = u->next ) if( u->gc && !u->online ) + for( u = irc->users; u; u = u->next ) if( u->ic && !u->online ) { if( offline == 1 ) { - g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); + g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->ic->acc->prpl->name ); irc_usermsg( irc, format, u->nick, s, "Offline" ); } n_offline ++; @@ -844,15 +844,15 @@ static void cmd_nick( irc_t *irc, char **cmd ) { irc_usermsg( irc, "Invalid account"); } - else if( !( a->gc && ( a->gc->flags & OPT_LOGGED_IN ) ) ) + else if( !( a->ic && ( a->ic->flags & OPT_LOGGED_IN ) ) ) { irc_usermsg( irc, "That account is not on-line" ); } else if ( !cmd[2] ) { - irc_usermsg( irc, "Your name is `%s'" , a->gc->displayname ? a->gc->displayname : "NULL" ); + irc_usermsg( irc, "Your name is `%s'" , a->ic->displayname ? a->ic->displayname : "NULL" ); } - else if ( !a->prpl->set_info ) + else if ( !a->prpl->set_my_name ) { irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); } @@ -860,7 +860,7 @@ static void cmd_nick( irc_t *irc, char **cmd ) { irc_usermsg( irc, "Setting your name to `%s'", cmd[2] ); - a->prpl->set_info( a->gc, cmd[2] ); + a->prpl->set_my_name( a->ic, cmd[2] ); } } @@ -878,8 +878,8 @@ static void cmd_qlist( irc_t *irc, char **cmd ) irc_usermsg( irc, "Pending queries:" ); for( num = 0; q; q = q->next, num ++ ) - if( q->gc ) /* Not necessary yet, but it might come later */ - irc_usermsg( irc, "%d, %s(%s): %s", num, q->gc->acc->prpl->name, q->gc->username, q->question ); + if( q->ic ) /* Not necessary yet, but it might come later */ + irc_usermsg( irc, "%d, %s(%s): %s", num, q->ic->acc->prpl->name, q->ic->username, q->question ); else irc_usermsg( irc, "%d, BitlBee: %s", num, q->question ); } @@ -887,16 +887,16 @@ static void cmd_qlist( irc_t *irc, char **cmd ) static void cmd_join_chat( irc_t *irc, char **cmd ) { account_t *a; - struct gaim_connection *gc; + struct im_connection *ic; char *chat, *channel, *nick = NULL, *password = NULL; - struct conversation *c; + struct groupchat *c; if( !( a = account_get( irc, cmd[1] ) ) ) { irc_usermsg( irc, "Invalid account" ); return; } - else if( !( a->gc && ( a->gc->flags & OPT_LOGGED_IN ) ) ) + else if( !( a->ic && ( a->ic->flags & OPT_LOGGED_IN ) ) ) { irc_usermsg( irc, "That account is not on-line" ); return; @@ -906,7 +906,7 @@ static void cmd_join_chat( irc_t *irc, char **cmd ) irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); return; } - gc = a->gc; + ic = a->ic; chat = cmd[2]; if( cmd[3] ) @@ -926,7 +926,7 @@ static void cmd_join_chat( irc_t *irc, char **cmd ) if( cmd[3] && cmd[4] && cmd[5] ) password = cmd[5]; - c = a->prpl->chat_join( gc, chat, nick, password ); + c = a->prpl->chat_join( ic, chat, nick, password ); g_free( channel ); } -- cgit v1.2.3 From c2fb38096ea4e75a680e57e103d4a4986aa84c75 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Apr 2007 15:39:35 -0700 Subject: Cleaned up struct im_connection. No more username/password stuff since it's in acc too. wants_to_die is now an argument to imc_logout(). --- root_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index ee6df91d..0b3d6844 100644 --- a/root_commands.c +++ b/root_commands.c @@ -879,7 +879,7 @@ static void cmd_qlist( irc_t *irc, char **cmd ) for( num = 0; q; q = q->next, num ++ ) if( q->ic ) /* Not necessary yet, but it might come later */ - irc_usermsg( irc, "%d, %s(%s): %s", num, q->ic->acc->prpl->name, q->ic->username, q->question ); + irc_usermsg( irc, "%d, %s(%s): %s", num, q->ic->acc->prpl->name, q->ic->acc->user, q->question ); else irc_usermsg( irc, "%d, BitlBee: %s", num, q->question ); } -- cgit v1.2.3 From 84b045d409f1e8da6d8bf379c6fef7236dcd9bcd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Apr 2007 18:03:08 -0700 Subject: s/imc/imcb/ for callback functions. Moved things aroundin nogaim.h a little bit, grouping things by category instead of original Gaim 0.58 filename. --- root_commands.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 0b3d6844..acbf579f 100644 --- a/root_commands.c +++ b/root_commands.c @@ -633,8 +633,8 @@ static void cmd_block( irc_t *irc, char **cmd ) } else { - bim_rem_allow( ic, cmd[2] ); - bim_add_block( ic, cmd[2] ); + imc_rem_allow( ic, cmd[2] ); + imc_add_block( ic, cmd[2] ); irc_usermsg( irc, "Buddy `%s' moved from your allow- to your block-list", cmd[2] ); } } @@ -692,8 +692,8 @@ static void cmd_allow( irc_t *irc, char **cmd ) } else { - bim_rem_block( ic, cmd[2] ); - bim_add_allow( ic, cmd[2] ); + imc_rem_block( ic, cmd[2] ); + imc_add_allow( ic, cmd[2] ); irc_usermsg( irc, "Buddy `%s' moved from your block- to your allow-list", cmd[2] ); } -- cgit v1.2.3 From f0cb961652cbd639e89dcd88a86f20a2414146c4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 18 Apr 2007 23:03:43 -0700 Subject: More API changes: buddy list management. imcb_add_buddy() is now a *real* callback, it's only called from inside IM-modules. This makes sure a buddy only gets added to the BitlBee structures if the add was successful. This gets rid of the weirdness described in #55. Unfortunately for now this change breaks A) automatic renaming of ICQ contacts (if there are names stored in the contact list) B) add -tmp. --- root_commands.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index acbf579f..a7582936 100644 --- a/root_commands.c +++ b/root_commands.c @@ -436,11 +436,11 @@ static void cmd_account( irc_t *irc, char **cmd ) static void cmd_add( irc_t *irc, char **cmd ) { account_t *a; - int add_for_real = 1; + int add_on_server = 1; if( g_strcasecmp( cmd[1], "-tmp" ) == 0 ) { - add_for_real = 0; + add_on_server = 0; cmd ++; /* So evil... :-D */ } @@ -475,12 +475,12 @@ static void cmd_add( irc_t *irc, char **cmd ) /* By making this optional, you can talk to people without having to add them to your *real* (server-side) contact list. */ - if( add_for_real ) + if( add_on_server ) a->ic->acc->prpl->add_buddy( a->ic, cmd[2], NULL ); - - add_buddy( a->ic, NULL, cmd[2], cmd[2] ); - irc_usermsg( irc, "User `%s' added to your contact list as `%s'", cmd[2], user_findhandle( a->ic, cmd[2] )->nick ); + /* add_buddy( a->ic, NULL, cmd[2], cmd[2] ); */ + + irc_usermsg( irc, "Adding `%s' to your contact list", cmd[2] ); } static void cmd_info( irc_t *irc, char **cmd ) -- cgit v1.2.3 From e35d1a121d5fb2da3698fbe4a365fe38d0097665 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 22 Apr 2007 13:44:27 -0700 Subject: Read-only support for Jabber conferences (non-anonymous rooms only). Just don't use this, you're really not going to like it. :-) --- root_commands.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index a7582936..2b57fb4f 100644 --- a/root_commands.c +++ b/root_commands.c @@ -923,12 +923,21 @@ static void cmd_join_chat( irc_t *irc, char **cmd ) } if( cmd[3] && cmd[4] ) nick = cmd[4]; + else + nick = irc->nick; if( cmd[3] && cmd[4] && cmd[5] ) password = cmd[5]; - c = a->prpl->chat_join( ic, chat, nick, password ); - - g_free( channel ); + if( ( c = a->prpl->chat_join( ic, chat, nick, password ) ) ) + { + g_free( c->channel ); + c->channel = channel; + } + else + { + irc_usermsg( irc, "Tried to join chat, not sure if this was successful" ); + g_free( channel ); + } } const command_t commands[] = { -- cgit v1.2.3 From 0e7ab64dfb66192a875c37322ca6f8a364ec5bc8 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 22 Apr 2007 19:58:44 -0700 Subject: Got rid of one HORRIBLE stupidity called chat_by_channel(), which still used the GLOBAL IM connections list, allowing user A to interfere with user B's groupchats if running in daemon mode. I can't believe this was still there... --- root_commands.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 2b57fb4f..9965c2e8 100644 --- a/root_commands.c +++ b/root_commands.c @@ -917,7 +917,7 @@ static void cmd_join_chat( irc_t *irc, char **cmd ) { char *s; - channel = g_strdup( chat ); + channel = g_strdup_printf( "&%s", chat ); if( ( s = strchr( channel, '@' ) ) ) *s = 0; } @@ -928,6 +928,19 @@ static void cmd_join_chat( irc_t *irc, char **cmd ) if( cmd[3] && cmd[4] && cmd[5] ) password = cmd[5]; + if( channel[0] != '#' && channel[0] != '&' ) + { + irc_usermsg( irc, "Invalid channel name: %s", channel ); + g_free( channel ); + return; + } + else if( g_strcasecmp( channel, irc->channel ) == 0 || irc_chat_by_channel( irc, channel ) ) + { + irc_usermsg( irc, "Channel already exists: %s", channel ); + g_free( channel ); + return; + } + if( ( c = a->prpl->chat_join( ic, chat, nick, password ) ) ) { g_free( c->channel ); -- cgit v1.2.3 From 7bf4326f7a9b2a2aec8b292ecbc876d4349d2624 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 1 Jul 2007 13:20:23 +0100 Subject: Better groupchat channel name generation/verification. --- root_commands.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 9965c2e8..8ffebd8e 100644 --- a/root_commands.c +++ b/root_commands.c @@ -911,7 +911,10 @@ static void cmd_join_chat( irc_t *irc, char **cmd ) chat = cmd[2]; if( cmd[3] ) { - channel = g_strdup( cmd[3] ); + if( channel[0] != '#' && channel[0] != '&' ) + channel = g_strdup_printf( "&%s", cmd[3] ); + else + channel = g_strdup( cmd[3] ); } else { @@ -928,7 +931,7 @@ static void cmd_join_chat( irc_t *irc, char **cmd ) if( cmd[3] && cmd[4] && cmd[5] ) password = cmd[5]; - if( channel[0] != '#' && channel[0] != '&' ) + if( !nick_ok( channel + 1 ) ) { irc_usermsg( irc, "Invalid channel name: %s", channel ); g_free( channel ); -- cgit v1.2.3 From 9da0bbfd42609f0f3864b5a16a3c1c378b7217c9 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 2 Jul 2007 23:12:03 +0100 Subject: Added (and using) jabber_chat_free() for better memory management, fixed channel name generation code in root_commands.c and fixed one memory leak in jabber_buddy_remove_bare(). --- root_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 8ffebd8e..0f9f776c 100644 --- a/root_commands.c +++ b/root_commands.c @@ -911,7 +911,7 @@ static void cmd_join_chat( irc_t *irc, char **cmd ) chat = cmd[2]; if( cmd[3] ) { - if( channel[0] != '#' && channel[0] != '&' ) + if( cmd[3][0] != '#' && cmd[3][0] != '&' ) channel = g_strdup_printf( "&%s", cmd[3] ); else channel = g_strdup( cmd[3] ); -- cgit v1.2.3 From 9334cc280474ae55f67e058797e214d30251973a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 25 Sep 2007 09:08:56 +0100 Subject: Fixed NULL pointer dereference in "account set" command. That command indeed does have a slightly confusing syntax. --- root_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index a7582936..baaf3354 100644 --- a/root_commands.c +++ b/root_commands.c @@ -382,7 +382,7 @@ static void cmd_account( irc_t *irc, char **cmd ) return; } - if( cmd[3] ) + if( cmd[3] && set_name ) { set_t *s = set_find( &a->set, set_name ); -- cgit v1.2.3 From cd428e473fe4428041722fd373badef890edebd9 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 17 Nov 2007 12:20:51 +0000 Subject: Added (account) set -del. --- root_commands.c | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index baaf3354..59852de6 100644 --- a/root_commands.c +++ b/root_commands.c @@ -367,15 +367,18 @@ static void cmd_account( irc_t *irc, char **cmd ) return; } - acc_handle = g_strdup( cmd[2] ); + if( g_strncasecmp( cmd[2], "-del", 4 ) == 0 ) + acc_handle = g_strdup( cmd[3] ); + else + acc_handle = g_strdup( cmd[2] ); + if( ( tmp = strchr( acc_handle, '/' ) ) ) { *tmp = 0; set_name = tmp + 1; } - a = account_get( irc, acc_handle ); - if( a == NULL ) + if( ( a = account_get( irc, acc_handle ) ) == NULL ) { g_free( acc_handle ); irc_usermsg( irc, "Invalid account" ); @@ -399,10 +402,12 @@ static void cmd_account( irc_t *irc, char **cmd ) return; } - set_setstr( &a->set, set_name, cmd[3] ); - if( ( strcmp( cmd[3], "=" ) ) == 0 && cmd[4] ) irc_usermsg( irc, "Warning: Correct syntax: \002account set \002 (without =)" ); + else if( g_strncasecmp( cmd[2], "-del", 4 ) == 0 ) + set_reset( &a->set, set_name ); + else + set_setstr( &a->set, set_name, cmd[3] ); } if( set_name ) /* else 'forgotten' on purpose.. Must show new value after changing */ { @@ -418,7 +423,7 @@ static void cmd_account( irc_t *irc, char **cmd ) while( s ) { if( s->value || s->def ) - irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def ); + irc_usermsg( irc, "%s = `%s'", s->key, s->value ? s->value : s->def ); else irc_usermsg( irc, "%s is empty", s->key ); s = s->next; @@ -739,20 +744,33 @@ static void cmd_yesno( irc_t *irc, char **cmd ) static void cmd_set( irc_t *irc, char **cmd ) { + char *set_name; + if( cmd[1] && cmd[2] ) { - set_setstr( &irc->set, cmd[1], cmd[2] ); - if( ( strcmp( cmd[2], "=" ) ) == 0 && cmd[3] ) + { irc_usermsg( irc, "Warning: Correct syntax: \002set \002 (without =)" ); + return; + } + else if( g_strncasecmp( cmd[1], "-del", 4 ) == 0 ) + { + set_reset( &irc->set, cmd[2] ); + set_name = cmd[2]; + } + else + { + set_setstr( &irc->set, cmd[1], cmd[2] ); + set_name = cmd[1]; + } } if( cmd[1] ) /* else 'forgotten' on purpose.. Must show new value after changing */ { - char *s = set_getstr( &irc->set, cmd[1] ); - if( s ) - irc_usermsg( irc, "%s = `%s'", cmd[1], s ); + char *s = set_getstr( &irc->set, set_name ); + if( s ) + irc_usermsg( irc, "%s = `%s'", set_name, s ); else - irc_usermsg( irc, "%s is empty", cmd[1] ); + irc_usermsg( irc, "%s is empty", set_name ); } else { @@ -760,7 +778,7 @@ static void cmd_set( irc_t *irc, char **cmd ) while( s ) { if( s->value || s->def ) - irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def ); + irc_usermsg( irc, "%s = `%s'", s->key, s->value ? s->value : s->def ); else irc_usermsg( irc, "%s is empty", s->key ); s = s->next; -- cgit v1.2.3 From 56f260affd91651cb0c44ee14713f7dfa0717ad4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 22 Nov 2007 22:56:52 +0000 Subject: Some changes to get rid of compiler warnings. (And disabling strict aliasing because there are too many warnings about it. :-P) --- root_commands.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index e9c71f04..642f5374 100644 --- a/root_commands.c +++ b/root_commands.c @@ -744,7 +744,7 @@ static void cmd_yesno( irc_t *irc, char **cmd ) static void cmd_set( irc_t *irc, char **cmd ) { - char *set_name; + char *set_name = NULL; if( cmd[1] && cmd[2] ) { @@ -764,7 +764,7 @@ static void cmd_set( irc_t *irc, char **cmd ) set_name = cmd[1]; } } - if( cmd[1] ) /* else 'forgotten' on purpose.. Must show new value after changing */ + if( set_name ) /* else 'forgotten' on purpose.. Must show new value after changing */ { char *s = set_getstr( &irc->set, set_name ); if( s ) -- cgit v1.2.3 From 71dc8543dc4eeafabbe28bae52ec1d05ce9f5fea Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 10 Dec 2007 22:33:08 +0000 Subject: Fixed "set xxx" syntax (it showed all settings instead of just xxx). --- root_commands.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 642f5374..2a5938e7 100644 --- a/root_commands.c +++ b/root_commands.c @@ -402,9 +402,7 @@ static void cmd_account( irc_t *irc, char **cmd ) return; } - if( ( strcmp( cmd[3], "=" ) ) == 0 && cmd[4] ) - irc_usermsg( irc, "Warning: Correct syntax: \002account set \002 (without =)" ); - else if( g_strncasecmp( cmd[2], "-del", 4 ) == 0 ) + if( g_strncasecmp( cmd[2], "-del", 4 ) == 0 ) set_reset( &a->set, set_name ); else set_setstr( &a->set, set_name, cmd[3] ); @@ -744,16 +742,11 @@ static void cmd_yesno( irc_t *irc, char **cmd ) static void cmd_set( irc_t *irc, char **cmd ) { - char *set_name = NULL; + char *set_name = cmd[1]; if( cmd[1] && cmd[2] ) { - if( ( strcmp( cmd[2], "=" ) ) == 0 && cmd[3] ) - { - irc_usermsg( irc, "Warning: Correct syntax: \002set \002 (without =)" ); - return; - } - else if( g_strncasecmp( cmd[1], "-del", 4 ) == 0 ) + if( g_strncasecmp( cmd[1], "-del", 4 ) == 0 ) { set_reset( &irc->set, cmd[2] ); set_name = cmd[2]; @@ -761,7 +754,6 @@ static void cmd_set( irc_t *irc, char **cmd ) else { set_setstr( &irc->set, cmd[1], cmd[2] ); - set_name = cmd[1]; } } if( set_name ) /* else 'forgotten' on purpose.. Must show new value after changing */ -- cgit v1.2.3 From 30ce1ced040c44c528d0a6e6e9c6b10a1caf1052 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 12 Dec 2007 23:30:51 +0000 Subject: Killed the parameter to "account add" and changed the default server for OSCAR to what both login.icq.com and login.oscar.aol.com resolve to these days. There's no need to specify a server anymore so why bother. And cleaned up the docs (removed all references to those OSCAR servers). --- root_commands.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 2a5938e7..dc70feb4 100644 --- a/root_commands.c +++ b/root_commands.c @@ -198,7 +198,7 @@ static void cmd_drop( irc_t *irc, char **cmd ) irc_usermsg( irc, "Account `%s' removed", irc->nick ); break; default: - irc_usermsg( irc, "Error: '%d'", status ); + irc_usermsg( irc, "Error: `%d'", status ); break; } } @@ -233,7 +233,11 @@ static void cmd_account( irc_t *irc, char **cmd ) a = account_add( irc, prpl, cmd[3], cmd[4] ); if( cmd[5] ) + { + irc_usermsg( irc, "Warning: Passing a servername/other flags to `account add' " + "is now deprecated. Use `account set' instead." ); set_setstr( &a->set, "server", cmd[5] ); + } irc_usermsg( irc, "Account successfully added" ); } @@ -316,7 +320,7 @@ static void cmd_account( irc_t *irc, char **cmd ) } else { - irc_usermsg( irc, "No accounts known. Use 'account add' to add one." ); + irc_usermsg( irc, "No accounts known. Use `account add' to add one." ); } } } -- cgit v1.2.3 From e7311208511c391b4f55161b6be93dbffb381c5e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 11 Jan 2008 00:45:18 +0000 Subject: Adding own handle to protocol name in blist output for people with multiple accounts on the same IM network. --- root_commands.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index dc70feb4..26a42a25 100644 --- a/root_commands.c +++ b/root_commands.c @@ -820,7 +820,7 @@ static void cmd_blist( irc_t *irc, char **cmd ) { if( online == 1 ) { - g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->ic->acc->prpl->name ); + g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user ); irc_usermsg( irc, format, u->nick, s, "Online" ); } @@ -831,7 +831,7 @@ static void cmd_blist( irc_t *irc, char **cmd ) { if( away == 1 ) { - g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->ic->acc->prpl->name ); + g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user ); irc_usermsg( irc, format, u->nick, s, u->away ); } n_away ++; @@ -841,7 +841,7 @@ static void cmd_blist( irc_t *irc, char **cmd ) { if( offline == 1 ) { - g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->ic->acc->prpl->name ); + g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user ); irc_usermsg( irc, format, u->nick, s, "Offline" ); } n_offline ++; -- cgit v1.2.3 From 7adc657830fe76df344bf718df45ca05cc015d4e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 9 Feb 2008 23:54:09 +0000 Subject: Restored "add -tmp". A bit hackish, but it will do for now. --- root_commands.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 26a42a25..8e315bd4 100644 --- a/root_commands.c +++ b/root_commands.c @@ -448,7 +448,7 @@ static void cmd_add( irc_t *irc, char **cmd ) if( g_strcasecmp( cmd[1], "-tmp" ) == 0 ) { add_on_server = 0; - cmd ++; /* So evil... :-D */ + cmd ++; } if( !( a = account_get( irc, cmd[1] ) ) ) @@ -480,12 +480,13 @@ static void cmd_add( irc_t *irc, char **cmd ) } } - /* By making this optional, you can talk to people without having to - add them to your *real* (server-side) contact list. */ if( add_on_server ) a->ic->acc->prpl->add_buddy( a->ic, cmd[2], NULL ); - - /* add_buddy( a->ic, NULL, cmd[2], cmd[2] ); */ + else + /* Yeah, officially this is a call-*back*... So if we just + called add_buddy, we'll wait for the IM server to respond + before we do this. */ + imcb_add_buddy( a->ic, cmd[2], NULL ); irc_usermsg( irc, "Adding `%s' to your contact list", cmd[2] ); } -- cgit v1.2.3 From d5bd9c078ae2fb4d2e9354e943e06e017e878776 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 28 Feb 2008 22:39:37 +0000 Subject: My fix for semi-PEBKAC bug #353: Add a warning if someone seems to be using the wrong command, and fixing "help nick" example to show how it should be done now. --- root_commands.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 8e315bd4..2f542826 100644 --- a/root_commands.c +++ b/root_commands.c @@ -768,6 +768,9 @@ static void cmd_set( irc_t *irc, char **cmd ) irc_usermsg( irc, "%s = `%s'", set_name, s ); else irc_usermsg( irc, "%s is empty", set_name ); + + if( strchr( set_name, '/' ) ) + irc_usermsg( irc, "Warning: / found in setting name, you're probably looking for the `account set' command." ); } else { -- cgit v1.2.3 From 7f421d6b922837857d6aca342da314225023eb46 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 3 Mar 2008 23:18:36 +0000 Subject: BitlBee <= 1.0 didn't have "account set" and allowed one to delete an account and re-create it with new login settings if necessary, without losing custom nicknames. Now, nicknames are connected to an account instead of just the protocol, and they're flushed together with the account. So I added a warning to make sure nobody accidentally loses any settings while just changing the password. This will probably go after a few releases, since it's slightly annoying. --- root_commands.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 2f542826..9a60b5af 100644 --- a/root_commands.c +++ b/root_commands.c @@ -203,6 +203,26 @@ 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; + + if( a->ic ) + { + irc_usermsg( irc, "Account is still logged in, can't delete" ); + } + else + { + account_del( irc, a ); + irc_usermsg( irc, "Account deleted" ); + } +} + +void cmd_account_del_no( gpointer w, void *data ) +{ +} + static void cmd_account( irc_t *irc, char **cmd ) { account_t *a; @@ -257,8 +277,15 @@ static void cmd_account( irc_t *irc, char **cmd ) } else { - account_del( irc, a ); - irc_usermsg( irc, "Account deleted" ); + char *msg; + + 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 ); + g_free( msg ); } } else if( g_strcasecmp( cmd[1], "list" ) == 0 ) -- cgit v1.2.3