pidgin.openq: c733d767: 2009.02.24 - flos <lonicerae(at)gmail.co...

csyfek at gmail.com csyfek at gmail.com
Tue Feb 24 09:30:38 EST 2009


-----------------------------------------------------------------
Revision: c733d767a0fad23b0f329c177b50cbcf4de0d140
Ancestor: a5dd5fe732d799dcb70435cee8a0df2b375df0e8
Author: csyfek at gmail.com
Date: 2009-02-24T14:33:49
Branch: im.pidgin.pidgin.openq
URL: http://d.pidgin.im/viewmtn/revision/info/c733d767a0fad23b0f329c177b50cbcf4de0d140

Modified files:
        libpurple/protocols/qq/ChangeLog
        libpurple/protocols/qq/buddy_list.c
        libpurple/protocols/qq/buddy_memo.c
        libpurple/protocols/qq/buddy_memo.h
        libpurple/protocols/qq/qq.c
        libpurple/protocols/qq/qq_process.c

ChangeLog: 

2009.02.24 - flos <lonicerae(at)gmail.com>
	* Changed update_class type from gint to guint32
	* Fixed a bug of displaying of memo when memo is nothing

-------------- next part --------------
============================================================
--- libpurple/protocols/qq/ChangeLog	1a8230fa965992f04045611e2c73e5dbc668d21e
+++ libpurple/protocols/qq/ChangeLog	6910604f15f86dbaa90866741146162ce37f4f7e
@@ -1,3 +1,7 @@
+2009.02.24 - flos <lonicerae(at)gmail.com>
+	* Changed update_class type from gint to guint32
+	* Fixed a bug of displaying of memo when memo is nothing
+
 2009.02.21 - flos <lonicerae(at)gmail.com>
 	* Added 'qq_strlen' and 'qq_strcmp' funtions in qq.h
 	* Fixed compiling problems with lower version of GTK+
============================================================
--- libpurple/protocols/qq/buddy_list.c	cf30c14cc9eabc1b2179e741e2a250b9691381de
+++ libpurple/protocols/qq/buddy_list.c	0b711432a1c7e324f44a5ea41d44a57c5aaf23ce
@@ -347,7 +347,8 @@ guint16 qq_process_get_buddies(guint8 *d
 		/* nickname has been copy to buddy_data do not free
 		   g_free(bd.nickname);
 		*/
-		qq_request_buddy_memo(gc, ((qq_buddy_data*)buddy->proto_data)->uid, 0, QQ_BUDDY_MEMO_GET);
+		/*qq_request_buddy_memo(gc, ((qq_buddy_data*)buddy->proto_data)->uid, 0, QQ_BUDDY_MEMO_GET);*/
+		qq_request_buddy_memo(gc, bd.uid, bd.uid, QQ_BUDDY_MEMO_GET);
 	}
 
 	if(bytes > data_len) {
============================================================
--- libpurple/protocols/qq/buddy_memo.c	ff08973b641edd8c1e0d6a8257268a27d5ee5e93
+++ libpurple/protocols/qq/buddy_memo.c	9b25c20640150638d49edde6514ff3d89542b4ea
@@ -37,13 +37,13 @@ static const gchar *memo_id[] = {
 
 /* memo id */
 static const gchar *memo_id[] = {
-	N_("mm_alias"),
-	N_("mm_mobile"),
-	N_("mm_telephone"),
-	N_("mm_address"),
-	N_("mm_email"),
-	N_("mm_zipcode"),
-	N_("mm_note")
+	"mm_alias",
+	"mm_mobile",
+	"mm_telephone",
+	"mm_address",
+	"mm_email",
+	"mm_zipcode",
+	"mm_note"
 };
 
 /* memo text */
@@ -97,7 +97,7 @@ static void update_buddy_memo(PurpleConn
 	buddy = purple_find_buddy(account, who);
 	if (buddy == NULL || buddy->proto_data == NULL) {
 		g_free(who);
-		purple_debug_info("QQ", "Error Can not find %d!\n", bd_uid);
+		purple_debug_info("QQ", "Error...Can NOT find %d!\n", bd_uid);
 		return;
 	}
 	purple_blist_alias_buddy(buddy, (const char*)alias);
@@ -108,7 +108,7 @@ static void request_change_memo(PurpleCo
 	gint bytes;
 	/* Attention, length of each segment must be guint8(0~255),
 	 * so length of memo string is limited.
-	 * convert it to guint8 first before put data */
+	 * convert it to guint8 first before putting data */
 	guint seg_len;
 	gint index;
 	guint8 raw_data[MAX_PACKET_SIZE - 16] = {0};
@@ -189,7 +189,7 @@ static void memo_modify_ok_cb(modify_mem
 }
 
 /* memo modify dialogue */
-static void memo_modify_dialogue(PurpleConnection *gc, guint32 bd_uid, gchar **segments, gint iclass)
+static void memo_modify_dialogue(PurpleConnection *gc, guint32 bd_uid, gchar **segments, guint32 action)
 {
 	modify_memo_request *memo_request;
 	PurpleRequestField *field;
@@ -201,11 +201,12 @@ static void memo_modify_dialogue(PurpleC
 
 	g_return_if_fail(NULL != gc && NULL != segments);
 
-	switch (iclass) {
+	switch (action) {
 		case QQ_BUDDY_MEMO_GET:
+			memo_free(segments);
 			break;
 		case QQ_BUDDY_MEMO_MODIFY:
-			/* Keep one dialog once a time */
+			/* keep one dialog once a time */
 			purple_request_close_with_handle(gc);
 			/* show dialog */
 			fields = purple_request_fields_new();
@@ -217,7 +218,6 @@ static void memo_modify_dialogue(PurpleC
 				   purple_debug_info("QQ", "id:%s txt:%s segment:%s\n",
 				   memo_id[index], memo_txt[index], segments[index]);
 				   */
-
 				field = purple_request_field_string_new(memo_id[index], memo_txt[index],
 						segments[index], FALSE);
 				purple_request_field_group_add_field(group, field);
@@ -243,13 +243,27 @@ static void memo_modify_dialogue(PurpleC
 			g_free(utf8_primary);
 			break;
 		default:
-			purple_debug_info("QQ", "unknown memo action\n");
+			purple_debug_info("QQ", "Error...unknown memo action, please tell us\n");
 			break;
 	}
 }
 
+static void qq_create_buddy_memo(PurpleConnection *gc, guint32 bd_uid, guint32 action)
+{
+	gchar **segments;
+	gint index;
+	g_return_if_fail(NULL != gc);
+
+	segments = g_new0(gchar*, QQ_MEMO_SIZE);
+	for (index = 0; index < QQ_MEMO_SIZE; index++) {
+		segments[index] = g_strdup("");;
+	}
+	memo_modify_dialogue(gc, bd_uid, segments, action);
+}
+
 /* process reply to get_memo packet */
-void qq_process_get_buddy_memo(PurpleConnection *gc, guint8* data, gint data_len, guint32 action)
+void qq_process_get_buddy_memo(PurpleConnection *gc, guint8* data, gint data_len,
+		guint32 update_class, guint32 action)
 {
 	gchar **segments;
 	gint bytes;
@@ -259,20 +273,26 @@ void qq_process_get_buddy_memo(PurpleCon
 	guint8 unk1_8;
 	guint8 is_success;
 
-	g_return_if_fail(data != NULL && data_len != 0);
+	g_return_if_fail(NULL != gc && NULL != data && 0 != data_len);
 	/*
 	   qq_show_packet("MEMO REACH", data, data_len);
 	   */
-	purple_debug_info("QQ", "action:0x%x\n", action);
+	purple_debug_info("QQ", "action=0x%02X\n", action);
 
 	bytes = 0;
 
 	/* TX looks a bit clever than before... :) */
 	bytes += qq_get8(&rcv_cmd, data+bytes);
-	purple_debug_info("QQ", "rcv_cmd:0x%x\n", rcv_cmd);
-	/* it's possible that no buddy uid and no memo!!! */
-	if (1 == data_len) {
+	purple_debug_info("QQ", "rcv_cmd=0x%02X\n", rcv_cmd);
+
+	/* it's possible that packet contains no buddy uid and no memo!!!
+	 * go to next step according to previous action sent */
+	if (1 == data_len) { /* only one byte */
 		purple_debug_info("QQ", "memo packet contains no buddy uid and memo...\n");
+		if (QQ_BUDDY_MEMO_MODIFY == action) {
+			qq_create_buddy_memo(gc, (guint32)update_class, QQ_BUDDY_MEMO_MODIFY);
+			return;
+		}
 		return;
 	}
 
@@ -282,22 +302,24 @@ void qq_process_get_buddy_memo(PurpleCon
 			bytes += qq_get8(&is_success, data+bytes);
 			if (QQ_BUDDY_MEMO_REQUEST_SUCCESS == is_success) {
 				purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO,
-						_("Memo Modify"), _("Your request was accepted."), NULL,
+						_("Memo Modify"), _("Server says:"),
+						_("Your request was accepted."),
 						NULL, NULL);
-				purple_debug_info("QQ", "memo change succeessfully!");
+				purple_debug_info("QQ", "memo change succeessfully!\n");
 			}
 			else {
 				purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO,
-						_("Memo Modify"), _("Your request was rejected."), NULL,
+						_("Memo Modify"), _("Server says:"),
+						_("Your request was rejected."),
 						NULL, NULL);
-				purple_debug_info("QQ", "memo change failed");
+				purple_debug_info("QQ", "memo change failed\n");
 			}
 			break;
 		case QQ_BUDDY_MEMO_GET:
 			bytes += qq_get32(&rcv_uid, data+bytes);
-			purple_debug_info("QQ", "rcv_uid:%u\n", rcv_uid);
+			purple_debug_info("QQ", "rcv_uid=%u\n", rcv_uid);
 			bytes += qq_get8(&unk1_8, data+bytes);
-			purple_debug_info("QQ", "unk1_8:0x%x\n", unk1_8);
+			purple_debug_info("QQ", "unk1_8=0x%02X\n", unk1_8);
 			segments = g_new0(gchar*, QQ_MEMO_SIZE);
 			for (index = 0; index < QQ_MEMO_SIZE; index++) {
 				/* get utf8 string */
@@ -312,21 +334,21 @@ void qq_process_get_buddy_memo(PurpleCon
 
 			/* memo is thing that we regard our buddy as, so we need one more buddy_uid */
 			memo_modify_dialogue(gc, rcv_uid, segments, action);
-
 			break;
 		default:
-			purple_debug_info("QQ", "received an UNKNOWN memo cmd!!!");
+			purple_debug_info("QQ", "received an UNKNOWN memo cmd!!!\n");
 			break;
 	}
 }
 
 /* request buddy memo */
-void qq_request_buddy_memo(PurpleConnection *gc, guint32 bd_uid, guint32 update_class, int action)
+void qq_request_buddy_memo(PurpleConnection *gc, guint32 bd_uid, guint32 update_class, guint32 action)
 {
 	guint8 raw_data[16] = {0};
 	gint bytes;
 
-	purple_debug_info("QQ", "qq_request_buddy_memo, buddy uid=%u\n", bd_uid);
+	purple_debug_info("QQ", "qq_request_buddy_memo, buddy uid=%u, update_class=%u\n",
+			bd_uid, update_class);
 	g_return_if_fail(NULL != gc);
 	/* '0' is ok
 	   g_return_if_fail(uid != 0);
@@ -341,16 +363,4 @@ void qq_request_buddy_memo(PurpleConnect
 	qq_send_cmd_mess(gc, QQ_CMD_BUDDY_MEMO, (guint8*)raw_data, bytes, update_class, action);
 }
 
-void qq_create_buddy_memo(PurpleConnection *gc, guint32 bd_uid, int action)
-{
-	gchar **segments;
-	gint index;
-	g_return_if_fail(NULL != gc);
 
-	segments = g_new0(gchar*, QQ_MEMO_SIZE);
-	for (index = 0; index < QQ_MEMO_SIZE; index++) {
-		segments[index] = g_strdup("");;
-	}
-	memo_modify_dialogue(gc, bd_uid, segments, action);
-}
-
============================================================
--- libpurple/protocols/qq/buddy_memo.h	dd9a02506ce8a79294995801a6e8210af1ddf067
+++ libpurple/protocols/qq/buddy_memo.h	1792759b8142c19fec23ecbf0513c8d1d0d040bf
@@ -16,11 +16,9 @@ enum
 };
 
 
-void qq_process_get_buddy_memo(PurpleConnection *gc, guint8* data, gint data_len, guint32 action);
+void qq_process_get_buddy_memo(PurpleConnection *gc, guint8* data, gint data_len, guint32 update_class, guint32 action);
 
-void qq_request_buddy_memo(PurpleConnection *gc, guint32 bd_uid, guint32 update_class, int action);
+void qq_request_buddy_memo(PurpleConnection *gc, guint32 bd_uid, guint32 update_class, guint32 action);
 
-void qq_create_buddy_memo(PurpleConnection *gc, guint32 bd_uid, int action);
-
 #endif
 
============================================================
--- libpurple/protocols/qq/qq.c	4665f83d3ddfb16006481ddefb856b1cf232c840
+++ libpurple/protocols/qq/qq.c	541e0e421503dbe141b9957e8da138b2513b6a8a
@@ -57,7 +57,7 @@
 #include "utils.h"
 #include "version.h"
 
-#define OPENQ_VERSION 		"0.3.2-p19" 
+#define OPENQ_VERSION 		"0.3.2-p20" 
 
 static GList *server_list_build(gchar select)
 {
@@ -826,8 +826,6 @@ static void qq_modify_buddy_memo_from_me
 	qq_buddy_data *bd;
 	PurpleConnection *gc;
 	guint32 bd_uid;
-	const gchar *alias;
-	const gchar *server_alias;
 
 	g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
 
@@ -841,19 +839,10 @@ static void qq_modify_buddy_memo_from_me
 	g_return_if_fail(NULL != bd);
 	bd_uid = bd->uid;
 
-	/* gc, uid, update_class, action */
-	qq_request_buddy_memo(gc, bd_uid, 0, QQ_BUDDY_MEMO_MODIFY);
-
-	/* if buddy does NOT have a memo, open the memo dialogue directly */
-	alias = purple_buddy_get_alias_only(buddy);
-	server_alias = purple_buddy_get_server_alias(buddy);
-
-	purple_debug_info("QQ", "alias=%s\n", alias);
-	purple_debug_info("QQ", "server_alias=%s\n", server_alias);
-
-	if (!qq_strcmp(alias, server_alias)) {
-		qq_create_buddy_memo(gc, bd_uid, QQ_BUDDY_MEMO_MODIFY);
-	}
+	/* param: gc, uid, update_class, action
+	 * here, update_class is set to bd_uid. because some memo packages returned
+	 * without uid, which will make us confused */
+	qq_request_buddy_memo(gc, bd_uid, bd_uid, QQ_BUDDY_MEMO_MODIFY);
 }
 
 static GList *qq_buddy_menu(PurpleBuddy *buddy)
============================================================
--- libpurple/protocols/qq/qq_process.c	a9c96a02c3ef43589244a781533fd7217744537f
+++ libpurple/protocols/qq/qq_process.c	b73d817e0676d6fcaa4abac490f6b58a6663fdf5
@@ -1145,7 +1145,9 @@ void qq_proc_client_cmds(PurpleConnectio
 			break;
 		case QQ_CMD_BUDDY_MEMO:
 			purple_debug_info("QQ", "Receive memo from server!\n");
-			qq_process_get_buddy_memo(gc, data, data_len, ship32);
+			qq_process_get_buddy_memo(gc, data, data_len, update_class, ship32);
+			return;
+			purple_debug_info("QQ", "Should NOT be here...\n");
 			break;
 		default:
 			process_unknow_cmd(gc, _("Unknown CLIENT CMD"), data, data_len, cmd, seq);


More information about the Commits mailing list