Mercurial > pidgin.yaz
annotate libpurple/protocols/qq/qq_base.c @ 26023:7252e3d0c627
Add files I missed committing before and remove a few unnecessary functions.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Mon, 20 Oct 2008 00:11:33 +0000 |
parents | bcfc98c7a55f |
children | bdfcfd71449c |
rev | line source |
---|---|
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
1 /** |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
2 * @file qq_base.c |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
3 * |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
4 * purple |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
5 * |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
6 * Purple is the legal property of its developers, whose names are too numerous |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
8 * source distribution. |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
9 * |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
10 * This program is free software; you can redistribute it and/or modify |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
13 * (at your option) any later version. |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
14 * |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
15 * This program is distributed in the hope that it will be useful, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
18 * GNU General Public License for more details. |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
19 * |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
20 * You should have received a copy of the GNU General Public License |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
21 * along with this program; if not, write to the Free Software |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
23 */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
24 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
25 #include "debug.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
26 #include "internal.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
27 #include "server.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
28 #include "cipher.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
29 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
30 #include "buddy_info.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
31 #include "buddy_list.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
32 #include "char_conv.h" |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23685
diff
changeset
|
33 #include "qq_crypt.h" |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
34 #include "group.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
35 #include "header_info.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
36 #include "qq_base.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
37 #include "packet_parse.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
38 #include "qq.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
39 #include "qq_network.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
40 #include "utils.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
41 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
42 #define QQ_LOGIN_DATA_LENGTH 416 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
43 #define QQ_LOGIN_REPLY_OK_PACKET_LEN 139 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
44 #define QQ_LOGIN_REPLY_REDIRECT_PACKET_LEN 11 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
45 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
46 /* for QQ 2003iii 0117, fixed value */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
47 /* static const guint8 login_23_51[29] = { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
48 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
49 0x00, 0x00, 0x00, 0x00, 0xbf, 0x14, 0x11, 0x20, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
50 0x03, 0x9d, 0xb2, 0xe6, 0xb3, 0x11, 0xb7, 0x13, |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
51 0x95, 0x67, 0xda, 0x2c, 0x01 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
52 }; */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
53 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
54 /* for QQ 2003iii 0304, fixed value */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
55 /* |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
56 static const guint8 login_23_51[29] = { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
57 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
58 0x00, 0x00, 0x00, 0x00, 0x9a, 0x93, 0xfe, 0x85, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
59 0xd3, 0xd9, 0x2a, 0x41, 0xc8, 0x0d, 0xff, 0xb6, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
60 0x40, 0xb8, 0xac, 0x32, 0x01 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
61 }; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
62 */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
63 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
64 /* for QQ 2005? copy from lumaqq */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
65 /* FIXME: change to guint8 */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
66 static const guint8 login_23_51[29] = { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
67 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
68 0x00, 0x00, 0x00, 0x00, 0x86, 0xcc, 0x4c, 0x35, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
69 0x2c, 0xd3, 0x73, 0x6c, 0x14, 0xf6, 0xf6, 0xaf, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
70 0xc3, 0xfa, 0x33, 0xa4, 0x01 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
71 }; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
72 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
73 static const guint8 login_53_68[16] = { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
74 0x8D, 0x8B, 0xFA, 0xEC, 0xD5, 0x52, 0x17, 0x4A, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
75 0x86, 0xF9, 0xA7, 0x75, 0xE6, 0x32, 0xD1, 0x6D |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
76 }; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
77 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
78 static const guint8 login_100_bytes[100] = { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
79 0x40, 0x0B, 0x04, 0x02, 0x00, 0x01, 0x00, 0x00, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
80 0x00, 0x00, 0x00, 0x03, 0x09, 0x00, 0x00, 0x00, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
81 0x00, 0x00, 0x00, 0x00, 0x01, 0xE9, 0x03, 0x01, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
82 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF3, 0x03, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
83 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xED, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
84 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
85 0xEC, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
86 0x03, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
87 0x00, 0x03, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
88 0x00, 0x00, 0x01, 0xEE, 0x03, 0x00, 0x00, 0x00, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
89 0x00, 0x00, 0x00, 0x01, 0xEF, 0x03, 0x00, 0x00, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
90 0x00, 0x00, 0x00, 0x00, 0x01, 0xEB, 0x03, 0x00, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
91 0x00, 0x00, 0x00, 0x00 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
92 }; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
93 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
94 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
95 /* fixed value, not affected by version, or mac address */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
96 /* |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
97 static const guint8 login_53_68[16] = { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
98 0x82, 0x2a, 0x91, 0xfd, 0xa5, 0xca, 0x67, 0x4c, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
99 0xac, 0x81, 0x1f, 0x6f, 0x52, 0x05, 0xa7, 0xbf |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
100 }; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
101 */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
102 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
103 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
104 typedef struct _qq_login_reply_ok qq_login_reply_ok_packet; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
105 typedef struct _qq_login_reply_redirect qq_login_reply_redirect_packet; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
106 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
107 struct _qq_login_reply_ok { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
108 guint8 result; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
109 guint8 session_key[QQ_KEY_LENGTH]; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
110 guint32 uid; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
111 struct in_addr client_ip; /* those detected by server */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
112 guint16 client_port; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
113 struct in_addr server_ip; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
114 guint16 server_port; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
115 time_t login_time; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
116 guint8 unknown1[26]; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
117 struct in_addr unknown_server1_ip; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
118 guint16 unknown_server1_port; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
119 struct in_addr unknown_server2_ip; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
120 guint16 unknown_server2_port; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
121 guint16 unknown2; /* 0x0001 */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
122 guint16 unknown3; /* 0x0000 */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
123 guint8 unknown4[32]; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
124 guint8 unknown5[12]; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
125 struct in_addr last_client_ip; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
126 time_t last_login_time; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
127 guint8 unknown6[8]; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
128 }; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
129 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
130 struct _qq_login_reply_redirect { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
131 guint8 result; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
132 guint32 uid; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
133 struct in_addr new_server_ip; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
134 guint16 new_server_port; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
135 }; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
136 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
137 /* generate a md5 key using uid and session_key */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
138 static void get_session_md5(guint8 *session_md5, guint32 uid, guint8 *session_key) |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
139 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
140 guint8 src[QQ_KEY_LENGTH + QQ_KEY_LENGTH]; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
141 gint bytes = 0; |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
142 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
143 bytes += qq_put32(src + bytes, uid); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
144 bytes += qq_putdata(src + bytes, session_key, QQ_KEY_LENGTH); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
145 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
146 qq_get_md5(session_md5, QQ_KEY_LENGTH, src, bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
147 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
148 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
149 /* process login reply which says OK */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
150 static gint8 process_login_ok(PurpleConnection *gc, guint8 *data, gint len) |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
151 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
152 gint bytes; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
153 qq_data *qd; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
154 qq_login_reply_ok_packet lrop; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
155 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
156 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
157 /* FIXME, check QQ_LOGIN_REPLY_OK_PACKET_LEN here */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
158 bytes = 0; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
159 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
160 /* 000-000: reply code */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
161 bytes += qq_get8(&lrop.result, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
162 /* 001-016: session key */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
163 bytes += qq_getdata(lrop.session_key, sizeof(lrop.session_key), data + bytes); |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
164 purple_debug_info("QQ", "Got session_key\n"); |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
165 /* 017-020: login uid */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
166 bytes += qq_get32(&lrop.uid, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
167 /* 021-024: server detected user public IP */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
168 bytes += qq_getIP(&lrop.client_ip, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
169 /* 025-026: server detected user port */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
170 bytes += qq_get16(&lrop.client_port, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
171 /* 027-030: server detected itself ip 127.0.0.1 ? */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
172 bytes += qq_getIP(&lrop.server_ip, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
173 /* 031-032: server listening port */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
174 bytes += qq_get16(&lrop.server_port, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
175 /* 033-036: login time for current session */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
176 bytes += qq_getime(&lrop.login_time, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
177 /* 037-062: 26 bytes, unknown */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
178 bytes += qq_getdata((guint8 *) &lrop.unknown1, 26, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
179 /* 063-066: unknown server1 ip address */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
180 bytes += qq_getIP(&lrop.unknown_server1_ip, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
181 /* 067-068: unknown server1 port */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
182 bytes += qq_get16(&lrop.unknown_server1_port, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
183 /* 069-072: unknown server2 ip address */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
184 bytes += qq_getIP(&lrop.unknown_server2_ip, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
185 /* 073-074: unknown server2 port */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
186 bytes += qq_get16(&lrop.unknown_server2_port, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
187 /* 075-076: 2 bytes unknown */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
188 bytes += qq_get16(&lrop.unknown2, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
189 /* 077-078: 2 bytes unknown */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
190 bytes += qq_get16(&lrop.unknown3, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
191 /* 079-110: 32 bytes unknown */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
192 bytes += qq_getdata((guint8 *) &lrop.unknown4, 32, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
193 /* 111-122: 12 bytes unknown */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
194 bytes += qq_getdata((guint8 *) &lrop.unknown5, 12, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
195 /* 123-126: login IP of last session */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
196 bytes += qq_getIP(&lrop.last_client_ip, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
197 /* 127-130: login time of last session */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
198 bytes += qq_getime(&lrop.last_login_time, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
199 /* 131-138: 8 bytes unknown */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
200 bytes += qq_getdata((guint8 *) &lrop.unknown6, 8, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
201 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
202 if (bytes != QQ_LOGIN_REPLY_OK_PACKET_LEN) { /* fail parsing login info */ |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
203 purple_debug_warning("QQ", |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
204 "Fail parsing login info, expect %d bytes, read %d bytes\n", |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
205 QQ_LOGIN_REPLY_OK_PACKET_LEN, bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
206 } /* but we still go on as login OK */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
207 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
208 memcpy(qd->session_key, lrop.session_key, sizeof(qd->session_key)); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
209 get_session_md5(qd->session_md5, qd->uid, qd->session_key); |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
210 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
211 qd->my_ip.s_addr = lrop.client_ip.s_addr; |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
212 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
213 qd->my_port = lrop.client_port; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
214 qd->login_time = lrop.login_time; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
215 qd->last_login_time = lrop.last_login_time; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
216 qd->last_login_ip = g_strdup( inet_ntoa(lrop.last_client_ip) ); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
217 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
218 return QQ_LOGIN_REPLY_OK; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
219 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
220 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
221 /* process login reply packet which includes redirected new server address */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
222 static gint8 process_login_redirect(PurpleConnection *gc, guint8 *data, gint len) |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
223 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
224 qq_data *qd; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
225 gint bytes; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
226 qq_login_reply_redirect_packet lrrp; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
227 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
228 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
229 bytes = 0; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
230 /* 000-000: reply code */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
231 bytes += qq_get8(&lrrp.result, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
232 /* 001-004: login uid */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
233 bytes += qq_get32(&lrrp.uid, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
234 /* 005-008: redirected new server IP */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
235 bytes += qq_getIP(&lrrp.new_server_ip, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
236 /* 009-010: redirected new server port */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
237 bytes += qq_get16(&lrrp.new_server_port, data + bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
238 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
239 if (bytes != QQ_LOGIN_REPLY_REDIRECT_PACKET_LEN) { |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
240 purple_debug_error("QQ", |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
241 "Fail parsing login redirect packet, expect %d bytes, read %d bytes\n", |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
242 QQ_LOGIN_REPLY_REDIRECT_PACKET_LEN, bytes); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
243 return QQ_LOGIN_REPLY_ERR_MISC; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
244 } |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
245 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
246 /* redirect to new server, do not disconnect or connect here |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
247 * those connect should be called at packet_process */ |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
248 qd->redirect_ip.s_addr = lrrp.new_server_ip.s_addr; |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
249 qd->redirect_port = lrrp.new_server_port; |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
250 return QQ_LOGIN_REPLY_REDIRECT; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
251 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
252 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
253 /* request before login */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
254 void qq_send_packet_token(PurpleConnection *gc) |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
255 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
256 qq_data *qd; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
257 guint8 buf[16] = {0}; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
258 gint bytes = 0; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
259 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
260 g_return_if_fail(gc != NULL && gc->proto_data != NULL); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
261 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
262 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
263 bytes += qq_put8(buf + bytes, 0); |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
264 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
265 qd->send_seq++; |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
266 qq_send_cmd_encrypted(gc, QQ_CMD_TOKEN, qd->send_seq, buf, bytes, TRUE); |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
267 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
268 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
269 /* send login packet to QQ server */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
270 void qq_send_packet_login(PurpleConnection *gc) |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
271 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
272 qq_data *qd; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
273 guint8 *buf, *raw_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
274 gint bytes; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
275 guint8 *encrypted_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
276 gint encrypted_len; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
277 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
278 g_return_if_fail(gc != NULL && gc->proto_data != NULL); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
279 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
280 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
281 g_return_if_fail(qd->token != NULL && qd->token_len > 0); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
282 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
283 #ifdef DEBUG |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
284 memset(qd->inikey, 0x01, sizeof(qd->inikey)); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
285 #else |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
286 for (bytes = 0; bytes < sizeof(qd->inikey); bytes++) { |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23685
diff
changeset
|
287 qd->inikey[bytes] = (guint8) (rand() & 0xff); |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
288 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
289 #endif |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
290 |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23685
diff
changeset
|
291 raw_data = g_newa(guint8, QQ_LOGIN_DATA_LENGTH); |
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23685
diff
changeset
|
292 memset(raw_data, 0, QQ_LOGIN_DATA_LENGTH); |
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23685
diff
changeset
|
293 |
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23685
diff
changeset
|
294 encrypted_data = g_newa(guint8, QQ_LOGIN_DATA_LENGTH + 16); /* 16 bytes more */ |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
295 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
296 bytes = 0; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
297 /* now generate the encrypted data |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
298 * 000-015 use password_twice_md5 as key to encrypt empty string */ |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23685
diff
changeset
|
299 encrypted_len = qq_encrypt(raw_data + bytes, (guint8 *) "", 0, qd->password_twice_md5); |
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23685
diff
changeset
|
300 g_return_if_fail(encrypted_len == 16); |
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23685
diff
changeset
|
301 bytes += encrypted_len; |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
302 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
303 /* 016-016 */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
304 bytes += qq_put8(raw_data + bytes, 0x00); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
305 /* 017-020, used to be IP, now zero */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
306 bytes += qq_put32(raw_data + bytes, 0x00000000); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
307 /* 021-022, used to be port, now zero */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
308 bytes += qq_put16(raw_data + bytes, 0x0000); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
309 /* 023-051, fixed value, unknown */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
310 bytes += qq_putdata(raw_data + bytes, login_23_51, 29); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
311 /* 052-052, login mode */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
312 bytes += qq_put8(raw_data + bytes, qd->login_mode); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
313 /* 053-068, fixed value, maybe related to per machine */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
314 bytes += qq_putdata(raw_data + bytes, login_53_68, 16); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
315 /* 069, login token length */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
316 bytes += qq_put8(raw_data + bytes, qd->token_len); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
317 /* 070-093, login token, normally 24 bytes */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
318 bytes += qq_putdata(raw_data + bytes, qd->token, qd->token_len); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
319 /* 100 bytes unknown */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
320 bytes += qq_putdata(raw_data + bytes, login_100_bytes, 100); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
321 /* all zero left */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
322 |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23685
diff
changeset
|
323 encrypted_len = qq_encrypt(encrypted_data, raw_data, QQ_LOGIN_DATA_LENGTH, qd->inikey); |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
324 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
325 buf = g_newa(guint8, MAX_PACKET_SIZE); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
326 memset(buf, 0, MAX_PACKET_SIZE); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
327 bytes = 0; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
328 bytes += qq_putdata(buf + bytes, qd->inikey, QQ_KEY_LENGTH); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
329 bytes += qq_putdata(buf + bytes, encrypted_data, encrypted_len); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
330 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
331 qd->send_seq++; |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
332 qq_send_cmd_encrypted(gc, QQ_CMD_LOGIN, qd->send_seq, buf, bytes, TRUE); |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
333 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
334 |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
335 guint8 qq_process_token_reply(PurpleConnection *gc, guint8 *buf, gint buf_len) |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
336 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
337 qq_data *qd; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
338 guint8 ret; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
339 int token_len; |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
340 gchar *error_msg; |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
341 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
342 g_return_val_if_fail(buf != NULL && buf_len != 0, -1); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
343 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
344 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL, -1); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
345 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
346 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
347 ret = buf[0]; |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
348 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
349 if (ret != QQ_TOKEN_REPLY_OK) { |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
350 purple_debug_error("QQ", "Failed to request token: %d\n", buf[0]); |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
351 qq_hex_dump(PURPLE_DEBUG_WARNING, "QQ", |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
352 buf, buf_len, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
353 ">>> [default] decrypt and dump"); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
354 error_msg = try_dump_as_gbk(buf, buf_len); |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
355 if (error_msg == NULL) { |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
356 error_msg = g_strdup_printf( _("Invalid token reply code, 0x%02X"), ret); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
357 } |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
358 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_msg); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
359 g_free(error_msg); |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
360 return ret; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
361 } |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
362 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
363 token_len = buf_len-2; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
364 if (token_len <= 0) { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
365 error_msg = g_strdup_printf( _("Invalid token len, %d"), token_len); |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
366 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_msg); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
367 g_free(error_msg); |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
368 return -1; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
369 } |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
370 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
371 if (buf[1] != token_len) { |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
372 purple_debug_info("QQ", |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
373 "Invalid token len. Packet specifies length of %d, actual length is %d\n", buf[1], buf_len-2); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
374 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
375 qq_hex_dump(PURPLE_DEBUG_INFO, "QQ", |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
376 buf+2, token_len, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
377 "<<< got a token -> [default] decrypt and dump"); |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
378 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
379 qd->token = g_new0(guint8, token_len); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
380 qd->token_len = token_len; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
381 g_memmove(qd->token, buf + 2, qd->token_len); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
382 return ret; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
383 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
384 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
385 /* send logout packets to QQ server */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
386 void qq_send_packet_logout(PurpleConnection *gc) |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
387 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
388 gint i; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
389 qq_data *qd; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
390 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
391 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
392 for (i = 0; i < 4; i++) |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
393 qq_send_cmd(gc, QQ_CMD_LOGOUT, qd->password_twice_md5, QQ_KEY_LENGTH); |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
394 |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
395 qd->is_login = FALSE; /* update login status AFTER sending logout packets */ |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
396 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
397 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
398 /* process the login reply packet */ |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
399 guint8 qq_process_login_reply( PurpleConnection *gc, guint8 *data, gint data_len) |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
400 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
401 qq_data *qd; |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
402 guint8 ret = data[0]; |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
403 gchar *server_reply, *server_reply_utf8; |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
404 gchar *error_msg; |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
405 |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23685
diff
changeset
|
406 g_return_val_if_fail(data != NULL && data_len != 0, QQ_LOGIN_REPLY_ERR_MISC); |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
407 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
408 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
409 |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
410 switch (ret) { |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
411 case QQ_LOGIN_REPLY_OK: |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
412 purple_debug_info("QQ", "Login OK\n"); |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
413 return process_login_ok(gc, data, data_len); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
414 case QQ_LOGIN_REPLY_REDIRECT: |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
415 purple_debug_info("QQ", "Redirect new server\n"); |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
416 return process_login_redirect(gc, data, data_len); |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
417 |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
418 case QQ_LOGIN_REPLY_REDIRECT_EX: |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
419 purple_debug_error("QQ", "Extend redirect new server, not supported yet\n"); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
420 error_msg = g_strdup( _("Unable login for not support Redirect_EX now") ); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
421 return QQ_LOGIN_REPLY_REDIRECT_EX; |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
422 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
423 case QQ_LOGIN_REPLY_ERR_PWD: |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
424 server_reply = g_strndup((gchar *)data + 1, data_len - 1); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
425 server_reply_utf8 = qq_to_utf8(server_reply, QQ_CHARSET_DEFAULT); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
426 |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
427 purple_debug_error("QQ", "Error password: %s\n", server_reply_utf8); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
428 error_msg = g_strdup_printf( _("Error password: %s"), server_reply_utf8); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
429 |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
430 g_free(server_reply); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
431 g_free(server_reply_utf8); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
432 |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
433 if (!purple_account_get_remember_password(gc->account)) { |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
434 purple_account_set_password(gc->account, NULL); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
435 } |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
436 |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
437 purple_connection_error_reason(gc, |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
438 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, error_msg); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
439 g_free(error_msg); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
440 |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
441 return QQ_LOGIN_REPLY_ERR_PWD; |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
442 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
443 case QQ_LOGIN_REPLY_NEED_REACTIVE: |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
444 server_reply = g_strndup((gchar *)data + 1, data_len - 1); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
445 server_reply_utf8 = qq_to_utf8(server_reply, QQ_CHARSET_DEFAULT); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
446 |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
447 purple_debug_error("QQ", "Need active: %s\n", server_reply_utf8); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
448 error_msg = g_strdup_printf( _("Need active: %s"), server_reply_utf8); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
449 |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
450 g_free(server_reply); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
451 g_free(server_reply_utf8); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
452 break; |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
453 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
454 default: |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
455 purple_debug_error("QQ", |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
456 "Unable login for unknow reply code 0x%02X\n", data[0]); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
457 qq_hex_dump(PURPLE_DEBUG_WARNING, "QQ", |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
458 data, data_len, |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
459 ">>> [default] decrypt and dump"); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
460 error_msg = try_dump_as_gbk(data, data_len); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
461 if (error_msg == NULL) { |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
462 error_msg = g_strdup_printf( |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
463 _("Unable login for unknow reply code 0x%02X"), data[0] ); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
464 } |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
465 break; |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
466 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
467 |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
468 purple_connection_error_reason(gc, |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
469 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_msg); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
470 g_free(error_msg); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
471 return ret; |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
472 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
473 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
474 /* send keep-alive packet to QQ server (it is a heart-beat) */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
475 void qq_send_packet_keep_alive(PurpleConnection *gc) |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
476 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
477 qq_data *qd; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
478 guint8 raw_data[16] = {0}; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
479 gint bytes= 0; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
480 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
481 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
482 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
483 /* In fact, we can send whatever we like to server |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
484 * with this command, server return the same result including |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
485 * the amount of online QQ users, my ip and port */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
486 bytes += qq_put32(raw_data + bytes, qd->uid); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
487 |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
488 qq_send_cmd(gc, QQ_CMD_KEEP_ALIVE, raw_data, 4); |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
489 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
490 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
491 /* parse the return of keep-alive packet, it includes some system information */ |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
492 gboolean qq_process_keep_alive(guint8 *data, gint data_len, PurpleConnection *gc) |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
493 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
494 qq_data *qd; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
495 gchar **segments; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
496 |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23685
diff
changeset
|
497 g_return_val_if_fail(data != NULL && data_len != 0, FALSE); |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
498 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
499 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
500 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
501 /* qq_show_packet("Keep alive reply packet", data, len); */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
502 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
503 /* the last one is 60, don't know what it is */ |
23753
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23685
diff
changeset
|
504 if (NULL == (segments = split_data(data, data_len, "\x1f", 6))) |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
505 return TRUE; |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
506 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
507 /* segments[0] and segment[1] are all 0x30 ("0") */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
508 qd->total_online = strtol(segments[2], NULL, 10); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
509 if(0 == qd->total_online) { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
510 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
511 _("Keep alive error")); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
512 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
513 qd->my_ip.s_addr = inet_addr(segments[3]); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
514 qd->my_port = strtol(segments[4], NULL, 10); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
515 |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
516 purple_debug_info("QQ", "keep alive, %s:%d\n", |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
517 inet_ntoa(qd->my_ip), qd->my_port); |
24046
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24026
diff
changeset
|
518 |
23685
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
519 g_strfreev(segments); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
520 return TRUE; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
521 } |