aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/jabber/presence.c
diff options
context:
space:
mode:
authorulim <a.sporto+bee@gmail.com>2008-02-15 18:38:57 +0100
committerulim <a.sporto+bee@gmail.com>2008-02-15 18:38:57 +0100
commit1ba7e8f1d28c4876ea0b787f1e4ebb5607f48895 (patch)
tree5ba8bed0e1ba83c56a855059e88e3d2a205fe88c /protocols/jabber/presence.c
parent0fbd3a6d26d8fe747bd5e061748e75f397801064 (diff)
parenteeb85a8a880fefe655eb31b6322136b61ee969e2 (diff)
Merged with upstream r328
Wilmer van der Gaast 2008-02-11 Got rid of some noise at startup: complaining when the default configuration Wilmer van der Gaast 2008-02-10 Added support for password-protected Jabber chatrooms. Wilmer van der Gaast 2008-02-10 Making AI_ADDRCONFIG optional, it doesn't exist on at least NetBSD and Wilmer van der Gaast 2008-02-09 Restored "add -tmp". A bit hackish, but it will do for now. Wilmer van der Gaast 2008-02-07 Fixed getnameinfo() calls, this fixes Solaris stability issues. Thanks to Wilmer van der Gaast 2008-02-04 Added bogus G_GNUC_MALLOC to restore GLib 2.4 compatibility (hopefully). Wilmer van der Gaast 2008-02-03 Messages from the user are also included in backlogs when joining a Jabber Wilmer van der Gaast 2008-02-03 Disabling "Unknown command" warnings since they're very noisy and pretty Wilmer van der Gaast 2008-02-03 Implemented XEP-0115. This adds some info to the <presence/> tags so Wilmer van der Gaast 2008-02-03 Saner garbage collection of cached packets in the Jabber module. Now Wilmer van der Gaast 2008-02-02 Added help_free() and cleaned up some very stale help-related stuff I Wilmer van der Gaast 2008-01-30 Fixed handling of OSCAR multi-part messages... They're not arrays, they're Wilmer van der Gaast 2008-01-24 Keeping track of valid Jabber connections so _connected() events will be Wilmer van der Gaast 2008-01-24 Fixed two valgrind warnings (partially uninitialized "struct tm" vars.) Wilmer van der Gaast 2008-01-20 The Jabber module now uses imcb_chat_log() instead of imcb_log() where Wilmer van der Gaast 2008-01-20 Added imcb_chat_log() for chatroom system messages, so they can be Wilmer van der Gaast 2008-01-20 GET_BUDDY_FIRST wasn't actually implemented, even though it was in use Wilmer van der Gaast 2008-01-19 Using test -f instead of test -e. This breaks if the include files are Wilmer van der Gaast 2008-01-19 Added byte swapping code to the new MD5 checksumming code to make it work Wilmer van der Gaast 2008-01-18 Moving imcb_chat_new() to a saner location (no code changes) and fixing Wilmer van der Gaast 2008-01-17 Apparently ext_yahoo_got_im can be called with msg=NULL, so it should be Wilmer van der Gaast 2008-01-17 Fixing some Solaris compiler warnings (u_int->uint, adding some typecasts Wilmer van der Gaast 2008-01-13 Fixed handing of failed groupchat joins. Wilmer van der Gaast 2008-01-13 Fixed "Conditional jump or move depends on uninitialised value(s)" at Wilmer van der Gaast 2008-01-13 Fixed quickstart2. (Bug #349.) Wilmer van der Gaast 2008-01-13 Different handling of charset mismatches before login time. Ignoring a Wilmer van der Gaast 2008-01-12 When a switchboard connection dies (at the TCP level) and there are still Wilmer van der Gaast 2008-01-12 Killed info_string_append() and now showing the IP address of ICQ users Wilmer van der Gaast 2008-01-11 Fixing bug #344, now away states should always be correct, even when people Wilmer van der Gaast 2008-01-11 Adding own handle to protocol name in blist output for people with multiple Wilmer van der Gaast 2008-01-10 Now setting odata->icq properly again, this got lost some time ago, which Wilmer van der Gaast 2008-01-06 More consistency in error/warning errors. Until now "WARNING:" was usually Wilmer van der Gaast 2008-01-06 Changed warning message about unsent MSN messages. It should show the actual Wilmer van der Gaast 2008-01-05 Added "mail_notifications" setting. Who needs those notifications anyway? Wilmer van der Gaast 2008-01-05 Build fix from vmiklos. Wilmer van der Gaast 2008-01-05 Added handling of MSN switchboard NAK messages. Untested, but hey, it Wilmer van der Gaast 2008-01-05 Removed closure->result. I was planning to add some more stuff, but will Miklos Vajna 2007-12-31 encode: md5.c is no longer in protocols/, it's in lib/ Wilmer van der Gaast 2007-12-28 Fixed return value check in proxy_connect(), since on some systems Wilmer van der Gaast 2007-12-28 Added missing return in jabber_login(). Wilmer van der Gaast 2007-12-16 Implemented XEP-0199 (patch from misc@mandriva.org). Wilmer van der Gaast 2007-12-12 Checking conn->xcred before trying to clean it up since GnuTLS doesn't Wilmer van der Gaast 2007-12-12 Killed the <server> parameter to "account add" and changed the default Wilmer van der Gaast 2007-12-12 Fixed sockerr_again() usage in Jabber module to (hopefully) fix a 100% CPU Wilmer van der Gaast 2007-12-10 Don't allow nicks that start with a number. Wilmer van der Gaast 2007-12-10 Fixed "set xxx" syntax (it showed all settings instead of just xxx). Wilmer van der Gaast 2007-12-09 If I keep forgetting to credit people in commit msgs I should probably add Wilmer van der Gaast 2007-12-09 Added /invite support for Jabber chatrooms (and fixed the argument order
Diffstat (limited to 'protocols/jabber/presence.c')
-rw-r--r--protocols/jabber/presence.c76
1 files changed, 53 insertions, 23 deletions
diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c
index c3d7dced..6fc360b7 100644
--- a/protocols/jabber/presence.c
+++ b/protocols/jabber/presence.c
@@ -28,9 +28,9 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
struct im_connection *ic = data;
char *from = xt_find_attr( node, "from" );
char *type = xt_find_attr( node, "type" ); /* NULL should mean the person is online. */
- struct xt_node *c;
- struct jabber_buddy *bud;
- int is_chat = 0, is_away = 0;
+ struct xt_node *c, *cap;
+ struct jabber_buddy *bud, *send_presence = NULL;
+ int is_chat = 0;
char *s;
if( !from )
@@ -49,7 +49,7 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
if( !( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) )
{
if( set_getbool( &ic->irc->set, "debug" ) )
- imcb_log( ic, "WARNING: Could not handle presence information from JID: %s", from );
+ imcb_log( ic, "Warning: Could not handle presence information from JID: %s", from );
return XT_HANDLED;
}
@@ -62,8 +62,6 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
if( ( c = xt_find_node( node->children, "show" ) ) && c->text_len > 0 )
{
bud->away_state = (void*) jabber_away_state_by_code( c->text );
- if( strcmp( c->text, "chat" ) != 0 )
- is_away = OPT_AWAY;
}
else
{
@@ -78,19 +76,37 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
else
bud->priority = 0;
+ if( bud && ( cap = xt_find_node( node->children, "c" ) ) &&
+ ( s = xt_find_attr( cap, "xmlns" ) ) && strcmp( s, XMLNS_CAPS ) == 0 )
+ {
+ /* This <presence> stanza includes an XEP-0115
+ capabilities part. Not too interesting, but we can
+ see if it has an ext= attribute. */
+ s = xt_find_attr( cap, "ext" );
+ if( s && ( strstr( s, "cstates" ) || strstr( s, "chatstate" ) ) )
+ bud->flags |= JBFLAG_DOES_XEP85;
+
+ /* This field can contain more information like xhtml
+ support, but we don't support that ourselves.
+ Officially the ext= tag was deprecated, but enough
+ clients do send it.
+
+ (I'm aware that this is not the right way to use
+ this field.) See for an explanation of ext=:
+ http://www.xmpp.org/extensions/attic/xep-0115-1.3.html*/
+ }
+
if( is_chat )
jabber_chat_pkt_presence( ic, bud, node );
- else if( bud == jabber_buddy_by_jid( ic, bud->bare_jid, 0 ) )
- imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away,
- ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL,
- bud->away_message );
+ else
+ send_presence = jabber_buddy_by_jid( ic, bud->bare_jid, 0 );
}
else if( strcmp( type, "unavailable" ) == 0 )
{
if( ( bud = jabber_buddy_by_jid( ic, from, 0 ) ) == NULL )
{
if( set_getbool( &ic->irc->set, "debug" ) )
- imcb_log( ic, "WARNING: Received presence information from unknown JID: %s", from );
+ imcb_log( ic, "Warning: Received presence information from unknown JID: %s", from );
return XT_HANDLED;
}
@@ -118,17 +134,7 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
/* If another resource is still available, send its presence
information. */
- if( ( bud = jabber_buddy_by_jid( ic, from, 0 ) ) )
- {
- if( bud->away_state && ( *bud->away_state->code == 0 ||
- strcmp( bud->away_state->code, "chat" ) == 0 ) )
- is_away = OPT_AWAY;
-
- imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away,
- ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL,
- bud->away_message );
- }
- else
+ if( ( send_presence = jabber_buddy_by_jid( ic, from, 0 ) ) == NULL )
{
/* Otherwise, count him/her as offline now. */
imcb_buddy_status( ic, from, 0, NULL, NULL );
@@ -176,6 +182,20 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
jabber_error_free( err );
} */
}
+
+ if( send_presence )
+ {
+ int is_away = 0;
+
+ if( send_presence->away_state && !( *send_presence->away_state->code == 0 ||
+ strcmp( send_presence->away_state->code, "chat" ) == 0 ) )
+ is_away = OPT_AWAY;
+
+ imcb_buddy_status( ic, send_presence->bare_jid, OPT_LOGGED_IN | is_away,
+ ( is_away && send_presence->away_state ) ?
+ send_presence->away_state->full_name : NULL,
+ send_presence->away_message );
+ }
return XT_HANDLED;
}
@@ -185,7 +205,7 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
int presence_send_update( struct im_connection *ic )
{
struct jabber_data *jd = ic->proto_data;
- struct xt_node *node;
+ struct xt_node *node, *cap;
char *show = jd->away_state->code;
char *status = jd->away_message;
struct groupchat *c;
@@ -198,6 +218,16 @@ int presence_send_update( struct im_connection *ic )
if( status )
xt_add_child( node, xt_new_node( "status", status, NULL ) );
+ /* This makes the packet slightly bigger, but clients interested in
+ capabilities can now cache the discovery info. This reduces the
+ usual post-login iq-flood. See XEP-0115. At least libpurple and
+ Trillian seem to do this right. */
+ cap = xt_new_node( "c", NULL, NULL );
+ xt_add_attr( cap, "xmlns", XMLNS_CAPS );
+ xt_add_attr( cap, "node", "http://bitlbee.org/xmpp/caps" );
+ xt_add_attr( cap, "ver", BITLBEE_VERSION ); /* The XEP wants this hashed, but nobody's doing that. */
+ xt_add_child( node, cap );
+
st = jabber_write_packet( ic, node );
/* Have to send this update to all groupchats too, the server won't