cpw.darkrain42.xmpp.bosh: c2becef0: Rename a few functions and clean up the ...

paul at darkrain42.org paul at darkrain42.org
Sat Jan 17 23:56:45 EST 2009


-----------------------------------------------------------------
Revision: c2becef0773a1d9961b7106623b08b021add46b7
Ancestor: 6edff60c4aff126c95b9a8064e8e8fdfdc2cbb1a
Author: paul at darkrain42.org
Date: 2008-12-14T21:19:02
Branch: im.pidgin.cpw.darkrain42.xmpp.bosh
URL: http://d.pidgin.im/viewmtn/revision/info/c2becef0773a1d9961b7106623b08b021add46b7

Modified files:
        libpurple/protocols/jabber/caps.c

ChangeLog: 

Rename a few functions and clean up the exit cleanup of a function

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/caps.c	b625ac2930380d940031b489b3f7ea58c304d55c
+++ libpurple/protocols/jabber/caps.c	2ef41ffc69157622becc1d72d69bebc599df4bb4
@@ -574,7 +574,9 @@ void jabber_caps_get_info(JabberStream *
 #endif
 }
 
-static gint jabber_caps_jabber_identity_compare(gconstpointer a, gconstpointer b) {
+static gint
+jabber_identity_compare(gconstpointer a, gconstpointer b)
+{
 	const JabberIdentity *ac;
 	const JabberIdentity *bc;
 	gint cat_cmp;
@@ -622,7 +624,9 @@ static gchar *jabber_caps_get_formtype(c
 	return xmlnode_get_data(formtypefield);;
 }
 
-static gint jabber_caps_jabber_xdata_compare(gconstpointer a, gconstpointer b) {
+static gint
+jabber_xdata_compare(gconstpointer a, gconstpointer b)
+{
 	const xmlnode *aformtypefield = a;
 	const xmlnode *bformtypefield = b;
 	char *aformtype;
@@ -732,14 +736,15 @@ gchar *jabber_caps_calculate_hash(Jabber
 	PurpleCipherContext *context;
 	guint8 checksum[20];
 	gsize checksum_size = 20;
+	gboolean success;
 
 	if (!info || !(context = purple_cipher_context_new_by_name(hash, NULL)))
 		return NULL;
 
 	/* sort identities, features and x-data forms */
-	info->identities = g_list_sort(info->identities, jabber_caps_jabber_identity_compare);
+	info->identities = g_list_sort(info->identities, jabber_identity_compare);
 	info->features = g_list_sort(info->features, (GCompareFunc)strcmp);
-	info->forms = g_list_sort(info->forms, jabber_caps_jabber_xdata_compare);
+	info->forms = g_list_sort(info->forms, jabber_xdata_compare);
 
 	verification = g_string_new("");
 
@@ -773,7 +778,7 @@ gchar *jabber_caps_calculate_hash(Jabber
 			if (strcmp(field->var, "FORM_TYPE")) {
 				/* Append the "var" attribute */
 				verification = jabber_caps_verification_append(verification, field->var);
-				/* Append <value/> element's cdata */
+				/* Append <value/> elements' cdata */
 				for(value = field->values; value; value = value->next) {
 					verification = jabber_caps_verification_append(verification, value->data);
 					g_free(value->data);
@@ -790,17 +795,13 @@ gchar *jabber_caps_calculate_hash(Jabber
 	/* generate hash */
 	purple_cipher_context_append(context, (guchar*)verification->str, verification->len);
 
-	if (!purple_cipher_context_digest(context, verification->len, checksum, &checksum_size)) {
-		/* purple_debug_error("util", "Failed to get digest.\n"); */
-		g_string_free(verification, TRUE);
-		purple_cipher_context_destroy(context);
-		return NULL;
-	}
+	success = purple_cipher_context_digest(context, verification->len,
+	                                       checksum, &checksum_size);
 
 	g_string_free(verification, TRUE);
 	purple_cipher_context_destroy(context);
 
-	return purple_base64_encode(checksum, checksum_size);
+	return (success ? purple_base64_encode(checksum, checksum_size) : NULL);
 }
 
 void jabber_caps_calculate_own_hash(JabberStream *js) {


More information about the Commits mailing list