From 42616d147d9b6bfb5d09ea6dc237605917765853 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 28 May 2006 20:24:43 +0200 Subject: "ISON :nick1 nick2" works too now, which seems to be what the RFCs really want (although the example says "ISON nick1 nick2"). --- irc_commands.c | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index fe67a534..f80f50f5 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -320,7 +320,7 @@ static void irc_cmd_userhost( irc_t *irc, char **cmd ) static void irc_cmd_ison( irc_t *irc, char **cmd ) { user_t *u; - char buff[IRC_MAX_LINE]; + char buff[IRC_MAX_LINE], *s; int lenleft, i; buff[0] = '\0'; @@ -330,28 +330,41 @@ static void irc_cmd_ison( irc_t *irc, char **cmd ) for( i = 1; cmd[i]; i ++ ) { - if( ( u = user_find( irc, cmd[i] ) ) && u->online ) + char *this, *next; + + this = cmd[i]; + while( *this ) { - /* [SH] Make sure we don't use too much buffer space. */ - lenleft -= strlen( u->nick ) + 1; + if( ( next = strchr( this, ' ' ) ) ) + *next = 0; - if( lenleft < 0 ) + if( ( u = user_find( irc, this ) ) && u->online ) { - break; + lenleft -= strlen( u->nick ) + 1; + + if( lenleft < 0 ) + break; + + strcat( buff, u->nick ); + strcat( buff, " " ); } - /* [SH] Add the nick to the buffer. Note - * that an extra space is always added. Even - * if it's the last nick in the list. Who - * cares? - */ - - strcat( buff, u->nick ); - strcat( buff, " " ); + if( next ) + { + *next = ' '; + this = next + 1; + } + else + { + break; + } } + + /* *sigh* */ + if( lenleft < 0 ) + break; } - /* [WvG] Well, maybe someone cares, so why not remove it? */ if( strlen( buff ) > 0 ) buff[strlen(buff)-1] = '\0'; -- cgit v1.2.3 From c38e9656987d0b56f233353d2d0fa63c68dcf365 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 29 May 2006 01:21:42 +0200 Subject: Removed a message that only applied to the MSN module that got replaced two years ago already. --- irc_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index f80f50f5..dc59f7ee 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -176,7 +176,7 @@ static void irc_cmd_join( irc_t *irc, char **cmd ) if( !u->gc->prpl->chat_open( u->gc, u->handle ) ) { - irc_usermsg( irc, "Could not open a groupchat with %s, maybe you don't have a connection to him/her yet?", u->nick ); + irc_usermsg( irc, "Could not open a groupchat with %s.", u->nick ); } } else if( u ) -- cgit v1.2.3 From b4e4b958ac5db7f59f8a21c914b02d8d487de2a4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 13 Jun 2006 00:24:04 +0200 Subject: Remove unused variable. --- irc_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index dc59f7ee..75ab4dbd 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -320,7 +320,7 @@ static void irc_cmd_userhost( irc_t *irc, char **cmd ) static void irc_cmd_ison( irc_t *irc, char **cmd ) { user_t *u; - char buff[IRC_MAX_LINE], *s; + char buff[IRC_MAX_LINE]; int lenleft, i; buff[0] = '\0'; -- cgit v1.2.3 From 79e826a028f4b4c62c0c16e20af1fb13a9636324 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 15 Jun 2006 14:22:17 +0200 Subject: Converted irc->status to binary flags. (This also fixes auto-save-on-quit that broke because of USTATUS_SHUTDOWN. :-( ) --- irc_commands.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index dc59f7ee..519070db 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -31,7 +31,7 @@ static void irc_cmd_pass( irc_t *irc, char **cmd ) { if( global.conf->auth_pass && strcmp( cmd[1], global.conf->auth_pass ) == 0 ) { - irc->status = USTATUS_AUTHORIZED; + irc->status |= USTATUS_AUTHORIZED; irc_check_login( irc ); } else @@ -609,11 +609,11 @@ void irc_exec( irc_t *irc, char *cmd[] ) /* There should be no typo in the next line: */ for( n_arg = 0; cmd[n_arg]; n_arg ++ ); n_arg --; - if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status >= USTATUS_LOGGED_IN ) + if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status & USTATUS_LOGGED_IN ) { irc_reply( irc, 462, ":Only allowed before logging in" ); } - else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && irc->status < USTATUS_LOGGED_IN ) + else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && ! irc->status & USTATUS_LOGGED_IN ) { irc_reply( irc, 451, ":Register first" ); } -- cgit v1.2.3 From 3af70b06b2f0fb0fb41a041f6d86e3711b9eea3f Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 15 Jun 2006 14:37:05 +0200 Subject: !x&y == (!x)&y, not !(x&y). --- irc_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 519070db..f410bb52 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -613,7 +613,7 @@ void irc_exec( irc_t *irc, char *cmd[] ) { irc_reply( irc, 462, ":Only allowed before logging in" ); } - else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && ! irc->status & USTATUS_LOGGED_IN ) + else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && !( irc->status & USTATUS_LOGGED_IN ) ) { irc_reply( irc, 451, ":Register first" ); } -- cgit v1.2.3 From 2f1322291d06a3a401f730802d501ea3cae6f4e3 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 25 Jun 2006 21:55:18 +0200 Subject: IRC protocol compliance fixes (closes: #158, #159, #160). --- irc_commands.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 3bb24fdb..3a7ace1c 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -118,6 +118,8 @@ static void irc_cmd_mode( irc_t *irc, char **cmd ) { if( cmd[2] ) irc_umode_set( irc, cmd[2], 0 ); + else + irc_reply( irc, 221, "+%s", irc->umode ); } else irc_reply( irc, 502, ":Don't touch their modes" ); @@ -636,6 +638,9 @@ void irc_exec( irc_t *irc, char *cmd[] ) irc_commands[i].execute( irc, cmd ); } - break; + return; } + + if( irc->status >= USTATUS_LOGGED_IN ) + irc_reply( irc, 421, "%s :Unknown command", cmd[0] ); } -- cgit v1.2.3 From 5c9512ffa716f2bc8bbf9e2c31ee40624a0ff842 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 30 Jun 2006 11:17:18 +0200 Subject: Made set.c API more generic so it's not specific to irc_t structures anymore, but can be used for account_t structures too, for example. --- irc_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 3a7ace1c..a3fa0e6e 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -229,7 +229,7 @@ static void irc_cmd_privmsg( irc_t *irc, char **cmd ) if( g_strcasecmp( cmd[1], irc->channel ) == 0 ) { unsigned int i; - char *t = set_getstr( irc, "default_target" ); + char *t = set_getstr( &irc->set, "default_target" ); if( g_strcasecmp( t, "last" ) == 0 && irc->last_target ) cmd[1] = irc->last_target; -- cgit v1.2.3 From 0a3c243b6659dc10efb227e507f324c2711d6dcd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 1 Jul 2006 01:18:56 +0200 Subject: Got rid of struct aim_user (now using account_t everywhere). Needs some more testing though. --- irc_commands.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index a3fa0e6e..889de9da 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -149,10 +149,10 @@ static void irc_cmd_part( irc_t *irc, char **cmd ) irc_part( irc, u, c->channel ); - if( c->gc && c->gc->prpl ) + if( c->gc ) { c->joined = 0; - c->gc->prpl->chat_leave( c->gc, c->id ); + c->gc->acc->prpl->chat_leave( c->gc, c->id ); } } else @@ -172,11 +172,11 @@ static void irc_cmd_join( irc_t *irc, char **cmd ) { user_t *u = user_find( irc, cmd[1] + 1 ); - if( u && u->gc && u->gc->prpl && u->gc->prpl->chat_open ) + if( u && u->gc && u->gc->acc->prpl->chat_open ) { irc_reply( irc, 403, "%s :Initializing groupchat in a different channel", cmd[1] ); - if( !u->gc->prpl->chat_open( u->gc, u->handle ) ) + if( !u->gc->acc->prpl->chat_open( u->gc, u->handle ) ) { irc_usermsg( irc, "Could not open a groupchat with %s.", u->nick ); } @@ -204,9 +204,9 @@ static void irc_cmd_invite( irc_t *irc, char **cmd ) user_t *u = user_find( irc, nick ); if( u && c && ( u->gc == c->gc ) ) - if( c->gc && c->gc->prpl && c->gc->prpl->chat_invite ) + if( c->gc && c->gc->acc->prpl->chat_invite ) { - c->gc->prpl->chat_invite( c->gc, c->id, "", u->handle ); + c->gc->acc->prpl->chat_invite( c->gc, c->id, "", u->handle ); irc_reply( irc, 341, "%s %s", nick, channel ); return; } @@ -476,8 +476,8 @@ static void irc_cmd_whois( irc_t *irc, char **cmd ) irc_reply( irc, 311, "%s %s %s * :%s", u->nick, u->user, u->host, u->realname ); if( u->gc ) - irc_reply( irc, 312, "%s %s.%s :%s network", u->nick, u->gc->user->username, - *u->gc->user->proto_opt[0] ? u->gc->user->proto_opt[0] : "", u->gc->prpl->name ); + irc_reply( irc, 312, "%s %s.%s :%s network", u->nick, u->gc->acc->user, + *u->gc->acc->server ? u->gc->acc->server : "", u->gc->acc->prpl->name ); else irc_reply( irc, 312, "%s %s :%s", u->nick, irc->myhost, IRCD_INFO ); -- cgit v1.2.3 From 5b52a4895e5a59ff6509f7771f4d8665737688c3 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 3 Jul 2006 23:22:45 +0200 Subject: Implemented per-account nick lists instead of per-protocol nick lists. nick_t is dead, instead nicks are just saves in a per-account_t GLib hash table. While doing this, the import_buddies command finally died and text_save() disappeared, because the old file format can't handle most of the new features in this branch anyway. Still have to implement support for the new nick lists in text_load()! --- irc_commands.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 889de9da..47d9e8cb 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -477,7 +477,8 @@ static void irc_cmd_whois( irc_t *irc, char **cmd ) if( u->gc ) irc_reply( irc, 312, "%s %s.%s :%s network", u->nick, u->gc->acc->user, - *u->gc->acc->server ? u->gc->acc->server : "", u->gc->acc->prpl->name ); + u->gc->acc->server && *u->gc->acc->server ? u->gc->acc->server : "", + u->gc->acc->prpl->name ); else irc_reply( irc, 312, "%s %s :%s", u->nick, irc->myhost, IRCD_INFO ); -- cgit v1.2.3 From dfc8a468020935a444397129eb5b2579e1001cf2 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 24 Nov 2006 20:39:59 +0100 Subject: Bye bye lilo. I've never been a fan of yours, but let's not make fun of the dead... --- irc_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 47d9e8cb..b1045c93 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -592,7 +592,7 @@ static const command_t irc_commands[] = { { "completions", 0, irc_cmd_completions, IRC_CMD_LOGGED_IN }, { "die", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, { "wallops", 1, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, - { "lilo", 1, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, + { "wall", 1, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, { "rehash", 0, irc_cmd_rehash, IRC_CMD_OPER_ONLY }, { "restart", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, { "kill", 2, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, -- cgit v1.2.3 From fa29d09342c79b886efacee4cfc3078be5f5a722 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 27 Mar 2007 22:53:11 -0700 Subject: Preparing for Jabber conference room support. --- irc_commands.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index b1045c93..023bd0d4 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -143,7 +143,7 @@ static void irc_cmd_part( irc_t *irc, char **cmd ) irc_part( irc, u, irc->channel ); irc_join( irc, u, irc->channel ); } - else if( ( c = conv_findchannel( cmd[1] ) ) ) + else if( ( c = chat_by_channel( cmd[1] ) ) ) { user_t *u = user_find( irc, irc->nick ); @@ -152,7 +152,7 @@ static void irc_cmd_part( irc_t *irc, char **cmd ) if( c->gc ) { c->joined = 0; - c->gc->acc->prpl->chat_leave( c->gc, c->id ); + c->gc->acc->prpl->chat_leave( c ); } } else @@ -200,13 +200,13 @@ static void irc_cmd_join( irc_t *irc, char **cmd ) static void irc_cmd_invite( irc_t *irc, char **cmd ) { char *nick = cmd[1], *channel = cmd[2]; - struct conversation *c = conv_findchannel( channel ); + struct conversation *c = chat_by_channel( channel ); user_t *u = user_find( irc, nick ); if( u && c && ( u->gc == c->gc ) ) if( c->gc && c->gc->acc->prpl->chat_invite ) { - c->gc->acc->prpl->chat_invite( c->gc, c->id, "", u->handle ); + c->gc->acc->prpl->chat_invite( c, "", u->handle ); irc_reply( irc, 341, "%s %s", nick, channel ); return; } @@ -286,7 +286,7 @@ static void irc_cmd_who( irc_t *irc, char **cmd ) irc_reply( irc, 352, "%s %s %s %s %s %c :0 %s", channel, u->user, u->host, irc->myhost, u->nick, u->away ? 'G' : 'H', u->realname ); u = u->next; } - else if( ( c = conv_findchannel( channel ) ) ) + else if( ( c = chat_by_channel( channel ) ) ) for( l = c->in_room; l; l = l->next ) { if( ( u = user_findhandle( c->gc, l->data ) ) ) -- cgit v1.2.3 From 0da65d5fb37691ed4d31f7ab4058732f1440db6b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 30 Mar 2007 22:40:45 -0700 Subject: s/gaim_connection/im_connection/ and some other minor API changes. The rest will come tomorrow. It compiles, I'll leave the real testing up to someone else. ;-) --- irc_commands.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 023bd0d4..d65cf720 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -133,7 +133,7 @@ static void irc_cmd_names( irc_t *irc, char **cmd ) static void irc_cmd_part( irc_t *irc, char **cmd ) { - struct conversation *c; + struct groupchat *c; if( g_strcasecmp( cmd[1], irc->channel ) == 0 ) { @@ -149,10 +149,10 @@ static void irc_cmd_part( irc_t *irc, char **cmd ) irc_part( irc, u, c->channel ); - if( c->gc ) + if( c->ic ) { c->joined = 0; - c->gc->acc->prpl->chat_leave( c ); + c->ic->acc->prpl->chat_leave( c ); } } else @@ -172,11 +172,11 @@ static void irc_cmd_join( irc_t *irc, char **cmd ) { user_t *u = user_find( irc, cmd[1] + 1 ); - if( u && u->gc && u->gc->acc->prpl->chat_open ) + if( u && u->ic && u->ic->acc->prpl->chat_with ) { irc_reply( irc, 403, "%s :Initializing groupchat in a different channel", cmd[1] ); - if( !u->gc->acc->prpl->chat_open( u->gc, u->handle ) ) + if( !u->ic->acc->prpl->chat_with( u->ic, u->handle ) ) { irc_usermsg( irc, "Could not open a groupchat with %s.", u->nick ); } @@ -200,13 +200,13 @@ static void irc_cmd_join( irc_t *irc, char **cmd ) static void irc_cmd_invite( irc_t *irc, char **cmd ) { char *nick = cmd[1], *channel = cmd[2]; - struct conversation *c = chat_by_channel( channel ); + struct groupchat *c = chat_by_channel( channel ); user_t *u = user_find( irc, nick ); - if( u && c && ( u->gc == c->gc ) ) - if( c->gc && c->gc->acc->prpl->chat_invite ) + if( u && c && ( u->ic == c->ic ) ) + if( c->ic && c->ic->acc->prpl->chat_invite ) { - c->gc->acc->prpl->chat_invite( c, "", u->handle ); + c->ic->acc->prpl->chat_invite( c, "", u->handle ); irc_reply( irc, 341, "%s %s", nick, channel ); return; } @@ -270,7 +270,7 @@ static void irc_cmd_who( irc_t *irc, char **cmd ) { char *channel = cmd[1]; user_t *u = irc->users; - struct conversation *c; + struct groupchat *c; GList *l; if( !channel || *channel == '0' || *channel == '*' || !*channel ) @@ -289,7 +289,7 @@ static void irc_cmd_who( irc_t *irc, char **cmd ) else if( ( c = chat_by_channel( channel ) ) ) for( l = c->in_room; l; l = l->next ) { - if( ( u = user_findhandle( c->gc, l->data ) ) ) + if( ( u = user_findhandle( c->ic, l->data ) ) ) irc_reply( irc, 352, "%s %s %s %s %s %c :0 %s", channel, u->user, u->host, irc->myhost, u->nick, u->away ? 'G' : 'H', u->realname ); } else if( ( u = user_find( irc, channel ) ) ) @@ -459,10 +459,10 @@ static void irc_cmd_away( irc_t *irc, char **cmd ) for( a = irc->accounts; a; a = a->next ) { - struct gaim_connection *gc = a->gc; + struct im_connection *ic = a->ic; - if( gc && gc->flags & OPT_LOGGED_IN ) - bim_set_away( gc, u->away ); + if( ic && ic->flags & OPT_LOGGED_IN ) + bim_set_away( ic, u->away ); } } @@ -475,10 +475,10 @@ static void irc_cmd_whois( irc_t *irc, char **cmd ) { irc_reply( irc, 311, "%s %s %s * :%s", u->nick, u->user, u->host, u->realname ); - if( u->gc ) - irc_reply( irc, 312, "%s %s.%s :%s network", u->nick, u->gc->acc->user, - u->gc->acc->server && *u->gc->acc->server ? u->gc->acc->server : "", - u->gc->acc->prpl->name ); + if( u->ic ) + irc_reply( irc, 312, "%s %s.%s :%s network", u->nick, u->ic->acc->user, + u->ic->acc->server && *u->ic->acc->server ? u->ic->acc->server : "", + u->ic->acc->prpl->name ); else irc_reply( irc, 312, "%s %s :%s", u->nick, irc->myhost, IRCD_INFO ); -- cgit v1.2.3 From 84b045d409f1e8da6d8bf379c6fef7236dcd9bcd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Apr 2007 18:03:08 -0700 Subject: s/imc/imcb/ for callback functions. Moved things aroundin nogaim.h a little bit, grouping things by category instead of original Gaim 0.58 filename. --- irc_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index d65cf720..016b6f84 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -462,7 +462,7 @@ static void irc_cmd_away( irc_t *irc, char **cmd ) struct im_connection *ic = a->ic; if( ic && ic->flags & OPT_LOGGED_IN ) - bim_set_away( ic, u->away ); + imc_set_away( ic, u->away ); } } -- cgit v1.2.3 From 6bbb939e953bbe1ca9ed3101a1569abe4521f543 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Apr 2007 21:01:13 -0700 Subject: Split serv_got_update() into imcb_buddy_(status|times). (Well, the second one isn't implemented yet, but I'll do that later.) At last I got rid of the hack called get_status_string(). And now Yahoo seems to mess up away messages... --- irc_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 016b6f84..8d841aaa 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -262,7 +262,7 @@ static void irc_cmd_privmsg( irc_t *irc, char **cmd ) { irc->is_private = 1; } - irc_send( irc, cmd[1], cmd[2], ( g_strcasecmp( cmd[0], "NOTICE" ) == 0 ) ? IM_FLAG_AWAY : 0 ); + irc_send( irc, cmd[1], cmd[2], ( g_strcasecmp( cmd[0], "NOTICE" ) == 0 ) ? OPT_AWAY : 0 ); } } -- cgit v1.2.3 From 0e7ab64dfb66192a875c37322ca6f8a364ec5bc8 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 22 Apr 2007 19:58:44 -0700 Subject: Got rid of one HORRIBLE stupidity called chat_by_channel(), which still used the GLOBAL IM connections list, allowing user A to interfere with user B's groupchats if running in daemon mode. I can't believe this was still there... --- irc_commands.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 8d841aaa..266d9732 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -143,7 +143,7 @@ static void irc_cmd_part( irc_t *irc, char **cmd ) irc_part( irc, u, irc->channel ); irc_join( irc, u, irc->channel ); } - else if( ( c = chat_by_channel( cmd[1] ) ) ) + else if( ( c = irc_chat_by_channel( irc, cmd[1] ) ) ) { user_t *u = user_find( irc, irc->nick ); @@ -200,7 +200,7 @@ static void irc_cmd_join( irc_t *irc, char **cmd ) static void irc_cmd_invite( irc_t *irc, char **cmd ) { char *nick = cmd[1], *channel = cmd[2]; - struct groupchat *c = chat_by_channel( channel ); + struct groupchat *c = irc_chat_by_channel( irc, channel ); user_t *u = user_find( irc, nick ); if( u && c && ( u->ic == c->ic ) ) @@ -286,7 +286,7 @@ static void irc_cmd_who( irc_t *irc, char **cmd ) irc_reply( irc, 352, "%s %s %s %s %s %c :0 %s", channel, u->user, u->host, irc->myhost, u->nick, u->away ? 'G' : 'H', u->realname ); u = u->next; } - else if( ( c = chat_by_channel( channel ) ) ) + else if( ( c = irc_chat_by_channel( irc, channel ) ) ) for( l = c->in_room; l; l = l->next ) { if( ( u = user_findhandle( c->ic, l->data ) ) ) -- cgit v1.2.3 From 50e1776cb0c76b3328d458dd8a1bfb379b6b0e43 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 19 Nov 2007 22:23:58 +0000 Subject: Merging /TOPIC code from Miklos Vajna. Untested, because I still have to implement the Jabber hooks. --- irc_commands.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 266d9732..287a126f 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -420,10 +420,21 @@ static void irc_cmd_watch( irc_t *irc, char **cmd ) static void irc_cmd_topic( irc_t *irc, char **cmd ) { - if( cmd[2] ) - irc_reply( irc, 482, "%s :Cannot change topic", cmd[1] ); + char *channel = cmd[1]; + char *topic = cmd[2]; + + if( topic ) + { + /* Send the topic */ + struct groupchat *c = irc_chat_by_channel( irc, channel ); + if( c && c->ic && c->ic->acc->prpl->chat_topic ) + c->ic->acc->prpl->chat_topic( c, topic ); + } else - irc_topic( irc, cmd[1] ); + { + /* Get the topic */ + irc_topic( irc, channel ); + } } static void irc_cmd_away( irc_t *irc, char **cmd ) -- cgit v1.2.3 From c058ff976bbbbf43ef11c262f21440e61244f73e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 9 Dec 2007 23:19:35 +0000 Subject: Added /invite support for Jabber chatrooms (and fixed the argument order to chat_invite). --- irc_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 287a126f..65f0d6c6 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -206,7 +206,7 @@ static void irc_cmd_invite( irc_t *irc, char **cmd ) if( u && c && ( u->ic == c->ic ) ) if( c->ic && c->ic->acc->prpl->chat_invite ) { - c->ic->acc->prpl->chat_invite( c, "", u->handle ); + c->ic->acc->prpl->chat_invite( c, u->handle, NULL ); irc_reply( irc, 341, "%s %s", nick, channel ); return; } -- cgit v1.2.3 From 0fbda19314c806e3e677847f3c977eb5a1bc2b61 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 2 Feb 2008 21:48:09 +0000 Subject: Added help_free() and cleaned up some very stale help-related stuff I wasn't even aware of. This closes bug #352. --- irc_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 65f0d6c6..4b431027 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -555,7 +555,7 @@ static void irc_cmd_completions( irc_t *irc, char **cmd ) irc_privmsg( irc, u, "NOTICE", irc->nick, "COMPLETIONS ", commands[i].command ); for( h = global.help; h; h = h->next ) - irc_privmsg( irc, u, "NOTICE", irc->nick, "COMPLETIONS help ", h->string ); + irc_privmsg( irc, u, "NOTICE", irc->nick, "COMPLETIONS help ", h->title ); for( s = irc->set; s; s = s->next ) irc_privmsg( irc, u, "NOTICE", irc->nick, "COMPLETIONS set ", s->key ); -- cgit v1.2.3 From eeb85a8a880fefe655eb31b6322136b61ee969e2 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 11 Feb 2008 12:35:01 +0000 Subject: Got rid of some noise at startup: complaining when the default configuration file couldn't be found while the user specified an alternative location with the -c option, and double complaints about /var/lib/bitlbee/ permissions. --- irc_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 4b431027..68db4617 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -570,7 +570,7 @@ static void irc_cmd_rehash( irc_t *irc, char **cmd ) else ipc_to_master( cmd ); - irc_reply( irc, 382, "%s :Rehashing", CONF_FILE ); + irc_reply( irc, 382, "%s :Rehashing", global.conf_file ); } static const command_t irc_commands[] = { -- cgit v1.2.3 From ec0355f6998eb5dee254e4bc60a3207bb661c854 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 16 Mar 2008 16:31:27 +0000 Subject: Passwords in bitlbee.conf can now be (properly salted) MD5 hashes, for just that little bit extra security. --- irc_commands.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 68db4617..14209732 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -29,7 +29,10 @@ static void irc_cmd_pass( irc_t *irc, char **cmd ) { - if( global.conf->auth_pass && strcmp( cmd[1], global.conf->auth_pass ) == 0 ) + if( global.conf->auth_pass && + strncmp( global.conf->auth_pass, "md5:", 4 ) == 0 ? + md5_verify_password( cmd[1], global.conf->auth_pass + 4 ) == 0 : + strcmp( cmd[1], global.conf->auth_pass ) == 0 ) { irc->status |= USTATUS_AUTHORIZED; irc_check_login( irc ); @@ -87,7 +90,10 @@ static void irc_cmd_ping( irc_t *irc, char **cmd ) static void irc_cmd_oper( irc_t *irc, char **cmd ) { - if( global.conf->oper_pass && strcmp( cmd[2], global.conf->oper_pass ) == 0 ) + if( global.conf->oper_pass && + strncmp( global.conf->oper_pass, "md5:", 4 ) == 0 ? + md5_verify_password( cmd[2], global.conf->oper_pass + 4 ) == 0 : + strcmp( cmd[2], global.conf->oper_pass ) == 0 ) { irc_umode_set( irc, "+o", 1 ); irc_reply( irc, 381, ":Password accepted" ); -- cgit v1.2.3 From c029350d962d95c2d5e9854ca4d82e597addf76d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 16 Mar 2008 17:17:23 +0000 Subject: Added some brackets in irc_cmd_(pass|oper) to prevent crashes when no passwords were set. --- irc_commands.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 14209732..b8bae541 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -30,9 +30,9 @@ static void irc_cmd_pass( irc_t *irc, char **cmd ) { if( global.conf->auth_pass && - strncmp( global.conf->auth_pass, "md5:", 4 ) == 0 ? - md5_verify_password( cmd[1], global.conf->auth_pass + 4 ) == 0 : - strcmp( cmd[1], global.conf->auth_pass ) == 0 ) + ( strncmp( global.conf->auth_pass, "md5:", 4 ) == 0 ? + md5_verify_password( cmd[1], global.conf->auth_pass + 4 ) == 0 : + strcmp( cmd[1], global.conf->auth_pass ) == 0 ) ) { irc->status |= USTATUS_AUTHORIZED; irc_check_login( irc ); @@ -91,9 +91,9 @@ static void irc_cmd_ping( irc_t *irc, char **cmd ) static void irc_cmd_oper( irc_t *irc, char **cmd ) { if( global.conf->oper_pass && - strncmp( global.conf->oper_pass, "md5:", 4 ) == 0 ? - md5_verify_password( cmd[2], global.conf->oper_pass + 4 ) == 0 : - strcmp( cmd[2], global.conf->oper_pass ) == 0 ) + ( strncmp( global.conf->oper_pass, "md5:", 4 ) == 0 ? + md5_verify_password( cmd[2], global.conf->oper_pass + 4 ) == 0 : + strcmp( cmd[2], global.conf->oper_pass ) == 0 ) ) { irc_umode_set( irc, "+o", 1 ); irc_reply( irc, 381, ":Password accepted" ); -- cgit v1.2.3 From a199d33ed818820ffba328f718799bbd77392f6a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 29 Mar 2008 22:19:17 +0000 Subject: Closing bug #209: The PASS command can now be used to identify yourself to BitlBee. The advantage: No more messing with NickServ hooks. Just set a server password. --- irc_commands.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index b8bae541..61517614 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -29,7 +29,19 @@ static void irc_cmd_pass( irc_t *irc, char **cmd ) { - if( global.conf->auth_pass && + if( irc->status & USTATUS_LOGGED_IN ) + { + char *send_cmd[] = { "identify", cmd[1], NULL }; + + /* We're already logged in, this client seems to send the PASS + command last. (Possibly it won't send it at all if it turns + out we don't require it, which will break this feature.) + Try to identify using the given password. */ + return root_command( irc, send_cmd ); + } + /* Handling in pre-logged-in state, first see if this server is + password-protected: */ + else if( global.conf->auth_pass && ( strncmp( global.conf->auth_pass, "md5:", 4 ) == 0 ? md5_verify_password( cmd[1], global.conf->auth_pass + 4 ) == 0 : strcmp( cmd[1], global.conf->auth_pass ) == 0 ) ) @@ -37,10 +49,16 @@ static void irc_cmd_pass( irc_t *irc, char **cmd ) irc->status |= USTATUS_AUTHORIZED; irc_check_login( irc ); } - else + else if( global.conf->auth_pass ) { irc_reply( irc, 464, ":Incorrect password" ); } + else + { + /* Remember the password and try to identify after USER/NICK. */ + irc_setpass( irc, cmd[1] ); + irc_check_login( irc ); + } } static void irc_cmd_user( irc_t *irc, char **cmd ) @@ -580,7 +598,7 @@ static void irc_cmd_rehash( irc_t *irc, char **cmd ) } static const command_t irc_commands[] = { - { "pass", 1, irc_cmd_pass, IRC_CMD_PRE_LOGIN }, + { "pass", 1, irc_cmd_pass, 0 }, { "user", 4, irc_cmd_user, IRC_CMD_PRE_LOGIN }, { "nick", 1, irc_cmd_nick, 0 }, { "quit", 0, irc_cmd_quit, 0 }, -- cgit v1.2.3 From f9756bd2e2711d58e06ad2a33ad3292ff10fc6da Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 30 Mar 2008 22:26:16 +0100 Subject: Changed charset handling: irc_t keeps two iconv structures, which are just used for every line sent and received, so now there's no need to use g_iconv_open() every time a message comes in/out. Also, fixed a small memory leak that was there for a long time but somehow never caught my attention. --- irc_commands.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 61517614..6a47007a 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -277,8 +277,7 @@ static void irc_cmd_privmsg( irc_t *irc, char **cmd ) if( cmd[1] != irc->last_target ) { - if( irc->last_target ) - g_free( irc->last_target ); + g_free( irc->last_target ); irc->last_target = g_strdup( cmd[1] ); } } -- cgit v1.2.3