aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/jabber/presence.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2006-10-10 14:05:42 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2006-10-10 14:05:42 +0200
commita21a8ac4fbd5a234bc8d31d9d487c74a81383c8a (patch)
treed8445a5409dfe11de56433f59cfa063952734d86 /protocols/jabber/presence.c
parent6a1128d1333cf79f1ef9fb1f55b1b8fec67caf2a (diff)
Added resource selection (based on priority or time of last message) to
budd_by_jid(), added a full_jid property to easily address that resource without having to rebuild the full JID every time and implemented typing notification shite.
Diffstat (limited to 'protocols/jabber/presence.c')
-rw-r--r--protocols/jabber/presence.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c
index 86bdcb1d..3a682e52 100644
--- a/protocols/jabber/presence.c
+++ b/protocols/jabber/presence.c
@@ -29,13 +29,19 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
char *from = xt_find_attr( node, "from" );
char *type = xt_find_attr( node, "type" ); /* NULL should mean the person is online. */
struct xt_node *c;
+ struct jabber_buddy *bud;
if( !from )
return XT_HANDLED;
if( type == NULL )
{
- struct jabber_buddy *bud;
+ if( strchr( from, '/' ) == NULL )
+ {
+ char *s = xt_to_string( node );
+ serv_got_crap( gc, "WARNING: Ignoring presence tag with bare JID: %s\n", s );
+ g_free( s );
+ }
if( !( bud = jabber_buddy_by_jid( gc, from ) ) )
{
@@ -51,23 +57,34 @@ 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 );
else
+ {
bud->away_state = NULL;
+ /* Let's only set last_act if there's *no* away state,
+ since it could be some auto-away thingy. */
+ bud->last_act = time( NULL );
+ }
if( ( c = xt_find_node( node->children, "priority" ) ) && c->text_len > 0 )
bud->priority = atoi( c->text );
else
bud->priority = 0;
- serv_got_update( gc, bud->handle, 1, 0, 0, 0, 0, 0 );
+ serv_got_update( gc, bud->handle, 1, 0, 0, 0,
+ bud->away_state ? UC_UNAVAILABLE : 0, 0 );
}
else if( strcmp( type, "unavailable" ) == 0 )
{
char *s;
- jabber_buddy_remove( gc, from );
+ if( ( s = strchr( from, '/' ) ) == NULL )
+ {
+ char *s = xt_to_string( node );
+ serv_got_crap( gc, "WARNING: Ignoring presence tag with bare JID: %s\n", s );
+ g_free( s );
+ }
- if( ( s = strchr( from, '/' ) ) )
- *s = 0;
+ jabber_buddy_remove( gc, from );
+ *s = 0;
/* Only count this as offline if there's no other resource
available anymore. */