aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/jabber/presence.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2006-10-15 22:24:01 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2006-10-15 22:24:01 +0200
commit788a1afa9628aeaf9d69fc53f49131a4330253cf (patch)
treecaecf2ba1287434d3d94be165c12fb24a56a404a /protocols/jabber/presence.c
parente617b35a6771362164aff194cb6e0b757552c0bd (diff)
Proper cleanup of jabber buddy structures when removing a buddy from the
list, proper checking (and handling) of events related to buddies that aren't "hashed" yet, limit checks on priorityto setting, renamed JEP85 to XEP85, support for more XEP85 states.
Diffstat (limited to 'protocols/jabber/presence.c')
-rw-r--r--protocols/jabber/presence.c28
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;