changeset 19677:e68694150fd8

Add the ability to affiliate people in an xmpp chat room even if they're not in the room. Just use their real bare jid instead of their room nickname.
author Mark Doliner <mark@kingant.net>
date Fri, 07 Sep 2007 04:11:47 +0000
parents a48681403103
children 490b258e34c0
files libpurple/protocols/jabber/chat.c
diffstat 1 files changed, 18 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/chat.c	Fri Sep 07 01:52:47 2007 +0000
+++ b/libpurple/protocols/jabber/chat.c	Fri Sep 07 04:11:47 2007 +0000
@@ -833,12 +833,18 @@
 
 gboolean jabber_chat_ban_user(JabberChat *chat, const char *who, const char *why)
 {
+	JabberChatMember *jcm;
+	const char *jid;
+	char *to;
 	JabberIq *iq;
-	JabberChatMember *jcm = g_hash_table_lookup(chat->members, who);
-	char *to;
 	xmlnode *query, *item, *reason;
 
-	if(!jcm || !jcm->jid)
+	jcm = g_hash_table_lookup(chat->members, who);
+	if (jcm && jcm->jid)
+		jid = jcm->jid;
+	else if (g_utf8_strchr(who, -1, '@') != NULL)
+		jid = who;
+	else
 		return FALSE;
 
 	iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET,
@@ -850,7 +856,7 @@
 
 	query = xmlnode_get_child(iq->node, "query");
 	item = xmlnode_new_child(query, "item");
-	xmlnode_set_attrib(item, "jid", jcm->jid);
+	xmlnode_set_attrib(item, "jid", jid);
 	xmlnode_set_attrib(item, "affiliation", "outcast");
 	if(why) {
 		reason = xmlnode_new_child(item, "reason");
@@ -864,14 +870,18 @@
 
 gboolean jabber_chat_affiliate_user(JabberChat *chat, const char *who, const char *affiliation)
 {
+	JabberChatMember *jcm;
+	const char *jid;
 	char *to;
 	JabberIq *iq;
 	xmlnode *query, *item;
-	JabberChatMember *jcm;
 
 	jcm = g_hash_table_lookup(chat->members, who);
-
-	if (!jcm || !jcm->jid)
+	if (jcm && jcm->jid)
+		jid = jcm->jid;
+	else if (g_utf8_strchr(who, -1, '@') != NULL)
+		jid = who;
+	else
 		return FALSE;
 
 	iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET,
@@ -883,7 +893,7 @@
 
 	query = xmlnode_get_child(iq->node, "query");
 	item = xmlnode_new_child(query, "item");
-	xmlnode_set_attrib(item, "jid", jcm->jid);
+	xmlnode_set_attrib(item, "jid", jid);
 	xmlnode_set_attrib(item, "affiliation", affiliation);
 
 	jabber_iq_send(iq);