gobjectification: 76803b12: Make QQ compile. May or may not work. I ...

qulogic at pidgin.im qulogic at pidgin.im
Mon Jul 14 00:41:20 EDT 2008


-----------------------------------------------------------------
Revision: 76803b12cbfc48ce0937ea3cfbb7a79d2d9f3161
Ancestor: 2fd60fa70d8bf835eaa6e043c49253f823a3b01d
Author: qulogic at pidgin.im
Date: 2008-07-14T02:25:18
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/76803b12cbfc48ce0937ea3cfbb7a79d2d9f3161

Modified files:
        libpurple/protocols/qq/buddy_info.c
        libpurple/protocols/qq/buddy_list.c
        libpurple/protocols/qq/im.c
        libpurple/protocols/qq/login_logout.c
        libpurple/protocols/qq/qq.c
        libpurple/protocols/qq/qq_network.c
        libpurple/protocols/qq/sys_msg.c

ChangeLog: 

Make QQ compile. May or may not work. I was never able to login anyway.

-------------- next part --------------
============================================================
--- libpurple/protocols/qq/buddy_info.c	3a26d543a60f6412c6037c830bc70c045253c14a
+++ libpurple/protocols/qq/buddy_info.c	f65dd050e3e6f2d93a08150881a14b81bdbd7d3e
@@ -313,7 +313,7 @@ static void qq_send_packet_modify_info(P
 /* send packet to modify personal information */
 static void qq_send_packet_modify_info(PurpleConnection *gc, contact_info *info)
 {
-	qq_data *qd = (qq_data *) gc->proto_data;
+	qq_data *qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	gint bytes = 0;
 	guint8 raw_data[MAX_PACKET_SIZE - 128] = {0};
 	guint8 bar;
@@ -933,14 +933,13 @@ void qq_send_packet_get_level(PurpleConn
 
 void qq_send_packet_get_level(PurpleConnection *gc, guint32 uid)
 {
-	qq_data *qd = (qq_data *) gc->proto_data;
+	qq_data *qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	guint8 buf[16] = {0};
 	gint bytes = 0;
 
 	bytes += qq_put8(buf + bytes, 0x00);
 	bytes += qq_put32(buf + bytes, uid);
 
-	qd = (qq_data *) gc->proto_data;
 	qq_send_cmd(qd, QQ_CMD_GET_LEVEL, buf, bytes);
 }
 
============================================================
--- libpurple/protocols/qq/buddy_list.c	e53fa1ed36f81e0b85426cef7b48cce8c137ba6d
+++ libpurple/protocols/qq/buddy_list.c	513b726b0714427b8d47b005f76c9de97b17e3cd
@@ -89,7 +89,7 @@ void qq_send_packet_get_buddies_list(Pur
  * server may return a position tag if list is too long for one packet */
 void qq_send_packet_get_buddies_list(PurpleConnection *gc, guint16 position)
 {
-	qq_data *qd = (qq_data *) gc->proto_data;
+	qq_data *qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	guint8 raw_data[16] = {0};
 	gint bytes = 0;
 
@@ -108,7 +108,7 @@ void qq_send_packet_get_all_list_with_gr
 /* get all list, buddies & Quns with groupsid support */
 void qq_send_packet_get_all_list_with_group(PurpleConnection *gc, guint32 position)
 {
-	qq_data *qd = (qq_data *) gc->proto_data;
+	qq_data *qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	guint8 raw_data[16] = {0};
 	gint bytes = 0;
 
============================================================
--- libpurple/protocols/qq/im.c	2b8d4c0bbc8adc5fd6306ac9bd4a2a33fefcd72d
+++ libpurple/protocols/qq/im.c	1911cfc854a757c3dd037eca7b7f15db266854cf
@@ -221,7 +221,7 @@ static void _qq_send_packet_recv_im_ack(
 {
 	qq_data *qd;
 
-	qd = (qq_data *) gc->proto_data;
+	qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	qq_send_cmd_detail(qd, QQ_CMD_RECV_IM, seq, FALSE, data, 16);
 }
 
============================================================
--- libpurple/protocols/qq/login_logout.c	4f3ae2c020773eca362f906adc80b705ef85847d
+++ libpurple/protocols/qq/login_logout.c	6fb150a273152f4b67542eb08669f49929f00cb2
@@ -25,7 +25,7 @@
 #include "debug.h"
 #include "internal.h"
 #include "server.h"
-#include "cipher.h"
+#include "md5cipher.h"
 
 #include "buddy_info.h"
 #include "buddy_list.h"
@@ -147,18 +147,16 @@ static guint8 *gen_session_md5(gint uid,
 {
 	guint8 *src, md5_str[QQ_KEY_LENGTH];
 	PurpleCipher *cipher;
-	PurpleCipherContext *context;
 
 	src = g_newa(guint8, 20);
 	/* bug found by QuLogic */
 	memcpy(src, &uid, sizeof(uid));
 	memcpy(src + sizeof(uid), session_key, QQ_KEY_LENGTH);
 
-	cipher = purple_ciphers_find_cipher("md5");
-	context = purple_cipher_context_new(cipher, NULL);
-	purple_cipher_context_append(context, src, 20);
-	purple_cipher_context_digest(context, sizeof(md5_str), md5_str, NULL);
-	purple_cipher_context_destroy(context);
+	cipher = purple_md5_cipher_new();
+	purple_cipher_append(cipher, src, 20);
+	purple_cipher_digest(cipher, sizeof(md5_str), md5_str, NULL);
+	g_object_unref(G_OBJECT(cipher));
 
 	return g_memdup(md5_str, QQ_KEY_LENGTH);
 }
============================================================
--- libpurple/protocols/qq/qq.c	34317ac96c69afd1e677e968481c163d0b40704d
+++ libpurple/protocols/qq/qq.c	cb1327a1b0b644ef3d03bde2bff228cfc9dbcb8d
@@ -74,8 +74,9 @@ static void server_list_create(PurpleAcc
 
 	purple_debug(PURPLE_DEBUG_INFO, "QQ", "Create server list\n");
 	gc = purple_account_get_connection(account);
-	g_return_if_fail(gc != NULL  && gc->proto_data != NULL);
-	qd = gc->proto_data;
+	g_return_if_fail(gc != NULL);
+	qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
+	g_return_if_fail(qd != NULL);
 
 	qd->use_tcp = purple_account_get_bool(account, "use_tcp", TRUE);
 	port = purple_account_get_int(account, "port", 0);
@@ -177,8 +178,9 @@ static void qq_close(PurpleConnection *g
 {
 	qq_data *qd;
 
-	g_return_if_fail(gc != NULL  && gc->proto_data);
-	qd = gc->proto_data;
+	g_return_if_fail(gc != NULL);
+	qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
+	g_return_if_fail(qd != NULL);
 
 	qq_disconnect(gc);
 
@@ -186,7 +188,7 @@ static void qq_close(PurpleConnection *g
 	
 	g_free(qd);
 
-	gc->proto_data = NULL;
+	purple_object_set_protocol_data(PURPLE_OBJECT(gc), NULL);
 }
 
 /* returns the icon name for a buddy or protocol */
============================================================
--- libpurple/protocols/qq/qq_network.c	4ddd81310ea1c6ad22702fc19e5b75d74a58d293
+++ libpurple/protocols/qq/qq_network.c	907288536856b5b60a26241c52e63d0f2274ce00
@@ -22,9 +22,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
  */
 
-#include "cipher.h"
 #include "debug.h"
 #include "internal.h"
+#include "md5cipher.h"
 
 #ifdef _WIN32
 #define random rand
@@ -111,19 +111,16 @@ static guint8 *encrypt_account_password(
 static guint8 *encrypt_account_password(const gchar *pwd)
 {
 	PurpleCipher *cipher;
-	PurpleCipherContext *context;
 
 	guchar pwkey_tmp[QQ_KEY_LENGTH];
 
-	cipher = purple_ciphers_find_cipher("md5");
-	context = purple_cipher_context_new(cipher, NULL);
-	purple_cipher_context_append(context, (guchar *) pwd, strlen(pwd));
-	purple_cipher_context_digest(context, sizeof(pwkey_tmp), pwkey_tmp, NULL);
-	purple_cipher_context_destroy(context);
-	context = purple_cipher_context_new(cipher, NULL);
-	purple_cipher_context_append(context, pwkey_tmp, QQ_KEY_LENGTH);
-	purple_cipher_context_digest(context, sizeof(pwkey_tmp), pwkey_tmp, NULL);
-	purple_cipher_context_destroy(context);
+	cipher = purple_md5_cipher_new();
+	purple_cipher_append(cipher, (guchar *) pwd, strlen(pwd));
+	purple_cipher_digest(cipher, sizeof(pwkey_tmp), pwkey_tmp, NULL);
+	purple_cipher_reset(cipher);
+	purple_cipher_append(cipher, pwkey_tmp, QQ_KEY_LENGTH);
+	purple_cipher_digest(cipher, sizeof(pwkey_tmp), pwkey_tmp, NULL);
+	g_object_unref(G_OBJECT(cipher));
 
 	return g_memdup(pwkey_tmp, QQ_KEY_LENGTH);
 }
@@ -140,7 +137,7 @@ static void process_cmd_unknow(PurpleCon
 
 	qq_show_packet("Processing unknown packet", buf, buf_len);
 
-	qd = (qq_data *) gc->proto_data;
+	qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 
 	data_len = buf_len;
 	data = g_newa(guint8, data_len);
@@ -210,12 +207,13 @@ static gboolean reconnect_later_cb(gpoin
 	qq_data *qd;
 
 	gc = (PurpleConnection *) data;
-	g_return_val_if_fail(gc != NULL && gc->proto_data != NULL, FALSE);
-	qd = (qq_data *) gc->proto_data;
+	g_return_val_if_fail(gc != NULL, FALSE);
+	qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
+	g_return_val_if_fail(qd != NULL, FALSE);
 
 	qd->reconnect_timeout = 0;
 
-	qq_connect(gc->account);
+	qq_connect(purple_connection_get_account(gc));
 	return FALSE;	/* timeout callback stops */
 }
 
@@ -223,8 +221,9 @@ static void reconnect_later(PurpleConnec
 {
 	qq_data *qd;
 
-	g_return_if_fail(gc != NULL && gc->proto_data != NULL);
-	qd = (qq_data *) gc->proto_data;
+	g_return_if_fail(gc != NULL);
+	qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
+	g_return_if_fail(qd != NULL);
 
 	qd->reconnect_times--;
 	if (qd->reconnect_times < 0) {
@@ -342,7 +341,7 @@ static void packet_process(PurpleConnect
 
 	g_return_if_fail(buf != NULL && buf_len > 0);
 
-	qd = (qq_data *) gc->proto_data;
+	qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 
 	prev_login_status = qd->logged_in;
 
@@ -425,15 +424,15 @@ static void tcp_pending(gpointer data, g
 	gint jump_len;
 
 	gc = (PurpleConnection *) data;
-	g_return_if_fail(gc != NULL && gc->proto_data != NULL);
+	g_return_if_fail(gc != NULL);
+	qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
+	g_return_if_fail(qd != NULL);
 
 	if(cond != PURPLE_INPUT_READ) {
 		purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 				_("Socket error"));
 		return;
 	}
-
-	qd = (qq_data *) gc->proto_data;
 	
 	/* test code, not using tcp_rxqueue
 	memset(pkt,0, sizeof(pkt));
@@ -460,7 +459,7 @@ static void tcp_pending(gpointer data, g
 		return;
 	}
 
-	gc->last_received = time(NULL);
+	purple_connection_received_now(gc);
 	purple_debug(PURPLE_DEBUG_INFO, "TCP_PENDING",
 			   "Read %d bytes from socket, rxlen is %d\n", buf_len, qd->tcp_rxlen);
 	qd->tcp_rxqueue = g_realloc(qd->tcp_rxqueue, buf_len + qd->tcp_rxlen);
@@ -544,7 +543,10 @@ static void udp_pending(gpointer data, g
 	gint buf_len;
 
 	gc = (PurpleConnection *) data;
-	g_return_if_fail(gc != NULL && gc->proto_data != NULL);
+	g_return_if_fail(gc != NULL);
+	qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
+	g_return_if_fail(qd != NULL);
+	g_return_if_fail(qd->fd >= 0);
 
 	if(cond != PURPLE_INPUT_READ) {
 		purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
@@ -552,9 +554,6 @@ static void udp_pending(gpointer data, g
 		return;
 	}
 
-	qd = (qq_data *) gc->proto_data;
-	g_return_if_fail(qd->fd >= 0);
-	
 	buf = g_newa(guint8, MAX_PACKET_SIZE);
 
 	/* here we have UDP proxy suppport */
@@ -565,7 +564,7 @@ static void udp_pending(gpointer data, g
 		return;
 	}
 
-	gc->last_received = time(NULL);
+	purple_connection_received_now(gc);
 
 	if (buf_len < QQ_UDP_HEADER_LENGTH) {
 		if (buf[0] != QQ_PACKET_TAG || buf[buf_len - 1] != QQ_PACKET_TAIL) {
@@ -684,9 +683,9 @@ static gboolean trans_timeout(gpointer d
 	int index;
 	
 	gc = (PurpleConnection *) data;
-	g_return_val_if_fail(gc != NULL && gc->proto_data != NULL, TRUE);
-
-	qd = (qq_data *) gc->proto_data;
+	g_return_val_if_fail(gc != NULL, TRUE);
+	qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
+	g_return_val_if_fail(qd != NULL, TRUE);
 	
 	index = 0;
 	buf = g_newa(guint8, MAX_PACKET_SIZE);
@@ -759,10 +758,10 @@ static void qq_connect_cb(gpointer data,
 		return;
 	}
 
-	g_return_if_fail(gc != NULL && gc->proto_data != NULL);
+	g_return_if_fail(gc != NULL);
+	qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
+	g_return_if_fail(gc != NULL);
 
-	qd = (qq_data *) gc->proto_data;
-
 	/* Connect is now complete; clear the PurpleProxyConnectData */
 	qd->connect_data = NULL;
 
@@ -793,9 +792,9 @@ static void qq_connect_cb(gpointer data,
 	qd->resend_timeout = purple_timeout_add(5000, trans_timeout, gc);
 	
 	if (qd->use_tcp)
-		gc->inpa = purple_input_add(qd->fd, PURPLE_INPUT_READ, tcp_pending, gc);
+		g_object_set(G_OBJECT(gc), "inpa", purple_input_add(qd->fd, PURPLE_INPUT_READ, tcp_pending, gc), NULL);
 	else
-		gc->inpa = purple_input_add(qd->fd, PURPLE_INPUT_READ, udp_pending, gc);
+		g_object_set(G_OBJECT(gc), "inpa", purple_input_add(qd->fd, PURPLE_INPUT_READ, udp_pending, gc), NULL);
 
 	/* Update the login progress status display */
 	conn_msg = g_strdup_printf("Login as %d", qd->uid);
@@ -813,11 +812,11 @@ static void udp_can_write(gpointer data,
 	int error=0, ret;
 
 	gc = (PurpleConnection *) data;
-	g_return_if_fail(gc != NULL && gc->proto_data != NULL);
+	g_return_if_fail(gc != NULL);
+	qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
+	g_return_if_fail(qd != NULL);
 
-	qd = (qq_data *) gc->proto_data;
 
-
 	purple_debug_info("proxy", "Connected.\n");
 
 	/*
@@ -862,10 +861,10 @@ static void udp_host_resolved(GSList *ho
 	int flags;
 
 	gc = (PurpleConnection *) data;
-	g_return_if_fail(gc != NULL && gc->proto_data != NULL);
+	g_return_if_fail(gc != NULL);
+	qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
+	g_return_if_fail(qd != NULL);
 
-	qd = (qq_data *) gc->proto_data;
-
 	/* udp_query_data must be set as NULL.
 	 * Otherwise purple_dnsquery_destroy in qq_disconnect cause glib double free error */
 	qd->udp_query_data = NULL;
@@ -946,11 +945,10 @@ void qq_connect(PurpleAccount *account)
 	gchar *conn_msg;
 
 	gc = purple_account_get_connection(account);
-	g_return_if_fail(gc != NULL && gc->proto_data != NULL);
+	g_return_if_fail(gc != NULL);
+	qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
+	g_return_if_fail(qd != NULL);
 
-	qd = (qq_data *) gc->proto_data;
-
-
 	/* test set_new_server
 	while (set_new_server(qd)) {
    		purple_debug(PURPLE_DEBUG_INFO, "QQ_TEST",
@@ -1028,9 +1026,11 @@ void qq_disconnect(PurpleConnection *gc)
 void qq_disconnect(PurpleConnection *gc)
 {
 	qq_data *qd;
+	gint inpa;
 
-	g_return_if_fail(gc != NULL && gc->proto_data != NULL);
-	qd = (qq_data *) gc->proto_data;
+	g_return_if_fail(gc != NULL);
+	qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
+	g_return_if_fail(qd != NULL);
 
 	purple_debug(PURPLE_DEBUG_INFO, "QQ", "Disconnecting ...\n");
 	/* finish  all I/O */
@@ -1043,9 +1043,10 @@ void qq_disconnect(PurpleConnection *gc)
 		qd->resend_timeout = 0;
 	}
 
-	if (gc->inpa > 0) {
-		purple_input_remove(gc->inpa);
-		gc->inpa = 0;
+	g_object_get(G_OBJECT(gc), "inpa", &inpa, NULL);
+	if (inpa > 0) {
+		purple_input_remove(inpa);
+		g_object_set(G_OBJECT(gc), "inpa", 0, NULL);
 	}
 
 	if (qd->fd >= 0) {
@@ -1120,7 +1121,7 @@ void qq_disconnect(PurpleConnection *gc)
 	qq_group_free_all(qd);
 	qq_add_buddy_request_free(qd);
 	qq_info_query_free(qd);
-	qq_buddies_list_free(gc->account, qd);
+	qq_buddies_list_free(purple_connection_get_account(gc), qd);
 }
 
 static gint encap(qq_data *qd, guint8 *buf, gint maxlen, guint16 cmd, guint16 seq, 
============================================================
--- libpurple/protocols/qq/sys_msg.c	87d4be0f34953b60fea78dda99e2744d0ae82c0d
+++ libpurple/protocols/qq/sys_msg.c	c2c9be644f959ef18ebd148dea29681520b77f2d
@@ -125,7 +125,7 @@ static void _qq_send_packet_ack_msg_sys(
 	gchar *str;
 	gint ack_len, bytes;
 
-	qd = (qq_data *) gc->proto_data;
+	qd = (qq_data *) purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	
 	str = g_strdup_printf("%d", from);
 	bar = 0x1e;


More information about the Commits mailing list