From aefa533eb48587d9f509a8dcab358061b72c7b3b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 21 Mar 2006 09:12:22 +0100 Subject: Added a special +b usermode for easier parseability of some things. (For now blist and qlist, but more should come) --- root_commands.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index f69442d3..34445b9e 100644 --- a/root_commands.c +++ b/root_commands.c @@ -634,7 +634,8 @@ static void cmd_blist( irc_t *irc, char **cmd ) { int online = 0, away = 0, offline = 0; user_t *u; - char s[64]; + char s[256]; + char *format; int n_online = 0, n_away = 0, n_offline = 0; if( cmd[1] && g_strcasecmp( cmd[1], "all" ) == 0 ) @@ -648,30 +649,46 @@ static void cmd_blist( irc_t *irc, char **cmd ) else online = away = 1; - irc_usermsg( irc, "%-16.16s %-40.40s %s", "Nick", "User/Host/Network", "Status" ); + if( strchr( irc->umode, 'b' ) != NULL ) + format = "%s\t%s\t%s"; + else + format = "%-16.16s %-40.40s %s"; + + irc_usermsg( irc, format, "Nick", "User/Host/Network", "Status" ); - if( online == 1 ) for( u = irc->users; u; u = u->next ) if( u->gc && u->online && !u->away ) + for( u = irc->users; u; u = u->next ) if( u->gc && u->online && !u->away ) { - g_snprintf( s, 63, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); - irc_usermsg( irc, "%-16.16s %-40.40s %s", u->nick, s, "Online" ); + if( online == 1 ) + { + g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); + irc_usermsg( irc, format, u->nick, s, "Online" ); + } + n_online ++; } - if( away == 1 ) for( u = irc->users; u; u = u->next ) if( u->gc && u->online && u->away ) + for( u = irc->users; u; u = u->next ) if( u->gc && u->online && u->away ) { - g_snprintf( s, 63, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); - irc_usermsg( irc, "%-16.16s %-40.40s %s", u->nick, s, u->away ); + if( away == 1 ) + { + g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); + irc_usermsg( irc, format, u->nick, s, u->away ); + } n_away ++; } - if( offline == 1 ) for( u = irc->users; u; u = u->next ) if( u->gc && !u->online ) + for( u = irc->users; u; u = u->next ) if( u->gc && !u->online ) { - g_snprintf( s, 63, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); - irc_usermsg( irc, "%-16.16s %-40.40s %s", u->nick, s, "Offline" ); + if( offline == 1 ) + { + g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); + irc_usermsg( irc, format, u->nick, s, "Offline" ); + } n_offline ++; } - irc_usermsg( irc, "%d buddies (%d available, %d away, %d offline)", n_online + n_away + n_offline, n_online, n_away, n_offline ); + if( strchr( irc->umode, 'b' ) == NULL ) + 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 ) -- cgit v1.2.3 From 87b6a3e49a764201011c8d9f802beddd82b86821 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 21 Mar 2006 09:35:46 +0100 Subject: The block and allow commands can now display the block/allow lists. --- root_commands.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 34445b9e..978d8768 100644 --- a/root_commands.c +++ b/root_commands.c @@ -483,7 +483,27 @@ static void cmd_block( irc_t *irc, char **cmd ) struct gaim_connection *gc; account_t *a; - if( !cmd[2] ) + if( !cmd[2] && ( a = account_get( irc, cmd[1] ) ) && a->gc ) + { + char *format; + GSList *l; + + if( strchr( irc->umode, 'b' ) != NULL ) + format = "%s\t%s"; + else + format = "%-32.32 %-16.16s"; + + irc_usermsg( irc, format, "Handle", "Nickname" ); + for( l = a->gc->deny; l; l = l->next ) + { + user_t *u = user_findhandle( a->gc, l->data ); + irc_usermsg( irc, format, l->data, u ? u->nick : "(none)" ); + } + irc_usermsg( irc, "End of list." ); + + return; + } + else if( !cmd[2] ) { user_t *u = user_find( irc, cmd[1] ); if( !u || !u->gc ) @@ -522,7 +542,27 @@ static void cmd_allow( irc_t *irc, char **cmd ) struct gaim_connection *gc; account_t *a; - if( !cmd[2] ) + if( !cmd[2] && ( a = account_get( irc, cmd[1] ) ) && a->gc ) + { + char *format; + GSList *l; + + if( strchr( irc->umode, 'b' ) != NULL ) + format = "%s\t%s"; + else + format = "%-32.32 %-16.16s"; + + irc_usermsg( irc, format, "Handle", "Nickname" ); + for( l = a->gc->deny; l; l = l->next ) + { + user_t *u = user_findhandle( a->gc, l->data ); + irc_usermsg( irc, format, l->data, u ? u->nick : "(none)" ); + } + irc_usermsg( irc, "End of list." ); + + return; + } + else if( !cmd[2] ) { user_t *u = user_find( irc, cmd[1] ); if( !u || !u->gc ) -- cgit v1.2.3 From aa5ac01a7ed0808a981cabf81b91a3e6a2ee1c9a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 22 Mar 2006 18:35:03 +0100 Subject: Restored buddy counts in blist output for +b mode, it's a nice end-of-list marker. --- 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 978d8768..36eec8c3 100644 --- a/root_commands.c +++ b/root_commands.c @@ -727,8 +727,7 @@ static void cmd_blist( irc_t *irc, char **cmd ) n_offline ++; } - if( strchr( irc->umode, 'b' ) == NULL ) - irc_usermsg( irc, "%d buddies (%d available, %d away, %d offline)", n_online + n_away + n_offline, n_online, n_away, n_offline ); + 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 ) -- cgit v1.2.3 From 7d31002c391868a24693eadaf1c9c6024e1a30cb Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 31 Mar 2006 23:09:36 +0200 Subject: Tested and fixed one issue, and got rid of one more superfluous iconv call. --- root_commands.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 36eec8c3..56260d26 100644 --- a/root_commands.c +++ b/root_commands.c @@ -752,15 +752,9 @@ static void cmd_nick( irc_t *irc, char **cmd ) } else { - char utf8[1024]; - irc_usermsg( irc, "Setting your name to `%s'", cmd[2] ); - if( g_strncasecmp( set_getstr( irc, "charset" ), "none", 4 ) != 0 && - do_iconv( set_getstr( irc, "charset" ), "UTF-8", cmd[2], utf8, 0, 1024 ) != -1 ) - a->gc->prpl->set_info( a->gc, utf8 ); - else - a->gc->prpl->set_info( a->gc, cmd[2] ); + a->gc->prpl->set_info( a->gc, cmd[2] ); } } -- cgit v1.2.3 From e6e1f1815e332f88be3c315f1f8cebf0047721f5 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 1 Apr 2006 17:40:55 +0200 Subject: List header for "account list" in mode +b. --- root_commands.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 56260d26..a29294a0 100644 --- a/root_commands.c +++ b/root_commands.c @@ -244,6 +244,9 @@ static void cmd_account( irc_t *irc, char **cmd ) { int i = 0; + if( strchr( irc->umode, 'b' ) ) + irc_usermsg( irc, "Account list:" ); + for( a = irc->accounts; a; a = a->next ) { char *con; -- cgit v1.2.3 From 57ef86480b13cec08cec29f8352b168d9a16f4e4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 2 Apr 2006 10:29:34 +0200 Subject: Format string problem in cmd_block/allow. --- 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 a29294a0..86f75922 100644 --- a/root_commands.c +++ b/root_commands.c @@ -494,7 +494,7 @@ static void cmd_block( irc_t *irc, char **cmd ) if( strchr( irc->umode, 'b' ) != NULL ) format = "%s\t%s"; else - format = "%-32.32 %-16.16s"; + format = "%-32.32s %-16.16s"; irc_usermsg( irc, format, "Handle", "Nickname" ); for( l = a->gc->deny; l; l = l->next ) @@ -553,7 +553,7 @@ static void cmd_allow( irc_t *irc, char **cmd ) if( strchr( irc->umode, 'b' ) != NULL ) format = "%s\t%s"; else - format = "%-32.32 %-16.16s"; + format = "%-32.32s %-16.16s"; irc_usermsg( irc, format, "Handle", "Nickname" ); for( l = a->gc->deny; l; l = l->next ) -- cgit v1.2.3 From f8de26f98e3c38d3deacb674e533c588e6b48548 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 3 Apr 2006 23:34:45 +0200 Subject: Added "add -tmp" command, which you can use to temporary add a buddy to your list, like the handle_unknown=add setting does. --- root_commands.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 86f75922..0b5f4da5 100644 --- a/root_commands.c +++ b/root_commands.c @@ -349,6 +349,13 @@ static void cmd_account( irc_t *irc, char **cmd ) static void cmd_add( irc_t *irc, char **cmd ) { account_t *a; + int add_for_real = 1; + + if( g_strcasecmp( cmd[1], "-tmp" ) == 0 ) + { + add_for_real = 0; + cmd ++; /* So evil... :-D */ + } if( !( a = account_get( irc, cmd[1] ) ) ) { @@ -378,7 +385,12 @@ static void cmd_add( irc_t *irc, char **cmd ) nick_set( irc, cmd[2], a->gc->prpl, cmd[3] ); } } - a->gc->prpl->add_buddy( a->gc, cmd[2] ); + + /* By making this optional, you can talk to people without having to + add them to your *real* (server-side) contact list. */ + if( add_for_real ) + a->gc->prpl->add_buddy( a->gc, cmd[2] ); + add_buddy( a->gc, NULL, cmd[2], cmd[2] ); irc_usermsg( irc, "User `%s' added to your contact list as `%s'", cmd[2], user_findhandle( a->gc, cmd[2] )->nick ); -- cgit v1.2.3 From 79c6f9f8fff2b4c4627353e8a8eeb591d99a2098 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 25 Apr 2006 09:21:49 +0200 Subject: Implemented better quoting for root command arguments. (Support for backslashes instead of just "' quotes.) --- 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 0b5f4da5..6d9868ac 100644 --- a/root_commands.c +++ b/root_commands.c @@ -57,6 +57,13 @@ void root_command_string( irc_t *irc, user_t *u, char *command, int flags ) s --; } } + 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; -- cgit v1.2.3 From 619a68171055ca6ec460557176bd59817c09b736 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 22 May 2006 00:51:54 +0200 Subject: Fixed a bug that caused root_command_string() to sometimes not notice \0. --- 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 6d9868ac..24423958 100644 --- a/root_commands.c +++ b/root_commands.c @@ -56,6 +56,10 @@ void root_command_string( irc_t *irc, user_t *u, char *command, int flags ) cmd[k++] = s; s --; } + else + { + break; + } } else if( *s == '\\' && ( ( !q && s[1] ) || ( q && q == s[1] ) ) ) { -- cgit v1.2.3 From da3b53657c8e554fc8c28c8ef61ef44492da24dd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 23 May 2006 10:09:16 +0200 Subject: Added bim_ functions for block/allow list management to keep gc->permit/deny up-to-date at run-time. --- root_commands.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 24423958..0e12e9ab 100644 --- a/root_commands.c +++ b/root_commands.c @@ -557,9 +557,9 @@ static void cmd_block( irc_t *irc, char **cmd ) } else { - gc->prpl->rem_permit( gc, cmd[2] ); - gc->prpl->add_deny( gc, cmd[2] ); - irc_usermsg( irc, "Buddy `%s' moved from your permit- to your deny-list", cmd[2] ); + bim_rem_allow( gc, cmd[2] ); + bim_add_block( gc, cmd[2] ); + irc_usermsg( irc, "Buddy `%s' moved from your allow- to your block-list", cmd[2] ); } } @@ -616,10 +616,10 @@ static void cmd_allow( irc_t *irc, char **cmd ) } else { - gc->prpl->rem_deny( gc, cmd[2] ); - gc->prpl->add_permit( gc, cmd[2] ); + bim_rem_block( gc, cmd[2] ); + bim_add_allow( gc, cmd[2] ); - irc_usermsg( irc, "Buddy `%s' moved from your deny- to your permit-list", cmd[2] ); + irc_usermsg( irc, "Buddy `%s' moved from your block- to your allow-list", cmd[2] ); } } -- cgit v1.2.3