changeset 7445:6ea4a49b4b51

[gaim-migrate @ 8052] this should fix the case sensitivity issues for jabber. what made me think that g_utf8_normalize() did anything with the strings of cases is beyond me. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Thu, 06 Nov 2003 07:07:22 +0000
parents 66945d35a7c0
children 064c697cc223
files src/protocols/jabber/buddy.c src/protocols/jabber/iq.c src/protocols/jabber/jutil.c src/protocols/jabber/roster.c
diffstat 4 files changed, 23 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/jabber/buddy.c	Thu Nov 06 05:44:28 2003 +0000
+++ b/src/protocols/jabber/buddy.c	Thu Nov 06 07:07:22 2003 +0000
@@ -51,26 +51,17 @@
 		gboolean create)
 {
 	JabberBuddy *jb;
-	JabberID *jid = jabber_id_new(name);
-	char *realname;
+	const char *realname;
 
-	if(!jid)
+	if(!(realname = jabber_normalize(js->gc->account, name)))
 		return NULL;
 
-	if(jid->node)
-		realname = g_strdup_printf("%s@%s", jid->node, jid->domain);
-	else
-		realname = g_strdup(jid->domain);
-
 	jb = g_hash_table_lookup(js->buddies, realname);
 
 	if(!jb && create) {
 		jb = g_new0(JabberBuddy, 1);
 		g_hash_table_insert(js->buddies, g_strdup(realname), jb);
 	}
-	g_free(realname);
-
-	jabber_id_free(jid);
 
 	return jb;
 }
--- a/src/protocols/jabber/iq.c	Thu Nov 06 05:44:28 2003 +0000
+++ b/src/protocols/jabber/iq.c	Thu Nov 06 07:07:22 2003 +0000
@@ -279,11 +279,10 @@
 
 		if(jid->resource && (jb = jabber_buddy_find(js, from, TRUE)))
 			jbr = jabber_buddy_find_resource(jb, jid->resource);
+		jabber_id_free(jid);
 
-		if(!jbr) {
-			jabber_id_free(jid);
+		if(!jbr)
 			return;
-		}
 
 		for(child = query->child; child; child = child->next) {
 			if(child->type != NODE_TYPE_TAG)
@@ -303,7 +302,6 @@
 					jbr->capabilities |= JABBER_CAP_BYTESTREAMS;
 			}
 		}
-		jabber_id_free(jid);
 	}
 }
 
--- a/src/protocols/jabber/jutil.c	Thu Nov 06 05:44:28 2003 +0000
+++ b/src/protocols/jabber/jutil.c	Thu Nov 06 07:07:22 2003 +0000
@@ -274,21 +274,28 @@
 	JabberStream *js = gc ? gc->proto_data : NULL;
 	static char buf[3072]; /* maximum legal length of a jabber jid */
 	JabberID *jid;
+	char *node, *domain;
 
 	jid = jabber_id_new(in);
 
 	if(!jid)
 		return NULL;
 
-	if(js && jid->node && jid->resource &&
-			jabber_chat_find(js, jid->node, jid->domain))
-		g_snprintf(buf, sizeof(buf), "%s@%s/%s", jid->node, jid->domain,
+	node = jid->node ? g_utf8_strdown(jid->node, -1) : NULL;
+	domain = g_utf8_strdown(jid->domain, -1);
+
+
+	if(js && node && jid->resource &&
+			jabber_chat_find(js, node, domain))
+		g_snprintf(buf, sizeof(buf), "%s@%s/%s", node, domain,
 				jid->resource);
 	else
-		g_snprintf(buf, sizeof(buf), "%s%s%s", jid->node ? jid->node : "",
-				jid->node ? "@" : "", jid->domain);
+		g_snprintf(buf, sizeof(buf), "%s%s%s", node ? node : "",
+				node ? "@" : "", domain);
 
 	jabber_id_free(jid);
+	g_free(node);
+	g_free(domain);
 
 	return buf;
 }
--- a/src/protocols/jabber/roster.c	Thu Nov 06 05:44:28 2003 +0000
+++ b/src/protocols/jabber/roster.c	Thu Nov 06 07:07:22 2003 +0000
@@ -119,29 +119,19 @@
 	const char *from = xmlnode_get_attrib(packet, "from");
 
 	if(from) {
-		char *me, *from_norm;
-		JabberID *from_jid = jabber_id_new(from);
+		char *from_norm;
 		gboolean invalid;
 
-		if(!from_jid)
+		from_norm = g_strdup(jabber_normalize(js->gc->account, from));
+
+		if(!from_norm)
 			return;
 
-		from_norm = g_strdup_printf("%s@%s%s%s",
-				from_jid->node ? from_jid->node : "",
-				from_jid->domain,
-				from_jid->resource ? "/" : "",
-				from_jid->resource ? from_jid->resource : "");
+		invalid = g_utf8_collate(from_norm,
+				jabber_normalize(js->gc->account,
+					gaim_account_get_username(js->gc->account)));
 
-		if(from_jid->resource)
-			me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain,
-					js->user->resource);
-		else
-			me = g_strdup_printf("%s@%s", js->user->node, js->user->domain);
-
-		invalid = g_utf8_collate(from_norm, me);
 		g_free(from_norm);
-		g_free(me);
-		jabber_id_free(from_jid);
 
 		if(invalid)
 			return;