annotate src/protocols/qq/buddy_info.c @ 14014:9c5790820ac6

[gaim-migrate @ 16606] QQ no longer supports changing one's password through the client. Users must go to password.qq.com instead. I also squashed a compiler warning. committer: Tailor Script <tailor@pidgin.im>
author Mark Huetsch <markhuetsch>
date Tue, 01 Aug 2006 16:15:39 +0000
parents dd19c67be844
children ef8490f9e823
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
1 /**
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
2 * The QQ2003C protocol plugin
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
3 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
4 * for gaim
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
5 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
6 * Copyright (C) 2004 Puzzlebird
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
7 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
11 * (at your option) any later version.
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
12 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
16 * GNU General Public License for more details.
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
17 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
21 */
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
22
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
23 #include "internal.h" // strlen, _("get_text)
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
24 #include "debug.h" // gaim_debug
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
25 #include "notify.h" // gaim_notify
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
26 #include "request.h" // gaim_request_fields_new
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
27
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
28 #include "utils.h" // uid_to_gaim_name
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
29 #include "packet_parse.h" // MAX_PACKET_SIZE
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
30 #include "buddy_info.h" //
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
31 #include "char_conv.h" // qq_to_utf8
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
32 #include "crypt.h" // qq_crypt
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
33 #include "header_info.h" // cmd alias
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
34 #include "keep_alive.h" // qq_update_buddy_contact
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
35 #include "send_core.h" // qq_send_cmd
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
36
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
37 // Below is all of the information necessary to reconstruct the various
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
38 // information fields that one can set in the official client. When we need
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
39 // to know about a specific field (e.g., should "city" be a choice
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
40 // or text field?), we can simply look it up from the template. Note that
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
41 // there are a number of unidentified fields.
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
42
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
43 typedef struct _info_field {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
44 gchar *title;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
45 gchar *id; // used by gaim_request fields
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
46 gint pos;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
47 gchar *group;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
48 gint group_pos; // for display order in the UI
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
49 gint choice; // indicates which character array contains the choices
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
50 gboolean customizable; // whether a user can enter any text as a value, regardless of choice arrays
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
51 gchar *value;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
52 } info_field;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
53
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
54 static const info_field info_template_data[] = {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
55 { N_("User ID"), "uid", 0, QQ_MAIN_INFO, 0, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
56 { N_("Nickname"), "nick", 1, QQ_MAIN_INFO, 1, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
57 { N_("Country/Region"), "country", 2, QQ_MAIN_INFO, 5, QQ_COUNTRY, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
58 { N_("Province/State"), "province", 3, QQ_MAIN_INFO, 6, QQ_PROVINCE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
59 { N_("Zipcode"), "zipcode", 4, QQ_EXTRA_INFO, 7, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
60 { N_("Address"), "address", 5, QQ_EXTRA_INFO, 6, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
61 { N_("Phone Number"), "tel", 6, QQ_EXTRA_INFO, 9, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
62 { N_("Age"), "age", 7, QQ_MAIN_INFO, 3, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
63 { N_("Gender"), "gender", 8, QQ_MAIN_INFO, 4, QQ_GENDER, FALSE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
64 { N_("Name"), "name", 9, QQ_MAIN_INFO, 2, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
65 { N_("Email"), "email", 10, QQ_EXTRA_INFO, 5, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
66 { "pager_sn", "pager_sn", 11, QQ_MISC, 0, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
67 { "pager_num", "pager_num", 12, QQ_MISC, 1, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
68 { "pager_sp", "pager_sp", 13, QQ_MISC, 2, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
69 { "pager_base_num", "pager_base_num", 14, QQ_MISC, 3, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
70 { "pager_type", "pager_type", 15, QQ_MISC, 4, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
71 { N_("Occupation"), "occupation", 16, QQ_EXTRA_INFO, 1, QQ_OCCUPATION, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
72 { N_("Homepage"), "homepage", 17, QQ_EXTRA_INFO, 10, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
73 { "auth_type", "auth_type", 18, QQ_MISC, 5, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
74 { "unknown1", "unknown1", 19, QQ_MISC, 6, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
75 { "unknown2", "unknown2", 20, QQ_MISC, 7, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
76 { "face", "face", 21, QQ_MISC, 8, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
77 { N_("Cellphone Number"), "hp_num", 22, QQ_EXTRA_INFO, 8, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
78 { "hp_type", "hp_type", 23, QQ_MISC, 9, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
79 { N_("Personal Introduction"), "intro", 24, QQ_PERSONAL_INTRO, 0, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
80 { N_("City"), "city", 25, QQ_MAIN_INFO, 7, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
81 { "unknown3", "unknown3", 26, QQ_MISC, 10, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
82 { "unknown4", "unknown4", 27, QQ_MISC, 11, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
83 { "unknown5", "unknown5", 28, QQ_MISC, 12, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
84 { "is_open_hp", "is_open_hp", 29, QQ_MISC, 13, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
85 { "is_open_contact", "is_open_contact", 30, QQ_MISC, 14, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
86 { N_("College"), "college", 31, QQ_EXTRA_INFO, 4, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
87 { N_("Horoscope Symbol"), "horoscope", 32, QQ_EXTRA_INFO, 0, QQ_HOROSCOPE, FALSE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
88 { N_("Zodiac Symbol"), "zodiac", 33, QQ_EXTRA_INFO, 2, QQ_ZODIAC, FALSE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
89 { N_("Blood Type"), "blood", 34, QQ_EXTRA_INFO, 3, QQ_BLOOD, FALSE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
90 { "qq_show", "qq_show", 35, QQ_MISC, 15, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
91 { "unknown6", "unknown6", 36, QQ_MISC, 16, QQ_NO_CHOICE, TRUE, NULL },
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
92 { NULL, NULL, 0, NULL, 0, 0, 0, NULL } //NULL termination
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
93 };
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
94
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
95 //TODO: translate these arrays to their English equivalents
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
96 // and move these characters to the zh_CN po file
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
97 static const gchar *horoscope_names[] = {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
98 "-", "水瓶座", "双鱼座", "牡羊座", "金牛座",
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
99 "双子座", "巨蟹座", "狮子座", "处女座", "天秤座",
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
100 "天蝎座", "射手座", "魔羯座", NULL
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
101 };
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
102
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
103 static const gchar *zodiac_names[] = {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
104 "-", "鼠", "牛", "虎", "兔",
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
105 "龙", "蛇", "马", "羊", "猴",
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
106 "鸡", "狗", "猪", NULL
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
107 };
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
108
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
109 static const gchar *blood_types[] = {
13993
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
110 "-", N_("A"), N_("B"), N_("O"), N_("AB"), N_("Other"), NULL
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
111 };
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
112
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
113 static const gchar *genders[] = {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
114 N_("Male"),
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
115 N_("Female"),
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
116 NULL
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
117 };
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
118
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
119 static const gchar *country_names[] = {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
120 "中国", "中国香港", "中国澳门", "中国台湾",
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
121 "新加坡", "马来西亚", "美国", NULL
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
122 };
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
123
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
124 static const gchar *province_names[] = {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
125 "北京", "天津", "上海", "重庆", "香港",
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
126 "河北", "山西", "内蒙古", "辽宁", "吉林",
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
127 "黑龙江", "江西", "浙江", "江苏", "安徽",
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
128 "福建", "山东", "河南", "湖北", "湖南",
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
129 "广东", "广西", "海南", "四川", "贵州",
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
130 "云南", "西藏", "陕西", "甘肃", "宁夏",
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
131 "青海", "新疆", "台湾", "澳门", NULL
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
132 };
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
133
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
134 static const gchar *occupation_names[] = {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
135 "全职", "兼职", "制造业", "商业", "失业中",
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
136 "学生", "工程师", "政府部门", "教育业", "服务行业",
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
137 "老板", "计算机业", "退休", "金融业",
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
138 "销售/广告/市场", NULL
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
139 };
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
140
13993
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
141 static const gint choice_sizes[] = { 0, 13, 13, 6, 2, 7, 34, 15 };
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
142
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
143
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
144 static const gchar *info_group_headers[] = {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
145 QQ_MAIN_INFO,
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
146 QQ_EXTRA_INFO,
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
147 QQ_PERSONAL_INTRO,
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
148 QQ_MISC
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
149 };
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
150
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
151 static const gchar **choices[] = {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
152 NULL,
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
153 horoscope_names,
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
154 zodiac_names,
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
155 blood_types,
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
156 genders,
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
157 country_names,
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
158 province_names,
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
159 occupation_names
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
160 };
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
161
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
162 /*************** info and info_field methods *****************/
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
163
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
164 // Given an id, return the template for that field.
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
165 // Returns NULL if the id is not found.
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
166 static const info_field *info_field_get_template(const gchar *id)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
167 {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
168 const info_field *cur_field;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
169 const gchar *cur_id;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
170
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
171 cur_field = info_template_data;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
172 cur_id = cur_field->id;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
173 while(cur_id != NULL) {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
174 if (g_ascii_strcasecmp(cur_id, id) == 0) return cur_field;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
175 cur_field++;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
176 cur_id = cur_field->id;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
177 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
178 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Info field with id %s not found!", id);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
179 return NULL;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
180 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
181
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
182 // info_fields are compared by their group positions
14014
9c5790820ac6 [gaim-migrate @ 16606]
Mark Huetsch <markhuetsch>
parents: 13999
diff changeset
183 static gint info_field_compare(gconstpointer a, gconstpointer b)
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
184 {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
185 return ((info_field *) a)->group_pos - ((info_field *) b)->group_pos;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
186 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
187
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
188 static void info_field_free(info_field *i)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
189 {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
190 g_free(i->value);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
191 g_free(i);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
192 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
193
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
194 // Parses the info_template_data above and returns a newly-allocated list
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
195 // containing the desired fields from segments. This list is ordered by
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
196 // group_pos.
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
197 static GList *info_get_group(const gchar **info, const gchar *group_name)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
198 {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
199 const info_field *cur;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
200 info_field *entry;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
201 GList *group = NULL;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
202
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
203 cur = info_template_data;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
204 while (cur->id != NULL) {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
205 if (g_ascii_strcasecmp(group_name, cur->group) == 0) {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
206 entry = g_memdup(cur, sizeof(info_field));
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
207 entry->value = g_strdup(info[entry->pos]);
13999
dd19c67be844 [gaim-migrate @ 16584]
Sean Egan <seanegan@gmail.com>
parents: 13993
diff changeset
208 group = g_list_insert_sorted(group, entry, info_field_compare);
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
209 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
210 cur++;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
211 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
212
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
213 return group;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
214 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
215
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
216 // determines if the given text value and choice group require
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
217 // a lookup from the choice arrays
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
218 static gboolean is_valid_index(gchar *value, gint choice)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
219 {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
220 gint len, i;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
221
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
222 if (choice == 0) return FALSE;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
223 len = strlen(value);
13993
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
224 // the server sends us an ascii index and none of the arrays has more than 99
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
225 // elements
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
226 if (len > 3 || len == 0) return FALSE;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
227 for (i = 0; i < len; i++)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
228 if (!g_ascii_isdigit(value[i])) return FALSE;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
229 i = atoi(value);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
230 if (i < 0 || i >= choice_sizes[choice]) return FALSE;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
231 return TRUE;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
232 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
233
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
234 // formats a field for printing
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
235 static void append_field_to_str(gpointer field, gpointer str)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
236 {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
237 info_field *f;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
238 gint choice;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
239 gboolean valid_index;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
240 gchar *value;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
241
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
242 f = (info_field *) field;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
243 choice = f->choice;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
244 valid_index = is_valid_index(f->value, choice);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
245 if (choice && valid_index) value = g_strdup(choices[choice][atoi(f->value)]);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
246 else value = qq_to_utf8(f->value, QQ_CHARSET_DEFAULT);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
247 g_string_append_printf((GString *) str, "<b>%s:</b> %s<br />",
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
248 f->title, value);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
249 g_free(value);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
250 info_field_free(f);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
251 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
252
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
253 // formats a group of information for printing
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
254 static void append_group_to_str(GString *str, const gchar *group_name, const gchar **info)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
255 {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
256 GList *group;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
257
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
258 group = info_get_group(info, group_name);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
259 g_string_append_printf(str, "<b>%s</b><br /><br />", (*(info_field *) group->data).group);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
260 g_list_foreach(group, append_field_to_str, str);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
261 g_list_free(group);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
262 g_string_append_printf(str, "<br />");
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
263 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
264
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
265 // takes a contact_info struct and outputs the appropriate fields in
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
266 // a printable format for our upcoming call to gaim_notify_userinfo
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
267 static GString *info_to_str(const gchar **info)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
268 {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
269 GString *info_text;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
270
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
271 info_text = g_string_new("");
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
272 append_group_to_str(info_text, QQ_MAIN_INFO, info);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
273 append_group_to_str(info_text, QQ_EXTRA_INFO, info);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
274 append_group_to_str(info_text, QQ_PERSONAL_INTRO, info);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
275 //if (QQ_DEBUG) append_group_to_str(info_text, QQ_MISC, info);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
276
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
277 return info_text;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
278 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
279
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
280 /*************** packets and UI management *****************/
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
281
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
282 // send a packet to get detailed information of uid
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
283 void qq_send_packet_get_info(GaimConnection * gc, guint32 uid, gboolean show_window)
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
284 {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
285 qq_data *qd;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
286 gchar *uid_str;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
287 qq_info_query *query;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
288
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
289 g_return_if_fail(gc != NULL && gc->proto_data != NULL && uid != 0);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
290
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
291 qd = (qq_data *) gc->proto_data;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
292 uid_str = g_strdup_printf("%d", uid);
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
293 qq_send_cmd(gc, QQ_CMD_GET_USER_INFO, TRUE, 0, TRUE, (guint8 *) uid_str, strlen(uid_str));
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
294
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
295 query = g_new0(qq_info_query, 1);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
296 query->uid = uid;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
297 query->show_window = show_window;
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
298 query->modify_info = FALSE;
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
299 qd->info_query = g_list_append(qd->info_query, query);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
300
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
301 g_free(uid_str);
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
302 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
303
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
304 // set up the fields requesting personal information and send a get_info packet
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
305 // for myself
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
306 void qq_prepare_modify_info(GaimConnection *gc)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
307 {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
308 qq_data *qd;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
309 GList *ql;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
310 qq_info_query *query;
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
311
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
312 qd = (qq_data *) gc->proto_data;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
313 qq_send_packet_get_info(gc, qd->uid, FALSE);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
314 // traverse backwards so we get the most recent info_query
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
315 for (ql = g_list_last(qd->info_query); ql != NULL; ql = g_list_previous(ql)) {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
316 query = ql->data;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
317 if (query->uid == qd->uid) query->modify_info = TRUE;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
318 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
319 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
320
14014
9c5790820ac6 [gaim-migrate @ 16606]
Mark Huetsch <markhuetsch>
parents: 13999
diff changeset
321 // send packet to modify personal information
9c5790820ac6 [gaim-migrate @ 16606]
Mark Huetsch <markhuetsch>
parents: 13999
diff changeset
322 void qq_send_packet_modify_info(GaimConnection *gc, contact_info *info)
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
323 {
14014
9c5790820ac6 [gaim-migrate @ 16606]
Mark Huetsch <markhuetsch>
parents: 13999
diff changeset
324 gchar *info_field[QQ_CONTACT_FIELDS];
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
325 gint i;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
326 guint8 *raw_data, *cursor, bar;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
327
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
328 g_return_if_fail(gc != NULL && info != NULL);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
329
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
330 bar = 0x1f;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
331 raw_data = g_newa(guint8, MAX_PACKET_SIZE - 128);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
332 cursor = raw_data;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
333
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
334 g_memmove(info_field, info, sizeof(gchar *) * QQ_CONTACT_FIELDS);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
335
14014
9c5790820ac6 [gaim-migrate @ 16606]
Mark Huetsch <markhuetsch>
parents: 13999
diff changeset
336 create_packet_b(raw_data, &cursor, bar);
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
337
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
338 // important!, skip the first uid entry
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
339 for (i = 1; i < QQ_CONTACT_FIELDS; i++) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
340 create_packet_b(raw_data, &cursor, bar);
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
341 create_packet_data(raw_data, &cursor, (guint8 *) info_field[i], strlen(info_field[i]));
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
342 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
343 create_packet_b(raw_data, &cursor, bar);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
344
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
345 qq_send_cmd(gc, QQ_CMD_UPDATE_INFO, TRUE, 0, TRUE, raw_data, cursor - raw_data);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
346
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
347 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
348
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
349 static void modify_info_cancel_cb(modify_info_data *mid)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
350 {
13993
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
351 qq_data *qd;
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
352
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
353 qd = (qq_data *) mid->gc->proto_data;
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
354 qd->modifying_info = FALSE;
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
355
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
356 g_list_free(mid->misc);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
357 g_free(mid);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
358 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
359
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
360 // runs through all of the fields in the modify info UI and put
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
361 // their values into the outgoing packet
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
362 static void parse_field(gpointer field, gpointer outgoing_info)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
363 {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
364 GaimRequestField *f;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
365 gchar **segments, *value;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
366 const info_field *ft;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
367 const gchar *id;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
368
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
369 f = (GaimRequestField *) field;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
370 segments = (gchar **) outgoing_info;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
371 id = gaim_request_field_get_id(f);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
372 ft = info_field_get_template(id);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
373 if (ft->choice && !ft->customizable)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
374 value = g_strdup_printf("%d", gaim_request_field_choice_get_value(f));
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
375 else {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
376 value = (gchar *) gaim_request_field_string_get_value(f);
13993
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
377 if (value == NULL) value = g_strdup("-");
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
378 else value = utf8_to_qq(value, QQ_CHARSET_DEFAULT);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
379 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
380 segments[ft->pos] = value;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
381 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
382
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
383 // dumps the uneditable information straight into the outgoing packet
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
384 static void parse_misc_field(gpointer field, gpointer outgoing_info)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
385 {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
386 info_field *f;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
387 gchar **segments;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
388
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
389 f = (info_field *) field;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
390 segments = (gchar **) outgoing_info;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
391 segments[f->pos] = g_strdup(f->value);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
392 info_field_free(f);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
393 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
394
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
395 // runs through all of the information fields and copies them into an
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
396 // outgoing packet, then sends that packet
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
397 static void modify_info_ok_cb(modify_info_data *mid, GaimRequestFields *fields)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
398 {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
399 GaimConnection *gc;
13993
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
400 qq_data *qd;
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
401 GList *list, *groups, *group_node;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
402 gchar *info_field[QQ_CONTACT_FIELDS];
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
403 contact_info *info;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
404 gint i;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
405
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
406 gc = mid->gc;
13993
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
407 qd = (qq_data *) gc->proto_data;
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
408 qd->modifying_info = FALSE;
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
409 list = mid->misc;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
410 g_list_foreach(list, parse_misc_field, info_field);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
411 g_list_free(list);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
412 groups = gaim_request_fields_get_groups(fields);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
413 while(groups) {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
414 group_node = groups;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
415 list = gaim_request_field_group_get_fields(group_node->data);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
416 g_list_foreach(list, parse_field, info_field);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
417 groups = g_list_remove_link(groups, group_node);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
418 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
419 info = (contact_info *) info_field;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
420
14014
9c5790820ac6 [gaim-migrate @ 16606]
Mark Huetsch <markhuetsch>
parents: 13999
diff changeset
421 qq_send_packet_modify_info(gc, info);
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
422 g_free(mid);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
423 for (i = 0; i < QQ_CONTACT_FIELDS; i++)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
424 g_free(info_field[i]);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
425 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
426
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
427 // Sets up the display for one group of information. This includes
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
428 // managing which fields in the UI should be textfields and
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
429 // which choices, and also mapping ints to choice values when appropriate.
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
430 static void setup_group(gpointer field, gpointer group)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
431 {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
432 info_field *f;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
433 GaimRequestFieldGroup *g;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
434 GaimRequestField *rf;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
435 gint choice, index, j;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
436 gboolean customizable, valid_index, multiline;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
437 gchar *id, *value;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
438
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
439 f = (info_field *) field;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
440 g = (GaimRequestFieldGroup *) group;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
441 choice = f->choice;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
442 customizable = f->customizable;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
443 id = f->id;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
444 valid_index = TRUE;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
445
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
446 if (!choice || customizable) {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
447 valid_index = is_valid_index(f->value, choice);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
448 multiline = id == "intro";
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
449 if (valid_index) {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
450 index = atoi(f->value);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
451 value = (gchar *) choices[choice][index];
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
452 } else value = qq_to_utf8(f->value, QQ_CHARSET_DEFAULT);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
453 rf = gaim_request_field_string_new(id, f->title, value, multiline);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
454 } else {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
455 index = atoi(f->value);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
456 value = (gchar *) choices[choice][index];
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
457 rf = gaim_request_field_choice_new(id, f->title, index);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
458 j = 0;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
459 while(choices[choice][j] != NULL)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
460 gaim_request_field_choice_add(rf, choices[choice][j++]);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
461 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
462 gaim_request_field_group_add_field(g, rf);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
463 if (!valid_index) g_free(value);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
464 info_field_free(f);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
465 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
466
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
467 // Takes the info returned by a get_info packet for the user and sets up
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
468 // a form using those values and the info_template.
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
469 static void create_modify_info_dialogue(GaimConnection *gc, const gchar **info)
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
470 {
13993
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
471 qq_data *qd;
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
472 GaimRequestFields *fields;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
473 GaimRequestFieldGroup *group;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
474 GaimRequestField *field;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
475 GList *group_list;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
476 modify_info_data *mid;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
477 gint i;
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
478
13993
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
479 // so we only have one dialog open at a time
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
480 qd = (qq_data *) gc->proto_data;
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
481 if (!qd->modifying_info) {
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
482 qd->modifying_info = TRUE;
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
483
13993
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
484 fields = gaim_request_fields_new();
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
485
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
486 // we only care about the first 3 groups, not the miscellaneous stuff
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
487 for (i = 0; i < 3; i++) {
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
488 group = gaim_request_field_group_new(info_group_headers[i]);
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
489 gaim_request_fields_add_group(fields, group);
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
490 group_list = info_get_group(info, info_group_headers[i]);
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
491 g_list_foreach(group_list, setup_group, group);
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
492 g_list_free(group_list);
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
493 }
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
494
13993
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
495 //set this manually here instead of generating a new template column
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
496 field = gaim_request_fields_get_field(fields, "uid");
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
497 gaim_request_field_string_set_editable(field, FALSE);
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
498
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
499 //we need to pass the info that doesn't get modified as aux data
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
500 //because we'll still need it when we send the modify_info packet
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
501 mid = g_new0(modify_info_data, 1);
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
502 mid->gc = gc;
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
503 mid->misc = info_get_group(info, info_group_headers[3]);
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
504
13993
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
505 gaim_request_fields(gc, _("Modify my information"),
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
506 _("Modify my information"), NULL, fields,
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
507 _("Update my information"), G_CALLBACK(modify_info_ok_cb),
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
508 _("Cancel"), G_CALLBACK(modify_info_cancel_cb),
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
509 mid);
13993
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
510 }
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
511 }
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
512
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
513 // process the reply of modify_info packet
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
514 void qq_process_modify_info_reply(guint8 *buf, gint buf_len, GaimConnection *gc)
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
515 {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
516 qq_data *qd;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
517 gint len;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
518 guint8 *data;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
519
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
520 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
521 g_return_if_fail(buf != NULL && buf_len != 0);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
522
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
523 qd = (qq_data *) gc->proto_data;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
524 len = buf_len;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
525 data = g_newa(guint8, len);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
526
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
527 if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) {
13993
e6977f9435a1 [gaim-migrate @ 16570]
Mark Huetsch <markhuetsch>
parents: 13989
diff changeset
528 data[len] = '\0';
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
529 if (qd->uid == atoi((gchar *) data)) { // return should be my uid
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
530 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Update info ACK OK\n");
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
531 gaim_notify_info(gc, NULL, _("Your information has been updated"), NULL);
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
532 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
533 } else
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
534 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt modify info reply\n");
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
535
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
536 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
537
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
538 // after getting info or modify myself, refresh the buddy list accordingly
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
539 void qq_refresh_buddy_and_myself(contact_info *info, GaimConnection *gc)
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
540 {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
541 GaimBuddy *b;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
542 qq_data *qd;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
543 qq_buddy *q_bud;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
544 gchar *alias_utf8;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
545
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
546 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
547 qd = (qq_data *) gc->proto_data;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
548
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
549 alias_utf8 = qq_to_utf8(info->nick, QQ_CHARSET_DEFAULT);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
550 if (qd->uid == strtol(info->uid, NULL, 10)) { // it is me
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
551 qd->my_icon = strtol(info->face, NULL, 10);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
552 if (alias_utf8 != NULL)
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
553 gaim_account_set_alias(gc->account, alias_utf8);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
554 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
555 // update buddy list (including myself, if myself is the buddy)
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
556 b = gaim_find_buddy(gc->account, uid_to_gaim_name(strtol(info->uid, NULL, 10)));
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
557 q_bud = (b == NULL) ? NULL : (qq_buddy *) b->proto_data;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
558 if (q_bud != NULL) { // I have this buddy
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
559 q_bud->age = strtol(info->age, NULL, 10);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
560 q_bud->gender = strtol(info->gender, NULL, 10);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
561 q_bud->icon = strtol(info->face, NULL, 10);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
562 if (alias_utf8 != NULL)
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
563 q_bud->nickname = g_strdup(alias_utf8);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
564 qq_update_buddy_contact(gc, q_bud);
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
565 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
566 g_free(alias_utf8);
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
567 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
568
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
569 // process reply to get_info packet
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
570 void qq_process_get_info_reply(guint8 *buf, gint buf_len, GaimConnection *gc)
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
571 {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
572 gint len;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
573 guint8 *data;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
574 gchar **segments;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
575 qq_info_query *query;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
576 qq_data *qd;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
577 contact_info *info;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
578 GList *list, *query_list;
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
579 GString *info_text;
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
580
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
581 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
582 g_return_if_fail(buf != NULL && buf_len != 0);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
583
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
584 qd = (qq_data *) gc->proto_data;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
585 list = query_list = NULL;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
586 len = buf_len;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
587 data = g_newa(guint8, len);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
588 info = NULL;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
589
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
590 if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
591 if (NULL == (segments = split_data(data, len, "\x1e", QQ_CONTACT_FIELDS)))
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
592 return;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
593
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
594 info = (contact_info *) segments;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
595 qq_refresh_buddy_and_myself(info, gc);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
596
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
597 query_list = qd->info_query;
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
598 // ensure we're processing the right query
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
599 while (query_list) {
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
600 query = (qq_info_query *) query_list->data;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
601 if (query->uid == atoi(info->uid)) {
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
602 if (query->show_window) {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
603 info_text = info_to_str((const gchar **) segments);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
604 gaim_notify_userinfo(gc, info->uid, info_text->str, NULL, NULL);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
605 g_string_free(info_text, TRUE);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
606 } else if (query->modify_info) {
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
607 create_modify_info_dialogue(gc, (const gchar **) segments);
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
608 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
609 qd->info_query = g_list_remove(qd->info_query, qd->info_query->data);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
610 g_free(query);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
611 break;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
612 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
613 query_list = query_list->next;
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
614 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
615
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
616 g_strfreev(segments);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
617 } else
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
618 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt get info reply\n");
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
619
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
620 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
621
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
622 void qq_info_query_free(qq_data * qd)
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
623 {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
624 gint i;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
625 qq_info_query *p;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
626
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
627 g_return_if_fail(qd != NULL);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
628
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
629 i = 0;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
630 while (qd->info_query != NULL) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
631 p = (qq_info_query *) (qd->info_query->data);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
632 qd->info_query = g_list_remove(qd->info_query, p);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
633 g_free(p);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
634 i++;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
635 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
636 gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d info queries are freed!\n", i);
13989
16102b9c5c4a [gaim-migrate @ 16562]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
637 }