changeset 13993:e6977f9435a1

[gaim-migrate @ 16570] *Fixed an off-by-one blood_types bug. *Made it so that only one modify info dialog can be open at a time. *Fixed a bug where the user wasn't always notified when his info had been modified. *Eliminated the ability to send empty strings as info fields as these were making the official client unhappy. committer: Tailor Script <tailor@pidgin.im>
author Mark Huetsch <markhuetsch>
date Tue, 25 Jul 2006 04:31:36 +0000
parents 0567de116699
children 626977ae8869
files src/protocols/qq/buddy_info.c src/protocols/qq/qq.h
diffstat 2 files changed, 41 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/qq/buddy_info.c	Tue Jul 25 01:25:04 2006 +0000
+++ b/src/protocols/qq/buddy_info.c	Tue Jul 25 04:31:36 2006 +0000
@@ -107,7 +107,7 @@
 };
 
 static const gchar *blood_types[] = {
-	"其它", "A型", "B型", "O型", "AB型", NULL
+	"-", N_("A"), N_("B"), N_("O"), N_("AB"), N_("Other"), NULL
 };
 
 static const gchar *genders[] = {
@@ -138,7 +138,7 @@
         "销售/广告/市场", NULL
 };
 
-static const gint choice_sizes[] = { 0, 13, 13, 5, 2, 7, 34, 15 };
+static const gint choice_sizes[] = { 0, 13, 13, 6, 2, 7, 34, 15 };
 
 
 static const gchar *info_group_headers[] = {
@@ -221,7 +221,7 @@
 
 	if (choice == 0) return FALSE;
 	len = strlen(value);
-	// the server sends us an ascii index and none of arrays has more than 99
+	// the server sends us an ascii index and none of the arrays has more than 99
 	// elements
 	if (len > 3 || len == 0) return FALSE;
 	for (i = 0; i < len; i++)
@@ -357,6 +357,11 @@
 
 static void modify_info_cancel_cb(modify_info_data *mid)
 {
+	qq_data *qd;
+
+	qd = (qq_data *) mid->gc->proto_data;
+	qd->modifying_info = FALSE;
+
 	g_list_free(mid->misc);
 	g_free(mid);
 }
@@ -378,7 +383,7 @@
 		value = g_strdup_printf("%d", gaim_request_field_choice_get_value(f));
 	else {
 		value = (gchar *) gaim_request_field_string_get_value(f);
-		if (value == NULL) value = g_strdup("");
+		if (value == NULL) value = g_strdup("-");
 		else value = utf8_to_qq(value, QQ_CHARSET_DEFAULT);
 	}
 	segments[ft->pos] = value;
@@ -401,12 +406,15 @@
 static void modify_info_ok_cb(modify_info_data *mid, GaimRequestFields *fields)
 {
 	GaimConnection *gc;
+	qq_data *qd;
 	GList *list,  *groups, *group_node;
 	gchar *info_field[QQ_CONTACT_FIELDS];
 	contact_info *info;
 	gint i;
 
 	gc = mid->gc;
+	qd = (qq_data *) gc->proto_data;
+	qd->modifying_info = FALSE;
 	list = mid->misc;
 	g_list_foreach(list, parse_misc_field, info_field);
 	g_list_free(list);
@@ -469,6 +477,7 @@
 // a form using those values and the info_template.
 static void create_modify_info_dialogue(GaimConnection *gc, const gchar **info)
 {
+	qq_data *qd;
 	GaimRequestFields *fields;
 	GaimRequestFieldGroup *group;
 	GaimRequestField *field;
@@ -476,32 +485,38 @@
 	modify_info_data *mid;
 	gint i;
 
-	fields = gaim_request_fields_new();
-	
-	// we only care about the first 3 groups, not the miscellaneous stuff
-	for (i = 0; i < 3; i++) {
-		group = gaim_request_field_group_new(info_group_headers[i]);
-		gaim_request_fields_add_group(fields, group);
-		group_list = info_get_group(info, info_group_headers[i]);
-		g_list_foreach(group_list, setup_group, group);
-		g_list_free(group_list);
-	}
+	// so we only have one dialog open at a time
+	qd = (qq_data *) gc->proto_data;
+	if (!qd->modifying_info) {
+		qd->modifying_info = TRUE;
 
-	//set this manually here instead of generating a new template column
-	field = gaim_request_fields_get_field(fields, "uid");
-	gaim_request_field_string_set_editable(field, FALSE);
+		fields = gaim_request_fields_new();
+	
+		// we only care about the first 3 groups, not the miscellaneous stuff
+		for (i = 0; i < 3; i++) {
+			group = gaim_request_field_group_new(info_group_headers[i]);
+			gaim_request_fields_add_group(fields, group);
+			group_list = info_get_group(info, info_group_headers[i]);
+			g_list_foreach(group_list, setup_group, group);
+			g_list_free(group_list);
+		}
 
-	//we need to pass the info that doesn't get modified as aux data
-	//because we'll still need it when we send the modify_info packet
-	mid = g_new0(modify_info_data, 1);
-	mid->gc = gc;
-	mid->misc = info_get_group(info, info_group_headers[3]);
+		//set this manually here instead of generating a new template column
+		field = gaim_request_fields_get_field(fields, "uid");
+		gaim_request_field_string_set_editable(field, FALSE);
+
+		//we need to pass the info that doesn't get modified as aux data
+		//because we'll still need it when we send the modify_info packet
+		mid = g_new0(modify_info_data, 1);
+		mid->gc = gc;
+		mid->misc = info_get_group(info, info_group_headers[3]);
 	
-	gaim_request_fields(gc, _("Modify my information"),
+		gaim_request_fields(gc, _("Modify my information"),
 			_("Modify my information"), NULL, fields,
 			_("Update my information"), G_CALLBACK(modify_info_ok_cb),
 			_("Cancel"), G_CALLBACK(modify_info_cancel_cb),
 			mid);
+	}
 }
 
 // process the reply of modify_info packet
@@ -519,6 +534,7 @@
 	data = g_newa(guint8, len);
 
 	if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) {
+		data[len] = '\0';
 		if (qd->uid == atoi((gchar *) data)) {	// return should be my uid
 			gaim_debug(GAIM_DEBUG_INFO, "QQ", "Update info ACK OK\n");
 			gaim_notify_info(gc, NULL, _("Your information has been updated"), NULL);
@@ -559,10 +575,6 @@
 	g_free(alias_utf8);
 }
 
-// XXX When we don't have any immediate response, we send duplicate get info packets 
-// to the server. If the server ends up responding to multiple packets, we get multiple
-// modify info dialogues, which is annoying. Fix this.
-
 // process reply to get_info packet
 void qq_process_get_info_reply(guint8 *buf, gint buf_len, GaimConnection *gc)
 {
--- a/src/protocols/qq/qq.h	Tue Jul 25 01:25:04 2006 +0000
+++ b/src/protocols/qq/qq.h	Tue Jul 25 04:31:36 2006 +0000
@@ -102,6 +102,8 @@
 	GList *info_query;
 	GList *add_buddy_request;
 	GQueue *before_login_packets;
+
+	gboolean modifying_info;
 };
 
 void qq_function_not_implemented(GaimConnection * gc);