From b75acf6367400ff88428618719cefbbee648b0cb Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 22 Oct 2009 22:55:23 +0100 Subject: Don't include chat.h from bitlbee.h. make install-dev doesn't install chat.h and it shouldn't ... but things broke because bitlbee.h includes it. Fixes #534. --- account.c | 1 + bitlbee.h | 1 - chat.c | 1 + chat.h | 5 +++++ irc_commands.c | 1 + protocols/nogaim.h | 1 + root_commands.c | 1 + storage_xml.c | 1 + 8 files changed, 11 insertions(+), 1 deletion(-) diff --git a/account.c b/account.c index cb54731f..912cba6a 100644 --- a/account.c +++ b/account.c @@ -26,6 +26,7 @@ #define BITLBEE_CORE #include "bitlbee.h" #include "account.h" +#include "chat.h" account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass ) { diff --git a/bitlbee.h b/bitlbee.h index cbda42cd..46a91419 100644 --- a/bitlbee.h +++ b/bitlbee.h @@ -128,7 +128,6 @@ #include "commands.h" #include "account.h" #include "nick.h" -#include "chat.h" #include "conf.h" #include "log.h" #include "ini.h" diff --git a/chat.c b/chat.c index 87c262b8..8c5ce0bc 100644 --- a/chat.c +++ b/chat.c @@ -24,6 +24,7 @@ */ #include "bitlbee.h" +#include "chat.h" struct chat *chat_add( irc_t *irc, account_t *acc, char *handle, char *channel ) { diff --git a/chat.h b/chat.h index 5aef745c..7196aea8 100644 --- a/chat.h +++ b/chat.h @@ -23,6 +23,9 @@ Suite 330, Boston, MA 02111-1307 USA */ +#ifndef _CHAT_H +#define _CHAT_H + struct chat { account_t *acc; @@ -44,3 +47,5 @@ int chat_chancmp( char *a, char *b ); int chat_chanok( char *a ); int chat_join( irc_t *irc, struct chat *c, const char *password ); + +#endif diff --git a/irc_commands.c b/irc_commands.c index 044ff62c..74334ee9 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -26,6 +26,7 @@ #define BITLBEE_CORE #include "bitlbee.h" #include "ipc.h" +#include "chat.h" static void irc_cmd_pass( irc_t *irc, char **cmd ) { diff --git a/protocols/nogaim.h b/protocols/nogaim.h index 1e5df503..ade8c23f 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -43,6 +43,7 @@ #include "proxy.h" #include "query.h" #include "md5.h" +#include "chat.h" #define BUDDY_ALIAS_MAXLEN 388 /* because MSN names can be 387 characters */ diff --git a/root_commands.c b/root_commands.c index 678ee143..5de616fb 100644 --- a/root_commands.c +++ b/root_commands.c @@ -28,6 +28,7 @@ #include "crypting.h" #include "bitlbee.h" #include "help.h" +#include "chat.h" #include diff --git a/storage_xml.c b/storage_xml.c index b78c3661..b6745c75 100644 --- a/storage_xml.c +++ b/storage_xml.c @@ -28,6 +28,7 @@ #include "base64.h" #include "arc.h" #include "md5.h" +#include "chat.h" #if GLIB_CHECK_VERSION(2,8,0) #include -- cgit v1.2.3 From 4cf80bb798a4159f42a904cb830b99c87a0ca8e0 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 23 Oct 2009 11:43:15 +0100 Subject: Shuffling a few more #includes. Much more shuffling will be needed. --- lib/misc.c | 1 + protocols/jabber/jabber.h | 3 ++- protocols/nogaim.c | 4 +++- protocols/nogaim.h | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/misc.c b/lib/misc.c index 9d504b75..35e9909b 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -45,6 +45,7 @@ #include #endif +#include "md5.h" #include "ssl_client.h" void strip_linefeed(gchar *text) diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index ee453144..1180d2b9 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -26,8 +26,9 @@ #include -#include "xmltree.h" #include "bitlbee.h" +#include "md5.h" +#include "xmltree.h" extern GSList *jabber_connections; diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 710b7645..21f7dcb1 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -32,9 +32,11 @@ */ #define BITLBEE_CORE -#include "nogaim.h" #include +#include "nogaim.h" +#include "chat.h" + static int remove_chat_buddy_silent( struct groupchat *b, const char *handle ); GSList *connections; diff --git a/protocols/nogaim.h b/protocols/nogaim.h index ade8c23f..dc6154e2 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -38,12 +38,12 @@ #ifndef _NOGAIM_H #define _NOGAIM_H +#include + #include "bitlbee.h" #include "account.h" #include "proxy.h" #include "query.h" -#include "md5.h" -#include "chat.h" #define BUDDY_ALIAS_MAXLEN 388 /* because MSN names can be 387 characters */ -- cgit v1.2.3 From fb51d85751b36098ad4271bc4553ade4dc53f20b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 24 Oct 2009 00:57:41 +0100 Subject: "chat add", not chat_add --- doc/user-guide/misc.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/user-guide/misc.xml b/doc/user-guide/misc.xml index 3102b8b0..68b44e95 100644 --- a/doc/user-guide/misc.xml +++ b/doc/user-guide/misc.xml @@ -76,7 +76,7 @@ Then, just use the ordinary IRC /invite command to invite m -Some protocols (like Jabber) also support named groupchats. BitlBee now supports these too. You can use the chat add command to join them. See help chat_add for more information. +Some protocols (like Jabber) also support named groupchats. BitlBee now supports these too. You can use the chat add command to join them. See help chat add for more information. -- cgit v1.2.3 From 36cf9fda6a5cc4bcbfe98319b48af636fa142590 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 12 Nov 2009 20:41:54 +0900 Subject: Proper detection of a usable libresolv.so or libresolv.a. glibc 2.9 and later are no longer retarded and support SRV record lookups without having to link against a static library. --- configure | 49 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/configure b/configure index b3a98086..9d92cedf 100755 --- a/configure +++ b/configure @@ -266,7 +266,7 @@ EOF detect_ldap() { - TMPFILE=`mktemp` + TMPFILE=$(mktemp) if $CC -o $TMPFILE -shared -lldap 2>/dev/null >/dev/null; then cat<>Makefile.settings EFLAGS+=-lldap @@ -281,6 +281,43 @@ EOF fi } +RESOLV_TESTCODE=' +#include +#include + +int main() +{ + ns_initparse( NULL, 0, NULL ); + ns_parserr( NULL, ns_s_an, 0, NULL ); +} +' + +detect_resolv_dynamic() +{ + echo "$RESOLV_TESTCODE" | $CC -o /dev/null -x c - -lresolv >/dev/null 2>/dev/null + if [ "$?" = "0" ]; then + echo 'EFLAGS+=-lresolv' >> Makefile.settings + return 0 + fi + + return 1 +} + +detect_resolv_static() +{ + for i in $systemlibdirs; do + if [ -f $i/libresolv.a ]; then + echo "$RESOLV_TESTCODE" | $CC -o /dev/null -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null + if [ "$?" = "0" ]; then + echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings + return 0 + fi + fi + done + + return 1 +} + if [ "$ssl" = "auto" ]; then detect_gnutls if [ "$ret" = "0" ]; then @@ -348,13 +385,9 @@ fi; echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings -for i in $systemlibdirs; do - if [ -f $i/libresolv.a ]; then - echo '#define HAVE_RESOLV_A' >> config.h - echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings - break - fi -done +if detect_resolv_dynamic || detect_resolv_static; then + echo '#define HAVE_RESOLV_A' >> config.h +fi STORAGES="text xml" -- cgit v1.2.3 From ec29351181b9557c5490d2eed38505d22f9ce6bb Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 7 Dec 2009 22:11:40 +0000 Subject: Committing some >1y old change. This seems to fix a small leak in the MSN mail notification handler. --- protocols/msn/ns.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index fe48f96d..30a35e4e 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -662,8 +662,8 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int imcb_log( ic, "The server is going down for maintenance in %s minutes.", arg1 ); } - if( arg1 ) g_free( arg1 ); - if( mtype ) g_free( mtype ); + g_free( arg1 ); + g_free( mtype ); } else if( g_strncasecmp( ct, "text/x-msmsgsprofile", 20 ) == 0 ) { @@ -671,25 +671,30 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int } else if( g_strncasecmp( ct, "text/x-msmsgsinitialemailnotification", 37 ) == 0 ) { - char *inbox = msn_findheader( body, "Inbox-Unread:", blen ); - char *folders = msn_findheader( body, "Folders-Unread:", blen ); - - if( inbox && folders && set_getbool( &ic->acc->set, "mail_notifications" ) ) + if( set_getbool( &ic->acc->set, "mail_notifications" ) ) { - imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); + char *inbox = msn_findheader( body, "Inbox-Unread:", blen ); + char *folders = msn_findheader( body, "Folders-Unread:", blen ); + + if( inbox && folders ) + imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); + + g_free( inbox ); + g_free( folders ); } - - g_free( inbox ); - g_free( folders ); } else if( g_strncasecmp( ct, "text/x-msmsgsemailnotification", 30 ) == 0 ) { - char *from = msn_findheader( body, "From-Addr:", blen ); - char *fromname = msn_findheader( body, "From:", blen ); - - if( from && fromname && set_getbool( &ic->acc->set, "mail_notifications" ) ) + if( set_getbool( &ic->acc->set, "mail_notifications" ) ) { - imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from ); + char *from = msn_findheader( body, "From-Addr:", blen ); + char *fromname = msn_findheader( body, "From:", blen ); + + if( from && fromname ) + imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from ); + + g_free( from ); + g_free( fromname ); } } else if( g_strncasecmp( ct, "text/x-msmsgsactivemailnotification", 35 ) == 0 ) -- cgit v1.2.3 From ccba98084344125e0f89331baced2ba6d1802b29 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 17 Dec 2009 00:42:25 +0000 Subject: A few fixes for bugs that caused coredumps on testing.bitlbee.org (or caught my attention in new compiler warnings). --- protocols/msn/msn_util.c | 2 +- protocols/yahoo/libyahoo2.c | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index 58ad22f8..6b12217b 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -373,6 +373,6 @@ void msn_msgq_purge( struct im_connection *ic, GSList **list ) g_slist_free( *list ); *list = NULL; - imcb_log( ic, ret->str ); + imcb_log( ic, "%s", ret->str ); g_string_free( ret, TRUE ); } diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index a1755cc9..836670f7 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -1529,12 +1529,19 @@ static void yahoo_process_buddy_list(struct yahoo_input_data *yid, struct yahoo_ case 7: newbud = y_new0(struct yahoo_buddy, 1); newbud->id = strdup(pair->value); - if(cur_group) + if (cur_group) { newbud->group = strdup(cur_group); - else { - struct yahoo_buddy *lastbud = (struct yahoo_buddy *)y_list_nth( - yd->buddies, y_list_length(yd->buddies)-1)->data; - newbud->group = strdup(lastbud->group); + } else { + YList *last; + struct yahoo_buddy *lastbud; + + for (last = yd->buddies; last && last->next; last = last->next); + if (last) { + lastbud = last->data; + newbud->group = strdup(lastbud->group); + } else { + newbud->group = strdup("Buddies"); + } } yd->buddies = y_list_append(yd->buddies, newbud); @@ -2392,10 +2399,16 @@ static void yahoo_https_auth_token_init(struct yahoo_https_auth_data *had) static void yahoo_https_auth_token_finish(struct http_request *req) { struct yahoo_https_auth_data *had = req->data; - struct yahoo_input_data *yid = had->yid; - struct yahoo_data *yd = yid->yd; + struct yahoo_input_data *yid; + struct yahoo_data *yd; int st; + if (y_list_find(inputs, had->yid) == NULL) + return; + + yid = had->yid; + yd = yid->yd; + if (req->status_code != 200) { YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, 2000 + req->status_code, NULL); goto fail; @@ -2435,12 +2448,18 @@ static void yahoo_https_auth_init(struct yahoo_https_auth_data *had) static void yahoo_https_auth_finish(struct http_request *req) { struct yahoo_https_auth_data *had = req->data; - struct yahoo_input_data *yid = had->yid; - struct yahoo_data *yd = yid->yd; + struct yahoo_input_data *yid; + struct yahoo_data *yd; struct yahoo_packet *pack; - char *crumb; + char *crumb = NULL; int st; + if (y_list_find(inputs, had->yid) == NULL) + return; + + yid = had->yid; + yd = yid->yd; + md5_byte_t result[16]; md5_state_t ctx; -- cgit v1.2.3 From 1c2eaa3c99a2e7fbe264b06e559f3d709b9a080d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 17 Feb 2010 00:17:04 +0000 Subject: Also disable Yahoo! module if SSL support is missing since it also fully depends on working SSL support. --- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 9d92cedf..cac1161e 100755 --- a/configure +++ b/configure @@ -359,11 +359,11 @@ elif [ "$ssl" = "bogus" ]; then echo 'Using bogus SSL code. This means some features will not work properly.' ## Yes, you, at the console! How can you authenticate if you don't have any SSL!? - if [ "$msn" = "1" ]; then + if [ "$msn" = "1" -o "$yahoo" = "1" ]; then echo - echo 'Real SSL support is necessary for MSN authentication, will build without' - echo 'MSN protocol support.' + echo 'WARNING: The MSN and Yahoo! modules will not work without SSL. Disabling.' msn=0 + yahoo=0 fi ret=1 -- cgit v1.2.3 From d1ad6f0973bda799bdf21e36f20dc58f7bb1bf08 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 6 Mar 2010 14:15:14 +0000 Subject: Preparing for per-account status/away messages. Convert some #defines in account.h to an enum while I'm at it. --- account.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/account.h b/account.h index cf22482c..984dcfe6 100644 --- a/account.h +++ b/account.h @@ -36,6 +36,7 @@ typedef struct account int auto_connect; int auto_reconnect_delay; int reconnect; + int flags; set_t *set; GHashTable *nicks; @@ -55,8 +56,17 @@ char *set_eval_account( set_t *set, char *value ); char *set_eval_account_reconnect_delay( set_t *set, char *value ); int account_reconnect_delay( account_t *a ); -#define ACC_SET_NOSAVE 0x01 -#define ACC_SET_OFFLINE_ONLY 0x02 -#define ACC_SET_ONLINE_ONLY 0x04 +typedef enum +{ + ACC_SET_NOSAVE = 0x01, /* Don't save this setting (i.e. stored elsewhere). */ + ACC_SET_OFFLINE_ONLY = 0x02, /* Allow changes only if the acct is offline. */ + ACC_SET_ONLINE_ONLY = 0x04, /* Allow changes only if the acct is online. */ +} account_set_flag_t; + +typedef enum +{ + ACC_FLAG_AWAY_MESSAGE = 0x01, /* Supports away messages instead of just states. */ + ACC_FLAG_STATUS_MESSAGE = 0x02, /* Supports status messages (without being away). */ +} account_flag_t; #endif -- cgit v1.2.3 From 840bba81bc4ab7ce37aeeea5f32091684b19e5b8 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 6 Mar 2010 14:50:52 +0000 Subject: The Jabber part of the change. Also made representation of not-away a bit more consistent. Except for free-for-chat, which is nuts anyway. --- protocols/jabber/jabber.c | 11 +++++++---- protocols/jabber/jabber.h | 2 +- protocols/jabber/jabber_util.c | 9 +++++++-- protocols/jabber/presence.c | 17 +++++++---------- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index b8e88c26..35cf08c5 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -79,6 +79,8 @@ static void jabber_init( account_t *acc ) s = set_add( &acc->set, "xmlconsole", "false", set_eval_bool, acc ); s->flags |= ACC_SET_OFFLINE_ONLY; + + acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE; } static void jabber_generate_id_hash( struct jabber_data *jd ); @@ -376,11 +378,12 @@ static void jabber_get_info( struct im_connection *ic, char *who ) static void jabber_set_away( struct im_connection *ic, char *state_txt, char *message ) { struct jabber_data *jd = ic->proto_data; - struct jabber_away_state *state; - /* Save all this info. We need it, for example, when changing the priority setting. */ - state = (void *) jabber_away_state_by_name( state_txt ); - jd->away_state = state ? state : (void *) jabber_away_state_list; /* Fall back to "Away" if necessary. */ + /* state_txt == NULL -> Not away. + Unknown state -> fall back to the first defined away state. */ + jd->away_state = state_txt ? jabber_away_state_by_name( state_txt ) + ? : jabber_away_state_list : NULL; + g_free( jd->away_message ); jd->away_message = ( message && *message ) ? g_strdup( message ) : NULL; diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 1180d2b9..7bb66e0e 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -83,7 +83,7 @@ struct jabber_data /* After changing one of these two (or the priority setting), call presence_send_update() to inform the server about the changes. */ - struct jabber_away_state *away_state; + const struct jabber_away_state *away_state; char *away_message; md5_state_t cached_id_prefix; diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index 19a73b6a..185d3878 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -227,10 +227,9 @@ xt_status jabber_cache_handle_packet( struct im_connection *ic, struct xt_node * const struct jabber_away_state jabber_away_state_list[] = { { "away", "Away" }, - { "chat", "Free for Chat" }, + { "chat", "Free for Chat" }, /* WTF actually uses this? */ { "dnd", "Do not Disturb" }, { "xa", "Extended Away" }, - { "", "Online" }, { "", NULL } }; @@ -238,6 +237,9 @@ const struct jabber_away_state *jabber_away_state_by_code( char *code ) { int i; + if( code == NULL ) + return NULL; + for( i = 0; jabber_away_state_list[i].full_name; i ++ ) if( g_strcasecmp( jabber_away_state_list[i].code, code ) == 0 ) return jabber_away_state_list + i; @@ -249,6 +251,9 @@ const struct jabber_away_state *jabber_away_state_by_name( char *name ) { int i; + if( name == NULL ) + return NULL; + for( i = 0; jabber_away_state_list[i].full_name; i ++ ) if( g_strcasecmp( jabber_away_state_list[i].full_name, name ) == 0 ) return jabber_away_state_list + i; diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c index 939bc888..28aaea1b 100644 --- a/protocols/jabber/presence.c +++ b/protocols/jabber/presence.c @@ -189,13 +189,12 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) { int is_away = 0; - if( send_presence->away_state && !( *send_presence->away_state->code == 0 || - strcmp( send_presence->away_state->code, "chat" ) == 0 ) ) + if( send_presence->away_state && + 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, + is_away ? send_presence->away_state->full_name : NULL, send_presence->away_message ); } @@ -208,17 +207,15 @@ int presence_send_update( struct im_connection *ic ) { struct jabber_data *jd = ic->proto_data; struct xt_node *node, *cap; - char *show = jd->away_state->code; - char *status = jd->away_message; struct groupchat *c; int st; node = jabber_make_packet( "presence", NULL, NULL, NULL ); xt_add_child( node, xt_new_node( "priority", set_getstr( &ic->acc->set, "priority" ), NULL ) ); - if( show && *show ) - xt_add_child( node, xt_new_node( "show", show, NULL ) ); - if( status ) - xt_add_child( node, xt_new_node( "status", status, NULL ) ); + if( jd->away_state ) + xt_add_child( node, xt_new_node( "show", jd->away_state->code, NULL ) ); + if( jd->away_message ) + xt_add_child( node, xt_new_node( "status", jd->away_message, NULL ) ); /* This makes the packet slightly bigger, but clients interested in capabilities can now cache the discovery info. This reduces the -- cgit v1.2.3 From 2bc8ac0680e6a04f8431003ab468bb6e419534ed Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 6 Mar 2010 14:55:12 +0000 Subject: Away with this stupid GAIM_AWAY_CUSTOM constant. Let's see what still uses it. --- protocols/nogaim.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/protocols/nogaim.h b/protocols/nogaim.h index dc6154e2..80f8ed40 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -48,7 +48,6 @@ #define BUDDY_ALIAS_MAXLEN 388 /* because MSN names can be 387 characters */ #define WEBSITE "http://www.bitlbee.org/" -#define GAIM_AWAY_CUSTOM "Custom" /* Sharing flags between all kinds of things. I just hope I won't hit any limits before 32-bit machines become extinct. ;-) */ @@ -217,8 +216,8 @@ struct prpl { void (* chat_topic) (struct groupchat *, char *topic); /* You can tell what away states your protocol supports, so that - * BitlBee will try to map the IRC away reasons to them, or use - * GAIM_AWAY_CUSTOM when calling skype_set_away(). */ + * BitlBee will try to map the IRC away reasons to them. If your + * protocol doesn't have any, just return one generic "Away". */ GList *(* away_states)(struct im_connection *ic); /* Mainly for AOL, since they think "Bung hole" == "Bu ngho le". *sigh* -- cgit v1.2.3 From b051d39d99219852a1dc79f68ee301fc1fe16a5e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 6 Mar 2010 15:44:46 +0000 Subject: MSN module updated to deal with the new API. Not many changes since it doesn't currently support away messages anyway. This is more a bit of a cleanup. --- protocols/msn/msn.c | 18 ++++++++---------- protocols/msn/msn.h | 1 - protocols/msn/ns.c | 14 ++++++++------ protocols/msn/tables.c | 37 +++++++++++++------------------------ 4 files changed, 29 insertions(+), 41 deletions(-) diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index 046b2772..e12fb3a9 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -138,8 +138,9 @@ static GList *msn_away_states( struct im_connection *ic ) int i; if( l == NULL ) - for( i = 0; msn_away_state_list[i].number > -1; i ++ ) - l = g_list_append( l, (void*) msn_away_state_list[i].name ); + for( i = 0; *msn_away_state_list[i].code; i ++ ) + if( *msn_away_state_list[i].name ) + l = g_list_append( l, (void*) msn_away_state_list[i].name ); return l; } @@ -148,17 +149,14 @@ static void msn_set_away( struct im_connection *ic, char *state, char *message ) { char buf[1024]; struct msn_data *md = ic->proto_data; - const struct msn_away_state *st; - if( strcmp( state, GAIM_AWAY_CUSTOM ) == 0 ) - st = msn_away_state_by_name( "Away" ); + if( state ) + md->away_state = msn_away_state_by_name( state ) ? : + msn_away_state_list + 1; else - st = msn_away_state_by_name( state ); + md->away_state = msn_away_state_list; - if( !st ) st = msn_away_state_list; - md->away_state = st; - - g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, st->code ); + g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, md->away_state->code ); msn_write( ic, buf, strlen( buf ) ); } diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index 7c849acf..333ae7f0 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -96,7 +96,6 @@ struct msn_switchboard struct msn_away_state { - int number; char code[4]; char name[16]; }; diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 30a35e4e..d05d8e0d 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -419,11 +419,12 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( !st ) { /* FIXME: Warn/Bomb about unknown away state? */ - st = msn_away_state_list; + st = msn_away_state_list + 1; } - imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN | - ( st->number ? OPT_AWAY : 0 ), st->name, NULL ); + imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN | + ( st != msn_away_state_list ? OPT_AWAY : 0 ), + st->name, NULL ); } else if( strcmp( cmd[0], "FLN" ) == 0 ) { @@ -448,11 +449,12 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( !st ) { /* FIXME: Warn/Bomb about unknown away state? */ - st = msn_away_state_list; + st = msn_away_state_list + 1; } - imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN | - ( st->number ? OPT_AWAY : 0 ), st->name, NULL ); + imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN | + ( st != msn_away_state_list ? OPT_AWAY : 0 ), + st->name, NULL ); } else if( strcmp( cmd[0], "RNG" ) == 0 ) { diff --git a/protocols/msn/tables.c b/protocols/msn/tables.c index 5ba9ea73..b01361bd 100644 --- a/protocols/msn/tables.c +++ b/protocols/msn/tables.c @@ -28,48 +28,37 @@ const struct msn_away_state msn_away_state_list[] = { - { 0, "NLN", "Available" }, - { 1, "BSY", "Busy" }, - { 3, "IDL", "Idle" }, - { 5, "BRB", "Be Right Back" }, - { 7, "AWY", "Away" }, - { 9, "PHN", "On the Phone" }, - { 11, "LUN", "Out to Lunch" }, - { 13, "HDN", "Hidden" }, - { -1, "", "" } + { "NLN", "" }, + { "BSY", "Busy" }, + { "IDL", "Idle" }, + { "BRB", "Be Right Back" }, + { "AWY", "Away" }, + { "PHN", "On the Phone" }, + { "LUN", "Out to Lunch" }, + { "HDN", "Hidden" }, + { "", "" } }; -const struct msn_away_state *msn_away_state_by_number( int number ) -{ - int i; - - for( i = 0; msn_away_state_list[i].number > -1; i ++ ) - if( msn_away_state_list[i].number == number ) - return( msn_away_state_list + i ); - - return( NULL ); -} - const struct msn_away_state *msn_away_state_by_code( char *code ) { int i; - for( i = 0; msn_away_state_list[i].number > -1; i ++ ) + for( i = 0; *msn_away_state_list[i].code; i ++ ) if( g_strcasecmp( msn_away_state_list[i].code, code ) == 0 ) return( msn_away_state_list + i ); - return( NULL ); + return NULL; } const struct msn_away_state *msn_away_state_by_name( char *name ) { int i; - for( i = 0; msn_away_state_list[i].number > -1; i ++ ) + for( i = 0; *msn_away_state_list[i].code; i ++ ) if( g_strcasecmp( msn_away_state_list[i].name, name ) == 0 ) return( msn_away_state_list + i ); - return( NULL ); + return NULL; } const struct msn_status_code msn_status_code_list[] = -- cgit v1.2.3 From 17f952299cd2780a2dfecc4d4b9861f6f0f4b1c2 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 6 Mar 2010 16:17:23 +0000 Subject: OSCAR cleanup. --- protocols/oscar/oscar.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 1118c26d..3aa9f136 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -379,6 +379,8 @@ static void oscar_init(account_t *acc) s = set_add( &acc->set, "web_aware", "false", set_eval_bool, acc ); s->flags |= ACC_SET_OFFLINE_ONLY; } + + acc->flags |= ACC_FLAG_AWAY_MESSAGE; } static void oscar_login(account_t *acc) { @@ -1958,7 +1960,9 @@ static void oscar_set_away_aim(struct im_connection *ic, struct oscar_data *od, } else if (!g_strcasecmp(state, _("Invisible"))) { aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_INVISIBLE); return; - } /* else... */ + } else if (message == NULL) { + message = state; + } if (od->rights.maxawaymsglen == 0) imcb_error(ic, "oscar_set_away_aim called before locate rights received"); @@ -2026,7 +2030,7 @@ static void oscar_set_away_icq(struct im_connection *ic, struct oscar_data *od, } else if (!g_strcasecmp(state, "Invisible")) { aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_INVISIBLE); ic->away = g_strdup(msg); - } else if (!g_strcasecmp(state, GAIM_AWAY_CUSTOM)) { + } else { if (no_message) { aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); } else { @@ -2275,20 +2279,21 @@ static void oscar_rem_deny(struct im_connection *ic, char *who) { static GList *oscar_away_states(struct im_connection *ic) { struct oscar_data *od = ic->proto_data; - GList *m = NULL; - - if (!od->icq) - return g_list_append(m, GAIM_AWAY_CUSTOM); - m = g_list_append(m, "Online"); - m = g_list_append(m, "Away"); - m = g_list_append(m, "Do Not Disturb"); - m = g_list_append(m, "Not Available"); - m = g_list_append(m, "Occupied"); - m = g_list_append(m, "Free For Chat"); - m = g_list_append(m, "Invisible"); - - return m; + if (od->icq) { + static GList *m = NULL; + m = g_list_append(m, "Away"); + m = g_list_append(m, "Do Not Disturb"); + m = g_list_append(m, "Not Available"); + m = g_list_append(m, "Occupied"); + m = g_list_append(m, "Free For Chat"); + m = g_list_append(m, "Invisible"); + return m; + } else { + static GList *m = NULL; + m = g_list_append(m, "Away"); + return m; + } } static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) -- cgit v1.2.3 From 4049061ea3b1fbe939c623a8501aea60906893ea Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 6 Mar 2010 17:10:32 +0000 Subject: Fixed up Yahoo! I'll have to do some more thorough testing of this code since I may have broken something. --- protocols/yahoo/libyahoo2.c | 20 +++++--------------- protocols/yahoo/yahoo.c | 37 +++++++------------------------------ 2 files changed, 12 insertions(+), 45 deletions(-) diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index 836670f7..20e284f7 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -4086,6 +4086,9 @@ void yahoo_send_typing(int id, const char *from, const char *who, int typ) yahoo_packet_free(pkt); } +/* TODO(wilmer): See if this this function still works since I got rid of a + lot of things that seemed illogical. Some things may have + been intentional. */ void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away) { struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); @@ -4098,14 +4101,8 @@ void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away) return; yd = yid->yd; - old_status = yd->current_status; - - if (msg && strncmp(msg,"Invisible",9)) { - yd->current_status = YAHOO_STATUS_CUSTOM; - } else { - yd->current_status = state; - } + yd->current_status = state; /* Thank you libpurple :) */ if (yd->current_status == YAHOO_STATUS_INVISIBLE) { @@ -4120,15 +4117,8 @@ void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away) pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, yd->current_status, yd->session_id); snprintf(s, sizeof(s), "%d", yd->current_status); yahoo_packet_hash(pkt, 10, s); - - if (yd->current_status == YAHOO_STATUS_CUSTOM) { - yahoo_packet_hash(pkt, 19, msg); - } else { - yahoo_packet_hash(pkt, 19, ""); - } - + yahoo_packet_hash(pkt, 19, msg); yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); - yahoo_send_packet(yid, pkt, 0); yahoo_packet_free(pkt); diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index ac57d4b6..78a8eb8a 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -129,6 +129,8 @@ static char *byahoo_strip( const char *in ) static void byahoo_init( account_t *acc ) { set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); + + acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE; } static void byahoo_login( account_t *acc ) @@ -196,29 +198,10 @@ static int byahoo_send_typing( struct im_connection *ic, char *who, int typing ) static void byahoo_set_away( struct im_connection *ic, char *state, char *msg ) { struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; - char *away; - - away = NULL; - if( state && msg && g_strcasecmp( state, msg ) != 0 ) - { - yd->current_status = YAHOO_STATUS_CUSTOM; - away = ""; - } - else if( state ) + if( state ) { - /* Set msg to NULL since (if it isn't NULL already) it's equal - to state. msg must be empty if we want to use an existing - away state. */ - msg = NULL; - - away = ""; - if( g_strcasecmp( state, "Available" ) == 0 ) - { - yd->current_status = YAHOO_STATUS_AVAILABLE; - away = NULL; - } - else if( g_strcasecmp( state, "Be Right Back" ) == 0 ) + if( g_strcasecmp( state, "Be Right Back" ) == 0 ) yd->current_status = YAHOO_STATUS_BRB; else if( g_strcasecmp( state, "Busy" ) == 0 ) yd->current_status = YAHOO_STATUS_BUSY; @@ -238,17 +221,13 @@ static void byahoo_set_away( struct im_connection *ic, char *state, char *msg ) yd->current_status = YAHOO_STATUS_STEPPEDOUT; else if( g_strcasecmp( state, "Invisible" ) == 0 ) yd->current_status = YAHOO_STATUS_INVISIBLE; - else if( g_strcasecmp( state, GAIM_AWAY_CUSTOM ) == 0 ) - { - yd->current_status = YAHOO_STATUS_AVAILABLE; - - away = NULL; - } + else + yd->current_status = YAHOO_STATUS_CUSTOM; } else yd->current_status = YAHOO_STATUS_AVAILABLE; - yahoo_set_away( yd->y2_id, yd->current_status, msg, away != NULL ? 2 : 0 ); + yahoo_set_away( yd->y2_id, yd->current_status, msg, state ? 2 : 0 ); } static GList *byahoo_away_states( struct im_connection *ic ) @@ -257,7 +236,6 @@ static GList *byahoo_away_states( struct im_connection *ic ) if( m == NULL ) { - m = g_list_append( m, "Available" ); m = g_list_append( m, "Be Right Back" ); m = g_list_append( m, "Busy" ); m = g_list_append( m, "Not At Home" ); @@ -268,7 +246,6 @@ static GList *byahoo_away_states( struct im_connection *ic ) m = g_list_append( m, "Out To Lunch" ); m = g_list_append( m, "Stepped Out" ); m = g_list_append( m, "Invisible" ); - m = g_list_append( m, GAIM_AWAY_CUSTOM ); } return m; -- cgit v1.2.3 From 0714d51217d999fc67b6ef193e04f7af437cc2b0 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 6 Mar 2010 17:41:01 +0000 Subject: Put AWY at the beginning of the list since it's used as a fallback. --- protocols/msn/tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/msn/tables.c b/protocols/msn/tables.c index b01361bd..42b12aa9 100644 --- a/protocols/msn/tables.c +++ b/protocols/msn/tables.c @@ -29,10 +29,10 @@ const struct msn_away_state msn_away_state_list[] = { { "NLN", "" }, + { "AWY", "Away" }, { "BSY", "Busy" }, { "IDL", "Idle" }, { "BRB", "Be Right Back" }, - { "AWY", "Away" }, { "PHN", "On the Phone" }, { "LUN", "Out to Lunch" }, { "HDN", "Hidden" }, -- cgit v1.2.3 From be915f54a52dd0f88b2a64d5cef094b0e6c9334d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 6 Mar 2010 18:19:31 +0000 Subject: Yahoo! fixes. Turns out the protocol really is somewhat odd. --- protocols/yahoo/libyahoo2.c | 5 +---- protocols/yahoo/yahoo.c | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index 20e284f7..721f4b7c 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -4086,9 +4086,6 @@ void yahoo_send_typing(int id, const char *from, const char *who, int typ) yahoo_packet_free(pkt); } -/* TODO(wilmer): See if this this function still works since I got rid of a - lot of things that seemed illogical. Some things may have - been intentional. */ void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away) { struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); @@ -4117,7 +4114,7 @@ void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away) pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, yd->current_status, yd->session_id); snprintf(s, sizeof(s), "%d", yd->current_status); yahoo_packet_hash(pkt, 10, s); - yahoo_packet_hash(pkt, 19, msg); + yahoo_packet_hash(pkt, 19, msg && state == YAHOO_STATUS_CUSTOM ? msg : ""); yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); yahoo_send_packet(yid, pkt, 0); yahoo_packet_free(pkt); diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 78a8eb8a..a47de966 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -199,8 +199,10 @@ static void byahoo_set_away( struct im_connection *ic, char *state, char *msg ) { struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; - if( state ) + if( state && msg == NULL ) { + /* Use these states only if msg doesn't contain additional + info since away messages are only supported with CUSTOM. */ if( g_strcasecmp( state, "Be Right Back" ) == 0 ) yd->current_status = YAHOO_STATUS_BRB; else if( g_strcasecmp( state, "Busy" ) == 0 ) @@ -224,6 +226,8 @@ static void byahoo_set_away( struct im_connection *ic, char *state, char *msg ) else yd->current_status = YAHOO_STATUS_CUSTOM; } + else if( state ) + yd->current_status = YAHOO_STATUS_CUSTOM; else yd->current_status = YAHOO_STATUS_AVAILABLE; -- cgit v1.2.3 From 34fbbf9c6a80ea7bf5e371c6d36c6ed596b15bd7 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 6 Mar 2010 18:22:20 +0000 Subject: Adapted nogaim.c. Pretty nice cleanup of away state alias handling, mostly. --- protocols/nogaim.c | 85 +++++++++++++++++++++++++----------------------------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 21f7dcb1..f7a62f54 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -1069,51 +1069,24 @@ int imc_chat_msg( struct groupchat *c, char *msg, int flags ) return 1; } -static char *imc_away_alias_find( GList *gcm, char *away ); +static char *imc_away_state_find( GList *gcm, char *away, char **message ); int imc_set_away( struct im_connection *ic, char *away ) { - GList *m, *ms; - char *s; - - if( !away ) away = ""; - ms = m = ic->acc->prpl->away_states( ic ); + char *s = NULL, *msg = away; - while( m ) + if( away && *away ) { - if( *away ) - { - if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 ) - break; - } - else - { - if( g_strcasecmp( m->data, "Available" ) == 0 ) - break; - if( g_strcasecmp( m->data, "Online" ) == 0 ) - break; - } - m = m->next; + GList *m = ic->acc->prpl->away_states( ic ); + s = imc_away_state_find( m, away, &msg ) ? : m->data; } - if( m ) - { - ic->acc->prpl->set_away( ic, m->data, *away ? away : NULL ); - } - else - { - s = imc_away_alias_find( ms, away ); - if( s ) - { - ic->acc->prpl->set_away( ic, s, away ); - if( set_getbool( &ic->irc->set, "debug" ) ) - imcb_log( ic, "Setting away state to %s", s ); - } - else - ic->acc->prpl->set_away( ic, GAIM_AWAY_CUSTOM, away ); - } + if( set_getbool( &ic->irc->set, "debug" ) ) + imcb_log( ic, "Setting away state to %s", s ); + + ic->acc->prpl->set_away( ic, s, ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? msg : NULL ); - return( 1 ); + return 1; } static char *imc_away_alias_list[8][5] = @@ -1128,16 +1101,33 @@ static char *imc_away_alias_list[8][5] = { NULL } }; -static char *imc_away_alias_find( GList *gcm, char *away ) +static char *imc_away_state_find( GList *gcm, char *away, char **message ) { GList *m; int i, j; + for( m = gcm; m; m = m->next ) + if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 ) + { + /* At least the Yahoo! module works better if message + contains no data unless it adds something to what + we have in state already. */ + if( strlen( m->data ) == strlen( away ) ) + *message = NULL; + + return m->data; + } + for( i = 0; *imc_away_alias_list[i]; i ++ ) { + int keep_message; + for( j = 0; imc_away_alias_list[i][j]; j ++ ) if( g_strncasecmp( away, imc_away_alias_list[i][j], strlen( imc_away_alias_list[i][j] ) ) == 0 ) + { + keep_message = strlen( away ) != strlen( imc_away_alias_list[i][j] ); break; + } if( !imc_away_alias_list[i][j] ) /* If we reach the end, this row */ continue; /* is not what we want. Next! */ @@ -1145,17 +1135,22 @@ static char *imc_away_alias_find( GList *gcm, char *away ) /* Now find an entry in this row which exists in gcm */ for( j = 0; imc_away_alias_list[i][j]; j ++ ) { - m = gcm; - while( m ) - { + for( m = gcm; m; m = m->next ) if( g_strcasecmp( imc_away_alias_list[i][j], m->data ) == 0 ) - return( imc_away_alias_list[i][j] ); - m = m->next; - } + { + if( !keep_message ) + *message = NULL; + + return imc_away_alias_list[i][j]; + } } + + /* No need to look further, apparently this state doesn't + have any good alias for this protocol. */ + break; } - return( NULL ); + return NULL; } void imc_add_allow( struct im_connection *ic, char *handle ) -- cgit v1.2.3 From 58adb7e800db87c1e38b810c288f1455654dab3d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 7 Mar 2010 00:22:33 +0000 Subject: Added global and per-account settings "away" and "status" so the user can set these things individually. --- account.c | 30 +++++++++++++++++++++++++++--- irc.c | 23 +++++++++++++++++++++++ irc_commands.c | 8 +------- protocols/nogaim.c | 27 ++++++++++++++++----------- protocols/nogaim.h | 2 +- 5 files changed, 68 insertions(+), 22 deletions(-) diff --git a/account.c b/account.c index 912cba6a..99c3ff53 100644 --- a/account.c +++ b/account.c @@ -1,7 +1,7 @@ /********************************************************************\ * BitlBee -- An IRC to other IM-networks gateway * * * - * Copyright 2002-2004 Wilmer van der Gaast and others * + * Copyright 2002-2010 Wilmer van der Gaast and others * \********************************************************************/ /* Account management functions */ @@ -68,7 +68,16 @@ account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass ) if( prpl->init ) prpl->init( a ); - return( a ); + s = set_add( &a->set, "away", NULL, set_eval_account, a ); + s->flags |= SET_NULL_OK; + + if( a->flags & ACC_FLAG_STATUS_MESSAGE ) + { + s = set_add( &a->set, "status", NULL, set_eval_account, a ); + s->flags |= SET_NULL_OK; + } + + return a; } char *set_eval_account( set_t *set, char *value ) @@ -122,6 +131,21 @@ char *set_eval_account( set_t *set, char *value ) acc->auto_connect = bool2int( value ); return value; } + else if( strcmp( set->key, "away" ) == 0 || + strcmp( set->key, "status" ) == 0 ) + { + if( acc->ic && acc->ic->flags & OPT_LOGGED_IN ) + { + /* If we're currently on-line, set the var now already + (bit of a hack) and send an update. */ + g_free( set->value ); + set->value = g_strdup( value ); + + imc_away_send_update( acc->ic ); + } + + return value; + } return SET_INVALID; } @@ -266,7 +290,7 @@ int account_reconnect_delay_parse( char *value, struct account_reconnect_delay * /* A whole day seems like a sane "maximum maximum". */ p->max = 86400; - /* Format: /[0-9]+([*+][0-9]+(<[0-9+]))/ */ + /* Format: /[0-9]+([*+][0-9]+(<[0-9+])?)?/ */ while( *value && isdigit( *value ) ) p->start = p->start * 10 + *value++ - '0'; diff --git a/irc.c b/irc.c index 2dcc625d..8d503e02 100644 --- a/irc.c +++ b/irc.c @@ -77,6 +77,25 @@ static char *set_eval_charset( set_t *set, char *value ) return value; } +static char *set_eval_away_status( set_t *set, char *value ) +{ + irc_t *irc = set->data; + account_t *a; + + g_free( set->value ); + set->value = g_strdup( value ); + + for( a = irc->accounts; a; a = a->next ) + { + struct im_connection *ic = a->ic; + + if( ic && ic->flags & OPT_LOGGED_IN ) + imc_away_send_update( ic ); + } + + return value; +} + irc_t *irc_new( int fd ) { irc_t *irc; @@ -142,6 +161,8 @@ irc_t *irc_new( int fd ) irc_connection_list = g_slist_append( irc_connection_list, irc ); + s = set_add( &irc->set, "away", NULL, set_eval_away_status, irc ); + s->flags |= SET_NULL_OK; s = set_add( &irc->set, "away_devoice", "true", set_eval_away_devoice, irc ); s = set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc ); s = set_add( &irc->set, "auto_reconnect", "false", set_eval_bool, irc ); @@ -162,6 +183,8 @@ irc_t *irc_new( int fd ) s = set_add( &irc->set, "root_nick", irc->mynick, set_eval_root_nick, irc ); s = set_add( &irc->set, "save_on_quit", "true", set_eval_bool, irc ); s = set_add( &irc->set, "simulate_netsplit", "true", set_eval_bool, irc ); + s = set_add( &irc->set, "status", NULL, set_eval_away_status, irc ); + s->flags |= SET_NULL_OK; s = set_add( &irc->set, "strip_html", "true", NULL, irc ); s = set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc ); s = set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc ); diff --git a/irc_commands.c b/irc_commands.c index 74334ee9..0fbaacd1 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -474,13 +474,7 @@ static void irc_cmd_away( irc_t *irc, char **cmd ) irc_reply( irc, 305, ":Welcome back" ); } - for( a = irc->accounts; a; a = a->next ) - { - struct im_connection *ic = a->ic; - - if( ic && ic->flags & OPT_LOGGED_IN ) - imc_set_away( ic, u->away ); - } + set_setstr( &irc->set, "away", u->away ); } static void irc_cmd_whois( irc_t *irc, char **cmd ) diff --git a/protocols/nogaim.c b/protocols/nogaim.c index f7a62f54..3d2cff5c 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -1,7 +1,7 @@ /********************************************************************\ * BitlBee -- An IRC to other IM-networks gateway * * * - * Copyright 2002-2006 Wilmer van der Gaast and others * + * Copyright 2002-2010 Wilmer van der Gaast and others * \********************************************************************/ /* @@ -267,9 +267,8 @@ void imcb_connected( struct im_connection *ic ) ic->keepalive = b_timeout_add( 60000, send_keepalive, ic ); ic->flags |= OPT_LOGGED_IN; - /* Also necessary when we're not away, at least for some of the - protocols. */ - imc_set_away( ic, u->away ); + /* Necessary to send initial presence status, even if we're not away. */ + imc_away_send_update( ic ); /* Apparently we're connected successfully, so reset the exponential backoff timer. */ @@ -1071,20 +1070,26 @@ int imc_chat_msg( struct groupchat *c, char *msg, int flags ) static char *imc_away_state_find( GList *gcm, char *away, char **message ); -int imc_set_away( struct im_connection *ic, char *away ) +int imc_away_send_update( struct im_connection *ic ) { - char *s = NULL, *msg = away; + char *away, *msg; + away = set_getstr( &ic->acc->set, "away" ) ? + : set_getstr( &ic->irc->set, "away" ); if( away && *away ) { GList *m = ic->acc->prpl->away_states( ic ); - s = imc_away_state_find( m, away, &msg ) ? : m->data; + msg = ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? away : NULL; + away = imc_away_state_find( m, away, &msg ) ? : m->data; + } + else if( ic->acc->flags & ACC_FLAG_STATUS_MESSAGE ) + { + away = NULL; + msg = set_getstr( &ic->acc->set, "status" ) ? + : set_getstr( &ic->irc->set, "status" ); } - if( set_getbool( &ic->irc->set, "debug" ) ) - imcb_log( ic, "Setting away state to %s", s ); - - ic->acc->prpl->set_away( ic, s, ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? msg : NULL ); + ic->acc->prpl->set_away( ic, away, msg ); return 1; } diff --git a/protocols/nogaim.h b/protocols/nogaim.h index 80f8ed40..4fc32281 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -313,7 +313,7 @@ G_MODULE_EXPORT void imcb_chat_topic( struct groupchat *c, char *who, char *topi G_MODULE_EXPORT void imcb_chat_free( struct groupchat *c ); /* Actions, or whatever. */ -int imc_set_away( struct im_connection *ic, char *away ); +int imc_away_send_update( struct im_connection *ic ); int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags ); int imc_chat_msg( struct groupchat *c, char *msg, int flags ); -- cgit v1.2.3 From 68198e97b6a6dd479e88fd1bd85a7b19cf67d149 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 7 Mar 2010 00:31:34 +0000 Subject: Two more fixes in OSCAR to avoid NULL pointers being passed to g_strcasecmp(). --- protocols/oscar/oscar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 3aa9f136..f0e65f9a 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -1953,6 +1953,8 @@ static void oscar_get_away(struct im_connection *g, char *who) { static void oscar_set_away_aim(struct im_connection *ic, struct oscar_data *od, const char *state, const char *message) { + if (state == NULL) + state = ""; if (!g_strcasecmp(state, _("Visible"))) { aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); @@ -2005,7 +2007,7 @@ static void oscar_set_away_icq(struct im_connection *ic, struct oscar_data *od, no_message = TRUE; } - if (!g_strcasecmp(state, "Online")) { + if (state == NULL) { aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); } else if (!g_strcasecmp(state, "Away")) { aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY); -- cgit v1.2.3 From 63770b44953f9fbd7355b81217143375a2db246c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 7 Mar 2010 18:32:31 +0000 Subject: Changed formatting of Jabber buddy info response. --- irc_commands.c | 1 - protocols/jabber/jabber.c | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/irc_commands.c b/irc_commands.c index 0fbaacd1..750bbcf5 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -447,7 +447,6 @@ static void irc_cmd_away( irc_t *irc, char **cmd ) { user_t *u = user_find( irc, irc->nick ); char *away = cmd[1]; - account_t *a; if( !u ) return; diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 35cf08c5..eca7d2d3 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -365,10 +365,11 @@ static void jabber_get_info( struct im_connection *ic, char *who ) while( bud ) { - imcb_log( ic, "Buddy %s (%d) information:\nAway state: %s\nAway message: %s", - bud->full_jid, bud->priority, - bud->away_state ? bud->away_state->full_name : "(none)", - bud->away_message ? : "(none)" ); + imcb_log( ic, "Buddy %s (%d) information:", bud->full_jid, bud->priority ); + if( bud->away_state ) + imcb_log( ic, "Away state: %s", bud->away_state->full_name ); + imcb_log( ic, "Status message: %s", bud->away_message ? : "(none)" ); + bud = bud->next; } -- cgit v1.2.3 From 0e99548ba9c6ec9c78367e05b676dab90b5261a4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 7 Mar 2010 18:37:23 +0000 Subject: Doc update. --- doc/user-guide/commands.xml | 32 ++++++++++++++++++++++++++++++++ doc/user-guide/misc.xml | 22 +++++++++++++--------- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index af566de4..a7d06cf1 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -435,6 +435,22 @@ + + + + To mark yourself as away, it is recommended to just use /away, like on normal IRC networks. If you want to mark yourself as away on only one IM network, you can use this per-account setting. + + + + You can set it to any value and BitlBee will try to map it to the most appropriate away state for every open IM connection, or set it as a free-form away message where possible. + + + + Any per-account away setting will override globally set away states. To un-set the setting, use set -del away. + + + + true @@ -746,6 +762,22 @@ + + + + Certain protocols (like Jabber/XMPP) support status messages, similar to away messages. They can be used to indicate things like your location or activity, without showing up as away/busy. + + + + This setting can be used to set such a message. It will be available as a per-account setting for protocols that support it, and also as a global setting (which will then automatically be used for all protocols that support it). + + + + Away states set using /away or the away setting will override this setting. To un-set the setting, use set -del status. + + + + true diff --git a/doc/user-guide/misc.xml b/doc/user-guide/misc.xml index 68b44e95..a926775a 100644 --- a/doc/user-guide/misc.xml +++ b/doc/user-guide/misc.xml @@ -85,31 +85,35 @@ Some protocols (like Jabber) also support named groupchats. BitlBee now supports Away states -As you might've expected, you can just use the /away command in your IRC client to set an away-state. BitlBee supports most away-states supported by the protocols. +To mark yourself as away, you can just use the /away command in your IRC client. BitlBee supports most away-states supported by the protocols. -Not all away states are supported by all protocols, and some protocols have different names for them. BitlBee will try to pick the best available alias from this list for every connection: +Away states have different names accross different protocols. BitlBee will try to pick the best available option for every connection: - Away from computer, Away, Extended away - NA, N/A, Not available - Busy, Do not disturb, DND, Occupied - Be right back, BRB - On the phone, Phone, On phone - Out to lunch, Lunch, Food + Away + NA + Busy, DND + BRB + Phone + Lunch, Food Invisible, Hidden -So /away Food will set your state to "Out to lunch" on your MSN connection, and for most other connections the default, "Away" or "Away from computer" will be chosen. +So /away Food will set your state to "Out to lunch" on your MSN connection, and for most other connections the default, "Away" will be chosen. You can also add more information to your away message. Setting it to "Busy - Fixing BitlBee bugs" will set your IM-away-states to Busy, but your away message will be more descriptive for people on IRC. Most IM-protocols can also show this additional information to your buddies. + +If you want to set an away state for only one of your connections, you can use the per-account away setting. See help set away. + + -- cgit v1.2.3 From b52e478f9cfea9c0319d3f0203b31e4b5d03f38b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 8 Mar 2010 01:25:10 +0000 Subject: Added ' HTML entity since we're sure getting that one a lot with libpurple.. --- lib/misc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/misc.c b/lib/misc.c index 35e9909b..3976e01b 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -88,6 +88,7 @@ static const htmlentity_t ent[] = { "lt", "<" }, { "gt", ">" }, { "amp", "&" }, + { "apos", "'" }, { "quot", "\"" }, { "aacute", "á" }, { "eacute", "é" }, -- cgit v1.2.3 From 7c9db249e4d94413f561841495d1e147d53327d5 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 8 Mar 2010 02:10:41 +0000 Subject: Replaced obsolete (useless for the current .xml files) encode/decode tools with a few command-line options to the BitlBee binary. Type "bitlbee -x" for more info. --- Makefile | 8 +------- conf.c | 3 ++- crypting.c | 60 ------------------------------------------------------ unix.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 69 insertions(+), 71 deletions(-) diff --git a/Makefile b/Makefile index 20feb067..337fcf63 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ Makefile.settings: @echo clean: $(subdirs) - rm -f *.o $(OUTFILE) core utils/bitlbeed encode decode + rm -f *.o $(OUTFILE) core utils/bitlbeed $(MAKE) -C tests clean distclean: clean $(subdirs) @@ -123,11 +123,5 @@ ifndef DEBUG @-$(STRIP) $(OUTFILE) endif -encode: crypting.c - $(CC) crypting.c lib/md5.c $(CFLAGS) -o encode -DCRYPTING_MAIN $(CFLAGS) $(EFLAGS) $(LFLAGS) - -decode: encode - cp encode decode - ctags: ctags `find . -name "*.c"` `find . -name "*.h"` diff --git a/conf.c b/conf.c index 873aa0e7..c8cfaad8 100644 --- a/conf.c +++ b/conf.c @@ -126,7 +126,7 @@ conf_t *conf_load( int argc, char *argv[] ) else if( opt == 'h' ) { printf( "Usage: bitlbee [-D/-F [-i ] [-p ] [-n] [-v]] [-I]\n" - " [-c ] [-d ] [-h]\n" + " [-c ] [-d ] [-x] [-h]\n" "\n" "An IRC-to-other-chat-networks gateway\n" "\n" @@ -142,6 +142,7 @@ conf_t *conf_load( int argc, char *argv[] ) " -v Be verbose (only works in combination with -n)\n" " -c Load alternative configuration file\n" " -d Specify alternative user configuration directory\n" + " -x Command-line interface to password encryption/hashing\n" " -h Show this help page.\n" ); return NULL; } diff --git a/crypting.c b/crypting.c index 34b99034..0a5c937e 100644 --- a/crypting.c +++ b/crypting.c @@ -131,63 +131,3 @@ char *deobfucrypt (char *line, const char *password) return (rv); } - -#ifdef CRYPTING_MAIN - -/* A little main() function for people who want a stand-alone program to - encode/decode BitlCrypted files. */ - -int main( int argc, char *argv[] ) -{ - char *hash, *action, line[256]; - char* (*func)( char *, const char * ); - - if( argc < 2 ) - { - fprintf( stderr, "Usage: %s \n\n" - "Reads from stdin, writes to stdout.\n" - "Call as \"encode\" to encode, \"decode\" to decode.\n", argv[0] ); - return( 1 ); - } - - hash = hashpass( argv[1] ); - action = argv[0] + strlen( argv[0] ) - strlen( "encode" ); - - if( strcmp( action, "encode" ) == 0 ) - { - fwrite( hash, 32, 1, stdout ); - func = obfucrypt; - } - else if( strcmp( action, "decode" ) == 0 ) - { - char hash2[32]; - - fread( hash2, 32, 1, stdin ); - if( memcmp( hash, hash2, 32 ) != 0 ) - { - fprintf( stderr, "Passwords don't match. Can't decode.\n" ); - return( 1 ); - } - func = deobfucrypt; - } - else - { - return( main( 0, NULL ) ); - } - - while( fscanf( stdin, "%[^\n]255s", line ) > 0 ) - { - char *out; - - /* Flush the newline */ - fgetc( stdin ); - - out = func( line, argv[1] ); - printf( "%s\n", out ); - g_free( out ); - } - - return( 0 ); -} - -#endif diff --git a/unix.c b/unix.c index 56b0ab46..00bea6c8 100644 --- a/unix.c +++ b/unix.c @@ -24,11 +24,15 @@ */ #include "bitlbee.h" + +#include "arc.h" +#include "base64.h" #include "commands.h" -#include "crypting.h" #include "protocols/nogaim.h" #include "help.h" #include "ipc.h" +#include "md5.h" +#include "misc.h" #include #include #include @@ -39,12 +43,17 @@ global_t global; /* Against global namespace pollution */ static void sighandler( int signal ); +static int crypt_main( int argc, char *argv[] ); + int main( int argc, char *argv[] ) { int i = 0; char *old_cwd = NULL; struct sigaction sig, old; + if( argc > 1 && strcmp( argv[1], "-x" ) == 0 ) + return crypt_main( argc, argv ); + log_init(); global.conf_file = g_strdup( CONF_FILE_DEF ); global.conf = conf_load( argc, argv ); @@ -158,6 +167,62 @@ int main( int argc, char *argv[] ) return( 0 ); } +static int crypt_main( int argc, char *argv[] ) +{ + int pass_len; + unsigned char *pass_cr, *pass_cl; + + if( argc < 3 ) + { + printf( "Supported:\n" + " %s -x enc \n" + " %s -x dec \n" + " %s -x hash \n" + " %s -x unhash \n" + " %s -x chkhash \n", + argv[0], argv[0], argv[0], argv[0], argv[0] ); + } + else if( strcmp( argv[2], "enc" ) == 0 ) + { + pass_len = arc_encode( argv[4], strlen( argv[4] ), (unsigned char**) &pass_cr, argv[3], 12 ); + printf( "%s\n", base64_encode( pass_cr, pass_len ) ); + } + else if( strcmp( argv[2], "dec" ) == 0 ) + { + pass_len = base64_decode( argv[4], (unsigned char**) &pass_cr ); + arc_decode( pass_cr, pass_len, (char**) &pass_cl, argv[3] ); + printf( "%s\n", pass_cl ); + } + else if( strcmp( argv[2], "hash" ) == 0 ) + { + md5_byte_t pass_md5[21]; + md5_state_t md5_state; + + random_bytes( pass_md5 + 16, 5 ); + md5_init( &md5_state ); + md5_append( &md5_state, (md5_byte_t*) argv[3], strlen( argv[3] ) ); + md5_append( &md5_state, pass_md5 + 16, 5 ); /* Add the salt. */ + md5_finish( &md5_state, pass_md5 ); + + printf( "%s\n", base64_encode( pass_md5, 21 ) ); + } + else if( strcmp( argv[2], "unhash" ) == 0 ) + { + printf( "Hash %s submitted to a massive Beowulf cluster of\n" + "overclocked 486s. Expect your answer next year somewhere around this time. :-)\n", argv[3] ); + } + else if( strcmp( argv[2], "chkhash" ) == 0 ) + { + int st = md5_verify_password( argv[4], argv[3] ); + + printf( "Hash %s given password.\n", st == 0 ? "matches" : "does not match" ); + + return st; + } + + return 0; +} + static void sighandler( int signal ) { /* FIXME: Calling log_message() here is not a very good idea! */ @@ -213,5 +278,3 @@ double gettime() gettimeofday( time, 0 ); return( (double) time->tv_sec + (double) time->tv_usec / 1000000 ); } - - -- cgit v1.2.3 From 3e1ef92cecad385c64c2398355d90225ac54440c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 9 Mar 2010 13:13:50 +0000 Subject: Fixed a compiler warning for an ugliness that fortunately shouldn't have caused any issues except with broken protocol modules. --- protocols/nogaim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 3d2cff5c..603905ab 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -1072,7 +1072,7 @@ static char *imc_away_state_find( GList *gcm, char *away, char **message ); int imc_away_send_update( struct im_connection *ic ) { - char *away, *msg; + char *away, *msg = NULL; away = set_getstr( &ic->acc->set, "away" ) ? : set_getstr( &ic->irc->set, "away" ); -- cgit v1.2.3 From a0bd4c247472c1997afbe8683ef460dadbb16b46 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 10 Mar 2010 23:58:28 +0000 Subject: Huh, what was that dead code doing there.. :-/ --- root_commands.c | 73 --------------------------------------------------------- 1 file changed, 73 deletions(-) diff --git a/root_commands.c b/root_commands.c index 5de616fb..c79ff325 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1114,79 +1114,6 @@ static void cmd_chat( irc_t *irc, char **cmd ) { irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "chat", cmd[1] ); } - - - -#if 0 - account_t *a; - struct im_connection *ic; - char *chat, *channel, *nick = NULL, *password = NULL; - struct groupchat *c; - - if( !( a = account_get( irc, cmd[1] ) ) ) - { - irc_usermsg( irc, "Invalid account" ); - return; - } - else if( !( a->ic && ( a->ic->flags & OPT_LOGGED_IN ) ) ) - { - irc_usermsg( irc, "That account is not on-line" ); - return; - } - else if( a->prpl->chat_join == NULL ) - { - irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); - return; - } - ic = a->ic; - - chat = cmd[2]; - if( cmd[3] ) - { - if( strchr( CTYPES, cmd[3][0] ) == NULL ) - channel = g_strdup_printf( "&%s", cmd[3] ); - else - channel = g_strdup( cmd[3] ); - } - else - { - char *s; - - channel = g_strdup_printf( "&%s", chat ); - if( ( s = strchr( channel, '@' ) ) ) - *s = 0; - } - if( cmd[3] && cmd[4] ) - nick = cmd[4]; - else - nick = irc->nick; - if( cmd[3] && cmd[4] && cmd[5] ) - password = cmd[5]; - - if( !nick_ok( channel + 1 ) ) - { - irc_usermsg( irc, "Invalid channel name: %s", channel ); - g_free( channel ); - return; - } - else if( g_strcasecmp( channel, irc->channel ) == 0 || irc_chat_by_channel( irc, channel ) ) - { - irc_usermsg( irc, "Channel already exists: %s", channel ); - g_free( channel ); - return; - } - - if( ( c = a->prpl->chat_join( ic, chat, nick, password ) ) ) - { - g_free( c->channel ); - c->channel = channel; - } - else - { - irc_usermsg( irc, "Tried to join chat, not sure if this was successful" ); - g_free( channel ); - } -#endif } const command_t commands[] = { -- cgit v1.2.3 From 75ec2c8398afde059e3a2403ca8907229d3720de Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 10 Mar 2010 23:58:47 +0000 Subject: Fixed an "off-by -1" bug in msn_findheader() that could probably be triggered by incoming messages without headers. --- protocols/msn/msn_util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index 6b12217b..668a8b8a 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -170,9 +170,9 @@ char *msn_findheader( char *text, char *header, int len ) while( i < len && ( text[i] == '\r' || text[i] == '\n' ) ) i ++; /* End of headers? */ - if( strncmp( text + i - 2, "\n\n", 2 ) == 0 || - strncmp( text + i - 4, "\r\n\r\n", 4 ) == 0 || - strncmp( text + i - 2, "\r\r", 2 ) == 0 ) + if( ( i >= 4 && strncmp( text + i - 4, "\r\n\r\n", 4 ) == 0 ) || + ( i >= 2 && ( strncmp( text + i - 2, "\n\n", 2 ) == 0 || + strncmp( text + i - 2, "\r\r", 2 ) == 0 ) ) ) { break; } -- cgit v1.2.3 From 8b6b7405d3844271f7bff56e527bfeb1a4872975 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 11 Mar 2010 11:15:36 +0000 Subject: Document the new -x flag in one useful location and make it a bit better at argument checking to avoid ugly (even though harmless) segfaults. Also skip any md5: prefix that may be present when checking hashes. --- bitlbee.conf | 5 ++--- unix.c | 6 ++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bitlbee.conf b/bitlbee.conf index 5fce2820..4a3bbddf 100644 --- a/bitlbee.conf +++ b/bitlbee.conf @@ -54,9 +54,8 @@ ## AuthPassword ## ## Password the user should enter when logging into a closed BitlBee server. -## You can also have an MD5-encrypted password here. Format: "md5:", followed -## by a hash as generated for the attribute in a BitlBee -## XML file (for now there's no easier way to generate the hash). +## You can also have a BitlBee-style MD5 hash here. Format: "md5:", followed +## by a hash as generated by "bitlbee -x hash ". ## # AuthPassword = ItllBeBitlBee ## Heh.. Our slogan. ;-) ## or diff --git a/unix.c b/unix.c index 00bea6c8..7088d0f8 100644 --- a/unix.c +++ b/unix.c @@ -172,7 +172,8 @@ static int crypt_main( int argc, char *argv[] ) int pass_len; unsigned char *pass_cr, *pass_cl; - if( argc < 3 ) + if( argc < 4 || ( strcmp( argv[2], "hash" ) != 0 && + strcmp( argv[2], "unhash" ) != 0 && argc < 5 ) ) { printf( "Supported:\n" " %s -x enc \n" @@ -213,7 +214,8 @@ static int crypt_main( int argc, char *argv[] ) } else if( strcmp( argv[2], "chkhash" ) == 0 ) { - int st = md5_verify_password( argv[4], argv[3] ); + char *hash = strncmp( argv[3], "md5:", 4 ) == 0 ? argv[3] + 4 : argv[3]; + int st = md5_verify_password( argv[4], hash ); printf( "Hash %s given password.\n", st == 0 ? "matches" : "does not match" ); -- cgit v1.2.3 From 547c94cf6b3654997ef2570d398468af75380b26 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 12 Mar 2010 22:32:55 +0000 Subject: Merging in some code from libyahoo2-trunk that deals better with (initial) status updates and cleans up some stale stuff. --- protocols/yahoo/libyahoo2.c | 340 +++++++++++++++++++------------------------- 1 file changed, 146 insertions(+), 194 deletions(-) diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index 721f4b7c..f043baf5 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -854,55 +854,6 @@ static int is_same_bud(const void * a, const void * b) { return strcmp(subject->id, object->id); } -static YList * bud_str2list(char *rawlist) -{ - YList * l = NULL; - - char **lines; - char **split; - char **buddies; - char **tmp, **bud; - - lines = y_strsplit(rawlist, "\n", -1); - for (tmp = lines; *tmp; tmp++) { - struct yahoo_buddy *newbud; - - split = y_strsplit(*tmp, ":", 2); - if (!split) - continue; - if (!split[0] || !split[1]) { - y_strfreev(split); - continue; - } - buddies = y_strsplit(split[1], ",", -1); - - for (bud = buddies; bud && *bud; bud++) { - newbud = y_new0(struct yahoo_buddy, 1); - newbud->id = strdup(*bud); - newbud->group = strdup(split[0]); - - if(y_list_find_custom(l, newbud, is_same_bud)) { - FREE(newbud->id); - FREE(newbud->group); - FREE(newbud); - continue; - } - - newbud->real_name = NULL; - - l = y_list_append(l, newbud); - - NOTICE(("Added buddy %s to group %s", newbud->id, newbud->group)); - } - - y_strfreev(buddies); - y_strfreev(split); - } - y_strfreev(lines); - - return l; -} - static char * getcookie(char *rawcookie) { char * cookie=NULL; @@ -1359,140 +1310,165 @@ static void yahoo_process_message(struct yahoo_input_data *yid, struct yahoo_pac y_list_free(messages); } - -static void yahoo_process_status(struct yahoo_input_data *yid, struct yahoo_packet *pkt) +static void yahoo_process_status(struct yahoo_input_data *yid, + struct yahoo_packet *pkt) { YList *l; struct yahoo_data *yd = yid->yd; - struct user - { - char *name; /* 7 name */ - int state; /* 10 state */ - int flags; /* 13 flags, bit 0 = pager, bit 1 = chat, bit 2 = game */ - int mobile; /* 60 mobile */ - char *msg; /* 19 custom status message */ - int away; /* 47 away (or invisible)*/ - int buddy_session; /* 11 state */ - int f17; /* 17 in chat? then what about flags? */ - int idle; /* 137 seconds idle */ - int f138; /* 138 state */ - char *f184; /* 184 state */ - int f192; /* 192 state */ - int f10001; /* 10001 state */ - int f10002; /* 10002 state */ - int f198; /* 198 state */ - char *f197; /* 197 state */ - char *f205; /* 205 state */ - int f213; /* 213 state */ + struct user { + char *name; /* 7 name */ + int state; /* 10 state */ + int flags; /* 13 flags, bit 0 = pager, bit 1 = chat, bit 2 = game */ + int mobile; /* 60 mobile */ + char *msg; /* 19 custom status message */ + int away; /* 47 away (or invisible) */ + int buddy_session; /* 11 state */ + int f17; /* 17 in chat? then what about flags? */ + int idle; /* 137 seconds idle */ + int f138; /* 138 state */ + char *f184; /* 184 state */ + int f192; /* 192 state */ + int f10001; /* 10001 state */ + int f10002; /* 10002 state */ + int f198; /* 198 state */ + char *f197; /* 197 state */ + char *f205; /* 205 state */ + int f213; /* 213 state */ } *u; YList *users = 0; - + if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) { - YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_DUPL, NULL); + YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, + YAHOO_LOGIN_DUPL, NULL); return; } + u = NULL; + for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; switch (pair->key) { - case 0: /* we won't actually do anything with this */ + case 300: /* Begin buddy */ + if (!strcmp(pair->value, "315") && !u) { + u = y_new0(struct user, 1); + } + break; + case 301: /* End buddy */ + if (!strcmp(pair->value, "315") && u) { + users = y_list_prepend(users, u); + u = NULL; + } + break; + case 0: /* we won't actually do anything with this */ NOTICE(("key %d:%s", pair->key, pair->value)); break; - case 1: /* we don't get the full buddy list here. */ + case 1: /* we don't get the full buddy list here. */ if (!yd->logged_in) { - yd->logged_in = TRUE; - if(yd->current_status < 0) + yd->logged_in = 1; + if (yd->current_status < 0) yd->current_status = yd->initial_status; - YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_OK, NULL); + YAHOO_CALLBACK(ext_yahoo_login_response) (yd-> + client_id, YAHOO_LOGIN_OK, NULL); } break; - case 8: /* how many online buddies we have */ + case 8: /* how many online buddies we have */ NOTICE(("key %d:%s", pair->key, pair->value)); break; - case 7: /* the current buddy */ - u = y_new0(struct user, 1); + case 7: /* the current buddy */ + if (!u) { + /* This will only happen in case of a single level message */ + u = y_new0(struct user, 1); + users = y_list_prepend(users, u); + } u->name = pair->value; - users = y_list_prepend(users, u); break; - case 10: /* state */ - ((struct user*)users->data)->state = strtol(pair->value, NULL, 10); + case 10: /* state */ + u->state = strtol(pair->value, NULL, 10); break; - case 19: /* custom status message */ - ((struct user*)users->data)->msg = pair->value; + case 19: /* custom status message */ + u->msg = pair->value; break; - case 47: /* is it an away message or not */ - ((struct user*)users->data)->away = atoi(pair->value); + case 47: /* is it an away message or not. Not applicable for YMSG16 anymore */ + u->away = atoi(pair->value); break; - case 137: /* seconds idle */ - ((struct user*)users->data)->idle = atoi(pair->value); + case 137: /* seconds idle */ + u->idle = atoi(pair->value); break; - case 11: /* this is the buddy's session id */ - ((struct user*)users->data)->buddy_session = atoi(pair->value); + case 11: /* this is the buddy's session id */ + u->buddy_session = atoi(pair->value); break; - case 17: /* in chat? */ - ((struct user*)users->data)->f17 = atoi(pair->value); + case 17: /* in chat? */ + u->f17 = atoi(pair->value); break; - case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */ - ((struct user*)users->data)->flags = atoi(pair->value); + case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */ + u->flags = atoi(pair->value); break; - case 60: /* SMS -> 1 MOBILE USER */ + case 60: /* SMS -> 1 MOBILE USER */ /* sometimes going offline makes this 2, but invisible never sends it */ - ((struct user*)users->data)->mobile = atoi(pair->value); + u->mobile = atoi(pair->value); break; case 138: - ((struct user*)users->data)->f138 = atoi(pair->value); + u->f138 = atoi(pair->value); break; case 184: - ((struct user*)users->data)->f184 = pair->value; + u->f184 = pair->value; break; case 192: - ((struct user*)users->data)->f192 = atoi(pair->value); + u->f192 = atoi(pair->value); break; case 10001: - ((struct user*)users->data)->f10001 = atoi(pair->value); + u->f10001 = atoi(pair->value); break; case 10002: - ((struct user*)users->data)->f10002 = atoi(pair->value); + u->f10002 = atoi(pair->value); break; case 198: - ((struct user*)users->data)->f198 = atoi(pair->value); + u->f198 = atoi(pair->value); break; case 197: - ((struct user*)users->data)->f197 = pair->value; + u->f197 = pair->value; break; case 205: - ((struct user*)users->data)->f205 = pair->value; + u->f205 = pair->value; break; case 213: - ((struct user*)users->data)->f213 = atoi(pair->value); + u->f213 = atoi(pair->value); break; - case 16: /* Custom error message */ - YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, pair->value, 0, E_CUSTOM); + case 16: /* Custom error message */ + YAHOO_CALLBACK(ext_yahoo_error) (yd->client_id, + pair->value, 0, E_CUSTOM); break; default: - WARNING(("unknown status key %d:%s", pair->key, pair->value)); + WARNING(("unknown status key %d:%s", pair->key, + pair->value)); break; } } - + while (users) { YList *t = users; struct user *u = users->data; if (u->name != NULL) { - if (pkt->service == YAHOO_SERVICE_LOGOFF) { /* || u->flags == 0) { Not in YMSG16 */ - YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0); + if (pkt->service == + YAHOO_SERVICE_LOGOFF + /*|| u->flags == 0 No flags for YMSG16 */ ) { + YAHOO_CALLBACK(ext_yahoo_status_changed) (yd-> + client_id, u->name, + YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0); } else { /* Key 47 always seems to be 1 for YMSG16 */ - if(!u->state) + if (!u->state) u->away = 0; else u->away = 1; - YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, u->state, u->msg, u->away, u->idle, u->mobile); + YAHOO_CALLBACK(ext_yahoo_status_changed) (yd-> + client_id, u->name, u->state, u->msg, + u->away, u->idle, u->mobile); } } @@ -1502,7 +1478,8 @@ static void yahoo_process_status(struct yahoo_input_data *yid, struct yahoo_pack } } -static void yahoo_process_buddy_list(struct yahoo_input_data *yid, struct yahoo_packet *pkt) +static void yahoo_process_buddy_list(struct yahoo_input_data *yid, + struct yahoo_packet *pkt) { struct yahoo_data *yd = yid->yd; YList *l; @@ -1514,34 +1491,29 @@ static void yahoo_process_buddy_list(struct yahoo_input_data *yid, struct yahoo_ for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; - switch(pair->key) { + switch (pair->key) { case 300: case 301: case 302: + break; /* Separators. Our logic does not need them */ case 303: - if ( 315 == atoi(pair->value) ) + if (318 == atoi(pair->value)) last_packet = 1; break; case 65: - g_free(cur_group); cur_group = strdup(pair->value); break; case 7: newbud = y_new0(struct yahoo_buddy, 1); newbud->id = strdup(pair->value); - if (cur_group) { + if (cur_group) newbud->group = strdup(cur_group); - } else { - YList *last; - struct yahoo_buddy *lastbud; - - for (last = yd->buddies; last && last->next; last = last->next); - if (last) { - lastbud = last->data; - newbud->group = strdup(lastbud->group); - } else { - newbud->group = strdup("Buddies"); - } + else { + struct yahoo_buddy *lastbud = + (struct yahoo_buddy *)y_list_nth(yd-> + buddies, + y_list_length(yd->buddies) - 1)->data; + newbud->group = strdup(lastbud->group); } yd->buddies = y_list_append(yd->buddies, newbud); @@ -1549,106 +1521,86 @@ static void yahoo_process_buddy_list(struct yahoo_input_data *yid, struct yahoo_ break; } } - - g_free(cur_group); /* we could be getting multiple packets here */ - if (last_packet) + if (pkt->hash && !last_packet) return; - YAHOO_CALLBACK(ext_yahoo_got_buddies)(yd->client_id, yd->buddies); + YAHOO_CALLBACK(ext_yahoo_got_buddies) (yd->client_id, yd->buddies); - /*** We login at the very end of the packet communication */ + /* Logged in */ if (!yd->logged_in) { - yd->logged_in = TRUE; - if(yd->current_status < 0) + yd->logged_in = 1; + if (yd->current_status < 0) yd->current_status = yd->initial_status; - YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_OK, NULL); + YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, + YAHOO_LOGIN_OK, NULL); + + /* + yahoo_set_away(yd->client_id, yd->initial_status, NULL, + (yd->initial_status == YAHOO_STATUS_AVAILABLE) ? 0 : 1); + + yahoo_get_yab(yd->client_id); + */ } + } -static void yahoo_process_list(struct yahoo_input_data *yid, struct yahoo_packet *pkt) +static void yahoo_process_list(struct yahoo_input_data *yid, + struct yahoo_packet *pkt) { struct yahoo_data *yd = yid->yd; YList *l; - if (!yd->logged_in) { - yd->logged_in = TRUE; - if(yd->current_status < 0) - yd->current_status = yd->initial_status; - YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_OK, NULL); - } - + /* we could be getting multiple packets here */ for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; - switch(pair->key) { - case 87: /* buddies */ - if(!yd->rawbuddylist) - yd->rawbuddylist = strdup(pair->value); - else { - yd->rawbuddylist = y_string_append(yd->rawbuddylist, pair->value); - } - break; - - case 88: /* ignore list */ - if(!yd->ignorelist) - yd->ignorelist = strdup("Ignore:"); - yd->ignorelist = y_string_append(yd->ignorelist, pair->value); - break; - - case 89: /* identities */ + switch (pair->key) { + case 89: /* identities */ { - char **identities = y_strsplit(pair->value, ",", -1); - int i; - for(i=0; identities[i]; i++) - yd->identities = y_list_append(yd->identities, + char **identities = + y_strsplit(pair->value, ",", -1); + int i; + for (i = 0; identities[i]; i++) + yd->identities = + y_list_append(yd->identities, strdup(identities[i])); - y_strfreev(identities); + y_strfreev(identities); } - YAHOO_CALLBACK(ext_yahoo_got_identities)(yd->client_id, yd->identities); + YAHOO_CALLBACK(ext_yahoo_got_identities) (yd->client_id, + yd->identities); break; - case 59: /* cookies */ - if(yd->ignorelist) { - yd->ignore = bud_str2list(yd->ignorelist); - FREE(yd->ignorelist); - YAHOO_CALLBACK(ext_yahoo_got_ignore)(yd->client_id, yd->ignore); - } - if(yd->rawbuddylist) { - yd->buddies = bud_str2list(yd->rawbuddylist); - FREE(yd->rawbuddylist); - YAHOO_CALLBACK(ext_yahoo_got_buddies)(yd->client_id, yd->buddies); - } - - if(pair->value[0]=='Y') { + case 59: /* cookies */ + if (pair->value[0] == 'Y') { FREE(yd->cookie_y); FREE(yd->login_cookie); yd->cookie_y = getcookie(pair->value); yd->login_cookie = getlcookie(yd->cookie_y); - } else if(pair->value[0]=='T') { + } else if (pair->value[0] == 'T') { FREE(yd->cookie_t); yd->cookie_t = getcookie(pair->value); - } else if(pair->value[0]=='C') { + } else if (pair->value[0] == 'C') { FREE(yd->cookie_c); yd->cookie_c = getcookie(pair->value); - } - - if(yd->cookie_y && yd->cookie_t) - YAHOO_CALLBACK(ext_yahoo_got_cookies)(yd->client_id); + } break; - case 3: /* my id */ - case 90: /* 1 */ - case 100: /* 0 */ - case 101: /* NULL */ - case 102: /* NULL */ - case 93: /* 86400/1440 */ + case 3: /* my id */ + case 90: /* 1 */ + case 100: /* 0 */ + case 101: /* NULL */ + case 102: /* NULL */ + case 93: /* 86400/1440 */ break; } } + + if (yd->cookie_y && yd->cookie_t) /* We don't get cookie_c anymore */ + YAHOO_CALLBACK(ext_yahoo_got_cookies) (yd->client_id); } static void yahoo_process_verify(struct yahoo_input_data *yid, struct yahoo_packet *pkt) -- cgit v1.2.3 From 70533795ac441b82e40b0cf4b8709994be7ac5ce Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 12 Mar 2010 23:02:29 +0000 Subject: Yahoo! status updates (at least initial ones, I assume) can be too long to fit into one packet. Yahoo! servers will split them up, and not necessarily on buddy boundaries. Trying to handle this a little bit better now. (Sadly I can't test this myself, I can only see this causing troubles on testing sometimes.) --- protocols/yahoo/libyahoo2.c | 35 ++++++++++------------------------- protocols/yahoo/yahoo2_types.h | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index f043baf5..57c32e2d 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -1316,26 +1316,7 @@ static void yahoo_process_status(struct yahoo_input_data *yid, YList *l; struct yahoo_data *yd = yid->yd; - struct user { - char *name; /* 7 name */ - int state; /* 10 state */ - int flags; /* 13 flags, bit 0 = pager, bit 1 = chat, bit 2 = game */ - int mobile; /* 60 mobile */ - char *msg; /* 19 custom status message */ - int away; /* 47 away (or invisible) */ - int buddy_session; /* 11 state */ - int f17; /* 17 in chat? then what about flags? */ - int idle; /* 137 seconds idle */ - int f138; /* 138 state */ - char *f184; /* 184 state */ - int f192; /* 192 state */ - int f10001; /* 10001 state */ - int f10002; /* 10002 state */ - int f198; /* 198 state */ - char *f197; /* 197 state */ - char *f205; /* 205 state */ - int f213; /* 213 state */ - } *u; + struct yahoo_process_status_entry *u; YList *users = 0; @@ -1345,7 +1326,11 @@ static void yahoo_process_status(struct yahoo_input_data *yid, return; } - u = NULL; + /* Status updates may be spread accross multiple packets and not + even on buddy boundaries, so keeping some state is important. + So, continue where we left off, and only add a user entry to + the list once it's complete (301-315 End buddy). */ + u = yd->half_user; for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; @@ -1353,13 +1338,13 @@ static void yahoo_process_status(struct yahoo_input_data *yid, switch (pair->key) { case 300: /* Begin buddy */ if (!strcmp(pair->value, "315") && !u) { - u = y_new0(struct user, 1); + u = yd->half_user = y_new0(struct yahoo_process_status_entry, 1); } break; case 301: /* End buddy */ if (!strcmp(pair->value, "315") && u) { users = y_list_prepend(users, u); - u = NULL; + u = yd->half_user = NULL; } break; case 0: /* we won't actually do anything with this */ @@ -1380,7 +1365,7 @@ static void yahoo_process_status(struct yahoo_input_data *yid, case 7: /* the current buddy */ if (!u) { /* This will only happen in case of a single level message */ - u = y_new0(struct user, 1); + u = y_new0(struct yahoo_process_status_entry, 1); users = y_list_prepend(users, u); } u->name = pair->value; @@ -1450,7 +1435,7 @@ static void yahoo_process_status(struct yahoo_input_data *yid, while (users) { YList *t = users; - struct user *u = users->data; + struct yahoo_process_status_entry *u = users->data; if (u->name != NULL) { if (pkt->service == diff --git a/protocols/yahoo/yahoo2_types.h b/protocols/yahoo/yahoo2_types.h index 3507e13a..f05acb3c 100644 --- a/protocols/yahoo/yahoo2_types.h +++ b/protocols/yahoo/yahoo2_types.h @@ -195,6 +195,8 @@ struct yahoo_data { char *ignorelist; void *server_settings; + + struct yahoo_process_status_entry *half_user; }; struct yab { @@ -260,6 +262,27 @@ struct yahoo_chat_member { char *location; }; +struct yahoo_process_status_entry { + char *name; /* 7 name */ + int state; /* 10 state */ + int flags; /* 13 flags, bit 0 = pager, bit 1 = chat, bit 2 = game */ + int mobile; /* 60 mobile */ + char *msg; /* 19 custom status message */ + int away; /* 47 away (or invisible) */ + int buddy_session; /* 11 state */ + int f17; /* 17 in chat? then what about flags? */ + int idle; /* 137 seconds idle */ + int f138; /* 138 state */ + char *f184; /* 184 state */ + int f192; /* 192 state */ + int f10001; /* 10001 state */ + int f10002; /* 10002 state */ + int f198; /* 198 state */ + char *f197; /* 197 state */ + char *f205; /* 205 state */ + int f213; /* 213 state */ +}; + #ifdef __cplusplus } #endif -- cgit v1.2.3 From 1be0d260da62542dd27b8a6f5d367a2e79191a8d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 13 Mar 2010 00:12:07 +0000 Subject: Fixed handling of contact lists where at least the first contact is not in any group yet. Crashing is not the right solution. --- protocols/yahoo/libyahoo2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index 57c32e2d..5b2ff44e 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -1493,13 +1493,14 @@ static void yahoo_process_buddy_list(struct yahoo_input_data *yid, newbud->id = strdup(pair->value); if (cur_group) newbud->group = strdup(cur_group); - else { + else if (yd->buddies) { struct yahoo_buddy *lastbud = (struct yahoo_buddy *)y_list_nth(yd-> buddies, y_list_length(yd->buddies) - 1)->data; newbud->group = strdup(lastbud->group); - } + } else + newbud->group = strdup("Buddies"); yd->buddies = y_list_append(yd->buddies, newbud); -- cgit v1.2.3 From 286b28eabf39d98d642c73c34a16a599e61dfc99 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 13 Mar 2010 01:02:47 +0000 Subject: Added nick_source account setting to allow using full name fields for generating nicknames instead of just the handle. --- account.c | 2 ++ doc/user-guide/commands.xml | 15 +++++++++++++++ protocols/nogaim.c | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/account.c b/account.c index 99c3ff53..a844d229 100644 --- a/account.c +++ b/account.c @@ -54,6 +54,8 @@ account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass ) s = set_add( &a->set, "auto_reconnect", "true", set_eval_bool, a ); + s = set_add( &a->set, "nick_source", "handle", NULL, a ); + s = set_add( &a->set, "password", NULL, set_eval_account, a ); s->flags |= ACC_SET_NOSAVE | SET_NULL_OK; diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index a7d06cf1..931608ee 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -607,6 +607,21 @@ + + handle + handle, full_name, first_name + + + + By default, BitlBee generates a nickname for every contact by taking its handle and chopping off everything after the @. In some cases, this gives very inconvenient nicknames. The Facebook XMPP server is a good example, as all Facebook XMPP handles are numeric. + + + + With this setting set to full_name, the person's full name is used to generate a nickname. Or if you don't like long nicknames, set this setting to first_name instead and only the first word will be used. Note that the full name can be full of non-ASCII characters which will be stripped off. + + + + both both, root, user, none diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 603905ab..6ee89e29 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -447,6 +447,7 @@ struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle ) void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ) { user_t *u = user_findhandle( ic, handle ); + char *set; if( !u || !realname ) return; @@ -459,6 +460,23 @@ void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ) if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) ) imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname ); } + + set = set_getstr( &ic->acc->set, "nick_source" ); + if( strcmp( set, "handle" ) != 0 ) + { + char *name = g_strdup( realname ); + + if( strcmp( set, "first_name" ) == 0 ) + { + int i; + for( i = 0; name[i] && !isspace( name[i] ); i ++ ) {} + name[i] = '\0'; + } + + imcb_buddy_nick_hint( ic, handle, name ); + + g_free( name ); + } } void imcb_remove_buddy( struct im_connection *ic, char *handle, char *group ) -- cgit v1.2.3 From bb3477107afcc6f532758bb08c4677d62e17ee57 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 14 Mar 2010 16:35:55 +0000 Subject: Close fd's 0,1,2 no matter what, not just if they're ttys. (Bug #476) --- bitlbee.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bitlbee.c b/bitlbee.c index b31c31fe..a96cff03 100644 --- a/bitlbee.c +++ b/bitlbee.c @@ -108,11 +108,17 @@ int bitlbee_daemon_init() chdir( "/" ); - /* Sometimes std* are already closed (for example when we're in a RESTARTed - BitlBee process. So let's only close TTY-fds. */ - if( isatty( 0 ) ) close( 0 ); - if( isatty( 1 ) ) close( 1 ); - if( isatty( 2 ) ) close( 2 ); + i = close( 0 ) == 0; + i += close( 1 ) == 0; + i += close( 2 ) == 0; + /* To avoid that something important ends up on one of those + fd's, open them for something bogus. Otherwise RESTART + may cause troubles. */ + while( i > 0 ) + { + open( "/dev/null", O_WRONLY ); + i --; + } } #endif -- cgit v1.2.3 From caceb0672b29fa49958d5f8b5338ff8e6ecb74d3 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 14 Mar 2010 16:37:46 +0000 Subject: Don't strip binaries on OS X since it causes plugin troubles. (Bug #480) --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index cac1161e..7fbaa37d 100755 --- a/configure +++ b/configure @@ -528,6 +528,7 @@ GNU/* ) *BSD ) ;; Darwin ) + echo 'STRIP=\# skip strip' >> Makefile.settings ;; IRIX ) ;; -- cgit v1.2.3 From e9cf291a52097d5b9428b8d1650cc691d5cc5dc8 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 14 Mar 2010 16:42:22 +0000 Subject: Allow the identify command only once. (Bug #509) --- root_commands.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/root_commands.c b/root_commands.c index c79ff325..b3432b9b 100644 --- a/root_commands.c +++ b/root_commands.c @@ -143,6 +143,12 @@ static void cmd_identify( irc_t *irc, char **cmd ) storage_status_t status = storage_load( irc, cmd[1] ); char *account_on[] = { "account", "on", NULL }; + if( strchr( irc->umode, 'R' ) != NULL ) + { + irc_usermsg( irc, "You're already logged in." ); + return; + } + switch (status) { case STORAGE_INVALID_PASSWORD: irc_usermsg( irc, "Incorrect password" ); -- cgit v1.2.3 From 435f55271b09102e21228a7add1b897025cdb078 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 14 Mar 2010 16:47:00 +0000 Subject: While I'm at it, set auto_reconnect to true by default, which I intended to do for a long time already since it should be safe with all protocol modules now. --- irc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/irc.c b/irc.c index 8d503e02..ee7b4b0d 100644 --- a/irc.c +++ b/irc.c @@ -165,7 +165,7 @@ irc_t *irc_new( int fd ) s->flags |= SET_NULL_OK; s = set_add( &irc->set, "away_devoice", "true", set_eval_away_devoice, irc ); s = set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc ); - s = set_add( &irc->set, "auto_reconnect", "false", set_eval_bool, irc ); + s = set_add( &irc->set, "auto_reconnect", "true", set_eval_bool, irc ); s = set_add( &irc->set, "auto_reconnect_delay", "5*3<900", set_eval_account_reconnect_delay, irc ); s = set_add( &irc->set, "buddy_sendbuffer", "false", set_eval_bool, irc ); s = set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc ); -- cgit v1.2.3 From af7f046b85694db45d670054e28960e4a0d79232 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 14 Mar 2010 16:56:00 +0000 Subject: Don't send a stream start after starttls since it upsets certain jabberd's including Zimbra's. Thanks to jMCg and balzar in #bitlbee for helping with figuring this out. --- protocols/jabber/io.c | 8 +++++--- protocols/jabber/jabber.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/protocols/jabber/io.c b/protocols/jabber/io.c index 10efad37..9534ff1a 100644 --- a/protocols/jabber/io.c +++ b/protocols/jabber/io.c @@ -440,6 +440,7 @@ static xt_status jabber_pkt_proceed_tls( struct xt_node *node, gpointer data ) imcb_log( ic, "Converting stream to TLS" ); + jd->flags |= JFLAG_STARTTLS_DONE; jd->ssl = ssl_starttls( jd->fd, jabber_connected_ssl, ic ); return XT_HANDLED; @@ -530,9 +531,10 @@ gboolean jabber_start_stream( struct im_connection *ic ) if( jd->r_inpa <= 0 ) jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, ic ); - greet = g_strdup_printf( "" - "", jd->server ); + greet = g_strdup_printf( "%s", + ( jd->flags & JFLAG_STARTTLS_DONE ) ? "" : "", + jd->server ); st = jabber_write( ic, greet, strlen( greet ) ); diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 7bb66e0e..a6cceb5a 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -45,6 +45,7 @@ typedef enum JFLAG_WANT_TYPING = 32, /* Set if we ever sent a typing notification, this activates all XEP-85 related code. */ JFLAG_XMLCONSOLE = 64, /* If the user added an xmlconsole buddy. */ + JFLAG_STARTTLS_DONE = 128, /* If a plaintext session was converted to TLS. */ } jabber_flags_t; typedef enum -- cgit v1.2.3 From 8fb1263325c6839b792c352283abac3f63142fa2 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 14 Mar 2010 17:45:33 +0000 Subject: Don't send bind and session requests at the same time when logging in because some very picky jabberd's don't like it. (Fixes Bug #569) --- protocols/jabber/io.c | 30 +++++++----------------------- protocols/jabber/iq.c | 31 +++++++++++++++++++++++++------ protocols/jabber/jabber.h | 4 ++-- 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/protocols/jabber/io.c b/protocols/jabber/io.c index 9534ff1a..4a790f27 100644 --- a/protocols/jabber/io.c +++ b/protocols/jabber/io.c @@ -374,39 +374,23 @@ static xt_status jabber_pkt_features( struct xt_node *node, gpointer data ) } if( ( c = xt_find_node( node->children, "bind" ) ) ) - { - reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) ); - xt_add_attr( reply, "xmlns", XMLNS_BIND ); - reply = jabber_make_packet( "iq", "set", NULL, reply ); - jabber_cache_add( ic, reply, jabber_pkt_bind_sess ); - - if( !jabber_write_packet( ic, reply ) ) - return XT_ABORT; - - jd->flags |= JFLAG_WAIT_BIND; - } + jd->flags |= JFLAG_WANT_BIND; if( ( c = xt_find_node( node->children, "session" ) ) ) - { - reply = xt_new_node( "session", NULL, NULL ); - xt_add_attr( reply, "xmlns", XMLNS_SESSION ); - reply = jabber_make_packet( "iq", "set", NULL, reply ); - jabber_cache_add( ic, reply, jabber_pkt_bind_sess ); - - if( !jabber_write_packet( ic, reply ) ) - return XT_ABORT; - - jd->flags |= JFLAG_WAIT_SESSION; - } + jd->flags |= JFLAG_WANT_SESSION; /* This flag is already set if we authenticated via SASL, so now we can resume the session in the new stream, if we don't have to bind/initialize the session. */ - if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 ) + if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WANT_BIND | JFLAG_WANT_SESSION ) ) == 0 ) { if( !jabber_get_roster( ic ) ) return XT_ABORT; } + else if( jd->flags & JFLAG_AUTHENTICATED ) + { + return jabber_pkt_bind_sess( ic, NULL, NULL ); + } return XT_HANDLED; } diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c index 875b5c81..21e52da6 100644 --- a/protocols/jabber/iq.c +++ b/protocols/jabber/iq.c @@ -297,24 +297,43 @@ static xt_status jabber_finish_iq_auth( struct im_connection *ic, struct xt_node xt_status jabber_pkt_bind_sess( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) { struct jabber_data *jd = ic->proto_data; - struct xt_node *c; + struct xt_node *c, *reply = NULL; char *s; - if( ( c = xt_find_node( node->children, "bind" ) ) ) + if( node && ( c = xt_find_node( node->children, "bind" ) ) ) { c = xt_find_node( c->children, "jid" ); if( c && c->text_len && ( s = strchr( c->text, '/' ) ) && strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 ) imcb_log( ic, "Server changed session resource string to `%s'", s + 1 ); - jd->flags &= ~JFLAG_WAIT_BIND; + jd->flags &= ~JFLAG_WANT_BIND; } - else + else if( node && ( c = xt_find_node( node->children, "session" ) ) ) + { + jd->flags &= ~JFLAG_WANT_SESSION; + } + + if( jd->flags & JFLAG_WANT_BIND ) { - jd->flags &= ~JFLAG_WAIT_SESSION; + reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) ); + xt_add_attr( reply, "xmlns", XMLNS_BIND ); + } + else if( jd->flags & JFLAG_WANT_SESSION ) + { + reply = xt_new_node( "session", NULL, NULL ); + xt_add_attr( reply, "xmlns", XMLNS_SESSION ); } - if( ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 ) + if( reply != NULL ) + { + reply = jabber_make_packet( "iq", "set", NULL, reply ); + jabber_cache_add( ic, reply, jabber_pkt_bind_sess ); + + if( !jabber_write_packet( ic, reply ) ) + return XT_ABORT; + } + else if( ( jd->flags & ( JFLAG_WANT_BIND | JFLAG_WANT_SESSION ) ) == 0 ) { if( !jabber_get_roster( ic ) ) return XT_ABORT; diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index a6cceb5a..8e3bf036 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -39,9 +39,9 @@ typedef enum JFLAG_AUTHENTICATED = 2, /* Set when we're successfully authenticatd. */ JFLAG_STREAM_RESTART = 4, /* Set when we want to restart the stream (after SASL or TLS). */ - JFLAG_WAIT_SESSION = 8, /* Set if we sent a tag and need a reply + JFLAG_WANT_SESSION = 8, /* Set if the server wants a tag before we continue. */ - JFLAG_WAIT_BIND = 16, /* ... for tag. */ + JFLAG_WANT_BIND = 16, /* ... for tag. */ JFLAG_WANT_TYPING = 32, /* Set if we ever sent a typing notification, this activates all XEP-85 related code. */ JFLAG_XMLCONSOLE = 64, /* If the user added an xmlconsole buddy. */ -- cgit v1.2.3 From c6ca3ee33e27feefb8cae0dc1d55a7239baf43cb Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 14 Mar 2010 17:49:24 +0000 Subject: Some const/etc cleanups submitted by domen@coderock.org back in bug #431. --- bitlbee.h | 2 ++ configure | 2 +- lib/misc.c | 3 ++- lib/misc.h | 2 +- protocols/jabber/jabber.h | 1 + protocols/msn/msn.c | 4 ++++ protocols/msn/msn.h | 6 +++--- protocols/nogaim.c | 16 ++++++++-------- protocols/nogaim.h | 17 ++++++++--------- user.c | 2 +- user.h | 2 +- 11 files changed, 32 insertions(+), 25 deletions(-) diff --git a/bitlbee.h b/bitlbee.h index 7c8b8a36..a09ebc5f 100644 --- a/bitlbee.h +++ b/bitlbee.h @@ -26,7 +26,9 @@ #ifndef _BITLBEE_H #define _BITLBEE_H +#ifndef _GNU_SOURCE #define _GNU_SOURCE /* Stupid GNU :-P */ +#endif /* Depend on Windows 2000 for now since we need getaddrinfo() */ #define _WIN32_WINNT 0x0501 diff --git a/configure b/configure index b3a98086..5be64a84 100755 --- a/configure +++ b/configure @@ -155,7 +155,7 @@ else fi echo CFLAGS=$CFLAGS >> Makefile.settings -echo CFLAGS+=-I`pwd` -I`pwd`/lib -I`pwd`/protocols -I. >> Makefile.settings +echo CFLAGS+=-I`pwd` -iquote`pwd`/lib -iquote`pwd`/protocols -I. >> Makefile.settings echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings diff --git a/lib/misc.c b/lib/misc.c index 9d504b75..c5087f75 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -33,6 +33,7 @@ #define BITLBEE_CORE #include "nogaim.h" #include "base64.h" +#include "md5.h" #include #include #include @@ -520,7 +521,7 @@ struct ns_srv_reply *srv_lookup( char *service, char *protocol, char *domain ) } /* Word wrapping. Yes, I know this isn't UTF-8 clean. I'm willing to take the risk. */ -char *word_wrap( char *msg, int line_len ) +char *word_wrap( const char *msg, int line_len ) { GString *ret = g_string_sized_new( strlen( msg ) + 16 ); diff --git a/lib/misc.h b/lib/misc.h index 5376cd22..ce36caf5 100644 --- a/lib/misc.h +++ b/lib/misc.h @@ -61,7 +61,7 @@ G_MODULE_EXPORT int bool2int( char *value ); G_MODULE_EXPORT struct ns_srv_reply *srv_lookup( char *service, char *protocol, char *domain ); -G_MODULE_EXPORT char *word_wrap( char *msg, int line_len ); +G_MODULE_EXPORT char *word_wrap( const char *msg, int line_len ); G_MODULE_EXPORT gboolean ssl_sockerr_again( void *ssl ); diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 904bf0c4..61238a30 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -28,6 +28,7 @@ #include "xmltree.h" #include "bitlbee.h" +#include "md5.h" extern GSList *jabber_connections; diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index a2e8519a..09670dfa 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -26,6 +26,10 @@ #include "nogaim.h" #include "msn.h" +int msn_chat_id; +GSList *msn_connections; +GSList *msn_switchboards; + static char *msn_set_display_name( set_t *set, char *value ); static void msn_init( account_t *acc ) diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index 63759303..16e5ab52 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -132,7 +132,7 @@ struct msn_handler_data #define STATUS_SB_IM_SPARE 4 /* Make one-to-one conversation switchboard available again, invite failed. */ #define STATUS_SB_CHAT_SPARE 8 /* Same, but also for groupchats (not used yet). */ -int msn_chat_id; +extern int msn_chat_id; extern const struct msn_away_state msn_away_state_list[]; extern const struct msn_status_code msn_status_code_list[]; @@ -141,8 +141,8 @@ extern const struct msn_status_code msn_status_code_list[]; is down already (for example, when an impatient user disabled the connection), the callback should check whether it's still listed here before doing *anything* else. */ -GSList *msn_connections; -GSList *msn_switchboards; +extern GSList *msn_connections; +extern GSList *msn_switchboards; /* ns.c */ gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ); diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 7466e93a..62669aaf 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -351,7 +351,7 @@ void imcb_ask( struct im_connection *ic, char *msg, void *data, /* list.c */ -void imcb_add_buddy( struct im_connection *ic, char *handle, char *group ) +void imcb_add_buddy( struct im_connection *ic, const char *handle, const char *group ) { user_t *u; char nick[MAX_NICK_LENGTH+1], *s; @@ -425,7 +425,7 @@ struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle ) return( b ); } -void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ) +void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *realname ) { user_t *u = user_findhandle( ic, handle ); @@ -442,7 +442,7 @@ void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ) } } -void imcb_remove_buddy( struct im_connection *ic, char *handle, char *group ) +void imcb_remove_buddy( struct im_connection *ic, const char *handle, char *group ) { user_t *u; @@ -627,7 +627,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, uint32_t flags, time_t sent_at ) +void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at ) { irc_t *irc = ic->irc; char *wrapped; @@ -694,7 +694,7 @@ 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 *imcb_chat_new( struct im_connection *ic, const char *handle ) { struct groupchat *c; @@ -760,7 +760,7 @@ void imcb_chat_free( struct groupchat *c ) } } -void imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, time_t sent_at ) +void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at ) { struct im_connection *ic = c->ic; char *wrapped; @@ -832,7 +832,7 @@ void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at /* buddy_chat.c */ -void imcb_chat_add_buddy( struct groupchat *b, char *handle ) +void imcb_chat_add_buddy( struct groupchat *b, const char *handle ) { user_t *u = user_findhandle( b->ic, handle ); int me = 0; @@ -867,7 +867,7 @@ void imcb_chat_add_buddy( struct groupchat *b, char *handle ) } /* This function is one BIG hack... :-( EREWRITE */ -void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason ) +void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char *reason ) { user_t *u; int me = 0; diff --git a/protocols/nogaim.h b/protocols/nogaim.h index 9fe843b5..ee5d7a30 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -42,7 +42,6 @@ #include "account.h" #include "proxy.h" #include "query.h" -#include "md5.h" #define BUDDY_ALIAS_MAXLEN 388 /* because MSN names can be 387 characters */ @@ -263,10 +262,10 @@ G_MODULE_EXPORT void imcb_ask_add( struct im_connection *ic, char *handle, const /* This function should be called for each handle which are visible to the * user, usually after a login, or if the user added a buddy and the IM * server confirms that the add was successful. Don't forget to do this! */ -G_MODULE_EXPORT void imcb_add_buddy( struct im_connection *ic, char *handle, char *group ); -G_MODULE_EXPORT void imcb_remove_buddy( struct im_connection *ic, char *handle, char *group ); +G_MODULE_EXPORT void imcb_add_buddy( struct im_connection *ic, const char *handle, const char *group ); +G_MODULE_EXPORT void imcb_remove_buddy( struct im_connection *ic, const char *handle, char *group ); G_MODULE_EXPORT struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle ); -G_MODULE_EXPORT void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ); +G_MODULE_EXPORT void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *realname ); G_MODULE_EXPORT void imcb_buddy_nick_hint( struct im_connection *ic, char *handle, char *nick ); /* Buddy activity */ @@ -277,7 +276,7 @@ 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, uint32_t flags, time_t sent_at ); +G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, const 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 ); @@ -289,12 +288,12 @@ G_MODULE_EXPORT void imcb_chat_invited( struct im_connection *ic, char *handle, * - After you have a groupchat pointer, you should add the handles, finally * the user her/himself. At that point the group chat will be visible to the * user, too. */ -G_MODULE_EXPORT struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle ); -G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, char *handle ); +G_MODULE_EXPORT struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle ); +G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, const 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 ); +G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const 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 ); +G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, const 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'. */ diff --git a/user.c b/user.c index 26676dd4..4d58f56b 100644 --- a/user.c +++ b/user.c @@ -140,7 +140,7 @@ user_t *user_find( irc_t *irc, char *nick ) return( NULL ); } -user_t *user_findhandle( struct im_connection *ic, char *handle ) +user_t *user_findhandle( struct im_connection *ic, const char *handle ) { user_t *u; char *nick; diff --git a/user.h b/user.h index c6b933bc..9d8a41a0 100644 --- a/user.h +++ b/user.h @@ -55,7 +55,7 @@ typedef struct __USER user_t *user_add( struct irc *irc, char *nick ); int user_del( irc_t *irc, char *nick ); G_MODULE_EXPORT user_t *user_find( irc_t *irc, char *nick ); -G_MODULE_EXPORT user_t *user_findhandle( struct im_connection *ic, char *handle ); +G_MODULE_EXPORT user_t *user_findhandle( struct im_connection *ic, const char *handle ); void user_rename( irc_t *irc, char *oldnick, char *newnick ); #endif /* __USER_H__ */ -- cgit v1.2.3 From ceebeb12e935e7a6fa72e1375e99d53cc91fcf45 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 14 Mar 2010 18:09:56 +0000 Subject: Warn if xmlto is missing and a prebuilt helpfile is missing. --- configure | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/configure b/configure index 1daf0a99..4fa1ee8c 100755 --- a/configure +++ b/configure @@ -443,6 +443,12 @@ else echo '#define WITH_PLUGINS' >> config.h fi +if [ ! -e doc/user-guide/help.txt ] && ! type xmlto > /dev/null 2> /dev/null; then + echo + echo 'WARNING: Building from an unreleased source tree without prebuilt helpfile.' + echo 'Install xmlto if you want online help to work.' +fi + echo if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then nick=`bzr nick` -- cgit v1.2.3 From 90cd6c4780c7e42a0b7caff5d3a2ba1e0bd3f308 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 14 Mar 2010 18:22:43 +0000 Subject: Allow disabling certain IM protocols at runtime, patch from misc@mandriva.org, bug #381. --- bitlbee.conf | 8 ++++++++ conf.c | 6 ++++++ conf.h | 1 + protocols/nogaim.c | 14 +++++++++++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/bitlbee.conf b/bitlbee.conf index 4a3bbddf..c5dafd9f 100644 --- a/bitlbee.conf +++ b/bitlbee.conf @@ -119,6 +119,14 @@ ## Proxy = socks4://socksproxy.localnet.com ## Proxy = socks5://socksproxy.localnet.com +## Protocols offered by bitlbee +## +## As recompiling may be quite unpractical for some people, this option +## allows to remove the support of protocol, even if compiled in. If +## nothing is given, there are no restrictions. +## +## Protocols = jabber yahoo + [defaults] diff --git a/conf.c b/conf.c index c8cfaad8..b997fb0a 100644 --- a/conf.c +++ b/conf.c @@ -62,6 +62,7 @@ conf_t *conf_load( int argc, char *argv[] ) conf->ping_interval = 180; conf->ping_timeout = 300; conf->user = NULL; + conf->protocols = NULL; proxytype = 0; i = conf_loadini( conf, global.conf_file ); @@ -306,6 +307,11 @@ static int conf_loadini( conf_t *conf, char *file ) g_free( conf->user ); conf->user = g_strdup( ini->value ); } + else if( g_strcasecmp( ini->key, "protocols" ) == 0 ) + { + g_strfreev( conf->protocols ); + conf->protocols = g_strsplit_set( ini->value, " \t,;", -1 ); + } else { fprintf( stderr, "Error: Unknown setting `%s` in configuration file (line %d).\n", ini->key, ini->line ); diff --git a/conf.h b/conf.h index c41fd096..b112681d 100644 --- a/conf.h +++ b/conf.h @@ -49,6 +49,7 @@ typedef struct conf int ping_interval; int ping_timeout; char *user; + char **protocols; } conf_t; G_GNUC_MALLOC conf_t *conf_load( int argc, char *argv[] ); diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 75c2139b..9c6daeaf 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -97,7 +97,19 @@ GList *protocols = NULL; void register_protocol (struct prpl *p) { - protocols = g_list_append(protocols, p); + int i; + gboolean refused = global.conf->protocols != NULL; + + for (i = 0; global.conf->protocols && global.conf->protocols[i]; i++) + { + if (g_strcasecmp(p->name, global.conf->protocols[i]) == 0) + refused = FALSE; + } + + if (refused) + log_message(LOGLVL_WARNING, "Protocol %s disabled\n", p->name); + else + protocols = g_list_append(protocols, p); } struct prpl *find_protocol(const char *name) -- cgit v1.2.3 From 21d48d977b35d35d0ad86b3ccd051dae0d1fe055 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 14 Mar 2010 20:19:10 +0000 Subject: Fix for bug #536: No longer fail on corrupted USR responses with certain Unicode characters in the friendly name. --- protocols/msn/ns.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index d05d8e0d..d78d753a 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -228,19 +228,26 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) return( 0 ); } } - else if( num_parts == 7 && strcmp( cmd[2], "OK" ) == 0 ) + else if( num_parts >= 7 && strcmp( cmd[2], "OK" ) == 0 ) { set_t *s; - http_decode( cmd[4] ); - - strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) ); - ic->displayname[sizeof(ic->displayname)-1] = 0; - - if( ( s = set_find( &ic->acc->set, "display_name" ) ) ) + if( num_parts == 7 ) { - g_free( s->value ); - s->value = g_strdup( cmd[4] ); + http_decode( cmd[4] ); + + strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) ); + ic->displayname[sizeof(ic->displayname)-1] = 0; + + if( ( s = set_find( &ic->acc->set, "display_name" ) ) ) + { + g_free( s->value ); + s->value = g_strdup( cmd[4] ); + } + } + else + { + imcb_log( ic, "Warning: Friendly name in server response was corrupted" ); } imcb_log( ic, "Authenticated, getting buddy list" ); -- cgit v1.2.3 From 7e2b5934976f6d833397f72bd11fbc63616a56f2 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 14 Mar 2010 23:14:41 +0000 Subject: Preparing for 1.2.5. --- bitlbee.h | 2 +- doc/CHANGES | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/bitlbee.h b/bitlbee.h index 326e944d..15592020 100644 --- a/bitlbee.h +++ b/bitlbee.h @@ -34,7 +34,7 @@ #define _WIN32_WINNT 0x0501 #define PACKAGE "BitlBee" -#define BITLBEE_VERSION "1.2.4" +#define BITLBEE_VERSION "1.2.5" #define VERSION BITLBEE_VERSION #define MAX_STRING 511 diff --git a/doc/CHANGES b/doc/CHANGES index 1bfd71d4..a0e9b30b 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -3,6 +3,21 @@ found in the bzr commit logs, for example you can try: http://bugs.bitlbee.org/bitlbee/timeline?daysback=90&changeset=on +Version 1.2.5: +- Many bug fixes, including a fix for MSN login issues, Jabber login timing + issues, Yahoo! crashes at login time with huge contact lists, +- Avoid linking in a static version of libresolv now that glibc has all + relevant functions available in the dynamic version. +- Improved away state code and added the ability to set (non-away) status + messages using "set status" (also possible per account). +- Added a post-1.2 equivalent of encode/decode to quickly encrypt/decrypt + passwords in a way that BitlBee can read them. +- Allow using the full name for generating nicknames, instead of just the + handle. This is especially useful when using the Facebook XMPP server. +- Auto reconnect is now enabled by default since all protocols can properly + detect cases where auto reconnect should be avoided (i.e. concurrent + logins). + Version 1.2.4: - Most important change (and main reason for releasing now): Upgraded Yahoo! module to a newer version to get it working again. -- cgit v1.2.3 From 315dd4c1566dcd4caa9c4ca0eceeceb995a01443 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 15 Mar 2010 01:25:47 +0000 Subject: Oops.. Today's Jabber fix could get stuck in a somewhat infinite loop if a Jabber server returns an empty response to the session establishment request (which is valid and actually done by the example, but my test Jabberd shows different behaviour). Fixed. --- protocols/jabber/io.c | 12 +----------- protocols/jabber/iq.c | 8 ++------ 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/protocols/jabber/io.c b/protocols/jabber/io.c index 4a790f27..a14ad21c 100644 --- a/protocols/jabber/io.c +++ b/protocols/jabber/io.c @@ -379,18 +379,8 @@ static xt_status jabber_pkt_features( struct xt_node *node, gpointer data ) if( ( c = xt_find_node( node->children, "session" ) ) ) jd->flags |= JFLAG_WANT_SESSION; - /* This flag is already set if we authenticated via SASL, so now - we can resume the session in the new stream, if we don't have - to bind/initialize the session. */ - if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WANT_BIND | JFLAG_WANT_SESSION ) ) == 0 ) - { - if( !jabber_get_roster( ic ) ) - return XT_ABORT; - } - else if( jd->flags & JFLAG_AUTHENTICATED ) - { + if( jd->flags & JFLAG_AUTHENTICATED ) return jabber_pkt_bind_sess( ic, NULL, NULL ); - } return XT_HANDLED; } diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c index 21e52da6..1b76a761 100644 --- a/protocols/jabber/iq.c +++ b/protocols/jabber/iq.c @@ -306,23 +306,19 @@ xt_status jabber_pkt_bind_sess( struct im_connection *ic, struct xt_node *node, if( c && c->text_len && ( s = strchr( c->text, '/' ) ) && strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 ) imcb_log( ic, "Server changed session resource string to `%s'", s + 1 ); - - jd->flags &= ~JFLAG_WANT_BIND; - } - else if( node && ( c = xt_find_node( node->children, "session" ) ) ) - { - jd->flags &= ~JFLAG_WANT_SESSION; } if( jd->flags & JFLAG_WANT_BIND ) { reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) ); xt_add_attr( reply, "xmlns", XMLNS_BIND ); + jd->flags &= ~JFLAG_WANT_BIND; } else if( jd->flags & JFLAG_WANT_SESSION ) { reply = xt_new_node( "session", NULL, NULL ); xt_add_attr( reply, "xmlns", XMLNS_SESSION ); + jd->flags &= ~JFLAG_WANT_SESSION; } if( reply != NULL ) -- cgit v1.2.3 From 9fca06579d61d6360520db98092bce13d30d39ce Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 15 Mar 2010 10:26:25 +0000 Subject: Deal with stupid (on first sight, at least) Yahoo! server behaviour causing double free()s on testing ATM. Apparently it's perfectly legal to give buddy information with an "end buddy" marker but no "begin buddy". --- protocols/yahoo/libyahoo2.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index 5b2ff44e..1bfc2e59 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -1343,7 +1343,11 @@ static void yahoo_process_status(struct yahoo_input_data *yid, break; case 301: /* End buddy */ if (!strcmp(pair->value, "315") && u) { - users = y_list_prepend(users, u); + /* Sometimes user info comes in an odd format with no + "begin buddy" but *with* an "end buddy". Don't add + it twice. */ + if (!y_list_find(users, u)) + users = y_list_prepend(users, u); u = yd->half_user = NULL; } break; -- cgit v1.2.3 From 449a51de265cb3b4f0f5003e09fbbb030247c972 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 16 Mar 2010 10:18:02 +0000 Subject: Include non-away status messages in blist and whois responses. The whois change is a complete violation of the IRC protocol but that doesn't seem to be an uncommon thing. --- irc_commands.c | 2 ++ protocols/nogaim.c | 13 +++++++------ root_commands.c | 9 +++++++-- user.h | 1 + 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/irc_commands.c b/irc_commands.c index 750bbcf5..a417e0d9 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -496,6 +496,8 @@ static void irc_cmd_whois( irc_t *irc, char **cmd ) irc_reply( irc, 301, "%s :%s", u->nick, "User is offline" ); else if( u->away ) irc_reply( irc, 301, "%s :%s", u->nick, u->away ); + if( u->status_msg ) + irc_reply( irc, 333, "%s :Status: %s", u->nick, u->status_msg ); irc_reply( irc, 318, "%s :End of /WHOIS list", nick ); } diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 9c6daeaf..c326e378 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -646,11 +646,9 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, oa = u->away != NULL; oo = u->online; - if( u->away ) - { - g_free( u->away ); - u->away = NULL; - } + g_free( u->away ); + g_free( u->status_msg ); + u->away = u->status_msg = NULL; if( ( flags & OPT_LOGGED_IN ) && !u->online ) { @@ -688,7 +686,10 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, u->away = g_strdup( "Away" ); } } - /* else waste_any_state_information_for_now(); */ + else + { + u->status_msg = g_strdup( message ); + } /* LISPy... */ if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ diff --git a/root_commands.c b/root_commands.c index b3432b9b..15e6e72a 100644 --- a/root_commands.c +++ b/root_commands.c @@ -913,7 +913,7 @@ static void cmd_blist( irc_t *irc, char **cmd ) else if( cmd[1] && g_strcasecmp( cmd[1], "online" ) == 0 ) online = 1; else - online = away = 1; + online = away = 1; if( strchr( irc->umode, 'b' ) != NULL ) format = "%s\t%s\t%s"; @@ -926,8 +926,13 @@ static void cmd_blist( irc_t *irc, char **cmd ) { if( online == 1 ) { + char st[256] = "Online"; + + if( u->status_msg ) + g_snprintf( st, sizeof( st ) - 1, "Online (%s)", u->status_msg ); + 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" ); + irc_usermsg( irc, format, u->nick, s, st ); } n_online ++; diff --git a/user.h b/user.h index 9d8a41a0..8c4f9c44 100644 --- a/user.h +++ b/user.h @@ -33,6 +33,7 @@ typedef struct __USER char *realname; char *away; + char *status_msg; /* Non-IRC extension, but nice on IM. */ char is_private; char online; -- cgit v1.2.3 From ec55a7d76711d6b071e0d1ba043cb120d3e11c24 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 16 Mar 2010 10:24:00 +0000 Subject: Really set Yahoo! status messages properly. YMSG, how I hate you. --- protocols/yahoo/yahoo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index a47de966..b61f6ff9 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -226,7 +226,7 @@ static void byahoo_set_away( struct im_connection *ic, char *state, char *msg ) else yd->current_status = YAHOO_STATUS_CUSTOM; } - else if( state ) + else if( msg ) yd->current_status = YAHOO_STATUS_CUSTOM; else yd->current_status = YAHOO_STATUS_AVAILABLE; -- cgit v1.2.3 From 0b510af4fc35c08e7eb693c018c9db141916970a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 16 Mar 2010 10:45:26 +0000 Subject: Check the RESTART environment variable before closing fd's 0-2 since the previous approach broke upgrades to bzr >= 500. --- bitlbee.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/bitlbee.c b/bitlbee.c index a96cff03..26d12b6c 100644 --- a/bitlbee.c +++ b/bitlbee.c @@ -108,17 +108,13 @@ int bitlbee_daemon_init() chdir( "/" ); - i = close( 0 ) == 0; - i += close( 1 ) == 0; - i += close( 2 ) == 0; - /* To avoid that something important ends up on one of those - fd's, open them for something bogus. Otherwise RESTART - may cause troubles. */ - while( i > 0 ) - { - open( "/dev/null", O_WRONLY ); - i --; - } + if( getenv( "_BITLBEE_RESTART_STATE" ) == NULL ) + for( i = 0; i < 3; i ++ ) + if( close( i ) == 0 ) + { + /* Keep something bogus on those fd's just in case. */ + open( "/dev/null", O_WRONLY ); + } } #endif -- cgit v1.2.3 From a1ac227895d6e457bf0bc1fe3f4ecd72d2f39b08 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 17 Mar 2010 01:07:41 +0000 Subject: Here we go, stable for >24h on testing and im. Time to release. --- doc/CHANGES | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/CHANGES b/doc/CHANGES index a0e9b30b..cbd8d737 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -9,7 +9,8 @@ Version 1.2.5: - Avoid linking in a static version of libresolv now that glibc has all relevant functions available in the dynamic version. - Improved away state code and added the ability to set (non-away) status - messages using "set status" (also possible per account). + messages using "set status" (also possible per account) and see them in + blist and /whois output. - Added a post-1.2 equivalent of encode/decode to quickly encrypt/decrypt passwords in a way that BitlBee can read them. - Allow using the full name for generating nicknames, instead of just the @@ -18,6 +19,8 @@ Version 1.2.5: detect cases where auto reconnect should be avoided (i.e. concurrent logins). +Fixed 17 Mar 2010 + Version 1.2.4: - Most important change (and main reason for releasing now): Upgraded Yahoo! module to a newer version to get it working again. -- cgit v1.2.3 From f9928cb319c2879a56b7280f09723b26035982d0 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 17 Mar 2010 01:13:23 +0000 Subject: Set resource_select to activity by default since priority has always been a stupid default. More fixes coming up soon. --- doc/CHANGES | 3 +++ doc/user-guide/commands.xml | 2 +- protocols/jabber/jabber.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/CHANGES b/doc/CHANGES index cbd8d737..1cac2dc7 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -18,6 +18,9 @@ Version 1.2.5: - Auto reconnect is now enabled by default since all protocols can properly detect cases where auto reconnect should be avoided (i.e. concurrent logins). +- Changed the default resource_select setting which should reduce message + routing issues on Jabber (i.e. messages going someone's phone instead of + the main client). Fixed 17 Mar 2010 diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index 931608ee..700df7bb 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -715,7 +715,7 @@ - priority + activity priority, activity diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index eca7d2d3..a1fb8817 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -66,7 +66,7 @@ static void jabber_init( account_t *acc ) s = set_add( &acc->set, "resource", "BitlBee", NULL, acc ); s->flags |= ACC_SET_OFFLINE_ONLY; - s = set_add( &acc->set, "resource_select", "priority", NULL, acc ); + s = set_add( &acc->set, "resource_select", "activity", NULL, acc ); s = set_add( &acc->set, "server", NULL, set_eval_account, acc ); s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY | SET_NULL_OK; -- cgit v1.2.3