From 26fdfc5c39ebc2ca75ec3fa6e8d697a98d217edc Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 5 Mar 2006 23:34:06 +0100 Subject: Fixed ssl_openssl... :-/ --- protocols/ssl_openssl.c | 86 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 76 insertions(+), 10 deletions(-) diff --git a/protocols/ssl_openssl.c b/protocols/ssl_openssl.c index e62f95b9..b79088cc 100644 --- a/protocols/ssl_openssl.c +++ b/protocols/ssl_openssl.c @@ -4,7 +4,7 @@ * Copyright 2002-2004 Wilmer van der Gaast and others * \********************************************************************/ -/* SSL module - OpenTLS version */ +/* SSL module - OpenSSL version */ /* This program is free software; you can redistribute it and/or modify @@ -40,11 +40,13 @@ static gboolean initialized = FALSE; struct scd { - SslInputFunction func; + ssl_input_function func; gpointer data; int fd; gboolean established; + int inpa; + int lasterr; /* Necessary for SSL_get_error */ SSL *ssl; SSL_CTX *ssl_ctx; }; @@ -53,7 +55,7 @@ static void ssl_connected( gpointer data, gint source, GaimInputCondition cond ) -void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data ) +void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) { struct scd *conn = g_new0( struct scd, 1 ); SSL_METHOD *meth; @@ -92,19 +94,45 @@ void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data ) return( conn ); } +static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond ); + static void ssl_connected( gpointer data, gint source, GaimInputCondition cond ) { struct scd *conn = data; if( source == -1 ) - goto ssl_connected_failure; + return ssl_handshake( data, -1, cond ); + /* Make it non-blocking at least during the handshake... */ + sock_make_nonblocking( conn->fd ); SSL_set_fd( conn->ssl, conn->fd ); - if( SSL_connect( conn->ssl ) < 0 ) - goto ssl_connected_failure; + return ssl_handshake( data, source, cond ); +} + +static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond ) +{ + struct scd *conn = data; + int st; + + if( conn->inpa != -1 ) + { + gaim_input_remove( conn->inpa ); + conn->inpa = -1; + } + + if( ( st = SSL_connect( conn->ssl ) ) < 0 ) + { + conn->lasterr = SSL_get_error( conn->ssl, st ); + if( conn->lasterr != SSL_ERROR_WANT_READ && conn->lasterr != SSL_ERROR_WANT_WRITE ) + goto ssl_connected_failure; + + conn->inpa = gaim_input_add( conn->fd, ssl_getdirection( conn ), ssl_handshake, data ); + return; + } conn->established = TRUE; + sock_make_blocking( conn->fd ); /* For now... */ conn->func( conn->data, conn, cond ); return; @@ -126,24 +154,57 @@ ssl_connected_failure: int ssl_read( void *conn, char *buf, int len ) { + int st; + if( !((struct scd*)conn)->established ) - return( 0 ); + { + ssl_errno = SSL_NOHANDSHAKE; + return -1; + } + + st = SSL_read( ((struct scd*)conn)->ssl, buf, len ); - return( SSL_read( ((struct scd*)conn)->ssl, buf, len ) ); + ssl_errno = SSL_OK; + if( st <= 0 ) + { + ((struct scd*)conn)->lasterr = SSL_get_error( ((struct scd*)conn)->ssl, st ); + if( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_READ || ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ) + ssl_errno = SSL_AGAIN; + } + + return st; } int ssl_write( void *conn, const char *buf, int len ) { + int st; + if( !((struct scd*)conn)->established ) - return( 0 ); + { + ssl_errno = SSL_NOHANDSHAKE; + return -1; + } + + st = SSL_write( ((struct scd*)conn)->ssl, buf, len ); - return( SSL_write( ((struct scd*)conn)->ssl, buf, len ) ); + ssl_errno = SSL_OK; + if( st <= 0 ) + { + ((struct scd*)conn)->lasterr = SSL_get_error( ((struct scd*)conn)->ssl, st ); + if( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_READ || ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ) + ssl_errno = SSL_AGAIN; + } + + return st; } void ssl_disconnect( void *conn_ ) { struct scd *conn = conn_; + if( conn->inpa != -1 ) + gaim_input_remove( conn->inpa ); + if( conn->established ) SSL_shutdown( conn->ssl ); @@ -158,3 +219,8 @@ int ssl_getfd( void *conn ) { return( ((struct scd*)conn)->fd ); } + +GaimInputCondition ssl_getdirection( void *conn ) +{ + return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? GAIM_INPUT_WRITE : GAIM_INPUT_READ ); +} -- cgit v1.2.3 From 022e77fee802dfc50b8dce51ac10ea0597f7a64a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 6 Mar 2006 13:15:46 +0100 Subject: Fixed error handling on empty help topics. (See #109) --- help.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/help.c b/help.c index 8959a70b..7c6d2dda 100644 --- a/help.c +++ b/help.c @@ -115,22 +115,21 @@ char *help_get( help_t **help, char *string ) if( g_strcasecmp( h->string, string ) == 0 ) break; h = h->next; } - if( h ) + if( h && h->length > 0 ) { char *s = g_new( char, h->length + 1 ); if( fstat( h->fd, stat ) != 0 ) { g_free( h ); - *help=NULL; - return( NULL ); + *help = NULL; + return NULL; } mtime = stat->st_mtime; - if( mtime > h->mtime ) { - return( NULL ); - return( g_strdup( "Help file changed during this session. Please restart to get help back." ) ); - } + if( mtime > h->mtime ) + return NULL; + s[h->length] = 0; if( h->fd >= 0 ) { @@ -141,8 +140,8 @@ char *help_get( help_t **help, char *string ) { strncpy( s, h->offset.mem_offset, h->length ); } - return( s ); + return s; } - return( NULL ); + return NULL; } -- cgit v1.2.3 From 55cc2be3e83f82b9d26565fce235ccc5a5631c5f Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 15 Mar 2006 19:17:01 +0100 Subject: Fixed cleanup of connections in (non-forking) daemon mode. (Better handling of auto_reconnect) --- irc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/irc.c b/irc.c index 93cbc293..096f9d99 100644 --- a/irc.c +++ b/irc.c @@ -231,9 +231,12 @@ void irc_free(irc_t * irc) g_io_channel_unref( irc->io_channel ); irc_connection_list = g_slist_remove( irc_connection_list, irc ); - for (account = irc->accounts; account; account = account->next) + for (account = irc->accounts; account; account = account->next) { if (account->gc) - signoff(account->gc); + account_offline(account->gc); + else if (account->reconnect) + g_source_remove(account->reconnect); + } g_free(irc->sendbuffer); g_free(irc->readbuffer); -- cgit v1.2.3 From 58f31364d2ddefee79396ff73126a21fd5022fa8 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 15 Mar 2006 19:17:26 +0100 Subject: Let's ignore .gdb_history --- .bzrignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.bzrignore b/.bzrignore index d70ec406..802cb1a0 100644 --- a/.bzrignore +++ b/.bzrignore @@ -10,3 +10,4 @@ tags decode encode bitlbee.pc +.gdb_history -- cgit v1.2.3 From 84c1a0ac4530a04113a349dbc3dd15f0e0a4e683 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 15 Mar 2006 20:19:16 +0100 Subject: Small code cleanup, got rid of some functions in nogaim.c that we never needed. --- ipc.c | 2 -- protocols/nogaim.c | 26 +++----------------------- protocols/oscar/oscar.c | 11 +++-------- 3 files changed, 6 insertions(+), 33 deletions(-) diff --git a/ipc.c b/ipc.c index 1b813e7f..48bd574a 100644 --- a/ipc.c +++ b/ipc.c @@ -83,8 +83,6 @@ void ipc_master_cmd_rehash( irc_t *data, char **cmd ) void ipc_master_cmd_restart( irc_t *data, char **cmd ) { - struct bitlbee_child *child = (void*) data; - if( global.conf->runmode != RUNMODE_FORKDAEMON ) { /* Tell child that this is unsupported. */ diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 29ae860a..b0c357db 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -13,7 +13,7 @@ * from scratch for BitlBee and doesn't contain any code from Gaim anymore * (except for the function names). * - * Copyright 2002-2004 Wilmer van der Gaast + * Copyright 2002-2006 Wilmer van der Gaast and others */ /* @@ -351,7 +351,7 @@ void account_online( struct gaim_connection *gc ) user_t *u; /* MSN servers sometimes redirect you to a different server and do - the whole login sequence again, so subsequent calls to this + the whole login sequence again, so these "late" calls to this function should be handled correctly. (IOW, ignored) */ if( gc->flags & OPT_LOGGED_IN ) return; @@ -365,7 +365,7 @@ void account_online( struct gaim_connection *gc ) if( u && u->away ) proto_away( gc, u->away ); - if( !strcmp(gc->prpl->name, "icq") ) + if( strcmp( gc->prpl->name, "ICQ" ) == 0 ) { for( u = gc->irc->users; u; u = u->next ) if( u->gc == gc ) @@ -469,16 +469,6 @@ void do_ask_dialog( struct gaim_connection *gc, char *msg, void *data, void *doi /* list.c */ -int bud_list_cache_exists( struct gaim_connection *gc ) -{ - return( 0 ); -} - -void do_import( struct gaim_connection *gc, void *null ) -{ - return; -} - void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname ) { user_t *u; @@ -553,11 +543,6 @@ struct buddy *find_buddy( struct gaim_connection *gc, char *handle ) return( b ); } -void do_export( struct gaim_connection *gc ) -{ - return; -} - void signoff_blocked( struct gaim_connection *gc ) { return; /* Make all blocked users look invisible (TODO?) */ @@ -883,11 +868,6 @@ struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, c return( c ); } -void serv_finish_login( struct gaim_connection *gc ) -{ - return; -} - /* buddy_chat.c */ diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 4e552bce..7f5c0fc3 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -355,7 +355,9 @@ static void oscar_login(struct aim_user *user) { if (isdigit(*user->username)) { odata->icq = TRUE; - /* this is odd but it's necessary for a proper do_import and do_export */ + /* This is odd but it's necessary for a proper do_import and do_export. + We don't do those anymore, but let's stick with it, just in case + it accidentally fixes something else too... */ gc->password[8] = 0; } else { gc->flags |= OPT_CONN_HTML; @@ -1736,11 +1738,6 @@ static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { odata->rights.maxpermits = (guint)maxpermits; odata->rights.maxdenies = (guint)maxdenies; -// serv_finish_login(gc); - - if (bud_list_cache_exists(gc)) - do_import(gc, NULL); - aim_clientready(sess, fr->conn); aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); @@ -2095,8 +2092,6 @@ static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { } /* End of switch on curitem->type */ } /* End of for loop */ - if (tmp) - do_export(gc); aim_ssi_enable(sess, fr->conn); /* Request offline messages, now that the buddy list is complete. */ -- cgit v1.2.3 From 8ba511db7b32975df97247474782f82d6a3906f9 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 17 Mar 2006 16:39:16 +0100 Subject: Fixed a very stupid bug in the "Closing switchboard with unsent messages" warning message. There's still another problem with switchboar management somewhere.. :-( --- protocols/msn/sb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c index deaceba1..234be1d6 100644 --- a/protocols/msn/sb.c +++ b/protocols/msn/sb.c @@ -201,9 +201,6 @@ void msn_sb_destroy( struct msn_switchboard *sb ) debug( "Destroying switchboard: %s", sb->who ? sb->who : sb->key ? sb->key : "" ); - if( sb->key ) g_free( sb->key ); - if( sb->who ) g_free( sb->who ); - if( sb->msgq ) { struct msn_message *m; @@ -221,9 +218,12 @@ void msn_sb_destroy( struct msn_switchboard *sb ) serv_got_crap( gc, "Warning: Closing down MSN switchboard connection with " "unsent message to %s, you'll have to resend it.", - m->who ? m->who : "(unknown)" ); + sb->who ? sb->who : "(unknown)" ); } + if( sb->key ) g_free( sb->key ); + if( sb->who ) g_free( sb->who ); + if( sb->chat ) { serv_got_chat_left( gc, sb->chat->id ); -- cgit v1.2.3 From 61dddd0442c0e3c792cf90368c00681051b381a5 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 18 Mar 2006 09:33:33 +0100 Subject: Fixed #111, Jabber away states get set correctly at connect-time now. --- protocols/jabber/jabber.c | 5 +---- protocols/msn/msn_util.c | 8 -------- protocols/nogaim.c | 4 +++- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index ba652b8a..224762ce 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -1231,9 +1231,7 @@ static void jabber_handleroster(gjconn gjc, xmlnode querynode) x = xmlnode_get_nextsibling(x); } - x = jutil_presnew(0, NULL, "Online"); - gjab_send(gjc, x); - xmlnode_free(x); + account_online(GJ_GC(gjc)); } static void jabber_handleauthresp(gjconn gjc, jpacket p) @@ -1249,7 +1247,6 @@ static void jabber_handleauthresp(gjconn gjc, jpacket p) gjab_auth(gjc); } else { gjab_reqroster(gjc); - account_online(GJ_GC(gjc)); ((struct jabber_data *)GJ_GC(gjc)->proto_data)->did_import = TRUE; } diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index e5f0b2c9..c2d840b1 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -50,14 +50,6 @@ int msn_logged_in( struct gaim_connection *gc ) account_online( gc ); - /* account_online() sets an away state if there is any, so only - execute this code if we're not away. */ - if( md->away_state == msn_away_state_list ) - { - g_snprintf( buf, sizeof( buf ), "CHG %d %s %d\r\n", ++md->trId, md->away_state->code, 0 ); - return( msn_write( gc, buf, strlen( buf ) ) ); - } - return( 0 ); } diff --git a/protocols/nogaim.c b/protocols/nogaim.c index b0c357db..24b74dc9 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -363,7 +363,9 @@ void account_online( struct gaim_connection *gc ) gc->keepalive = g_timeout_add( 60000, send_keepalive, gc ); gc->flags |= OPT_LOGGED_IN; - if( u && u->away ) proto_away( gc, u->away ); + /* Also necessary when we're not away, at least for some of the + protocols. */ + proto_away( gc, u->away ); if( strcmp( gc->prpl->name, "ICQ" ) == 0 ) { -- cgit v1.2.3 From 42d957194cdf8a3437d7d12e50b2c9d33f98b4d3 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 18 Mar 2006 10:10:44 +0100 Subject: Stupid warnings. :-P --- protocols/msn/msn_util.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index c2d840b1..5cda9f1c 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -45,9 +45,6 @@ int msn_write( struct gaim_connection *gc, char *s, int len ) int msn_logged_in( struct gaim_connection *gc ) { - struct msn_data *md = gc->proto_data; - char buf[1024]; - account_online( gc ); return( 0 ); -- cgit v1.2.3 From 82898afe3d659db4fc921aa22a1b21fddd7b2fd0 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 18 Mar 2006 10:10:57 +0100 Subject: Added the IRC VERSION command. --- irc_commands.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/irc_commands.c b/irc_commands.c index f2c7a645..01b01dfb 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -510,6 +510,11 @@ static void irc_cmd_pong( irc_t *irc, char **cmd ) irc->pinging = 0; } +static void irc_cmd_version( irc_t *irc, char **cmd ) +{ + irc_reply( irc, 351, "bitlbee-%s. %s :%s/%s ", BITLBEE_VERSION, irc->myhost, ARCH, CPU ); +} + static void irc_cmd_completions( irc_t *irc, char **cmd ) { user_t *u = user_find( irc, irc->mynick ); @@ -567,6 +572,7 @@ static const command_t irc_commands[] = { { "ns", 1, irc_cmd_nickserv, IRC_CMD_LOGGED_IN }, { "motd", 0, irc_cmd_motd, IRC_CMD_LOGGED_IN }, { "pong", 0, irc_cmd_pong, IRC_CMD_LOGGED_IN }, + { "version", 0, irc_cmd_version, IRC_CMD_LOGGED_IN }, { "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 }, -- cgit v1.2.3 From bc736cfadae460de29553ec0f9bb6e452dfe407d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 21 Mar 2006 09:00:12 +0100 Subject: Basic handling of LSG responses. --- protocols/msn/msn.h | 5 ++++- protocols/msn/ns.c | 43 ++++++++++++++++++------------------------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index 9727c537..0cd174f2 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -65,8 +65,11 @@ struct msn_data GSList *msgq; GSList *switchboards; - int buddycount; const struct msn_away_state *away_state; + + int buddycount; + int groupcount; + char **grouplist; }; struct msn_switchboard diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 4ced58a0..57212910 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -256,6 +256,9 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts == 5 ) { md->buddycount = atoi( cmd[3] ); + md->groupcount = atoi( cmd[4] ); + if( md->groupcount > 0 ) + md->grouplist = g_new0( char *, md->groupcount ); if( !*cmd[3] || md->buddycount == 0 ) msn_logged_in( gc ); @@ -268,18 +271,6 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) msn_logged_in( gc ); } } - else if( strcmp( cmd[0], "GTC" ) == 0 ) - { - } - else if( strcmp( cmd[0], "BLP" ) == 0 ) - { - } - else if( strcmp( cmd[0], "PRP" ) == 0 ) - { - } - else if( strcmp( cmd[0], "LSG" ) == 0 ) - { - } else if( strcmp( cmd[0], "LST" ) == 0 ) { int list; @@ -326,11 +317,22 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } } } - else if( strcmp( cmd[0], "BPR" ) == 0 ) - { - } - else if( strcmp( cmd[0], "CHG" ) == 0 ) + else if( strcmp( cmd[0], "LSG" ) == 0 ) { + int num; + + if( num_parts != 4 ) + { + hide_login_progress_error( gc, "Syntax error" ); + signoff( gc ); + return( 0 ); + } + + http_decode( cmd[2] ); + num = atoi( cmd[1] ); + + if( num < md->groupcount ) + md->grouplist[num] = g_strdup( cmd[2] ); } else if( strcmp( cmd[0], "CHL" ) == 0 ) { @@ -356,12 +358,6 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) return( msn_write( gc, buf, strlen( buf ) ) ); } - else if( strcmp( cmd[0], "QRY" ) == 0 ) - { - } - else if( strcmp( cmd[0], "QNG" ) == 0 ) - { - } else if( strcmp( cmd[0], "ILN" ) == 0 ) { const struct msn_away_state *st; @@ -478,9 +474,6 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) msn_buddy_ask( gc, cmd[4], cmd[5] ); } } - else if( strcmp( cmd[0], "REM" ) == 0 ) - { - } else if( strcmp( cmd[0], "OUT" ) == 0 ) { if( cmd[1] && strcmp( cmd[1], "OTH" ) == 0 ) -- cgit v1.2.3 From 1ad104ab06fe3f7db1b55cc178e92e43cbda9d95 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 21 Mar 2006 09:11:10 +0100 Subject: ns.c now passess the first group a buddy is in. --- protocols/msn/ns.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 57212910..90d525ef 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -287,7 +287,13 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( list & 1 ) /* FL */ { - add_buddy( gc, NULL, cmd[1], cmd[2] ); + char *group = NULL; + int num; + + if( cmd[4] != NULL && sscanf( cmd[4], "%d", &num ) == 1 ) + group = md->grouplist[num]; + + add_buddy( gc, group, cmd[1], cmd[2] ); } if( list & 2 ) /* AL */ { -- cgit v1.2.3 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) --- irc.h | 2 +- protocols/oscar/oscar.c | 2 +- query.c | 12 +++++++++++- root_commands.c | 41 +++++++++++++++++++++++++++++------------ 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/irc.h b/irc.h index 5c53273a..86721058 100644 --- a/irc.h +++ b/irc.h @@ -32,7 +32,7 @@ #define IRC_LOGIN_TIMEOUT 60 #define IRC_PING_STRING "PinglBee" -#define UMODES "iasw" +#define UMODES "abisw" #define UMODES_PRIV "Ro" #define CMODES "nt" #define CMODE "t" diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 7f5c0fc3..97384afb 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -1149,7 +1149,7 @@ static void gaim_icq_authask(struct gaim_connection *gc, guint32 uin, char *msg) if (strlen(msg) > 6) reason = msg + 6; - dialog_msg = g_strdup_printf("The user %u wants to add you to their buddy list for the following reason:\n\n%s", uin, reason ? reason : "No reason given."); + dialog_msg = g_strdup_printf("The user %u wants to add you to their buddy list for the following reason: %s", uin, reason ? reason : "No reason given."); data->gc = gc; data->uin = uin; do_ask_dialog(gc, dialog_msg, data, gaim_icq_authgrant, gaim_icq_authdeny); diff --git a/query.c b/query.c index 670dde36..eb2f45df 100644 --- a/query.c +++ b/query.c @@ -39,6 +39,17 @@ query_t *query_add( irc_t *irc, struct gaim_connection *gc, char *question, void q->no = no; q->data = data; + if( strchr( irc->umode, 'b' ) != NULL ) + { + char *s; + + /* At least for the machine-parseable version, get rid of + newlines to make "parsing" easier. */ + for( s = q->question; *s; s ++ ) + if( *s == '\r' || *s == '\n' ) + *s = ' '; + } + if( irc->queries ) { query_t *l = irc->queries; @@ -126,7 +137,6 @@ void query_answer( irc_t *irc, query_t *q, int ans ) q = query_default( irc ); disp = 1; } - //Using irc_usermsg instead of serv_got_crap because \x02A is a char too, so a SPACE is needed. if( ans ) { q->yes( NULL, q->data ); 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 19a6c756bd064e8955f1a733c4e71f9c41bba36c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 21 Mar 2006 09:19:01 +0100 Subject: Added Hidden and Invisible to the away state aliases list. --- protocols/nogaim.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 24b74dc9..1ea68358 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -38,7 +38,7 @@ #include #include -static char *proto_away_alias[7][5] = +static char *proto_away_alias[8][5] = { { "Away from computer", "Away", "Extended away", NULL }, { "NA", "N/A", "Not available", NULL }, @@ -46,6 +46,7 @@ static char *proto_away_alias[7][5] = { "Be right back", "BRB", NULL }, { "On the phone", "Phone", "On phone", NULL }, { "Out to lunch", "Lunch", "Food", NULL }, + { "Invisible", "Hidden" }, { NULL } }; static char *proto_away_alias_find( GList *gcm, char *away ); -- 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(-) 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 7b07dc6cae23180e8a06b8663ced71fb4ace7775 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 21 Mar 2006 09:36:10 +0100 Subject: Fixed ugliness in serv_got_crap(). --- protocols/nogaim.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 1ea68358..f9ee8a55 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -305,7 +305,7 @@ void hide_login_progress_error( struct gaim_connection *gc, char *msg ) void serv_got_crap( struct gaim_connection *gc, char *format, ... ) { va_list params; - char text[1024], buf[1024], acc_id[33]; + char text[1024], buf[1024], *acc_id; char *msg; account_t *a; @@ -330,11 +330,13 @@ void serv_got_crap( struct gaim_connection *gc, char *format, ... ) /* If we found one, add the screenname to the acc_id. */ if( a ) - g_snprintf( acc_id, 32, "%s(%s)", gc->prpl->name, gc->username ); + acc_id = g_strdup_printf( "%s(%s)", gc->prpl->name, gc->username ); else - g_snprintf( acc_id, 32, "%s", gc->prpl->name ); + acc_id = g_strdup( gc->prpl->name ); irc_usermsg( gc->irc, "%s - %s", acc_id, msg ); + + g_free( acc_id ); } static gboolean send_keepalive( gpointer d ) -- cgit v1.2.3 From 9b8efab1327b0263871fd95fc8612a21c7bb2389 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 21 Mar 2006 09:38:15 +0100 Subject: Updated documentation for the new block/allow syntax. Yes, it's slightly ambiguous now, but it shouldn't cause problems. --- doc/user-guide/commands.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index b04a6b0a..fd803801 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -196,11 +196,16 @@ Block someone block <nick> block <connection> <handle> + block <connection> Puts the specified user on your ignore list. Either specify the user's nick when you have him/her in your contact list or a connection number and a user handle. + + + When called with only a connection specification as an argument, the command displays the current block list for that connection. + @@ -213,6 +218,10 @@ Reverse of block. Unignores the specified user or user handle on specified connection. + + + When called with only a connection specification as an argument, the command displays the current allow list for that connection. + -- 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(-) 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 9b8a38bfa9a89e9741521ac522927c80b68976cf Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 22 Mar 2006 19:22:41 +0100 Subject: Buddy group data is now stored in the user_t structure. --- protocols/nogaim.c | 1 + user.h | 1 + 2 files changed, 2 insertions(+) diff --git a/protocols/nogaim.c b/protocols/nogaim.c index f9ee8a55..28f76fff 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -525,6 +525,7 @@ void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *rea u->gc = gc; u->handle = g_strdup( handle ); + if( group ) u->group = g_strdup( group ); u->send_handler = buddy_send_handler; u->last_typing_notice = 0; } diff --git a/user.h b/user.h index da657a4d..b8896d92 100644 --- a/user.h +++ b/user.h @@ -36,6 +36,7 @@ typedef struct __USER char online; char *handle; + char *group; struct gaim_connection *gc; char *sendbuf; -- cgit v1.2.3