diff options
| author | dequis <dx@dxzone.com.ar> | 2016-01-24 10:22:08 -0300 | 
|---|---|---|
| committer | dequis <dx@dxzone.com.ar> | 2016-03-20 00:58:05 -0300 | 
| commit | 8f8a56f6216214dd8a945dbc0106f21421832e4b (patch) | |
| tree | a9f5147852b90b5fb9886bbf2b20bbbeb0db7714 /protocols/jabber | |
| parent | a42fda42abad6af64ac9a905856ee9a3095954cd (diff) | |
jabber: Check for other resources before removing someone from a chat
So if someone has several connections with several clients to a chat,
they won't appear as leaving from the chat until they leave from the
last client.
Diffstat (limited to 'protocols/jabber')
| -rw-r--r-- | protocols/jabber/conference.c | 15 | 
1 files changed, 14 insertions, 1 deletions
| diff --git a/protocols/jabber/conference.c b/protocols/jabber/conference.c index db117faf..cc832659 100644 --- a/protocols/jabber/conference.c +++ b/protocols/jabber/conference.c @@ -243,6 +243,19 @@ void jabber_chat_invite(struct groupchat *c, char *who, char *message)  	xt_free_node(node);  } +static int jabber_chat_has_other_resources(struct im_connection *ic, struct jabber_buddy *bud) +{ +	struct jabber_buddy *cur; + +	for (cur = jabber_buddy_by_jid(ic, bud->bare_jid, GET_BUDDY_FIRST); cur; cur = cur->next) { +		if (cur != bud && jabber_compare_jid(cur->ext_jid, bud->ext_jid)) { +			return TRUE; +		} +	} +	 +	return FALSE; +} +  /* Not really the same syntax as the normal pkt_ functions, but this isn't     called by the xmltree parser directly and this way I can add some extra     parameters so we won't have to repeat too many things done by the caller @@ -332,7 +345,7 @@ void jabber_chat_pkt_presence(struct im_connection *ic, struct jabber_buddy *bud  			*s = '/';  		}  	} else if (type) { /* type can only be NULL or "unavailable" in this function */ -		if ((bud->flags & JBFLAG_IS_CHATROOM) && bud->ext_jid) { +		if ((bud->flags & JBFLAG_IS_CHATROOM) && bud->ext_jid && !jabber_chat_has_other_resources(ic, bud)) {  			char *reason = NULL;  			char *status = NULL;  			char *status_text = NULL; | 
