diff options
Diffstat (limited to 'protocols/jabber/presence.c')
-rw-r--r-- | protocols/jabber/presence.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c index b10ce634..ccd22f60 100644 --- a/protocols/jabber/presence.c +++ b/protocols/jabber/presence.c @@ -30,22 +30,40 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) char *type = xt_find_attr( node, "type" ); /* NULL should mean the person is online. */ struct xt_node *c; struct jabber_buddy *bud; + char *s; if( !from ) return XT_HANDLED; if( type == NULL ) { - if( strchr( from, '/' ) == NULL ) + 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 ); + serv_got_crap( gc, "WARNING: Ignoring presence tag with bare JID: %s", s ); g_free( s ); return XT_HANDLED; } if( !( bud = jabber_buddy_by_jid( gc, from ) ) ) { + /* FOR NOW, s still contains the location of the /. + Keep this in mind when changing things here. :-) */ + + /* We check if the buddy is in the contact list, + because Jabber servers seem to like to send + presence information of buddies we removed + from our list sometimes, for example... */ + + *s = 0; + if( find_buddy( gc, from ) == NULL ) + { + *s = '/'; + serv_got_crap( gc, "WARNING: Ignoring presence information from unknown JID: %s", from ); + return XT_HANDLED; + } + *s = '/'; + bud = jabber_buddy_add( gc, from ); } @@ -85,6 +103,12 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) return XT_HANDLED; } + if( jabber_buddy_by_jid( gc, from ) == NULL ) + { + serv_got_crap( gc, "WARNING: Received presence information from unknown JID: %s", from ); + return XT_HANDLED; + } + jabber_buddy_remove( gc, from ); *s = 0; |