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