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 +- protocols/jabber/conference.c | 21 +++++++++++++++++++++ protocols/jabber/jabber.c | 16 +++++++++++++++- protocols/jabber/jabber.h | 1 + protocols/msn/msn.c | 2 +- protocols/oscar/oscar.c | 2 +- protocols/yahoo/yahoo.c | 2 +- 7 files changed, 41 insertions(+), 5 deletions(-) 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; } diff --git a/protocols/jabber/conference.c b/protocols/jabber/conference.c index c5bc0e68..074412ec 100644 --- a/protocols/jabber/conference.c +++ b/protocols/jabber/conference.c @@ -175,6 +175,27 @@ int jabber_chat_leave( struct groupchat *c, const char *reason ) return 1; } +void jabber_chat_invite( struct groupchat *c, char *who, char *message ) +{ + struct xt_node *node; + struct im_connection *ic = c->ic; + struct jabber_chat *jc = c->data; + + node = xt_new_node( "reason", message, NULL ); + + node = xt_new_node( "invite", NULL, node ); + xt_add_attr( node, "to", who ); + + node = xt_new_node( "x", NULL, node ); + xt_add_attr( node, "xmlns", XMLNS_MUC_USER ); + + node = jabber_make_packet( "message", NULL, jc->name, node ); + + jabber_write_packet( ic, node ); + + xt_free_node( node ); +} + /* Not really the same syntax as the normal pkt_ functions, but this isn't called by the xmltree parser directly and this way I can add some extra parameters so we won't have to repeat too many things done by the caller diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index e2a3a27a..4c89ab5c 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -426,6 +426,20 @@ static void jabber_chat_leave_( struct groupchat *c ) jabber_chat_leave( c, NULL ); } +static void jabber_chat_invite_( struct groupchat *c, char *who, char *msg ) +{ + struct jabber_chat *jc = c->data; + gchar *msg_alt = NULL; + + if( msg == NULL ) + msg_alt = g_strdup_printf( "%s invited you to %s", c->ic->acc->user, jc->name ); + + if( c && who ) + jabber_chat_invite( c, who, msg ? msg : msg_alt ); + + g_free( msg_alt ); +} + static void jabber_keepalive( struct im_connection *ic ) { /* Just any whitespace character is enough as a keepalive for XMPP sessions. */ @@ -497,7 +511,7 @@ void jabber_initmodule() ret->remove_buddy = jabber_remove_buddy; ret->chat_msg = jabber_chat_msg_; ret->chat_topic = jabber_chat_topic_; -// ret->chat_invite = jabber_chat_invite; + ret->chat_invite = jabber_chat_invite_; ret->chat_leave = jabber_chat_leave_; ret->chat_join = jabber_chat_join_; ret->keepalive = jabber_keepalive; diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 94d017d6..56056534 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -236,5 +236,6 @@ int jabber_chat_topic( struct groupchat *c, char *topic ); int jabber_chat_leave( struct groupchat *c, const char *reason ); void jabber_chat_pkt_presence( struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node ); void jabber_chat_pkt_message( struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node ); +void jabber_chat_invite( struct groupchat *c, char *who, char *message ); #endif diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index df04e30d..aa05dbdd 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -240,7 +240,7 @@ static void msn_chat_msg( struct groupchat *c, char *message, int flags ) already severely broken) disappeared here! */ } -static void msn_chat_invite( struct groupchat *c, char *msg, char *who ) +static void msn_chat_invite( struct groupchat *c, char *who, char *message ) { struct msn_switchboard *sb = msn_sb_by_chat( c ); char buf[1024]; diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 96983738..8d45acf0 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -2508,7 +2508,7 @@ void oscar_chat_msg(struct groupchat *c, char *message, int msgflags) /* return (ret >= 0); */ } -void oscar_chat_invite(struct groupchat *c, char *message, char *who) +void oscar_chat_invite(struct groupchat *c, char *who, char *message) { struct im_connection *ic = c->ic; struct oscar_data * od = (struct oscar_data *)ic->proto_data; diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 28a72877..625f3d1c 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -305,7 +305,7 @@ static void byahoo_chat_msg( struct groupchat *c, char *message, int flags ) yahoo_conference_message( yd->y2_id, NULL, c->data, c->title, message, 1 ); } -static void byahoo_chat_invite( struct groupchat *c, char *msg, char *who ) +static void byahoo_chat_invite( struct groupchat *c, char *who, char *msg ) { struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; -- cgit v1.2.3 From 3f2bc2d721c1ac3d6c11a88a350041c2166f71e7 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 9 Dec 2007 23:23:03 +0000 Subject: If I keep forgetting to credit people in commit msgs I should probably add them to doc/CREDITS. Shouldn't be using bzr uncommit all the time. ;-( --- doc/CREDITS | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/CREDITS b/doc/CREDITS index f805c251..d53f6de0 100644 --- a/doc/CREDITS +++ b/doc/CREDITS @@ -54,6 +54,7 @@ The authors thank the following people: - Ed Schouten, for reporting bugs. - Greg (gropeep.org), for updating the Yahoo! module to fix some issues that were there for quite some time already. +- misc@mandriva.org for lots of Jabber contributions. - And all other users who help us by sending useful bug reports, positive feedback, nice patches and cool addons. Mentioning you all would make -- cgit v1.2.3 From 71dc8543dc4eeafabbe28bae52ec1d05ce9f5fea Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 10 Dec 2007 22:33:08 +0000 Subject: Fixed "set xxx" syntax (it showed all settings instead of just xxx). --- root_commands.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/root_commands.c b/root_commands.c index 642f5374..2a5938e7 100644 --- a/root_commands.c +++ b/root_commands.c @@ -402,9 +402,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 +742,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 +754,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 0f47613a39ad1b5d22d187e63c80c2f70702c217 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 10 Dec 2007 22:57:13 +0000 Subject: Don't allow nicks that start with a number. --- nick.c | 19 ++++++++++++++----- tests/check_nick.c | 12 +++++++++--- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/nick.c b/nick.c index 88c3faea..4b05f4a7 100644 --- a/nick.c +++ b/nick.c @@ -153,10 +153,10 @@ void nick_del( account_t *acc, const char *handle ) /* Character maps, _lc_[x] == _uc_[x] (but uppercase), according to the RFC's. With one difference, we allow dashes. */ -static char *nick_lc_chars = "0123456789abcdefghijklmnopqrstuvwxyz{}^-_|"; -static char *nick_uc_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[]~-_\\"; +static char *nick_lc_chars = "0123456789abcdefghijklmnopqrstuvwxyz{}^`-_|"; +static char *nick_uc_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[]~`-_\\"; -void nick_strip( char * nick ) +void nick_strip( char *nick ) { int i, j; @@ -169,6 +169,15 @@ void nick_strip( char * nick ) j++; } } + if( isdigit( nick[0] ) ) + { + char *orig; + + orig = g_strdup( nick ); + g_snprintf( nick, MAX_NICK_LENGTH, "_%s", orig ); + g_free( orig ); + j ++; + } while( j <= MAX_NICK_LENGTH ) nick[j++] = '\0'; } @@ -177,8 +186,8 @@ int nick_ok( const char *nick ) { const char *s; - /* Empty/long nicks are not allowed */ - if( !*nick || strlen( nick ) > MAX_NICK_LENGTH ) + /* Empty/long nicks are not allowed, nor numbers at [0] */ + if( !*nick || isdigit( nick[0] ) || strlen( nick ) > MAX_NICK_LENGTH ) return( 0 ); for( s = nick; *s; s ++ ) diff --git a/tests/check_nick.c b/tests/check_nick.c index 714c4fdc..6c4267cd 100644 --- a/tests/check_nick.c +++ b/tests/check_nick.c @@ -14,11 +14,17 @@ START_TEST(test_nick_strip) "thisisaveryveryveryverylongnick", "thisisave:ryveryveryverylongnick", "t::::est", + "test123", + "123test", + "123", NULL }; const char *expected[] = { "test", "test", "test", "thisisaveryveryveryveryl", "thisisaveryveryveryveryl", "test", + "test123", + "_123test", + "_123", NULL }; for (i = 0; get[i]; i++) { @@ -34,8 +40,8 @@ END_TEST START_TEST(test_nick_ok_ok) { - const char *nicks[] = { "foo", "bar", "bla[", "blie]", - "BreEZaH", "\\od^~", NULL }; + const char *nicks[] = { "foo", "bar123", "bla[", "blie]", "BreEZaH", + "\\od^~", "_123", "_123test", NULL }; int i; for (i = 0; nicks[i]; i++) { @@ -48,7 +54,7 @@ END_TEST START_TEST(test_nick_ok_notok) { const char *nicks[] = { "thisisaveryveryveryveryveryveryverylongnick", - "\nillegalchar", "", "nick%", NULL }; + "\nillegalchar", "", "nick%", "123test", NULL }; int i; for (i = 0; nicks[i]; i++) { -- cgit v1.2.3 From d52111a7b05657e4a4fa8417e6655389a50769cf Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 12 Dec 2007 21:36:33 +0000 Subject: Fixed sockerr_again() usage in Jabber module to (hopefully) fix a 100% CPU usage bug. --- lib/misc.c | 10 ++++++++++ lib/misc.h | 2 ++ protocols/jabber/io.c | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/misc.c b/lib/misc.c index c977029f..d6795ec9 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -44,6 +44,8 @@ #include #endif +#include "ssl_client.h" + void strip_linefeed(gchar *text) { int i, j; @@ -590,3 +592,11 @@ char *word_wrap( char *msg, int line_len ) return g_string_free( ret, FALSE ); } + +gboolean ssl_sockerr_again( void *ssl ) +{ + if( ssl ) + return ssl_errno == SSL_AGAIN; + else + return sockerr_again(); +} diff --git a/lib/misc.h b/lib/misc.h index 1d76f7f2..e0468d73 100644 --- a/lib/misc.h +++ b/lib/misc.h @@ -65,4 +65,6 @@ G_MODULE_EXPORT struct ns_srv_reply *srv_lookup( char *service, char *protocol, G_MODULE_EXPORT char *word_wrap( char *msg, int line_len ); +G_MODULE_EXPORT gboolean ssl_sockerr_again( void *ssl ); + #endif diff --git a/protocols/jabber/io.c b/protocols/jabber/io.c index 61cd142e..29561b86 100644 --- a/protocols/jabber/io.c +++ b/protocols/jabber/io.c @@ -119,7 +119,7 @@ static gboolean jabber_write_queue( struct im_connection *ic ) return TRUE; } - else if( st == 0 || ( st < 0 && !sockerr_again() ) ) + else if( st == 0 || ( st < 0 && !ssl_sockerr_again( jd->ssl ) ) ) { /* Set fd to -1 to make sure we won't write to it anymore. */ closesocket( jd->fd ); /* Shouldn't be necessary after errors? */ @@ -230,7 +230,7 @@ static gboolean jabber_read_callback( gpointer data, gint fd, b_input_condition } } } - else if( st == 0 || ( st < 0 && !sockerr_again() ) ) + else if( st == 0 || ( st < 0 && !ssl_sockerr_again( jd->ssl ) ) ) { closesocket( jd->fd ); jd->fd = -1; -- cgit v1.2.3 From 30ce1ced040c44c528d0a6e6e9c6b10a1caf1052 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 12 Dec 2007 23:30:51 +0000 Subject: Killed the parameter to "account add" and changed the default server for OSCAR to what both login.icq.com and login.oscar.aol.com resolve to these days. There's no need to specify a server anymore so why bother. And cleaned up the docs (removed all references to those OSCAR servers). --- account.c | 7 ++++++- doc/user-guide/commands.xml | 12 ++++++------ doc/user-guide/quickstart.xml | 4 ++-- protocols/oscar/aim.h | 2 +- protocols/oscar/oscar.c | 26 ++++---------------------- root_commands.c | 8 ++++++-- 6 files changed, 25 insertions(+), 34 deletions(-) diff --git a/account.c b/account.c index 388d04d0..4eb78faa 100644 --- a/account.c +++ b/account.c @@ -94,10 +94,15 @@ char *set_eval_account( set_t *set, char *value ) { g_free( acc->server ); if( *value ) + { acc->server = g_strdup( value ); + return value; + } else + { acc->server = NULL; - return value; + return g_strdup( set->def ); + } } else if( strcmp( set->key, "auto_connect" ) == 0 ) { diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index ac9bdf11..b4efd967 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -16,7 +16,7 @@ - account add <protocol> <username> <password> [<server>] + account add <protocol> <username> <password> @@ -25,7 +25,7 @@ - account add jabber <handle@server.tld> <password> [<servertag>] + account add jabber <handle@server.tld> <password> @@ -49,16 +49,16 @@ - account add oscar <handle> <password> [<servername>] + account add oscar <handle> <password> - Specifying a server is required for OSCAR, since OSCAR can be used for both ICQ- and AIM-connections. Although these days it's supposed to be possible to connect to ICQ via AIM-servers and vice versa, we like to stick with this separation for now. For ICQ connections, the servername is login.icq.com, for AIM connections it's login.oscar.aol.com. + OSCAR is the protocol used to connect to AIM and/or ICQ. The servers will automatically detect if you're using a numeric or non-numeric username so there's no need to tell which network you want to connect to. - account add oscar 72696705 hobbelmeeuw login.icq.com + account add oscar 72696705 hobbelmeeuw Account successfully added @@ -594,7 +594,7 @@ - Can be set for Jabber- and OSCAR-connections. For OSCAR, this must be set to login.icq.com if it's an ICQ connection, or login.oscar.aol.com if it's an AIM connection. For Jabber, you have to set this if the servername isn't equal to the part after the @ in the Jabber handle. + Can be set for Jabber- and OSCAR-connections. For Jabber, you might have to set this if the servername isn't equal to the part after the @ in the Jabber handle. For OSCAR this shouldn't be necessary anymore in recent BitlBee versions. diff --git a/doc/user-guide/quickstart.xml b/doc/user-guide/quickstart.xml index 520f240f..fcb06c6b 100644 --- a/doc/user-guide/quickstart.xml +++ b/doc/user-guide/quickstart.xml @@ -37,12 +37,12 @@ For instance, suppose you have an ICQ account with UIN 72696705 - account add oscar 72696705 QuickStart login.icq.com + account add jabber bitlbee@jabber.org QuickStart Account successfully added -Other available IM protocols are jabber, msn, and yahoo. Oscar is the protocol used by ICQ and AOL. For oscar, you need to specify the IM-server as a fourth argument (for msn and yahoo there is no fourth argument). For AOL Instant Messenger, the server name is login.oscar.aol.com. For ICQ, the server name is login.icq.com. +Other available IM protocols are msn, oscar, and yahoo. Oscar is the protocol used by ICQ and AOL. diff --git a/protocols/oscar/aim.h b/protocols/oscar/aim.h index 81ea5f9e..9516996c 100644 --- a/protocols/oscar/aim.h +++ b/protocols/oscar/aim.h @@ -93,7 +93,7 @@ typedef guint16 flap_seqnum_t; * the client to connect to it. * */ -#define AIM_DEFAULT_LOGIN_SERVER "login.oscar.aol.com" +#define AIM_DEFAULT_LOGIN_SERVER "login.messaging.aol.com" #define AIM_LOGIN_PORT 5190 /* diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 8d45acf0..c4683046 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -340,7 +340,7 @@ static void oscar_init(account_t *acc) { set_t *s; - s = set_add( &acc->set, "server", NULL, set_eval_account, acc ); + s = set_add( &acc->set, "server", AIM_DEFAULT_LOGIN_SERVER, set_eval_account, acc ); s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; if (isdigit(acc->user[0])) { @@ -355,15 +355,7 @@ static void oscar_login(account_t *acc) { struct im_connection *ic = imcb_new(acc); struct oscar_data *odata = ic->proto_data = g_new0(struct oscar_data, 1); - if (isdigit(acc->user[0])) { - odata->icq = TRUE; - /* 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... */ - /* ic->acc->pass[8] = 0; - Not touching this anymore now that it belongs to account_t! - Let's hope nothing will break. ;-) */ - } else { + if (!isdigit(acc->user[0])) { ic->flags |= OPT_DOES_HTML; } @@ -384,24 +376,14 @@ static void oscar_login(account_t *acc) { return; } - if (acc->server == NULL) { - imcb_error(ic, "No servername specified"); - imc_logout(ic, FALSE); - return; - } - - if (g_strcasecmp(acc->server, "login.icq.com") != 0 && - g_strcasecmp(acc->server, "login.oscar.aol.com") != 0) { - imcb_log(ic, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails.",acc->server); - } - imcb_log(ic, _("Signon: %s"), ic->acc->user); aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); conn->status |= AIM_CONN_STATUS_INPROGRESS; - conn->fd = proxy_connect(acc->server, AIM_LOGIN_PORT, oscar_login_connect, ic); + conn->fd = proxy_connect(set_getstr(&acc->set, "server"), + AIM_LOGIN_PORT, oscar_login_connect, ic); if (conn->fd < 0) { imcb_error(ic, _("Couldn't connect to host")); imc_logout(ic, TRUE); diff --git a/root_commands.c b/root_commands.c index 2a5938e7..dc70feb4 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." ); } } } -- cgit v1.2.3 From 3e79889dceeac1432156dc5fb6ae4a1f20b86d69 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 12 Dec 2007 23:57:49 +0000 Subject: Checking conn->xcred before trying to clean it up since GnuTLS doesn't seem to check for NULL pointers here. (Closes #257) --- lib/ssl_gnutls.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ssl_gnutls.c b/lib/ssl_gnutls.c index 221a2862..b964ab49 100644 --- a/lib/ssl_gnutls.c +++ b/lib/ssl_gnutls.c @@ -222,8 +222,10 @@ void ssl_disconnect( void *conn_ ) closesocket( conn->fd ); - gnutls_deinit( conn->session ); - gnutls_certificate_free_credentials( conn->xcred ); + if( conn->session ) + gnutls_deinit( conn->session ); + if( conn->xcred ) + gnutls_certificate_free_credentials( conn->xcred ); g_free( conn ); } -- cgit v1.2.3 From 529078a3e7f701c7b85201380b2d2097ac676ec6 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 16 Dec 2007 16:35:38 +0000 Subject: Implemented XEP-0199 (patch from misc@mandriva.org). --- protocols/jabber/iq.c | 12 +++++++++++- protocols/jabber/jabber.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c index 3dae39f6..069e3af3 100644 --- a/protocols/jabber/iq.c +++ b/protocols/jabber/iq.c @@ -49,7 +49,8 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ) } else if( strcmp( type, "get" ) == 0 ) { - if( !( c = xt_find_node( node->children, "query" ) ) || + if( !( ( c = xt_find_node( node->children, "query" ) ) || + ( c = xt_find_node( node->children, "ping" ) ) ) || /* O_o WHAT is wrong with just ????? */ !( s = xt_find_attr( c, "xmlns" ) ) ) { imcb_log( ic, "WARNING: Received incomplete IQ-%s packet", type ); @@ -80,12 +81,21 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ) strftime( buf, sizeof( buf ) - 1, "%Z", localtime( &time_ep ) ); xt_add_child( reply, xt_new_node( "tz", buf, NULL ) ); } + else if( strcmp( s, XMLNS_PING ) == 0 ) + { + xt_free_node( reply ); + reply = jabber_make_packet( "iq", "result", xt_find_attr( node, "from" ), NULL ); + if( ( s = xt_find_attr( node, "id" ) ) ) + xt_add_attr( reply, "id", s ); + pack = 0; + } else if( strcmp( s, XMLNS_DISCOVER ) == 0 ) { const char *features[] = { XMLNS_VERSION, XMLNS_TIME, XMLNS_CHATSTATES, XMLNS_MUC, + XMLNS_PING, NULL }; const char **f; diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 56056534..f673ee0d 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -151,6 +151,7 @@ struct jabber_chat #define XMLNS_AUTH "jabber:iq:auth" /* XEP-0078 */ #define XMLNS_VERSION "jabber:iq:version" /* XEP-0092 */ #define XMLNS_TIME "jabber:iq:time" /* XEP-0090 */ +#define XMLNS_PING "urn:xmpp:ping" /* XEP-0199 */ #define XMLNS_VCARD "vcard-temp" /* XEP-0054 */ #define XMLNS_DELAY "jabber:x:delay" /* XEP-0091 */ #define XMLNS_CHATSTATES "http://jabber.org/protocol/chatstates" /* 0085 */ -- cgit v1.2.3 From fb4ebcc5e3cffc4683cd3f38d7aba6cd86dbcd50 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 28 Dec 2007 23:26:44 +0000 Subject: Added missing return in jabber_login(). --- protocols/jabber/jabber.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 4c89ab5c..264a0308 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -196,6 +196,8 @@ static void jabber_login( account_t *acc ) { imcb_error( ic, "Could not connect to server" ); imc_logout( ic, TRUE ); + + return; } if( set_getbool( &acc->set, "xmlconsole" ) ) -- cgit v1.2.3 From 6f7ac174bb8fbde5e07e1c7da3cf691ecb4e172b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 28 Dec 2007 23:27:45 +0000 Subject: Fixed return value check in proxy_connect(), since on some systems a non-blocking connect() can return immediately (when connecting to localhost, for example). Closes bug #233 and #340. --- lib/proxy.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/proxy.c b/lib/proxy.c index dff5d0a4..0e1c8f07 100644 --- a/lib/proxy.c +++ b/lib/proxy.c @@ -129,18 +129,17 @@ static int proxy_connect_none(const char *host, unsigned short port, struct PHB event_debug("proxy_connect_none( \"%s\", %d ) = %d\n", host, port, fd); - if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0) { - if (sockerr_again()) { - phb->inpa = b_input_add(fd, GAIM_INPUT_WRITE, gaim_io_connected, phb); - phb->fd = fd; - } else { - closesocket(fd); - g_free(phb); - return -1; - } + if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0 && !sockerr_again()) { + closesocket(fd); + g_free(phb); + + return -1; + } else { + phb->inpa = b_input_add(fd, GAIM_INPUT_WRITE, gaim_io_connected, phb); + phb->fd = fd; + + return fd; } - - return fd; } -- cgit v1.2.3 From debc281b8f35015c0491c3a34465f82289a0e919 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 31 Dec 2007 00:40:59 +0100 Subject: encode: md5.c is no longer in protocols/, it's in lib/ Fix build failure. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a9dd2e17..0a988feb 100644 --- a/Makefile +++ b/Makefile @@ -115,7 +115,7 @@ ifndef DEBUG endif encode: crypting.c - $(CC) crypting.c protocols/md5.c $(CFLAGS) -o encode -DCRYPTING_MAIN $(CFLAGS) $(EFLAGS) $(LFLAGS) + $(CC) crypting.c lib/md5.c $(CFLAGS) -o encode -DCRYPTING_MAIN $(CFLAGS) $(EFLAGS) $(LFLAGS) decode: encode cp encode decode -- cgit v1.2.3 From f394500c46003237373a47c5a1dcb4af16029e4d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 5 Jan 2008 15:00:15 +0000 Subject: Removed closure->result. I was planning to add some more stuff, but will do that later. --- lib/events_glib.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/events_glib.c b/lib/events_glib.c index 38938380..1198dba6 100644 --- a/lib/events_glib.c +++ b/lib/events_glib.c @@ -47,7 +47,6 @@ typedef struct _GaimIOClosure { b_event_handler function; - guint result; gpointer data; } GaimIOClosure; @@ -100,6 +99,7 @@ gint b_input_add(gint source, b_input_condition condition, b_event_handler funct GaimIOClosure *closure = g_new0(GaimIOClosure, 1); GIOChannel *channel; GIOCondition cond = 0; + int st; closure->function = function; closure->data = data; @@ -110,13 +110,13 @@ gint b_input_add(gint source, b_input_condition condition, b_event_handler funct cond |= GAIM_WRITE_COND; channel = g_io_channel_unix_new(source); - closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, - gaim_io_invoke, closure, gaim_io_destroy); + st = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, + gaim_io_invoke, closure, gaim_io_destroy); - event_debug( "b_input_add( %d, %d, 0x%x, 0x%x ) = %d (0x%x)\n", source, condition, function, data, closure->result, closure ); + event_debug( "b_input_add( %d, %d, 0x%x, 0x%x ) = %d (%p)\n", source, condition, function, data, st, closure ); g_io_channel_unref(channel); - return closure->result; + return st; } gint b_timeout_add(gint timeout, b_event_handler func, gpointer data) -- cgit v1.2.3 From 3585c5aa1770147dd4a75a5283793d7908573011 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 5 Jan 2008 19:03:02 +0000 Subject: Added handling of MSN switchboard NAK messages. Untested, but hey, it compiles! (And it's pretty trivial...) --- protocols/msn/sb.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c index cb9e2cab..557f4f16 100644 --- a/protocols/msn/sb.c +++ b/protocols/msn/sb.c @@ -490,6 +490,17 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts ) return( 0 ); } } + else if( strcmp( cmd[0], "NAK" ) == 0 ) + { + if( sb->who ) + { + imcb_log( ic, "The MSN servers could not deliver one of your messages to %s.", sb->who ); + } + else + { + imcb_log( ic, "The MSN servers could not deliver one of your groupchat messages to all participants." ); + } + } else if( strcmp( cmd[0], "BYE" ) == 0 ) { if( num_parts < 2 ) -- cgit v1.2.3 From 1febf5c93b231942cd9cac8ac6a5a0d830c581cc Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 5 Jan 2008 21:15:32 +0000 Subject: Added "mail_notifications" setting. Who needs those notifications anyway? Closes: #338. --- doc/user-guide/commands.xml | 11 +++++++++++ protocols/msn/msn.c | 2 ++ protocols/msn/ns.c | 4 ++-- protocols/yahoo/yahoo.c | 10 +++++++++- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index b4efd967..5a1e398c 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -474,6 +474,17 @@ + + false + + + + Some protocols (MSN, Yahoo!) can notify via IM about new e-mail. Since most people use their Hotmail/Yahoo! addresses as a spam-box, this is disabled default. If you want these notifications, you can enable this setting. + + + + + both both, root, user, none diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index aa05dbdd..192dda0a 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -34,6 +34,8 @@ static void msn_init( account_t *acc ) s = set_add( &acc->set, "display_name", NULL, msn_set_display_name, acc ); s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; + + s = set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); } static void msn_login( account_t *acc ) diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 9bd7f152..3735aad6 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -642,7 +642,7 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int char *inbox = msn_findheader( body, "Inbox-Unread:", blen ); char *folders = msn_findheader( body, "Folders-Unread:", blen ); - if( inbox && folders ) + if( inbox && folders && set_getbool( &ic->acc->set, "mail_notifications" ) ) { imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); } @@ -652,7 +652,7 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int char *from = msn_findheader( body, "From-Addr:", blen ); char *fromname = msn_findheader( body, "From:", blen ); - if( from && fromname ) + if( from && fromname && set_getbool( &ic->acc->set, "mail_notifications" ) ) { imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from ); } diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 625f3d1c..d413597a 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -126,6 +126,11 @@ static char *byahoo_strip( const char *in ) return( g_strndup( in, len ) ); } +static void byahoo_init( account_t *acc ) +{ + set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); +} + static void byahoo_login( account_t *acc ) { struct im_connection *ic = imcb_new( acc ); @@ -348,6 +353,7 @@ void byahoo_initmodule( ) { struct prpl *ret = g_new0(struct prpl, 1); ret->name = "yahoo"; + ret->init = byahoo_init; ret->login = byahoo_login; ret->keepalive = byahoo_keepalive; @@ -922,7 +928,9 @@ void ext_yahoo_mail_notify( int id, const char *from, const char *subj, int cnt { struct im_connection *ic = byahoo_get_ic_by_id( id ); - if( from && subj ) + if( !set_getbool( &ic->acc->set, "mail_notifications" ) ) + ; /* The user doesn't care. */ + else if( from && subj ) imcb_log( ic, "Received e-mail message from %s with subject `%s'", from, subj ); else if( cnt > 0 ) imcb_log( ic, "Received %d new e-mails", cnt ); -- cgit v1.2.3 From 46dca11bfad72bb9365b85b433f1e812733f31ec Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 6 Jan 2008 12:32:27 +0000 Subject: Changed warning message about unsent MSN messages. It should show the actual message(s) now. --- protocols/msn/msn.c | 16 +--------------- protocols/msn/msn.h | 1 + protocols/msn/msn_util.c | 34 ++++++++++++++++++++++++++++++++++ protocols/msn/sb.c | 41 ++++++----------------------------------- 4 files changed, 42 insertions(+), 50 deletions(-) diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index 192dda0a..a2e8519a 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -89,21 +89,7 @@ static void msn_logout( struct im_connection *ic ) while( md->switchboards ) msn_sb_destroy( md->switchboards->data ); - if( md->msgq ) - { - struct msn_message *m; - - for( l = md->msgq; l; l = l->next ) - { - m = l->data; - - imcb_log( ic, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who ); - g_free( m->who ); - g_free( m->text ); - g_free( m ); - } - g_slist_free( md->msgq ); - } + msn_msgq_purge( ic, &md->msgq ); while( md->groupcount > 0 ) g_free( md->grouplist[--md->groupcount] ); diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index 721466d6..746606a0 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -157,6 +157,7 @@ char *msn_findheader( char *text, char *header, int len ); char **msn_linesplit( char *line ); int msn_handler( struct msn_handler_data *h ); char *msn_http_encode( const char *input ); +void msn_msgq_purge( struct im_connection *ic, GSList **list ); /* tables.c */ const struct msn_away_state *msn_away_state_by_number( int number ); diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index c9eb5ee2..04ee799d 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -338,3 +338,37 @@ char *msn_http_encode( const char *input ) return ret; } + +void msn_msgq_purge( struct im_connection *ic, GSList **list ) +{ + struct msn_message *m; + GString *ret; + GSList *l; + + l = *list; + if( l == NULL ) + return; + + m = l->data; + ret = g_string_sized_new( 1024 ); + g_string_printf( ret, "WARNING: Cleaning up MSN (switchboard) connection with unsent " + "messages to %s:", m->who ? m->who : "unknown recipient" ); + + while( l ) + { + m = l->data; + + g_string_append_printf( ret, "\n%s", m->text ); + + g_free( m->who ); + g_free( m->text ); + g_free( m ); + + l = l->next; + } + g_slist_free( *list ); + *list = NULL; + + imcb_log( ic, ret->str ); + g_string_free( ret, TRUE ); +} diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c index 557f4f16..8c0afca6 100644 --- a/protocols/msn/sb.c +++ b/protocols/msn/sb.c @@ -127,7 +127,7 @@ int msn_sb_sendmessage( struct msn_switchboard *sb, char *text ) /* Build the message. Convert LF to CR-LF for normal messages. */ if( strcmp( text, TYPING_NOTIFICATION_MESSAGE ) != 0 ) { - buf = g_new0( char, sizeof( MSN_MESSAGE_HEADERS ) + strlen( text ) * 2 ); + buf = g_new0( char, sizeof( MSN_MESSAGE_HEADERS ) + strlen( text ) * 2 + 1 ); i = strlen( MSN_MESSAGE_HEADERS ); strcpy( buf, MSN_MESSAGE_HEADERS ); @@ -206,25 +206,7 @@ void msn_sb_destroy( struct msn_switchboard *sb ) debug( "Destroying switchboard: %s", sb->who ? sb->who : sb->key ? sb->key : "" ); - if( sb->msgq ) - { - struct msn_message *m; - GSList *l; - - for( l = sb->msgq; l; l = l->next ) - { - m = l->data; - - g_free( m->who ); - g_free( m->text ); - g_free( m ); - } - g_slist_free( sb->msgq ); - - imcb_log( ic, "Warning: Closing down MSN switchboard connection with " - "unsent message to %s, you'll have to resend it.", - sb->who ? sb->who : "(unknown)" ); - } + msn_msgq_purge( ic, &sb->msgq ); if( sb->key ) g_free( sb->key ); if( sb->who ) g_free( sb->who ); @@ -265,7 +247,7 @@ gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ) if( source != sb->fd ) { - debug( "ERROR %d while connecting to switchboard server", 1 ); + debug( "Error %d while connecting to switchboard server", 1 ); msn_sb_destroy( sb ); return FALSE; } @@ -286,7 +268,7 @@ gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ) if( msn_sb_write( sb, buf, strlen( buf ) ) ) sb->inp = b_input_add( sb->fd, GAIM_INPUT_READ, msn_sb_callback, sb ); else - debug( "ERROR %d while connecting to switchboard server", 2 ); + debug( "Error %d while connecting to switchboard server", 2 ); return FALSE; } @@ -297,7 +279,7 @@ static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition c if( msn_handler( sb->handler ) == -1 ) { - debug( "ERROR: Switchboard died" ); + debug( "Error: Switchboard died" ); msn_sb_destroy( sb ); return FALSE; @@ -554,24 +536,13 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts ) { if( sb->who ) { - struct msn_message *m; - GSList *l; - /* Apparently some invitation failed. We might want to use this board later, so keep it as a spare. */ g_free( sb->who ); sb->who = NULL; /* Also clear the msgq, otherwise someone else might get them. */ - for( l = sb->msgq; l; l = l->next ) - { - m = l->data; - g_free( m->who ); - g_free( m->text ); - g_free( m ); - } - g_slist_free( sb->msgq ); - sb->msgq = NULL; + msn_msgq_purge( ic, &sb->msgq ); } /* Do NOT return 0 here, we want to keep this sb. */ -- cgit v1.2.3 From 434627083613f016d432462fce73f728dd77172e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 6 Jan 2008 12:37:55 +0000 Subject: More consistency in error/warning errors. Until now "WARNING:" was usually in upper case while "Error:" wasn't .... that doesn't really make sense. --- configure | 2 +- irc.c | 2 +- nick.c | 2 +- protocols/jabber/iq.c | 12 ++++++------ protocols/jabber/jabber_util.c | 2 +- protocols/jabber/presence.c | 4 ++-- protocols/msn/msn_util.c | 2 +- protocols/oscar/service.c | 2 +- protocols/oscar/txqueue.c | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/configure b/configure index 15e22623..6f8d8ea6 100755 --- a/configure +++ b/configure @@ -453,7 +453,7 @@ else fi if [ "$protocols" = "PROTOCOLS = " ]; then - echo "WARNING: You haven't selected any communication protocol to compile!" + echo "Warning: You haven't selected any communication protocol to compile!" echo " BitlBee will run, but you will be unable to connect to IM servers!" fi diff --git a/irc.c b/irc.c index 01d4c47e..2b86aebb 100644 --- a/irc.c +++ b/irc.c @@ -325,7 +325,7 @@ void irc_process( irc_t *irc ) if( do_iconv( cs, "UTF-8", lines[i], conv, 0, IRC_MAX_LINE - 2 ) == -1 ) { if( irc->status & USTATUS_LOGGED_IN ) - irc_usermsg( irc, "ERROR: Charset mismatch detected. The charset " + irc_usermsg( irc, "Error: Charset mismatch detected. The charset " "setting is currently set to %s, so please make " "sure your IRC client will send and accept text in " "that charset, or tell BitlBee which charset to " diff --git a/nick.c b/nick.c index 4b05f4a7..52f9e5ad 100644 --- a/nick.c +++ b/nick.c @@ -110,7 +110,7 @@ void nick_dedupe( account_t *acc, const char *handle, char nick[MAX_NICK_LENGTH+ { int i; - irc_usermsg( acc->irc, "WARNING: Almost had an infinite loop in nick_get()! " + irc_usermsg( acc->irc, "Warning: Almost had an infinite loop in nick_get()! " "This used to be a fatal BitlBee bug, but we tried to fix it. " "This message should *never* appear anymore. " "If it does, please *do* send us a bug report! " diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c index 069e3af3..e1bab29e 100644 --- a/protocols/jabber/iq.c +++ b/protocols/jabber/iq.c @@ -53,7 +53,7 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ) ( c = xt_find_node( node->children, "ping" ) ) ) || /* O_o WHAT is wrong with just ????? */ !( s = xt_find_attr( c, "xmlns" ) ) ) { - imcb_log( ic, "WARNING: Received incomplete IQ-%s packet", type ); + imcb_log( ic, "Warning: Received incomplete IQ-%s packet", type ); return XT_HANDLED; } @@ -124,7 +124,7 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ) if( !( c = xt_find_node( node->children, "query" ) ) || !( s = xt_find_attr( c, "xmlns" ) ) ) { - imcb_log( ic, "WARNING: Received incomplete IQ-%s packet", type ); + imcb_log( ic, "Warning: Received incomplete IQ-%s packet", type ); return XT_HANDLED; } @@ -146,7 +146,7 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ) } else { - imcb_log( ic, "WARNING: %s tried to fake a roster push!", s ? s : "(unknown)" ); + imcb_log( ic, "Warning: %s tried to fake a roster push!", s ? s : "(unknown)" ); xt_free_node( reply ); reply = jabber_make_error_packet( node, "not-allowed", "cancel" ); @@ -211,7 +211,7 @@ static xt_status jabber_do_iq_auth( struct im_connection *ic, struct xt_node *no if( !( query = xt_find_node( node->children, "query" ) ) ) { - imcb_log( ic, "WARNING: Received incomplete IQ packet while authenticating" ); + imcb_log( ic, "Warning: Received incomplete IQ packet while authenticating" ); imc_logout( ic, FALSE ); return XT_HANDLED; } @@ -269,7 +269,7 @@ static xt_status jabber_finish_iq_auth( struct im_connection *ic, struct xt_node if( !( type = xt_find_attr( node, "type" ) ) ) { - imcb_log( ic, "WARNING: Received incomplete IQ packet while authenticating" ); + imcb_log( ic, "Warning: Received incomplete IQ packet while authenticating" ); imc_logout( ic, FALSE ); return XT_HANDLED; } @@ -345,7 +345,7 @@ static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node * if( !( query = xt_find_node( node->children, "query" ) ) ) { - imcb_log( ic, "WARNING: Received NULL roster packet" ); + imcb_log( ic, "Warning: Received NULL roster packet" ); return XT_HANDLED; } diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index 9d84e099..b84be49b 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -199,7 +199,7 @@ xt_status jabber_cache_handle_packet( struct im_connection *ic, struct xt_node * if( entry == NULL ) { - imcb_log( ic, "WARNING: Received %s-%s packet with unknown/expired ID %s!", + imcb_log( ic, "Warning: Received %s-%s packet with unknown/expired ID %s!", node->name, xt_find_attr( node, "type" ) ? : "(no type)", s ); } else if( entry->func ) diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c index c3d7dced..f2dca26c 100644 --- a/protocols/jabber/presence.c +++ b/protocols/jabber/presence.c @@ -49,7 +49,7 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) if( !( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) ) { if( set_getbool( &ic->irc->set, "debug" ) ) - imcb_log( ic, "WARNING: Could not handle presence information from JID: %s", from ); + imcb_log( ic, "Warning: Could not handle presence information from JID: %s", from ); return XT_HANDLED; } @@ -90,7 +90,7 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) if( ( bud = jabber_buddy_by_jid( ic, from, 0 ) ) == NULL ) { if( set_getbool( &ic->irc->set, "debug" ) ) - imcb_log( ic, "WARNING: Received presence information from unknown JID: %s", from ); + imcb_log( ic, "Warning: Received presence information from unknown JID: %s", from ); return XT_HANDLED; } diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index 04ee799d..fae2877d 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -351,7 +351,7 @@ void msn_msgq_purge( struct im_connection *ic, GSList **list ) m = l->data; ret = g_string_sized_new( 1024 ); - g_string_printf( ret, "WARNING: Cleaning up MSN (switchboard) connection with unsent " + g_string_printf( ret, "Warning: Cleaning up MSN (switchboard) connection with unsent " "messages to %s:", m->who ? m->who : "unknown recipient" ); while( l ) diff --git a/protocols/oscar/service.c b/protocols/oscar/service.c index 3a180780..acd09150 100644 --- a/protocols/oscar/service.c +++ b/protocols/oscar/service.c @@ -893,7 +893,7 @@ int aim_sendmemblock(aim_session_t *sess, aim_conn_t *conn, guint32 offset, guin aimbs_put32(&fr->data, 0xecf8427e); */ } else - imcb_error(sess->aux_data, "WARNING: unknown hash request"); + imcb_error(sess->aux_data, "Warning: unknown hash request"); } diff --git a/protocols/oscar/txqueue.c b/protocols/oscar/txqueue.c index 4416025a..d38986d0 100644 --- a/protocols/oscar/txqueue.c +++ b/protocols/oscar/txqueue.c @@ -79,7 +79,7 @@ static int aim_tx_enqueue__queuebased(aim_session_t *sess, aim_frame_t *fr) { if (!fr->conn) { - imcb_error(sess->aux_data, "WARNING: enqueueing packet with no connection"); + imcb_error(sess->aux_data, "Warning: enqueueing packet with no connection"); fr->conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS); } -- cgit v1.2.3 From 181e47a9693d56e4bc0cec65ec05fce6086aebe8 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 10 Jan 2008 00:31:38 +0000 Subject: Now setting odata->icq properly again, this got lost some time ago, which broke the info command and probably more things. --- protocols/oscar/oscar.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index c4683046..980beaca 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -355,9 +355,10 @@ static void oscar_login(account_t *acc) { struct im_connection *ic = imcb_new(acc); struct oscar_data *odata = ic->proto_data = g_new0(struct oscar_data, 1); - if (!isdigit(acc->user[0])) { + if (isdigit(acc->user[0])) + odata->icq = TRUE; + else ic->flags |= OPT_DOES_HTML; - } sess = g_new0(aim_session_t, 1); -- cgit v1.2.3 From e7311208511c391b4f55161b6be93dbffb381c5e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 11 Jan 2008 00:45:18 +0000 Subject: Adding own handle to protocol name in blist output for people with multiple accounts on the same IM network. --- root_commands.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/root_commands.c b/root_commands.c index dc70feb4..26a42a25 100644 --- a/root_commands.c +++ b/root_commands.c @@ -820,7 +820,7 @@ static void cmd_blist( irc_t *irc, char **cmd ) { if( online == 1 ) { - g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->ic->acc->prpl->name ); + 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, "Online" ); } @@ -831,7 +831,7 @@ static void cmd_blist( irc_t *irc, char **cmd ) { if( away == 1 ) { - g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->ic->acc->prpl->name ); + 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 ); } n_away ++; @@ -841,7 +841,7 @@ static void cmd_blist( irc_t *irc, char **cmd ) { if( offline == 1 ) { - g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->ic->acc->prpl->name ); + 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" ); } n_offline ++; -- cgit v1.2.3 From e7f8838951c81ba7edf6c6567cf68075de42be6e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 11 Jan 2008 13:17:11 +0000 Subject: Fixing bug #344, now away states should always be correct, even when people do complicated things with multiple resources. (There were two bugs and some duplicated code, so I moved things around a bit.) --- protocols/jabber/presence.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c index f2dca26c..3bfc83ff 100644 --- a/protocols/jabber/presence.c +++ b/protocols/jabber/presence.c @@ -29,8 +29,8 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) char *from = xt_find_attr( node, "from" ); char *type = xt_find_attr( node, "type" ); /* NULL should mean the person is online. */ struct xt_node *c; - struct jabber_buddy *bud; - int is_chat = 0, is_away = 0; + struct jabber_buddy *bud, *send_presence = NULL; + int is_chat = 0; char *s; if( !from ) @@ -62,8 +62,6 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) if( ( c = xt_find_node( node->children, "show" ) ) && c->text_len > 0 ) { bud->away_state = (void*) jabber_away_state_by_code( c->text ); - if( strcmp( c->text, "chat" ) != 0 ) - is_away = OPT_AWAY; } else { @@ -80,10 +78,8 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) if( is_chat ) jabber_chat_pkt_presence( ic, bud, node ); - else if( bud == jabber_buddy_by_jid( ic, bud->bare_jid, 0 ) ) - imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away, - ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL, - bud->away_message ); + else + send_presence = jabber_buddy_by_jid( ic, bud->bare_jid, 0 ); } else if( strcmp( type, "unavailable" ) == 0 ) { @@ -118,17 +114,7 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) /* If another resource is still available, send its presence information. */ - if( ( bud = jabber_buddy_by_jid( ic, from, 0 ) ) ) - { - if( bud->away_state && ( *bud->away_state->code == 0 || - strcmp( bud->away_state->code, "chat" ) == 0 ) ) - is_away = OPT_AWAY; - - imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away, - ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL, - bud->away_message ); - } - else + if( ( send_presence = jabber_buddy_by_jid( ic, from, 0 ) ) == NULL ) { /* Otherwise, count him/her as offline now. */ imcb_buddy_status( ic, from, 0, NULL, NULL ); @@ -176,6 +162,20 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) jabber_error_free( err ); } */ } + + if( send_presence ) + { + int is_away; + + if( send_presence->away_state && !( *send_presence->away_state->code == 0 || + strcmp( send_presence->away_state->code, "chat" ) == 0 ) ) + is_away = OPT_AWAY; + + imcb_buddy_status( ic, send_presence->bare_jid, OPT_LOGGED_IN | is_away, + ( is_away && send_presence->away_state ) ? + send_presence->away_state->full_name : NULL, + send_presence->away_message ); + } return XT_HANDLED; } -- cgit v1.2.3 From e64de00bf2d99962182243983e8c09decaa36eb4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 12 Jan 2008 00:24:46 +0000 Subject: Killed info_string_append() and now showing the IP address of ICQ users in the "info" command response. --- lib/misc.c | 6 -- lib/misc.h | 1 - protocols/oscar/oscar.c | 184 +++++++++++++++++++++++++++--------------------- 3 files changed, 102 insertions(+), 89 deletions(-) diff --git a/lib/misc.c b/lib/misc.c index d6795ec9..c2dd966e 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -244,12 +244,6 @@ char *escape_html( const char *html ) return( str ); } -void info_string_append(GString *str, char *newline, char *name, char *value) -{ - if( value && value[0] ) - g_string_sprintfa( str, "%s%s: %s", newline, name, value ); -} - /* Decode%20a%20file%20name */ void http_decode( char *s ) { diff --git a/lib/misc.h b/lib/misc.h index e0468d73..7804bfb1 100644 --- a/lib/misc.h +++ b/lib/misc.h @@ -41,7 +41,6 @@ G_MODULE_EXPORT void strip_linefeed( gchar *text ); G_MODULE_EXPORT char *add_cr( char *text ); G_MODULE_EXPORT char *strip_newlines(char *source); G_MODULE_EXPORT char *normalize( const char *s ); -G_MODULE_EXPORT void info_string_append( GString *str, char *newline, char *name, char *value ); G_MODULE_EXPORT time_t get_time( int year, int month, int day, int hour, int min, int sec ); double gettime( void ); diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 980beaca..c96e342e 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -90,6 +90,8 @@ struct oscar_data { gboolean killme; gboolean icq; GSList *evilhack; + + GHashTable *ips; struct { guint maxbuddies; /* max users you can watch */ @@ -411,6 +413,8 @@ static void oscar_logout(struct im_connection *ic) { odata->create_rooms = g_slist_remove(odata->create_rooms, cr); g_free(cr); } + if (odata->ips) + g_hash_table_destroy(odata->ips); if (odata->email) g_free(odata->email); if (odata->newp) @@ -987,6 +991,16 @@ static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) signon = time(NULL) - info->sessionlen; + if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR) { + uint32_t *uin = g_new0(uint32_t, 1); + + if (od->ips == NULL) + od->ips = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL); + + if (sscanf(info->sn, "%d", uin) == 1) + g_hash_table_insert(od->ips, uin, (gpointer) (long) info->icqinfo.ipaddr); + } + tmp = g_strdup(normalize(ic->acc->user)); if (!strcmp(tmp, normalize(info->sn))) g_snprintf(ic->displayname, sizeof(ic->displayname), "%s", info->sn); @@ -2219,87 +2233,93 @@ static GList *oscar_away_states(struct im_connection *ic) static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) { - struct im_connection *ic = sess->aux_data; - gchar who[16]; - GString *str; - va_list ap; - struct aim_icq_info *info; - - va_start(ap, fr); - info = va_arg(ap, struct aim_icq_info *); - va_end(ap); - - if (!info->uin) - return 0; - - str = g_string_sized_new(100); - g_snprintf(who, sizeof(who), "%u", info->uin); - - g_string_sprintfa(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"), - info->nick ? info->nick : "-"); - info_string_append(str, "\n", _("First Name"), info->first); - info_string_append(str, "\n", _("Last Name"), info->last); - info_string_append(str, "\n", _("Email Address"), info->email); - if (info->numaddresses && info->email2) { - int i; - for (i = 0; i < info->numaddresses; i++) { - info_string_append(str, "\n", _("Email Address"), info->email2[i]); - } - } - info_string_append(str, "\n", _("Mobile Phone"), info->mobile); - if (info->gender != 0) - info_string_append(str, "\n", _("Gender"), info->gender==1 ? _("Female") : _("Male")); - if (info->birthyear || info->birthmonth || info->birthday) { - char date[30]; - struct tm tm; - tm.tm_mday = (int)info->birthday; - tm.tm_mon = (int)info->birthmonth-1; - tm.tm_year = (int)info->birthyear%100; - strftime(date, sizeof(date), "%Y-%m-%d", &tm); - info_string_append(str, "\n", _("Birthday"), date); - } - if (info->age) { - char age[5]; - g_snprintf(age, sizeof(age), "%hhd", info->age); - info_string_append(str, "\n", _("Age"), age); - } - info_string_append(str, "\n", _("Personal Web Page"), info->personalwebpage); - if (info->info && info->info[0]) { - g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"), - info->info, _("End of Additional Information")); - } - g_string_sprintfa(str, "\n"); - if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { - g_string_sprintfa(str, "%s:", _("Home Address")); - info_string_append(str, "\n", _("Address"), info->homeaddr); - info_string_append(str, "\n", _("City"), info->homecity); - info_string_append(str, "\n", _("State"), info->homestate); - info_string_append(str, "\n", _("Zip Code"), info->homezip); - g_string_sprintfa(str, "\n"); - } - if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { - g_string_sprintfa(str, "%s:", _("Work Address")); - info_string_append(str, "\n", _("Address"), info->workaddr); - info_string_append(str, "\n", _("City"), info->workcity); - info_string_append(str, "\n", _("State"), info->workstate); - info_string_append(str, "\n", _("Zip Code"), info->workzip); - g_string_sprintfa(str, "\n"); - } - if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { - g_string_sprintfa(str, "%s:", _("Work Information")); - info_string_append(str, "\n", _("Company"), info->workcompany); - info_string_append(str, "\n", _("Division"), info->workdivision); - info_string_append(str, "\n", _("Position"), info->workposition); - if (info->workwebpage && info->workwebpage[0]) { - info_string_append(str, "\n", _("Web Page"), info->workwebpage); - } - g_string_sprintfa(str, "\n"); - } - - imcb_log(ic, "%s\n%s", _("User Info"), str->str); - g_string_free(str, TRUE); - - return 1; + struct im_connection *ic = sess->aux_data; + struct oscar_data *od = ic->proto_data; + gchar who[16]; + GString *str; + va_list ap; + struct aim_icq_info *info; + uint32_t ip; + + va_start(ap, fr); + info = va_arg(ap, struct aim_icq_info *); + va_end(ap); + + if (!info->uin) + return 0; + + str = g_string_sized_new(512); + g_snprintf(who, sizeof(who), "%u", info->uin); + + g_string_printf(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"), + info->nick ? info->nick : "-"); + g_string_append_printf(str, "\n%s: %s", _("First Name"), info->first); + g_string_append_printf(str, "\n%s: %s", _("Last Name"), info->last); + g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email); + if (info->numaddresses && info->email2) { + int i; + for (i = 0; i < info->numaddresses; i++) { + g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email2[i]); + } + } + if ((ip = (long) g_hash_table_lookup(od->ips, &info->uin)) != 0) { + g_string_append_printf(str, "\n%s: %d.%d.%d.%d", _("Last used IP address"), + (ip >> 24), (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff); + } + g_string_append_printf(str, "\n%s: %s", _("Mobile Phone"), info->mobile); + if (info->gender != 0) + g_string_append_printf(str, "\n%s: %s", _("Gender"), info->gender==1 ? _("Female") : _("Male")); + if (info->birthyear || info->birthmonth || info->birthday) { + char date[30]; + struct tm tm; + tm.tm_mday = (int)info->birthday; + tm.tm_mon = (int)info->birthmonth-1; + tm.tm_year = (int)info->birthyear%100; + strftime(date, sizeof(date), "%Y-%m-%d", &tm); + g_string_append_printf(str, "\n%s: %s", _("Birthday"), date); + } + if (info->age) { + char age[5]; + g_snprintf(age, sizeof(age), "%hhd", info->age); + g_string_append_printf(str, "\n%s: %s", _("Age"), age); + } + g_string_append_printf(str, "\n%s: %s", _("Personal Web Page"), info->personalwebpage); + if (info->info && info->info[0]) { + g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"), + info->info, _("End of Additional Information")); + } + g_string_append_c(str, '\n'); + if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { + g_string_append_printf(str, "%s:", _("Home Address")); + g_string_append_printf(str, "\n%s: %s", _("Address"), info->homeaddr); + g_string_append_printf(str, "\n%s: %s", _("City"), info->homecity); + g_string_append_printf(str, "\n%s: %s", _("State"), info->homestate); + g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->homezip); + g_string_append_c(str, '\n'); + } + if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { + g_string_append_printf(str, "%s:", _("Work Address")); + g_string_append_printf(str, "\n%s: %s", _("Address"), info->workaddr); + g_string_append_printf(str, "\n%s: %s", _("City"), info->workcity); + g_string_append_printf(str, "\n%s: %s", _("State"), info->workstate); + g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->workzip); + g_string_append_c(str, '\n'); + } + if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { + g_string_append_printf(str, "%s:", _("Work Information")); + g_string_append_printf(str, "\n%s: %s", _("Company"), info->workcompany); + g_string_append_printf(str, "\n%s: %s", _("Division"), info->workdivision); + g_string_append_printf(str, "\n%s: %s", _("Position"), info->workposition); + if (info->workwebpage && info->workwebpage[0]) { + g_string_append_printf(str, "\n%s: %s", _("Web Page"), info->workwebpage); + } + g_string_append_c(str, '\n'); + } + + imcb_log(ic, "%s\n%s", _("User Info"), str->str); + g_string_free(str, TRUE); + + return 1; } @@ -2433,7 +2453,7 @@ int gaim_parsemtn(aim_session_t *sess, aim_frame_t *fr, ...) else { /* User has stopped typing */ imcb_buddy_typing(ic, sn, 0); - } + } return 1; } -- cgit v1.2.3 From 59f527b6eefaae452533170f52a96903ef63a209 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 12 Jan 2008 17:24:38 +0000 Subject: When a switchboard connection dies (at the TCP level) and there are still queued messages, they will now be moved back to the main queue and a new sb will be created to try to send the messages again. I hope this will solve some/most/all of the "Closing switchboard with unsent messages" problems, but can't be sure since this problem isn't very easy to reproduce. At least it should solve the ones caused by keeping spare switchboards around. Also enabling switchboard debugging output if configured with --debug=1, at least for now this will be useful. --- protocols/msn/msn.h | 10 +++++----- protocols/msn/sb.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index 746606a0..c8f4f4c6 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -28,11 +28,9 @@ #define TYPING_NOTIFICATION_MESSAGE "\r\r\rBEWARE, ME R TYPINK MESSAGE!!!!\r\r\r" #define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r" -#ifdef _WIN32 -#define debug +#ifdef DEBUG +#define debug( text... ) imcb_log( ic, text ); #else -#define debug( text... ) irc_usermsg( IRC, text ); -#undef debug #define debug( text... ) #endif @@ -65,8 +63,10 @@ struct msn_data GSList *msgq; GSList *switchboards; - const struct msn_away_state *away_state; + int sb_failures; + time_t first_sb_failure; + const struct msn_away_state *away_state; int buddycount; int groupcount; char **grouplist; diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c index 8c0afca6..cdf2e8ad 100644 --- a/protocols/msn/sb.c +++ b/protocols/msn/sb.c @@ -276,16 +276,59 @@ gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ) static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition cond ) { struct msn_switchboard *sb = data; + struct im_connection *ic = sb->ic; + struct msn_data *md = ic->proto_data; if( msn_handler( sb->handler ) == -1 ) { + time_t now = time( NULL ); + + if( now - md->first_sb_failure > 600 ) + { + /* It's not really the first one, but the start of this "series". + With this, the warning below will be shown only if this happens + at least three times in ten minutes. This algorithm isn't + perfect, but for this purpose it will do. */ + md->first_sb_failure = now; + md->sb_failures = 0; + } + debug( "Error: Switchboard died" ); + if( ++ md->sb_failures >= 3 ) + imcb_log( ic, "Warning: Many switchboard failures on MSN connection. " + "There might be problems delivering your messages." ); + + if( sb->msgq != NULL ) + { + char buf[1024]; + + if( md->msgq == NULL ) + { + md->msgq = sb->msgq; + } + else + { + GSList *l; + + for( l = md->msgq; l->next; l = l->next ); + l->next = sb->msgq; + } + sb->msgq = NULL; + + debug( "Moved queued messages back to the main queue, creating a new switchboard to retry." ); + g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); + if( !msn_write( ic, buf, strlen( buf ) ) ) + return FALSE; + } + msn_sb_destroy( sb ); return FALSE; } else + { return TRUE; + } } static int msn_sb_command( gpointer data, char **cmd, int num_parts ) -- cgit v1.2.3 From fc0cf92a81086903914056b32663479909a6fbff Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 13 Jan 2008 00:15:12 +0000 Subject: Different handling of charset mismatches before login time. Ignoring a USER command because of encoding issues isn't too great, so let's simply replace them. The information isn't really used anywhere anyway. --- irc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/irc.c b/irc.c index 2b86aebb..972e030e 100644 --- a/irc.c +++ b/irc.c @@ -324,7 +324,10 @@ void irc_process( irc_t *irc ) conv[IRC_MAX_LINE] = 0; if( do_iconv( cs, "UTF-8", lines[i], conv, 0, IRC_MAX_LINE - 2 ) == -1 ) { + /* GLib can do strange things if things are not in the expected charset, + so let's be a little bit paranoid here: */ if( irc->status & USTATUS_LOGGED_IN ) + { irc_usermsg( irc, "Error: Charset mismatch detected. The charset " "setting is currently set to %s, so please make " "sure your IRC client will send and accept text in " @@ -332,7 +335,18 @@ void irc_process( irc_t *irc ) "expect by changing the charset setting. See " "`help set charset' for more information. Your " "message was ignored.", cs ); - *conv = 0; + *conv = 0; + } + else + { + irc_write( irc, ":%s NOTICE AUTH :%s", irc->myhost, + "Warning: invalid (non-UTF8) characters received at login time." ); + + strncpy( conv, lines[i], IRC_MAX_LINE ); + for( temp = conv; *temp; temp ++ ) + if( *temp & 0x80 ) + *temp = '?'; + } } lines[i] = conv; } -- cgit v1.2.3 From 07ff8a2c5af9b281fa6cdf6f1273f7c55c83bdb2 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 13 Jan 2008 14:45:51 +0000 Subject: Fixed quickstart2. (Bug #349.) --- doc/user-guide/quickstart.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/user-guide/quickstart.xml b/doc/user-guide/quickstart.xml index fcb06c6b..7735a8d7 100644 --- a/doc/user-guide/quickstart.xml +++ b/doc/user-guide/quickstart.xml @@ -33,7 +33,7 @@ To add an account to the account list you will need to use the account -For instance, suppose you have an ICQ account with UIN 72696705 with password QuickStart, you would: +For instance, suppose you have a Jabber account at jabber.org with handle bitlbee@jabber.org with password QuickStart, you would: @@ -42,7 +42,7 @@ For instance, suppose you have an ICQ account with UIN 72696705 -Other available IM protocols are msn, oscar, and yahoo. Oscar is the protocol used by ICQ and AOL. +Other available IM protocols are msn, oscar, and yahoo. OSCAR is the protocol used by ICQ and AOL. For more information about the account add command, see help account add. -- cgit v1.2.3 From dded27d9a58237036b23f152eb6dfeaad3ae762d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 13 Jan 2008 14:48:32 +0000 Subject: Fixed "Conditional jump or move depends on uninitialised value(s)" at jabber_pkt_presence (presence.c:174). Valgrind-Wilmer: 1-0. --- protocols/jabber/presence.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c index 3bfc83ff..2c49b800 100644 --- a/protocols/jabber/presence.c +++ b/protocols/jabber/presence.c @@ -165,7 +165,7 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) if( send_presence ) { - int is_away; + int is_away = 0; if( send_presence->away_state && !( *send_presence->away_state->code == 0 || strcmp( send_presence->away_state->code, "chat" ) == 0 ) ) -- cgit v1.2.3 From 13857c648210a16448619c65e33f9918bfe27cbe Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 13 Jan 2008 17:13:45 +0000 Subject: Fixed handing of failed groupchat joins. --- protocols/jabber/conference.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/protocols/jabber/conference.c b/protocols/jabber/conference.c index 074412ec..466cb323 100644 --- a/protocols/jabber/conference.c +++ b/protocols/jabber/conference.c @@ -72,17 +72,16 @@ static xt_status jabber_chat_join_failed( struct im_connection *ic, struct xt_no char *room; room = xt_find_attr( orig, "to" ); - if( ( bud = jabber_buddy_by_jid( ic, room, 0 ) ) ) - jabber_chat_free( jabber_chat_by_jid( ic, bud->bare_jid ) ); - + bud = jabber_buddy_by_jid( ic, room, 0 ); err = jabber_error_parse( xt_find_node( node->children, "error" ), XMLNS_STANZA_ERROR ); if( err ) { - imcb_error( ic, "Error joining groupchat %s: %s%s%s", - bud->bare_jid, err->code, err->text ? ": " : "", - err->text ? err->text : "" ); + imcb_error( ic, "Error joining groupchat %s: %s%s%s", room, err->code, + err->text ? ": " : "", err->text ? err->text : "" ); jabber_error_free( err ); } + if( bud ) + jabber_chat_free( jabber_chat_by_jid( ic, bud->bare_jid ) ); return XT_HANDLED; } -- cgit v1.2.3 From 52744f8f65a278a59a8903d5c594e057d63c7006 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 17 Jan 2008 22:06:55 +0000 Subject: Fixing some Solaris compiler warnings (u_int->uint, adding some typecasts for pid_t variables). --- bitlbee.c | 2 +- ipc.c | 6 +++--- lib/md5.c | 22 +++++++++++----------- lib/md5.h | 7 ++++--- protocols/nogaim.c | 6 +++--- protocols/nogaim.h | 8 ++++---- unix.c | 4 ++-- 7 files changed, 28 insertions(+), 27 deletions(-) diff --git a/bitlbee.c b/bitlbee.c index 3f488b46..c4b5abb3 100644 --- a/bitlbee.c +++ b/bitlbee.c @@ -278,7 +278,7 @@ static gboolean bitlbee_io_new_client( gpointer data, gint fd, b_input_condition child->ipc_inpa = b_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child ); child_list = g_slist_append( child_list, child ); - log_message( LOGLVL_INFO, "Creating new subprocess with pid %d.", client_pid ); + log_message( LOGLVL_INFO, "Creating new subprocess with pid %d.", (int) client_pid ); /* Close some things we don't need in the parent process. */ close( new_socket ); diff --git a/ipc.c b/ipc.c index d0d2dff3..384a9c33 100644 --- a/ipc.c +++ b/ipc.c @@ -51,7 +51,7 @@ static void ipc_master_cmd_client( irc_t *data, char **cmd ) if( g_strcasecmp( cmd[0], "CLIENT" ) == 0 ) ipc_to_children_str( "OPERMSG :Client connecting (PID=%d): %s@%s (%s)\r\n", - child ? child->pid : -1, cmd[2], cmd[1], cmd[3] ); + (int) ( child ? child->pid : -1 ), cmd[2], cmd[1], cmd[3] ); } static void ipc_master_cmd_die( irc_t *data, char **cmd ) @@ -445,7 +445,7 @@ char *ipc_master_save_state() fprintf( fp, "%d\n", i ); for( l = child_list; l; l = l->next ) - fprintf( fp, "%d %d\n", ((struct bitlbee_child*)l->data)->pid, + fprintf( fp, "%d %d\n", (int) ((struct bitlbee_child*)l->data)->pid, ((struct bitlbee_child*)l->data)->ipc_fd ); if( fclose( fp ) == 0 ) @@ -550,7 +550,7 @@ int ipc_master_load_state() { child = g_new0( struct bitlbee_child, 1 ); - if( fscanf( fp, "%d %d", &child->pid, &child->ipc_fd ) != 2 ) + if( fscanf( fp, "%d %d", (int *) &child->pid, &child->ipc_fd ) != 2 ) { log_message( LOGLVL_WARNING, "Unexpected end of file: Only processed %d clients.", i ); g_free( child ); diff --git a/lib/md5.c b/lib/md5.c index 08c298a2..f1779794 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -25,7 +25,7 @@ #include /* for memcpy() */ #include "md5.h" -static void md5_transform(u_int32_t buf[4], u_int32_t const in[16]); +static void md5_transform(uint32_t buf[4], uint32_t const in[16]); /* * Wrapper function for all-in-one MD5 @@ -52,12 +52,12 @@ void md5_init(struct MD5Context *ctx) void md5_append(struct MD5Context *ctx, const md5_byte_t *buf, unsigned int len) { - u_int32_t t; + uint32_t t; /* Update bitcount */ t = ctx->bits[0]; - if ((ctx->bits[0] = t + ((u_int32_t) len << 3)) < t) + if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t) ctx->bits[1]++; /* Carry from low to high */ ctx->bits[1] += len >> 29; @@ -74,7 +74,7 @@ void md5_append(struct MD5Context *ctx, const md5_byte_t *buf, return; } memcpy(p, buf, t); - md5_transform(ctx->buf, (u_int32_t *) ctx->in); + md5_transform(ctx->buf, (uint32_t *) ctx->in); buf += t; len -= t; } @@ -82,7 +82,7 @@ void md5_append(struct MD5Context *ctx, const md5_byte_t *buf, while (len >= 64) { memcpy(ctx->in, buf, 64); - md5_transform(ctx->buf, (u_int32_t *) ctx->in); + md5_transform(ctx->buf, (uint32_t *) ctx->in); buf += 64; len -= 64; } @@ -116,7 +116,7 @@ void md5_finish(struct MD5Context *ctx, md5_byte_t digest[16]) if (count < 8) { /* Two lots of padding: Pad the first block to 64 bytes */ memset(p, 0, count); - md5_transform(ctx->buf, (u_int32_t *) ctx->in); + md5_transform(ctx->buf, (uint32_t *) ctx->in); /* Now fill the next block with 56 bytes */ memset(ctx->in, 0, 56); @@ -126,10 +126,10 @@ void md5_finish(struct MD5Context *ctx, md5_byte_t digest[16]) } /* Append length in bits and transform */ - ((u_int32_t *) ctx->in)[14] = ctx->bits[0]; - ((u_int32_t *) ctx->in)[15] = ctx->bits[1]; + ((uint32_t *) ctx->in)[14] = ctx->bits[0]; + ((uint32_t *) ctx->in)[15] = ctx->bits[1]; - md5_transform(ctx->buf, (u_int32_t *) ctx->in); + md5_transform(ctx->buf, (uint32_t *) ctx->in); memcpy(digest, ctx->buf, 16); memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ } @@ -151,9 +151,9 @@ void md5_finish(struct MD5Context *ctx, md5_byte_t digest[16]) * reflect the addition of 16 longwords of new data. MD5Update blocks * the data and converts bytes into longwords for this routine. */ -static void md5_transform(u_int32_t buf[4], u_int32_t const in[16]) +static void md5_transform(uint32_t buf[4], uint32_t const in[16]) { - register u_int32_t a, b, c, d; + register uint32_t a, b, c, d; a = buf[0]; b = buf[1]; diff --git a/lib/md5.h b/lib/md5.h index 86568b7a..094507b2 100644 --- a/lib/md5.h +++ b/lib/md5.h @@ -26,11 +26,12 @@ #include #include +#include -typedef u_int8_t md5_byte_t; +typedef uint8_t md5_byte_t; typedef struct MD5Context { - u_int32_t buf[4]; - u_int32_t bits[2]; + uint32_t buf[4]; + uint32_t bits[2]; unsigned char in[64]; } md5_state_t; diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 5e698902..b9008af1 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -624,7 +624,7 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, } } -void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_t flags, time_t sent_at ) +void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, uint32_t flags, time_t sent_at ) { irc_t *irc = ic->irc; char *wrapped; @@ -675,7 +675,7 @@ void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_ g_free( wrapped ); } -void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags ) +void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags ) { user_t *u; @@ -731,7 +731,7 @@ void imcb_chat_free( struct groupchat *c ) } } -void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at ) +void imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, time_t sent_at ) { struct im_connection *ic = c->ic; char *wrapped; diff --git a/protocols/nogaim.h b/protocols/nogaim.h index 0e890464..8ba8fd9e 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -67,7 +67,7 @@ struct im_connection { account_t *acc; - u_int32_t flags; + uint32_t flags; /* each connection then can have its own protocol-specific data */ void *proto_data; @@ -281,8 +281,8 @@ G_MODULE_EXPORT void imcb_buddy_nick_hint( struct im_connection *ic, char *handl G_MODULE_EXPORT void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message ); /* Not implemented yet! */ G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle ); /* Call when a handle says something. 'flags' and 'sent_at may be just 0. */ -G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_t flags, time_t sent_at ); -G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags ); +G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, uint32_t flags, time_t sent_at ); +G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags ); G_MODULE_EXPORT void imcb_clean_handle( struct im_connection *ic, char *handle ); /* Groupchats */ @@ -298,7 +298,7 @@ G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, char *handle ); /* To remove a handle from a group chat. Reason can be NULL. */ G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason ); /* To tell BitlBee 'who' said 'msg' in 'c'. 'flags' and 'sent_at' can be 0. */ -G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at ); +G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, time_t sent_at ); /* To tell BitlBee 'who' changed the topic of 'c' to 'topic'. */ G_MODULE_EXPORT void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at ); G_MODULE_EXPORT void imcb_chat_free( struct groupchat *c ); diff --git a/unix.c b/unix.c index 75ffcf95..0aaf505a 100644 --- a/unix.c +++ b/unix.c @@ -196,9 +196,9 @@ static void sighandler( int signal ) while( ( pid = waitpid( 0, &st, WNOHANG ) ) > 0 ) { if( WIFSIGNALED( st ) ) - log_message( LOGLVL_INFO, "Client %d terminated normally. (status = %d)", pid, WEXITSTATUS( st ) ); + log_message( LOGLVL_INFO, "Client %d terminated normally. (status = %d)", (int) pid, WEXITSTATUS( st ) ); else if( WIFEXITED( st ) ) - log_message( LOGLVL_INFO, "Client %d killed by signal %d.", pid, WTERMSIG( st ) ); + log_message( LOGLVL_INFO, "Client %d killed by signal %d.", (int) pid, WTERMSIG( st ) ); } } else if( signal != SIGPIPE ) -- cgit v1.2.3 From ac4adf9a546c2e9b247b9de4b753177e6bd479e4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 17 Jan 2008 22:48:32 +0000 Subject: Apparently ext_yahoo_got_im can be called with msg=NULL, so it should be handled. Let's just ignore those packets. --- protocols/yahoo/yahoo.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index d413597a..9f9ffcf7 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -623,10 +623,14 @@ void ext_yahoo_status_changed( int id, const char *who, int stat, const char *ms void ext_yahoo_got_im( int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8 ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); - char *m = byahoo_strip( msg ); + char *m; - imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 ); - g_free( m ); + if( msg ) + { + m = byahoo_strip( msg ); + imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 ); + g_free( m ); + } } void ext_yahoo_got_file( int id, -- cgit v1.2.3 From 83ba3e541acc3c29616fbf982b57633d303d941a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 18 Jan 2008 13:20:37 +0000 Subject: Moving imcb_chat_new() to a saner location (no code changes) and fixing default channel topic. --- protocols/nogaim.c | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/protocols/nogaim.c b/protocols/nogaim.c index b9008af1..cfdaa454 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -691,6 +691,31 @@ void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags ) } } +struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle ) +{ + struct groupchat *c; + + /* This one just creates the conversation structure, user won't see anything yet */ + + if( ic->groupchats ) + { + for( c = ic->groupchats; c->next; c = c->next ); + c = c->next = g_new0( struct groupchat, 1 ); + } + else + ic->groupchats = c = g_new0( struct groupchat, 1 ); + + c->ic = ic; + c->title = g_strdup( handle ); + c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ ); + c->topic = g_strdup_printf( "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->title ); + + if( set_getbool( &ic->irc->set, "debug" ) ) + imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle ); + + return c; +} + void imcb_chat_free( struct groupchat *c ) { struct im_connection *ic = c->ic; @@ -727,6 +752,7 @@ void imcb_chat_free( struct groupchat *c ) g_list_free( c->in_room ); g_free( c->channel ); g_free( c->title ); + g_free( c->topic ); g_free( c ); } } @@ -782,31 +808,6 @@ void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at irc_write( ic->irc, ":%s!%s@%s TOPIC %s :%s", u->nick, u->user, u->host, c->channel, topic ); } -struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle ) -{ - struct groupchat *c; - - /* This one just creates the conversation structure, user won't see anything yet */ - - if( ic->groupchats ) - { - for( c = ic->groupchats; c->next; c = c->next ); - c = c->next = g_new0( struct groupchat, 1 ); - } - else - ic->groupchats = c = g_new0( struct groupchat, 1 ); - - c->ic = ic; - c->title = g_strdup( handle ); - c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ ); - c->topic = g_strdup_printf( "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->channel, c->title ); - - if( set_getbool( &ic->irc->set, "debug" ) ) - imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle ); - - return c; -} - /* buddy_chat.c */ -- cgit v1.2.3 From bea13052bf43e34b043d868dfdaa84241a8b163a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 19 Jan 2008 12:36:30 +0000 Subject: Added byte swapping code to the new MD5 checksumming code to make it work on big-endian machines. (If someone thinks BitlBee should work on PDPs, send me the fix. I don't care. :-P) This fixes bug #351 (MSN challenge- response failure) but might break backward compatibility if the broken MD5 code was used to save settings. (Somewhere between rev 266 and now.) --- lib/md5.c | 165 ++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 96 insertions(+), 69 deletions(-) diff --git a/lib/md5.c b/lib/md5.c index f1779794..3c39eccd 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -34,6 +34,29 @@ static void md5_transform(uint32_t buf[4], uint32_t const in[16]); * 20021120 */ +/* Turns out MD5 was designed for little-endian machines. If we're running + on a big-endian machines, we have to swap some bytes. Since detecting + endianness at compile time reliably seems pretty hard, let's do it at + run-time. It's not like we're going to checksum megabytes of data... */ +static uint32_t cvt32(uint32_t val) +{ + static int little_endian = -1; + + if (little_endian == -1) + { + little_endian = 1; + little_endian = *((char*) &little_endian); + } + + if (little_endian) + return val; + else + return (val >> 24) | + ((val >> 8) & 0xff00) | + ((val << 8) & 0xff0000) | + (val << 24); +} + void md5_init(struct MD5Context *ctx) { ctx->buf[0] = 0x67452301; @@ -126,10 +149,14 @@ void md5_finish(struct MD5Context *ctx, md5_byte_t digest[16]) } /* Append length in bits and transform */ - ((uint32_t *) ctx->in)[14] = ctx->bits[0]; - ((uint32_t *) ctx->in)[15] = ctx->bits[1]; + ((uint32_t *) ctx->in)[14] = cvt32(ctx->bits[0]); + ((uint32_t *) ctx->in)[15] = cvt32(ctx->bits[1]); md5_transform(ctx->buf, (uint32_t *) ctx->in); + ctx->buf[0] = cvt32(ctx->buf[0]); + ctx->buf[1] = cvt32(ctx->buf[1]); + ctx->buf[2] = cvt32(ctx->buf[2]); + ctx->buf[3] = cvt32(ctx->buf[3]); memcpy(digest, ctx->buf, 16); memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ } @@ -160,73 +187,73 @@ static void md5_transform(uint32_t buf[4], uint32_t const in[16]) c = buf[2]; d = buf[3]; - MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); - MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); - MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); - MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); - MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); - MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); - MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); - MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); - MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); - MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); - MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); - MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); - MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); - MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); - MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); - MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); - - MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); - MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); - MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); - MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); - MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); - MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); - MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); - MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); - MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); - MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); - MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); - MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); - MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); - MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); - MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); - MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); - - MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); - MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); - MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); - MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); - MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); - MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); - MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); - MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); - MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); - MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); - MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); - MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); - MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); - MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); - MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); - MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); - - MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); - MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); - MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); - MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); - MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); - MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); - MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); - MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); - MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); - MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); - MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); - MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); - MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); - MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); - MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); - MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); + MD5STEP(F1, a, b, c, d, cvt32(in[0]) + 0xd76aa478, 7); + MD5STEP(F1, d, a, b, c, cvt32(in[1]) + 0xe8c7b756, 12); + MD5STEP(F1, c, d, a, b, cvt32(in[2]) + 0x242070db, 17); + MD5STEP(F1, b, c, d, a, cvt32(in[3]) + 0xc1bdceee, 22); + MD5STEP(F1, a, b, c, d, cvt32(in[4]) + 0xf57c0faf, 7); + MD5STEP(F1, d, a, b, c, cvt32(in[5]) + 0x4787c62a, 12); + MD5STEP(F1, c, d, a, b, cvt32(in[6]) + 0xa8304613, 17); + MD5STEP(F1, b, c, d, a, cvt32(in[7]) + 0xfd469501, 22); + MD5STEP(F1, a, b, c, d, cvt32(in[8]) + 0x698098d8, 7); + MD5STEP(F1, d, a, b, c, cvt32(in[9]) + 0x8b44f7af, 12); + MD5STEP(F1, c, d, a, b, cvt32(in[10]) + 0xffff5bb1, 17); + MD5STEP(F1, b, c, d, a, cvt32(in[11]) + 0x895cd7be, 22); + MD5STEP(F1, a, b, c, d, cvt32(in[12]) + 0x6b901122, 7); + MD5STEP(F1, d, a, b, c, cvt32(in[13]) + 0xfd987193, 12); + MD5STEP(F1, c, d, a, b, cvt32(in[14]) + 0xa679438e, 17); + MD5STEP(F1, b, c, d, a, cvt32(in[15]) + 0x49b40821, 22); + + MD5STEP(F2, a, b, c, d, cvt32(in[1]) + 0xf61e2562, 5); + MD5STEP(F2, d, a, b, c, cvt32(in[6]) + 0xc040b340, 9); + MD5STEP(F2, c, d, a, b, cvt32(in[11]) + 0x265e5a51, 14); + MD5STEP(F2, b, c, d, a, cvt32(in[0]) + 0xe9b6c7aa, 20); + MD5STEP(F2, a, b, c, d, cvt32(in[5]) + 0xd62f105d, 5); + MD5STEP(F2, d, a, b, c, cvt32(in[10]) + 0x02441453, 9); + MD5STEP(F2, c, d, a, b, cvt32(in[15]) + 0xd8a1e681, 14); + MD5STEP(F2, b, c, d, a, cvt32(in[4]) + 0xe7d3fbc8, 20); + MD5STEP(F2, a, b, c, d, cvt32(in[9]) + 0x21e1cde6, 5); + MD5STEP(F2, d, a, b, c, cvt32(in[14]) + 0xc33707d6, 9); + MD5STEP(F2, c, d, a, b, cvt32(in[3]) + 0xf4d50d87, 14); + MD5STEP(F2, b, c, d, a, cvt32(in[8]) + 0x455a14ed, 20); + MD5STEP(F2, a, b, c, d, cvt32(in[13]) + 0xa9e3e905, 5); + MD5STEP(F2, d, a, b, c, cvt32(in[2]) + 0xfcefa3f8, 9); + MD5STEP(F2, c, d, a, b, cvt32(in[7]) + 0x676f02d9, 14); + MD5STEP(F2, b, c, d, a, cvt32(in[12]) + 0x8d2a4c8a, 20); + + MD5STEP(F3, a, b, c, d, cvt32(in[5]) + 0xfffa3942, 4); + MD5STEP(F3, d, a, b, c, cvt32(in[8]) + 0x8771f681, 11); + MD5STEP(F3, c, d, a, b, cvt32(in[11]) + 0x6d9d6122, 16); + MD5STEP(F3, b, c, d, a, cvt32(in[14]) + 0xfde5380c, 23); + MD5STEP(F3, a, b, c, d, cvt32(in[1]) + 0xa4beea44, 4); + MD5STEP(F3, d, a, b, c, cvt32(in[4]) + 0x4bdecfa9, 11); + MD5STEP(F3, c, d, a, b, cvt32(in[7]) + 0xf6bb4b60, 16); + MD5STEP(F3, b, c, d, a, cvt32(in[10]) + 0xbebfbc70, 23); + MD5STEP(F3, a, b, c, d, cvt32(in[13]) + 0x289b7ec6, 4); + MD5STEP(F3, d, a, b, c, cvt32(in[0]) + 0xeaa127fa, 11); + MD5STEP(F3, c, d, a, b, cvt32(in[3]) + 0xd4ef3085, 16); + MD5STEP(F3, b, c, d, a, cvt32(in[6]) + 0x04881d05, 23); + MD5STEP(F3, a, b, c, d, cvt32(in[9]) + 0xd9d4d039, 4); + MD5STEP(F3, d, a, b, c, cvt32(in[12]) + 0xe6db99e5, 11); + MD5STEP(F3, c, d, a, b, cvt32(in[15]) + 0x1fa27cf8, 16); + MD5STEP(F3, b, c, d, a, cvt32(in[2]) + 0xc4ac5665, 23); + + MD5STEP(F4, a, b, c, d, cvt32(in[0]) + 0xf4292244, 6); + MD5STEP(F4, d, a, b, c, cvt32(in[7]) + 0x432aff97, 10); + MD5STEP(F4, c, d, a, b, cvt32(in[14]) + 0xab9423a7, 15); + MD5STEP(F4, b, c, d, a, cvt32(in[5]) + 0xfc93a039, 21); + MD5STEP(F4, a, b, c, d, cvt32(in[12]) + 0x655b59c3, 6); + MD5STEP(F4, d, a, b, c, cvt32(in[3]) + 0x8f0ccc92, 10); + MD5STEP(F4, c, d, a, b, cvt32(in[10]) + 0xffeff47d, 15); + MD5STEP(F4, b, c, d, a, cvt32(in[1]) + 0x85845dd1, 21); + MD5STEP(F4, a, b, c, d, cvt32(in[8]) + 0x6fa87e4f, 6); + MD5STEP(F4, d, a, b, c, cvt32(in[15]) + 0xfe2ce6e0, 10); + MD5STEP(F4, c, d, a, b, cvt32(in[6]) + 0xa3014314, 15); + MD5STEP(F4, b, c, d, a, cvt32(in[13]) + 0x4e0811a1, 21); + MD5STEP(F4, a, b, c, d, cvt32(in[4]) + 0xf7537e82, 6); + MD5STEP(F4, d, a, b, c, cvt32(in[11]) + 0xbd3af235, 10); + MD5STEP(F4, c, d, a, b, cvt32(in[2]) + 0x2ad7d2bb, 15); + MD5STEP(F4, b, c, d, a, cvt32(in[9]) + 0xeb86d391, 21); buf[0] += a; buf[1] += b; -- cgit v1.2.3 From 003553b6ac35ce3d9caa44ebe301e0eeb2125ed0 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 19 Jan 2008 18:23:56 +0000 Subject: Using test -f instead of test -e. This breaks if the include files are symlinks, but I guess that's less common than people trying to run BitlBee on Solaris machines... (Bug #350) --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 6f8d8ea6..22989f60 100755 --- a/configure +++ b/configure @@ -188,7 +188,7 @@ else fi if [ "$events" = "libevent" ]; then - if ! [ -e "${libevent}include/event.h" ]; then + if ! [ -f "${libevent}include/event.h" ]; then echo echo 'Warning: Could not find event.h, you might have to install it and/or specify' echo 'its location using the --libevent= argument. (Example: If event.h is in' @@ -323,7 +323,7 @@ fi; echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings for i in /lib /usr/lib /usr/local/lib; do - if [ -e $i/libresolv.a ]; then + if [ -f $i/libresolv.a ]; then echo '#define HAVE_RESOLV_A' >> config.h echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings break -- cgit v1.2.3 From 0adce2151fc2a4f517e558663e5afe010b86a39a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 20 Jan 2008 00:01:31 +0000 Subject: GET_BUDDY_FIRST wasn't actually implemented, even though it was in use already. I don't want to know how long it took me to find out... --- protocols/jabber/jabber_util.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index b84be49b..794a1040 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -391,19 +391,26 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, *s = 0; if( ( bud = g_hash_table_lookup( jd->buddies, jid ) ) ) { + /* Just return the first one for this bare JID. */ + if( flags & GET_BUDDY_FIRST ) + { + *s = '/'; + g_free( jid ); + return bud; + } + /* Is this one of those no-resource buddies? */ if( bud->resource == NULL ) { + *s = '/'; g_free( jid ); return NULL; } - else - { - /* See if there's an exact match. */ - for( ; bud; bud = bud->next ) - if( g_strcasecmp( bud->resource, s + 1 ) == 0 ) - break; - } + + /* See if there's an exact match. */ + for( ; bud; bud = bud->next ) + if( g_strcasecmp( bud->resource, s + 1 ) == 0 ) + break; } else { @@ -412,6 +419,8 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, for this JID, even if it's an unknown buddy. This is done to handle conferences properly. */ none_found = 1; + /* TODO(wilmer): Find out what I was thinking when I + wrote this??? And then fix it. This makes me sad... */ } if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && ( imcb_find_buddy( ic, jid ) || !none_found ) ) @@ -442,6 +451,9 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, else if( ( bud->resource == NULL || bud->next == NULL ) ) /* No need for selection if there's only one option. */ return bud; + else if( flags & GET_BUDDY_FIRST ) + /* Looks like the caller doesn't care about details. */ + return bud; best_prio = best_time = bud; for( ; bud; bud = bud->next ) -- cgit v1.2.3 From 31e584652a5543b87e0953525a742fb067c28e6f Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 20 Jan 2008 00:17:57 +0000 Subject: Added imcb_chat_log() for chatroom system messages, so they can be displayed inside the right channel. --- protocols/nogaim.c | 18 ++++++++++++++++++ protocols/nogaim.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/protocols/nogaim.c b/protocols/nogaim.c index cfdaa454..3ce15166 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -785,6 +785,24 @@ void imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, t g_free( wrapped ); } +void imcb_chat_log( struct groupchat *c, char *format, ... ) +{ + irc_t *irc = c->ic->irc; + va_list params; + char *text; + user_t *u; + + va_start( params, format ); + text = g_strdup_vprintf( format, params ); + va_end( params ); + + u = user_find( irc, irc->mynick ); + + irc_privmsg( irc, u, "PRIVMSG", c->channel, "System message: ", text ); + + g_free( text ); +} + void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at ) { struct im_connection *ic = c->ic; diff --git a/protocols/nogaim.h b/protocols/nogaim.h index 8ba8fd9e..7d391edd 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -299,6 +299,8 @@ G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, char *handle ); G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason ); /* To tell BitlBee 'who' said 'msg' in 'c'. 'flags' and 'sent_at' can be 0. */ G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, time_t sent_at ); +/* System messages specific to a groupchat, so they can be displayed in the right context. */ +G_MODULE_EXPORT void imcb_chat_log( struct groupchat *c, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); /* To tell BitlBee 'who' changed the topic of 'c' to 'topic'. */ G_MODULE_EXPORT void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at ); G_MODULE_EXPORT void imcb_chat_free( struct groupchat *c ); -- cgit v1.2.3 From a882d6c1eec55fb9a00ce61acd6d776884d0c84a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 20 Jan 2008 11:15:40 +0000 Subject: The Jabber module now uses imcb_chat_log() instead of imcb_log() where possible. --- protocols/jabber/conference.c | 46 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/protocols/jabber/conference.c b/protocols/jabber/conference.c index 466cb323..515194fc 100644 --- a/protocols/jabber/conference.c +++ b/protocols/jabber/conference.c @@ -294,18 +294,54 @@ void jabber_chat_pkt_message( struct im_connection *ic, struct jabber_buddy *bud { struct xt_node *subject = xt_find_node( node->children, "subject" ); struct xt_node *body = xt_find_node( node->children, "body" ); - struct groupchat *chat; + struct groupchat *chat = NULL; char *s; if( bud == NULL ) { + char *nick; + + if( body == NULL || body->text_len == 0 ) + /* Meh. Empty messages aren't very interesting, no matter + how much some servers love to send them. */ + return; + s = xt_find_attr( node, "from" ); /* pkt_message() already NULL-checked this one. */ - if( strchr( s, '/' ) == NULL ) + nick = strchr( s, '/' ); + if( nick ) + { + /* If this message included a resource/nick we don't know, + we might still know the groupchat itself. */ + *nick = 0; + chat = jabber_chat_by_jid( ic, s ); + *nick = '/'; + + nick ++; + } + else + { + /* message.c uses the EXACT_JID option, so bud should + always be NULL here for bare JIDs. */ + chat = jabber_chat_by_jid( ic, s ); + } + + if( nick == NULL ) + { /* This is fine, the groupchat itself isn't in jd->buddies. */ - imcb_log( ic, "System message from groupchat %s: %s", s, body? body->text : "NULL" ); + if( chat ) + imcb_chat_log( chat, "From conference server: %s", body->text ); + else + imcb_log( ic, "System message from unknown groupchat %s: %s", s, body->text ); + } else - /* This, however, isn't fine! */ - imcb_log( ic, "Groupchat message from unknown participant %s: %s", s, body ? body->text : "NULL" ); + { + /* This can happen too, at least when receiving a backlog when + just joining a channel. */ + if( chat ) + imcb_chat_log( chat, "Message from unknown participant %s: %s", nick, body->text ); + else + imcb_log( ic, "Groupchat message from unknown JID %s: %s", s, body->text ); + } return; } -- cgit v1.2.3 From 613cc5583465b2fa35288a2f28d0e408904c4fd9 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 24 Jan 2008 22:22:46 +0000 Subject: Fixed two valgrind warnings (partially uninitialized "struct tm" vars.) --- lib/misc.c | 2 ++ protocols/oscar/oscar.c | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/misc.c b/lib/misc.c index c2dd966e..18d98f9e 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -89,12 +89,14 @@ time_t get_time(int year, int month, int day, int hour, int min, int sec) { struct tm tm; + memset(&tm, 0, sizeof(struct tm)); tm.tm_year = year - 1900; tm.tm_mon = month - 1; tm.tm_mday = day; tm.tm_hour = hour; tm.tm_min = min; tm.tm_sec = sec >= 0 ? sec : time(NULL) % 60; + return mktime(&tm); } diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index c96e342e..30ad4b68 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -2272,6 +2272,7 @@ static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) if (info->birthyear || info->birthmonth || info->birthday) { char date[30]; struct tm tm; + memset(&tm, 0, sizeof(struct tm)); tm.tm_mday = (int)info->birthday; tm.tm_mon = (int)info->birthmonth-1; tm.tm_year = (int)info->birthyear%100; -- cgit v1.2.3 From b5c8a34aeff244ffe7a9f4bd5edf827495d0deea Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 24 Jan 2008 22:49:47 +0000 Subject: Keeping track of valid Jabber connections so _connected() events will be ignored if the connection's dead already. Necessary if using GLib for event handling for now. :-/ --- protocols/jabber/io.c | 10 +++++++++- protocols/jabber/jabber.c | 9 +++++++++ protocols/jabber/jabber.h | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/protocols/jabber/io.c b/protocols/jabber/io.c index 29561b86..86c216ef 100644 --- a/protocols/jabber/io.c +++ b/protocols/jabber/io.c @@ -248,6 +248,9 @@ gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition c { struct im_connection *ic = data; + if( g_slist_find( jabber_connections, ic ) == NULL ) + return FALSE; + if( source == -1 ) { imcb_error( ic, "Could not connect to server" ); @@ -263,7 +266,12 @@ gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition c gboolean jabber_connected_ssl( gpointer data, void *source, b_input_condition cond ) { struct im_connection *ic = data; - struct jabber_data *jd = ic->proto_data; + struct jabber_data *jd; + + if( g_slist_find( jabber_connections, ic ) == NULL ) + return FALSE; + + jd = ic->proto_data; if( source == NULL ) { diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 264a0308..243ed7fd 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -34,6 +34,8 @@ #include "md5.h" #include "base64.h" +GSList *jabber_connections; + static void jabber_init( account_t *acc ) { set_t *s; @@ -70,6 +72,11 @@ static void jabber_login( account_t *acc ) struct ns_srv_reply *srv = NULL; char *connect_to, *s; + /* For now this is needed in the _connected() handlers if using + GLib event handling, to make sure we're not handling events + on dead connections. */ + jabber_connections = g_slist_prepend( jabber_connections, ic ); + jd->ic = ic; ic->proto_data = jd; @@ -262,6 +269,8 @@ static void jabber_logout( struct im_connection *ic ) g_free( jd->away_message ); g_free( jd->username ); g_free( jd ); + + jabber_connections = g_slist_remove( jabber_connections, ic ); } static int jabber_buddy_msg( struct im_connection *ic, char *who, char *message, int flags ) diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index f673ee0d..cf0f8e6a 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -29,6 +29,8 @@ #include "xmltree.h" #include "bitlbee.h" +extern GSList *jabber_connections; + typedef enum { JFLAG_STREAM_STARTED = 1, /* Set when we detected the beginning of the stream -- cgit v1.2.3 From f774e01cdb34e339455671f51413ecdc6de3208d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 30 Jan 2008 23:05:52 +0000 Subject: Fixed handling of OSCAR multi-part messages... They're not arrays, they're linked lists! --- protocols/oscar/oscar.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 30ad4b68..9e5de70a 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -1065,12 +1065,14 @@ static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_ } else if (args->mpmsg.numparts == 0) { g_snprintf(tmp, BUF_LONG, "%s", args->msg); } else { - int i; + aim_mpmsg_section_t *part; *tmp = 0; - for (i = 0; i < args->mpmsg.numparts; i ++) { - g_strlcat(tmp, (char*) args->mpmsg.parts[i].data, BUF_LONG); - g_strlcat(tmp, "\n", BUF_LONG); + for (part = args->mpmsg.parts; part; part = part->next) { + if (part->data) { + g_strlcat(tmp, (char*) part->data, BUF_LONG); + g_strlcat(tmp, "\n", BUF_LONG); + } } } -- 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. --- help.c | 66 +++++++++++++++++++++++++++++++++++++++------------------- help.h | 5 +++-- irc.c | 11 ---------- irc.h | 1 - irc_commands.c | 2 +- unix.c | 5 ++++- 6 files changed, 53 insertions(+), 37 deletions(-) diff --git a/help.c b/help.c index 756eb12a..587b9940 100644 --- a/help.c +++ b/help.c @@ -70,21 +70,20 @@ help_t *help_init( help_t **help, const char *helpfile ) if( !( t = strstr( s, "\n%\n" ) ) || s[0] != '?' ) { /* FIXME: Clean up */ -// help_close( *help ); - *help = NULL; + help_free( help ); g_free( s ); - return( NULL ); + return NULL; } i = strchr( s, '\n' ) - s; - if( h->string ) + if( h->title ) { h = h->next = g_new0( help_t, 1 ); } - h->string = g_new ( char, i ); + h->title = g_new ( char, i ); - strncpy( h->string, s + 1, i - 1 ); - h->string[i-1] = 0; + strncpy( h->title, s + 1, i - 1 ); + h->title[i-1] = 0; h->fd = (*help)->fd; h->offset.file_offset = lseek( h->fd, 0, SEEK_CUR ) - buflen + i + 1; h->length = t - s - i - 1; @@ -102,7 +101,31 @@ help_t *help_init( help_t **help, const char *helpfile ) return( *help ); } -char *help_get( help_t **help, char *string ) +void help_free( help_t **help ) +{ + help_t *h, *oh; + int last_fd = -1; /* Weak de-dupe */ + + if( help == NULL || *help == NULL ) + return; + + h = *help; + while( h ) + { + if( h->fd != last_fd ) + { + close( h->fd ); + last_fd = h->fd; + } + g_free( h->title ); + h = (oh=h)->next; + g_free( oh ); + } + + *help = NULL; +} + +char *help_get( help_t **help, char *title ) { time_t mtime; struct stat stat[1]; @@ -110,28 +133,29 @@ char *help_get( help_t **help, char *string ) for( h = *help; h; h = h->next ) { - if( h->string != NULL && - g_strcasecmp( h->string, string ) == 0 ) + if( h->title != NULL && g_strcasecmp( h->title, title ) == 0 ) break; } 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; - } - mtime = stat->st_mtime; - - if( mtime > h->mtime ) - return NULL; - s[h->length] = 0; if( h->fd >= 0 ) { + if( fstat( h->fd, stat ) != 0 ) + { + g_free( s ); + return NULL; + } + mtime = stat->st_mtime; + + if( mtime > h->mtime ) + { + g_free( s ); + return NULL; + } + lseek( h->fd, h->offset.file_offset, SEEK_SET ); read( h->fd, s, h->length ); } diff --git a/help.h b/help.h index 32aba723..5421220c 100644 --- a/help.h +++ b/help.h @@ -36,13 +36,14 @@ typedef struct help { int fd; time_t mtime; - char *string; + char *title; help_off_t offset; int length; struct help *next; } help_t; G_GNUC_MALLOC help_t *help_init( help_t **help, const char *helpfile ); -char *help_get( help_t **help, char *string ); +void help_free( help_t **help ); +char *help_get( help_t **help, char *title ); #endif diff --git a/irc.c b/irc.c index 972e030e..2510e3d9 100644 --- a/irc.c +++ b/irc.c @@ -188,7 +188,6 @@ void irc_free(irc_t * irc) { account_t *account; user_t *user, *usertmp; - help_t *helpnode, *helpnodetmp; log_message( LOGLVL_INFO, "Destroying connection with fd %d", irc->fd ); @@ -265,16 +264,6 @@ void irc_free(irc_t * irc) g_hash_table_foreach_remove(irc->watches, irc_free_hashkey, NULL); g_hash_table_destroy(irc->watches); - if (irc->help != NULL) { - helpnode = irc->help; - while (helpnode != NULL) { - g_free(helpnode->string); - - helpnodetmp = helpnode; - helpnode = helpnode->next; - g_free(helpnodetmp); - } - } g_free(irc); if( global.conf->runmode == RUNMODE_INETD || global.conf->runmode == RUNMODE_FORKDAEMON ) diff --git a/irc.h b/irc.h index 8be3579e..eb70ad1c 100644 --- a/irc.h +++ b/irc.h @@ -88,7 +88,6 @@ typedef struct irc GHashTable *userhash; GHashTable *watches; struct __NICK *nicks; - struct help *help; struct set *set; gint r_watch_source_id; 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 ); diff --git a/unix.c b/unix.c index 0aaf505a..9b670d78 100644 --- a/unix.c +++ b/unix.c @@ -123,11 +123,14 @@ int main( int argc, char *argv[], char **envp ) if( !getuid() || !geteuid() ) log_message( LOGLVL_WARNING, "BitlBee is running with root privileges. Why?" ); - if( help_init( &(global.help), global.helpfile ) == NULL ) + if( help_init( &global.help, global.helpfile ) == NULL ) log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE ); b_main_run(); + /* Mainly good for restarting, to make sure we close the help.txt fd. */ + help_free( &global.help ); + if( global.restart ) { char *fn = ipc_master_save_state(); -- cgit v1.2.3 From 979cfb448cc233e29ceb6cd43f99fb4104728be6 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 3 Feb 2008 13:54:19 +0000 Subject: Saner garbage collection of cached packets in the Jabber module. Now cached packets are removed after about ten minues instead of something between one and two minutes. Closes one issue in #354. --- protocols/jabber/jabber.h | 5 +++++ protocols/jabber/jabber_util.c | 16 ++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index cf0f8e6a..5132d45f 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -94,6 +94,7 @@ typedef xt_status (*jabber_cache_event) ( struct im_connection *ic, struct xt_no struct jabber_cache_entry { + time_t saved_at; struct xt_node *node; jabber_cache_event func; }; @@ -140,6 +141,10 @@ struct jabber_chat #define JABBER_PACKET_ID "BeeP" #define JABBER_CACHED_ID "BeeC" +/* The number of seconds to keep cached packets before garbage collecting + them. This gc is done on every keepalive (every minute). */ +#define JABBER_CACHE_MAX_AGE 600 + /* RFC 392[01] stuff */ #define XMLNS_TLS "urn:ietf:params:xml:ns:xmpp-tls" #define XMLNS_SASL "urn:ietf:params:xml:ns:xmpp-sasl" diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index 794a1040..6e872040 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -141,6 +141,7 @@ void jabber_cache_add( struct im_connection *ic, struct xt_node *node, jabber_ca entry->node = node; entry->func = func; + entry->saved_at = time( NULL ); g_hash_table_insert( jd->node_cache, xt_find_attr( node, "id" ), entry ); } @@ -162,22 +163,17 @@ gboolean jabber_cache_clean_entry( gpointer key, gpointer entry, gpointer nullpo void jabber_cache_clean( struct im_connection *ic ) { struct jabber_data *jd = ic->proto_data; + time_t threshold = time( NULL ) - JABBER_CACHE_MAX_AGE; - g_hash_table_foreach_remove( jd->node_cache, jabber_cache_clean_entry, NULL ); + g_hash_table_foreach_remove( jd->node_cache, jabber_cache_clean_entry, &threshold ); } -gboolean jabber_cache_clean_entry( gpointer key, gpointer entry_, gpointer nullpointer ) +gboolean jabber_cache_clean_entry( gpointer key, gpointer entry_, gpointer threshold_ ) { struct jabber_cache_entry *entry = entry_; - struct xt_node *node = entry->node; + time_t *threshold = threshold_; - if( node->flags & XT_SEEN ) - return TRUE; - else - { - node->flags |= XT_SEEN; - return FALSE; - } + return entry->saved_at < *threshold; } xt_status jabber_cache_handle_packet( struct im_connection *ic, struct xt_node *node ) -- cgit v1.2.3 From 8c1eb8025f493ce22b4cc58da1ecfd4afa416816 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 3 Feb 2008 16:59:39 +0000 Subject: Implemented XEP-0115. This adds some info to the tags so clients interested in capabilities can cache discovery info, so they don't have to ask about it every time you/they log in. --- protocols/jabber/iq.c | 3 ++- protocols/jabber/jabber.h | 1 + protocols/jabber/presence.c | 34 ++++++++++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c index e1bab29e..c88bc0b0 100644 --- a/protocols/jabber/iq.c +++ b/protocols/jabber/iq.c @@ -91,7 +91,8 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ) } else if( strcmp( s, XMLNS_DISCOVER ) == 0 ) { - const char *features[] = { XMLNS_VERSION, + const char *features[] = { XMLNS_DISCOVER, + XMLNS_VERSION, XMLNS_TIME, XMLNS_CHATSTATES, XMLNS_MUC, diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 5132d45f..44655409 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -165,6 +165,7 @@ struct jabber_chat #define XMLNS_DISCOVER "http://jabber.org/protocol/disco#info" /* 0030 */ #define XMLNS_MUC "http://jabber.org/protocol/muc" /* XEP-0045 */ #define XMLNS_MUC_USER "http://jabber.org/protocol/muc#user"/* XEP-0045 */ +#define XMLNS_CAPS "http://jabber.org/protocol/caps" /* XEP-0115 */ /* iq.c */ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ); diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c index 2c49b800..6fc360b7 100644 --- a/protocols/jabber/presence.c +++ b/protocols/jabber/presence.c @@ -28,7 +28,7 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) struct im_connection *ic = data; char *from = xt_find_attr( node, "from" ); char *type = xt_find_attr( node, "type" ); /* NULL should mean the person is online. */ - struct xt_node *c; + struct xt_node *c, *cap; struct jabber_buddy *bud, *send_presence = NULL; int is_chat = 0; char *s; @@ -76,6 +76,26 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) else bud->priority = 0; + if( bud && ( cap = xt_find_node( node->children, "c" ) ) && + ( s = xt_find_attr( cap, "xmlns" ) ) && strcmp( s, XMLNS_CAPS ) == 0 ) + { + /* This stanza includes an XEP-0115 + capabilities part. Not too interesting, but we can + see if it has an ext= attribute. */ + s = xt_find_attr( cap, "ext" ); + if( s && ( strstr( s, "cstates" ) || strstr( s, "chatstate" ) ) ) + bud->flags |= JBFLAG_DOES_XEP85; + + /* This field can contain more information like xhtml + support, but we don't support that ourselves. + Officially the ext= tag was deprecated, but enough + clients do send it. + + (I'm aware that this is not the right way to use + this field.) See for an explanation of ext=: + http://www.xmpp.org/extensions/attic/xep-0115-1.3.html*/ + } + if( is_chat ) jabber_chat_pkt_presence( ic, bud, node ); else @@ -185,7 +205,7 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) int presence_send_update( struct im_connection *ic ) { struct jabber_data *jd = ic->proto_data; - struct xt_node *node; + struct xt_node *node, *cap; char *show = jd->away_state->code; char *status = jd->away_message; struct groupchat *c; @@ -198,6 +218,16 @@ int presence_send_update( struct im_connection *ic ) if( status ) xt_add_child( node, xt_new_node( "status", status, NULL ) ); + /* This makes the packet slightly bigger, but clients interested in + capabilities can now cache the discovery info. This reduces the + usual post-login iq-flood. See XEP-0115. At least libpurple and + Trillian seem to do this right. */ + cap = xt_new_node( "c", NULL, NULL ); + xt_add_attr( cap, "xmlns", XMLNS_CAPS ); + xt_add_attr( cap, "node", "http://bitlbee.org/xmpp/caps" ); + xt_add_attr( cap, "ver", BITLBEE_VERSION ); /* The XEP wants this hashed, but nobody's doing that. */ + xt_add_child( node, cap ); + st = jabber_write_packet( ic, node ); /* Have to send this update to all groupchats too, the server won't -- cgit v1.2.3 From 8ff0a61e7389db201ff4534f267225af6f66736b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 3 Feb 2008 17:11:15 +0000 Subject: Disabling "Unknown command" warnings since they're very noisy and pretty pointless. --- protocols/msn/ns.c | 2 +- protocols/msn/sb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 3735aad6..0bb84a74 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -583,7 +583,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } else { - debug( "Received unknown command from main server: %s", cmd[0] ); + /* debug( "Received unknown command from main server: %s", cmd[0] ); */ } return( 1 ); diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c index cdf2e8ad..18c41ef5 100644 --- a/protocols/msn/sb.c +++ b/protocols/msn/sb.c @@ -593,7 +593,7 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts ) } else { - debug( "Received unknown command from switchboard server: %s", cmd[0] ); + /* debug( "Received unknown command from switchboard server: %s", cmd[0] ); */ } return( 1 ); -- cgit v1.2.3 From 63075d7345355dde6e490ad00a886a1b165dbe17 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 3 Feb 2008 23:33:18 +0000 Subject: Messages from the user are also included in backlogs when joining a Jabber chatroom. Until now they were ignored, which might make backlogs a little bit confusing. --- protocols/jabber/conference.c | 9 ++++++--- protocols/jabber/jabber.h | 14 ++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/protocols/jabber/conference.c b/protocols/jabber/conference.c index 515194fc..f206e084 100644 --- a/protocols/jabber/conference.c +++ b/protocols/jabber/conference.c @@ -122,6 +122,8 @@ int jabber_chat_msg( struct groupchat *c, char *message, int flags ) struct jabber_chat *jc = c->data; struct xt_node *node; + jc->flags |= JCFLAG_MESSAGE_SENT; + node = xt_new_node( "body", message, NULL ); node = jabber_make_packet( "message", "groupchat", jc->name, node ); @@ -294,10 +296,11 @@ void jabber_chat_pkt_message( struct im_connection *ic, struct jabber_buddy *bud { struct xt_node *subject = xt_find_node( node->children, "subject" ); struct xt_node *body = xt_find_node( node->children, "body" ); - struct groupchat *chat = NULL; + struct groupchat *chat = bud ? jabber_chat_by_jid( ic, bud->bare_jid ) : NULL; + struct jabber_chat *jc = chat ? chat->data : NULL; char *s; - if( bud == NULL ) + if( bud == NULL || ( jc && ~jc->flags & JCFLAG_MESSAGE_SENT && bud == jc->me ) ) { char *nick; @@ -345,7 +348,7 @@ void jabber_chat_pkt_message( struct im_connection *ic, struct jabber_buddy *bud return; } - else if( ( chat = jabber_chat_by_jid( ic, bud->bare_jid ) ) == NULL ) + else if( chat == NULL ) { /* How could this happen?? We could do kill( self, 11 ) now or just wait for the OS to do it. :-) */ diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 44655409..1ff0e8dd 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -48,16 +48,22 @@ typedef enum typedef enum { - JBFLAG_PROBED_XEP85 = 1, /* Set this when we sent our probe packet to make + JBFLAG_PROBED_XEP85 = 1, /* Set this when we sent our probe packet to make sure it gets sent only once. */ - JBFLAG_DOES_XEP85 = 2, /* Set this when the resource seems to support + JBFLAG_DOES_XEP85 = 2, /* Set this when the resource seems to support XEP85 (typing notification shite). */ - JBFLAG_IS_CHATROOM = 4, /* It's convenient to use this JID thingy for + JBFLAG_IS_CHATROOM = 4, /* It's convenient to use this JID thingy for groupchat state info too. */ - JBFLAG_IS_ANONYMOUS = 8, /* For anonymous chatrooms, when we don't have + JBFLAG_IS_ANONYMOUS = 8, /* For anonymous chatrooms, when we don't have have a real JID. */ } jabber_buddy_flags_t; +typedef enum +{ + JCFLAG_MESSAGE_SENT = 1, /* Set this after sending the first message, so + we can detect echoes/backlogs. */ +} jabber_chat_flags_t; + struct jabber_data { struct im_connection *ic; -- cgit v1.2.3 From 69ac78cef9505f334cf61d13825371ce0c67ca16 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 4 Feb 2008 23:54:08 +0000 Subject: Added bogus G_GNUC_MALLOC to restore GLib 2.4 compatibility (hopefully). --- bitlbee.h | 6 ++++++ crypting.c | 5 +---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bitlbee.h b/bitlbee.h index 23ec64b1..55687e3b 100644 --- a/bitlbee.h +++ b/bitlbee.h @@ -98,6 +98,12 @@ #define F_OK 0 #endif +#ifndef G_GNUC_MALLOC +/* Doesn't exist in GLib <=2.4 while everything else in BitlBee should + work with it, so let's fake this one. */ +#define G_GNUC_MALLOC +#endif + #define _( x ) x #define ROOT_NICK "root" diff --git a/crypting.c b/crypting.c index 2a17a913..34b99034 100644 --- a/crypting.c +++ b/crypting.c @@ -28,10 +28,7 @@ included if CRYPTING_MAIN is defined. Or just do "make decode" and the programs will be built. */ -#include -#include -#include -#include +#include #include "md5.h" #include "crypting.h" -- cgit v1.2.3 From c84e31ae1e972a327b103ada52cae6a2e2335767 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 7 Feb 2008 21:25:18 +0000 Subject: Fixed getnameinfo() calls, this fixes Solaris stability issues. Thanks to Logan O'Sullivan Bruns for the report. --- irc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/irc.c b/irc.c index 2510e3d9..3a09f684 100644 --- a/irc.c +++ b/irc.c @@ -73,7 +73,7 @@ irc_t *irc_new( int fd ) char buf[NI_MAXHOST+1]; if( getnameinfo( (struct sockaddr *) &sock, socklen, buf, - NI_MAXHOST, NULL, -1, 0 ) == 0 ) + NI_MAXHOST, NULL, 0, 0 ) == 0 ) { irc->myhost = g_strdup( ipv6_unwrap( buf ) ); } @@ -84,7 +84,7 @@ irc_t *irc_new( int fd ) char buf[NI_MAXHOST+1]; if( getnameinfo( (struct sockaddr *)&sock, socklen, buf, - NI_MAXHOST, NULL, -1, 0 ) == 0 ) + NI_MAXHOST, NULL, 0, 0 ) == 0 ) { irc->host = g_strdup( ipv6_unwrap( buf ) ); } -- cgit v1.2.3 From 7adc657830fe76df344bf718df45ca05cc015d4e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 9 Feb 2008 23:54:09 +0000 Subject: Restored "add -tmp". A bit hackish, but it will do for now. --- root_commands.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/root_commands.c b/root_commands.c index 26a42a25..8e315bd4 100644 --- a/root_commands.c +++ b/root_commands.c @@ -448,7 +448,7 @@ static void cmd_add( irc_t *irc, char **cmd ) if( g_strcasecmp( cmd[1], "-tmp" ) == 0 ) { add_on_server = 0; - cmd ++; /* So evil... :-D */ + cmd ++; } if( !( a = account_get( irc, cmd[1] ) ) ) @@ -480,12 +480,13 @@ static void cmd_add( irc_t *irc, char **cmd ) } } - /* By making this optional, you can talk to people without having to - add them to your *real* (server-side) contact list. */ if( add_on_server ) a->ic->acc->prpl->add_buddy( a->ic, cmd[2], NULL ); - - /* add_buddy( a->ic, NULL, cmd[2], cmd[2] ); */ + 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 ); irc_usermsg( irc, "Adding `%s' to your contact list", cmd[2] ); } -- cgit v1.2.3 From 1ecff5ee9ab540584a8b15814dcc15f706a26d4c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 10 Feb 2008 11:12:35 +0000 Subject: Making AI_ADDRCONFIG optional, it doesn't exist on at least NetBSD and (IIRC) OpenBSD systems. --- bitlbee.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bitlbee.c b/bitlbee.c index c4b5abb3..59a417f0 100644 --- a/bitlbee.c +++ b/bitlbee.c @@ -47,7 +47,11 @@ int bitlbee_daemon_init() memset( &hints, 0, sizeof( hints ) ); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE; + hints.ai_flags = AI_PASSIVE +#ifdef AI_ADDRCONFIG + | AI_ADDRCONFIG +#endif + ; i = getaddrinfo( global.conf->iface, global.conf->port, &hints, &addrinfo_bind ); if( i ) -- cgit v1.2.3 From 3038e476a93b2be057581b831749eac931a06559 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 10 Feb 2008 17:11:06 +0000 Subject: Added support for password-protected Jabber chatrooms. --- protocols/jabber/conference.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/protocols/jabber/conference.c b/protocols/jabber/conference.c index f206e084..79fdd053 100644 --- a/protocols/jabber/conference.c +++ b/protocols/jabber/conference.c @@ -36,6 +36,8 @@ struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char * node = xt_new_node( "x", NULL, NULL ); xt_add_attr( node, "xmlns", XMLNS_MUC ); node = jabber_make_packet( "presence", NULL, roomjid, node ); + if( password ) + xt_add_child( node, xt_new_node( "password", password, NULL ) ); jabber_cache_add( ic, node, jabber_chat_join_failed ); if( !jabber_write_packet( ic, node ) ) -- 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. --- bitlbee.h | 3 +-- conf.c | 45 ++++++++++++++++++++++++--------------------- irc_commands.c | 2 +- storage_text.c | 8 ++++---- storage_xml.c | 4 ++-- unix.c | 2 +- 6 files changed, 33 insertions(+), 31 deletions(-) diff --git a/bitlbee.h b/bitlbee.h index 55687e3b..c118d7fc 100644 --- a/bitlbee.h +++ b/bitlbee.h @@ -121,8 +121,6 @@ #define HELP_FILE VARDIR "help.txt" #define CONF_FILE_DEF ETCDIR "bitlbee.conf" -extern char *CONF_FILE; - #include "irc.h" #include "storage.h" #include "set.h" @@ -144,6 +142,7 @@ typedef struct global { int listen_socket; gint listen_watch_source_id; help_t *help; + char *conf_file; conf_t *conf; GList *storage; /* The first backend in the list will be used for saving */ char *helpfile; diff --git a/conf.c b/conf.c index 94c673cc..57902826 100644 --- a/conf.c +++ b/conf.c @@ -35,14 +35,12 @@ #include "proxy.h" -char *CONF_FILE; - static int conf_loadini( conf_t *conf, char *file ); conf_t *conf_load( int argc, char *argv[] ) { conf_t *conf; - int opt, i; + int opt, i, config_missing = 0; conf = g_new0( conf_t, 1 ); @@ -65,15 +63,17 @@ conf_t *conf_load( int argc, char *argv[] ) conf->user = NULL; proxytype = 0; - i = conf_loadini( conf, CONF_FILE ); + i = conf_loadini( conf, global.conf_file ); if( i == 0 ) { - fprintf( stderr, "Error: Syntax error in configuration file `%s'.\n", CONF_FILE ); - return( NULL ); + fprintf( stderr, "Error: Syntax error in configuration file `%s'.\n", global.conf_file ); + return NULL; } else if( i == -1 ) { - fprintf( stderr, "Warning: Unable to read configuration file `%s'.\n", CONF_FILE ); + config_missing ++; + /* Whine after parsing the options if there was no -c pointing + at a *valid* configuration file. */ } while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:u:" ) ) >= 0 ) @@ -105,16 +105,16 @@ conf_t *conf_load( int argc, char *argv[] ) conf->runmode = RUNMODE_FORKDAEMON; else if( opt == 'c' ) { - if( strcmp( CONF_FILE, optarg ) != 0 ) + if( strcmp( global.conf_file, optarg ) != 0 ) { - g_free( CONF_FILE ); - CONF_FILE = g_strdup( optarg ); + g_free( global.conf_file ); + global.conf_file = g_strdup( optarg ); g_free( conf ); /* Re-evaluate arguments. Don't use this option twice, you'll end up in an infinite loop! Hope this trick works with all libcs BTW.. */ optind = 1; - return( conf_load( argc, argv ) ); + return conf_load( argc, argv ); } } else if( opt == 'd' ) @@ -142,7 +142,7 @@ conf_t *conf_load( int argc, char *argv[] ) " -c Load alternative configuration file\n" " -d Specify alternative user configuration directory\n" " -h Show this help page.\n" ); - return( NULL ); + return NULL; } else if( opt == 'R' ) { @@ -168,7 +168,10 @@ conf_t *conf_load( int argc, char *argv[] ) conf->configdir = s; } - return( conf ); + if( config_missing ) + fprintf( stderr, "Warning: Unable to read configuration file `%s'.\n", global.conf_file ); + + return conf; } static int conf_loadini( conf_t *conf, char *file ) @@ -177,7 +180,7 @@ static int conf_loadini( conf_t *conf, char *file ) int i; ini = ini_open( file ); - if( ini == NULL ) return( -1 ); + if( ini == NULL ) return -1; while( ini_read( ini ) ) { if( g_strcasecmp( ini->section, "settings" ) == 0 ) @@ -255,7 +258,7 @@ static int conf_loadini( conf_t *conf, char *file ) if( sscanf( ini->value, "%d", &i ) != 1 ) { fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); - return( 0 ); + return 0; } conf->ping_interval = i; } @@ -264,7 +267,7 @@ static int conf_loadini( conf_t *conf, char *file ) if( sscanf( ini->value, "%d", &i ) != 1 ) { fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); - return( 0 ); + return 0; } conf->ping_timeout = i; } @@ -276,7 +279,7 @@ static int conf_loadini( conf_t *conf, char *file ) { fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); g_free( url ); - return( 0 ); + return 0; } strncpy( proxyhost, url->host, sizeof( proxyhost ) ); @@ -300,7 +303,7 @@ static int conf_loadini( conf_t *conf, char *file ) else { fprintf( stderr, "Error: Unknown setting `%s` in configuration file.\n", ini->key ); - return( 0 ); + return 0; /* For now just ignore unknown keys... */ } } @@ -308,19 +311,19 @@ static int conf_loadini( conf_t *conf, char *file ) { fprintf( stderr, "Error: Unknown section [%s] in configuration file. " "BitlBee configuration must be put in a [settings] section!\n", ini->section ); - return( 0 ); + return 0; } } ini_close( ini ); - return( 1 ); + return 1; } void conf_loaddefaults( irc_t *irc ) { ini_t *ini; - ini = ini_open( CONF_FILE ); + ini = ini_open( global.conf_file ); if( ini == NULL ) return; while( ini_read( ini ) ) { 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[] = { diff --git a/storage_text.c b/storage_text.c index 7c29d95a..5ee6438d 100644 --- a/storage_text.c +++ b/storage_text.c @@ -29,10 +29,10 @@ static void text_init (void) { - if( access( global.conf->configdir, F_OK ) != 0 ) - log_message( LOGLVL_WARNING, "The configuration directory %s does not exist. Configuration won't be saved.", global.conf->configdir ); - else if( access( global.conf->configdir, R_OK ) != 0 || access( global.conf->configdir, W_OK ) != 0 ) - log_message( LOGLVL_WARNING, "Permission problem: Can't read/write from/to %s.", global.conf->configdir ); + /* Don't complain about the configuration directory anymore, leave it + up to the XML storage module, which uses the same directory for it + anyway. Nobody should be using just the text plugin anymore since + it's read only! */ } static storage_status_t text_load ( const char *my_nick, const char* password, irc_t *irc ) diff --git a/storage_xml.c b/storage_xml.c index 4c372cde..19070a74 100644 --- a/storage_xml.c +++ b/storage_xml.c @@ -262,9 +262,9 @@ GMarkupParser xml_parser = static void xml_init( void ) { if( access( global.conf->configdir, F_OK ) != 0 ) - log_message( LOGLVL_WARNING, "The configuration directory %s does not exist. Configuration won't be saved.", global.conf->configdir ); + log_message( LOGLVL_WARNING, "The configuration directory `%s' does not exist. Configuration won't be saved.", global.conf->configdir ); else if( access( global.conf->configdir, R_OK ) != 0 || access( global.conf->configdir, W_OK ) != 0 ) - log_message( LOGLVL_WARNING, "Permission problem: Can't read/write from/to %s.", global.conf->configdir ); + log_message( LOGLVL_WARNING, "Permission problem: Can't read/write from/to `%s'.", global.conf->configdir ); } static storage_status_t xml_load_real( const char *my_nick, const char *password, irc_t *irc, xml_pass_st action ) diff --git a/unix.c b/unix.c index 9b670d78..d25aeb2e 100644 --- a/unix.c +++ b/unix.c @@ -46,7 +46,7 @@ int main( int argc, char *argv[], char **envp ) struct sigaction sig, old; log_init(); - CONF_FILE = g_strdup( CONF_FILE_DEF ); + global.conf_file = g_strdup( CONF_FILE_DEF ); global.conf = conf_load( argc, argv ); if( global.conf == NULL ) return( 1 ); -- cgit v1.2.3