From 2c2df7dd91930345a9b22a8bb61327d1dcc7e3d5 Mon Sep 17 00:00:00 2001 From: ulim Date: Wed, 28 Nov 2007 22:07:30 +0100 Subject: Initial import of jabber file receive and DCC send support. This introduces only a few changes to bitlbees code, mainly the addition of the "transfers" command. This is known to work with Kopete, Psi, and Pidgin (formerly known as gaim). At least with Pidgin also over a proxy. DCC has only been tested with irssi. IPV6 is untested but should work. Currently, only receiving via SOCKS5BYTESREAMS is implemented. I'm not sure if the alternative(in-band bytestreams IBB) is worth implementing since I didn't see a client yet that can do it. Additionally, it is probably very slow and needs support by the server as well. --- root_commands.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 642f5374..2da77519 100644 --- a/root_commands.c +++ b/root_commands.c @@ -974,6 +974,71 @@ static void cmd_join_chat( irc_t *irc, char **cmd ) } } +static void cmd_transfers( irc_t *irc, char **cmd ) +{ + GSList *files = irc->file_transfers; + enum { LIST, REJECT, CANCEL }; + int subcmd = LIST; + int fid; + + if( !files ) + { + irc_usermsg( irc, "No pending transfers" ); + return; + } + + if( cmd[1] && + ( strcmp( cmd[1], "reject" ) == 0 ) ) + { + subcmd = REJECT; + } + else if( cmd[1] && + ( strcmp( cmd[1], "cancel" ) == 0 ) && + cmd[2] && + ( fid = atoi( cmd[2] ) ) ) + { + subcmd = CANCEL; + } + + for( ; files; files = g_slist_next( files ) ) + { + file_transfer_t *file = files->data; + + switch( subcmd ) { + case LIST: + if ( file->status == FT_STATUS_LISTENING ) + irc_usermsg( irc, + "Pending file(id %d): %s (Listening...)", file->local_id, file->file_name); + else + { + int kb_per_s = 0; + time_t diff = time( NULL ) - file->started; + if ( ( file->started > 0 ) && ( file->bytes_transferred > 0 ) ) + kb_per_s = file->bytes_transferred / 1024 / diff; + + irc_usermsg( irc, + "Pending file(id %d): %s (%10zd/%zd kb, %d kb/s)", file->local_id, file->file_name, + file->bytes_transferred/1024, file->file_size/1024, kb_per_s); + } + break; + case REJECT: + if( file->status == FT_STATUS_LISTENING ) + { + irc_usermsg( irc, "Rejecting file transfer for %s", file->file_name ); + imcb_file_canceled( file, "Denied by user" ); + } + break; + case CANCEL: + if( file->local_id == fid ) + { + irc_usermsg( irc, "Canceling file transfer for %s", file->file_name ); + imcb_file_canceled( file, "Canceled by user" ); + } + break; + } + } +} + const command_t commands[] = { { "help", 0, cmd_help, 0 }, { "identify", 1, cmd_identify, 0 }, @@ -994,5 +1059,6 @@ const command_t commands[] = { { "nick", 1, cmd_nick, 0 }, { "qlist", 0, cmd_qlist, 0 }, { "join_chat", 2, cmd_join_chat, 0 }, + { "transfers", 0, cmd_transfers, 0 }, { NULL } }; -- cgit v1.2.3 From eded1f703a8f5d2272b9d294d8e3dfb48fa302b4 Mon Sep 17 00:00:00 2001 From: kenobi Date: Wed, 19 Dec 2007 00:59:35 +0100 Subject: Merged in 280..288 from upstream (e.g. PING) --- root_commands.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 2da77519..eea16178 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." ); } } } @@ -402,9 +406,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 +746,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 +758,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 44961cb326fde3cb681a79eb28becb74a921a29d Mon Sep 17 00:00:00 2001 From: ulim Date: Wed, 7 May 2008 00:06:22 +0200 Subject: fix bug in new kb/s display for transfers of less than one second. --- 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 9dfbc998..b3a77a10 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1075,7 +1075,7 @@ static void cmd_transfers( irc_t *irc, char **cmd ) else { int kb_per_s = 0; - time_t diff = time( NULL ) - file->started; + time_t diff = time( NULL ) - file->started ? : 1; if ( ( file->started > 0 ) && ( file->bytes_transferred > 0 ) ) kb_per_s = file->bytes_transferred / 1024 / diff; -- cgit v1.2.3 From b8a491db597ba2d82cc8eddc727509197747f0d5 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 18 Mar 2010 00:30:38 +0000 Subject: Some compiler warning fixes and renamed "transfers" command to just "transfer" since all root commands are singular so far. --- root_commands.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index b39cb1ba..c60092f0 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1127,7 +1127,7 @@ static void cmd_chat( irc_t *irc, char **cmd ) } } -static void cmd_transfers( irc_t *irc, char **cmd ) +static void cmd_transfer( irc_t *irc, char **cmd ) { GSList *files = irc->file_transfers; enum { LIST, REJECT, CANCEL }; @@ -1140,15 +1140,12 @@ static void cmd_transfers( irc_t *irc, char **cmd ) return; } - if( cmd[1] && - ( strcmp( cmd[1], "reject" ) == 0 ) ) + if( cmd[1] && ( strcmp( cmd[1], "reject" ) == 0 ) ) { subcmd = REJECT; } - else if( cmd[1] && - ( strcmp( cmd[1], "cancel" ) == 0 ) && - cmd[2] && - ( fid = atoi( cmd[2] ) ) ) + else if( cmd[1] && ( strcmp( cmd[1], "cancel" ) == 0 ) && + cmd[2] && ( sscanf( cmd[2], "%d", &fid ) == 1 ) ) { subcmd = CANCEL; } @@ -1213,6 +1210,6 @@ const command_t commands[] = { { "qlist", 0, cmd_qlist, 0 }, { "join_chat", 2, cmd_join_chat, 0 }, { "chat", 1, cmd_chat, 0 }, - { "transfers", 0, cmd_transfers, 0 }, + { "transfer", 0, cmd_transfer, 0 }, { NULL } }; -- cgit v1.2.3 From ba7d16f3c90de2744243efe6373ccebe51cfcb5a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 24 Mar 2010 17:12:53 +0000 Subject: Now seems like a pretty good time to finally kill crypting.c and storage_text. This means people won't be able to upgrade from BitlBee 1.0 to this version anymore but only via 1.2. 1.0 is old enough that I don't really expect this to be a problem. --- root_commands.c | 1 - 1 file changed, 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index e42268b5..d3b0c7d3 100644 --- a/root_commands.c +++ b/root_commands.c @@ -25,7 +25,6 @@ #define BITLBEE_CORE #include "commands.h" -#include "crypting.h" #include "bitlbee.h" #include "help.h" #include "chat.h" -- cgit v1.2.3 From 280c56a7b24dc08b35a1ecd98c8f4b61435d1100 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 27 Mar 2010 13:36:47 -0400 Subject: Added privmsg handlers to users/channels. root commands are coming back. --- root_commands.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index d3b0c7d3..9b396379 100644 --- a/root_commands.c +++ b/root_commands.c @@ -31,7 +31,7 @@ #include -void root_command_string( irc_t *irc, user_t *u, char *command, int flags ) +void root_command_string( irc_t *irc, char *command ) { char *cmd[IRC_MAX_ARGS]; char *s; @@ -135,6 +135,7 @@ static void cmd_help( irc_t *irc, char **cmd ) } } +#if 0 static void cmd_account( irc_t *irc, char **cmd ); static void cmd_identify( irc_t *irc, char **cmd ) @@ -1216,9 +1217,11 @@ static void cmd_transfer( irc_t *irc, char **cmd ) } } } +#endif const command_t commands[] = { { "help", 0, cmd_help, 0 }, +#if 0 { "identify", 1, cmd_identify, 0 }, { "register", 1, cmd_register, 0 }, { "drop", 1, cmd_drop, 0 }, @@ -1239,5 +1242,6 @@ const command_t commands[] = { { "join_chat", 2, cmd_join_chat, 0 }, { "chat", 1, cmd_chat, 0 }, { "transfer", 0, cmd_transfer, 0 }, +#endif { NULL } }; -- cgit v1.2.3 From d860a8ddf5039f7208bff4c179bc9fe1549da6da Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 31 Mar 2010 23:38:50 -0400 Subject: Restored "account" root command and restored enough stuff to be able to send messages. Also started moving stuff out from nogaim.* into bee_* files. --- root_commands.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 9b396379..75f3af81 100644 --- a/root_commands.c +++ b/root_commands.c @@ -220,6 +220,7 @@ static void cmd_drop( irc_t *irc, char **cmd ) break; } } +#endif struct cmd_account_del_data { @@ -232,7 +233,7 @@ 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 ); + for( a = cad->irc->b->accounts; a && a != cad->a; a = a->next ); if( a == NULL ) { @@ -244,7 +245,7 @@ void cmd_account_del_yes( void *data ) } else { - account_del( cad->irc, a ); + account_del( cad->irc->b, a ); irc_usermsg( cad->irc, "Account deleted" ); } g_free( data ); @@ -285,7 +286,7 @@ static int cmd_set_real( irc_t *irc, char **cmd, cmd_set_findhead findhead, cmd_ { set_name = set_full; - head = &irc->set; + head = &irc->b->set; } else { @@ -356,7 +357,7 @@ static set_t **cmd_account_set_findhead( irc_t *irc, char *id ) { account_t *a; - if( ( a = account_get( irc, id ) ) ) + if( ( a = account_get( irc->b, id ) ) ) return &a->set; else return NULL; @@ -404,7 +405,7 @@ static void cmd_account( irc_t *irc, char **cmd ) return; } - a = account_add( irc, prpl, cmd[3], cmd[4] ); + a = account_add( irc->b, prpl, cmd[3], cmd[4] ); if( cmd[5] ) { irc_usermsg( irc, "Warning: Passing a servername/other flags to `account add' " @@ -418,7 +419,7 @@ static void cmd_account( irc_t *irc, char **cmd ) { MIN_ARGS( 2 ); - if( !( a = account_get( irc, cmd[2] ) ) ) + if( !( a = account_get( irc->b, cmd[2] ) ) ) { irc_usermsg( irc, "Invalid account" ); } @@ -440,7 +441,7 @@ static void cmd_account( irc_t *irc, char **cmd ) "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, cad ); + //query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, cad ); g_free( msg ); } } @@ -451,7 +452,7 @@ static void cmd_account( irc_t *irc, char **cmd ) if( strchr( irc->umode, 'b' ) ) irc_usermsg( irc, "Account list:" ); - for( a = irc->accounts; a; a = a->next ) + for( a = irc->b->accounts; a; a = a->next ) { char *con; @@ -474,7 +475,7 @@ static void cmd_account( irc_t *irc, char **cmd ) { if( cmd[2] ) { - if( ( a = account_get( irc, cmd[2] ) ) ) + if( ( a = account_get( irc->b, cmd[2] ) ) ) { if( a->ic ) { @@ -483,7 +484,7 @@ static void cmd_account( irc_t *irc, char **cmd ) } else { - account_on( irc, a ); + account_on( irc->b, a ); } } else @@ -494,12 +495,13 @@ static void cmd_account( irc_t *irc, char **cmd ) } else { - if ( irc->accounts ) { + if ( irc->b->accounts ) + { irc_usermsg( irc, "Trying to get all accounts connected..." ); - for( a = irc->accounts; a; a = a->next ) + for( a = irc->b->accounts; a; a = a->next ) if( !a->ic && a->auto_connect ) - account_on( irc, a ); + account_on( irc->b, a ); } else { @@ -513,19 +515,19 @@ static void cmd_account( irc_t *irc, char **cmd ) { irc_usermsg( irc, "Deactivating all active (re)connections..." ); - for( a = irc->accounts; a; a = a->next ) + for( a = irc->b->accounts; a; a = a->next ) { if( a->ic ) - account_off( irc, a ); + account_off( irc->b, a ); else if( a->reconnect ) cancel_auto_reconnect( a ); } } - else if( ( a = account_get( irc, cmd[2] ) ) ) + else if( ( a = account_get( irc->b, cmd[2] ) ) ) { if( a->ic ) { - account_off( irc, a ); + account_off( irc->b, a ); } else if( a->reconnect ) { @@ -556,6 +558,7 @@ static void cmd_account( irc_t *irc, char **cmd ) } } +#if 0 static void cmd_add( irc_t *irc, char **cmd ) { account_t *a; @@ -1221,11 +1224,11 @@ static void cmd_transfer( irc_t *irc, char **cmd ) const command_t commands[] = { { "help", 0, cmd_help, 0 }, + { "account", 1, cmd_account, 0 }, #if 0 { "identify", 1, cmd_identify, 0 }, { "register", 1, cmd_register, 0 }, { "drop", 1, cmd_drop, 0 }, - { "account", 1, cmd_account, 0 }, { "add", 2, cmd_add, 0 }, { "info", 1, cmd_info, 0 }, { "rename", 2, cmd_rename, 0 }, -- cgit v1.2.3 From 57c96f7be2511a0a50015512dc03a30ba0923862 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 4 Apr 2010 21:00:02 -0400 Subject: Restored the rename command. --- root_commands.c | 54 +++++++++++++++++++++++------------------------------- 1 file changed, 23 insertions(+), 31 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 75f3af81..7e0b16d3 100644 --- a/root_commands.c +++ b/root_commands.c @@ -647,65 +647,55 @@ static void cmd_info( irc_t *irc, char **cmd ) ic->acc->prpl->get_info( ic, cmd[2] ); } } +#endif static void cmd_rename( irc_t *irc, char **cmd ) { - user_t *u; + irc_user_t *iu; - if( g_strcasecmp( cmd[1], irc->nick ) == 0 ) - { - irc_usermsg( irc, "Nick `%s' can't be changed", cmd[1] ); - } - else if( g_strcasecmp( cmd[1], irc->channel ) == 0 ) + iu = irc_user_by_name( irc, cmd[1] ); + + if( iu == NULL ) { - if( strchr( CTYPES, cmd[2][0] ) && nick_ok( cmd[2] + 1 ) ) - { - u = user_find( irc, irc->nick ); - - irc_part( irc, u, irc->channel ); - g_free( irc->channel ); - irc->channel = g_strdup( cmd[2] ); - irc_join( irc, u, irc->channel ); - - if( strcmp( cmd[0], "set_rename" ) != 0 ) - set_setstr( &irc->set, "control_channel", cmd[2] ); - } + irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); } - else if( user_find( irc, cmd[2] ) && ( nick_cmp( cmd[1], cmd[2] ) != 0 ) ) + else if( iu == irc->user ) { - irc_usermsg( irc, "Nick `%s' already exists", cmd[2] ); + irc_usermsg( irc, "Nick `%s' can't be changed", cmd[1] ); } else if( !nick_ok( cmd[2] ) ) { irc_usermsg( irc, "Nick `%s' is invalid", cmd[2] ); } - else if( !( u = user_find( irc, cmd[1] ) ) ) + else if( irc_user_by_name( irc, cmd[2] ) ) { - irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); + irc_usermsg( irc, "Nick `%s' already exists", cmd[2] ); } else { - user_rename( irc, cmd[1], cmd[2] ); - irc_write( irc, ":%s!%s@%s NICK %s", cmd[1], u->user, u->host, cmd[2] ); - if( g_strcasecmp( cmd[1], irc->mynick ) == 0 ) + if( !irc_user_set_nick( iu, cmd[2] ) ) + { + irc_usermsg( irc, "Error while changing nick" ); + return; + } + + if( iu == irc->root ) { - g_free( irc->mynick ); - irc->mynick = g_strdup( cmd[2] ); - /* If we're called internally (user did "set root_nick"), let's not go O(INF). :-) */ if( strcmp( cmd[0], "set_rename" ) != 0 ) - set_setstr( &irc->set, "root_nick", cmd[2] ); + set_setstr( &irc->b->set, "root_nick", cmd[2] ); } - else if( u->send_handler == buddy_send_handler ) + else if( iu->bu ) { - nick_set( u->ic->acc, u->handle, cmd[2] ); + nick_set( iu->bu->ic->acc, iu->bu->handle, cmd[2] ); } irc_usermsg( irc, "Nick successfully changed" ); } } +#if 0 char *set_eval_root_nick( set_t *set, char *new_nick ) { irc_t *irc = set->data; @@ -1231,7 +1221,9 @@ const command_t commands[] = { { "drop", 1, cmd_drop, 0 }, { "add", 2, cmd_add, 0 }, { "info", 1, cmd_info, 0 }, +#endif { "rename", 2, cmd_rename, 0 }, +#if 0 { "remove", 1, cmd_remove, 0 }, { "block", 1, cmd_block, 0 }, { "allow", 1, cmd_allow, 0 }, -- cgit v1.2.3 From 1f92a5851e0e3b1730e940980f2b0122c506c724 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 10 Apr 2010 03:27:50 +0100 Subject: Restore the storage module. --- root_commands.c | 66 +++++++++++++-------------------------------------------- 1 file changed, 15 insertions(+), 51 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 7e0b16d3..73670d3a 100644 --- a/root_commands.c +++ b/root_commands.c @@ -135,7 +135,6 @@ static void cmd_help( irc_t *irc, char **cmd ) } } -#if 0 static void cmd_account( irc_t *irc, char **cmd ); static void cmd_identify( irc_t *irc, char **cmd ) @@ -161,7 +160,7 @@ static void cmd_identify( irc_t *irc, char **cmd ) irc_setpass( irc, cmd[1] ); irc->status |= USTATUS_IDENTIFIED; irc_umode_set( irc, "+R", 1 ); - if( set_getbool( &irc->set, "auto_connect" ) ) + if( set_getbool( &irc->b->set, "auto_connect" ) ) cmd_account( irc, account_on ); break; case STORAGE_OTHER_ERROR: @@ -201,7 +200,7 @@ static void cmd_drop( irc_t *irc, char **cmd ) { storage_status_t status; - status = storage_remove (irc->nick, cmd[1]); + status = storage_remove (irc->user->nick, cmd[1]); switch (status) { case STORAGE_NO_SUCH_USER: irc_usermsg( irc, "That account does not exist" ); @@ -213,14 +212,23 @@ static void cmd_drop( irc_t *irc, char **cmd ) irc_setpass( irc, NULL ); irc->status &= ~USTATUS_IDENTIFIED; irc_umode_set( irc, "-R", 1 ); - irc_usermsg( irc, "Account `%s' removed", irc->nick ); + irc_usermsg( irc, "Account `%s' removed", irc->user->nick ); break; default: irc_usermsg( irc, "Error: `%d'", status ); break; } } -#endif + +static void cmd_save( irc_t *irc, char **cmd ) +{ + if( ( irc->status & USTATUS_IDENTIFIED ) == 0 ) + irc_usermsg( irc, "Please create an account first" ); + else if( storage_save( irc, NULL, TRUE ) == STORAGE_OK ) + irc_usermsg( irc, "Configuration saved" ); + else + irc_usermsg( irc, "Configuration could not be saved!" ); +} struct cmd_account_del_data { @@ -908,16 +916,6 @@ static void cmd_set( irc_t *irc, char **cmd ) cmd_set_real( irc, cmd, NULL, NULL ); } -static void cmd_save( irc_t *irc, char **cmd ) -{ - if( ( irc->status & USTATUS_IDENTIFIED ) == 0 ) - irc_usermsg( irc, "Please create an account first" ); - else if( storage_save( irc, NULL, TRUE ) == STORAGE_OK ) - irc_usermsg( irc, "Configuration saved" ); - else - irc_usermsg( irc, "Configuration could not be saved!" ); -} - static void cmd_blist( irc_t *irc, char **cmd ) { int online = 0, away = 0, offline = 0; @@ -983,34 +981,6 @@ static void cmd_blist( irc_t *irc, char **cmd ) irc_usermsg( irc, "%d buddies (%d available, %d away, %d offline)", n_online + n_away + n_offline, n_online, n_away, n_offline ); } -static void cmd_nick( irc_t *irc, char **cmd ) -{ - account_t *a; - - if( !cmd[1] || !( a = account_get( irc, cmd[1] ) ) ) - { - irc_usermsg( irc, "Invalid account"); - } - 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->ic->displayname ? a->ic->displayname : "NULL" ); - } - else if ( !a->prpl->set_my_name ) - { - irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); - } - else - { - irc_usermsg( irc, "Setting your name to `%s'", cmd[2] ); - - a->prpl->set_my_name( a->ic, cmd[2] ); - } -} - static void cmd_qlist( irc_t *irc, char **cmd ) { query_t *q = irc->queries; @@ -1031,12 +1001,6 @@ 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 ) -{ - irc_usermsg( irc, "This command is now obsolete. " - "Please try the `chat' command instead." ); -} - static set_t **cmd_chat_set_findhead( irc_t *irc, char *id ) { struct chat *c; @@ -1215,10 +1179,11 @@ static void cmd_transfer( irc_t *irc, char **cmd ) const command_t commands[] = { { "help", 0, cmd_help, 0 }, { "account", 1, cmd_account, 0 }, -#if 0 { "identify", 1, cmd_identify, 0 }, { "register", 1, cmd_register, 0 }, { "drop", 1, cmd_drop, 0 }, + { "save", 0, cmd_save, 0 }, +#if 0 { "add", 2, cmd_add, 0 }, { "info", 1, cmd_info, 0 }, #endif @@ -1227,7 +1192,6 @@ const command_t commands[] = { { "remove", 1, cmd_remove, 0 }, { "block", 1, cmd_block, 0 }, { "allow", 1, cmd_allow, 0 }, - { "save", 0, cmd_save, 0 }, { "set", 0, cmd_set, 0 }, { "yes", 0, cmd_yesno, 0 }, { "no", 0, cmd_yesno, 0 }, -- cgit v1.2.3 From dbb0ce32e607dbcd6c5ad4d5ab309e969afd6fd4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 11 Apr 2010 21:38:45 +0200 Subject: Restored add/remove command and, oh, yes/no commands. Nice to be able to answer the questions.. --- root_commands.c | 66 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 31 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 73670d3a..7f3a6599 100644 --- a/root_commands.c +++ b/root_commands.c @@ -566,7 +566,6 @@ static void cmd_account( irc_t *irc, char **cmd ) } } -#if 0 static void cmd_add( irc_t *irc, char **cmd ) { account_t *a; @@ -579,7 +578,7 @@ static void cmd_add( irc_t *irc, char **cmd ) cmd ++; } - if( !( a = account_get( irc, cmd[1] ) ) ) + if( !( a = account_get( irc->b, cmd[1] ) ) ) { irc_usermsg( irc, "Invalid account" ); return; @@ -597,7 +596,7 @@ static void cmd_add( irc_t *irc, char **cmd ) irc_usermsg( irc, "The requested nick `%s' is invalid", cmd[3] ); return; } - else if( user_find( irc, cmd[3] ) ) + else if( irc_user_by_name( irc, cmd[3] ) ) { irc_usermsg( irc, "The requested nick `%s' already exists", cmd[3] ); return; @@ -611,14 +610,37 @@ static void cmd_add( irc_t *irc, char **cmd ) if( add_on_server ) a->ic->acc->prpl->add_buddy( a->ic, cmd[2], NULL ); 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 ); + /* Only for add -tmp. For regular adds, this callback will + be called once the IM server confirms. */ + bee_user_new( irc->b, a->ic, cmd[2] ); irc_usermsg( irc, "Adding `%s' to your contact list", cmd[2] ); } +static void cmd_remove( irc_t *irc, char **cmd ) +{ + irc_user_t *iu; + bee_user_t *bu; + char *s; + + if( !( iu = irc_user_by_name( irc, cmd[1] ) ) || !( bu = iu->bu ) ) + { + irc_usermsg( irc, "Buddy `%s' not found", cmd[1] ); + return; + } + s = g_strdup( bu->handle ); + + bu->ic->acc->prpl->remove_buddy( bu->ic, bu->handle, NULL ); + nick_del( bu->ic->acc, bu->handle ); + irc_user_free( irc, cmd[1] ); + + irc_usermsg( irc, "Buddy `%s' (nick %s) removed from contact list", s, cmd[1] ); + g_free( s ); + + return; +} + +#if 0 static void cmd_info( irc_t *irc, char **cmd ) { struct im_connection *ic; @@ -732,28 +754,6 @@ char *set_eval_control_channel( set_t *set, char *new_name ) return strcmp( irc->channel, new_name ) == 0 ? new_name : SET_INVALID; } -static void cmd_remove( irc_t *irc, char **cmd ) -{ - user_t *u; - char *s; - - 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->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] ); - g_free( s ); - - return; -} - static void cmd_block( irc_t *irc, char **cmd ) { struct im_connection *ic; @@ -872,6 +872,7 @@ static void cmd_allow( irc_t *irc, char **cmd ) irc_usermsg( irc, "Buddy `%s' moved from your block- to your allow-list", cmd[2] ); } } +#endif static void cmd_yesno( irc_t *irc, char **cmd ) { @@ -916,6 +917,7 @@ static void cmd_set( irc_t *irc, char **cmd ) cmd_set_real( irc, cmd, NULL, NULL ); } +#if 0 static void cmd_blist( irc_t *irc, char **cmd ) { int online = 0, away = 0, offline = 0; @@ -1183,18 +1185,20 @@ const command_t commands[] = { { "register", 1, cmd_register, 0 }, { "drop", 1, cmd_drop, 0 }, { "save", 0, cmd_save, 0 }, -#if 0 { "add", 2, cmd_add, 0 }, + { "remove", 1, cmd_remove, 0 }, +#if 0 { "info", 1, cmd_info, 0 }, #endif { "rename", 2, cmd_rename, 0 }, #if 0 - { "remove", 1, cmd_remove, 0 }, { "block", 1, cmd_block, 0 }, { "allow", 1, cmd_allow, 0 }, +#endif { "set", 0, cmd_set, 0 }, { "yes", 0, cmd_yesno, 0 }, { "no", 0, cmd_yesno, 0 }, +#if 0 { "blist", 0, cmd_blist, 0 }, { "nick", 1, cmd_nick, 0 }, { "qlist", 0, cmd_qlist, 0 }, -- cgit v1.2.3 From eabc9d2c1b1d29aeb47162da64ce2b607c3d43ff Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 12 Apr 2010 00:49:32 +0200 Subject: Fixed cleanup issues when turning off an account. Also fixed syntax of *_user_free(). --- 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 7f3a6599..e5a5b41d 100644 --- a/root_commands.c +++ b/root_commands.c @@ -632,7 +632,7 @@ static void cmd_remove( irc_t *irc, char **cmd ) bu->ic->acc->prpl->remove_buddy( bu->ic, bu->handle, NULL ); nick_del( bu->ic->acc, bu->handle ); - irc_user_free( irc, cmd[1] ); + //TODO(wilmer): bee_user_free() and/or let the IM mod do it? irc_user_free( irc, cmd[1] ); irc_usermsg( irc, "Buddy `%s' (nick %s) removed from contact list", s, cmd[1] ); g_free( s ); -- cgit v1.2.3 From 6c56f426fb2823ea6b41d1c9028448b7f8d5db09 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 12 Apr 2010 01:04:24 +0200 Subject: Allow short versions of root commands (just give enough to match exactly one command), for the lazy users. --- root_commands.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index e5a5b41d..60aa3bf6 100644 --- a/root_commands.c +++ b/root_commands.c @@ -91,14 +91,20 @@ void root_command_string( irc_t *irc, char *command ) void root_command( irc_t *irc, char *cmd[] ) { - int i; + int i, len; if( !cmd[0] ) return; + len = strlen( cmd[0] ); for( i = 0; commands[i].command; i++ ) - if( g_strcasecmp( commands[i].command, cmd[0] ) == 0 ) + if( g_strncasecmp( commands[i].command, cmd[0], len ) == 0 ) { + if( commands[i+1].command && + g_strncasecmp( commands[i+1].command, cmd[0], len ) == 0 ) + /* Only match on the first letters if the match is unique. */ + break; + MIN_ARGS( commands[i].required_parameters ); commands[i].execute( irc, cmd ); @@ -1178,32 +1184,30 @@ static void cmd_transfer( irc_t *irc, char **cmd ) } #endif +/* IMPORTANT: Keep this list sorted! The short command logic needs that. */ const command_t commands[] = { - { "help", 0, cmd_help, 0 }, { "account", 1, cmd_account, 0 }, + { "add", 2, cmd_add, 0 }, + { "drop", 1, cmd_drop, 0 }, + { "help", 0, cmd_help, 0 }, { "identify", 1, cmd_identify, 0 }, + { "no", 0, cmd_yesno, 0 }, { "register", 1, cmd_register, 0 }, - { "drop", 1, cmd_drop, 0 }, - { "save", 0, cmd_save, 0 }, - { "add", 2, cmd_add, 0 }, { "remove", 1, cmd_remove, 0 }, -#if 0 - { "info", 1, cmd_info, 0 }, -#endif { "rename", 2, cmd_rename, 0 }, -#if 0 - { "block", 1, cmd_block, 0 }, - { "allow", 1, cmd_allow, 0 }, -#endif + { "save", 0, cmd_save, 0 }, { "set", 0, cmd_set, 0 }, { "yes", 0, cmd_yesno, 0 }, - { "no", 0, cmd_yesno, 0 }, #if 0 + { "allow", 1, cmd_allow, 0 }, { "blist", 0, cmd_blist, 0 }, + { "block", 1, cmd_block, 0 }, + { "chat", 1, cmd_chat, 0 }, + { "ft", 0, cmd_transfer, 0 }, + { "info", 1, cmd_info, 0 }, + { "join_chat", 2, cmd_join_chat, 0 }, { "nick", 1, cmd_nick, 0 }, { "qlist", 0, cmd_qlist, 0 }, - { "join_chat", 2, cmd_join_chat, 0 }, - { "chat", 1, cmd_chat, 0 }, { "transfer", 0, cmd_transfer, 0 }, #endif { NULL } -- cgit v1.2.3 From aa44bddd276f047edd39fdb3eadc9b1e87f0014f Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 12 Apr 2010 01:18:03 +0200 Subject: Restored info command. --- root_commands.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 60aa3bf6..3853a73e 100644 --- a/root_commands.c +++ b/root_commands.c @@ -646,7 +646,6 @@ static void cmd_remove( irc_t *irc, char **cmd ) return; } -#if 0 static void cmd_info( irc_t *irc, char **cmd ) { struct im_connection *ic; @@ -654,16 +653,16 @@ static void cmd_info( irc_t *irc, char **cmd ) if( !cmd[2] ) { - user_t *u = user_find( irc, cmd[1] ); - if( !u || !u->ic ) + irc_user_t *iu = irc_user_by_name( irc, cmd[1] ); + if( !iu || !iu->bu ) { irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); return; } - ic = u->ic; - cmd[2] = u->handle; + ic = iu->bu->ic; + cmd[2] = iu->bu->handle; } - else if( !( a = account_get( irc, cmd[1] ) ) ) + else if( !( a = account_get( irc->b, cmd[1] ) ) ) { irc_usermsg( irc, "Invalid account" ); return; @@ -683,7 +682,6 @@ static void cmd_info( irc_t *irc, char **cmd ) ic->acc->prpl->get_info( ic, cmd[2] ); } } -#endif static void cmd_rename( irc_t *irc, char **cmd ) { @@ -1191,6 +1189,7 @@ const command_t commands[] = { { "drop", 1, cmd_drop, 0 }, { "help", 0, cmd_help, 0 }, { "identify", 1, cmd_identify, 0 }, + { "info", 1, cmd_info, 0 }, { "no", 0, cmd_yesno, 0 }, { "register", 1, cmd_register, 0 }, { "remove", 1, cmd_remove, 0 }, @@ -1204,9 +1203,7 @@ const command_t commands[] = { { "block", 1, cmd_block, 0 }, { "chat", 1, cmd_chat, 0 }, { "ft", 0, cmd_transfer, 0 }, - { "info", 1, cmd_info, 0 }, { "join_chat", 2, cmd_join_chat, 0 }, - { "nick", 1, cmd_nick, 0 }, { "qlist", 0, cmd_qlist, 0 }, { "transfer", 0, cmd_transfer, 0 }, #endif -- cgit v1.2.3 From 24b8bbb2616d685006a279e46a4bd2e8e7cf6694 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 12 Apr 2010 02:06:49 +0200 Subject: Start handling CTCPs, in a saner way than before. --- root_commands.c | 43 +------------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 3853a73e..7a4c021e 100644 --- a/root_commands.c +++ b/root_commands.c @@ -33,48 +33,7 @@ void root_command_string( irc_t *irc, char *command ) { - char *cmd[IRC_MAX_ARGS]; - char *s; - int k; - char q = 0; - - memset( cmd, 0, sizeof( cmd ) ); - cmd[0] = command; - k = 1; - for( s = command; *s && k < ( IRC_MAX_ARGS - 1 ); s ++ ) - if( *s == ' ' && !q ) - { - *s = 0; - while( *++s == ' ' ); - if( *s == '"' || *s == '\'' ) - { - q = *s; - s ++; - } - if( *s ) - { - cmd[k++] = s; - s --; - } - else - { - break; - } - } - else if( *s == '\\' && ( ( !q && s[1] ) || ( q && q == s[1] ) ) ) - { - char *cpy; - - for( cpy = s; *cpy; cpy ++ ) - cpy[0] = cpy[1]; - } - else if( *s == q ) - { - q = *s = 0; - } - cmd[k] = NULL; - - root_command( irc, cmd ); + root_command( irc, split_command_parts( command ) ); } #define MIN_ARGS( x, y... ) \ -- cgit v1.2.3 From 4c3519a8e9f8733577b0ca060a80606955f92cce Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 15 Apr 2010 00:45:09 +0200 Subject: Restored blist command. --- root_commands.c | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 7a4c021e..3dbf8bcd 100644 --- a/root_commands.c +++ b/root_commands.c @@ -880,11 +880,10 @@ static void cmd_set( irc_t *irc, char **cmd ) cmd_set_real( irc, cmd, NULL, NULL ); } -#if 0 static void cmd_blist( irc_t *irc, char **cmd ) { int online = 0, away = 0, offline = 0; - user_t *u; + GSList *l; char s[256]; char *format; int n_online = 0, n_away = 0, n_offline = 0; @@ -905,40 +904,58 @@ static void cmd_blist( irc_t *irc, char **cmd ) else format = "%-16.16s %-40.40s %s"; - irc_usermsg( irc, format, "Nick", "User/Host/Network", "Status" ); + irc_usermsg( irc, format, "Nick", "Handle/Account", "Status" ); - for( u = irc->users; u; u = u->next ) if( u->ic && u->online && !u->away ) + for( l = irc->users; l; l = l->next ) { + irc_user_t *iu = l->data; + bee_user_t *bu = iu->bu; + + if( !bu || ( bu->flags & ( BEE_USER_ONLINE | BEE_USER_AWAY ) ) != BEE_USER_ONLINE ) + continue; + if( online == 1 ) { char st[256] = "Online"; - if( u->status_msg ) - g_snprintf( st, sizeof( st ) - 1, "Online (%s)", u->status_msg ); + if( bu->status_msg ) + g_snprintf( st, sizeof( st ) - 1, "Online (%s)", bu->status_msg ); - 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, st ); + g_snprintf( s, sizeof( s ) - 1, "%s %s(%s)", bu->handle, bu->ic->acc->prpl->name, bu->ic->acc->user ); + irc_usermsg( irc, format, iu->nick, s, st ); } n_online ++; } - for( u = irc->users; u; u = u->next ) if( u->ic && u->online && u->away ) + for( l = irc->users; l; l = l->next ) { + irc_user_t *iu = l->data; + bee_user_t *bu = iu->bu; + + if( !bu || !( bu->flags & BEE_USER_ONLINE ) || !( bu->flags & BEE_USER_AWAY ) ) + continue; + if( away == 1 ) { - 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 ); + g_snprintf( s, sizeof( s ) - 1, "%s %s(%s)", bu->handle, bu->ic->acc->prpl->name, bu->ic->acc->user ); + irc_usermsg( irc, format, iu->nick, s, irc_user_get_away( iu ) ); } n_away ++; } - for( u = irc->users; u; u = u->next ) if( u->ic && !u->online ) + for( l = irc->users; l; l = l->next ) { + irc_user_t *iu = l->data; + bee_user_t *bu = iu->bu; + + if( !bu || bu->flags & BEE_USER_ONLINE ) + continue; + if( offline == 1 ) { - 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" ); + g_snprintf( s, sizeof( s ) - 1, "%s %s(%s)", bu->handle, bu->ic->acc->prpl->name, bu->ic->acc->user ); + irc_usermsg( irc, format, iu->nick, s, "Offline" ); } n_offline ++; } @@ -946,6 +963,7 @@ static void cmd_blist( irc_t *irc, char **cmd ) irc_usermsg( irc, "%d buddies (%d available, %d away, %d offline)", n_online + n_away + n_offline, n_online, n_away, n_offline ); } +#if 0 static void cmd_qlist( irc_t *irc, char **cmd ) { query_t *q = irc->queries; @@ -1145,6 +1163,7 @@ static void cmd_transfer( irc_t *irc, char **cmd ) const command_t commands[] = { { "account", 1, cmd_account, 0 }, { "add", 2, cmd_add, 0 }, + { "blist", 0, cmd_blist, 0 }, { "drop", 1, cmd_drop, 0 }, { "help", 0, cmd_help, 0 }, { "identify", 1, cmd_identify, 0 }, @@ -1158,11 +1177,9 @@ const command_t commands[] = { { "yes", 0, cmd_yesno, 0 }, #if 0 { "allow", 1, cmd_allow, 0 }, - { "blist", 0, cmd_blist, 0 }, { "block", 1, cmd_block, 0 }, { "chat", 1, cmd_chat, 0 }, { "ft", 0, cmd_transfer, 0 }, - { "join_chat", 2, cmd_join_chat, 0 }, { "qlist", 0, cmd_qlist, 0 }, { "transfer", 0, cmd_transfer, 0 }, #endif -- cgit v1.2.3 From 9d4352c51300548b4a053dab85517f0dd0cb386c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 21 Apr 2010 01:03:01 +0200 Subject: Restored a few more root commands. --- root_commands.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 3dbf8bcd..7f835cd8 100644 --- a/root_commands.c +++ b/root_commands.c @@ -963,7 +963,6 @@ static void cmd_blist( irc_t *irc, char **cmd ) irc_usermsg( irc, "%d buddies (%d available, %d away, %d offline)", n_online + n_away + n_offline, n_online, n_away, n_offline ); } -#if 0 static void cmd_qlist( irc_t *irc, char **cmd ) { query_t *q = irc->queries; @@ -984,6 +983,7 @@ static void cmd_qlist( irc_t *irc, char **cmd ) irc_usermsg( irc, "%d, BitlBee: %s", num, q->question ); } +#if 0 static set_t **cmd_chat_set_findhead( irc_t *irc, char *id ) { struct chat *c; @@ -1095,6 +1095,7 @@ static void cmd_chat( irc_t *irc, char **cmd ) irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "chat", cmd[1] ); } } +#endif static void cmd_transfer( irc_t *irc, char **cmd ) { @@ -1144,20 +1145,19 @@ static void cmd_transfer( irc_t *irc, char **cmd ) if( file->status == FT_STATUS_LISTENING ) { irc_usermsg( irc, "Rejecting file transfer for %s", file->file_name ); - imcb_file_canceled( file, "Denied by user" ); + imcb_file_canceled( file->ic, file, "Denied by user" ); } break; case CANCEL: if( file->local_id == fid ) { irc_usermsg( irc, "Canceling file transfer for %s", file->file_name ); - imcb_file_canceled( file, "Canceled by user" ); + imcb_file_canceled( file->ic, file, "Canceled by user" ); } break; } } } -#endif /* IMPORTANT: Keep this list sorted! The short command logic needs that. */ const command_t commands[] = { @@ -1165,23 +1165,23 @@ const command_t commands[] = { { "add", 2, cmd_add, 0 }, { "blist", 0, cmd_blist, 0 }, { "drop", 1, cmd_drop, 0 }, + { "ft", 0, cmd_transfer, 0 }, { "help", 0, cmd_help, 0 }, { "identify", 1, cmd_identify, 0 }, { "info", 1, cmd_info, 0 }, { "no", 0, cmd_yesno, 0 }, + { "qlist", 0, cmd_qlist, 0 }, { "register", 1, cmd_register, 0 }, { "remove", 1, cmd_remove, 0 }, { "rename", 2, cmd_rename, 0 }, { "save", 0, cmd_save, 0 }, { "set", 0, cmd_set, 0 }, + { "transfer", 0, cmd_transfer, 0 }, { "yes", 0, cmd_yesno, 0 }, #if 0 { "allow", 1, cmd_allow, 0 }, { "block", 1, cmd_block, 0 }, { "chat", 1, cmd_chat, 0 }, - { "ft", 0, cmd_transfer, 0 }, - { "qlist", 0, cmd_qlist, 0 }, - { "transfer", 0, cmd_transfer, 0 }, #endif { NULL } }; -- cgit v1.2.3 From 2272cb30851366324e844681b97c383c655ccc33 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 21 Apr 2010 01:11:32 +0200 Subject: Restored block/allow commands. Only "chat" is left now, which will need some more rethinking anyway (and groupchat support is not back yet anyway). --- root_commands.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 7f835cd8..d5da0691 100644 --- a/root_commands.c +++ b/root_commands.c @@ -716,13 +716,14 @@ char *set_eval_control_channel( set_t *set, char *new_name ) return strcmp( irc->channel, new_name ) == 0 ? new_name : SET_INVALID; } +#endif static void cmd_block( irc_t *irc, char **cmd ) { struct im_connection *ic; account_t *a; - if( !cmd[2] && ( a = account_get( irc, cmd[1] ) ) && a->ic ) + if( !cmd[2] && ( a = account_get( irc->b, cmd[1] ) ) && a->ic ) { char *format; GSList *l; @@ -735,8 +736,9 @@ static void cmd_block( irc_t *irc, char **cmd ) irc_usermsg( irc, format, "Handle", "Nickname" ); for( l = a->ic->deny; l; l = l->next ) { - user_t *u = user_findhandle( a->ic, l->data ); - irc_usermsg( irc, format, l->data, u ? u->nick : "(none)" ); + bee_user_t *bu = bee_user_by_handle( irc->b, a->ic, l->data ); + irc_user_t *iu = bu ? bu->ui_data : NULL; + irc_usermsg( irc, format, l->data, iu ? iu->nick : "(none)" ); } irc_usermsg( irc, "End of list." ); @@ -744,16 +746,16 @@ static void cmd_block( irc_t *irc, char **cmd ) } else if( !cmd[2] ) { - user_t *u = user_find( irc, cmd[1] ); - if( !u || !u->ic ) + irc_user_t *iu = irc_user_by_name( irc, cmd[1] ); + if( !iu || !iu->bu ) { irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); return; } - ic = u->ic; - cmd[2] = u->handle; + ic = iu->bu->ic; + cmd[2] = iu->bu->handle; } - else if( !( a = account_get( irc, cmd[1] ) ) ) + else if( !( a = account_get( irc->b, cmd[1] ) ) ) { irc_usermsg( irc, "Invalid account" ); return; @@ -781,7 +783,7 @@ static void cmd_allow( irc_t *irc, char **cmd ) struct im_connection *ic; account_t *a; - if( !cmd[2] && ( a = account_get( irc, cmd[1] ) ) && a->ic ) + if( !cmd[2] && ( a = account_get( irc->b, cmd[1] ) ) && a->ic ) { char *format; GSList *l; @@ -794,8 +796,9 @@ static void cmd_allow( irc_t *irc, char **cmd ) irc_usermsg( irc, format, "Handle", "Nickname" ); for( l = a->ic->permit; l; l = l->next ) { - user_t *u = user_findhandle( a->ic, l->data ); - irc_usermsg( irc, format, l->data, u ? u->nick : "(none)" ); + bee_user_t *bu = bee_user_by_handle( irc->b, a->ic, l->data ); + irc_user_t *iu = bu ? bu->ui_data : NULL; + irc_usermsg( irc, format, l->data, iu ? iu->nick : "(none)" ); } irc_usermsg( irc, "End of list." ); @@ -803,16 +806,16 @@ static void cmd_allow( irc_t *irc, char **cmd ) } else if( !cmd[2] ) { - user_t *u = user_find( irc, cmd[1] ); - if( !u || !u->ic ) + irc_user_t *iu = irc_user_by_name( irc, cmd[1] ); + if( !iu || !iu->bu ) { irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); return; } - ic = u->ic; - cmd[2] = u->handle; + ic = iu->bu->ic; + cmd[2] = iu->bu->handle; } - else if( !( a = account_get( irc, cmd[1] ) ) ) + else if( !( a = account_get( irc->b, cmd[1] ) ) ) { irc_usermsg( irc, "Invalid account" ); return; @@ -835,7 +838,6 @@ static void cmd_allow( irc_t *irc, char **cmd ) irc_usermsg( irc, "Buddy `%s' moved from your block- to your allow-list", cmd[2] ); } } -#endif static void cmd_yesno( irc_t *irc, char **cmd ) { @@ -1163,7 +1165,9 @@ static void cmd_transfer( irc_t *irc, char **cmd ) const command_t commands[] = { { "account", 1, cmd_account, 0 }, { "add", 2, cmd_add, 0 }, + { "allow", 1, cmd_allow, 0 }, { "blist", 0, cmd_blist, 0 }, + { "block", 1, cmd_block, 0 }, { "drop", 1, cmd_drop, 0 }, { "ft", 0, cmd_transfer, 0 }, { "help", 0, cmd_help, 0 }, @@ -1179,8 +1183,6 @@ const command_t commands[] = { { "transfer", 0, cmd_transfer, 0 }, { "yes", 0, cmd_yesno, 0 }, #if 0 - { "allow", 1, cmd_allow, 0 }, - { "block", 1, cmd_block, 0 }, { "chat", 1, cmd_chat, 0 }, #endif { NULL } -- cgit v1.2.3 From 6fd4d46eb854902391549de95774260a94ae7072 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 13 May 2010 01:22:28 +0100 Subject: Restore "account del". --- root_commands.c | 50 ++------------------------------------------------ 1 file changed, 2 insertions(+), 48 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index d5da0691..bbf888c1 100644 --- a/root_commands.c +++ b/root_commands.c @@ -195,40 +195,6 @@ static void cmd_save( irc_t *irc, char **cmd ) irc_usermsg( irc, "Configuration could not be saved!" ); } -struct cmd_account_del_data -{ - 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->b->accounts; a && a != cad->a; a = a->next ); - - if( a == NULL ) - { - 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( cad->irc->b, a ); - irc_usermsg( cad->irc, "Account deleted" ); - } - g_free( data ); -} - -void cmd_account_del_no( void *data ) -{ - g_free( data ); -} - static void cmd_showset( irc_t *irc, set_t **head, char *key ) { char *val; @@ -402,20 +368,8 @@ 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, cad ); - g_free( msg ); + account_del( irc->b, a ); + irc_usermsg( irc, "Account deleted" ); } } else if( g_strcasecmp( cmd[1], "list" ) == 0 ) -- cgit v1.2.3 From ad404ab26aa3cfdfc3c76f6926e556e333d02753 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 3 Jun 2010 01:20:53 +0100 Subject: Restore add_* handle_unknown settings. --- 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 bbf888c1..aeb4f62a 100644 --- a/root_commands.c +++ b/root_commands.c @@ -531,7 +531,7 @@ static void cmd_add( irc_t *irc, char **cmd ) else /* Only for add -tmp. For regular adds, this callback will be called once the IM server confirms. */ - bee_user_new( irc->b, a->ic, cmd[2] ); + bee_user_new( irc->b, a->ic, cmd[2], BEE_USER_LOCAL ); irc_usermsg( irc, "Adding `%s' to your contact list", cmd[2] ); } -- cgit v1.2.3 From 7b71feb6f88b7e14199b8f7e9930f76d5324e356 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 14 May 2010 00:34:38 +0100 Subject: Just enough code to join named chatrooms again. This UI is *not* final, the "chat" command will probably mostly stick around for bw compatibility. Still thinking about how this should work eventually. --- root_commands.c | 64 +++++++++------------------------------------------------ 1 file changed, 10 insertions(+), 54 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index aeb4f62a..65f3de9a 100644 --- a/root_commands.c +++ b/root_commands.c @@ -939,17 +939,6 @@ static void cmd_qlist( irc_t *irc, char **cmd ) irc_usermsg( irc, "%d, BitlBee: %s", num, q->question ); } -#if 0 -static set_t **cmd_chat_set_findhead( irc_t *irc, char *id ) -{ - struct chat *c; - - if( ( c = chat_get( irc, id ) ) ) - return &c->set; - else - return NULL; -} - static void cmd_chat( irc_t *irc, char **cmd ) { account_t *acc; @@ -958,10 +947,11 @@ static void cmd_chat( irc_t *irc, char **cmd ) if( g_strcasecmp( cmd[1], "add" ) == 0 ) { char *channel, *s; + struct irc_channel *ic; MIN_ARGS( 3 ); - if( !( acc = account_get( irc, cmd[2] ) ) ) + if( !( acc = account_get( irc->b, cmd[2] ) ) ) { irc_usermsg( irc, "Invalid account" ); return; @@ -980,53 +970,21 @@ static void cmd_chat( irc_t *irc, char **cmd ) if( strchr( CTYPES, channel[0] ) == NULL ) { - s = g_strdup_printf( "%c%s", CTYPES[0], channel ); + s = g_strdup_printf( "#%s", channel ); g_free( channel ); channel = s; } - if( ( c = chat_add( irc, acc, cmd[3], channel ) ) ) - irc_usermsg( irc, "Chatroom added successfully." ); - else - irc_usermsg( irc, "Could not add chatroom." ); - - g_free( channel ); - } - else if( g_strcasecmp( cmd[1], "list" ) == 0 ) - { - int i = 0; - - if( strchr( irc->umode, 'b' ) ) - irc_usermsg( irc, "Chatroom list:" ); - - for( c = irc->chatrooms; c; c = c->next ) + if( ( ic = irc_channel_new( irc, channel ) ) ) { - irc_usermsg( irc, "%2d. %s(%s) %s, %s", i, c->acc->prpl->name, - c->acc->user, c->handle, c->channel ); + struct irc_groupchat_stub *igs; - i ++; - } - irc_usermsg( irc, "End of chatroom list" ); - } - else if( g_strcasecmp( cmd[1], "set" ) == 0 ) - { - MIN_ARGS( 2 ); - - cmd_set_real( irc, cmd + 1, cmd_chat_set_findhead, NULL ); - } - else if( g_strcasecmp( cmd[1], "del" ) == 0 ) - { - MIN_ARGS( 2 ); - - if( ( c = chat_get( irc, cmd[2] ) ) ) - { - chat_del( irc, c ); - } - else - { - irc_usermsg( irc, "Could not remove chat." ); + ic->data = igs = g_new0( struct irc_groupchat_stub, 1 ); + igs->acc = acc; + igs->room = g_strdup( cmd[3] ); } } + /* else if( g_strcasecmp( cmd[1], "with" ) == 0 ) { user_t *u; @@ -1046,12 +1004,12 @@ static void cmd_chat( irc_t *irc, char **cmd ) irc_usermsg( irc, "Can't open a groupchat with %s.", cmd[2] ); } } + */ else { irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "chat", cmd[1] ); } } -#endif static void cmd_transfer( irc_t *irc, char **cmd ) { @@ -1136,8 +1094,6 @@ const command_t commands[] = { { "set", 0, cmd_set, 0 }, { "transfer", 0, cmd_transfer, 0 }, { "yes", 0, cmd_yesno, 0 }, -#if 0 { "chat", 1, cmd_chat, 0 }, -#endif { NULL } }; -- cgit v1.2.3 From c133d4b82b205b515e0c43be9f9b92ac3dbcd9ce Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 5 Jun 2010 02:06:26 +0100 Subject: Added "channel set" command, mostly so I can test all that stuff. Needs more work. --- root_commands.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 65f3de9a..cf1c169c 100644 --- a/root_commands.c +++ b/root_commands.c @@ -485,6 +485,30 @@ static void cmd_account( irc_t *irc, char **cmd ) } } +static set_t **cmd_channel_set_findhead( irc_t *irc, char *id ) +{ + irc_channel_t *ic; + + if( ( ic = irc_channel_by_name( irc, id ) ) ) + return &ic->set; + else + return NULL; +} + +static void cmd_channel( irc_t *irc, char **cmd ) +{ + if( g_strcasecmp( cmd[1], "set" ) == 0 ) + { + MIN_ARGS( 2 ); + + cmd_set_real( irc, cmd + 1, cmd_channel_set_findhead, NULL ); + } + else + { + irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "channel", cmd[1] ); + } +} + static void cmd_add( irc_t *irc, char **cmd ) { account_t *a; @@ -942,7 +966,6 @@ static void cmd_qlist( irc_t *irc, char **cmd ) static void cmd_chat( irc_t *irc, char **cmd ) { account_t *acc; - struct chat *c; if( g_strcasecmp( cmd[1], "add" ) == 0 ) { @@ -1080,6 +1103,8 @@ const command_t commands[] = { { "allow", 1, cmd_allow, 0 }, { "blist", 0, cmd_blist, 0 }, { "block", 1, cmd_block, 0 }, + { "channel", 1, cmd_channel, 0 }, + { "chat", 1, cmd_chat, 0 }, { "drop", 1, cmd_drop, 0 }, { "ft", 0, cmd_transfer, 0 }, { "help", 0, cmd_help, 0 }, @@ -1094,6 +1119,5 @@ const command_t commands[] = { { "set", 0, cmd_set, 0 }, { "transfer", 0, cmd_transfer, 0 }, { "yes", 0, cmd_yesno, 0 }, - { "chat", 1, cmd_chat, 0 }, { NULL } }; -- cgit v1.2.3 From 5a75d1586478f78446b6c78b161572fc7cabe4d9 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 5 Jun 2010 23:32:36 +0100 Subject: Chatroom improvements. Merged chatroom stub into normal chatroom stuff, restored "chat add" behaviour a little bit better (don't clean up a channel when its room disappears, just disconnect it from the groupchat). --- root_commands.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index cf1c169c..7c54e272 100644 --- a/root_commands.c +++ b/root_commands.c @@ -979,6 +979,11 @@ static void cmd_chat( irc_t *irc, char **cmd ) irc_usermsg( irc, "Invalid account" ); return; } + else if( !acc->prpl->chat_join ) + { + irc_usermsg( irc, "Named chatrooms not supported on that account." ); + return; + } if( cmd[4] == NULL ) { @@ -998,13 +1003,19 @@ static void cmd_chat( irc_t *irc, char **cmd ) channel = s; } - if( ( ic = irc_channel_new( irc, channel ) ) ) + if( ( ic = irc_channel_new( irc, channel ) ) && + set_setstr( &ic->set, "chat_type", "room" ) && + set_setstr( &ic->set, "account", cmd[2] ) && + set_setstr( &ic->set, "room", cmd[3] ) ) + { + irc_usermsg( irc, "Chatroom successfully added." ); + } + else { - struct irc_groupchat_stub *igs; + if( ic ) + irc_channel_free( ic ); - ic->data = igs = g_new0( struct irc_groupchat_stub, 1 ); - igs->acc = acc; - igs->room = g_strdup( cmd[3] ); + irc_usermsg( irc, "Could not add chatroom." ); } } /* -- cgit v1.2.3 From c1a8a163703a903c7a69e06286013f12d6bf865e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 6 Jun 2010 00:16:52 +0100 Subject: Restored the "chat with" command, let's keep it around at least for now. Maybe it's nice to keep since it's only one command, as opposed to /join + /invite. --- root_commands.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 7c54e272..eb42c888 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1018,19 +1018,19 @@ static void cmd_chat( irc_t *irc, char **cmd ) irc_usermsg( irc, "Could not add chatroom." ); } } - /* else if( g_strcasecmp( cmd[1], "with" ) == 0 ) { - user_t *u; + irc_user_t *iu; MIN_ARGS( 2 ); - if( ( u = user_find( irc, cmd[2] ) ) && u->ic && u->ic->acc->prpl->chat_with ) + if( ( iu = irc_user_by_name( irc, cmd[2] ) ) && + iu->bu && iu->bu->ic->acc->prpl->chat_with ) { - if( !u->ic->acc->prpl->chat_with( u->ic, u->handle ) ) + if( !iu->bu->ic->acc->prpl->chat_with( iu->bu->ic, iu->bu->handle ) ) { irc_usermsg( irc, "(Possible) failure while trying to open " - "a groupchat with %s.", u->nick ); + "a groupchat with %s.", iu->nick ); } } else @@ -1038,7 +1038,6 @@ static void cmd_chat( irc_t *irc, char **cmd ) irc_usermsg( irc, "Can't open a groupchat with %s.", cmd[2] ); } } - */ else { irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "chat", cmd[1] ); -- cgit v1.2.3 From 16834a53f85be092acc16dee70cb72451b2230f9 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 6 Jun 2010 02:30:45 +0100 Subject: Set handle_unknown to add_channel by default. --- root_commands.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index eb42c888..cdc1ccdb 100644 --- a/root_commands.c +++ b/root_commands.c @@ -680,20 +680,6 @@ char *set_eval_root_nick( set_t *set, char *new_nick ) return strcmp( irc->mynick, new_nick ) == 0 ? new_nick : SET_INVALID; } - -char *set_eval_control_channel( set_t *set, char *new_name ) -{ - irc_t *irc = set->data; - - if( strcmp( irc->channel, new_name ) != 0 ) - { - char *cmd[] = { "set_rename", irc->channel, new_name, NULL }; - - cmd_rename( irc, cmd ); - } - - return strcmp( irc->channel, new_name ) == 0 ? new_name : SET_INVALID; -} #endif static void cmd_block( irc_t *irc, char **cmd ) -- cgit v1.2.3 From 92cb8c4c251fb04a483b29e7108e7a52388f14dd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 7 Jun 2010 00:47:46 +0100 Subject: Complete (hopefully) fix for nickname changes: Add flags to the identify command to allow identifying without loading any new settings. With some documentation hints. --- root_commands.c | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index cdc1ccdb..bb9b26cd 100644 --- a/root_commands.c +++ b/root_commands.c @@ -104,15 +104,46 @@ 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, cmd[1] ); + storage_status_t status; char *account_on[] = { "account", "on", NULL }; + gboolean load = TRUE; + char *password = cmd[1]; - if( strchr( irc->umode, 'R' ) != NULL ) + if( irc->status & USTATUS_IDENTIFIED ) { irc_usermsg( irc, "You're already logged in." ); return; } + if( strncmp( cmd[1], "-no", 3 ) == 0 ) + { + load = FALSE; + password = cmd[2]; + } + else if( strncmp( cmd[1], "-force", 6 ) == 0 ) + { + password = cmd[2]; + } + else if( irc->b->accounts != NULL ) + { + irc_usermsg( irc, + "You're trying to identify yourself, but already have " + "at least one IM account set up. " + "Use \x02identify -noload\x02 or \x02identify -force\x02 " + "instead (see \x02help identify\x02)." ); + return; + } + + if( password == NULL ) + { + MIN_ARGS( 2 ); + } + + if( load ) + status = storage_load( irc, password ); + else + status = storage_check_pass( irc->user->nick, password ); + switch (status) { case STORAGE_INVALID_PASSWORD: irc_usermsg( irc, "Incorrect password" ); @@ -121,11 +152,12 @@ 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, settings and accounts loaded" ); - irc_setpass( irc, cmd[1] ); + irc_usermsg( irc, "Password accepted%s", + load ? ", settings and accounts loaded" : "" ); + irc_setpass( irc, password ); irc->status |= USTATUS_IDENTIFIED; irc_umode_set( irc, "+R", 1 ); - if( set_getbool( &irc->b->set, "auto_connect" ) ) + if( load && set_getbool( &irc->b->set, "auto_connect" ) ) cmd_account( irc, account_on ); break; case STORAGE_OTHER_ERROR: -- cgit v1.2.3 From 36562b0f1a82bd2a5e9a24a7091845847e4242b4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 7 Jun 2010 01:44:45 +0100 Subject: Added "channel list" command and the ability to use only part of the channel name or a number in "chan set"/etc. --- root_commands.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index bb9b26cd..72dec6f1 100644 --- a/root_commands.c +++ b/root_commands.c @@ -521,7 +521,7 @@ static set_t **cmd_channel_set_findhead( irc_t *irc, char *id ) { irc_channel_t *ic; - if( ( ic = irc_channel_by_name( irc, id ) ) ) + if( ( ic = irc_channel_get( irc, id ) ) ) return &ic->set; else return NULL; @@ -535,6 +535,26 @@ static void cmd_channel( irc_t *irc, char **cmd ) cmd_set_real( irc, cmd + 1, cmd_channel_set_findhead, NULL ); } + else if( g_strcasecmp( cmd[1], "list" ) == 0 ) + { + GSList *l; + int i = 0; + + if( strchr( irc->umode, 'b' ) ) + irc_usermsg( irc, "Channel list:" ); + + for( l = irc->channels; l; l = l->next ) + { + irc_channel_t *ic = l->data; + + irc_usermsg( irc, "%2d. %s, %s channel%s", i, ic->name, + set_getstr( &ic->set, "type" ), + ic->flags & IRC_CHANNEL_JOINED ? " (joined)" : "" ); + + i ++; + } + irc_usermsg( irc, "End of channel list" ); + } else { irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "channel", cmd[1] ); -- cgit v1.2.3 From 0a6e5d1fd4e0c33e0529db7f94aae66b3f995f84 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 7 Jun 2010 16:51:31 +0100 Subject: Restore "set root_nick" behaviour. All disabled set evaluators are back now. Getting *very* close to "feature parity" now! --- root_commands.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 72dec6f1..a9106781 100644 --- a/root_commands.c +++ b/root_commands.c @@ -718,21 +718,19 @@ static void cmd_rename( irc_t *irc, char **cmd ) } } -#if 0 char *set_eval_root_nick( set_t *set, char *new_nick ) { irc_t *irc = set->data; - if( strcmp( irc->mynick, new_nick ) != 0 ) + if( strcmp( irc->root->nick, new_nick ) != 0 ) { - char *cmd[] = { "set_rename", irc->mynick, new_nick, NULL }; + char *cmd[] = { "set_rename", irc->root->nick, new_nick, NULL }; cmd_rename( irc, cmd ); } - return strcmp( irc->mynick, new_nick ) == 0 ? new_nick : SET_INVALID; + return strcmp( irc->root->nick, new_nick ) == 0 ? new_nick : SET_INVALID; } -#endif static void cmd_block( irc_t *irc, char **cmd ) { -- cgit v1.2.3 From a4d920bfc34db9ca9161ff3817385423e52b8c90 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 7 Jun 2010 17:48:11 +0100 Subject: Added "channel del". --- root_commands.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index a9106781..12e89b32 100644 --- a/root_commands.c +++ b/root_commands.c @@ -555,6 +555,24 @@ static void cmd_channel( irc_t *irc, char **cmd ) } irc_usermsg( irc, "End of channel list" ); } + else if( g_strcasecmp( cmd[1], "del" ) == 0 ) + { + irc_channel_t *ic; + + MIN_ARGS( 2 ); + + if( ( ic = irc_channel_get( irc, cmd[2] ) ) && + !( ic->flags & IRC_CHANNEL_JOINED ) && + ic != ic->irc->default_channel ) + { + irc_usermsg( irc, "Channel %s deleted.", ic->name ); + irc_channel_free( ic ); + } + else + irc_usermsg( irc, "Couldn't remove channel (main channel %s or " + "channels you're still in cannot be deleted).", + ic->irc->default_channel->name ); + } else { irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "channel", cmd[1] ); -- cgit v1.2.3 From d7db3468f95d6b8ed2a161c71cb5b6ab1a7b5895 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 8 Jun 2010 23:44:16 +0100 Subject: Some cleanup improvements. --- 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 12e89b32..ebcb6896 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1071,6 +1071,7 @@ static void cmd_chat( irc_t *irc, char **cmd ) irc_usermsg( irc, "Could not add chatroom." ); } + g_free( channel ); } else if( g_strcasecmp( cmd[1], "with" ) == 0 ) { -- cgit v1.2.3 From 46d215d562f8e1aba2b24e2d1feab27337956d50 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 9 Jun 2010 00:43:13 +0100 Subject: Allow moving contacts around between groups. Works with at least Jabber, will check the others now. --- 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 ebcb6896..f6f95599 100644 --- a/root_commands.c +++ b/root_commands.c @@ -621,7 +621,7 @@ static void cmd_add( irc_t *irc, char **cmd ) } if( add_on_server ) - a->ic->acc->prpl->add_buddy( a->ic, cmd[2], NULL ); + a->prpl->add_buddy( a->ic, cmd[2], NULL ); else /* Only for add -tmp. For regular adds, this callback will be called once the IM server confirms. */ -- cgit v1.2.3 From 52663546cc019ebdf4a7d56f1425408e20e1d4cb Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 10 Jun 2010 17:39:17 +0100 Subject: Fixed extremely stupid NULLptr dereference. --- 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 f6f95599..10ce68e1 100644 --- a/root_commands.c +++ b/root_commands.c @@ -571,7 +571,7 @@ static void cmd_channel( irc_t *irc, char **cmd ) else irc_usermsg( irc, "Couldn't remove channel (main channel %s or " "channels you're still in cannot be deleted).", - ic->irc->default_channel->name ); + irc->default_channel->name ); } else { -- cgit v1.2.3 From 7cd2e8a6c0ba091f56e6ee8bc087c799faee3662 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 23 Jun 2010 00:43:36 +0100 Subject: Automatically call the "channel" command for the now-gone chat subcommands. --- root_commands.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 10ce68e1..ea110467 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1093,6 +1093,13 @@ static void cmd_chat( irc_t *irc, char **cmd ) irc_usermsg( irc, "Can't open a groupchat with %s.", cmd[2] ); } } + else if( g_strcasecmp( cmd[1], "list" ) == 0 || + g_strcasecmp( cmd[1], "set" ) == 0 || + g_strcasecmp( cmd[1], "del" ) == 0 ) + { + irc_usermsg( irc, "Warning: The \002chat\002 command was mostly replaced with the \002channel\002 command." ); + cmd_channel( irc, cmd ); + } else { irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "chat", cmd[1] ); -- cgit v1.2.3 From e907683afea9e2789e0ac6a1eb55bda9c896c255 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 27 Jun 2010 00:39:31 +0100 Subject: Changed account set (and other account commands) syntax. Instead of "account set acc/key value" you now do "account acc set key value". So just the regular set syntax with a "account acc" prefix. The slash has been a source of confusion for long enough now. For consistency, commands like "account on acc" should now also be "account acc on" instead. Same for the new "channel" comand, of course. --- root_commands.c | 257 ++++++++++++++++++++++++-------------------------------- 1 file changed, 109 insertions(+), 148 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index ea110467..63f1c867 100644 --- a/root_commands.c +++ b/root_commands.c @@ -240,49 +240,24 @@ static void cmd_showset( irc_t *irc, set_t **head, char *key ) typedef set_t** (*cmd_set_findhead)( irc_t*, char* ); typedef int (*cmd_set_checkflags)( irc_t*, set_t *set ); -static int cmd_set_real( irc_t *irc, char **cmd, cmd_set_findhead findhead, cmd_set_checkflags checkflags ) +static int cmd_set_real( irc_t *irc, char **cmd, set_t **head, cmd_set_checkflags checkflags ) { - char *set_full = NULL, *set_name = NULL, *tmp; - set_t **head; + char *set_name = NULL, *value = NULL; + gboolean del = FALSE; if( cmd[1] && g_strncasecmp( cmd[1], "-del", 4 ) == 0 ) { MIN_ARGS( 2, 0 ); - set_full = cmd[2]; + set_name = cmd[2]; + del = TRUE; } else - set_full = cmd[1]; - - if( findhead == NULL ) - { - set_name = set_full; - - head = &irc->b->set; - } - else { - char *id; - - if( ( tmp = strchr( set_full, '/' ) ) ) - { - id = g_strndup( set_full, ( tmp - set_full ) ); - set_name = tmp + 1; - } - else - { - id = g_strdup( set_full ); - } - - if( ( head = findhead( irc, id ) ) == NULL ) - { - g_free( id ); - irc_usermsg( irc, "Could not find setting." ); - return 0; - } - g_free( id ); + set_name = cmd[1]; + value = cmd[2]; } - if( cmd[1] && cmd[2] && set_name ) + if( set_name && ( value || del ) ) { set_t *s = set_find( head, set_name ); int st; @@ -290,13 +265,16 @@ static int cmd_set_real( irc_t *irc, char **cmd, cmd_set_findhead findhead, cmd_ if( s && checkflags && checkflags( irc, s ) == 0 ) return 0; - if( g_strncasecmp( cmd[1], "-del", 4 ) == 0 ) + if( del ) st = set_reset( head, set_name ); else - st = set_setstr( head, set_name, cmd[2] ); + st = set_setstr( head, set_name, value ); if( set_getstr( head, set_name ) == NULL ) { + /* This happens when changing the passwd, for example. + Showing these msgs instead gives slightly clearer + feedback. */ if( st ) irc_usermsg( irc, "Setting changed successfully" ); else @@ -324,16 +302,6 @@ static int cmd_set_real( irc_t *irc, char **cmd, cmd_set_findhead findhead, cmd_ return 1; } -static set_t **cmd_account_set_findhead( irc_t *irc, char *id ) -{ - account_t *a; - - if( ( a = account_get( irc->b, id ) ) ) - return &a->set; - else - return NULL; -} - static int cmd_account_set_checkflags( irc_t *irc, set_t *s ) { account_t *a = s->data; @@ -385,24 +353,8 @@ static void cmd_account( irc_t *irc, char **cmd ) } irc_usermsg( irc, "Account successfully added" ); - } - else if( g_strcasecmp( cmd[1], "del" ) == 0 ) - { - MIN_ARGS( 2 ); - - if( !( a = account_get( irc->b, cmd[2] ) ) ) - { - irc_usermsg( irc, "Invalid account" ); - } - else if( a->ic ) - { - irc_usermsg( irc, "Account is still logged in, can't delete" ); - } - else - { - account_del( irc->b, a ); - irc_usermsg( irc, "Account deleted" ); - } + + return; } else if( g_strcasecmp( cmd[1], "list" ) == 0 ) { @@ -429,113 +381,112 @@ static void cmd_account( irc_t *irc, char **cmd ) i ++; } irc_usermsg( irc, "End of account list" ); + + return; + } + else if( cmd[2] ) + { + /* Try the following two only if cmd[2] == NULL */ } else if( g_strcasecmp( cmd[1], "on" ) == 0 ) { - if( cmd[2] ) + if ( irc->b->accounts ) { - if( ( a = account_get( irc->b, cmd[2] ) ) ) - { - if( a->ic ) - { - irc_usermsg( irc, "Account already online" ); - return; - } - else - { + irc_usermsg( irc, "Trying to get all accounts connected..." ); + + for( a = irc->b->accounts; a; a = a->next ) + if( !a->ic && a->auto_connect ) account_on( irc->b, a ); - } - } - else - { - irc_usermsg( irc, "Invalid account" ); - return; - } - } + } else { - if ( irc->b->accounts ) - { - irc_usermsg( irc, "Trying to get all accounts connected..." ); - - for( a = irc->b->accounts; a; a = a->next ) - if( !a->ic && a->auto_connect ) - account_on( irc->b, a ); - } - 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." ); } + + return; } else if( g_strcasecmp( cmd[1], "off" ) == 0 ) { - if( !cmd[2] ) - { - irc_usermsg( irc, "Deactivating all active (re)connections..." ); - - for( a = irc->b->accounts; a; a = a->next ) - { - if( a->ic ) - account_off( irc->b, a ); - else if( a->reconnect ) - cancel_auto_reconnect( a ); - } - } - else if( ( a = account_get( irc->b, cmd[2] ) ) ) + irc_usermsg( irc, "Deactivating all active (re)connections..." ); + + for( a = irc->b->accounts; a; a = a->next ) { if( a->ic ) - { account_off( irc->b, a ); - } else if( a->reconnect ) - { cancel_auto_reconnect( a ); - irc_usermsg( irc, "Reconnect cancelled" ); - } - else - { - irc_usermsg( irc, "Account already offline" ); - return; - } + } + + return; + } + + MIN_ARGS( 2 ); + + /* At least right now, don't accept on/off/set/del as account IDs even + if they're a proper match, since people not familiar with the new + syntax yet may get a confusing/nasty surprise. */ + if( g_strcasecmp( cmd[1], "on" ) == 0 || + g_strcasecmp( cmd[1], "off" ) == 0 || + g_strcasecmp( cmd[1], "set" ) == 0 || + g_strcasecmp( cmd[1], "del" ) == 0 || + ( a = account_get( irc->b, cmd[1] ) ) == NULL ) + { + irc_usermsg( irc, "Could not find account `%s'. Note that the syntax " + "of the account command changed, see \x02help account\x02.", cmd[1] ); + + return; + } + + if( g_strcasecmp( cmd[2], "del" ) == 0 ) + { + if( a->ic ) + { + irc_usermsg( irc, "Account is still logged in, can't delete" ); } else { - irc_usermsg( irc, "Invalid account" ); - return; + account_del( irc->b, a ); + irc_usermsg( irc, "Account deleted" ); } } - else if( g_strcasecmp( cmd[1], "set" ) == 0 ) + else if( g_strcasecmp( cmd[2], "on" ) == 0 ) { - MIN_ARGS( 2 ); - - cmd_set_real( irc, cmd + 1, cmd_account_set_findhead, cmd_account_set_checkflags ); + if( a->ic ) + irc_usermsg( irc, "Account already online" ); + else + account_on( irc->b, a ); + } + else if( g_strcasecmp( cmd[2], "off" ) == 0 ) + { + if( a->ic ) + { + account_off( irc->b, a ); + } + else if( a->reconnect ) + { + cancel_auto_reconnect( a ); + irc_usermsg( irc, "Reconnect cancelled" ); + } + else + { + irc_usermsg( irc, "Account already offline" ); + } + } + else if( g_strcasecmp( cmd[2], "set" ) == 0 ) + { + cmd_set_real( irc, cmd + 2, &a->set, cmd_account_set_checkflags ); } else { - irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "account", cmd[1] ); + irc_usermsg( irc, "Unknown command: %s [...] %s. Please use \x02help commands\x02 to get a list of available commands.", "account", cmd[2] ); } } -static set_t **cmd_channel_set_findhead( irc_t *irc, char *id ) +static void cmd_channel( irc_t *irc, char **cmd ) { irc_channel_t *ic; - if( ( ic = irc_channel_get( irc, id ) ) ) - return &ic->set; - else - return NULL; -} - -static void cmd_channel( irc_t *irc, char **cmd ) -{ - if( g_strcasecmp( cmd[1], "set" ) == 0 ) - { - MIN_ARGS( 2 ); - - cmd_set_real( irc, cmd + 1, cmd_channel_set_findhead, NULL ); - } - else if( g_strcasecmp( cmd[1], "list" ) == 0 ) + if( g_strcasecmp( cmd[1], "list" ) == 0 ) { GSList *l; int i = 0; @@ -554,15 +505,25 @@ static void cmd_channel( irc_t *irc, char **cmd ) i ++; } irc_usermsg( irc, "End of channel list" ); + + return; } - else if( g_strcasecmp( cmd[1], "del" ) == 0 ) + + MIN_ARGS( 2 ); + + if( ( ic = irc_channel_get( irc, cmd[1] ) ) == NULL ) { - irc_channel_t *ic; - - MIN_ARGS( 2 ); - - if( ( ic = irc_channel_get( irc, cmd[2] ) ) && - !( ic->flags & IRC_CHANNEL_JOINED ) && + irc_usermsg( irc, "Could not find channel `%s'", cmd[1] ); + return; + } + + if( g_strcasecmp( cmd[2], "set" ) == 0 ) + { + cmd_set_real( irc, cmd + 2, &ic->set, NULL ); + } + else if( g_strcasecmp( cmd[2], "del" ) == 0 ) + { + if( !( ic->flags & IRC_CHANNEL_JOINED ) && ic != ic->irc->default_channel ) { irc_usermsg( irc, "Channel %s deleted.", ic->name ); @@ -575,7 +536,7 @@ static void cmd_channel( irc_t *irc, char **cmd ) } else { - irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "channel", cmd[1] ); + irc_usermsg( irc, "Unknown command: %s [...] %s. Please use \x02help commands\x02 to get a list of available commands.", "channel", cmd[1] ); } } @@ -911,7 +872,7 @@ static void cmd_yesno( irc_t *irc, char **cmd ) static void cmd_set( irc_t *irc, char **cmd ) { - cmd_set_real( irc, cmd, NULL, NULL ); + cmd_set_real( irc, cmd, &irc->b->set, NULL ); } static void cmd_blist( irc_t *irc, char **cmd ) -- cgit v1.2.3 From 84c3a72604a292c41348d678eccf1875263cb8dd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 27 Jun 2010 13:39:07 +0100 Subject: Import chatrooms configured in older BitlBee versions. Settings are currently ignored though. Also removing the old chat.[ch] files since they're really not important anymore. --- root_commands.c | 1 - 1 file changed, 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 63f1c867..e075816a 100644 --- a/root_commands.c +++ b/root_commands.c @@ -27,7 +27,6 @@ #include "commands.h" #include "bitlbee.h" #include "help.h" -#include "chat.h" #include -- cgit v1.2.3 From 547ea687b733113e06d7b941096b60632ac24de9 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 27 Jun 2010 16:32:12 +0100 Subject: Save and load channels. Also fixing a bug in creating non-control channels with a &-name. --- 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 e075816a..b47ce078 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1018,6 +1018,7 @@ static void cmd_chat( irc_t *irc, char **cmd ) } if( ( ic = irc_channel_new( irc, channel ) ) && + set_setstr( &ic->set, "type", "chat" ) && set_setstr( &ic->set, "chat_type", "room" ) && set_setstr( &ic->set, "account", cmd[2] ) && set_setstr( &ic->set, "room", cmd[3] ) ) -- cgit v1.2.3 From 134a02cd563c395d0026d9d1b07eb136394798ca Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 27 Jun 2010 17:04:28 +0100 Subject: irc_channel_name_strip() instead of nick_strip(). --- root_commands.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index b47ce078..470b2536 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1015,6 +1015,8 @@ static void cmd_chat( irc_t *irc, char **cmd ) s = g_strdup_printf( "#%s", channel ); g_free( channel ); channel = s; + + irc_channel_name_strip( channel ); } if( ( ic = irc_channel_new( irc, channel ) ) && -- cgit v1.2.3 From c7eb7719b4642b72669d280d4c24c54109ed0d28 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 28 Jun 2010 01:18:40 +0100 Subject: Hacky support for short subcommands (i.e. "ac l" instead of "account list".). --- root_commands.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 470b2536..127570e6 100644 --- a/root_commands.c +++ b/root_commands.c @@ -322,6 +322,7 @@ static int cmd_account_set_checkflags( irc_t *irc, set_t *s ) static void cmd_account( irc_t *irc, char **cmd ) { account_t *a; + int len; if( global.conf->authmode == AUTHMODE_REGISTERED && !( irc->status & USTATUS_IDENTIFIED ) ) { @@ -329,7 +330,9 @@ static void cmd_account( irc_t *irc, char **cmd ) return; } - if( g_strcasecmp( cmd[1], "add" ) == 0 ) + len = strlen( cmd[1] ); + + if( len >= 1 && g_strncasecmp( cmd[1], "add", len ) == 0 ) { struct prpl *prpl; @@ -355,7 +358,7 @@ static void cmd_account( irc_t *irc, char **cmd ) return; } - else if( g_strcasecmp( cmd[1], "list" ) == 0 ) + else if( len >= 1 && g_strncasecmp( cmd[1], "list", len ) == 0 ) { int i = 0; @@ -387,7 +390,7 @@ static void cmd_account( irc_t *irc, char **cmd ) { /* Try the following two only if cmd[2] == NULL */ } - else if( g_strcasecmp( cmd[1], "on" ) == 0 ) + else if( len >= 2 && g_strncasecmp( cmd[1], "on", len ) == 0 ) { if ( irc->b->accounts ) { @@ -404,7 +407,7 @@ static void cmd_account( irc_t *irc, char **cmd ) return; } - else if( g_strcasecmp( cmd[1], "off" ) == 0 ) + else if( len >= 2 && g_strncasecmp( cmd[1], "off", len ) == 0 ) { irc_usermsg( irc, "Deactivating all active (re)connections..." ); @@ -420,6 +423,7 @@ static void cmd_account( irc_t *irc, char **cmd ) } MIN_ARGS( 2 ); + len = strlen( cmd[2] ); /* At least right now, don't accept on/off/set/del as account IDs even if they're a proper match, since people not familiar with the new @@ -436,7 +440,7 @@ static void cmd_account( irc_t *irc, char **cmd ) return; } - if( g_strcasecmp( cmd[2], "del" ) == 0 ) + if( len >= 1 && g_strncasecmp( cmd[2], "del", len ) == 0 ) { if( a->ic ) { @@ -448,14 +452,14 @@ static void cmd_account( irc_t *irc, char **cmd ) irc_usermsg( irc, "Account deleted" ); } } - else if( g_strcasecmp( cmd[2], "on" ) == 0 ) + else if( len >= 2 && g_strncasecmp( cmd[2], "on", len ) == 0 ) { if( a->ic ) irc_usermsg( irc, "Account already online" ); else account_on( irc->b, a ); } - else if( g_strcasecmp( cmd[2], "off" ) == 0 ) + else if( len >= 2 && g_strncasecmp( cmd[2], "off", len ) == 0 ) { if( a->ic ) { @@ -471,7 +475,7 @@ static void cmd_account( irc_t *irc, char **cmd ) irc_usermsg( irc, "Account already offline" ); } } - else if( g_strcasecmp( cmd[2], "set" ) == 0 ) + else if( len >= 1 && g_strncasecmp( cmd[2], "set", len ) == 0 ) { cmd_set_real( irc, cmd + 2, &a->set, cmd_account_set_checkflags ); } @@ -484,8 +488,11 @@ static void cmd_account( irc_t *irc, char **cmd ) static void cmd_channel( irc_t *irc, char **cmd ) { irc_channel_t *ic; + int len; + + len = strlen( cmd[1] ); - if( g_strcasecmp( cmd[1], "list" ) == 0 ) + if( len >= 1 && g_strncasecmp( cmd[1], "list", len ) == 0 ) { GSList *l; int i = 0; @@ -509,6 +516,7 @@ static void cmd_channel( irc_t *irc, char **cmd ) } MIN_ARGS( 2 ); + len = strlen( cmd[2] ); if( ( ic = irc_channel_get( irc, cmd[1] ) ) == NULL ) { @@ -516,11 +524,11 @@ static void cmd_channel( irc_t *irc, char **cmd ) return; } - if( g_strcasecmp( cmd[2], "set" ) == 0 ) + if( len >= 1 && g_strncasecmp( cmd[2], "set", len ) == 0 ) { cmd_set_real( irc, cmd + 2, &ic->set, NULL ); } - else if( g_strcasecmp( cmd[2], "del" ) == 0 ) + else if( len >= 1 && g_strncasecmp( cmd[2], "del", len ) == 0 ) { if( !( ic->flags & IRC_CHANNEL_JOINED ) && ic != ic->irc->default_channel ) -- cgit v1.2.3 From c8eeadd72286b87cc1638e388669e00e8c8b9f1e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 4 Jul 2010 11:16:07 +0100 Subject: Added automatic joining of channels. Auto-rejoin functionality for groupchats not reimplemented yet but that's the next step. --- 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 127570e6..62fe1e79 100644 --- a/root_commands.c +++ b/root_commands.c @@ -156,6 +156,7 @@ static void cmd_identify( irc_t *irc, char **cmd ) irc_setpass( irc, password ); irc->status |= USTATUS_IDENTIFIED; irc_umode_set( irc, "+R", 1 ); + irc_channel_auto_joins( irc, NULL ); if( load && set_getbool( &irc->b->set, "auto_connect" ) ) cmd_account( irc, account_on ); break; -- cgit v1.2.3 From 6c2404e051cb6a235f985797c149af0791f44bbd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 6 Jul 2010 22:44:52 +0100 Subject: First part of the handshake, including sending a file descriptor to the IPC master. --- root_commands.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 62fe1e79..5d84c6d4 100644 --- a/root_commands.c +++ b/root_commands.c @@ -104,7 +104,6 @@ static void cmd_account( irc_t *irc, char **cmd ); static void cmd_identify( irc_t *irc, char **cmd ) { storage_status_t status; - char *account_on[] = { "account", "on", NULL }; gboolean load = TRUE; char *password = cmd[1]; @@ -157,8 +156,16 @@ static void cmd_identify( irc_t *irc, char **cmd ) irc->status |= USTATUS_IDENTIFIED; irc_umode_set( irc, "+R", 1 ); irc_channel_auto_joins( irc, NULL ); - if( load && set_getbool( &irc->b->set, "auto_connect" ) ) - cmd_account( irc, account_on ); + + if( ipc_child_identify( irc ) ) + { + if( load && set_getbool( &irc->b->set, "auto_connect" ) ) + irc->login_source_id = b_timeout_add( 200, + cmd_identify_finish, irc ); + } + else if( load && set_getbool( &irc->b->set, "auto_connect" ) ) + cmd_identify_finish( irc, 0, 0 ); + break; case STORAGE_OTHER_ERROR: default: @@ -167,6 +174,16 @@ static void cmd_identify( irc_t *irc, char **cmd ) } } +gboolean cmd_identify_finish( gpointer data, gint fd, b_input_condition cond ) +{ + char *account_on[] = { "account", "on", NULL }; + irc_t *irc = data; + + cmd_account( irc, account_on ); + + return FALSE; +} + static void cmd_register( irc_t *irc, char **cmd ) { if( global.conf->authmode == AUTHMODE_REGISTERED ) @@ -671,7 +688,7 @@ static void cmd_rename( irc_t *irc, char **cmd ) } else if( iu == irc->user ) { - irc_usermsg( irc, "Nick `%s' can't be changed", cmd[1] ); + irc_usermsg( irc, "Use /nick to change your own nickname" ); } else if( !nick_ok( cmd[2] ) ) { -- cgit v1.2.3 From 9a9b520df6044cfc034f9736fb97660a46e879b9 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 8 Jul 2010 23:31:01 +0100 Subject: Allow nick changes if they're only different in capitalisation, fixed faulty responses in the NICK command, and fixing crash bug in nick changes before finishing login. --- 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 62fe1e79..5c5ead7b 100644 --- a/root_commands.c +++ b/root_commands.c @@ -661,7 +661,7 @@ static void cmd_info( irc_t *irc, char **cmd ) static void cmd_rename( irc_t *irc, char **cmd ) { - irc_user_t *iu; + irc_user_t *iu, *old; iu = irc_user_by_name( irc, cmd[1] ); @@ -677,7 +677,7 @@ static void cmd_rename( irc_t *irc, char **cmd ) { irc_usermsg( irc, "Nick `%s' is invalid", cmd[2] ); } - else if( irc_user_by_name( irc, cmd[2] ) ) + else if( ( old = irc_user_by_name( irc, cmd[2] ) ) && old != iu ) { irc_usermsg( irc, "Nick `%s' already exists", cmd[2] ); } -- cgit v1.2.3 From f545372483cef6a2414bc5bf21260579151a627e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 9 Jul 2010 00:10:43 +0100 Subject: Ask for confirmation. Generally working fairly well now, but definitely fragile. --- 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 5d84c6d4..daaebb95 100644 --- a/root_commands.c +++ b/root_commands.c @@ -181,6 +181,7 @@ gboolean cmd_identify_finish( gpointer data, gint fd, b_input_condition cond ) cmd_account( irc, account_on ); + irc->login_source_id = -1; return FALSE; } -- cgit v1.2.3 From f1c2b21af3a51796b747ca4dbc2cdec9611efc5d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 10 Jul 2010 16:08:02 +0100 Subject: Cleanup. Move some code to a more appropriate location, and show the old connection a quit message instead of just breaking the connection. --- root_commands.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index cf448e8d..6fa4fd54 100644 --- a/root_commands.c +++ b/root_commands.c @@ -27,8 +27,7 @@ #include "commands.h" #include "bitlbee.h" #include "help.h" - -#include +#include "ipc.h" void root_command_string( irc_t *irc, char *command ) { -- cgit v1.2.3 From e92c4f4f63ca0ba9ac6f959f7ff894ad2fc72a04 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 11 Jul 2010 01:29:19 +0100 Subject: Takeover stuff now works in daemon mode as well. --- root_commands.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 6fa4fd54..4aeb1470 100644 --- a/root_commands.c +++ b/root_commands.c @@ -154,16 +154,31 @@ static void cmd_identify( irc_t *irc, char **cmd ) irc_setpass( irc, password ); irc->status |= USTATUS_IDENTIFIED; irc_umode_set( irc, "+R", 1 ); - irc_channel_auto_joins( irc, NULL ); - if( ipc_child_identify( irc ) ) + /* The following code is a bit hairy now. With takeover + support, we shouldn't immediately auto_connect in case + we're going to offer taking over an existing session. + Do it in 200ms since that should give the parent process + enough time to come back to us. */ + if( load ) { - if( load && set_getbool( &irc->b->set, "auto_connect" ) ) + irc_channel_auto_joins( irc, NULL ); + if( set_getbool( &irc->b->set, "auto_connect" ) ) irc->login_source_id = b_timeout_add( 200, cmd_identify_finish, irc ); } - else if( load && set_getbool( &irc->b->set, "auto_connect" ) ) + + /* If ipc_child_identify() returns FALSE, it means we're + already sure that there's no takeover target (only + possible in 1-process daemon mode). Start auto_connect + immediately. */ + if( !ipc_child_identify( irc ) && load && + set_getbool( &irc->b->set, "auto_connect" ) ) + { + b_event_remove( irc->login_source_id ); + irc->login_source_id = -1; cmd_identify_finish( irc, 0, 0 ); + } break; case STORAGE_OTHER_ERROR: -- cgit v1.2.3 From af9f2ca883354a47635d130ff5e7bd693a200a29 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 11 Jul 2010 11:59:56 +0100 Subject: Added allow_takeover setting for people who don't like this new functionality. --- root_commands.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 4aeb1470..d19feae0 100644 --- a/root_commands.c +++ b/root_commands.c @@ -174,11 +174,7 @@ static void cmd_identify( irc_t *irc, char **cmd ) immediately. */ if( !ipc_child_identify( irc ) && load && set_getbool( &irc->b->set, "auto_connect" ) ) - { - b_event_remove( irc->login_source_id ); - irc->login_source_id = -1; cmd_identify_finish( irc, 0, 0 ); - } break; case STORAGE_OTHER_ERROR: @@ -195,6 +191,7 @@ gboolean cmd_identify_finish( gpointer data, gint fd, b_input_condition cond ) cmd_account( irc, account_on ); + b_event_remove( irc->login_source_id ); irc->login_source_id = -1; return FALSE; } -- cgit v1.2.3 From b1f818bcbd50eccd416127ed68346616295f54cd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 11 Jul 2010 13:21:59 +0100 Subject: Use bee_user structs in all nick_* functions. Prepare for a nick_get() with more flexible nickname generation. --- 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 d19feae0..f4bb4b82 100644 --- a/root_commands.c +++ b/root_commands.c @@ -614,7 +614,7 @@ static void cmd_add( irc_t *irc, char **cmd ) } else { - nick_set( a, cmd[2], cmd[3] ); + nick_set_raw( a, cmd[2], cmd[3] ); } } @@ -642,7 +642,7 @@ static void cmd_remove( irc_t *irc, char **cmd ) s = g_strdup( bu->handle ); bu->ic->acc->prpl->remove_buddy( bu->ic, bu->handle, NULL ); - nick_del( bu->ic->acc, bu->handle ); + nick_del( bu ); //TODO(wilmer): bee_user_free() and/or let the IM mod do it? irc_user_free( irc, cmd[1] ); irc_usermsg( irc, "Buddy `%s' (nick %s) removed from contact list", s, cmd[1] ); @@ -727,7 +727,7 @@ static void cmd_rename( irc_t *irc, char **cmd ) } else if( iu->bu ) { - nick_set( iu->bu->ic->acc, iu->bu->handle, cmd[2] ); + nick_set( iu->bu, cmd[2] ); } irc_usermsg( irc, "Nick successfully changed" ); -- cgit v1.2.3 From 5e98ff07af5a8d89b7c813f55dfd0972fca11297 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 17 Jul 2010 15:23:20 +0100 Subject: Free a user structure when using the remove command. This disappeared while most IM modules don't call back when a removal was successful. --- 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 f4bb4b82..e9b0e0ab 100644 --- a/root_commands.c +++ b/root_commands.c @@ -643,7 +643,8 @@ static void cmd_remove( irc_t *irc, char **cmd ) bu->ic->acc->prpl->remove_buddy( bu->ic, bu->handle, NULL ); nick_del( bu ); - //TODO(wilmer): bee_user_free() and/or let the IM mod do it? irc_user_free( irc, cmd[1] ); + if( g_slist_find( irc->users, iu ) ) + bee_user_free( irc->b, bu ); irc_usermsg( irc, "Buddy `%s' (nick %s) removed from contact list", s, cmd[1] ); g_free( s ); -- cgit v1.2.3 From fe4f28f593231f93fe4a2e6365edd45c301a6596 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 17 Jul 2010 17:11:09 +0100 Subject: Remove the user from default_channel if it has the auto_join setting disabled. --- root_commands.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index e9b0e0ab..3ce26924 100644 --- a/root_commands.c +++ b/root_commands.c @@ -163,6 +163,10 @@ static void cmd_identify( irc_t *irc, char **cmd ) if( load ) { irc_channel_auto_joins( irc, NULL ); + if( !set_getbool( &irc->default_channel->set, "auto_join" ) ) + irc_channel_del_user( irc->default_channel, irc->user, + IRC_CDU_PART, "auto_join disabled " + "for this channel." ); if( set_getbool( &irc->b->set, "auto_connect" ) ) irc->login_source_id = b_timeout_add( 200, cmd_identify_finish, irc ); -- cgit v1.2.3 From f1d488e9d3f14e68e7df9686acf0840bf7307854 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 18 Jul 2010 16:04:19 +0100 Subject: Add some context sensitivity to the "add" command: If it's used in a group-specific control channel, automatically add the person to that group. Also added the "group list" command I planned for a while already. --- root_commands.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 5 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 3ce26924..3b607d22 100644 --- a/root_commands.c +++ b/root_commands.c @@ -623,13 +623,34 @@ static void cmd_add( irc_t *irc, char **cmd ) } if( add_on_server ) - a->prpl->add_buddy( a->ic, cmd[2], NULL ); + { + irc_channel_t *ic; + char *s, *group = NULL;; + + if( ( ic = irc_channel_by_name( irc, irc->last_root_cmd ) ) && + ( s = set_getstr( &ic->set, "fill_by" ) ) && + strcmp( s, "group" ) == 0 && + ( group = set_getstr( &ic->set, "group" ) ) ) + irc_usermsg( irc, "Adding `%s' to contact list (group %s)", + cmd[2], group ); + else + irc_usermsg( irc, "Adding `%s' to contact list", cmd[2] ); + + a->prpl->add_buddy( a->ic, cmd[2], group ); + } else + { + bee_user_t *bu; + irc_user_t *iu; + /* Only for add -tmp. For regular adds, this callback will be called once the IM server confirms. */ - bee_user_new( irc->b, a->ic, cmd[2], BEE_USER_LOCAL ); + if( ( bu = bee_user_new( irc->b, a->ic, cmd[2], BEE_USER_LOCAL ) ) && + ( iu = bu->ui_data ) ) + irc_usermsg( irc, "Temporarily assigned nickname `%s' " + "to contact `%s'", iu->nick, cmd[2] ); + } - irc_usermsg( irc, "Adding `%s' to your contact list", cmd[2] ); } static void cmd_remove( irc_t *irc, char **cmd ) @@ -809,7 +830,7 @@ static void cmd_block( irc_t *irc, char **cmd ) { 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] ); + irc_usermsg( irc, "Buddy `%s' moved from allow- to block-list", cmd[2] ); } } @@ -870,7 +891,7 @@ static void cmd_allow( irc_t *irc, char **cmd ) 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] ); + irc_usermsg( irc, "Buddy `%s' moved from block- to allow-list", cmd[2] ); } } @@ -1112,6 +1133,32 @@ static void cmd_chat( irc_t *irc, char **cmd ) } } +static void cmd_group( irc_t *irc, char **cmd ) +{ + GSList *l; + int len; + + len = strlen( cmd[1] ); + if( g_strncasecmp( cmd[1], "list", len ) == 0 ) + { + int n = 0; + + if( strchr( irc->umode, 'b' ) ) + irc_usermsg( irc, "Group list:" ); + + for( l = irc->b->groups; l; l = l->next ) + { + bee_group_t *bg = l->data; + irc_usermsg( irc, "%d. %s", n ++, bg->name ); + } + irc_usermsg( irc, "End of group list" ); + } + else + { + irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "group", cmd[1] ); + } +} + static void cmd_transfer( irc_t *irc, char **cmd ) { GSList *files = irc->file_transfers; @@ -1185,6 +1232,7 @@ const command_t commands[] = { { "chat", 1, cmd_chat, 0 }, { "drop", 1, cmd_drop, 0 }, { "ft", 0, cmd_transfer, 0 }, + { "group", 1, cmd_group, 0 }, { "help", 0, cmd_help, 0 }, { "identify", 1, cmd_identify, 0 }, { "info", 1, cmd_info, 0 }, -- cgit v1.2.3 From 4f22a68c5d1dfd0d1da8b44c3a9d60a7754633b7 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 18 Jul 2010 21:12:55 +0100 Subject: Automatically operate on the current channel if just using "channel set". --- root_commands.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 3b607d22..ddef9cde 100644 --- a/root_commands.c +++ b/root_commands.c @@ -549,15 +549,23 @@ static void cmd_channel( irc_t *irc, char **cmd ) return; } - MIN_ARGS( 2 ); - len = strlen( cmd[2] ); - if( ( ic = irc_channel_get( irc, cmd[1] ) ) == NULL ) { - irc_usermsg( irc, "Could not find channel `%s'", cmd[1] ); + /* If this doesn't match any channel, maybe this is the short + syntax (only works when used inside a channel). */ + if( ( len = strlen( cmd[1] ) ) && + g_strncasecmp( cmd[1], "set", len ) == 0 && + ( ic = irc_channel_by_name( irc, irc->last_root_cmd ) ) ) + cmd_set_real( irc, cmd + 1, &ic->set, NULL ); + else + irc_usermsg( irc, "Could not find channel `%s'", cmd[1] ); + return; } + MIN_ARGS( 2 ); + len = strlen( cmd[2] ); + if( len >= 1 && g_strncasecmp( cmd[2], "set", len ) == 0 ) { cmd_set_real( irc, cmd + 2, &ic->set, NULL ); -- cgit v1.2.3 From 40e6dac45f29a4c2cc64ce55eecef03d0b185bd5 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 24 Jul 2010 17:46:59 +0200 Subject: Adding account tags as a way to 100% uniquely identify an account. protocol(screenname) doesn't do this and is a little bit long. These will be used for nick_format and XML storage. --- 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 ddef9cde..cdddf7f2 100644 --- a/root_commands.c +++ b/root_commands.c @@ -412,7 +412,7 @@ static void cmd_account( irc_t *irc, char **cmd ) else con = ""; - irc_usermsg( irc, "%2d. %s, %s%s", i, a->prpl->name, a->user, con ); + irc_usermsg( irc, "%2d (%s): %s, %s%s", i, a->tag, a->prpl->name, a->user, con ); i ++; } -- cgit v1.2.3 From 593971d9ff9f246cec5af5583f29e45fee62edfe Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 24 Jul 2010 22:59:41 +0200 Subject: Warn when adding an account twice. People are doing this a lot actually, and it's unlikely to be intentional. --- root_commands.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index cdddf7f2..69aa3e98 100644 --- a/root_commands.c +++ b/root_commands.c @@ -379,7 +379,13 @@ static void cmd_account( irc_t *irc, char **cmd ) irc_usermsg( irc, "Unknown protocol" ); return; } - + + for( a = irc->b->accounts; a; a = a->next ) + if( a->prpl == prpl && prpl->handle_cmp( a->user, cmd[3] ) == 0 ) + irc_usermsg( irc, "Warning: You already have an account with " + "protocol `%s' and username `%s'. Are you accidentally " + "trying to add it twice?", prpl->name, cmd[3] ); + a = account_add( irc->b, prpl, cmd[3], cmd[4] ); if( cmd[5] ) { -- cgit v1.2.3