changeset 26788:fbb2b8e2d91e

Use purple_strequal and g_str_equal
author Paul Aurich <paul@darkrain42.org>
date Sun, 26 Apr 2009 23:24:45 +0000
parents fef989505ea2
children 8953034dae88
files libpurple/protocols/jabber/buddy.c libpurple/protocols/jabber/useravatar.c
diffstat 2 files changed, 15 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c	Sun Apr 26 23:06:56 2009 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Sun Apr 26 23:24:45 2009 +0000
@@ -1104,8 +1104,7 @@
 	}
 
 	/* Republish our vcard if the photo is different than the server's */
-	if ((!vcard_hash && js->initial_avatar_hash) ||
-		 (vcard_hash && (!js->initial_avatar_hash || strcmp(vcard_hash, js->initial_avatar_hash)))) {
+	if (!purple_strequal(vcard_hash, js->initial_avatar_hash)) {
 		PurpleAccount *account = purple_connection_get_account(js->gc);
 		jabber_set_info(js->gc, purple_account_get_user_info(account));
 	} else if (js->initial_avatar_hash) {
--- a/libpurple/protocols/jabber/useravatar.c	Sun Apr 26 23:06:56 2009 +0000
+++ b/libpurple/protocols/jabber/useravatar.c	Sun Apr 26 23:24:45 2009 +0000
@@ -57,7 +57,7 @@
 		return;
 
 	if (!img) {
-		if (ns == NULL || !strcmp(ns, NS_AVATAR_0_12_METADATA)) {
+		if (ns == NULL || g_str_equal(ns, NS_AVATAR_0_12_METADATA)) {
 			/* remove the metadata */
 			publish = xmlnode_new("publish");
 			xmlnode_set_attrib(publish, "node", NS_AVATAR_0_12_METADATA);
@@ -71,7 +71,7 @@
 			jabber_pep_publish(js, publish);
 		}
 
-		if (ns == NULL || !strcmp(ns, NS_AVATAR_1_1_METADATA)) {
+		if (ns == NULL || g_str_equal(ns, NS_AVATAR_1_1_METADATA)) {
 			/* Now for the XEP-0084 v1.1 namespace, where we publish an empty
 			 * metadata node instead of a <stop/> element */
 			publish = xmlnode_new("publish");
@@ -106,7 +106,7 @@
 			} ihdr;
 		} *png = purple_imgstore_get_data(img); /* ATTN: this is in network byte order! */
 
-		/* check if the data is a valid png file (well, at least to some extend) */
+		/* check if the data is a valid png file (well, at least to some extent) */
 		if(png->signature[0] == 0x89 &&
 		   png->signature[1] == 0x50 &&
 		   png->signature[2] == 0x4e &&
@@ -132,7 +132,7 @@
 			char *base64avatar = purple_base64_encode(purple_imgstore_get_data(img),
 			                                          purple_imgstore_get_size(img));
 
-			if (ns == NULL || !strcmp(ns, NS_AVATAR_0_12_METADATA)) {
+			if (ns == NULL || g_str_equal(ns, NS_AVATAR_0_12_METADATA)) {
 				publish = xmlnode_new("publish");
 				xmlnode_set_attrib(publish, "node", NS_AVATAR_0_12_DATA);
 
@@ -147,7 +147,7 @@
 				jabber_pep_publish(js, publish);
 			}
 
-			if (ns == NULL || !strcmp(ns, NS_AVATAR_1_1_METADATA)) {
+			if (ns == NULL || g_str_equal(ns, NS_AVATAR_1_1_METADATA)) {
 				publish = xmlnode_new("publish");
 				xmlnode_set_attrib(publish, "node", NS_AVATAR_1_1_DATA);
 
@@ -169,8 +169,8 @@
 			widthstring = g_strdup_printf("%u", width);
 			heightstring = g_strdup_printf("%u", height);
 
-			/* next step: publish the metadata to the old namespace */
-			if (ns == NULL || !strcmp(ns, NS_AVATAR_0_12_METADATA)) {
+			if (ns == NULL || g_str_equal(ns, NS_AVATAR_0_12_METADATA)) {
+				/* next step: publish the metadata to the old namespace */
 				publish = xmlnode_new("publish");
 				xmlnode_set_attrib(publish, "node", NS_AVATAR_0_12_METADATA);
 
@@ -190,7 +190,7 @@
 				jabber_pep_publish(js, publish);
 			}
 
-			if (ns == NULL || !strcmp(ns, NS_AVATAR_1_1_METADATA)) {
+			if (ns == NULL || g_str_equal(ns, NS_AVATAR_1_1_METADATA)) {
 				/* publish the metadata to the new namespace */
 				publish = xmlnode_new("publish");
 				xmlnode_set_attrib(publish, "node", NS_AVATAR_1_1_METADATA);
@@ -243,8 +243,7 @@
 		return;
 
 	/* Publish ours if it's different than the server's */
-	if ((!server_hash && js->initial_avatar_hash) ||
-		 (server_hash && (!js->initial_avatar_hash || strcmp(server_hash, js->initial_avatar_hash)))) {
+	if (!purple_strequal(server_hash, js->initial_avatar_hash)) {
 		PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account);
 		jabber_avatar_set(js, img, ns);
 		purple_imgstore_unref(img);
@@ -309,8 +308,8 @@
 
 	ns = xmlnode_get_namespace(data);
 	/* Make sure the namespace is one of the two valid possibilities */
-	if (!ns || (strcmp(ns, NS_AVATAR_0_12_DATA) &&
-	            strcmp(ns, NS_AVATAR_1_1_DATA)))
+	if (!ns || (!g_str_equal(ns, NS_AVATAR_0_12_DATA) &&
+	            !g_str_equal(ns, NS_AVATAR_1_1_DATA)))
 		return;
 
 	checksum = xmlnode_get_attrib(item,"id");
@@ -353,8 +352,8 @@
 
 	ns = xmlnode_get_namespace(metadata);
 	/* Make sure the namespace is one of the two valid possibilities */
-	if (!ns || (strcmp(ns, NS_AVATAR_0_12_METADATA) &&
-	            strcmp(ns, NS_AVATAR_1_1_METADATA)))
+	if (!ns || (!g_str_equal(ns, NS_AVATAR_0_12_METADATA) &&
+	            !g_str_equal(ns, NS_AVATAR_1_1_METADATA)))
 		return;
 
 	checksum = purple_buddy_icons_get_checksum_for_user(buddy);
@@ -393,7 +392,7 @@
 			/* the avatar might either be stored in a pep node, or on a HTTP(S) URL */
 			if(!url) {
 				const char *data_ns;
-				data_ns = (strcmp(ns, NS_AVATAR_0_12_METADATA) == 0 ?
+				data_ns = (g_str_equal(ns, NS_AVATAR_0_12_METADATA) ?
 				               NS_AVATAR_0_12_DATA : NS_AVATAR_1_1_DATA);
 				jabber_pep_request_item(js, from, data_ns, id,
 				                        do_buddy_avatar_update_data);