annotate libgaim/protocols/qq/buddy_info.c @ 14812:399d4ccb34db

[gaim-migrate @ 17578] Some of these were out of order committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 24 Oct 2006 22:09:56 +0000
parents 6b8bc59414f0
children c039c920e11c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
1 /**
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
2 * The QQ2003C protocol plugin
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
3 *
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
4 * for gaim
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
5 *
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
6 * Copyright (C) 2004 Puzzlebird
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
7 *
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
11 * (at your option) any later version.
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
12 *
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
16 * GNU General Public License for more details.
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
17 *
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
21 */
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
22
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
23 #include "internal.h"
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
24 #include "debug.h"
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
25 #include "notify.h"
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
26 #include "request.h"
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
27
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
28 #include "utils.h"
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
29 #include "packet_parse.h"
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
30 #include "buddy_info.h"
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
31 #include "char_conv.h"
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
32 #include "crypt.h"
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
33 #include "header_info.h"
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
34 #include "keep_alive.h"
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
35 #include "send_core.h"
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
36
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
37 #define QQ_PRIMARY_INFORMATION _("Primary Information")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
38 #define QQ_ADDITIONAL_INFORMATION _("Additional Information")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
39 #define QQ_INTRO _("Personal Introduction")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
40 #define QQ_NUMBER _("QQ Number")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
41 #define QQ_NICKNAME _("Nickname")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
42 #define QQ_NAME _("Name")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
43 #define QQ_AGE _("Age")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
44 #define QQ_GENDER _("Gender")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
45 #define QQ_COUNTRY _("Country/Region")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
46 #define QQ_PROVINCE _("Province/State")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
47 #define QQ_CITY _("City")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
48 #define QQ_HOROSCOPE _("Horoscope Symbol")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
49 #define QQ_OCCUPATION _("Occupation")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
50 #define QQ_ZODIAC _("Zodiac Sign")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
51 #define QQ_BLOOD _("Blood Type")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
52 #define QQ_COLLEGE _("College")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
53 #define QQ_EMAIL _("Email")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
54 #define QQ_ADDRESS _("Address")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
55 #define QQ_ZIPCODE _("Zipcode")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
56 #define QQ_CELL _("Cellphone Number")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
57 #define QQ_TELEPHONE _("Phone Number")
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
58 #define QQ_HOMEPAGE _("Homepage")
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
59
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
60 #define QQ_HOROSCOPE_SIZE 13
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
61 static const gchar *horoscope_names[] = {
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
62 "-", N_("Aquarius"), N_("Pisces"), N_("Aries"), N_("Taurus"),
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
63 N_("Gemini"), N_("Cancer"), N_("Leo"), N_("Virgo"), N_("Libra"),
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
64 N_("Scorpio"), N_("Sagittarius"), N_("Capricorn")
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
65 };
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
66
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
67 #define QQ_ZODIAC_SIZE 13
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
68 static const gchar *zodiac_names[] = {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
69 "-", N_("Rat"), N_("Ox"), N_("Tiger"), N_("Rabbit"),
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
70 N_("Dragon"), N_("Snake"), N_("Horse"), N_("Goat"), N_("Monkey"),
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
71 N_("Rooster"), N_("Dog"), N_("Pig")
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
72 };
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
73
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
74 #define QQ_BLOOD_SIZE 6
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
75 static const gchar *blood_types[] = {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
76 "-", "A", "B", "O", "AB", N_("Other")
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
77 };
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
78
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
79 #define QQ_GENDER_SIZE 2
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
80 static const gchar *genders[] = {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
81 N_("Male"),
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
82 N_("Female")
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
83 };
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
84
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
85 #define QQ_CONTACT_FIELDS 37
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
86
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
87 /* There is no user id stored in the reply packet for information query
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
88 * we have to manually store the query, so that we know the query source */
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
89 typedef struct _qq_info_query {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
90 guint32 uid;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
91 gboolean show_window;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
92 gboolean modify_info;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
93 } qq_info_query;
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
94
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
95 /* We get an info packet on ourselves before we modify our information.
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
96 * Even though not all of the information is modifiable, it still
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
97 * all needs to be there when we send out the modify info packet */
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
98 typedef struct _modify_info_data {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
99 GaimConnection *gc;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
100 contact_info *info;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
101 } modify_info_data;
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
102
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
103 /* return -1 as a sentinel */
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
104 static gint choice_index(const gchar *value, const gchar **choice, gint choice_size)
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
105 {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
106 gint len, i;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
107
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
108 len = strlen(value);
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
109 if (len > 3 || len == 0) return -1;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
110 for (i = 0; i < len; i++) {
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
111 if (!g_ascii_isdigit(value[i]))
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
112 return -1;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
113 }
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
114 i = strtol(value, NULL, 10);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
115 if (i >= choice_size)
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
116 return -1;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
117
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
118 return i;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
119 }
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
120
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
121 /* return should be freed */
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
122 static gchar *field_value(const gchar *field, const gchar **choice, gint choice_size)
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
123 {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
124 gint index, len;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
125
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
126 len = strlen(field);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
127 if (len == 0) {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
128 return NULL;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
129 } else if (choice != NULL) {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
130 /* some choice fields are also customizable */
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
131 index = choice_index(field, choice, choice_size);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
132 if (index == -1) {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
133 if (strcmp(field, "-") != 0) {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
134 return qq_to_utf8(field, QQ_CHARSET_DEFAULT);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
135 } else {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
136 return NULL;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
137 }
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
138 /* else ASCIIized index */
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
139 } else {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
140 if (strcmp(choice[index], "-") != 0)
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
141 return g_strdup(choice[index]);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
142 else
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
143 return NULL;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
144 }
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
145 } else {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
146 if (strcmp(field, "-") != 0) {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
147 return qq_to_utf8(field, QQ_CHARSET_DEFAULT);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
148 } else {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
149 return NULL;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
150 }
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
151 }
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
152 }
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
153
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
154 static void append_field_value(GString *info_text, const gchar *field,
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
155 const gchar *title, const gchar **choice, gint choice_size)
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
156 {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
157 gchar *value = field_value(field, choice, choice_size);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
158
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
159 if (value != NULL) {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
160 g_string_append_printf(info_text, "<br /><b>%s:</b> %s", title, value);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
161 g_free(value);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
162 }
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
163 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
164
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
165 static GString *info_to_str(const contact_info *info)
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
166 {
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
167 GString *info_text, *extra_info;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
168 const gchar *intro;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
169 gint len;
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
170
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
171 info_text = g_string_new("");
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
172 g_string_append_printf(info_text, "<b>%s</b><br /><br />", QQ_PRIMARY_INFORMATION);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
173 g_string_append_printf(info_text, "<b>%s:</b> %s", QQ_NUMBER, info->uid);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
174 append_field_value(info_text, info->nick, QQ_NICKNAME, NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
175 append_field_value(info_text, info->name, QQ_NAME, NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
176 append_field_value(info_text, info->age, QQ_AGE, NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
177 append_field_value(info_text, info->gender, QQ_GENDER, genders, QQ_GENDER_SIZE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
178 append_field_value(info_text, info->country, QQ_COUNTRY, NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
179 append_field_value(info_text, info->province, QQ_PROVINCE, NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
180 append_field_value(info_text, info->city, QQ_CITY, NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
181
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
182 extra_info = g_string_new("");
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
183 g_string_append_printf(extra_info, "<br /><br /><b>%s</b><br />", QQ_ADDITIONAL_INFORMATION);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
184 len = extra_info->len;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
185 append_field_value(extra_info, info->horoscope, QQ_HOROSCOPE, horoscope_names, QQ_HOROSCOPE_SIZE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
186 append_field_value(extra_info, info->occupation, QQ_OCCUPATION, NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
187 append_field_value(extra_info, info->zodiac, QQ_ZODIAC, zodiac_names, QQ_ZODIAC_SIZE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
188 append_field_value(extra_info, info->blood, QQ_BLOOD, blood_types, QQ_BLOOD_SIZE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
189 append_field_value(extra_info, info->college, QQ_COLLEGE, NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
190 append_field_value(extra_info, info->email, QQ_EMAIL, NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
191 append_field_value(extra_info, info->address, QQ_ADDRESS, NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
192 append_field_value(extra_info, info->zipcode, QQ_ZIPCODE, NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
193 append_field_value(extra_info, info->hp_num, QQ_CELL, NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
194 append_field_value(extra_info, info->tel, QQ_TELEPHONE, NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
195 append_field_value(extra_info, info->homepage, QQ_HOMEPAGE, NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
196 if (len != extra_info->len)
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
197 g_string_append(info_text, extra_info->str);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
198 g_string_free(extra_info, TRUE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
199
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
200 intro = field_value(info->intro, NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
201 if (intro) {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
202 g_string_append_printf(info_text, "<br /><br /><b>%s</b><br /><br />", QQ_INTRO);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
203 g_string_append(info_text, intro);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
204 }
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
205
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
206 /* for debugging */
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
207 /*
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
208 g_string_append_printf(info_text, "<br /><br /><b>%s</b><br />", "Miscellaneous");
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
209 append_field_value(info_text, info->pager_sn, "pager_sn", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
210 append_field_value(info_text, info->pager_num, "pager_num", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
211 append_field_value(info_text, info->pager_sp, "pager_sp", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
212 append_field_value(info_text, info->pager_base_num, "pager_base_num", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
213 append_field_value(info_text, info->pager_type, "pager_type", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
214 append_field_value(info_text, info->auth_type, "auth_type", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
215 append_field_value(info_text, info->unknown1, "unknown1", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
216 append_field_value(info_text, info->unknown2, "unknown2", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
217 append_field_value(info_text, info->face, "face", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
218 append_field_value(info_text, info->hp_type, "hp_type", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
219 append_field_value(info_text, info->unknown3, "unknown3", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
220 append_field_value(info_text, info->unknown4, "unknown4", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
221 append_field_value(info_text, info->unknown5, "unknown5", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
222 append_field_value(info_text, info->is_open_hp, "is_open_hp", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
223 append_field_value(info_text, info->is_open_contact, "is_open_contact", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
224 append_field_value(info_text, info->qq_show, "qq_show", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
225 append_field_value(info_text, info->unknown6, "unknown6", NULL, 0);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
226 */
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
227
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
228 return info_text;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
229 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
230
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
231 /* send a packet to get detailed information of uid */
14265
584cbd1628d0 [gaim-migrate @ 16947]
Mark Huetsch <markhuetsch>
parents: 14192
diff changeset
232 void qq_send_packet_get_info(GaimConnection *gc, guint32 uid, gboolean show_window)
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
233 {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
234 qq_data *qd;
14519
e548832f0e82 [gaim-migrate @ 17239]
Mark Huetsch <markhuetsch>
parents: 14265
diff changeset
235 gchar uid_str[11];
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
236 qq_info_query *query;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
237
14629
6b8bc59414f0 [gaim-migrate @ 17375]
Mark Huetsch <markhuetsch>
parents: 14611
diff changeset
238 g_return_if_fail(uid != 0);
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
239
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
240 qd = (qq_data *) gc->proto_data;
14519
e548832f0e82 [gaim-migrate @ 17239]
Mark Huetsch <markhuetsch>
parents: 14265
diff changeset
241 g_snprintf(uid_str, sizeof(uid_str), "%d", uid);
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
242 qq_send_cmd(gc, QQ_CMD_GET_USER_INFO, TRUE, 0, TRUE, (guint8 *) uid_str, strlen(uid_str));
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
243
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
244 query = g_new0(qq_info_query, 1);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
245 query->uid = uid;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
246 query->show_window = show_window;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
247 query->modify_info = FALSE;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
248 qd->info_query = g_list_append(qd->info_query, query);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
249 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
250
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
251 /* set up the fields requesting personal information and send a get_info packet
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
252 * for myself */
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
253 void qq_prepare_modify_info(GaimConnection *gc)
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
254 {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
255 qq_data *qd;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
256 GList *ql;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
257 qq_info_query *query;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
258
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
259 qd = (qq_data *) gc->proto_data;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
260 qq_send_packet_get_info(gc, qd->uid, FALSE);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
261 /* traverse backwards so we get the most recent info_query */
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
262 for (ql = g_list_last(qd->info_query); ql != NULL; ql = g_list_previous(ql)) {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
263 query = ql->data;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
264 if (query->uid == qd->uid)
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
265 query->modify_info = TRUE;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
266 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
267 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
268
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
269 /* send packet to modify personal information */
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
270 static void qq_send_packet_modify_info(GaimConnection *gc, gchar **segments)
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
271 {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
272 gint i;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
273 guint8 *raw_data, *cursor, bar;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
274
14629
6b8bc59414f0 [gaim-migrate @ 17375]
Mark Huetsch <markhuetsch>
parents: 14611
diff changeset
275 g_return_if_fail(segments != NULL);
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
276
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
277 bar = 0x1f;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
278 raw_data = g_newa(guint8, MAX_PACKET_SIZE - 128);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
279 cursor = raw_data;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
280
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
281 create_packet_b(raw_data, &cursor, bar);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
282
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
283 /* important! skip the first uid entry */
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
284 for (i = 1; i < QQ_CONTACT_FIELDS; i++) {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
285 create_packet_b(raw_data, &cursor, bar);
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
286 create_packet_data(raw_data, &cursor, (guint8 *) segments[i], strlen(segments[i]));
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
287 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
288 create_packet_b(raw_data, &cursor, bar);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
289
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
290 qq_send_cmd(gc, QQ_CMD_UPDATE_INFO, TRUE, 0, TRUE, raw_data, cursor - raw_data);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
291
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
292 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
293
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
294 static void modify_info_cancel_cb(modify_info_data *mid)
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
295 {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
296 qq_data *qd;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
297
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
298 qd = (qq_data *) mid->gc->proto_data;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
299 qd->modifying_info = FALSE;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
300
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
301 g_strfreev((gchar **) mid->info);
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
302 g_free(mid);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
303 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
304
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
305 static gchar *parse_field(GList **list, gboolean choice)
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
306 {
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
307 gchar *value;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
308 GaimRequestField *field;
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
309
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
310 field = (GaimRequestField *) (*list)->data;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
311 if (choice) {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
312 value = g_strdup_printf("%d", gaim_request_field_choice_get_value(field));
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
313 } else {
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
314 value = (gchar *) gaim_request_field_string_get_value(field);
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
315 if (value == NULL)
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
316 value = g_strdup("-");
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
317 else
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
318 value = utf8_to_qq(value, QQ_CHARSET_DEFAULT);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
319 }
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
320 *list = g_list_remove_link(*list, *list);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
321
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
322 return value;
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
323 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
324
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
325 /* parse fields and send info packet */
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
326 static void modify_info_ok_cb(modify_info_data *mid, GaimRequestFields *fields)
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
327 {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
328 GaimConnection *gc;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
329 qq_data *qd;
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
330 GList *list, *groups;
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
331 contact_info *info;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
332
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
333 gc = mid->gc;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
334 qd = (qq_data *) gc->proto_data;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
335 qd->modifying_info = FALSE;
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
336
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
337 info = mid->info;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
338
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
339 groups = gaim_request_fields_get_groups(fields);
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
340 list = gaim_request_field_group_get_fields(groups->data);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
341 info->uid = parse_field(&list, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
342 info->nick = parse_field(&list, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
343 info->name = parse_field(&list, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
344 info->age = parse_field(&list, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
345 info->gender = parse_field(&list, TRUE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
346 info->country = parse_field(&list, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
347 info->province = parse_field(&list, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
348 info->city = parse_field(&list, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
349 groups = g_list_remove_link(groups, groups);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
350 list = gaim_request_field_group_get_fields(groups->data);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
351 info->horoscope = parse_field(&list, TRUE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
352 info->occupation = parse_field(&list, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
353 info->zodiac = parse_field(&list, TRUE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
354 info->blood = parse_field(&list, TRUE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
355 info->college = parse_field(&list, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
356 info->email = parse_field(&list, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
357 info->address = parse_field(&list, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
358 info->zipcode = parse_field(&list, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
359 info->hp_num = parse_field(&list, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
360 info->tel = parse_field(&list, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
361 info->homepage = parse_field(&list, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
362 groups = g_list_remove_link(groups, groups);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
363 list = gaim_request_field_group_get_fields(groups->data);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
364 info->intro = parse_field(&list, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
365 groups = g_list_remove_link(groups, groups);
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
366
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
367 qq_send_packet_modify_info(gc, (gchar **) info);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
368
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
369 g_strfreev((gchar **) mid->info);
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
370 g_free(mid);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
371 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
372
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
373 static GaimRequestFieldGroup *setup_field_group(GaimRequestFields *fields, const gchar *title)
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
374 {
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
375 GaimRequestFieldGroup *group;
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
376
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
377 group = gaim_request_field_group_new(title);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
378 gaim_request_fields_add_group(fields, group);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
379
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
380 return group;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
381 }
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
382
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
383 static void add_string_field_to_group(GaimRequestFieldGroup *group,
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
384 const gchar *id, const gchar *title, const gchar *value)
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
385 {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
386 GaimRequestField *field;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
387 gchar *utf8_value;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
388
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
389 utf8_value = qq_to_utf8(value, QQ_CHARSET_DEFAULT);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
390 field = gaim_request_field_string_new(id, title, utf8_value, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
391 gaim_request_field_group_add_field(group, field);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
392 g_free(utf8_value);
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
393 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
394
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
395 static void add_choice_field_to_group(GaimRequestFieldGroup *group,
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
396 const gchar *id, const gchar *title, const gchar *value,
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
397 const gchar **choice, gint choice_size)
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
398 {
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
399 GaimRequestField *field;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
400 gint i, index;
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
401
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
402 index = choice_index(value, choice, choice_size);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
403 field = gaim_request_field_choice_new(id, title, index);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
404 for (i = 0; i < choice_size; i++)
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
405 gaim_request_field_choice_add(field, choice[i]);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
406 gaim_request_field_group_add_field(group, field);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
407 }
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
408
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
409 /* take the info returned by a get_info packet for myself and set up a request form */
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
410 static void create_modify_info_dialogue(GaimConnection *gc, const contact_info *info)
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
411 {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
412 qq_data *qd;
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
413 GaimRequestFieldGroup *group;
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
414 GaimRequestFields *fields;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
415 GaimRequestField *field;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
416 modify_info_data *mid;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
417
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
418 /* so we only have one dialog open at a time */
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
419 qd = (qq_data *) gc->proto_data;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
420 if (!qd->modifying_info) {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
421 qd->modifying_info = TRUE;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
422
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
423 fields = gaim_request_fields_new();
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
424
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
425 group = setup_field_group(fields, QQ_PRIMARY_INFORMATION);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
426 field = gaim_request_field_string_new("uid", QQ_NUMBER, info->uid, FALSE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
427 gaim_request_field_group_add_field(group, field);
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
428 gaim_request_field_string_set_editable(field, FALSE);
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
429 add_string_field_to_group(group, "nick", QQ_NICKNAME, info->nick);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
430 add_string_field_to_group(group, "name", QQ_NAME, info->name);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
431 add_string_field_to_group(group, "age", QQ_AGE, info->age);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
432 add_choice_field_to_group(group, "gender", QQ_GENDER, info->gender, genders, QQ_GENDER_SIZE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
433 add_string_field_to_group(group, "country", QQ_COUNTRY, info->country);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
434 add_string_field_to_group(group, "province", QQ_PROVINCE, info->province);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
435 add_string_field_to_group(group, "city", QQ_CITY, info->city);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
436 group = setup_field_group(fields, QQ_ADDITIONAL_INFORMATION);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
437 add_choice_field_to_group(group, "horoscope", QQ_HOROSCOPE, info->horoscope, horoscope_names, QQ_HOROSCOPE_SIZE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
438 add_string_field_to_group(group, "occupation", QQ_OCCUPATION, info->occupation);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
439 add_choice_field_to_group(group, "zodiac", QQ_ZODIAC, info->zodiac, zodiac_names, QQ_ZODIAC_SIZE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
440 add_choice_field_to_group(group, "blood", QQ_BLOOD, info->blood, blood_types, QQ_BLOOD_SIZE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
441 add_string_field_to_group(group, "college", QQ_COLLEGE, info->college);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
442 add_string_field_to_group(group, "email", QQ_EMAIL, info->email);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
443 add_string_field_to_group(group, "address", QQ_ADDRESS, info->address);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
444 add_string_field_to_group(group, "zipcode", QQ_ZIPCODE, info->zipcode);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
445 add_string_field_to_group(group, "hp_num", QQ_CELL, info->hp_num);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
446 add_string_field_to_group(group, "tel", QQ_TELEPHONE, info->tel);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
447 add_string_field_to_group(group, "homepage", QQ_HOMEPAGE, info->homepage);
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
448
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
449 group = setup_field_group(fields, QQ_INTRO);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
450 field = gaim_request_field_string_new("intro", QQ_INTRO, info->intro, TRUE);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
451 gaim_request_field_group_add_field(group, field);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
452
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
453 /* prepare unmodifiable info */
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
454 mid = g_new0(modify_info_data, 1);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
455 mid->gc = gc;
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
456 /* QQ_CONTACT_FIELDS+1 so that the array is NULL-terminated and can be g_strfreev()'ed later */
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
457 mid->info = (contact_info *) g_new0(gchar *, QQ_CONTACT_FIELDS+1);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
458 mid->info->pager_sn = g_strdup(info->pager_sn);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
459 mid->info->pager_num = g_strdup(info->pager_num);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
460 mid->info->pager_sp = g_strdup(info->pager_sp);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
461 mid->info->pager_base_num = g_strdup(info->pager_base_num);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
462 mid->info->pager_type = g_strdup(info->pager_type);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
463 mid->info->auth_type = g_strdup(info->auth_type);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
464 mid->info->unknown1 = g_strdup(info->unknown1);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
465 mid->info->unknown2 = g_strdup(info->unknown2);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
466 mid->info->face = g_strdup(info->face);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
467 mid->info->hp_type = g_strdup(info->hp_type);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
468 mid->info->unknown3 = g_strdup(info->unknown3);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
469 mid->info->unknown4 = g_strdup(info->unknown4);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
470 mid->info->unknown5 = g_strdup(info->unknown5);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
471 /* TODO stop hiding these 2 */
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
472 mid->info->is_open_hp = g_strdup(info->is_open_hp);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
473 mid->info->is_open_contact = g_strdup(info->is_open_contact);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
474 mid->info->qq_show = g_strdup(info->qq_show);
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
475 mid->info->unknown6 = g_strdup(info->unknown6);
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
476
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
477 gaim_request_fields(gc, _("Modify my information"),
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
478 _("Modify my information"), NULL, fields,
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
479 _("Update my information"), G_CALLBACK(modify_info_ok_cb),
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
480 _("Cancel"), G_CALLBACK(modify_info_cancel_cb),
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
481 mid);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
482 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
483 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
484
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
485 /* process the reply of modify_info packet */
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
486 void qq_process_modify_info_reply(guint8 *buf, gint buf_len, GaimConnection *gc)
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
487 {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
488 qq_data *qd;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
489 gint len;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
490 guint8 *data;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
491
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
492 g_return_if_fail(buf != NULL && buf_len != 0);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
493
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
494 qd = (qq_data *) gc->proto_data;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
495 len = buf_len;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
496 data = g_newa(guint8, len);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
497
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
498 if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
499 data[len] = '\0';
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
500 if (qd->uid == atoi((gchar *) data)) { /* return should be my uid */
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
501 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Update info ACK OK\n");
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
502 gaim_notify_info(gc, NULL, _("Your information has been updated"), NULL);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
503 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
504 } else {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
505 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt modify info reply\n");
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
506 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
507 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
508
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
509 /* after getting info or modify myself, refresh the buddy list accordingly */
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
510 void qq_refresh_buddy_and_myself(contact_info *info, GaimConnection *gc)
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
511 {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
512 GaimBuddy *b;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
513 qq_data *qd;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
514 qq_buddy *q_bud;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
515 gchar *alias_utf8;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
516
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
517 qd = (qq_data *) gc->proto_data;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
518
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
519 alias_utf8 = qq_to_utf8(info->nick, QQ_CHARSET_DEFAULT);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
520 if (qd->uid == strtol(info->uid, NULL, 10)) { /* it is me */
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
521 qd->my_icon = strtol(info->face, NULL, 10);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
522 if (alias_utf8 != NULL)
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
523 gaim_account_set_alias(gc->account, alias_utf8);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
524 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
525 /* update buddy list (including myself, if myself is the buddy) */
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
526 b = gaim_find_buddy(gc->account, uid_to_gaim_name(strtol(info->uid, NULL, 10)));
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
527 q_bud = (b == NULL) ? NULL : (qq_buddy *) b->proto_data;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
528 if (q_bud != NULL) { /* I have this buddy */
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
529 q_bud->age = strtol(info->age, NULL, 10);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
530 q_bud->gender = strtol(info->gender, NULL, 10);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
531 q_bud->icon = strtol(info->face, NULL, 10);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
532 if (alias_utf8 != NULL)
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
533 q_bud->nickname = g_strdup(alias_utf8);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
534 qq_update_buddy_contact(gc, q_bud);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
535 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
536 g_free(alias_utf8);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
537 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
538
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
539 /* process reply to get_info packet */
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
540 void qq_process_get_info_reply(guint8 *buf, gint buf_len, GaimConnection *gc)
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
541 {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
542 gint len;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
543 guint8 *data;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
544 gchar **segments;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
545 qq_info_query *query;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
546 qq_data *qd;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
547 contact_info *info;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
548 GList *list, *query_list;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
549 GString *info_text;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
550
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
551 g_return_if_fail(buf != NULL && buf_len != 0);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
552
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
553 qd = (qq_data *) gc->proto_data;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
554 list = query_list = NULL;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
555 len = buf_len;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
556 data = g_newa(guint8, len);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
557 info = NULL;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
558
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
559 if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
560 if (NULL == (segments = split_data(data, len, "\x1e", QQ_CONTACT_FIELDS)))
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
561 return;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
562
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
563 info = (contact_info *) segments;
14265
584cbd1628d0 [gaim-migrate @ 16947]
Mark Huetsch <markhuetsch>
parents: 14192
diff changeset
564 if (qd->modifying_face && strtol(info->face, NULL, 10) != qd->my_icon) {
584cbd1628d0 [gaim-migrate @ 16947]
Mark Huetsch <markhuetsch>
parents: 14192
diff changeset
565 gchar *icon = g_strdup_printf("%i", qd->my_icon);
584cbd1628d0 [gaim-migrate @ 16947]
Mark Huetsch <markhuetsch>
parents: 14192
diff changeset
566 qd->modifying_face = FALSE;
584cbd1628d0 [gaim-migrate @ 16947]
Mark Huetsch <markhuetsch>
parents: 14192
diff changeset
567 memcpy(info->face, icon, 2);
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
568 qq_send_packet_modify_info(gc, segments);
14265
584cbd1628d0 [gaim-migrate @ 16947]
Mark Huetsch <markhuetsch>
parents: 14192
diff changeset
569 g_free(icon);
584cbd1628d0 [gaim-migrate @ 16947]
Mark Huetsch <markhuetsch>
parents: 14192
diff changeset
570 }
584cbd1628d0 [gaim-migrate @ 16947]
Mark Huetsch <markhuetsch>
parents: 14192
diff changeset
571
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
572 qq_refresh_buddy_and_myself(info, gc);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
573
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
574 query_list = qd->info_query;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
575 /* ensure we're processing the right query */
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
576 while (query_list) {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
577 query = (qq_info_query *) query_list->data;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
578 if (query->uid == atoi(info->uid)) {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
579 if (query->show_window) {
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
580 info_text = info_to_str(info);
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
581 gaim_notify_userinfo(gc, info->uid, info_text->str, NULL, NULL);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
582 g_string_free(info_text, TRUE);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
583 } else if (query->modify_info) {
14611
000b8c063121 [gaim-migrate @ 17339]
Mark Huetsch <markhuetsch>
parents: 14519
diff changeset
584 create_modify_info_dialogue(gc, info);
14192
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
585 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
586 qd->info_query = g_list_remove(qd->info_query, qd->info_query->data);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
587 g_free(query);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
588 break;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
589 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
590 query_list = query_list->next;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
591 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
592
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
593 g_strfreev(segments);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
594 } else {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
595 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt get info reply\n");
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
596 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
597 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
598
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
599 void qq_info_query_free(qq_data *qd)
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
600 {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
601 gint i;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
602 qq_info_query *p;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
603
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
604 g_return_if_fail(qd != NULL);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
605
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
606 i = 0;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
607 while (qd->info_query != NULL) {
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
608 p = (qq_info_query *) (qd->info_query->data);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
609 qd->info_query = g_list_remove(qd->info_query, p);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
610 g_free(p);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
611 i++;
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
612 }
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
613 gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d info queries are freed!\n", i);
60b1bc8dbf37 [gaim-migrate @ 16863]
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
614 }