annotate libpurple/protocols/qq/buddy_list.c @ 24145:ec3f7d3e0445

2008.10.04 - lonicerae <lonicerae(at)gmail.com> * fixed a bug in qq_base.c
author SHiNE CsyFeK <csyfek@gmail.com>
date Wed, 22 Oct 2008 14:49:38 +0000
parents a95c7e71064c
children ce94189f15ad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
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_list.c
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15482
diff changeset
4 * purple
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15482
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
15373
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
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18210
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15373
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include <string.h>
18210
b8572b937c09 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents: 16208
diff changeset
26
b8572b937c09 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents: 16208
diff changeset
27 #include "qq.h"
b8572b937c09 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents: 16208
diff changeset
28
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "notify.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "utils.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "packet_parse.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "buddy_info.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "buddy_list.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include "buddy_opt.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #include "char_conv.h"
24134
bdfcfd71449c patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24117
diff changeset
37 #include "qq_define.h"
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
38 #include "qq_base.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 #include "group.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 #include "group_find.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 #include "group_internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 #include "group_info.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43
23050
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23048
diff changeset
44 #include "qq_network.h"
15373
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 #define QQ_GET_ONLINE_BUDDY_02 0x02
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 #define QQ_GET_ONLINE_BUDDY_03 0x03 /* unknown function */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
49 typedef struct _qq_buddy_online {
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
50 qq_buddy_status bs;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 guint16 unknown1;
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
52 guint8 ext_flag;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 guint8 comm_flag;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 guint16 unknown2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 guint8 ending; /* 0x00 */
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
56 } qq_buddy_online;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 /* get a list of online_buddies */
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
59 void qq_request_get_buddies_online(PurpleConnection *gc, guint8 position, gint update_class)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 qq_data *qd;
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
62 guint8 *raw_data;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
63 gint bytes = 0;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 qd = (qq_data *) gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 raw_data = g_newa(guint8, 5);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 /* 000-000 get online friends cmd
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 * only 0x02 and 0x03 returns info from server, other valuse all return 0xff
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 * I can also only send the first byte (0x02, or 0x03)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 * and the result is the same */
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
72 bytes += qq_put8(raw_data + bytes, QQ_GET_ONLINE_BUDDY_02);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 /* 001-001 seems it supports 255 online buddies at most */
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
74 bytes += qq_put8(raw_data + bytes, position);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 /* 002-002 */
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
76 bytes += qq_put8(raw_data + bytes, 0x00);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 /* 003-004 */
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
78 bytes += qq_put16(raw_data + bytes, 0x0000);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
80 qq_send_cmd_mess(gc, QQ_CMD_GET_BUDDIES_ONLINE, raw_data, 5, update_class, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
83 /* position starts with 0x0000,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 * server may return a position tag if list is too long for one packet */
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
85 void qq_request_get_buddies_list(PurpleConnection *gc, guint16 position, gint update_class)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 {
24140
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
87 qq_data *qd;
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
88 guint8 raw_data[16] = {0};
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
89 gint bytes = 0;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90
24140
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
91 qd = (qq_data *) gc->proto_data;
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
92
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 /* 000-001 starting position, can manually specify */
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
94 bytes += qq_put16(raw_data + bytes, position);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 /* before Mar 18, 2004, any value can work, and we sent 00
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 * I do not know what data QQ server is expecting, as QQ2003iii 0304 itself
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 * even can sending packets 00 and get no response.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 * Now I tested that 00,00,00,00,00,01 work perfectly
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 * March 22, found the 00,00,00 starts to work as well */
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
100 bytes += qq_put8(raw_data + bytes, 0x00);
24140
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
101 if (qd->client_version >= 2007) {
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
102 bytes += qq_put16(raw_data + bytes, 0x0000);
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
103 }
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
104
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
105 qq_send_cmd_mess(gc, QQ_CMD_GET_BUDDIES_LIST, raw_data, bytes, update_class, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 /* get all list, buddies & Quns with groupsid support */
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
109 void qq_request_get_buddies_and_rooms(PurpleConnection *gc, guint32 position, gint update_class)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 {
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
111 guint8 raw_data[16] = {0};
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
112 gint bytes = 0;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 /* 0x01 download, 0x02, upload */
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
115 bytes += qq_put8(raw_data + bytes, 0x01);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 /* unknown 0x02 */
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
117 bytes += qq_put8(raw_data + bytes, 0x02);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 /* unknown 00 00 00 00 */
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
119 bytes += qq_put32(raw_data + bytes, 0x00000000);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
120 bytes += qq_put32(raw_data + bytes, position);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
122 qq_send_cmd_mess(gc, QQ_CMD_GET_BUDDIES_AND_ROOMS, raw_data, bytes, update_class, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
125 /* parse the data into qq_buddy_status */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
126 static gint get_buddy_status(qq_buddy_status *bs, guint8 *data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 {
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
128 gint bytes = 0;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
130 g_return_val_if_fail(data != NULL && bs != NULL, -1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
132 /* 000-003: uid */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
133 bytes += qq_get32(&bs->uid, data + bytes);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
134 /* 004-004: 0x01 */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
135 bytes += qq_get8(&bs->unknown1, data + bytes);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
136 /* this is no longer the IP, it seems QQ (as of 2006) no longer sends
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
137 * the buddy's IP in this packet. all 0s */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
138 /* 005-008: ip */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
139 bytes += qq_getIP(&bs->ip, data + bytes);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
140 /* port info is no longer here either */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
141 /* 009-010: port */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
142 bytes += qq_get16(&bs->port, data + bytes);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
143 /* 011-011: 0x00 */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
144 bytes += qq_get8(&bs->unknown2, data + bytes);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
145 /* 012-012: status */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
146 bytes += qq_get8(&bs->status, data + bytes);
24135
dbc7a9742f8d 2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24134
diff changeset
147 /* 013-014: client tag */
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
148 bytes += qq_get16(&bs->unknown3, data + bytes);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
149 /* 015-030: unknown key */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
150 bytes += qq_getdata(&(bs->unknown_key[0]), QQ_KEY_LENGTH, data + bytes);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
152 purple_debug_info("QQ_STATUS",
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
153 "uid: %d, U1: %d, ip: %s:%d, U2:%d, status:%d, U3:%04X\n",
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
154 bs->uid, bs->unknown1, inet_ntoa(bs->ip), bs->port,
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
155 bs->unknown2, bs->status, bs->unknown3);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
156
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
157 return bytes;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 /* process the reply packet for get_buddies_online packet */
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
161 guint8 qq_process_get_buddies_online_reply(guint8 *data, gint data_len, PurpleConnection *gc)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 qq_data *qd;
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
164 gint bytes, bytes_start;
23052
ebad75b719f5 Sun Jun 29 22:00:12 CST 2008 csyfek@gmail.com
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
165 gint count;
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
166 guint8 position;
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
167 qq_buddy *buddy;
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
168 qq_buddy_online bo;
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
169 int entry_len = 38;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
171 g_return_val_if_fail(data != NULL && data_len != 0, -1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 qd = (qq_data *) gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
175 /* qq_show_packet("Get buddies online reply packet", data, len); */
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
176 if (qd->client_version >= 2007) entry_len += 4;
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
177
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
178 bytes = 0;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
179 bytes += qq_get8(&position, data + bytes);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
180
23052
ebad75b719f5 Sun Jun 29 22:00:12 CST 2008 csyfek@gmail.com
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
181 count = 0;
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
182 while (bytes < data_len) {
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
183 if (data_len - bytes < entry_len) {
24140
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
184 purple_debug_error("QQ", "[buddies online] only %d, need %d\n",
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
185 (data_len - bytes), entry_len);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
186 break;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
187 }
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
188 memset(&bo, 0 ,sizeof(bo));
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
189
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
190 /* set flag */
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
191 bytes_start = bytes;
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
192 /* based on one online buddy entry */
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
193 /* 000-030 qq_buddy_status */
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
194 bytes += get_buddy_status(&(bo.bs), data + bytes);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
195 /* 031-032: */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
196 bytes += qq_get16(&bo.unknown1, data + bytes);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
197 /* 033-033: ext_flag */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
198 bytes += qq_get8(&bo.ext_flag, data + bytes);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
199 /* 034-034: comm_flag */
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
200 bytes += qq_get8(&bo.comm_flag, data + bytes);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
201 /* 035-036: */
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
202 bytes += qq_get16(&bo.unknown2, data + bytes);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
203 /* 037-037: */
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
204 bytes += qq_get8(&bo.ending, data + bytes); /* 0x00 */
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
205 /* skip 4 bytes in qq2007 */
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
206 if (qd->client_version >= 2007) bytes += 4;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
208 if (bo.bs.uid == 0 || (bytes - bytes_start) != entry_len) {
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
209 purple_debug_error("QQ", "uid=0 or entry complete len(%d) != %d",
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
210 (bytes - bytes_start), entry_len);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
211 continue;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
212 } /* check if it is a valid entry */
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
213
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
214 if (bo.bs.uid == qd->uid) {
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
215 purple_debug_warning("QQ", "I am in online list %d\n", bo.bs.uid);
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
216 }
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
217
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
218 /* update buddy information */
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
219 buddy = qq_get_buddy(gc, bo.bs.uid);
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
220 if (buddy == NULL) {
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
221 purple_debug_error("QQ",
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
222 "Got an online buddy %d, but not in my buddy list\n", bo.bs.uid);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
223 continue;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 }
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
225 /* we find one and update qq_buddy */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
226 /*
24135
dbc7a9742f8d 2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24134
diff changeset
227 if(0 != fe->s->client_tag)
dbc7a9742f8d 2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24134
diff changeset
228 q_bud->client_tag = fe->s->client_tag;
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
229 */
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
230 buddy->ip.s_addr = bo.bs.ip.s_addr;
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
231 buddy->port = bo.bs.port;
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
232 buddy->status = bo.bs.status;
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
233 buddy->ext_flag = bo.ext_flag;
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
234 buddy->comm_flag = bo.comm_flag;
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
235 qq_update_buddy_contact(gc, buddy);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
236 count++;
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
237 }
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
238
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
239 if(bytes > data_len) {
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
240 purple_debug_error("QQ",
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
241 "qq_process_get_buddies_online_reply: Dangerous error! maybe protocol changed, notify developers!\n");
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
242 }
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
243
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
244 purple_debug_info("QQ", "Received %d online buddies, nextposition=%u\n",
23561
bdb38a8bf721 20080717-05-1-fix-keep-alive ccpaging <ecc_hy(at)hotmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
245 count, (guint) position);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
246 return position;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
249
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 /* process reply for get_buddies_list */
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
251 guint16 qq_process_get_buddies_list_reply(guint8 *data, gint data_len, PurpleConnection *gc)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 qq_data *qd;
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
254 qq_buddy *q_bud;
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
255 gint bytes_expected, count;
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
256 gint bytes, buddy_bytes;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 guint16 position, unknown;
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
258 guint8 pascal_len;
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
259 gchar *name;
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
260 PurpleBuddy *b;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
262 g_return_val_if_fail(data != NULL && data_len != 0, -1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 qd = (qq_data *) gc->proto_data;
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
265
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
266 if (data_len <= 2) {
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
267 purple_debug_error("QQ", "empty buddies list");
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
268 return -1;
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
269 }
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
270 /* qq_show_packet("QQ get buddies list", data, data_len); */
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
271 bytes = 0;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
272 bytes += qq_get16(&position, data + bytes);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
273 /* the following data is buddy list in this packet */
23052
ebad75b719f5 Sun Jun 29 22:00:12 CST 2008 csyfek@gmail.com
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
274 count = 0;
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
275 while (bytes < data_len) {
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
276 q_bud = g_new0(qq_buddy, 1);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
277 /* set flag */
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
278 buddy_bytes = bytes;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
279 /* 000-003: uid */
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
280 bytes += qq_get32(&q_bud->uid, data + bytes);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
281 /* 004-005: icon index (1-255) */
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
282 bytes += qq_get16(&q_bud->face, data + bytes);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
283 /* 006-006: age */
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
284 bytes += qq_get8(&q_bud->age, data + bytes);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
285 /* 007-007: gender */
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
286 bytes += qq_get8(&q_bud->gender, data + bytes);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
288 pascal_len = convert_as_pascal_string(data + bytes, &q_bud->nickname, QQ_CHARSET_DEFAULT);
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
289 bytes += pascal_len;
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
290 qq_filter_str(q_bud->nickname);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291
24140
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
292 /* Fixme: merge following as 32bit flag */
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
293 bytes += qq_get16(&unknown, data + bytes);
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
294 bytes += qq_get8(&q_bud->ext_flag, data + bytes);
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
295 bytes += qq_get8(&q_bud->comm_flag, data + bytes);
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
296
24140
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
297 if (qd->client_version >= 2007) {
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
298 bytes += 4; /* skip 4 bytes */
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
299 bytes_expected = 16 + pascal_len;
24140
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
300 } else {
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
301 bytes_expected = 12 + pascal_len;
24140
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
302 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
304
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
305 if (q_bud->uid == 0 || (bytes - buddy_bytes) != bytes_expected) {
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
306 purple_debug_info("QQ",
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
307 "Buddy entry, expect %d bytes, read %d bytes\n", bytes_expected, bytes - buddy_bytes);
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
308 g_free(q_bud->nickname);
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
309 g_free(q_bud);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
310 continue;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
311 } else {
23052
ebad75b719f5 Sun Jun 29 22:00:12 CST 2008 csyfek@gmail.com
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
312 count++;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
315 #if 1
24117
d57928c9dd8f 2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24115
diff changeset
316 purple_debug_info("QQ", "buddy [%09d]: ext_flag=0x%02x, comm_flag=0x%02x, nick=%s\n",
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
317 q_bud->uid, q_bud->ext_flag, q_bud->comm_flag, q_bud->nickname);
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
318 #endif
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
319
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
320 name = uid_to_purple_name(q_bud->uid);
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
321 b = purple_find_buddy(gc->account, name);
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
322 g_free(name);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
323
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
324 if (b == NULL) {
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
325 b = qq_create_buddy(gc, q_bud->uid, TRUE, FALSE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 }
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
327
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
328 b->proto_data = q_bud;
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
329 qd->buddies = g_list_append(qd->buddies, q_bud);
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
330 qq_update_buddy_contact(gc, q_bud);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
331 }
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
332
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
333 if(bytes > data_len) {
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
334 purple_debug_error("QQ",
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
335 "qq_process_get_buddies_list_reply: Dangerous error! maybe protocol changed, notify developers!");
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
336 }
23052
ebad75b719f5 Sun Jun 29 22:00:12 CST 2008 csyfek@gmail.com
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
337
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
338 purple_debug_info("QQ", "Received %d buddies, nextposition=%u\n",
23052
ebad75b719f5 Sun Jun 29 22:00:12 CST 2008 csyfek@gmail.com
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
339 count, (guint) position);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
340 return position;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
343 guint32 qq_process_get_buddies_and_rooms(guint8 *data, gint data_len, PurpleConnection *gc)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 qq_data *qd;
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
346 gint i, j;
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
347 gint bytes;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 guint8 sub_cmd, reply_code;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 guint32 unknown, position;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 guint32 uid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 guint8 type, groupid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 qq_group *group;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
354 g_return_val_if_fail(data != NULL && data_len != 0, -1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 qd = (qq_data *) gc->proto_data;
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
357
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
358 bytes = 0;
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
359 bytes += qq_get8(&sub_cmd, data + bytes);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
360 g_return_val_if_fail(sub_cmd == 0x01, -1);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
361
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
362 bytes += qq_get8(&reply_code, data + bytes);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
363 if(0 != reply_code) {
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
364 purple_debug_warning("QQ", "qq_process_get_buddies_and_rooms, %d", reply_code);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
365 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
367 bytes += qq_get32(&unknown, data + bytes);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
368 bytes += qq_get32(&position, data + bytes);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
369 /* the following data is all list in this packet */
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
370 i = 0;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
371 j = 0;
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
372 while (bytes < data_len) {
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
373 /* 00-03: uid */
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
374 bytes += qq_get32(&uid, data + bytes);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
375 /* 04: type 0x1:buddy 0x4:Qun */
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
376 bytes += qq_get8(&type, data + bytes);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
377 /* 05: groupid*4 */ /* seems to always be 0 */
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
378 bytes += qq_get8(&groupid, data + bytes);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
379 /*
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
380 purple_debug_info("QQ", "groupid: %i\n", groupid);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
381 groupid >>= 2;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
382 */
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
383 if (uid == 0 || (type != 0x1 && type != 0x4)) {
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
384 purple_debug_info("QQ", "Buddy entry, uid=%d, type=%d", uid, type);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
385 continue;
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
386 }
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
387 if(0x1 == type) { /* a buddy */
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
388 /* don't do anything but count - buddies are handled by
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
389 * qq_request_get_buddies_list */
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
390 ++i;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
391 } else { /* a group */
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
392 group = qq_room_search_id(gc, uid);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
393 if(group == NULL) {
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
394 purple_debug_info("QQ",
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
395 "Not find room id %d in qq_process_get_buddies_and_rooms\n", uid);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
396 qq_set_pending_id(&qd->adding_groups_from_server, uid, TRUE);
24140
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
397 //group = g_newa(qq_group, 1);
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
398 //group->id = uid;
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
399 qq_send_room_cmd_mess(gc, QQ_ROOM_CMD_GET_INFO, uid, NULL, 0,
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
400 0, 0);
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
401 } else {
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
402 group->my_role = QQ_ROOM_ROLE_YES;
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
403 qq_group_refresh(gc, group);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
404 }
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
405 ++j;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 }
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
408
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
409 if(bytes > data_len) {
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
410 purple_debug_error("QQ",
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
411 "qq_process_get_buddies_and_rooms: Dangerous error! maybe protocol changed, notify developers!");
23048
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
412 }
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22544
diff changeset
413
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
414 purple_debug_info("QQ", "Received %d buddies and %d groups, nextposition=%u\n", i, j, (guint) position);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
415 return position;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
416 }
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
417
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
418 #define QQ_MISC_STATUS_HAVING_VIIDEO 0x00000001
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
419 #define QQ_CHANGE_ONLINE_STATUS_REPLY_OK 0x30 /* ASCII value of "0" */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
420
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
421 /* TODO: figure out what's going on with the IP region. Sometimes I get valid IP addresses,
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
422 * but the port number's weird, other times I get 0s. I get these simultaneously on the same buddy,
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
423 * using different accounts to get info. */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
424
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
425 /* check if status means online or offline */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
426 gboolean is_online(guint8 status)
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
427 {
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
428 switch(status) {
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
429 case QQ_BUDDY_ONLINE_NORMAL:
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
430 case QQ_BUDDY_ONLINE_AWAY:
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
431 case QQ_BUDDY_ONLINE_INVISIBLE:
24140
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
432 case QQ_BUDDY_ONLINE_BUSY:
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
433 return TRUE;
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
434 case QQ_BUDDY_CHANGE_TO_OFFLINE:
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
435 return FALSE;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
436 }
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
437 return FALSE;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
438 }
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
439
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
440 /* Help calculate the correct icon index to tell the server. */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
441 gint get_icon_offset(PurpleConnection *gc)
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
442 {
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
443 PurpleAccount *account;
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
444 PurplePresence *presence;
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
445
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
446 account = purple_connection_get_account(gc);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
447 presence = purple_account_get_presence(account);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
448
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
449 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_INVISIBLE)) {
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
450 return 2;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
451 } else if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_AWAY)
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
452 || purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_EXTENDED_AWAY)
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
453 || purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_UNAVAILABLE)) {
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
454 return 1;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
455 } else {
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
456 return 0;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
457 }
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
458 }
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
459
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
460 /* send a packet to change my online status */
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
461 void qq_request_change_status(PurpleConnection *gc, gint update_class)
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
462 {
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
463 qq_data *qd;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
464 guint8 raw_data[16] = {0};
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
465 gint bytes = 0;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
466 guint8 away_cmd;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
467 guint32 misc_status;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
468 gboolean fake_video;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
469 PurpleAccount *account;
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
470 PurplePresence *presence;
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
471
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
472 account = purple_connection_get_account(gc);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
473 presence = purple_account_get_presence(account);
23561
bdb38a8bf721 20080717-05-1-fix-keep-alive ccpaging <ecc_hy(at)hotmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
474
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
475 qd = (qq_data *) gc->proto_data;
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
476 if (!qd->is_login)
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
477 return;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
478
24140
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
479 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_INVISIBLE)) {
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
480 away_cmd = QQ_BUDDY_ONLINE_INVISIBLE;
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
481 } else if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_UNAVAILABLE))
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
482 {
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
483 if (qd->client_version >= 2007) {
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
484 away_cmd = QQ_BUDDY_ONLINE_BUSY;
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
485 } else {
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
486 away_cmd = QQ_BUDDY_ONLINE_INVISIBLE;
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
487 }
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
488 } else if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_AWAY)
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
489 || purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_EXTENDED_AWAY)
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
490 || purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_UNAVAILABLE)) {
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
491 away_cmd = QQ_BUDDY_ONLINE_AWAY;
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
492 } else {
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
493 away_cmd = QQ_BUDDY_ONLINE_NORMAL;
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
494 }
24145
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24144
diff changeset
495
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
496 misc_status = 0x00000000;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
497 fake_video = purple_prefs_get_bool("/plugins/prpl/qq/show_fake_video");
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
498 if (fake_video)
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
499 misc_status |= QQ_MISC_STATUS_HAVING_VIIDEO;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
500
24140
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
501 if (qd->client_version >= 2007) {
24137
87e61a85f5dd 2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24135
diff changeset
502 bytes = 0;
87e61a85f5dd 2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24135
diff changeset
503 bytes += qq_put8(raw_data + bytes, away_cmd);
87e61a85f5dd 2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24135
diff changeset
504 /* status version */
87e61a85f5dd 2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24135
diff changeset
505 bytes += qq_put16(raw_data + bytes, 0);
87e61a85f5dd 2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24135
diff changeset
506 bytes += qq_put16(raw_data + bytes, 0);
87e61a85f5dd 2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24135
diff changeset
507 bytes += qq_put32(raw_data + bytes, misc_status);
87e61a85f5dd 2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24135
diff changeset
508 /* Fixme: custom status message, now is empty */
87e61a85f5dd 2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24135
diff changeset
509 bytes += qq_put16(raw_data + bytes, 0);
87e61a85f5dd 2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24135
diff changeset
510 } else {
87e61a85f5dd 2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24135
diff changeset
511 bytes = 0;
87e61a85f5dd 2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24135
diff changeset
512 bytes += qq_put8(raw_data + bytes, away_cmd);
87e61a85f5dd 2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24135
diff changeset
513 bytes += qq_put32(raw_data + bytes, misc_status);
87e61a85f5dd 2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24135
diff changeset
514 }
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
515 qq_send_cmd_mess(gc, QQ_CMD_CHANGE_STATUS, raw_data, bytes, update_class, 0);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
516 }
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
517
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
518 /* parse the reply packet for change_status */
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
519 void qq_process_change_status_reply(guint8 *data, gint data_len, PurpleConnection *gc)
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
520 {
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
521 qq_data *qd;
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
522 gint bytes;
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
523 guint8 reply;
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
524 qq_buddy *buddy;
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
525
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
526 g_return_if_fail(data != NULL && data_len != 0);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
527
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
528 qd = (qq_data *) gc->proto_data;
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
529
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
530 bytes = 0;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
531 bytes = qq_get8(&reply, data + bytes);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
532 if (reply != QQ_CHANGE_ONLINE_STATUS_REPLY_OK) {
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
533 purple_debug_warning("QQ", "Change status fail 0x%02X\n", reply);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
534 return;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
535 }
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
536
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
537 /* purple_debug_info("QQ", "Change status OK\n"); */
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
538 buddy = qq_get_buddy(gc, qd->uid);
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
539 if (buddy != NULL) {
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
540 qq_update_buddy_contact(gc, buddy);
23052
ebad75b719f5 Sun Jun 29 22:00:12 CST 2008 csyfek@gmail.com
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
541 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
542 }
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
543
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
544 /* it is a server message indicating that one of my buddies has changed its status */
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
545 void qq_process_buddy_change_status(guint8 *data, gint data_len, PurpleConnection *gc)
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
546 {
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
547 qq_data *qd;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
548 gint bytes;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
549 guint32 my_uid;
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
550 qq_buddy *buddy;
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
551 qq_buddy_status bs;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
552
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
553 g_return_if_fail(data != NULL && data_len != 0);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
554
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
555 qd = (qq_data *) gc->proto_data;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
556
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
557 if (data_len < 35) {
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
558 purple_debug_error("QQ", "[buddy status change] only %d, need 35 bytes\n", data_len);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
559 return;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
560 }
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
561
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
562 memset(&bs, 0, sizeof(bs));
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
563 bytes = 0;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
564 /* 000-030: qq_buddy_status */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
565 bytes += get_buddy_status(&bs, data + bytes);
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
566 /* 031-034: Unknow, maybe my uid */
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
567 /* This has a value of 0 when we've changed our status to
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
568 * QQ_BUDDY_ONLINE_INVISIBLE */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
569 bytes += qq_get32(&my_uid, data + bytes);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
570
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
571 buddy = qq_get_buddy(gc, bs.uid);
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
572 if (buddy == NULL) {
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
573 purple_debug_warning("QQ", "Get status of unknown buddy %d\n", bs.uid);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
574 return;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
575 }
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
576
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
577 if(bs.ip.s_addr != 0) {
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
578 buddy->ip.s_addr = bs.ip.s_addr;
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
579 buddy->port = bs.port;
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
580 }
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
581 buddy->status =bs.status;
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
582
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
583 if (buddy->status == QQ_BUDDY_ONLINE_NORMAL && buddy->level <= 0) {
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
584 if (qd->client_version >= 2007) {
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
585 qq_request_get_level_2007(gc, buddy->uid);
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
586 } else {
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
587 qq_request_get_level(gc, buddy->uid);
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
588 }
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
589 }
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
590 qq_update_buddy_contact(gc, buddy);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
591 }
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
592
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
593 /*TODO: maybe this should be qq_update_buddy_status() ?*/
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
594 void qq_update_buddy_contact(PurpleConnection *gc, qq_buddy *buddy)
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
595 {
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
596 gchar *purple_name;
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
597 PurpleBuddy *purple_buddy;
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
598 gchar *status_id;
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
599
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
600 g_return_if_fail(buddy != NULL);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
601
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
602 purple_name = uid_to_purple_name(buddy->uid);
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
603 if (purple_name == NULL) {
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
604 purple_debug_error("QQ", "Not find purple name: %d\n", buddy->uid);
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
605 return;
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
606 }
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
607
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
608 purple_buddy = purple_find_buddy(gc->account, purple_name);
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
609 if (purple_buddy == NULL) {
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
610 purple_debug_error("QQ", "Not find buddy: %d\n", buddy->uid);
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
611 g_free(purple_name);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
612 return;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
613 }
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
614
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
615 purple_blist_server_alias_buddy(purple_buddy, buddy->nickname); /* server */
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
616 buddy->last_update = time(NULL);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
617
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
618 /* purple supports signon and idle time
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
619 * but it is not much use for QQ, I do not use them */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
620 /* serv_got_update(gc, name, online, 0, q_bud->signon, q_bud->idle, bud->uc); */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
621 status_id = "available";
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
622 switch(buddy->status) {
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
623 case QQ_BUDDY_OFFLINE:
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
624 status_id = "offline";
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
625 break;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
626 case QQ_BUDDY_ONLINE_NORMAL:
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
627 status_id = "available";
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
628 break;
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
629 case QQ_BUDDY_CHANGE_TO_OFFLINE:
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
630 status_id = "offline";
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
631 break;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
632 case QQ_BUDDY_ONLINE_AWAY:
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
633 status_id = "away";
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
634 break;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
635 case QQ_BUDDY_ONLINE_INVISIBLE:
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
636 status_id = "invisible";
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
637 break;
24140
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
638 case QQ_BUDDY_ONLINE_BUSY:
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
639 status_id = "busy";
619ac2303c46 2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24137
diff changeset
640 break;
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
641 default:
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
642 status_id = "invisible";
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
643 purple_debug_error("QQ", "unknown status: %x\n", buddy->status);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
644 break;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
645 }
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
646 purple_debug_info("QQ", "buddy %d %s\n", buddy->uid, status_id);
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
647 purple_prpl_got_user_status(gc->account, purple_name, status_id, NULL);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
648
24142
df699d739b8f 2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24140
diff changeset
649 if (buddy->comm_flag & QQ_COMM_FLAG_MOBILE && buddy->status != QQ_BUDDY_OFFLINE)
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
650 purple_prpl_got_user_status(gc->account, purple_name, "mobile", NULL);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
651 else
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
652 purple_prpl_got_user_status_deactive(gc->account, purple_name, "mobile");
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
653
23695
5f454b975a99 2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23638
diff changeset
654 g_free(purple_name);
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
655 }
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
656
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
657 /* refresh all buddies online/offline,
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
658 * after receiving reply for get_buddies_online packet */
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
659 void qq_refresh_all_buddy_status(PurpleConnection *gc)
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
660 {
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
661 time_t now;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
662 GList *list;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
663 qq_data *qd;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
664 qq_buddy *q_bud;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
665
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
666 qd = (qq_data *) (gc->proto_data);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
667 now = time(NULL);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
668 list = qd->buddies;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
669
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
670 while (list != NULL) {
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
671 q_bud = (qq_buddy *) list->data;
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
672 if (q_bud != NULL && now > q_bud->last_update + QQ_UPDATE_ONLINE_INTERVAL
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
673 && q_bud->status != QQ_BUDDY_ONLINE_INVISIBLE) {
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
674 q_bud->status = QQ_BUDDY_CHANGE_TO_OFFLINE;
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
675 qq_update_buddy_contact(gc, q_bud);
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
676 }
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
677 list = list->next;
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
678 }
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
679 }