annotate libpurple/protocols/qq/buddy_opt.c @ 30160:211afed0548b

Clarify
author Paul Aurich <paul@darkrain42.org>
date Sat, 17 Apr 2010 21:37:52 +0000
parents f1437342cc0e
children 351d07aefb09
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file buddy_opt.c
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
4 * purple
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18807
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24
29028
f1437342cc0e Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <paul@darkrain42.org>
parents: 28571
diff changeset
25 #include "internal.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "notify.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "request.h"
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
29 #include "privacy.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "buddy_info.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "buddy_list.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "buddy_opt.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "char_conv.h"
24065
bdfcfd71449c patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24048
diff changeset
35 #include "qq_define.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #include "im.h"
23683
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23053
diff changeset
37 #include "qq_base.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 #include "packet_parse.h"
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23050
diff changeset
39 #include "qq_network.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 #include "utils.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
42 #define PURPLE_GROUP_QQ_FORMAT "QQ (%s)"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 #define QQ_REMOVE_SELF_REPLY_OK 0x00
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 enum {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 QQ_MY_AUTH_APPROVE = 0x30, /* ASCII value of "0" */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 QQ_MY_AUTH_REJECT = 0x31, /* ASCII value of "1" */
24635
d8452c0bec7b Remove the commas at the end of enumerator lists. This resolves warnings
Florian Quèze <florian@instantbird.org>
parents: 24557
diff changeset
49 QQ_MY_AUTH_REQUEST = 0x32 /* ASCII value of "2" */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51
24090
9be95f0b9472 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24080
diff changeset
52 typedef struct _qq_buddy_req {
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
53 PurpleConnection *gc;
24090
9be95f0b9472 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24080
diff changeset
54 guint32 uid;
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
55 guint8 *auth;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
56 guint8 auth_len;
24090
9be95f0b9472 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24080
diff changeset
57 } qq_buddy_req;
9be95f0b9472 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24080
diff changeset
58
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
59 void add_buddy_authorize_input(PurpleConnection *gc, guint32 uid,
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
60 guint8 *auth, guint8 auth_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
61
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
62 static void buddy_req_free(qq_buddy_req *add_req)
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
63 {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
64 g_return_if_fail(add_req != NULL);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
65 if (add_req->auth) g_free(add_req->auth);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
66 g_free(add_req);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
67 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
68
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
69 static void buddy_req_cancel_cb(qq_buddy_req *add_req, const gchar *msg)
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
70 {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
71 g_return_if_fail(add_req != NULL);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
72 buddy_req_free(add_req);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
73 }
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
74
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
75 PurpleGroup *qq_group_find_or_new(const gchar *group_name)
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
76 {
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
77 PurpleGroup *g;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
78
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
79 g_return_val_if_fail(group_name != NULL, NULL);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
80
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
81 g = purple_find_group(group_name);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
82 if (g == NULL) {
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
83 g = purple_group_new(group_name);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
84 purple_blist_add_group(g, NULL);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
85 purple_debug_warning("QQ", "Add new group: %s\n", group_name);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
86 }
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
87
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
88 return g;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
89 }
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
90
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
91 static qq_buddy_data *qq_buddy_data_new(guint32 uid)
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
92 {
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
93 qq_buddy_data *bd = g_new0(qq_buddy_data, 1);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
94 memset(bd, 0, sizeof(qq_buddy_data));
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
95 bd->uid = uid;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
96 bd->status = QQ_BUDDY_OFFLINE;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
97 return bd;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
98 }
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
99
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
100 qq_buddy_data *qq_buddy_data_find(PurpleConnection *gc, guint32 uid)
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
101 {
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
102 gchar *who;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
103 PurpleBuddy *buddy;
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
104 qq_buddy_data *bd;
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
105
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
106 g_return_val_if_fail(gc != NULL, NULL);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
107
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
108 who = uid_to_purple_name(uid);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
109 if (who == NULL) return NULL;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
110 buddy = purple_find_buddy(purple_connection_get_account(gc), who);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
111 g_free(who);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
112
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
113 if (buddy == NULL) {
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
114 purple_debug_error("QQ", "Can not find purple buddy of %u\n", uid);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
115 return NULL;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
116 }
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
117
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
118 if ((bd = purple_buddy_get_protocol_data(buddy)) == NULL) {
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
119 purple_debug_error("QQ", "Can not find buddy data of %u\n", uid);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
120 return NULL;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
121 }
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
122 return bd;
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
123 }
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
124
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
125 void qq_buddy_data_free(qq_buddy_data *bd)
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
126 {
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
127 g_return_if_fail(bd != NULL);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
128
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
129 if (bd->nickname) g_free(bd->nickname);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
130 g_free(bd);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
131 }
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
132
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
133 /* create purple buddy without data and display with no-auth icon */
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
134 PurpleBuddy *qq_buddy_new(PurpleConnection *gc, guint32 uid)
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
135 {
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
136 PurpleBuddy *buddy;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
137 PurpleGroup *group;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
138 gchar *who;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
139 gchar *group_name;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
140
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
141 g_return_val_if_fail(gc->account != NULL && uid != 0, NULL);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
142
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
143 group_name = g_strdup_printf(PURPLE_GROUP_QQ_FORMAT,
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
144 purple_account_get_username(gc->account));
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
145 group = qq_group_find_or_new(group_name);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
146 if (group == NULL) {
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
147 purple_debug_error("QQ", "Failed creating group %s\n", group_name);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
148 return NULL;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
149 }
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
150
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
151 purple_debug_info("QQ", "Add new purple buddy: [%u]\n", uid);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
152 who = uid_to_purple_name(uid);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
153 buddy = purple_buddy_new(gc->account, who, NULL); /* alias is NULL */
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
154 purple_buddy_set_protocol_data(buddy, NULL);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
155
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
156 g_free(who);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
157
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
158 purple_blist_add_buddy(buddy, NULL, group, NULL);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
159
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
160 g_free(group_name);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
161
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
162 return buddy;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
163 }
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
164
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
165 static void qq_buddy_free(PurpleBuddy *buddy)
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
166 {
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
167 qq_buddy_data *bd;
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
168
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
169 g_return_if_fail(buddy);
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
170
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
171 if ((bd = purple_buddy_get_protocol_data(buddy)) != NULL) {
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
172 qq_buddy_data_free(bd);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
173 }
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
174 purple_buddy_set_protocol_data(buddy, NULL);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
175 purple_blist_remove_buddy(buddy);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
176 }
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
177
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
178 PurpleBuddy *qq_buddy_find(PurpleConnection *gc, guint32 uid)
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
179 {
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
180 PurpleBuddy *buddy;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
181 gchar *who;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
182
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
183 g_return_val_if_fail(gc->account != NULL && uid != 0, NULL);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
184
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
185 who = uid_to_purple_name(uid);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
186 buddy = purple_find_buddy(gc->account, who);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
187 g_free(who);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
188 return buddy;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
189 }
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
190
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
191 PurpleBuddy *qq_buddy_find_or_new(PurpleConnection *gc, guint32 uid)
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
192 {
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
193 PurpleBuddy *buddy;
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
194 qq_buddy_data *bd;
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
195
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
196 g_return_val_if_fail(gc->account != NULL && uid != 0, NULL);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
197
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
198 buddy = qq_buddy_find(gc, uid);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
199 if (buddy == NULL) {
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
200 buddy = qq_buddy_new(gc, uid);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
201 if (buddy == NULL) {
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
202 return NULL;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
203 }
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
204 }
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
205
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
206 if (purple_buddy_get_protocol_data(buddy) != NULL) {
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
207 return buddy;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
208 }
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
209
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
210 bd = qq_buddy_data_new(uid);
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
211 purple_buddy_set_protocol_data(buddy, bd);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
212 return buddy;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
213 }
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
214
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 /* send packet to remove a buddy from my buddy list */
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
216 static void request_remove_buddy(PurpleConnection *gc, guint32 uid)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 gchar uid_str[11];
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
219 gint bytes;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 g_return_if_fail(uid > 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
223 g_snprintf(uid_str, sizeof(uid_str), "%u", uid);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
224 bytes = strlen(uid_str);
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
225 qq_send_cmd_mess(gc, QQ_CMD_REMOVE_BUDDY, (guint8 *) uid_str, bytes, 0, uid);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
228 static void request_remove_buddy_ex(PurpleConnection *gc,
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
229 guint32 uid, guint8 *auth, guint8 auth_len)
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
230 {
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
231 gint bytes;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
232 guint8 *raw_data;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
233 gchar uid_str[16];
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
234
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
235 g_return_if_fail(uid != 0);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
236 g_return_if_fail(auth != NULL && auth_len > 0);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
237
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
238 raw_data = g_newa(guint8, auth_len + sizeof(uid_str) );
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
239 bytes = 0;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
240 bytes += qq_put8(raw_data + bytes, auth_len);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
241 bytes += qq_putdata(raw_data + bytes, auth, auth_len);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
242
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
243 g_snprintf(uid_str, sizeof(uid_str), "%u", uid);
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
244 bytes += qq_putdata(raw_data + bytes, (guint8 *)uid_str, strlen(uid_str));
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
245
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
246 qq_send_cmd_mess(gc, QQ_CMD_REMOVE_BUDDY, raw_data, bytes, 0, uid);
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
247 }
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
248
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
249 void qq_request_auth_code(PurpleConnection *gc, guint8 cmd, guint16 sub_cmd, guint32 uid)
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
250 {
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
251 guint8 raw_data[16];
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
252 gint bytes;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
253
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
254 g_return_if_fail(uid > 0);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
255 bytes = 0;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
256 bytes += qq_put8(raw_data + bytes, cmd);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
257 bytes += qq_put16(raw_data + bytes, sub_cmd);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
258 bytes += qq_put32(raw_data + bytes, uid);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
259
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
260 qq_send_cmd_mess(gc, QQ_CMD_AUTH_CODE, raw_data, bytes, 0, uid);
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
261 }
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
262
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
263 void qq_process_auth_code(PurpleConnection *gc, guint8 *data, gint data_len, guint32 uid)
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
264 {
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
265 qq_data *qd;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
266 gint bytes;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
267 guint8 cmd, reply;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
268 guint16 sub_cmd;
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
269 guint8 *code = NULL;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
270 guint16 code_len = 0;
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
271
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
272 g_return_if_fail(data != NULL && data_len != 0);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
273 g_return_if_fail(uid != 0);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
274
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
275 qd = (qq_data *) gc->proto_data;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
276
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
277 qq_show_packet("qq_process_auth_code", data, data_len);
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
278 bytes = 0;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
279 bytes += qq_get8(&cmd, data + bytes);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
280 bytes += qq_get16(&sub_cmd, data + bytes);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
281 bytes += qq_get8(&reply, data + bytes);
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
282 g_return_if_fail(bytes + 2 <= data_len);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
283
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
284 bytes += qq_get16(&code_len, data + bytes);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
285 g_return_if_fail(code_len > 0);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
286 g_return_if_fail(bytes + code_len <= data_len);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
287 code = g_newa(guint8, code_len);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
288 bytes += qq_getdata(code, code_len, data + bytes);
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
289
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
290 if (cmd == QQ_AUTH_INFO_BUDDY && sub_cmd == QQ_AUTH_INFO_REMOVE_BUDDY) {
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
291 request_remove_buddy_ex(gc, uid, code, code_len);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
292 return;
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
293 }
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
294 if (cmd == QQ_AUTH_INFO_BUDDY && sub_cmd == QQ_AUTH_INFO_ADD_BUDDY) {
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
295 add_buddy_authorize_input(gc, uid, code, code_len);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
296 return;
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
297 }
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
298 purple_debug_info("QQ", "Got auth info cmd 0x%x, sub 0x%x, reply 0x%x\n",
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
299 cmd, sub_cmd, reply);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
300 }
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
301
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
302 static void add_buddy_question_cb(qq_buddy_req *add_req, const gchar *text)
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
303 {
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
304 g_return_if_fail(add_req != NULL);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
305 if (add_req->gc == NULL || add_req->uid == 0) {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
306 buddy_req_free(add_req);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
307 return;
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
308 }
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
309
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
310 qq_request_question(add_req->gc, QQ_QUESTION_ANSWER, add_req->uid, NULL, text);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
311 buddy_req_free(add_req);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
312 }
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
313
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
314 static void add_buddy_question_input(PurpleConnection *gc, guint32 uid, gchar *question)
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
315 {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
316 gchar *who, *msg;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
317 qq_buddy_req *add_req;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
318 g_return_if_fail(uid != 0);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
319
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
320 add_req = g_new0(qq_buddy_req, 1);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
321 add_req->gc = gc;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
322 add_req->uid = uid;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
323 add_req->auth = NULL;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
324 add_req->auth_len = 0;
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
325
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
326 who = uid_to_purple_name(uid);
24630
8f757b2139d2 String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents: 24557
diff changeset
327 msg = g_strdup_printf(_("%u requires verification"), uid);
8f757b2139d2 String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents: 24557
diff changeset
328 purple_request_input(gc, _("Add buddy question"), msg,
8f757b2139d2 String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents: 24557
diff changeset
329 _("Enter answer here"),
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
330 NULL,
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
331 TRUE, FALSE, NULL,
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
332 _("Send"), G_CALLBACK(add_buddy_question_cb),
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
333 _("Cancel"), G_CALLBACK(buddy_req_cancel_cb),
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
334 purple_connection_get_account(gc), who, NULL,
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
335 add_req);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
336
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
337 g_free(msg);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
338 g_free(who);
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
339 }
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
340
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
341 void qq_request_question(PurpleConnection *gc,
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
342 guint8 cmd, guint32 uid, const gchar *question_utf8, const gchar *answer_utf8)
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
343 {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
344 guint8 raw_data[MAX_PACKET_SIZE - 16];
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
345 gint bytes;
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
346
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
347 g_return_if_fail(uid > 0);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
348 bytes = 0;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
349 bytes += qq_put8(raw_data + bytes, cmd);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
350 if (cmd == QQ_QUESTION_GET) {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
351 bytes += qq_put8(raw_data + bytes, 0);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
352 qq_send_cmd_mess(gc, QQ_CMD_BUDDY_QUESTION, raw_data, bytes, 0, uid);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
353 return;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
354 }
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
355 if (cmd == QQ_QUESTION_SET) {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
356 bytes += qq_put_vstr(raw_data + bytes, question_utf8, QQ_CHARSET_DEFAULT);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
357 bytes += qq_put_vstr(raw_data + bytes, answer_utf8, QQ_CHARSET_DEFAULT);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
358 bytes += qq_put8(raw_data + bytes, 0);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
359 qq_send_cmd_mess(gc, QQ_CMD_BUDDY_QUESTION, raw_data, bytes, 0, uid);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
360 return;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
361 }
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
362 /* Unknow 2 bytes, 0x(00 01) */
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
363 bytes += qq_put8(raw_data + bytes, 0x00);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
364 bytes += qq_put8(raw_data + bytes, 0x01);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
365 g_return_if_fail(uid != 0);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
366 bytes += qq_put32(raw_data + bytes, uid);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
367 if (cmd == QQ_QUESTION_REQUEST) {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
368 qq_send_cmd_mess(gc, QQ_CMD_BUDDY_QUESTION, raw_data, bytes, 0, uid);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
369 return;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
370 }
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
371 bytes += qq_put_vstr(raw_data + bytes, answer_utf8, QQ_CHARSET_DEFAULT);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
372 bytes += qq_put8(raw_data + bytes, 0);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
373 qq_send_cmd_mess(gc, QQ_CMD_BUDDY_QUESTION, raw_data, bytes, 0, uid);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
374 return;
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
375 }
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
376
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
377 static void request_add_buddy_by_question(PurpleConnection *gc, guint32 uid,
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
378 guint8 *code, guint16 code_len)
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
379 {
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
380 guint8 raw_data[MAX_PACKET_SIZE - 16];
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
381 gint bytes = 0;
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
382
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
383 g_return_if_fail(uid != 0 && code_len > 0);
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
384
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
385 bytes = 0;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
386 bytes += qq_put8(raw_data + bytes, 0x10);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
387 bytes += qq_put32(raw_data + bytes, uid);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
388 bytes += qq_put16(raw_data + bytes, 0);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
389
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
390 bytes += qq_put8(raw_data + bytes, 0);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
391 bytes += qq_put8(raw_data + bytes, 0); /* no auth code */
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
392
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
393 bytes += qq_put16(raw_data + bytes, code_len);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
394 bytes += qq_putdata(raw_data + bytes, code, code_len);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
395
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
396 bytes += qq_put8(raw_data + bytes, 1); /* ALLOW ADD ME FLAG */
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
397 bytes += qq_put8(raw_data + bytes, 0); /* group number? */
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
398 qq_send_cmd(gc, QQ_CMD_ADD_BUDDY_AUTH_EX, raw_data, bytes);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
399 }
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
400
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
401 void qq_process_question(PurpleConnection *gc, guint8 *data, gint data_len, guint32 uid)
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
402 {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
403 qq_data *qd;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
404 gint bytes;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
405 guint8 cmd, reply;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
406 gchar *question, *answer;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
407 guint16 code_len;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
408 guint8 *code;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
409
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
410 g_return_if_fail(data != NULL && data_len != 0);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
411
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
412 qd = (qq_data *) gc->proto_data;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
413
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
414 qq_show_packet("qq_process_question", data, data_len);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
415 bytes = 0;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
416 bytes += qq_get8(&cmd, data + bytes);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
417 if (cmd == QQ_QUESTION_GET) {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
418 bytes += qq_get_vstr(&question, QQ_CHARSET_DEFAULT, data + bytes);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
419 bytes += qq_get_vstr(&answer, QQ_CHARSET_DEFAULT, data + bytes);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
420 purple_debug_info("QQ", "Get buddy adding Q&A:\n%s\n%s\n", question, answer);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
421 g_free(question);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
422 g_free(answer);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
423 return;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
424 }
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
425 if (cmd == QQ_QUESTION_SET) {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
426 bytes += qq_get8(&reply, data + bytes);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
427 if (reply == 0) {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
428 purple_debug_info("QQ", "Successed setting Q&A\n");
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
429 } else {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
430 purple_debug_warning("QQ", "Failed setting Q&A, reply %d\n", reply);
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
431 }
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
432 return;
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
433 }
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
434
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
435 g_return_if_fail(uid != 0);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
436 bytes += 2; /* skip 2 bytes, 0x(00 01)*/
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
437 if (cmd == QQ_QUESTION_REQUEST) {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
438 bytes += qq_get8(&reply, data + bytes);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
439 if (reply == 0x01) {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
440 purple_debug_warning("QQ", "Failed getting question, reply %d\n", reply);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
441 return;
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
442 }
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
443 bytes += qq_get_vstr(&question, QQ_CHARSET_DEFAULT, data + bytes);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
444 purple_debug_info("QQ", "Get buddy question:\n%s\n", question);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
445 add_buddy_question_input(gc, uid, question);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
446 g_free(question);
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
447 return;
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
448 }
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
449
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
450 if (cmd == QQ_QUESTION_ANSWER) {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
451 bytes += qq_get8(&reply, data + bytes);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
452 if (reply == 0x01) {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
453 purple_notify_error(gc, _("Add Buddy"), _("Invalid answer."), NULL);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
454 return;
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
455 }
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
456 bytes += qq_get16(&code_len, data + bytes);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
457 g_return_if_fail(code_len > 0);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
458 g_return_if_fail(bytes + code_len <= data_len);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
459
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
460 code = g_newa(guint8, code_len);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
461 bytes += qq_getdata(code, code_len, data + bytes);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
462 request_add_buddy_by_question(gc, uid, code, code_len);
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
463 return;
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
464 }
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
465
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
466 g_return_if_reached();
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
467 }
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
468
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 /* try to remove myself from someone's buddy list */
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
470 static void request_buddy_remove_me(PurpleConnection *gc, guint32 uid)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471 {
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
472 guint8 raw_data[16] = {0};
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
473 gint bytes = 0;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 g_return_if_fail(uid > 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
477 bytes += qq_put32(raw_data + bytes, uid);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
479 qq_send_cmd_mess(gc, QQ_CMD_REMOVE_ME, raw_data, bytes, 0, uid);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 /* try to add a buddy without authentication */
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
483 static void request_add_buddy_no_auth(PurpleConnection *gc, guint32 uid)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485 gchar uid_str[11];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487 g_return_if_fail(uid > 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489 /* we need to send the ascii code of this uid to qq server */
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
490 g_snprintf(uid_str, sizeof(uid_str), "%u", uid);
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
491 qq_send_cmd_mess(gc, QQ_CMD_ADD_BUDDY_NO_AUTH,
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
492 (guint8 *) uid_str, strlen(uid_str), 0, uid);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
495 static void request_add_buddy_no_auth_ex(PurpleConnection *gc, guint32 uid)
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
496 {
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
497 guint bytes;
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
498 guint8 raw_data[16];
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
499
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
500 g_return_if_fail(uid != 0);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
501
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
502 bytes = 0;
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
503 bytes += qq_put32(raw_data + bytes, uid);
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
504 qq_send_cmd_mess(gc, QQ_CMD_ADD_BUDDY_NO_AUTH_EX, raw_data, bytes, 0, uid);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
505 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
506
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 /* this buddy needs authentication, text conversion is done at lowest level */
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
508 static void request_add_buddy_auth(PurpleConnection *gc, guint32 uid, const gchar response, const gchar *text)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 {
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
510 guint8 raw_data[MAX_PACKET_SIZE - 16];
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
511 gint bytes;
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
512 gchar *msg, uid_str[11];
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
513 guint8 bar;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515 g_return_if_fail(uid != 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
517 g_snprintf(uid_str, sizeof(uid_str), "%u", uid);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518 bar = 0x1f;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
519
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
520 bytes = 0;
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
521 bytes += qq_putdata(raw_data + bytes, (guint8 *) uid_str, strlen(uid_str));
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
522 bytes += qq_put8(raw_data + bytes, bar);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
523 bytes += qq_put8(raw_data + bytes, response);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525 if (text != NULL) {
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
526 msg = utf8_to_qq(text, QQ_CHARSET_DEFAULT);
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
527 bytes += qq_put8(raw_data + bytes, bar);
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
528 bytes += qq_putdata(raw_data + bytes, (guint8 *) msg, strlen(msg));
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
529 g_free(msg);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
532 qq_send_cmd(gc, QQ_CMD_ADD_BUDDY_AUTH, raw_data, bytes);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
534
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
535 static void request_add_buddy_auth_ex(PurpleConnection *gc, guint32 uid,
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
536 const gchar *text, guint8 *auth, guint8 auth_len)
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
537 {
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
538 guint8 raw_data[MAX_PACKET_SIZE - 16];
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
539 gint bytes = 0;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
540
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
541 g_return_if_fail(uid != 0);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
542
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
543 bytes = 0;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
544 bytes += qq_put8(raw_data + bytes, 0x02);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
545 bytes += qq_put32(raw_data + bytes, uid);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
546 bytes += qq_put16(raw_data + bytes, 0);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
547
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
548 bytes += qq_put8(raw_data + bytes, 0);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
549 if (auth == NULL || auth_len <= 0) {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
550 bytes += qq_put8(raw_data + bytes, 0);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
551 } else {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
552 bytes += qq_put8(raw_data + bytes, auth_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
553 bytes += qq_putdata(raw_data + bytes, auth, auth_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
554 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
555 bytes += qq_put8(raw_data + bytes, 1); /* ALLOW ADD ME FLAG */
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
556 bytes += qq_put8(raw_data + bytes, 0); /* group number? */
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
557 bytes += qq_put_vstr(raw_data + bytes, text, QQ_CHARSET_DEFAULT);
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
558 qq_send_cmd(gc, QQ_CMD_ADD_BUDDY_AUTH_EX, raw_data, bytes);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
559 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
560
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
561 void qq_process_add_buddy_auth_ex(PurpleConnection *gc, guint8 *data, gint data_len, guint32 ship32)
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
562 {
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
563 g_return_if_fail(data != NULL && data_len != 0);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
564
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
565 qq_show_packet("qq_process_question", data, data_len);
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
566 }
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
567
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
568 static void add_buddy_auth_cb(qq_buddy_req *add_req, const gchar *text)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569 {
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
570 qq_data *qd;
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
571 g_return_if_fail(add_req != NULL);
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
572 if (add_req->gc == NULL || add_req->uid == 0) {
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
573 buddy_req_free(add_req);
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
574 return;
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
575 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
577 qd = (qq_data *)add_req->gc->proto_data;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
578 if (qd->client_version > 2005) {
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
579 request_add_buddy_auth_ex(add_req->gc, add_req->uid,
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
580 text, add_req->auth, add_req->auth_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
581 } else {
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
582 request_add_buddy_auth(add_req->gc, add_req->uid, QQ_MY_AUTH_REQUEST, text);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
583 }
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
584 buddy_req_free(add_req);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
585 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587 /* the real packet to reject and request is sent from here */
24090
9be95f0b9472 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24080
diff changeset
588 static void buddy_add_deny_reason_cb(qq_buddy_req *add_req, const gchar *reason)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589 {
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
590 g_return_if_fail(add_req != NULL);
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
591 if (add_req->gc == NULL || add_req->uid == 0) {
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
592 buddy_req_free(add_req);
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
593 return;
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
594 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
596 request_add_buddy_auth(add_req->gc, add_req->uid, QQ_MY_AUTH_REJECT, reason);
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
597 buddy_req_free(add_req);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
598 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
600 static void buddy_add_deny_noreason_cb(qq_buddy_req *add_req)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
601 {
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
602 buddy_add_deny_reason_cb(add_req, NULL);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
603 }
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
604
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
605 /* we approve other's request of adding me as friend */
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
606 static void buddy_add_authorize_cb(gpointer data)
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
607 {
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
608 qq_buddy_req *add_req = (qq_buddy_req *)data;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
609
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
610 g_return_if_fail(add_req != NULL);
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
611 if (add_req->gc == NULL || add_req->uid == 0) {
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
612 buddy_req_free(add_req);
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
613 return;
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
614 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
615
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
616 request_add_buddy_auth(add_req->gc, add_req->uid, QQ_MY_AUTH_APPROVE, NULL);
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
617 buddy_req_free(add_req);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
618 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
619
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
620 /* we reject other's request of adding me as friend */
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
621 static void buddy_add_deny_cb(gpointer data)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
622 {
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
623 qq_buddy_req *add_req = (qq_buddy_req *)data;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
624 gchar *who = uid_to_purple_name(add_req->uid);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
625 purple_request_input(add_req->gc, NULL, _("Authorization denied message:"),
24630
8f757b2139d2 String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents: 24557
diff changeset
626 NULL, _("Sorry, you're not my style."), TRUE, FALSE, NULL,
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
627 _("OK"), G_CALLBACK(buddy_add_deny_reason_cb),
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
628 _("Cancel"), G_CALLBACK(buddy_add_deny_noreason_cb),
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
629 purple_connection_get_account(add_req->gc), who, NULL,
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
630 add_req);
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
631 g_free(who);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
632 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
633
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
634 static void add_buddy_no_auth_cb(qq_buddy_req *add_req)
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
635 {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
636 qq_data *qd;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
637 g_return_if_fail(add_req != NULL);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
638 if (add_req->gc == NULL || add_req->uid == 0) {
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
639 buddy_req_free(add_req);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
640 return;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
641 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
642
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
643 qd = (qq_data *) add_req->gc->proto_data;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
644 if (qd->client_version > 2005) {
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
645 request_add_buddy_no_auth_ex(add_req->gc, add_req->uid);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
646 } else {
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
647 request_add_buddy_no_auth(add_req->gc, add_req->uid);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
648 }
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
649 buddy_req_free(add_req);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
650 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
651
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
652 void add_buddy_authorize_input(PurpleConnection *gc, guint32 uid,
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
653 guint8 *auth, guint8 auth_len)
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
654 {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
655 gchar *who, *msg;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
656 qq_buddy_req *add_req;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
657 g_return_if_fail(uid != 0);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
658
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
659 add_req = g_new0(qq_buddy_req, 1);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
660 add_req->gc = gc;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
661 add_req->uid = uid;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
662 add_req->auth = NULL;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
663 add_req->auth_len = 0;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
664 if (auth != NULL && auth_len > 0) {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
665 add_req->auth = g_new0(guint8, auth_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
666 g_memmove(add_req->auth, auth, auth_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
667 add_req->auth_len = auth_len;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
668 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
669
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
670 who = uid_to_purple_name(uid);
24630
8f757b2139d2 String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents: 24557
diff changeset
671 msg = g_strdup_printf(_("%u needs authorization"), uid);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
672 purple_request_input(gc, _("Add buddy authorize"), msg,
24630
8f757b2139d2 String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents: 24557
diff changeset
673 _("Enter request here"),
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
674 _("Would you be my friend?"),
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
675 TRUE, FALSE, NULL,
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
676 _("Send"), G_CALLBACK(add_buddy_auth_cb),
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
677 _("Cancel"), G_CALLBACK(buddy_req_cancel_cb),
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
678 purple_connection_get_account(gc), who, NULL,
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
679 add_req);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
680
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
681 g_free(msg);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
682 g_free(who);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
683 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
684
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
685 /* add a buddy and send packet to QQ server
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
686 * note that when purple load local cached buddy list into its blist
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
687 * it also calls this funtion, so we have to
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
688 * define qd->is_login=TRUE AFTER LOGIN */
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
689 void qq_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
690 {
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
691 qq_data *qd;
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
692 guint32 uid;
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
693
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
694 g_return_if_fail(NULL != gc && NULL != gc->proto_data);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
695 g_return_if_fail(buddy != NULL);
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
696
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
697 qd = (qq_data *) gc->proto_data;
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
698 if (!qd->is_login)
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
699 return; /* IMPORTANT ! */
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
700
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
701 uid = purple_name_to_uid(purple_buddy_get_name(buddy));
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
702 if (uid > 0) {
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
703 if (qd->client_version > 2005) {
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
704 request_add_buddy_no_auth_ex(gc, uid);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
705 } else {
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
706 request_add_buddy_no_auth(gc, uid);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
707 }
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
708 return;
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
709 }
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
710
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
711 purple_notify_error(gc, _("QQ Buddy"), _("Add buddy"), _("Invalid QQ Number"));
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
712 if (buddy == NULL) {
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
713 return;
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
714 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
715
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
716 purple_debug_info("QQ", "Remove buddy with invalid QQ number %u\n", uid);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
717 qq_buddy_free(buddy);
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
718 }
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
719
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
720 /* process reply to add_buddy_auth request */
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
721 void qq_process_add_buddy_auth(guint8 *data, gint data_len, PurpleConnection *gc)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
722 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
723 qq_data *qd;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
724 gchar **segments, *msg_utf8;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
725
23753
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23683
diff changeset
726 g_return_if_fail(data != NULL && data_len != 0);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
727
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
728 qd = (qq_data *) gc->proto_data;
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
729
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
730 if (data[0] == '0') {
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
731 purple_debug_info("QQ", "Reply OK for sending authorize\n");
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
732 return;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
733 }
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
734
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
735 if (NULL == (segments = split_data(data, data_len, "\x1f", 2))) {
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
736 purple_notify_error(gc, _("QQ Buddy"), _("Failed sending authorize"), NULL);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
737 return;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
738 }
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
739 msg_utf8 = qq_to_utf8(segments[1], QQ_CHARSET_DEFAULT);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
740 purple_notify_error(gc, _("QQ Buddy"), _("Failed sending authorize"), msg_utf8);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
741 g_free(msg_utf8);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
742 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
743
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
744 /* process the server reply for my request to remove a buddy */
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
745 void qq_process_remove_buddy(PurpleConnection *gc, guint8 *data, gint data_len, guint32 uid)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
746 {
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
747 PurpleBuddy *buddy = NULL;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
748 gchar *msg;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
749
23753
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23683
diff changeset
750 g_return_if_fail(data != NULL && data_len != 0);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
751 g_return_if_fail(uid != 0);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
752
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
753 buddy = qq_buddy_find(gc, uid);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
754 if (data[0] != 0) {
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
755 msg = g_strdup_printf(_("Failed removing buddy %u"), uid);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
756 purple_notify_info(gc, _("QQ Buddy"), msg, NULL);
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
757 g_free(msg);
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
758 }
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
759
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
760 purple_debug_info("QQ", "Reply OK for removing buddy\n");
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
761 /* remove buddy again */
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
762 if (buddy != NULL) {
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
763 qq_buddy_free(buddy);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
764 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
765 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
766
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
767 /* process the server reply for my request to remove myself from a buddy */
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
768 void qq_process_buddy_remove_me(PurpleConnection *gc, guint8 *data, gint data_len, guint32 uid)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
769 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
770 qq_data *qd;
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
771 gchar *msg;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
772
23753
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23683
diff changeset
773 g_return_if_fail(data != NULL && data_len != 0);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
774 qd = (qq_data *) gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
775
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
776 if (data[0] == 0) {
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
777 purple_debug_info("QQ", "Reply OK for removing me from %u's buddy list\n", uid);
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
778 return;
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
779 }
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
780 msg = g_strdup_printf(_("Failed removing me from %d's buddy list"), uid);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
781 purple_notify_info(gc, _("QQ Buddy"), msg, NULL);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
782 g_free(msg);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
783 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
784
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
785 void qq_process_add_buddy_no_auth(PurpleConnection *gc,
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
786 guint8 *data, gint data_len, guint32 uid)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
787 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
788 qq_data *qd;
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
789 gchar **segments;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
790 gchar *dest_uid, *reply;
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
791 PurpleBuddy *buddy;
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
792 qq_buddy_data *bd;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
793
23753
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23683
diff changeset
794 g_return_if_fail(data != NULL && data_len != 0);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
795 g_return_if_fail(uid != 0);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
796
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797 qd = (qq_data *) gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
798
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
799 purple_debug_info("QQ", "Process buddy add for id [%u]\n", uid);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
800 qq_show_packet("buddy_add_no_auth", data, data_len);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
801
23753
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23683
diff changeset
802 if (NULL == (segments = split_data(data, data_len, "\x1f", 2)))
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23683
diff changeset
803 return;
24046
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24045
diff changeset
804
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
805 dest_uid = segments[0];
23753
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23683
diff changeset
806 reply = segments[1];
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
807 if (strtoul(dest_uid, NULL, 10) != qd->uid) { /* should not happen */
28571
73a30365c293 Add newline at end of debug messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27520
diff changeset
808 purple_debug_error("QQ", "Add buddy reply is to [%s], not me!\n", dest_uid);
23753
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23683
diff changeset
809 g_strfreev(segments);
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23683
diff changeset
810 return;
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23683
diff changeset
811 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
812
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
813 if (strtol(reply, NULL, 10) == 0) {
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
814 /* add OK */
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
815 qq_buddy_find_or_new(gc, uid);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
816
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
817 qq_request_buddy_info(gc, uid, 0, 0);
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
818 if (qd->client_version >= 2007) {
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
819 qq_request_get_level_2007(gc, uid);
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
820 } else {
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
821 qq_request_get_level(gc, uid);
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
822 }
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
823 qq_request_get_buddies_online(gc, 0, 0);
24079
1bdf7b602684 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24077
diff changeset
824
28571
73a30365c293 Add newline at end of debug messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27520
diff changeset
825 purple_debug_info("QQ", "Successed adding into %u's buddy list\n", uid);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
826 g_strfreev(segments);
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
827 return;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
828 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
829
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
830 /* need auth */
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
831 purple_debug_warning("QQ", "Failed adding buddy, need authorize\n");
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
832
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
833 buddy = qq_buddy_find(gc, uid);
24079
1bdf7b602684 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24077
diff changeset
834 if (buddy == NULL) {
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
835 buddy = qq_buddy_new(gc, uid);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
836 }
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
837 if (buddy != NULL && (bd = purple_buddy_get_protocol_data(buddy)) != NULL) {
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
838 /* Not authorized now, free buddy data */
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
839 qq_buddy_data_free(bd);
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
840 purple_buddy_set_protocol_data(buddy, NULL);
24079
1bdf7b602684 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24077
diff changeset
841 }
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
842
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
843 add_buddy_authorize_input(gc, uid, NULL, 0);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
844 g_strfreev(segments);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
845 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
846
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
847 void qq_process_add_buddy_no_auth_ex(PurpleConnection *gc,
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
848 guint8 *data, gint data_len, guint32 uid)
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
849 {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
850 qq_data *qd;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
851 gint bytes;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
852 guint32 dest_uid;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
853 guint8 reply;
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
854 guint8 auth_type;
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
855
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
856 g_return_if_fail(data != NULL && data_len >= 5);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
857 g_return_if_fail(uid != 0);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
858
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
859 qd = (qq_data *) gc->proto_data;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
860
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
861 purple_debug_info("QQ", "Process buddy add no auth for id [%u]\n", uid);
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
862 qq_show_packet("buddy_add_no_auth_ex", data, data_len);
24079
1bdf7b602684 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24077
diff changeset
863
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
864 bytes = 0;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
865 bytes += qq_get32(&dest_uid, data + bytes);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
866 bytes += qq_get8(&reply, data + bytes);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
867
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
868 g_return_if_fail(dest_uid == uid);
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
869
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
870 if (reply == 0x99) {
28571
73a30365c293 Add newline at end of debug messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27520
diff changeset
871 purple_debug_info("QQ", "Successfully added buddy %u\n", uid);
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
872 qq_buddy_find_or_new(gc, uid);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
873
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
874 qq_request_buddy_info(gc, uid, 0, 0);
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
875 if (qd->client_version >= 2007) {
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
876 qq_request_get_level_2007(gc, uid);
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
877 } else {
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
878 qq_request_get_level(gc, uid);
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
879 }
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
880 qq_request_get_buddies_online(gc, 0, 0);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
881 return;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
882 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
883
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
884 if (reply != 0) {
28571
73a30365c293 Add newline at end of debug messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27520
diff changeset
885 purple_debug_info("QQ", "Failed adding buddy %u, Unknown reply 0x%02X\n",
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
886 uid, reply);
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
887 }
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
888
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
889 /* need auth */
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
890 g_return_if_fail(data_len > bytes);
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
891 bytes += qq_get8(&auth_type, data + bytes);
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
892 purple_debug_warning("QQ", "Adding buddy needs authorize 0x%02X\n", auth_type);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
893
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
894 switch (auth_type) {
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
895 case 0x00: /* no authorize */
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
896 break;
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
897 case 0x01: /* authorize */
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
898 qq_request_auth_code(gc, QQ_AUTH_INFO_BUDDY, QQ_AUTH_INFO_ADD_BUDDY, uid);
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
899 break;
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
900 case 0x02: /* disable */
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
901 break;
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
902 case 0x03: /* answer question */
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
903 qq_request_question(gc, QQ_QUESTION_REQUEST, uid, NULL, NULL);
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
904 break;
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
905 default:
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
906 g_return_if_reached();
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
907 break;
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
908 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
909 return;
24073
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24069
diff changeset
910 }
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24069
diff changeset
911
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
912 /* remove a buddy and send packet to QQ server accordingly */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
913 void qq_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
914 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
915 qq_data *qd;
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
916 qq_buddy_data *bd;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
917 guint32 uid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
918
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
919 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
920 g_return_if_fail(buddy != NULL);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
921
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
922 qd = (qq_data *) gc->proto_data;
24046
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24045
diff changeset
923 if (!qd->is_login)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
924 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
925
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
926 uid = purple_name_to_uid(purple_buddy_get_name(buddy));
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
927 if (uid > 0 && uid != qd->uid) {
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
928 if (qd->client_version > 2005) {
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
929 qq_request_auth_code(gc, QQ_AUTH_INFO_BUDDY, QQ_AUTH_INFO_REMOVE_BUDDY, uid);
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
930 } else {
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
931 request_remove_buddy(gc, uid);
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
932 request_buddy_remove_me(gc, uid);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
933 }
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
934 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
935
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
936 if ((bd = purple_buddy_get_protocol_data(buddy)) != NULL) {
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
937 qq_buddy_data_free(bd);
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
938 purple_buddy_set_protocol_data(buddy, NULL);
24079
1bdf7b602684 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24077
diff changeset
939 } else {
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
940 purple_debug_warning("QQ", "Empty buddy data of %s\n", purple_buddy_get_name(buddy));
24079
1bdf7b602684 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24077
diff changeset
941 }
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
942
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
943 /* Do not call purple_blist_remove_buddy,
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
944 * otherwise purple segmentation fault */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
945 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
947 static void buddy_add_input(PurpleConnection *gc, guint32 uid, gchar *reason)
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
948 {
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
949 PurpleAccount *account = purple_connection_get_account(gc);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
950 qq_buddy_req *add_req;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
951 gchar *who;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
952
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
953 g_return_if_fail(uid != 0 && reason != NULL);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
954
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
955 purple_debug_info("QQ", "Buddy %u request adding, msg: %s\n", uid, reason);
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
956
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
957 add_req = g_new0(qq_buddy_req, 1);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
958 add_req->gc = gc;
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
959 add_req->uid = uid;
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
960
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
961 if (purple_prefs_get_bool("/plugins/prpl/qq/auto_get_authorize_info")) {
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
962 qq_request_buddy_info(gc, add_req->uid, 0, QQ_BUDDY_INFO_DISPLAY);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
963 }
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
964 who = uid_to_purple_name(add_req->uid);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
965
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
966 purple_account_request_authorization(account,
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
967 who, NULL,
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
968 NULL, reason,
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
969 purple_find_buddy(account, who) != NULL,
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
970 buddy_add_authorize_cb,
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
971 buddy_add_deny_cb,
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
972 add_req);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
973
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
974 g_free(who);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
975 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
976
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
977 /* someone wants to add you to his buddy list */
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
978 static void server_buddy_add_request(PurpleConnection *gc, gchar *from, gchar *to,
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
979 guint8 *data, gint data_len)
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
980 {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
981 guint32 uid;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
982 gchar *msg, *reason;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
983
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
984 g_return_if_fail(from != NULL && to != NULL);
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
985 uid = strtoul(from, NULL, 10);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
986 g_return_if_fail(uid != 0);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
987
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
988 if (purple_prefs_get_bool("/plugins/prpl/qq/auto_get_authorize_info")) {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
989 qq_request_buddy_info(gc, uid, 0, QQ_BUDDY_INFO_DISPLAY);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
990 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
991
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
992 if (data_len <= 0) {
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
993 reason = g_strdup( _("No reason given") );
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
994 } else {
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
995 msg = g_strndup((gchar *)data, data_len);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
996 reason = qq_to_utf8(msg, QQ_CHARSET_DEFAULT);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
997 if (reason == NULL) reason = g_strdup( _("Unknown reason") );
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
998 g_free(msg);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
999 }
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1000
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
1001 buddy_add_input(gc, uid, reason);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1002 g_free(reason);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1003 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1004
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
1005 void qq_process_buddy_check_code(PurpleConnection *gc, guint8 *data, gint data_len)
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1006 {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1007 qq_data *qd;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1008 gint bytes;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1009 guint8 cmd;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1010 guint8 reply;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1011 guint32 uid;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1012 guint16 flag1, flag2;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1013
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1014 g_return_if_fail(data != NULL && data_len >= 5);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1015
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1016 qd = (qq_data *) gc->proto_data;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1017
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1018 qq_show_packet("buddy_check_code", data, data_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1019
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1020 bytes = 0;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1021 bytes += qq_get8(&cmd, data + bytes); /* 0x03 */
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1022 bytes += qq_get8(&reply, data + bytes);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1023
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1024 if (reply == 0) {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1025 purple_debug_info("QQ", "Failed checking code\n");
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1026 return;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1027 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1028
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1029 bytes += qq_get32(&uid, data + bytes);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1030 g_return_if_fail(uid != 0);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1031 bytes += qq_get16(&flag1, data + bytes);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1032 bytes += qq_get16(&flag2, data + bytes);
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
1033 purple_debug_info("QQ", "Check code reply Ok, uid %u, flag 0x%04X-0x%04X\n",
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1034 uid, flag1, flag2);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1035 return;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1036 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1037
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1038 static void request_buddy_check_code(PurpleConnection *gc,
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1039 gchar *from, guint8 *code, gint code_len)
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1040 {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1041 guint8 *raw_data;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1042 gint bytes;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1043 guint32 uid;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1044
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1045 g_return_if_fail(code != NULL && code_len > 0 && from != NULL);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1046
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
1047 uid = strtoul(from, NULL, 10);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1048 raw_data = g_newa(guint8, code_len + 16);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1049 bytes = 0;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1050 bytes += qq_put8(raw_data + bytes, 0x03);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1051 bytes += qq_put8(raw_data + bytes, 0x01);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1052 bytes += qq_put32(raw_data + bytes, uid);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1053 bytes += qq_put16(raw_data + bytes, code_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1054 bytes += qq_putdata(raw_data + bytes, code, code_len);
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1055
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1056 qq_send_cmd(gc, QQ_CMD_BUDDY_CHECK_CODE, raw_data, bytes);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1057 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1058
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1059 static gint server_buddy_check_code(PurpleConnection *gc,
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1060 gchar *from, guint8 *data, gint data_len)
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1061 {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1062 gint bytes;
24095
2a19984c0005 2008.10.27 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24094
diff changeset
1063 guint16 code_len;
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1064 guint8 *code;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1065
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1066 g_return_val_if_fail(data != NULL && data_len > 0, 0);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1067
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1068 bytes = 0;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1069 bytes += qq_get16(&code_len, data + bytes);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1070 if (code_len <= 0) {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1071 purple_debug_info("QQ", "Server msg for buddy has no code\n");
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1072 return bytes;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1073 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1074 if (bytes + code_len < data_len) {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1075 purple_debug_error("QQ", "Code len error in server msg for buddy\n");
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1076 qq_show_packet("server_buddy_check_code", data, data_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1077 code_len = data_len - bytes;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1078 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1079 code = g_newa(guint8, code_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1080 bytes += qq_getdata(code, code_len, data + bytes);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1081
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1082 request_buddy_check_code(gc, from, code, code_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1083 return bytes;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1084 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1085
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1086 static void server_buddy_add_request_ex(PurpleConnection *gc, gchar *from, gchar *to,
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1087 guint8 *data, gint data_len)
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1088 {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1089 gint bytes;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1090 guint32 uid;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1091 gchar *msg;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1092 guint8 allow_reverse;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1094 g_return_if_fail(from != NULL && to != NULL);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1095 g_return_if_fail(data != NULL && data_len >= 3);
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
1096 uid = strtoul(from, NULL, 10);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1097 g_return_if_fail(uid != 0);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1098
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1099 /* qq_show_packet("server_buddy_add_request_ex", data, data_len); */
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1100
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1101 bytes = 0;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1102 bytes += qq_get_vstr(&msg, QQ_CHARSET_DEFAULT, data+bytes);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1103 bytes += qq_get8(&allow_reverse, data + bytes); /* allow_reverse = 0x01, allowed */
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1104 server_buddy_check_code(gc, from, data + bytes, data_len - bytes);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1105
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1106 if (strlen(msg) <= 0) {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1107 g_free(msg);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1108 msg = g_strdup( _("No reason given") );
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1109 }
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
1110 buddy_add_input(gc, uid, msg);
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1111 g_free(msg);
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1112 }
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1113
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1114 /* when you are added by a person, QQ server will send sys message */
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1115 static void server_buddy_added(PurpleConnection *gc, gchar *from, gchar *to,
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1116 guint8 *data, gint data_len)
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1117 {
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1118 PurpleAccount *account = purple_connection_get_account(gc);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1119 PurpleBuddy *buddy;
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1120 guint32 uid;
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1121 qq_buddy_req *add_req;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1122 gchar *who;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1123 gchar *primary;
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1124
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1125 g_return_if_fail(from != NULL && to != NULL);
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1126
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
1127 uid = strtoul(from, NULL, 10);
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1128 who = uid_to_purple_name(uid);
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1129
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1130 buddy = purple_find_buddy(account, who);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1131 if (buddy != NULL) {
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1132 purple_account_notify_added(account, from, to, NULL, NULL);
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1133 }
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1134
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1135 add_req = g_new0(qq_buddy_req, 1);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1136 add_req->gc = gc;
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1137 add_req->uid = uid; /* only need to get value */
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1138 primary = g_strdup_printf(_("You have been added by %s"), from);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1139 purple_request_action(gc, NULL, primary,
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1140 _("Would you like to add him?"),
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1141 PURPLE_DEFAULT_ACTION_NONE,
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1142 purple_connection_get_account(gc), who, NULL,
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1143 add_req, 2,
24094
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
1144 _("Add"), G_CALLBACK(add_buddy_no_auth_cb),
7f5433ffbf8d 2008.10.22 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24093
diff changeset
1145 _("Cancel"), G_CALLBACK(buddy_req_cancel_cb));
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1146
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1147 g_free(who);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1148 g_free(primary);
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1149 }
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1150
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1151 static void server_buddy_added_ex(PurpleConnection *gc, gchar *from, gchar *to,
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1152 guint8 *data, gint data_len)
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1153 {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1154 gint bytes;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1155 guint8 allow_reverse;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1156 gchar *msg;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1157
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1158 g_return_if_fail(from != NULL && to != NULL);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1159 g_return_if_fail(data != NULL && data_len >= 3);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1160
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1161 qq_show_packet("server_buddy_added_ex", data, data_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1162
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1163 bytes = 0;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1164 bytes += qq_get_vstr(&msg, QQ_CHARSET_DEFAULT, data+bytes); /* always empty msg */
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1165 purple_debug_info("QQ", "Buddy added msg: %s\n", msg);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1166 bytes += qq_get8(&allow_reverse, data + bytes); /* allow_reverse = 0x01, allowed */
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1167 server_buddy_check_code(gc, from, data + bytes, data_len - bytes);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1168
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1169 g_free(msg);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1170 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1171
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1172 static void server_buddy_adding_ex(PurpleConnection *gc, gchar *from, gchar *to,
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1173 guint8 *data, gint data_len)
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1174 {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1175 gint bytes;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1176 guint8 allow_reverse;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1177
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1178 g_return_if_fail(from != NULL && to != NULL);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1179 g_return_if_fail(data != NULL && data_len >= 3);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1180
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1181 qq_show_packet("server_buddy_adding_ex", data, data_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1182
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1183 bytes = 0;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1184 bytes += qq_get8(&allow_reverse, data + bytes); /* allow_reverse = 0x01, allowed */
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1185 server_buddy_check_code(gc, from, data + bytes, data_len - bytes);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1186 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1187
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1188 /* the buddy approves your request of adding him/her as your friend */
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1189 static void server_buddy_added_me(PurpleConnection *gc, gchar *from, gchar *to,
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1190 guint8 *data, gint data_len)
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1191 {
24066
dbc7a9742f8d 2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24065
diff changeset
1192 PurpleAccount *account = purple_connection_get_account(gc);
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1193 qq_data *qd;
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
1194 guint32 uid;
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1195
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1196 g_return_if_fail(from != NULL && to != NULL);
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1197
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1198 qd = (qq_data *) gc->proto_data;
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
1199
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
1200 uid = strtoul(from, NULL, 10);
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
1201 g_return_if_fail(uid > 0);
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
1202
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1203 server_buddy_check_code(gc, from, data, data_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1204
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
1205 qq_buddy_find_or_new(gc, uid);
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
1206 qq_request_buddy_info(gc, uid, 0, 0);
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
1207 qq_request_get_buddies_online(gc, 0, 0);
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
1208 if (qd->client_version >= 2007) {
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
1209 qq_request_get_level_2007(gc, uid);
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
1210 } else {
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
1211 qq_request_get_level(gc, uid);
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
1212 }
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1213
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1214 purple_account_notify_added(account, to, from, NULL, NULL);
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1215 }
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1216
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1217 /* you are rejected by the person */
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1218 static void server_buddy_rejected_me(PurpleConnection *gc, gchar *from, gchar *to,
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1219 guint8 *data, gint data_len)
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1220 {
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
1221 guint32 uid;
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
1222 PurpleBuddy *buddy;
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1223 gchar *msg, *msg_utf8;
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1224 gint bytes;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1225 gchar **segments;
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1226 gchar *primary, *secondary;
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
1227 qq_buddy_data *bd;
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1228
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1229 g_return_if_fail(from != NULL && to != NULL);
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1230
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1231 qq_show_packet("server_buddy_rejected_me", data, data_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1232
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1233 if (data_len <= 0) {
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1234 msg = g_strdup( _("No reason given") );
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1235 } else {
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1236 segments = g_strsplit((gchar *)data, "\x1f", 1);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1237 if (segments != NULL && segments[0] != NULL) {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1238 msg = g_strdup(segments[0]);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1239 g_strfreev(segments);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1240 bytes = strlen(msg) + 1;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1241 if (bytes < data_len) {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1242 server_buddy_check_code(gc, from, data + bytes, data_len - bytes);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1243 }
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1244 } else {
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1245 msg = g_strdup( _("No reason given") );
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1246 }
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1247 }
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1248 msg_utf8 = qq_to_utf8(msg, QQ_CHARSET_DEFAULT);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1249 if (msg_utf8 == NULL) {
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1250 msg_utf8 = g_strdup( _("Unknown reason") );
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1251 }
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1252 g_free(msg);
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1253
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1254 primary = g_strdup_printf(_("Rejected by %s"), from);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1255 secondary = g_strdup_printf(_("Message: %s"), msg_utf8);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1256
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1257 purple_notify_info(gc, _("QQ Buddy"), primary, secondary);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1258
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1259 g_free(msg_utf8);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1260 g_free(primary);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1261 g_free(secondary);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1262
24557
1aca68fe730c Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents: 24095
diff changeset
1263 uid = strtoul(from, NULL, 10);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
1264 g_return_if_fail(uid != 0);
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1265
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
1266 buddy = qq_buddy_find(gc, uid);
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
1267 if (buddy != NULL && (bd = purple_buddy_get_protocol_data(buddy)) != NULL) {
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
1268 /* Not authorized now, free buddy data */
25298
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
1269 qq_buddy_data_free(bd);
e35115192593 Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents: 24095
diff changeset
1270 purple_buddy_set_protocol_data(buddy, NULL);
24091
d35672443baa 2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24090
diff changeset
1271 }
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1272 }
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1273
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1274 void qq_process_buddy_from_server(PurpleConnection *gc, int funct,
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1275 gchar *from, gchar *to, guint8 *data, gint data_len)
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1276 {
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1277 switch (funct) {
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1278 case QQ_SERVER_BUDDY_ADDED:
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1279 server_buddy_added(gc, from, to, data, data_len);
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1280 break;
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1281 case QQ_SERVER_BUDDY_ADD_REQUEST:
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1282 server_buddy_add_request(gc, from, to, data, data_len);
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1283 break;
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1284 case QQ_SERVER_BUDDY_ADD_REQUEST_EX:
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1285 server_buddy_add_request_ex(gc, from, to, data, data_len);
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1286 break;
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1287 case QQ_SERVER_BUDDY_ADDED_ME:
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1288 server_buddy_added_me(gc, from, to, data, data_len);
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1289 break;
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1290 case QQ_SERVER_BUDDY_REJECTED_ME:
24092
7c0a56c5fea0 2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24091
diff changeset
1291 server_buddy_rejected_me(gc, from, to, data, data_len);
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1292 break;
24093
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1293 case QQ_SERVER_BUDDY_ADDED_EX:
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1294 server_buddy_added_ex(gc, from, to, data, data_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1295 break;
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1296 case QQ_SERVER_BUDDY_ADDING_EX:
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1297 case QQ_SERVER_BUDDY_ADDED_ANSWER:
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1298 server_buddy_adding_ex(gc, from, to, data, data_len);
f4f29fac96c6 2008.10.20 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24092
diff changeset
1299 break;
24048
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1300 default:
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1301 purple_debug_warning("QQ", "Unknow buddy operate (%d) from server\n", funct);
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1302 break;
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1303 }
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24046
diff changeset
1304 }