Mercurial > pidgin.yaz
annotate libpurple/protocols/qq/buddy_list.c @ 28768:3f2a74bf3b9b
Restore ChangeLog entry from 466c48e63... that was lost in 1bcd0bb175....
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Fri, 16 Oct 2009 20:45:02 +0000 |
parents | 73a30365c293 |
children | f1437342cc0e |
rev | line source |
---|---|
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2 * @file buddy_list.c |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
15823 | 4 * purple |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 * |
15823 | 6 * Purple is the legal property of its developers, whose names are too numerous |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * source distribution. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * along with this program; if not, write to the Free Software |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18210
diff
changeset
|
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 |
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 |
15374
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" |
25146
7f903e67a995
2009.02.09 - Chengming Wang <tiger2007532246(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24579
diff
changeset
|
34 #include "buddy_memo.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 #include "buddy_list.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 #include "buddy_opt.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 #include "char_conv.h" |
24065
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24048
diff
changeset
|
38 #include "qq_define.h" |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
39 #include "qq_base.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 #include "group.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 |
23052 | 44 #include "qq_network.h" |
15374
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 |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
49 typedef struct _qq_buddy_online { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 guint16 unknown1; |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
51 guint8 ext_flag; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 guint8 comm_flag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 guint16 unknown2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 guint8 ending; /* 0x00 */ |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
55 } qq_buddy_online; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 /* get a list of online_buddies */ |
25149
7da3cf2530b7
2009.02.21 - flos <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
25148
diff
changeset
|
58 void qq_request_get_buddies_online(PurpleConnection *gc, guint8 position, guint32 update_class) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 qq_data *qd; |
23050 | 61 guint8 *raw_data; |
62 gint bytes = 0; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 qd = (qq_data *) gc->proto_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 raw_data = g_newa(guint8, 5); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 /* 000-000 get online friends cmd |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 * 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
|
69 * 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
|
70 * and the result is the same */ |
23050 | 71 bytes += qq_put8(raw_data + bytes, QQ_GET_ONLINE_BUDDY_02); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 /* 001-001 seems it supports 255 online buddies at most */ |
23050 | 73 bytes += qq_put8(raw_data + bytes, position); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 /* 002-002 */ |
23050 | 75 bytes += qq_put8(raw_data + bytes, 0x00); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 /* 003-004 */ |
23050 | 77 bytes += qq_put16(raw_data + bytes, 0x0000); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
79 qq_send_cmd_mess(gc, QQ_CMD_GET_BUDDIES_ONLINE, raw_data, 5, update_class, 0); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
82 /* position starts with 0x0000, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 * server may return a position tag if list is too long for one packet */ |
25149
7da3cf2530b7
2009.02.21 - flos <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
25148
diff
changeset
|
84 void qq_request_get_buddies(PurpleConnection *gc, guint16 position, guint32 update_class) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 { |
24071
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24068
diff
changeset
|
86 qq_data *qd; |
23050 | 87 guint8 raw_data[16] = {0}; |
88 gint bytes = 0; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
89 |
24071
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24068
diff
changeset
|
90 qd = (qq_data *) gc->proto_data; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24068
diff
changeset
|
91 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 /* 000-001 starting position, can manually specify */ |
23050 | 93 bytes += qq_put16(raw_data + bytes, position); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
94 /* 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
|
95 * 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
|
96 * 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
|
97 * 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
|
98 * March 22, found the 00,00,00 starts to work as well */ |
23050 | 99 bytes += qq_put8(raw_data + bytes, 0x00); |
24071
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24068
diff
changeset
|
100 if (qd->client_version >= 2007) { |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24068
diff
changeset
|
101 bytes += qq_put16(raw_data + bytes, 0x0000); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24068
diff
changeset
|
102 } |
24077
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24076
diff
changeset
|
103 |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
104 qq_send_cmd_mess(gc, QQ_CMD_GET_BUDDIES_LIST, raw_data, bytes, update_class, 0); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 } |
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 /* get all list, buddies & Quns with groupsid support */ |
25149
7da3cf2530b7
2009.02.21 - flos <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
25148
diff
changeset
|
108 void qq_request_get_buddies_and_rooms(PurpleConnection *gc, guint32 position, guint32 update_class) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 { |
23050 | 110 guint8 raw_data[16] = {0}; |
111 gint bytes = 0; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 /* 0x01 download, 0x02, upload */ |
23050 | 114 bytes += qq_put8(raw_data + bytes, 0x01); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 /* unknown 0x02 */ |
23050 | 116 bytes += qq_put8(raw_data + bytes, 0x02); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 /* unknown 00 00 00 00 */ |
23050 | 118 bytes += qq_put32(raw_data + bytes, 0x00000000); |
119 bytes += qq_put32(raw_data + bytes, position); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
121 qq_send_cmd_mess(gc, QQ_CMD_GET_BUDDIES_AND_ROOMS, raw_data, bytes, update_class, 0); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
124 /* parse the data into qq_buddy_status */ |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
125 static gint get_buddy_status(qq_buddy_status *bs, guint8 *data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 { |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
127 gint bytes = 0; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
129 g_return_val_if_fail(data != NULL && bs != NULL, -1); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
131 /* 000-003: uid */ |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
132 bytes += qq_get32(&bs->uid, data + bytes); |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
133 /* 004-004: 0x01 */ |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
134 bytes += qq_get8(&bs->unknown1, data + bytes); |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
135 /* 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:
23606
diff
changeset
|
136 * the buddy's IP in this packet. all 0s */ |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
137 /* 005-008: ip */ |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
138 bytes += qq_getIP(&bs->ip, data + bytes); |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
139 /* port info is no longer here either */ |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
140 /* 009-010: port */ |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
141 bytes += qq_get16(&bs->port, data + bytes); |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
142 /* 011-011: 0x00 */ |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
143 bytes += qq_get8(&bs->unknown2, data + bytes); |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
144 /* 012-012: status */ |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
145 bytes += qq_get8(&bs->status, data + bytes); |
24066
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24065
diff
changeset
|
146 /* 013-014: client tag */ |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
147 bytes += qq_get16(&bs->unknown3, data + bytes); |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
148 /* 015-030: unknown key */ |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
149 bytes += qq_getdata(&(bs->unknown_key[0]), QQ_KEY_LENGTH, data + bytes); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 |
24579 | 151 purple_debug_info("QQ", "Status:%d, uid: %u, ip: %s:%d, U: %d - %d - %04X\n", |
152 bs->status, bs->uid, inet_ntoa(bs->ip), bs->port, | |
153 bs->unknown1, bs->unknown2, bs->unknown3); | |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
154 |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
155 return bytes; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
158 /* process the reply packet for get_buddies_online packet */ |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
159 guint8 qq_process_get_buddies_online(guint8 *data, gint data_len, PurpleConnection *gc) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 qq_data *qd; |
24073
df699d739b8f
2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24071
diff
changeset
|
162 gint bytes, bytes_start; |
23054
ebad75b719f5
Sun Jun 29 22:00:12 CST 2008 csyfek@gmail.com
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23053
diff
changeset
|
163 gint count; |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
164 guint8 position; |
24556
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
165 gchar *who; |
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
166 PurpleBuddy *buddy; |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
167 qq_buddy_data *bd; |
24073
df699d739b8f
2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24071
diff
changeset
|
168 int entry_len = 38; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
170 qq_buddy_status bs; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
171 struct { |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
172 guint16 unknown1; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
173 guint8 ext_flag; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
174 guint8 comm_flag; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
175 guint16 unknown2; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
176 guint8 ending; /* 0x00 */ |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
177 } packet; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
178 |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
179 g_return_val_if_fail(data != NULL && data_len != 0, -1); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 qd = (qq_data *) gc->proto_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
183 /* qq_show_packet("Get buddies online reply packet", data, len); */ |
24073
df699d739b8f
2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24071
diff
changeset
|
184 if (qd->client_version >= 2007) entry_len += 4; |
23050 | 185 |
186 bytes = 0; | |
187 bytes += qq_get8(&position, data + bytes); | |
188 | |
23054
ebad75b719f5
Sun Jun 29 22:00:12 CST 2008 csyfek@gmail.com
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23053
diff
changeset
|
189 count = 0; |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
190 while (bytes < data_len) { |
24073
df699d739b8f
2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24071
diff
changeset
|
191 if (data_len - bytes < entry_len) { |
24071
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24068
diff
changeset
|
192 purple_debug_error("QQ", "[buddies online] only %d, need %d\n", |
24073
df699d739b8f
2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24071
diff
changeset
|
193 (data_len - bytes), entry_len); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
194 break; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
195 } |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
196 memset(&bs, 0 ,sizeof(bs)); |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
197 memset(&packet, 0 ,sizeof(packet)); |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
198 |
23050 | 199 /* set flag */ |
24073
df699d739b8f
2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24071
diff
changeset
|
200 bytes_start = bytes; |
23050 | 201 /* based on one online buddy entry */ |
202 /* 000-030 qq_buddy_status */ | |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
203 bytes += get_buddy_status(&bs, data + bytes); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
204 /* 031-032: */ |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
205 bytes += qq_get16(&packet.unknown1, data + bytes); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
206 /* 033-033: ext_flag */ |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
207 bytes += qq_get8(&packet.ext_flag, data + bytes); |
23050 | 208 /* 034-034: comm_flag */ |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
209 bytes += qq_get8(&packet.comm_flag, data + bytes); |
23050 | 210 /* 035-036: */ |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
211 bytes += qq_get16(&packet.unknown2, data + bytes); |
23050 | 212 /* 037-037: */ |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
213 bytes += qq_get8(&packet.ending, data + bytes); /* 0x00 */ |
24073
df699d739b8f
2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24071
diff
changeset
|
214 /* skip 4 bytes in qq2007 */ |
df699d739b8f
2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24071
diff
changeset
|
215 if (qd->client_version >= 2007) bytes += 4; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
217 if (bs.uid == 0 || (bytes - bytes_start) != entry_len) { |
28571
73a30365c293
Add newline at end of debug messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26315
diff
changeset
|
218 purple_debug_error("QQ", "uid=0 or entry complete len(%d) != %d\n", |
24073
df699d739b8f
2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24071
diff
changeset
|
219 (bytes - bytes_start), entry_len); |
23050 | 220 continue; |
221 } /* check if it is a valid entry */ | |
222 | |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
223 if (bs.uid == qd->uid) { |
24556
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
224 purple_debug_warning("QQ", "I am in online list %u\n", bs.uid); |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
225 } |
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
226 |
23050 | 227 /* update buddy information */ |
24556
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
228 who = uid_to_purple_name(bs.uid); |
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
229 buddy = purple_find_buddy(gc->account, who); |
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
230 g_free(who); |
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
231 if (buddy == NULL) { |
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
232 /* create no-auth buddy */ |
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
233 buddy = qq_buddy_new(gc, bs.uid); |
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
234 } |
25397
716b14deee97
a few struct hiding clean ups
Gary Kramlich <grim@reaperworld.com>
parents:
25362
diff
changeset
|
235 bd = (buddy == NULL) ? NULL : (qq_buddy_data *)purple_buddy_get_protocol_data(buddy); |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
236 if (bd == NULL) { |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
237 purple_debug_error("QQ", |
24556
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
238 "Got an online buddy %u, but not in my buddy list\n", bs.uid); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
239 continue; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 } |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
241 /* |
24066
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24065
diff
changeset
|
242 if(0 != fe->s->client_tag) |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24065
diff
changeset
|
243 q_bud->client_tag = fe->s->client_tag; |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
244 */ |
24088
1ee91ff0d5fe
2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24087
diff
changeset
|
245 if (bd->status != bs.status || bd->comm_flag != packet.comm_flag) { |
1ee91ff0d5fe
2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24087
diff
changeset
|
246 bd->status = bs.status; |
1ee91ff0d5fe
2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24087
diff
changeset
|
247 bd->comm_flag = packet.comm_flag; |
1ee91ff0d5fe
2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24087
diff
changeset
|
248 qq_update_buddy_status(gc, bd->uid, bd->status, bd->comm_flag); |
1ee91ff0d5fe
2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24087
diff
changeset
|
249 } |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
250 bd->ip.s_addr = bs.ip.s_addr; |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
251 bd->port = bs.port; |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
252 bd->ext_flag = packet.ext_flag; |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
253 bd->last_update = time(NULL); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
254 count++; |
23050 | 255 } |
256 | |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
257 if(bytes > data_len) { |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
258 purple_debug_error("QQ", |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
259 "qq_process_get_buddies_online: Dangerous error! maybe protocol changed, notify developers!\n"); |
23050 | 260 } |
261 | |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
262 purple_debug_info("QQ", "Received %d online buddies, nextposition=%u\n", |
24087
147f1b17b6ce
2008.10.08 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24085
diff
changeset
|
263 count, (guint) position); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
264 return position; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 |
23050 | 267 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 /* process reply for get_buddies_list */ |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
269 guint16 qq_process_get_buddies(guint8 *data, gint data_len, PurpleConnection *gc) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 qq_data *qd; |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
272 qq_buddy_data bd; |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
273 gint bytes_expected, count; |
23050 | 274 gint bytes, buddy_bytes; |
24077
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24076
diff
changeset
|
275 gint nickname_len; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 guint16 position, unknown; |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
277 PurpleBuddy *buddy; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
279 g_return_val_if_fail(data != NULL && data_len != 0, -1); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 qd = (qq_data *) gc->proto_data; |
23050 | 282 |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
283 if (data_len <= 2) { |
28571
73a30365c293
Add newline at end of debug messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26315
diff
changeset
|
284 purple_debug_error("QQ", "empty buddies list\n"); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
285 return -1; |
23050 | 286 } |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
287 /* qq_show_packet("QQ get buddies list", data, data_len); */ |
23050 | 288 bytes = 0; |
289 bytes += qq_get16(&position, data + bytes); | |
290 /* the following data is buddy list in this packet */ | |
23054
ebad75b719f5
Sun Jun 29 22:00:12 CST 2008 csyfek@gmail.com
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23053
diff
changeset
|
291 count = 0; |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
292 while (bytes < data_len) { |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
293 memset(&bd, 0, sizeof(bd)); |
23050 | 294 /* set flag */ |
295 buddy_bytes = bytes; | |
296 /* 000-003: uid */ | |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
297 bytes += qq_get32(&bd.uid, data + bytes); |
23050 | 298 /* 004-005: icon index (1-255) */ |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
299 bytes += qq_get16(&bd.face, data + bytes); |
23050 | 300 /* 006-006: age */ |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
301 bytes += qq_get8(&bd.age, data + bytes); |
23050 | 302 /* 007-007: gender */ |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
303 bytes += qq_get8(&bd.gender, data + bytes); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
304 |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
305 nickname_len = qq_get_vstr(&bd.nickname, QQ_CHARSET_DEFAULT, data + bytes); |
24077
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24076
diff
changeset
|
306 bytes += nickname_len; |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
307 qq_filter_str(bd.nickname); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
308 |
24071
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24068
diff
changeset
|
309 /* Fixme: merge following as 32bit flag */ |
23050 | 310 bytes += qq_get16(&unknown, data + bytes); |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
311 bytes += qq_get8(&bd.ext_flag, data + bytes); |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
312 bytes += qq_get8(&bd.comm_flag, data + bytes); |
24077
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24076
diff
changeset
|
313 |
24071
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24068
diff
changeset
|
314 if (qd->client_version >= 2007) { |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24068
diff
changeset
|
315 bytes += 4; /* skip 4 bytes */ |
24077
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24076
diff
changeset
|
316 bytes_expected = 16 + nickname_len; |
24071
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24068
diff
changeset
|
317 } else { |
24077
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24076
diff
changeset
|
318 bytes_expected = 12 + nickname_len; |
24071
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24068
diff
changeset
|
319 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
320 |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
321 if (bd.uid == 0 || (bytes - buddy_bytes) != bytes_expected) { |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
322 purple_debug_info("QQ", |
24556
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
323 "Buddy entry, expect %d bytes, read %d bytes\n", |
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
324 bytes_expected, bytes - buddy_bytes); |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
325 g_free(bd.nickname); |
23050 | 326 continue; |
327 } else { | |
23054
ebad75b719f5
Sun Jun 29 22:00:12 CST 2008 csyfek@gmail.com
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23053
diff
changeset
|
328 count++; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
329 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
331 #if 1 |
24048
d57928c9dd8f
2008.09.19 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24046
diff
changeset
|
332 purple_debug_info("QQ", "buddy [%09d]: ext_flag=0x%02x, comm_flag=0x%02x, nick=%s\n", |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
333 bd.uid, bd.ext_flag, bd.comm_flag, bd.nickname); |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
334 #endif |
23050 | 335 |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
336 buddy = qq_buddy_find_or_new(gc, bd.uid); |
25298
e35115192593
Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents:
24091
diff
changeset
|
337 if (buddy == NULL || purple_buddy_get_protocol_data(buddy) == NULL) { |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
338 g_free(bd.nickname); |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
339 continue; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
340 } |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
341 purple_blist_server_alias_buddy(buddy, bd.nickname); |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
342 bd.last_update = time(NULL); |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
343 qq_update_buddy_status(gc, bd.uid, bd.status, bd.comm_flag); |
23050 | 344 |
25298
e35115192593
Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents:
24091
diff
changeset
|
345 g_memmove(purple_buddy_get_protocol_data(buddy), &bd, sizeof(qq_buddy_data)); |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
346 /* nickname has been copy to buddy_data do not free |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
347 g_free(bd.nickname); |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
348 */ |
25150
d673ccc44a6e
2009.02.24 - flos <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
25149
diff
changeset
|
349 /*qq_request_buddy_memo(gc, ((qq_buddy_data*)buddy->proto_data)->uid, 0, QQ_BUDDY_MEMO_GET);*/ |
d673ccc44a6e
2009.02.24 - flos <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
25149
diff
changeset
|
350 qq_request_buddy_memo(gc, bd.uid, bd.uid, QQ_BUDDY_MEMO_GET); |
23050 | 351 } |
352 | |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
353 if(bytes > data_len) { |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
354 purple_debug_error("QQ", |
28571
73a30365c293
Add newline at end of debug messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26315
diff
changeset
|
355 "qq_process_get_buddies: Dangerous error! maybe protocol changed, notify developers!\n"); |
23050 | 356 } |
23054
ebad75b719f5
Sun Jun 29 22:00:12 CST 2008 csyfek@gmail.com
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23053
diff
changeset
|
357 |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
358 purple_debug_info("QQ", "Received %d buddies, nextposition=%u\n", |
23054
ebad75b719f5
Sun Jun 29 22:00:12 CST 2008 csyfek@gmail.com
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23053
diff
changeset
|
359 count, (guint) position); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
360 return position; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
362 |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
363 guint32 qq_process_get_buddies_and_rooms(guint8 *data, gint data_len, PurpleConnection *gc) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
364 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
365 qq_data *qd; |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
366 gint i, j; |
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
367 gint bytes; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
368 guint8 sub_cmd, reply_code; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
369 guint32 unknown, position; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
370 guint32 uid; |
24087
147f1b17b6ce
2008.10.08 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24085
diff
changeset
|
371 guint8 type; |
24088
1ee91ff0d5fe
2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24087
diff
changeset
|
372 qq_room_data *rmd; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
373 |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
374 g_return_val_if_fail(data != NULL && data_len != 0, -1); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
375 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
376 qd = (qq_data *) gc->proto_data; |
23050 | 377 |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
378 bytes = 0; |
23050 | 379 bytes += qq_get8(&sub_cmd, data + bytes); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
380 g_return_val_if_fail(sub_cmd == 0x01, -1); |
23050 | 381 |
382 bytes += qq_get8(&reply_code, data + bytes); | |
383 if(0 != reply_code) { | |
24077
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24076
diff
changeset
|
384 purple_debug_warning("QQ", "qq_process_get_buddies_and_rooms, %d\n", reply_code); |
23050 | 385 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
386 |
23050 | 387 bytes += qq_get32(&unknown, data + bytes); |
388 bytes += qq_get32(&position, data + bytes); | |
389 /* the following data is all list in this packet */ | |
390 i = 0; | |
391 j = 0; | |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
392 while (bytes < data_len) { |
23050 | 393 /* 00-03: uid */ |
394 bytes += qq_get32(&uid, data + bytes); | |
395 /* 04: type 0x1:buddy 0x4:Qun */ | |
396 bytes += qq_get8(&type, data + bytes); | |
24087
147f1b17b6ce
2008.10.08 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24085
diff
changeset
|
397 /* 05: skip unknow 0x00 */ |
147f1b17b6ce
2008.10.08 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24085
diff
changeset
|
398 bytes += 1; |
23050 | 399 if (uid == 0 || (type != 0x1 && type != 0x4)) { |
28571
73a30365c293
Add newline at end of debug messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26315
diff
changeset
|
400 purple_debug_info("QQ", "Buddy entry, uid=%u, type=%d\n", uid, type); |
23050 | 401 continue; |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
402 } |
23050 | 403 if(0x1 == type) { /* a buddy */ |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
404 /* don't do anything but count - buddies are handled by |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
405 * qq_request_get_buddies */ |
23050 | 406 ++i; |
407 } else { /* a group */ | |
24088
1ee91ff0d5fe
2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24087
diff
changeset
|
408 rmd = qq_room_data_find(gc, uid); |
1ee91ff0d5fe
2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24087
diff
changeset
|
409 if(rmd == NULL) { |
28571
73a30365c293
Add newline at end of debug messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26315
diff
changeset
|
410 purple_debug_info("QQ", "Unknown room id %u\n", uid); |
24088
1ee91ff0d5fe
2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24087
diff
changeset
|
411 qq_send_room_cmd_only(gc, QQ_ROOM_CMD_GET_INFO, uid); |
23050 | 412 } else { |
24088
1ee91ff0d5fe
2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24087
diff
changeset
|
413 rmd->my_role = QQ_ROOM_ROLE_YES; |
23050 | 414 } |
415 ++j; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
417 } |
23050 | 418 |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
419 if(bytes > data_len) { |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
420 purple_debug_error("QQ", |
28571
73a30365c293
Add newline at end of debug messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26315
diff
changeset
|
421 "qq_process_get_buddies_and_rooms: Dangerous error! maybe protocol changed, notify developers!\n"); |
23050 | 422 } |
423 | |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
424 purple_debug_info("QQ", "Received %d buddies and %d groups, nextposition=%u\n", i, j, (guint) position); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
425 return position; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
426 } |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
427 |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
428 #define QQ_MISC_STATUS_HAVING_VIIDEO 0x00000001 |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
429 #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:
23606
diff
changeset
|
430 |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
431 /* 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:
24045
diff
changeset
|
432 * but the port number's weird, other times I get 0s. I get these simultaneously on the same buddy, |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
433 * using different accounts to get info. */ |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
434 static guint8 get_status_from_purple(PurpleConnection *gc) |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
435 { |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
436 qq_data *qd; |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
437 PurpleAccount *account; |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
438 PurplePresence *presence; |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
439 guint8 ret; |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
440 |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
441 qd = (qq_data *) gc->proto_data; |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
442 account = purple_connection_get_account(gc); |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
443 presence = purple_account_get_presence(account); |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
444 |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
445 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_INVISIBLE)) { |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
446 ret = QQ_BUDDY_ONLINE_INVISIBLE; |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
447 } else if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_UNAVAILABLE)) |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
448 { |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
449 if (qd->client_version >= 2007) { |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
450 ret = QQ_BUDDY_ONLINE_BUSY; |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
451 } else { |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
452 ret = QQ_BUDDY_ONLINE_INVISIBLE; |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
453 } |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
454 } else if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_AWAY) |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
455 || purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_EXTENDED_AWAY) |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
456 || purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_UNAVAILABLE)) { |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
457 ret = QQ_BUDDY_ONLINE_AWAY; |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
458 } else { |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
459 ret = QQ_BUDDY_ONLINE_NORMAL; |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
460 } |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
461 return ret; |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
462 } |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
463 |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
464 /* send a packet to change my online status */ |
25149
7da3cf2530b7
2009.02.21 - flos <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
25148
diff
changeset
|
465 void qq_request_change_status(PurpleConnection *gc, guint32 update_class) |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
466 { |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
467 qq_data *qd; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
468 guint8 raw_data[16] = {0}; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
469 gint bytes = 0; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
470 guint8 away_cmd; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
471 guint32 misc_status; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
472 gboolean fake_video; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
473 PurpleAccount *account; |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
474 PurplePresence *presence; |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
475 |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
476 account = purple_connection_get_account(gc); |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
477 presence = purple_account_get_presence(account); |
23606
bdb38a8bf721
20080717-05-1-fix-keep-alive ccpaging <ecc_hy(at)hotmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23054
diff
changeset
|
478 |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
479 qd = (qq_data *) gc->proto_data; |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
480 if (!qd->is_login) |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
481 return; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
482 |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
483 away_cmd = get_status_from_purple(gc); |
24077
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24076
diff
changeset
|
484 |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
485 misc_status = 0x00000000; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
486 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:
23606
diff
changeset
|
487 if (fake_video) |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
488 misc_status |= QQ_MISC_STATUS_HAVING_VIIDEO; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
489 |
24071
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24068
diff
changeset
|
490 if (qd->client_version >= 2007) { |
24068
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24066
diff
changeset
|
491 bytes = 0; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24066
diff
changeset
|
492 bytes += qq_put8(raw_data + bytes, away_cmd); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24066
diff
changeset
|
493 /* status version */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24066
diff
changeset
|
494 bytes += qq_put16(raw_data + bytes, 0); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24066
diff
changeset
|
495 bytes += qq_put16(raw_data + bytes, 0); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24066
diff
changeset
|
496 bytes += qq_put32(raw_data + bytes, misc_status); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24066
diff
changeset
|
497 /* Fixme: custom status message, now is empty */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24066
diff
changeset
|
498 bytes += qq_put16(raw_data + bytes, 0); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24066
diff
changeset
|
499 } else { |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24066
diff
changeset
|
500 bytes = 0; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24066
diff
changeset
|
501 bytes += qq_put8(raw_data + bytes, away_cmd); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24066
diff
changeset
|
502 bytes += qq_put32(raw_data + bytes, misc_status); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24066
diff
changeset
|
503 } |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
504 qq_send_cmd_mess(gc, QQ_CMD_CHANGE_STATUS, raw_data, bytes, update_class, 0); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
505 } |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
506 |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
507 /* parse the reply packet for change_status */ |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
508 void qq_process_change_status(guint8 *data, gint data_len, PurpleConnection *gc) |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
509 { |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
510 qq_data *qd; |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
511 gint bytes; |
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
512 guint8 reply; |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
513 qq_buddy_data *bd; |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
514 |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
515 g_return_if_fail(data != NULL && data_len != 0); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
516 |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
517 qd = (qq_data *) gc->proto_data; |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
518 |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
519 bytes = 0; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
520 bytes = qq_get8(&reply, data + bytes); |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
521 if (reply != QQ_CHANGE_ONLINE_STATUS_REPLY_OK) { |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
522 purple_debug_warning("QQ", "Change status fail 0x%02X\n", reply); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
523 return; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
524 } |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
525 |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
526 /* purple_debug_info("QQ", "Change status OK\n"); */ |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
527 bd = qq_buddy_data_find(gc, qd->uid); |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
528 if (bd != NULL) { |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
529 bd->status = get_status_from_purple(gc); |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
530 bd->last_update = time(NULL); |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
531 qq_update_buddy_status(gc, bd->uid, bd->status, bd->comm_flag); |
23054
ebad75b719f5
Sun Jun 29 22:00:12 CST 2008 csyfek@gmail.com
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23053
diff
changeset
|
532 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
533 } |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
534 |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
535 /* it is a server message indicating that one of my buddies has changed its status */ |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
536 void qq_process_buddy_change_status(guint8 *data, gint data_len, PurpleConnection *gc) |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
537 { |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
538 qq_data *qd; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
539 gint bytes; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
540 guint32 my_uid; |
24556
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
541 gchar *who; |
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
542 PurpleBuddy *buddy; |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
543 qq_buddy_data *bd; |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
544 qq_buddy_status bs; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
545 |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23683
diff
changeset
|
546 g_return_if_fail(data != NULL && data_len != 0); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
547 |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
548 qd = (qq_data *) gc->proto_data; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
549 |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
550 if (data_len < 35) { |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
551 purple_debug_error("QQ", "[buddy status change] only %d, need 35 bytes\n", data_len); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
552 return; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
553 } |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
554 |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
555 memset(&bs, 0, sizeof(bs)); |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
556 bytes = 0; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
557 /* 000-030: qq_buddy_status */ |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
558 bytes += get_buddy_status(&bs, data + bytes); |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
559 /* 031-034: Unknow, maybe my uid */ |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
560 /* This has a value of 0 when we've changed our status to |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
561 * QQ_BUDDY_ONLINE_INVISIBLE */ |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
562 bytes += qq_get32(&my_uid, data + bytes); |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
563 |
24556
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
564 /* update buddy information */ |
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
565 who = uid_to_purple_name(bs.uid); |
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
566 buddy = purple_find_buddy(gc->account, who); |
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
567 g_free(who); |
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
568 if (buddy == NULL) { |
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
569 /* create no-auth buddy */ |
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
570 buddy = qq_buddy_new(gc, bs.uid); |
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
571 } |
25397
716b14deee97
a few struct hiding clean ups
Gary Kramlich <grim@reaperworld.com>
parents:
25362
diff
changeset
|
572 bd = (buddy == NULL) ? NULL : (qq_buddy_data *)purple_buddy_get_protocol_data(buddy); |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
573 if (bd == NULL) { |
24579 | 574 purple_debug_warning("QQ", "Got status of no-auth buddy %u\n", bs.uid); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
575 return; |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
576 } |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
577 |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24045
diff
changeset
|
578 if(bs.ip.s_addr != 0) { |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
579 bd->ip.s_addr = bs.ip.s_addr; |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
580 bd->port = bs.port; |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
581 } |
24088
1ee91ff0d5fe
2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24087
diff
changeset
|
582 if (bd->status != bs.status) { |
1ee91ff0d5fe
2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24087
diff
changeset
|
583 bd->status = bs.status; |
1ee91ff0d5fe
2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24087
diff
changeset
|
584 qq_update_buddy_status(gc, bd->uid, bd->status, bd->comm_flag); |
1ee91ff0d5fe
2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24087
diff
changeset
|
585 } |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
586 bd->last_update = time(NULL); |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
587 |
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
588 if (bd->status == QQ_BUDDY_ONLINE_NORMAL && bd->level <= 0) { |
24073
df699d739b8f
2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24071
diff
changeset
|
589 if (qd->client_version >= 2007) { |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
590 qq_request_get_level_2007(gc, bd->uid); |
24073
df699d739b8f
2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24071
diff
changeset
|
591 } else { |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
592 qq_request_get_level(gc, bd->uid); |
24073
df699d739b8f
2008.10.03 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24071
diff
changeset
|
593 } |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
594 } |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
595 } |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
596 |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
597 /*TODO: maybe this should be qq_update_buddy_status() ?*/ |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
598 void qq_update_buddy_status(PurpleConnection *gc, guint32 uid, guint8 status, guint8 flag) |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
599 { |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
600 gchar *who; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
601 gchar *status_id; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
602 |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
603 g_return_if_fail(uid != 0); |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
604 |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
605 /* purple supports signon and idle time |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
606 * but it is not much use for QQ, I do not use them */ |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
607 /* serv_got_update(gc, name, online, 0, q_bud->signon, q_bud->idle, bud->uc); */ |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
608 status_id = "available"; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
609 switch(status) { |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
610 case QQ_BUDDY_OFFLINE: |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
611 status_id = "offline"; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
612 break; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
613 case QQ_BUDDY_ONLINE_NORMAL: |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
614 status_id = "available"; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
615 break; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
616 case QQ_BUDDY_CHANGE_TO_OFFLINE: |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
617 status_id = "offline"; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
618 break; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
619 case QQ_BUDDY_ONLINE_AWAY: |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
620 status_id = "away"; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
621 break; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
622 case QQ_BUDDY_ONLINE_INVISIBLE: |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
623 status_id = "invisible"; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
624 break; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
625 case QQ_BUDDY_ONLINE_BUSY: |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
626 status_id = "busy"; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
627 break; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
628 default: |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
629 status_id = "invisible"; |
24091
d35672443baa
2008.10.10 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24088
diff
changeset
|
630 purple_debug_error("QQ", "unknown status: 0x%X\n", status); |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
631 break; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
632 } |
24556
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
633 |
24579 | 634 purple_debug_info("QQ", "buddy %u status = %s\n", uid, status_id); |
24556
b22f6fb98cca
Change QQ number to unsigned long
Hu Yong <ccpaging@gmail.com>
parents:
24091
diff
changeset
|
635 who = uid_to_purple_name(uid); |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
636 purple_prpl_got_user_status(gc->account, who, status_id, NULL); |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
637 |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
638 if (flag & QQ_COMM_FLAG_MOBILE && status != QQ_BUDDY_OFFLINE) |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
639 purple_prpl_got_user_status(gc->account, who, "mobile", NULL); |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
640 else |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
641 purple_prpl_got_user_status_deactive(gc->account, who, "mobile"); |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
642 |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
643 g_free(who); |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
644 } |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
645 |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
646 /* refresh all buddies online/offline, |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
647 * after receiving reply for get_buddies_online packet */ |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
648 void qq_update_buddyies_status(PurpleConnection *gc) |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
649 { |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
650 qq_data *qd; |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
651 PurpleBuddy *buddy; |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
652 qq_buddy_data *bd; |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
653 GSList *buddies, *it; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
654 time_t tm_limit = time(NULL); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
655 |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
656 qd = (qq_data *) (gc->proto_data); |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
657 |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
658 tm_limit -= QQ_UPDATE_ONLINE_INTERVAL; |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
659 |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
660 buddies = purple_find_buddies(purple_connection_get_account(gc), NULL); |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
661 for (it = buddies; it; it = it->next) { |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
662 buddy = it->data; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
663 if (buddy == NULL) continue; |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
664 |
25298
e35115192593
Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents:
24091
diff
changeset
|
665 bd = purple_buddy_get_protocol_data(buddy); |
e35115192593
Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents:
24091
diff
changeset
|
666 if (bd == NULL) continue; |
e35115192593
Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents:
24091
diff
changeset
|
667 |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
668 if (bd->uid == 0) continue; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
669 if (bd->uid == qd->uid) continue; /* my status is always online in my buddy list */ |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
670 if (tm_limit < bd->last_update) continue; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
671 if (bd->status == QQ_BUDDY_ONLINE_INVISIBLE) continue; |
24088
1ee91ff0d5fe
2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24087
diff
changeset
|
672 if (bd->status == QQ_BUDDY_CHANGE_TO_OFFLINE) continue; |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
673 |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
674 bd->status = QQ_BUDDY_CHANGE_TO_OFFLINE; |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
675 bd->last_update = time(NULL); |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
676 qq_update_buddy_status(gc, bd->uid, bd->status, bd->comm_flag); |
23683
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
677 } |
1c50f12b1c52
2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23606
diff
changeset
|
678 } |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
679 |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
680 void qq_buddy_data_free_all(PurpleConnection *gc) |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
681 { |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
682 qq_data *qd; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
683 PurpleBuddy *buddy; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
684 GSList *buddies, *it; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
685 gint count = 0; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
686 |
25298
e35115192593
Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents:
24091
diff
changeset
|
687 qd = (qq_data *)purple_connection_get_protocol_data(gc); |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
688 |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
689 buddies = purple_find_buddies(purple_connection_get_account(gc), NULL); |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
690 for (it = buddies; it; it = it->next) { |
25298
e35115192593
Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents:
24091
diff
changeset
|
691 qq_buddy_data *qbd = NULL; |
e35115192593
Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents:
24091
diff
changeset
|
692 |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
693 buddy = it->data; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
694 if (buddy == NULL) continue; |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
695 |
25298
e35115192593
Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents:
24091
diff
changeset
|
696 qbd = purple_buddy_get_protocol_data(buddy); |
e35115192593
Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents:
24091
diff
changeset
|
697 if (qbd == NULL) continue; |
e35115192593
Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents:
24091
diff
changeset
|
698 |
e35115192593
Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents:
24091
diff
changeset
|
699 qq_buddy_data_free(qbd); |
e35115192593
Finished struct hiding in bonjour and qq
Gary Kramlich <grim@reaperworld.com>
parents:
24091
diff
changeset
|
700 purple_buddy_set_protocol_data(buddy, NULL); |
24080
818ab62006f5
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24079
diff
changeset
|
701 |
24079
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
702 count++; |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
703 } |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
704 |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
705 if (count > 0) { |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
706 purple_debug_info("QQ", "%d buddies' data are freed\n", count); |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
707 } |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
708 } |
1bdf7b602684
2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24077
diff
changeset
|
709 |