gobjectification: c5ca0fbf: Jabber compiles now... except for that o...

qulogic at pidgin.im qulogic at pidgin.im
Wed Jun 9 01:31:10 EDT 2010


-----------------------------------------------------------------
Revision: c5ca0fbfb51d1b3c0335d2eb9df960495ec17ca9
Ancestor: dad5ab65aa0503b70f999c7c851afc7106612f47
Author: qulogic at pidgin.im
Date: 2010-06-09T04:11:44
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/c5ca0fbfb51d1b3c0335d2eb9df960495ec17ca9

Modified files:
        libpurple/protocols/jabber/auth_digest_md5.c
        libpurple/protocols/jabber/auth_plain.c
        libpurple/protocols/jabber/auth_scram.c
        libpurple/protocols/jabber/auth_scram.h
        libpurple/protocols/jabber/buddy.c
        libpurple/protocols/jabber/caps.c
        libpurple/protocols/jabber/disco.c
        libpurple/protocols/jabber/google.c
        libpurple/protocols/jabber/jabber.c
        libpurple/protocols/jabber/jutil.c
        libpurple/protocols/jabber/parser.c
        libpurple/protocols/jabber/presence.c
        libpurple/protocols/jabber/roster.c
        libpurple/protocols/jabber/usermood.c

ChangeLog: 

Jabber compiles now... except for that one FIXME.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/auth_digest_md5.c	857c4e8e03d05e94a105e5763b7cd8eb5c758cc6
+++ libpurple/protocols/jabber/auth_digest_md5.c	fe000e924a53bc4e70efeb286fef092877c9be4a
@@ -23,7 +23,7 @@
 #include "internal.h"
 
 #include "debug.h"
-#include "cipher.h"
+#include "md5cipher.h"
 #include "util.h"
 #include "xmlnode.h"
 
@@ -106,7 +106,6 @@ generate_response_value(JabberID *jid, c
 		const char *cnonce, const char *a2, const char *realm)
 {
 	PurpleCipher *cipher;
-	PurpleCipherContext *context;
 	guchar result[16];
 	size_t a1len;
 
@@ -121,35 +120,34 @@ generate_response_value(JabberID *jid, c
 		convpasswd = g_strdup(passwd);
 	}
 
-	cipher = purple_ciphers_find_cipher("md5");
-	context = purple_cipher_context_new(cipher, NULL);
+	cipher = purple_md5_cipher_new();
 
 	x = g_strdup_printf("%s:%s:%s", convnode, realm, convpasswd ? convpasswd : "");
-	purple_cipher_context_append(context, (const guchar *)x, strlen(x));
-	purple_cipher_context_digest(context, sizeof(result), result, NULL);
+	purple_cipher_append(cipher, (const guchar *)x, strlen(x));
+	purple_cipher_digest(cipher, sizeof(result), result, NULL);
 
 	a1 = g_strdup_printf("xxxxxxxxxxxxxxxx:%s:%s", nonce, cnonce);
 	a1len = strlen(a1);
 	g_memmove(a1, result, 16);
 
-	purple_cipher_context_reset(context, NULL);
-	purple_cipher_context_append(context, (const guchar *)a1, a1len);
-	purple_cipher_context_digest(context, sizeof(result), result, NULL);
+	purple_cipher_reset(cipher);
+	purple_cipher_append(cipher, (const guchar *)a1, a1len);
+	purple_cipher_digest(cipher, sizeof(result), result, NULL);
 
 	ha1 = purple_base16_encode(result, 16);
 
-	purple_cipher_context_reset(context, NULL);
-	purple_cipher_context_append(context, (const guchar *)a2, strlen(a2));
-	purple_cipher_context_digest(context, sizeof(result), result, NULL);
+	purple_cipher_reset(cipher);
+	purple_cipher_append(cipher, (const guchar *)a2, strlen(a2));
+	purple_cipher_digest(cipher, sizeof(result), result, NULL);
 
 	ha2 = purple_base16_encode(result, 16);
 
 	kd = g_strdup_printf("%s:%s:00000001:%s:auth:%s", ha1, nonce, cnonce, ha2);
 
-	purple_cipher_context_reset(context, NULL);
-	purple_cipher_context_append(context, (const guchar *)kd, strlen(kd));
-	purple_cipher_context_digest(context, sizeof(result), result, NULL);
-	purple_cipher_context_destroy(context);
+	purple_cipher_reset(cipher);
+	purple_cipher_append(cipher, (const guchar *)kd, strlen(kd));
+	purple_cipher_digest(cipher, sizeof(result), result, NULL);
+	g_object_unref(G_OBJECT(cipher));
 
 	z = purple_base16_encode(result, 16);
 
============================================================
--- libpurple/protocols/jabber/auth_plain.c	0cea8f0272a4cdf948cde0ecc7fc631b3a9754c9
+++ libpurple/protocols/jabber/auth_plain.c	643acb35e1f042c08f810c3c1796c806f8e243f2
@@ -66,7 +66,7 @@ static void allow_plaintext_auth(PurpleA
 static void allow_plaintext_auth(PurpleAccount *account)
 {
 	PurpleConnection *gc = purple_account_get_connection(account);
-	JabberStream *js = purple_connection_get_protocol_data(gc);
+	JabberStream *js = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	xmlnode *response;
 
 	purple_account_set_bool(account, "auth_plain_in_clear", TRUE);
============================================================
--- libpurple/protocols/jabber/auth_scram.c	64a287b607ece18bc980d07601280ccfcedc0ddb
+++ libpurple/protocols/jabber/auth_scram.c	2ff7bdb9a0f8d05915b8aa4990ff3ebd89aa26bb
@@ -26,10 +26,12 @@
 #include "auth_scram.h"
 
 #include "cipher.h"
+#include "hmaccipher.h"
+#include "sha1cipher.h"
 #include "debug.h"
 
 static const JabberScramHash hashes[] = {
-	{ "-SHA-1", "sha1", 20 },
+	{ "-SHA-1", purple_sha1_cipher_new, 20 },
 };
 
 static const JabberScramHash *mech_to_hash(const char *mech)
@@ -76,7 +78,8 @@ guchar *jabber_scram_hi(const JabberScra
 guchar *jabber_scram_hi(const JabberScramHash *hash, const GString *str,
                         GString *salt, guint iterations)
 {
-	PurpleCipherContext *context;
+	PurpleCipher *hash_cipher;
+	PurpleCipher *cipher;
 	guchar *result;
 	guint i;
 	guchar *prev, *tmp;
@@ -90,27 +93,28 @@ guchar *jabber_scram_hi(const JabberScra
 	tmp    = g_new0(guint8, hash->size);
 	result = g_new0(guint8, hash->size);
 
-	context = purple_cipher_context_new_by_name("hmac", NULL);
+	hash_cipher = hash->new();
+	cipher = purple_hmac_cipher_new(hash_cipher);
+	g_object_unref(G_OBJECT(hash_cipher));
 
 	/* Append INT(1), a four-octet encoding of the integer 1, most significant
 	 * octet first. */
 	g_string_append_len(salt, "\0\0\0\1", 4);
 
 	/* Compute U0 */
-	purple_cipher_context_set_option(context, "hash", (gpointer)hash->name);
-	purple_cipher_context_set_key_with_len(context, (guchar *)str->str, str->len);
-	purple_cipher_context_append(context, (guchar *)salt->str, salt->len);
-	purple_cipher_context_digest(context, hash->size, result, NULL);
+	purple_cipher_set_key_with_len(cipher, (guchar *)str->str, str->len);
+	purple_cipher_append(cipher, (guchar *)salt->str, salt->len);
+	purple_cipher_digest(cipher, hash->size, result, NULL);
 
 	memcpy(prev, result, hash->size);
 
 	/* Compute U1...Ui */
 	for (i = 1; i < iterations; ++i) {
 		guint j;
-		purple_cipher_context_set_option(context, "hash", (gpointer)hash->name);
-		purple_cipher_context_set_key_with_len(context, (guchar *)str->str, str->len);
-		purple_cipher_context_append(context, prev, hash->size);
-		purple_cipher_context_digest(context, hash->size, tmp, NULL);
+		purple_cipher_reset(cipher);
+		purple_cipher_set_key_with_len(cipher, (guchar *)str->str, str->len);
+		purple_cipher_append(cipher, prev, hash->size);
+		purple_cipher_digest(cipher, hash->size, tmp, NULL);
 
 		for (j = 0; j < hash->size; ++j)
 			result[j] ^= tmp[j];
@@ -118,7 +122,7 @@ guchar *jabber_scram_hi(const JabberScra
 		memcpy(prev, tmp, hash->size);
 	}
 
-	purple_cipher_context_destroy(context);
+	g_object_unref(G_OBJECT(cipher));
 	g_free(tmp);
 	g_free(prev);
 	return result;
@@ -136,25 +140,27 @@ hmac(const JabberScramHash *hash, guchar
 static void
 hmac(const JabberScramHash *hash, guchar *out, const guchar *key, const gchar *str)
 {
-	PurpleCipherContext *context;
+	PurpleCipher *hash_cipher;
+	PurpleCipher *cipher;
 
-	context = purple_cipher_context_new_by_name("hmac", NULL);
-	purple_cipher_context_set_option(context, "hash", (gpointer)hash->name);
-	purple_cipher_context_set_key_with_len(context, key, hash->size);
-	purple_cipher_context_append(context, (guchar *)str, strlen(str));
-	purple_cipher_context_digest(context, hash->size, out, NULL);
-	purple_cipher_context_destroy(context);
+	hash_cipher = hash->new();
+	cipher = purple_hmac_cipher_new(hash_cipher);
+	g_object_unref(G_OBJECT(hash_cipher));
+	purple_cipher_set_key_with_len(cipher, key, hash->size);
+	purple_cipher_append(cipher, (guchar *)str, strlen(str));
+	purple_cipher_digest(cipher, hash->size, out, NULL);
+	g_object_unref(G_OBJECT(cipher));
 }
 
 static void
 hash(const JabberScramHash *hash, guchar *out, const guchar *data)
 {
-	PurpleCipherContext *context;
+	PurpleCipher *cipher;
 
-	context = purple_cipher_context_new_by_name(hash->name, NULL);
-	purple_cipher_context_append(context, data, hash->size);
-	purple_cipher_context_digest(context, hash->size, out, NULL);
-	purple_cipher_context_destroy(context);
+	cipher = hash->new();
+	purple_cipher_append(cipher, data, hash->size);
+	purple_cipher_digest(cipher, hash->size, out, NULL);
+	g_object_unref(G_OBJECT(cipher));
 }
 
 gboolean
============================================================
--- libpurple/protocols/jabber/auth_scram.h	8f7564b2c0ccae49e4c2ff83fac061d0ae4808cd
+++ libpurple/protocols/jabber/auth_scram.h	f6114a3176b579d349751715ce61fb5ceb548bc3
@@ -34,7 +34,7 @@ typedef struct {
  */
 typedef struct {
 	const char *mech_substr;
-	const char *name;
+	PurpleCipher *(*new)(void);
 	guint size;
 } JabberScramHash;
 
============================================================
--- libpurple/protocols/jabber/buddy.c	e10f6249f684bae7b94a22d481ca6707e4241a0b
+++ libpurple/protocols/jabber/buddy.c	99a7d0e679a9b2feb166fa9a47d9fd7a744d22a4
@@ -1722,7 +1722,7 @@ jabber_buddy_cancel_presence_notificatio
 	const gchar *name;
 	char *msg;
 
-	g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
+	g_return_if_fail(PURPLE_IS_BUDDY(node));
 
 	buddy = (PurpleBuddy *) node;
 	name = purple_buddy_get_name(buddy);
============================================================
--- libpurple/protocols/jabber/caps.c	3817af8dafc8dc0b3a1ddec49e0f5b2eded5159c
+++ libpurple/protocols/jabber/caps.c	c632c231b85c0afbe75ca86a1997c40566b5a0d8
@@ -899,7 +899,7 @@ gchar *jabber_caps_calculate_hash(Jabber
 
 	/* concat features to the verification string */
 	for (node = info->features; node; node = node->next) {
-		append_escaped_string(context, node->data);
+		append_escaped_string(hasher, node->data);
 	}
 
 	/* concat x-data forms to the verification string */
@@ -909,7 +909,7 @@ gchar *jabber_caps_calculate_hash(Jabber
 		GList *fields = jabber_caps_xdata_get_fields(data);
 
 		/* append FORM_TYPE's field value to the verification string */
-		append_escaped_string(context, formtype);
+		append_escaped_string(hasher, formtype);
 		g_free(formtype);
 
 		while (fields) {
@@ -918,10 +918,10 @@ gchar *jabber_caps_calculate_hash(Jabber
 
 			if (!g_str_equal(field->var, "FORM_TYPE")) {
 				/* Append the "var" attribute */
-				append_escaped_string(context, field->var);
+				append_escaped_string(hasher, field->var);
 				/* Append <value/> elements' cdata */
 				for (value = field->values; value; value = value->next) {
-					append_escaped_string(context, value->data);
+					append_escaped_string(hasher, value->data);
 					g_free(value->data);
 				}
 			}
============================================================
--- libpurple/protocols/jabber/disco.c	23af1630fbbd37e2ff0a4d95f55a2b03a3daff77
+++ libpurple/protocols/jabber/disco.c	5ecd3ab9d1ad485e1fca9e1a2337a820ad506a8f
@@ -520,8 +520,9 @@ jabber_disco_server_info_result_cb(Jabbe
 		if(category && type && !strcmp(category, "pubsub") && !strcmp(type,"pep")) {
 			PurpleConnection *gc = js->gc;
 			js->pep = TRUE;
-			gc->flags |= PURPLE_CONNECTION_SUPPORT_MOODS |
-				PURPLE_CONNECTION_SUPPORT_MOOD_MESSAGES;
+			purple_connection_turn_on_flags(gc,
+				PURPLE_CONNECTION_FLAGS_SUPPORT_MOODS |
+				PURPLE_CONNECTION_FLAGS_SUPPORT_MOOD_MESSAGES);
 		}
 		if (!category || strcmp(category, "server"))
 			continue;
============================================================
--- libpurple/protocols/jabber/google.c	63cc93b4b1f181d87c593c1b60e14d67da17b034
+++ libpurple/protocols/jabber/google.c	06425a57127512ae17b28aedc9da8a66764023f7
@@ -1409,12 +1409,12 @@ void google_buddy_node_chat(PurpleBlistN
 	gchar *room;
 	gchar *uuid = purple_uuid_random();
 
-	g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
+	g_return_if_fail(PURPLE_IS_BUDDY(node));
 
 	buddy = PURPLE_BUDDY(node);
 	gc = purple_account_get_connection(purple_buddy_get_account(buddy));
 	g_return_if_fail(gc != NULL);
-	js = purple_connection_get_protocol_data(gc);
+	js = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 
 	room = g_strdup_printf("private-chat-%s", uuid);	
 	chat = jabber_join_chat(js, room, GOOGLE_GROUPCHAT_SERVER, js->user->node,
============================================================
--- libpurple/protocols/jabber/jabber.c	ce162dcd91d1b2f139d14049c8e82612165b7206
+++ libpurple/protocols/jabber/jabber.c	8e5c0668613151fe92d2e7a867811f91d6341a41
@@ -412,7 +412,7 @@ static gboolean do_jabber_send_raw(Jabbe
 		 * we're disconnecting, don't generate (possibly another) error that
 		 * (for some UIs) would mask the first.
 		 */
-		if (!account->disconnecting) {
+		if (!purple_account_is_disconnecting(account)) {
 			gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"),
 					g_strerror(errno));
 			purple_connection_error_reason(js->gc,
@@ -2296,8 +2296,8 @@ GList *jabber_status_types(PurpleAccount
 	
 	type = purple_status_type_new_with_attrs(PURPLE_STATUS_MOOD,
 	    "mood", NULL, TRUE, TRUE, TRUE,
-			PURPLE_MOOD_NAME, _("Mood Name"), purple_value_new(PURPLE_TYPE_STRING),
-			PURPLE_MOOD_COMMENT, _("Mood Comment"), purple_value_new(PURPLE_TYPE_STRING),
+			PURPLE_MOOD_NAME, _("Mood Name"), purple_g_value_slice_new(G_TYPE_STRING),
+			PURPLE_MOOD_COMMENT, _("Mood Comment"), purple_g_value_slice_new(G_TYPE_STRING),
 			NULL);
 	types = g_list_prepend(types, type);
 
@@ -3458,7 +3458,8 @@ jabber_cmd_mood(PurpleConversation *conv
 jabber_cmd_mood(PurpleConversation *conv,
 		const char *cmd, char **args, char **error, void *data)
 {
-	JabberStream *js = conv->account->gc->proto_data;
+	PurpleConnection *pc = purple_account_get_connection(conv->account);
+	JabberStream *js = purple_object_get_protocol_data(PURPLE_OBJECT(pc));
 
 	if (js->pep) {
 		/* if no argument was given, unset mood */
@@ -3593,7 +3594,7 @@ static void jabber_register_commands(Pur
 					  PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS,
 					  "prpl-jabber", jabber_cmd_buzz,
 					  _("buzz: Buzz a user to get their attention"), NULL);
-	jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
+	commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
 
 	id = purple_cmd_register("mood", "ws", PURPLE_CMD_P_PRPL,
 	    			  PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM |
============================================================
--- libpurple/protocols/jabber/jutil.c	670cf4d386799627ccb6b41269718285ca78f9af
+++ libpurple/protocols/jabber/jutil.c	57a92bf51d698dc9ad9cb52e23ea9b8efb189e10
@@ -25,7 +25,7 @@
 #include "conversation.h"
 #include "debug.h"
 #include "server.h"
-#include "md4cipher.h"
+#include "md4hash.h"
 #include "md5cipher.h"
 #include "sha1cipher.h"
 #include "util.h"
@@ -741,7 +741,7 @@ jabber_calculate_data_hash(gconstpointer
 	if (g_str_equal(hash_algo, "sha1"))
 		cipher = purple_sha1_cipher_new();
 	else if (g_str_equal(hash_algo, "md4"))
-		cipher = purple_md4_cipher_new();
+		cipher = purple_md4_hash_new();
 	else if (g_str_equal(hash_algo, "md5"))
 		cipher = purple_md5_cipher_new();
 	if (cipher == NULL)
@@ -758,7 +758,7 @@ jabber_calculate_data_hash(gconstpointer
 		    hash_algo);
 		g_return_val_if_reached(NULL);
 	}
-	g_object_unref(G_OBJECT(sha1));
+	g_object_unref(G_OBJECT(cipher));
 
 	return g_strdup(digest);
 }
============================================================
--- libpurple/protocols/jabber/parser.c	cb0b0f6d7ce8ae78749be3b7aadeb1ca5143e939
+++ libpurple/protocols/jabber/parser.c	0b647fd263015f1ca9883a2d98c4a72d0968d7f0
@@ -293,7 +293,7 @@ void jabber_parser_process(JabberStream 
 	}
 
 	if (js->protocol_version.major == 0 && js->protocol_version.minor == 9 &&
-			!js->gc->disconnect_timeout &&
+			/* FIXME: !js->gc->disconnect_timeout &&*/
 			(js->state == JABBER_STREAM_INITIALIZING ||
 			 js->state == JABBER_STREAM_INITIALIZING_ENCRYPTION)) {
 		/*
============================================================
--- libpurple/protocols/jabber/presence.c	5c2c76cac556057e8e42f7b3b35bcc4834b9ff81
+++ libpurple/protocols/jabber/presence.c	cca34b42fb8ccd020c0f987bf55766c61a4e0d6c
@@ -460,7 +460,7 @@ jabber_vcard_parse_avatar(JabberStream *
 			data = purple_base64_decode(text, &size);
 			if (data) {
 				gchar *hash = jabber_calculate_data_hash(data, size, "sha1");
-				purple_buddy_icons_set_for_user(js->gc->account, from, data,
+				purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, data,
 				                                size, hash);
 				g_free(hash);
 			}
============================================================
--- libpurple/protocols/jabber/roster.c	fb4cff1ea04ca7e912507c52c20118dc6f2931cf
+++ libpurple/protocols/jabber/roster.c	cd322180dbfdaca78c16db6204bd0803fc7fbf35
@@ -159,7 +159,7 @@ static void add_purple_buddy_to_groups(J
 			                  "from group '%s' on the local list\n",
 			                  purple_buddy_get_name(b),
 			                  purple_group_get_name(g));
-			purple_blist_remove_buddy(b);
+			purple_blist_node_remove(PURPLE_BLIST_NODE(b));
 		}
 	}
 
@@ -392,7 +392,7 @@ void jabber_roster_add_buddy(PurpleConne
 		                     "to your buddy list and removing the buddy. "
 		                     "Buddies can only be added by real (non-MUC) "
 		                     "JID\n");
-		purple_blist_remove_buddy(buddy);
+		purple_blist_node_remove(PURPLE_BLIST_NODE(buddy));
 		jabber_id_free(jid);
 		return;
 	}
@@ -403,7 +403,7 @@ void jabber_roster_add_buddy(PurpleConne
 		 * If the buddy name added contains a resource, strip that off and
 		 * rename the buddy.
 		 */
-		purple_blist_rename_buddy(buddy, who);
+		purple_buddy_set_name(buddy, who);
 	}
 
 	jb = jabber_buddy_find(js, who, FALSE);
============================================================
--- libpurple/protocols/jabber/usermood.c	99f714015ce1450a1af123427a372315532915f3
+++ libpurple/protocols/jabber/usermood.c	1ee63b37b5ae23859e4bfbb5f1566cb3ee1bc8c7
@@ -120,6 +120,7 @@ static void jabber_mood_cb(JabberStream 
 };
 
 static void jabber_mood_cb(JabberStream *js, const char *from, xmlnode *items) {
+	PurpleAccount *account;
 	/* it doesn't make sense to have more than one item here, so let's just pick the first one */
 	xmlnode *item = xmlnode_get_child(items, "item");
 	const char *newmood = NULL;
@@ -154,13 +155,14 @@ static void jabber_mood_cb(JabberStream 
 		if (newmood != NULL && moodtext != NULL)
 		   break;
 	}
+	account = purple_connection_get_account(js->gc);
 	if (newmood != NULL) {
-		purple_prpl_got_user_status(js->gc->account, from, "mood",
+		purple_prpl_got_user_status(account, from, "mood",
 				PURPLE_MOOD_NAME, newmood,
 				PURPLE_MOOD_COMMENT, moodtext,
 				NULL);
 	} else {
-		purple_prpl_got_user_status_deactive(js->gc->account, from, "mood");
+		purple_prpl_got_user_status_deactive(account, from, "mood");
 	}
 	g_free(moodtext);
 }


More information about the Commits mailing list