annotate src/protocols/qq/buddy_info.c @ 14115:8ea1929c4c69

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