Mercurial > pidgin
annotate libpurple/protocols/qq/qq_base.c @ 25538:27e6ab4ff554
This should fix a sporadic crash? The behavior before was clearly wrong--
there's no need to check that body != NULL twice. This behavior should
be better... but this probably shouldn't be a g_return(), since we don't
control the data sent to us by the server it shouldn't be considered a
programming error if they fail to send us the "Completed" key
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 26 Feb 2009 08:14:24 +0000 |
parents | 8f757b2139d2 |
children | f541583e31bd |
rev | line source |
---|---|
23640
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" |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
29 #include "request.h" |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
30 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
31 #include "buddy_info.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
32 #include "buddy_list.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
33 #include "char_conv.h" |
23695
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23640
diff
changeset
|
34 #include "qq_crypt.h" |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
35 #include "group.h" |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
36 #include "qq_define.h" |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
37 #include "qq_network.h" |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
38 #include "qq_base.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
39 #include "packet_parse.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
40 #include "qq.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
41 #include "qq_network.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
42 #include "utils.h" |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
43 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
44 /* 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
|
45 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
|
46 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
47 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
|
48 gint bytes = 0; |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
49 |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
50 bytes += qq_put32(src + bytes, uid); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
51 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
|
52 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
53 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
|
54 } |
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 /* process login reply which says OK */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
57 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
|
58 { |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
59 qq_data *qd; |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
60 gint bytes; |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
61 |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
62 guint8 ret; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
63 guint32 uid; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
64 struct in_addr ip; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
65 guint16 port; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
66 struct tm *tm_local; |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
67 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
68 qd = (qq_data *) gc->proto_data; |
24146
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24145
diff
changeset
|
69 /* qq_show_packet("Login reply", data, len); */ |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
70 |
24622
d8af9602c1b1
Correct QQ2005's login reply length
Hu Yong <ccpaging@gmail.com>
parents:
24161
diff
changeset
|
71 if (len < 148) { |
d8af9602c1b1
Correct QQ2005's login reply length
Hu Yong <ccpaging@gmail.com>
parents:
24161
diff
changeset
|
72 qq_show_packet("Login reply OK, but length < 139", data, len); |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
73 purple_connection_error_reason(gc, |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
74 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, |
24679
55b7371eadf4
Fix some English in the QQ plugin. And remove some translated phrases that are
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24678
diff
changeset
|
75 _("Cannot decrypt server reply")); |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
76 return QQ_LOGIN_REPLY_ERR; |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
77 } |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
78 |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
79 bytes = 0; |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
80 bytes += qq_get8(&ret, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
81 bytes += qq_getdata(qd->session_key, sizeof(qd->session_key), data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
82 get_session_md5(qd->session_md5, qd->uid, qd->session_key); |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
83 purple_debug_info("QQ", "Got session_key\n"); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
84 bytes += qq_get32(&uid, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
85 if (uid != qd->uid) { |
24622
d8af9602c1b1
Correct QQ2005's login reply length
Hu Yong <ccpaging@gmail.com>
parents:
24161
diff
changeset
|
86 purple_debug_warning("QQ", "My uid in login reply is %u, not %u\n", uid, qd->uid); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
87 } |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
88 bytes += qq_getIP(&qd->my_ip, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
89 bytes += qq_get16(&qd->my_port, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
90 purple_debug_info("QQ", "Internet IP: %s, %d\n", inet_ntoa(qd->my_ip), qd->my_port); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
91 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
92 bytes += qq_getIP(&qd->my_local_ip, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
93 bytes += qq_get16(&qd->my_local_port, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
94 purple_debug_info("QQ", "Local IP: %s, %d\n", inet_ntoa(qd->my_local_ip), qd->my_local_port); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
95 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
96 bytes += qq_getime(&qd->login_time, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
97 tm_local = localtime(&qd->login_time); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
98 purple_debug_info("QQ", "Login time: %d-%d-%d, %d:%d:%d\n", |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
99 (1900 +tm_local->tm_year), (1 + tm_local->tm_mon), tm_local->tm_mday, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
100 tm_local->tm_hour, tm_local->tm_min, tm_local->tm_sec); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
101 /* skip unknown 2 bytes, 0x(03 0a) */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
102 bytes += 2; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
103 /* skip unknown 24 bytes, maybe token to access Qun shared files */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
104 bytes += 24; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
105 /* unknow ip and port */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
106 bytes += qq_getIP(&ip, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
107 bytes += qq_get16(&port, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
108 purple_debug_info("QQ", "Unknow IP: %s, %d\n", inet_ntoa(ip), port); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
109 /* unknow ip and port */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
110 bytes += qq_getIP(&ip, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
111 bytes += qq_get16(&port, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
112 purple_debug_info("QQ", "Unknow IP: %s, %d\n", inet_ntoa(ip), port); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
113 /* unknown 4 bytes, 0x(00 81 00 00)*/ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
114 bytes += 4; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
115 /* skip unknown 32 bytes, maybe key to access QQ Home */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
116 bytes += 32; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
117 /* skip unknown 16 bytes, 0x(00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 00) */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
118 bytes += 16; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
119 /* time */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
120 bytes += qq_getime(&qd->last_login_time[0], data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
121 tm_local = localtime(&qd->last_login_time[0]); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
122 purple_debug_info("QQ", "Last login time: %d-%d-%d, %d:%d:%d\n", |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
123 (1900 +tm_local->tm_year), (1 + tm_local->tm_mon), tm_local->tm_mday, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
124 tm_local->tm_hour, tm_local->tm_min, tm_local->tm_sec); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
125 /* unknow time */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
126 g_return_val_if_fail(sizeof(qd->last_login_time) / sizeof(time_t) > 1, QQ_LOGIN_REPLY_OK); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
127 bytes += qq_getime(&qd->last_login_time[1], data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
128 tm_local = localtime(&qd->last_login_time[1]); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
129 purple_debug_info("QQ", "Time: %d-%d-%d, %d:%d:%d\n", |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
130 (1900 +tm_local->tm_year), (1 + tm_local->tm_mon), tm_local->tm_mday, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
131 tm_local->tm_hour, tm_local->tm_min, tm_local->tm_sec); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
132 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
133 g_return_val_if_fail(sizeof(qd->last_login_time) / sizeof(time_t) > 2, QQ_LOGIN_REPLY_OK); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
134 bytes += qq_getime(&qd->last_login_time[2], data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
135 tm_local = localtime(&qd->last_login_time[2]); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
136 purple_debug_info("QQ", "Time: %d-%d-%d, %d:%d:%d\n", |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
137 (1900 +tm_local->tm_year), (1 + tm_local->tm_mon), tm_local->tm_mday, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
138 tm_local->tm_hour, tm_local->tm_min, tm_local->tm_sec); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
139 /* unknow 9 bytes, 0x(00 0a 00 0a 01 00 00 0e 10) */ |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
140 |
24622
d8af9602c1b1
Correct QQ2005's login reply length
Hu Yong <ccpaging@gmail.com>
parents:
24161
diff
changeset
|
141 if (len > 148) { |
d8af9602c1b1
Correct QQ2005's login reply length
Hu Yong <ccpaging@gmail.com>
parents:
24161
diff
changeset
|
142 qq_show_packet("Login reply OK, but length > 139", data, len); |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
143 } |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
144 return QQ_LOGIN_REPLY_OK; |
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 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
147 /* 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
|
148 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
|
149 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
150 qq_data *qd; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
151 gint bytes; |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
152 struct { |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
153 guint8 result; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
154 guint32 uid; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
155 struct in_addr new_server_ip; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
156 guint16 new_server_port; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
157 } packet; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
158 |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
159 |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
160 if (len < 11) { |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
161 purple_connection_error_reason(gc, |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
162 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, |
24679
55b7371eadf4
Fix some English in the QQ plugin. And remove some translated phrases that are
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24678
diff
changeset
|
163 _("Cannot decrypt server reply")); |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
164 return QQ_LOGIN_REPLY_ERR; |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
165 } |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
166 |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
167 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
168 bytes = 0; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
169 /* 000-000: reply code */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
170 bytes += qq_get8(&packet.result, data + bytes); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
171 /* 001-004: login uid */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
172 bytes += qq_get32(&packet.uid, data + bytes); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
173 /* 005-008: redirected new server IP */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
174 bytes += qq_getIP(&packet.new_server_ip, data + bytes); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
175 /* 009-010: redirected new server port */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
176 bytes += qq_get16(&packet.new_server_port, data + bytes); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
177 |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
178 if (len > 11) { |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
179 purple_debug_error("QQ", "Login redirect more than expected %d bytes, read %d bytes\n", 11, bytes); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
180 } |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
181 |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
182 /* 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
|
183 * those connect should be called at packet_process */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
184 qd->redirect_ip.s_addr = packet.new_server_ip.s_addr; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
185 qd->redirect_port = packet.new_server_port; |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
186 return QQ_LOGIN_REPLY_REDIRECT; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
187 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
188 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
189 /* request before login */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
190 void qq_request_token(PurpleConnection *gc) |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
191 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
192 qq_data *qd; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
193 guint8 buf[16] = {0}; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
194 gint bytes = 0; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
195 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
196 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
|
197 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
198 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
199 bytes += qq_put8(buf + bytes, 0); |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
200 |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
201 qd->send_seq++; |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
202 qq_send_cmd_encrypted(gc, QQ_CMD_TOKEN, qd->send_seq, buf, bytes, TRUE); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
203 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
204 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
205 /* send login packet to QQ server */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
206 void qq_request_login(PurpleConnection *gc) |
23640
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 qq_data *qd; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
209 guint8 *buf, *raw_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
210 gint bytes; |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
211 guint8 *encrypted; |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
212 gint encrypted_len; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
213 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
214 /* for QQ 2005? copy from lumaqq */ |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
215 static const guint8 login_23_51[29] = { |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
216 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
217 0x00, 0x00, 0x00, 0x00, 0x86, 0xcc, 0x4c, 0x35, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
218 0x2c, 0xd3, 0x73, 0x6c, 0x14, 0xf6, 0xf6, 0xaf, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
219 0xc3, 0xfa, 0x33, 0xa4, 0x01 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
220 }; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
221 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
222 static const guint8 login_53_68[16] = { |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
223 0x8D, 0x8B, 0xFA, 0xEC, 0xD5, 0x52, 0x17, 0x4A, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
224 0x86, 0xF9, 0xA7, 0x75, 0xE6, 0x32, 0xD1, 0x6D |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
225 }; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
226 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
227 static const guint8 login_100_bytes[100] = { |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
228 0x40, 0x0B, 0x04, 0x02, 0x00, 0x01, 0x00, 0x00, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
229 0x00, 0x00, 0x00, 0x03, 0x09, 0x00, 0x00, 0x00, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
230 0x00, 0x00, 0x00, 0x00, 0x01, 0xE9, 0x03, 0x01, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
231 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF3, 0x03, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
232 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xED, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
233 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
234 0xEC, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
235 0x03, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
236 0x00, 0x03, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
237 0x00, 0x00, 0x01, 0xEE, 0x03, 0x00, 0x00, 0x00, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
238 0x00, 0x00, 0x00, 0x01, 0xEF, 0x03, 0x00, 0x00, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
239 0x00, 0x00, 0x00, 0x00, 0x01, 0xEB, 0x03, 0x00, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
240 0x00, 0x00, 0x00, 0x00 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
241 }; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
242 |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
243 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
|
244 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
245 |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
246 g_return_if_fail(qd->ld.token != NULL && qd->ld.token_len > 0); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
247 |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
248 raw_data = g_newa(guint8, MAX_PACKET_SIZE - 16); |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
249 memset(raw_data, 0, MAX_PACKET_SIZE - 16); |
23695
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23640
diff
changeset
|
250 |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
251 encrypted = g_newa(guint8, MAX_PACKET_SIZE); /* 16 bytes more */ |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
252 |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
253 bytes = 0; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
254 /* now generate the encrypted data |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
255 * 000-015 use password_twice_md5 as key to encrypt empty string */ |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
256 encrypted_len = qq_encrypt(encrypted, (guint8 *) "", 0, qd->ld.pwd_twice_md5); |
23695
5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
23640
diff
changeset
|
257 g_return_if_fail(encrypted_len == 16); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
258 bytes += qq_putdata(raw_data + bytes, encrypted, encrypted_len); |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
259 |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
260 /* 016-016 */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
261 bytes += qq_put8(raw_data + bytes, 0x00); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
262 /* 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
|
263 bytes += qq_put32(raw_data + bytes, 0x00000000); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
264 /* 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
|
265 bytes += qq_put16(raw_data + bytes, 0x0000); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
266 /* 023-051, fixed value, unknown */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
267 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
|
268 /* 052-052, login mode */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
269 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
|
270 /* 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
|
271 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
|
272 /* 069, login token length */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
273 bytes += qq_put8(raw_data + bytes, qd->ld.token_len); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
274 /* 070-093, login token, normally 24 bytes */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
275 bytes += qq_putdata(raw_data + bytes, qd->ld.token, qd->ld.token_len); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
276 /* 100 bytes unknown */ |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
277 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
|
278 /* all zero left */ |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
279 memset(raw_data + bytes, 0, 416 - bytes); |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
280 bytes = 416; |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
281 |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
282 encrypted_len = qq_encrypt(encrypted, raw_data, bytes, qd->ld.random_key); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
283 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
284 buf = g_newa(guint8, MAX_PACKET_SIZE); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
285 memset(buf, 0, MAX_PACKET_SIZE); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
286 bytes = 0; |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
287 bytes += qq_putdata(buf + bytes, qd->ld.random_key, QQ_KEY_LENGTH); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
288 bytes += qq_putdata(buf + bytes, encrypted, encrypted_len); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
289 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
290 qd->send_seq++; |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
291 qq_send_cmd_encrypted(gc, QQ_CMD_LOGIN, qd->send_seq, buf, bytes, TRUE); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
292 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
293 |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
294 guint8 qq_process_token(PurpleConnection *gc, guint8 *buf, gint buf_len) |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
295 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
296 qq_data *qd; |
24161
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
297 gint bytes; |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
298 guint8 ret; |
24161
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
299 guint8 token_len; |
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
300 gchar *msg; |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
301 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
302 g_return_val_if_fail(buf != NULL && buf_len != 0, QQ_LOGIN_REPLY_ERR); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
303 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
304 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL, QQ_LOGIN_REPLY_ERR); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
305 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
306 |
24161
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
307 bytes = 0; |
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
308 bytes += qq_get8(&ret, buf + bytes); |
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
309 bytes += qq_get8(&token_len, buf + bytes); |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
310 |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
311 if (ret != QQ_LOGIN_REPLY_OK) { |
24161
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
312 qq_show_packet("Failed requesting token", buf, buf_len); |
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
313 |
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
314 msg = g_strdup_printf( _("Failed requesting token, 0x%02X"), ret ); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
315 purple_connection_error_reason(gc, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
316 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, |
24161
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
317 msg); |
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
318 g_free(msg); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
319 return QQ_LOGIN_REPLY_ERR; |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
320 } |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
321 |
24161
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
322 if (bytes + token_len < buf_len) { |
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
323 msg = g_strdup_printf( _("Invalid token len, %d"), token_len); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
324 purple_connection_error_reason(gc, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
325 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, |
24161
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
326 msg); |
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
327 g_free(msg); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
328 return QQ_LOGIN_REPLY_ERR; |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
329 } |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
330 |
24161
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
331 if (bytes + token_len > buf_len) { |
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
332 purple_debug_info("QQ", "Extra token data, %d %d\n", token_len, buf_len - bytes); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
333 } |
24622
d8af9602c1b1
Correct QQ2005's login reply length
Hu Yong <ccpaging@gmail.com>
parents:
24161
diff
changeset
|
334 /* qq_show_packet("Got token", buf + bytes, buf_len - bytes); */ |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
335 |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
336 if (qd->ld.token != NULL) { |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
337 g_free(qd->ld.token); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
338 qd->ld.token = NULL; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
339 qd->ld.token_len = 0; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
340 } |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
341 qd->ld.token = g_new0(guint8, token_len); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
342 qd->ld.token_len = token_len; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
343 g_memmove(qd->ld.token, buf + 2, qd->ld.token_len); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
344 return ret; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
345 } |
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 /* send logout packets to QQ server */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
348 void qq_request_logout(PurpleConnection *gc) |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
349 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
350 gint i; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
351 qq_data *qd; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
352 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
353 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
354 for (i = 0; i < 4; i++) |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
355 qq_send_cmd(gc, QQ_CMD_LOGOUT, qd->ld.pwd_twice_md5, QQ_KEY_LENGTH); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
356 |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
357 qd->is_login = FALSE; /* update login status AFTER sending logout packets */ |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
358 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
359 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
360 /* for QQ 2003iii 0117, fixed value */ |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
361 /* static const guint8 login_23_51[29] = { |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
362 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
363 0x00, 0x00, 0x00, 0x00, 0xbf, 0x14, 0x11, 0x20, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
364 0x03, 0x9d, 0xb2, 0xe6, 0xb3, 0x11, 0xb7, 0x13, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
365 0x95, 0x67, 0xda, 0x2c, 0x01 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
366 }; */ |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
367 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
368 /* for QQ 2003iii 0304, fixed value */ |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
369 /* |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
370 static const guint8 login_23_51[29] = { |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
371 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
372 0x00, 0x00, 0x00, 0x00, 0x9a, 0x93, 0xfe, 0x85, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
373 0xd3, 0xd9, 0x2a, 0x41, 0xc8, 0x0d, 0xff, 0xb6, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
374 0x40, 0xb8, 0xac, 0x32, 0x01 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
375 }; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
376 */ |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
377 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
378 /* fixed value, not affected by version, or mac address */ |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
379 /* |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
380 static const guint8 login_53_68[16] = { |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
381 0x82, 0x2a, 0x91, 0xfd, 0xa5, 0xca, 0x67, 0x4c, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
382 0xac, 0x81, 0x1f, 0x6f, 0x52, 0x05, 0xa7, 0xbf |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
383 }; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
384 */ |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
385 |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
386 /* process the login reply packet */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
387 guint8 qq_process_login( PurpleConnection *gc, guint8 *data, gint data_len) |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
388 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
389 qq_data *qd; |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
390 guint8 ret = data[0]; |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
391 gchar *msg, *msg_utf8; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
392 gchar *error; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
393 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
394 |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
395 g_return_val_if_fail(data != NULL && data_len != 0, QQ_LOGIN_REPLY_ERR); |
23640
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 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
398 |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
399 switch (ret) { |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
400 case QQ_LOGIN_REPLY_OK: |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
401 purple_debug_info("QQ", "Login OK\n"); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
402 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
|
403 case QQ_LOGIN_REPLY_REDIRECT: |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
404 purple_debug_info("QQ", "Redirect new server\n"); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
405 return process_login_redirect(gc, data, data_len); |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
406 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
407 case 0x0A: /* extend redirect used in QQ2006 */ |
24431
75545fdf8944
String changes. I'm kind of blindly making changes to the qq strings
Mark Doliner <mark@kingant.net>
parents:
24161
diff
changeset
|
408 error = g_strdup( _("Redirect_EX is not currently supported") ); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
409 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
410 break; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
411 case 0x05: /* invalid password */ |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
412 if (!purple_account_get_remember_password(gc->account)) { |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
413 purple_account_set_password(gc->account, NULL); |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
414 } |
24431
75545fdf8944
String changes. I'm kind of blindly making changes to the qq strings
Mark Doliner <mark@kingant.net>
parents:
24161
diff
changeset
|
415 error = g_strdup( _("Incorrect password.")); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
416 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
417 break; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
418 case 0x06: /* need activation */ |
24431
75545fdf8944
String changes. I'm kind of blindly making changes to the qq strings
Mark Doliner <mark@kingant.net>
parents:
24161
diff
changeset
|
419 error = g_strdup( _("Activation required")); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
420 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
421 break; |
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
422 |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
423 default: |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
424 qq_hex_dump(PURPLE_DEBUG_WARNING, "QQ", data, data_len, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
425 ">>> [default] decrypt and dump"); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
426 error = g_strdup_printf( |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
427 _("Unknown reply code when logging in (0x%02X)"), |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
428 ret ); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
429 reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
430 break; |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
431 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
432 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
433 msg = g_strndup((gchar *)data + 1, data_len - 1); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
434 msg_utf8 = qq_to_utf8(msg, QQ_CHARSET_DEFAULT); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
435 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
436 purple_debug_error("QQ", "%s: %s\n", error, msg_utf8); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
437 purple_connection_error_reason(gc, reason, msg_utf8); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
438 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
439 g_free(error); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
440 g_free(msg); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
441 g_free(msg_utf8); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
442 return QQ_LOGIN_REPLY_ERR; |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
443 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
444 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
445 /* send keep-alive packet to QQ server (it is a heart-beat) */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
446 void qq_request_keep_alive(PurpleConnection *gc) |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
447 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
448 qq_data *qd; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
449 guint8 raw_data[16] = {0}; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
450 gint bytes= 0; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
451 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
452 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
453 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
454 /* 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
|
455 * 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
|
456 * 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
|
457 bytes += qq_put32(raw_data + bytes, qd->uid); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
458 qq_send_cmd(gc, QQ_CMD_KEEP_ALIVE, raw_data, bytes); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
459 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
460 |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
461 /* parse the return ofqq_process_keep_alive keep-alive packet, it includes some system information */ |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
462 gboolean qq_process_keep_alive(guint8 *data, gint data_len, PurpleConnection *gc) |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
463 { |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
464 qq_data *qd; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
465 gchar **segments; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
466 |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
467 g_return_val_if_fail(data != NULL, FALSE); |
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
468 g_return_val_if_fail(data_len != 0, FALSE); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
469 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
470 qd = (qq_data *) gc->proto_data; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
471 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
472 /* 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
|
473 |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
474 /* the last one is 60, don't know what it is */ |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
475 segments = split_data(data, data_len, "\x1f", 6); |
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
476 if (segments == NULL) |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
477 return TRUE; |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
478 |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
479 /* segments[0] and segment[1] are all 0x30 ("0") */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
480 qd->online_total = strtol(segments[2], NULL, 10); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
481 if(0 == qd->online_total) { |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
482 purple_connection_error_reason(gc, |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
483 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
484 _("Lost connection with server")); |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
485 } |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
486 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
|
487 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
|
488 |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
489 purple_debug_info("QQ", "keep alive, %s:%d\n", |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
490 inet_ntoa(qd->my_ip), qd->my_port); |
24115
bcfc98c7a55f
merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24095
diff
changeset
|
491 |
23640
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
492 g_strfreev(segments); |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
493 return TRUE; |
58bb7fc244e4
2008.08.03 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
diff
changeset
|
494 } |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
495 |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
496 void qq_request_keep_alive_2007(PurpleConnection *gc) |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
497 { |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
498 qq_data *qd; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
499 guint8 raw_data[32] = {0}; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
500 gint bytes= 0; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
501 gchar *uid_str; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
502 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
503 qd = (qq_data *) gc->proto_data; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
504 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
505 /* In fact, we can send whatever we like to server |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
506 * with this command, server return the same result including |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
507 * the amount of online QQ users, my ip and port */ |
24653
fecedf6d9ee1
propagate from branch 'im.pidgin.pidgin' (head 97d295a04f3a9852a3b29cf0df43d56d1ddcc672)
SHiNE CsyFeK <csyfek@gmail.com>
diff
changeset
|
508 uid_str = g_strdup_printf("%u", qd->uid); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
509 bytes += qq_putdata(raw_data + bytes, (guint8 *)uid_str, strlen(uid_str)); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
510 qq_send_cmd(gc, QQ_CMD_KEEP_ALIVE, raw_data, bytes); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
511 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
512 g_free(uid_str); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
513 } |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
514 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
515 gboolean qq_process_keep_alive_2007(guint8 *data, gint data_len, PurpleConnection *gc) |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
516 { |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
517 qq_data *qd; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
518 gint bytes= 0; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
519 guint8 ret; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
520 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
521 g_return_val_if_fail(data != NULL && data_len != 0, FALSE); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
522 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
523 qd = (qq_data *) gc->proto_data; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
524 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
525 /* qq_show_packet("Keep alive reply packet", data, len); */ |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
526 |
24653
fecedf6d9ee1
propagate from branch 'im.pidgin.pidgin' (head 97d295a04f3a9852a3b29cf0df43d56d1ddcc672)
SHiNE CsyFeK <csyfek@gmail.com>
diff
changeset
|
527 bytes = 0; |
fecedf6d9ee1
propagate from branch 'im.pidgin.pidgin' (head 97d295a04f3a9852a3b29cf0df43d56d1ddcc672)
SHiNE CsyFeK <csyfek@gmail.com>
diff
changeset
|
528 bytes += qq_get8(&ret, data + bytes); |
fecedf6d9ee1
propagate from branch 'im.pidgin.pidgin' (head 97d295a04f3a9852a3b29cf0df43d56d1ddcc672)
SHiNE CsyFeK <csyfek@gmail.com>
diff
changeset
|
529 bytes += qq_get32(&qd->online_total, data + bytes); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
530 if(0 == qd->online_total) { |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
531 purple_connection_error_reason(gc, |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
532 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
533 _("Lost connection with server")); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
534 } |
24653
fecedf6d9ee1
propagate from branch 'im.pidgin.pidgin' (head 97d295a04f3a9852a3b29cf0df43d56d1ddcc672)
SHiNE CsyFeK <csyfek@gmail.com>
diff
changeset
|
535 |
fecedf6d9ee1
propagate from branch 'im.pidgin.pidgin' (head 97d295a04f3a9852a3b29cf0df43d56d1ddcc672)
SHiNE CsyFeK <csyfek@gmail.com>
diff
changeset
|
536 bytes += qq_getIP(&qd->my_ip, data + bytes); |
fecedf6d9ee1
propagate from branch 'im.pidgin.pidgin' (head 97d295a04f3a9852a3b29cf0df43d56d1ddcc672)
SHiNE CsyFeK <csyfek@gmail.com>
diff
changeset
|
537 bytes += qq_get16(&qd->my_port, data + bytes); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
538 return TRUE; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
539 } |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
540 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
541 void qq_request_keep_alive_2008(PurpleConnection *gc) |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
542 { |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
543 qq_data *qd; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
544 guint8 raw_data[16] = {0}; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
545 gint bytes= 0; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
546 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
547 qd = (qq_data *) gc->proto_data; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
548 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
549 /* In fact, we can send whatever we like to server |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
550 * with this command, server return the same result including |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
551 * the amount of online QQ users, my ip and port */ |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
552 bytes += qq_put32(raw_data + bytes, qd->uid); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
553 bytes += qq_putime(raw_data + bytes, &qd->login_time); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
554 qq_send_cmd(gc, QQ_CMD_KEEP_ALIVE, raw_data, bytes); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
555 } |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
556 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
557 gboolean qq_process_keep_alive_2008(guint8 *data, gint data_len, PurpleConnection *gc) |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
558 { |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
559 qq_data *qd; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
560 gint bytes= 0; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
561 guint8 ret; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
562 time_t server_time; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
563 struct tm *tm_local; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
564 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
565 g_return_val_if_fail(data != NULL && data_len != 0, FALSE); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
566 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
567 qd = (qq_data *) gc->proto_data; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
568 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
569 /* qq_show_packet("Keep alive reply packet", data, len); */ |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
570 |
24653
fecedf6d9ee1
propagate from branch 'im.pidgin.pidgin' (head 97d295a04f3a9852a3b29cf0df43d56d1ddcc672)
SHiNE CsyFeK <csyfek@gmail.com>
diff
changeset
|
571 bytes = 0; |
fecedf6d9ee1
propagate from branch 'im.pidgin.pidgin' (head 97d295a04f3a9852a3b29cf0df43d56d1ddcc672)
SHiNE CsyFeK <csyfek@gmail.com>
diff
changeset
|
572 bytes += qq_get8(&ret, data + bytes); |
fecedf6d9ee1
propagate from branch 'im.pidgin.pidgin' (head 97d295a04f3a9852a3b29cf0df43d56d1ddcc672)
SHiNE CsyFeK <csyfek@gmail.com>
diff
changeset
|
573 bytes += qq_get32(&qd->online_total, data + bytes); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
574 if(0 == qd->online_total) { |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
575 purple_connection_error_reason(gc, |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
576 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
577 _("Lost connection with server")); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
578 } |
24653
fecedf6d9ee1
propagate from branch 'im.pidgin.pidgin' (head 97d295a04f3a9852a3b29cf0df43d56d1ddcc672)
SHiNE CsyFeK <csyfek@gmail.com>
diff
changeset
|
579 |
fecedf6d9ee1
propagate from branch 'im.pidgin.pidgin' (head 97d295a04f3a9852a3b29cf0df43d56d1ddcc672)
SHiNE CsyFeK <csyfek@gmail.com>
diff
changeset
|
580 bytes += qq_getIP(&qd->my_ip, data + bytes); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
581 bytes += qq_get16(&qd->my_port, data + bytes); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
582 /* skip 2 byytes, 0x(00 3c) */ |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
583 bytes += 2; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
584 bytes += qq_getime(&server_time, data + bytes); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
585 /* skip 5 bytes, all are 0 */ |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
586 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
587 purple_debug_info("QQ", "keep alive, %s:%d\n", |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
588 inet_ntoa(qd->my_ip), qd->my_port); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
589 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
590 tm_local = localtime(&server_time); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
591 purple_debug_info("QQ", "Server time: %d-%d-%d, %d:%d:%d\n", |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
592 (1900 +tm_local->tm_year), (1 + tm_local->tm_mon), tm_local->tm_mday, |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
593 tm_local->tm_hour, tm_local->tm_min, tm_local->tm_sec); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
594 return TRUE; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
595 } |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
596 |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
597 /* For QQ2007/2008 */ |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
598 void qq_request_get_server(PurpleConnection *gc) |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
599 { |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
600 qq_data *qd; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
601 guint8 *buf, *raw_data; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
602 gint bytes; |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
603 guint8 *encrypted; |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
604 gint encrypted_len; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
605 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
606 g_return_if_fail(gc != NULL && gc->proto_data != NULL); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
607 qd = (qq_data *) gc->proto_data; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
608 |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
609 raw_data = g_newa(guint8, 128); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
610 memset(raw_data, 0, 128); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
611 |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
612 encrypted = g_newa(guint8, 128 + 16); /* 16 bytes more */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
613 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
614 bytes = 0; |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
615 if (qd->redirect == NULL) { |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
616 /* first packet to get server */ |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
617 qd->redirect_len = 15; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
618 qd->redirect = g_realloc(qd->redirect, qd->redirect_len); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
619 memset(qd->redirect, 0, qd->redirect_len); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
620 } |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
621 bytes += qq_putdata(raw_data + bytes, qd->redirect, qd->redirect_len); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
622 |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
623 encrypted_len = qq_encrypt(encrypted, raw_data, bytes, qd->ld.random_key); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
624 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
625 buf = g_newa(guint8, MAX_PACKET_SIZE); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
626 memset(buf, 0, MAX_PACKET_SIZE); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
627 bytes = 0; |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
628 bytes += qq_putdata(buf + bytes, qd->ld.random_key, QQ_KEY_LENGTH); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
629 bytes += qq_putdata(buf + bytes, encrypted, encrypted_len); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
630 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
631 qd->send_seq++; |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
632 qq_send_cmd_encrypted(gc, QQ_CMD_GET_SERVER, qd->send_seq, buf, bytes, TRUE); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
633 } |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
634 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
635 guint16 qq_process_get_server(PurpleConnection *gc, guint8 *data, gint data_len) |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
636 { |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
637 qq_data *qd; |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
638 gint bytes; |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
639 guint16 ret; |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
640 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
641 g_return_val_if_fail (gc != NULL && gc->proto_data != NULL, QQ_LOGIN_REPLY_ERR); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
642 qd = (qq_data *) gc->proto_data; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
643 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
644 g_return_val_if_fail (data != NULL, QQ_LOGIN_REPLY_ERR); |
24161
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
645 |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
646 /* qq_show_packet("Get Server", data, data_len); */ |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
647 bytes = 0; |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
648 bytes += qq_get16(&ret, data + bytes); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
649 if (ret == 0) { |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
650 /* Notice: do not clear redirect_data here. It will be used in login*/ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
651 qd->redirect_ip.s_addr = 0; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
652 return QQ_LOGIN_REPLY_OK; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
653 } |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
654 |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
655 if (data_len < 15) { |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
656 purple_connection_error_reason(gc, |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
657 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
658 _("Could not decrypt server reply")); |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
659 return QQ_LOGIN_REPLY_ERR; |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
660 } |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
661 |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
662 qd->redirect_len = data_len; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
663 qd->redirect = g_realloc(qd->redirect, qd->redirect_len); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
664 qq_getdata(qd->redirect, qd->redirect_len, data); |
24146
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24145
diff
changeset
|
665 /* qq_show_packet("Redirect to", qd->redirect, qd->redirect_len); */ |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
666 |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
667 qq_getIP(&qd->redirect_ip, data + 11); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
668 purple_debug_info("QQ", "Get server %s\n", inet_ntoa(qd->redirect_ip)); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
669 return QQ_LOGIN_REPLY_REDIRECT; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
670 } |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
671 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
672 void qq_request_token_ex(PurpleConnection *gc) |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
673 { |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
674 qq_data *qd; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
675 guint8 *buf, *raw_data; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
676 gint bytes; |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
677 guint8 *encrypted; |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
678 gint encrypted_len; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
679 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
680 g_return_if_fail(gc != NULL && gc->proto_data != NULL); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
681 qd = (qq_data *) gc->proto_data; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
682 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
683 g_return_if_fail(qd->ld.token != NULL && qd->ld.token_len > 0); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
684 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
685 raw_data = g_newa(guint8, MAX_PACKET_SIZE - 16); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
686 memset(raw_data, 0, MAX_PACKET_SIZE - 16); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
687 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
688 encrypted = g_newa(guint8, MAX_PACKET_SIZE); /* 16 bytes more */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
689 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
690 bytes = 0; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
691 bytes += qq_put8(raw_data + bytes, qd->ld.token_len); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
692 bytes += qq_putdata(raw_data + bytes, qd->ld.token, qd->ld.token_len); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
693 bytes += qq_put8(raw_data + bytes, 3); /* Subcommand */ |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
694 bytes += qq_put16(raw_data + bytes, 5); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
695 bytes += qq_put32(raw_data + bytes, 0); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
696 bytes += qq_put8(raw_data + bytes, 0); /* fragment index */ |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
697 bytes += qq_put16(raw_data + bytes, 0); /* captcha token */ |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
698 |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
699 encrypted_len = qq_encrypt(encrypted, raw_data, bytes, qd->ld.random_key); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
700 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
701 buf = g_newa(guint8, MAX_PACKET_SIZE); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
702 memset(buf, 0, MAX_PACKET_SIZE); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
703 bytes = 0; |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
704 bytes += qq_putdata(buf + bytes, qd->ld.random_key, QQ_KEY_LENGTH); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
705 bytes += qq_putdata(buf + bytes, encrypted, encrypted_len); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
706 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
707 qd->send_seq++; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
708 qq_send_cmd_encrypted(gc, QQ_CMD_TOKEN_EX, qd->send_seq, buf, bytes, TRUE); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
709 } |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
710 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
711 void qq_request_token_ex_next(PurpleConnection *gc) |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
712 { |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
713 qq_data *qd; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
714 guint8 *buf, *raw_data; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
715 gint bytes; |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
716 guint8 *encrypted; |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
717 gint encrypted_len; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
718 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
719 g_return_if_fail(gc != NULL && gc->proto_data != NULL); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
720 qd = (qq_data *) gc->proto_data; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
721 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
722 g_return_if_fail(qd->ld.token != NULL && qd->ld.token_len > 0); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
723 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
724 raw_data = g_newa(guint8, MAX_PACKET_SIZE - 16); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
725 memset(raw_data, 0, MAX_PACKET_SIZE - 16); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
726 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
727 encrypted = g_newa(guint8, MAX_PACKET_SIZE); /* 16 bytes more */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
728 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
729 bytes = 0; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
730 bytes += qq_put8(raw_data + bytes, qd->ld.token_len); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
731 bytes += qq_putdata(raw_data + bytes, qd->ld.token, qd->ld.token_len); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
732 bytes += qq_put8(raw_data + bytes, 3); /* Subcommand */ |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
733 bytes += qq_put16(raw_data + bytes, 5); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
734 bytes += qq_put32(raw_data + bytes, 0); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
735 bytes += qq_put8(raw_data + bytes, qd->captcha.next_index); /* fragment index */ |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
736 bytes += qq_put16(raw_data + bytes, qd->captcha.token_len); /* captcha token */ |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
737 bytes += qq_putdata(raw_data + bytes, qd->captcha.token, qd->captcha.token_len); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
738 |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
739 encrypted_len = qq_encrypt(encrypted, raw_data, bytes, qd->ld.random_key); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
740 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
741 buf = g_newa(guint8, MAX_PACKET_SIZE); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
742 memset(buf, 0, MAX_PACKET_SIZE); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
743 bytes = 0; |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
744 bytes += qq_putdata(buf + bytes, qd->ld.random_key, QQ_KEY_LENGTH); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
745 bytes += qq_putdata(buf + bytes, encrypted, encrypted_len); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
746 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
747 qd->send_seq++; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
748 qq_send_cmd_encrypted(gc, QQ_CMD_TOKEN_EX, qd->send_seq, buf, bytes, TRUE); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
749 |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
750 purple_connection_update_progress(gc, _("Requesting captcha"), 3, QQ_CONNECT_STEPS); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
751 } |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
752 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
753 static void request_token_ex_code(PurpleConnection *gc, |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
754 guint8 *token, guint16 token_len, guint8 *code, guint16 code_len) |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
755 { |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
756 qq_data *qd; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
757 guint8 *buf, *raw_data; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
758 gint bytes; |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
759 guint8 *encrypted; |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
760 gint encrypted_len; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
761 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
762 g_return_if_fail(gc != NULL && gc->proto_data != NULL); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
763 qd = (qq_data *) gc->proto_data; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
764 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
765 g_return_if_fail(qd->ld.token != NULL && qd->ld.token_len > 0); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
766 g_return_if_fail(code != NULL && code_len > 0); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
767 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
768 raw_data = g_newa(guint8, MAX_PACKET_SIZE - 16); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
769 memset(raw_data, 0, MAX_PACKET_SIZE - 16); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
770 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
771 encrypted = g_newa(guint8, MAX_PACKET_SIZE); /* 16 bytes more */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
772 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
773 bytes = 0; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
774 bytes += qq_put8(raw_data + bytes, qd->ld.token_len); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
775 bytes += qq_putdata(raw_data + bytes, qd->ld.token, qd->ld.token_len); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
776 bytes += qq_put8(raw_data + bytes, 4); /* Subcommand */ |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
777 bytes += qq_put16(raw_data + bytes, 5); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
778 bytes += qq_put32(raw_data + bytes, 0); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
779 bytes += qq_put16(raw_data + bytes, code_len); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
780 bytes += qq_putdata(raw_data + bytes, code, code_len); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
781 bytes += qq_put16(raw_data + bytes, qd->ld.token_ex_len); /* login token ex */ |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
782 bytes += qq_putdata(raw_data + bytes, qd->ld.token_ex, qd->ld.token_ex_len); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
783 |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
784 encrypted_len = qq_encrypt(encrypted, raw_data, bytes, qd->ld.random_key); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
785 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
786 buf = g_newa(guint8, MAX_PACKET_SIZE); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
787 memset(buf, 0, MAX_PACKET_SIZE); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
788 bytes = 0; |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
789 bytes += qq_putdata(buf + bytes, qd->ld.random_key, QQ_KEY_LENGTH); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
790 bytes += qq_putdata(buf + bytes, encrypted, encrypted_len); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
791 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
792 qd->send_seq++; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
793 qq_send_cmd_encrypted(gc, QQ_CMD_TOKEN_EX, qd->send_seq, buf, bytes, TRUE); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
794 |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
795 purple_connection_update_progress(gc, _("Checking captcha"), 3, QQ_CONNECT_STEPS); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
796 } |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
797 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
798 typedef struct { |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
799 PurpleConnection *gc; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
800 guint8 *token; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
801 guint16 token_len; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
802 } qq_captcha_request; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
803 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
804 static void captcha_request_destory(qq_captcha_request *captcha_req) |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
805 { |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
806 g_return_if_fail(captcha_req != NULL); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
807 if (captcha_req->token) g_free(captcha_req->token); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
808 g_free(captcha_req); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
809 } |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
810 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
811 static void captcha_input_cancel_cb(qq_captcha_request *captcha_req, |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
812 PurpleRequestFields *fields) |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
813 { |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
814 captcha_request_destory(captcha_req); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
815 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
816 purple_connection_error_reason(captcha_req->gc, |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
817 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
818 _("Failed captcha verification")); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
819 } |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
820 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
821 static void captcha_input_ok_cb(qq_captcha_request *captcha_req, |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
822 PurpleRequestFields *fields) |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
823 { |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
824 gchar *code; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
825 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
826 g_return_if_fail(captcha_req != NULL && captcha_req->gc != NULL); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
827 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
828 code = utf8_to_qq( |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
829 purple_request_fields_get_string(fields, "captcha_code"), |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
830 QQ_CHARSET_DEFAULT); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
831 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
832 if (strlen(code) <= 0) { |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
833 captcha_input_cancel_cb(captcha_req, fields); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
834 return; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
835 } |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
836 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
837 request_token_ex_code(captcha_req->gc, |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
838 captcha_req->token, captcha_req->token_len, |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
839 (guint8 *)code, strlen(code)); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
840 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
841 captcha_request_destory(captcha_req); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
842 } |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
843 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
844 void qq_captcha_input_dialog(PurpleConnection *gc,qq_captcha_data *captcha) |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
845 { |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
846 PurpleAccount *account; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
847 PurpleRequestFields *fields; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
848 PurpleRequestFieldGroup *group; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
849 PurpleRequestField *field; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
850 qq_captcha_request *captcha_req; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
851 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
852 g_return_if_fail(captcha->token != NULL && captcha->token_len > 0); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
853 g_return_if_fail(captcha->data != NULL && captcha->data_len > 0); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
854 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
855 captcha_req = g_new0(qq_captcha_request, 1); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
856 captcha_req->gc = gc; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
857 captcha_req->token = g_new0(guint8, captcha->token_len); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
858 g_memmove(captcha_req->token, captcha->token, captcha->token_len); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
859 captcha_req->token_len = captcha->token_len; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
860 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
861 account = purple_connection_get_account(gc); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
862 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
863 fields = purple_request_fields_new(); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
864 group = purple_request_field_group_new(NULL); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
865 purple_request_fields_add_group(fields, group); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
866 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
867 field = purple_request_field_image_new("captcha_img", |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
868 _("Captcha Image"), (char *)captcha->data, captcha->data_len); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
869 purple_request_field_group_add_field(group, field); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
870 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
871 field = purple_request_field_string_new("captcha_code", |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
872 _("Enter code"), "", FALSE); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
873 purple_request_field_string_set_masked(field, FALSE); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
874 purple_request_field_group_add_field(group, field); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
875 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
876 purple_request_fields(account, |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
877 _("QQ Captcha Verification"), |
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
878 _("QQ Captcha Verification"), |
24431
75545fdf8944
String changes. I'm kind of blindly making changes to the qq strings
Mark Doliner <mark@kingant.net>
parents:
24161
diff
changeset
|
879 _("Enter the text from the image"), |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
880 fields, |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
881 _("OK"), G_CALLBACK(captcha_input_ok_cb), |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
882 _("Cancel"), G_CALLBACK(captcha_input_cancel_cb), |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
883 purple_connection_get_account(gc), NULL, NULL, |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
884 captcha_req); |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
885 } |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
886 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
887 guint8 qq_process_token_ex(PurpleConnection *gc, guint8 *data, gint data_len) |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
888 { |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
889 qq_data *qd; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
890 int bytes; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
891 guint8 ret; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
892 guint8 sub_cmd; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
893 guint8 reply; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
894 guint16 captcha_len; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
895 guint8 curr_index; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
896 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
897 g_return_val_if_fail(data != NULL && data_len != 0, QQ_LOGIN_REPLY_ERR); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
898 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
899 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL, QQ_LOGIN_REPLY_ERR); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
900 qd = (qq_data *) gc->proto_data; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
901 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
902 ret = data[0]; |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
903 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
904 bytes = 0; |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
905 bytes += qq_get8(&sub_cmd, data + bytes); /* 03: ok; 04: need verifying */ |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
906 bytes += 2; /* 0x(00 05) */ |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
907 bytes += qq_get8(&reply, data + bytes); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
908 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
909 bytes += qq_get16(&(qd->ld.token_ex_len), data + bytes); |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
910 qd->ld.token_ex = g_realloc(qd->ld.token_ex, qd->ld.token_ex_len); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
911 bytes += qq_getdata(qd->ld.token_ex, qd->ld.token_ex_len, data + bytes); |
24146
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24145
diff
changeset
|
912 /* qq_show_packet("Get token ex", qd->ld.token_ex, qd->ld.token_ex_len); */ |
24161
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
913 |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
914 if(reply != 1) |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
915 { |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
916 purple_debug_info("QQ", "Captcha verified, result %d\n", reply); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
917 return QQ_LOGIN_REPLY_OK; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
918 } |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
919 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
920 bytes += qq_get16(&captcha_len, data + bytes); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
921 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
922 qd->captcha.data = g_realloc(qd->captcha.data, qd->captcha.data_len + captcha_len); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
923 bytes += qq_getdata(qd->captcha.data + qd->captcha.data_len, captcha_len, data + bytes); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
924 qd->captcha.data_len += captcha_len; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
925 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
926 bytes += qq_get8(&curr_index, data + bytes); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
927 bytes += qq_get8(&qd->captcha.next_index, data + bytes); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
928 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
929 bytes += qq_get16(&qd->captcha.token_len, data + bytes); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
930 qd->captcha.token = g_realloc(qd->captcha.token, qd->captcha.token_len); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
931 bytes += qq_getdata(qd->captcha.token, qd->captcha.token_len, data + bytes); |
24146
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24145
diff
changeset
|
932 /* qq_show_packet("Get captcha token", qd->captcha.token, qd->captcha.token_len); */ |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
933 |
24161
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
934 purple_debug_info("QQ", "Request next captcha %d, new %d, total %d\n", |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
935 qd->captcha.next_index, captcha_len, qd->captcha.data_len); |
24134
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
936 if(qd->captcha.next_index > 0) |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
937 { |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
938 return QQ_LOGIN_REPLY_NEXT_TOKEN_EX; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
939 } |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
940 |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
941 return QQ_LOGIN_REPLY_CAPTCHA_DLG; |
bdfcfd71449c
patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24115
diff
changeset
|
942 } |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
943 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
944 /* source copy from gg's common.c */ |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
945 static guint32 crc32_table[256]; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
946 static int crc32_initialized = 0; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
947 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
948 static void crc32_make_table() |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
949 { |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
950 guint32 h = 1; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
951 unsigned int i, j; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
952 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
953 memset(crc32_table, 0, sizeof(crc32_table)); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
954 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
955 for (i = 128; i; i >>= 1) { |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
956 h = (h >> 1) ^ ((h & 1) ? 0xedb88320L : 0); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
957 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
958 for (j = 0; j < 256; j += 2 * i) |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
959 crc32_table[i + j] = crc32_table[j] ^ h; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
960 } |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
961 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
962 crc32_initialized = 1; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
963 } |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
964 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
965 static guint32 crc32(guint32 crc, const guint8 *buf, int len) |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
966 { |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
967 if (!crc32_initialized) |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
968 crc32_make_table(); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
969 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
970 if (!buf || len < 0) |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
971 return crc; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
972 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
973 crc ^= 0xffffffffL; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
974 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
975 while (len--) |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
976 crc = (crc >> 8) ^ crc32_table[(crc ^ *buf++) & 0xff]; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
977 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
978 return crc ^ 0xffffffffL; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
979 } |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
980 |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
981 void qq_request_check_pwd(PurpleConnection *gc) |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
982 { |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
983 qq_data *qd; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
984 guint8 *buf, *raw_data; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
985 gint bytes; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
986 guint8 *encrypted; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
987 gint encrypted_len; |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
988 static guint8 header[] = { |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
989 0x00, 0x5F, 0x00, 0x00, 0x08, 0x04, 0x01, 0xE0 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
990 }; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
991 static guint8 unknown[] = { |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
992 0xDB, 0xB9, 0xF3, 0x0B, 0xF9, 0x13, 0x87, 0xB2, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
993 0xE6, 0x20, 0x43, 0xBE, 0x53, 0xCA, 0x65, 0x03 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
994 }; |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
995 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
996 g_return_if_fail(gc != NULL && gc->proto_data != NULL); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
997 qd = (qq_data *) gc->proto_data; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
998 |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
999 g_return_if_fail(qd->ld.token_ex != NULL && qd->ld.token_ex_len > 0); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1000 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1001 raw_data = g_newa(guint8, MAX_PACKET_SIZE - 16); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1002 memset(raw_data, 0, MAX_PACKET_SIZE - 16); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1003 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1004 encrypted = g_newa(guint8, MAX_PACKET_SIZE); /* 16 bytes more */ |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1005 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1006 /* Encrypted password and put in encrypted */ |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1007 bytes = 0; |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1008 bytes += qq_putdata(raw_data + bytes, qd->ld.pwd_md5, sizeof(qd->ld.pwd_md5)); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1009 bytes += qq_put16(raw_data + bytes, 0); |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1010 bytes += qq_put16(raw_data + bytes, rand() & 0xffff); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1011 |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1012 encrypted_len = qq_encrypt(encrypted, raw_data, bytes, qd->ld.pwd_twice_md5); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1013 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1014 /* create packet */ |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1015 bytes = 0; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1016 bytes += qq_putdata(raw_data + bytes, header, sizeof(header)); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1017 /* token get from qq_request_token_ex */ |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1018 bytes += qq_put8(raw_data + bytes, (guint8)(qd->ld.token_ex_len & 0xff)); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1019 bytes += qq_putdata(raw_data + bytes, qd->ld.token_ex, qd->ld.token_ex_len); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1020 /* password encrypted */ |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1021 bytes += qq_put16(raw_data + bytes, encrypted_len); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1022 bytes += qq_putdata(raw_data + bytes, encrypted, encrypted_len); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1023 /* len of unknown + len of CRC32 */ |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1024 bytes += qq_put16(raw_data + bytes, sizeof(unknown) + 4); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1025 bytes += qq_putdata(raw_data + bytes, unknown, sizeof(unknown)); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1026 bytes += qq_put32( |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1027 raw_data + bytes, crc32(0xFFFFFFFF, unknown, sizeof(unknown))); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1028 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1029 /* put length into first 2 bytes */ |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1030 qq_put8(raw_data + 1, bytes - 2); |
24161
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
1031 |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1032 /* tail */ |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1033 bytes += qq_put16(raw_data + bytes, 0x0003); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1034 bytes += qq_put8(raw_data + bytes, 0); |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1035 bytes += qq_put8(raw_data + bytes, qd->ld.pwd_md5[1]); |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1036 bytes += qq_put8(raw_data + bytes, qd->ld.pwd_md5[2]); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1037 |
24146
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24145
diff
changeset
|
1038 /* qq_show_packet("Check password", raw_data, bytes); */ |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1039 /* Encrypted by random key*/ |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1040 encrypted_len = qq_encrypt(encrypted, raw_data, bytes, qd->ld.random_key); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1041 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1042 buf = g_newa(guint8, MAX_PACKET_SIZE); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1043 memset(buf, 0, MAX_PACKET_SIZE); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1044 bytes = 0; |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1045 bytes += qq_putdata(buf + bytes, qd->ld.random_key, QQ_KEY_LENGTH); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1046 bytes += qq_putdata(buf + bytes, encrypted, encrypted_len); |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1047 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1048 qd->send_seq++; |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1049 qq_send_cmd_encrypted(gc, QQ_CMD_CHECK_PWD, qd->send_seq, buf, bytes, TRUE); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1050 } |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1051 |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1052 guint8 qq_process_check_pwd( PurpleConnection *gc, guint8 *data, gint data_len) |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1053 { |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1054 qq_data *qd; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1055 int bytes; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1056 guint8 ret; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1057 gchar *error = NULL; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1058 guint16 unknow_token_len; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1059 gchar *msg, *msg_utf8; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1060 guint16 msg_len; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1061 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1062 |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1063 g_return_val_if_fail(data != NULL && data_len != 0, QQ_LOGIN_REPLY_ERR); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1064 |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1065 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL, QQ_LOGIN_REPLY_ERR); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1066 qd = (qq_data *) gc->proto_data; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1067 |
24146
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24145
diff
changeset
|
1068 /* qq_show_packet("Check password reply", data, data_len); */ |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1069 |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1070 bytes = 0; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1071 bytes += qq_get16(&unknow_token_len, data + bytes); /* maybe total length */ |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1072 bytes += qq_get8(&ret, data + bytes); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1073 bytes += 4; /* 0x(00 00 6d b9) */ |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1074 /* unknow_token_len may 0 when not reply ok*/ |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1075 bytes += qq_get16(&unknow_token_len, data + bytes); /* 0x0020 */ |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1076 bytes += unknow_token_len; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1077 bytes += qq_get16(&unknow_token_len, data + bytes); /* 0x0020 */ |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1078 bytes += unknow_token_len; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1079 |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1080 if (ret == 0) { |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1081 /* get login_token */ |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1082 bytes += qq_get16(&qd->ld.login_token_len, data + bytes); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1083 if (qd->ld.login_token != NULL) g_free(qd->ld.login_token); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1084 qd->ld.login_token = g_new0(guint8, qd->ld.login_token_len); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1085 bytes += qq_getdata(qd->ld.login_token, qd->ld.login_token_len, data + bytes); |
24146
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24145
diff
changeset
|
1086 /* qq_show_packet("Get login token", qd->ld.login_token, qd->ld.login_token_len); */ |
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24145
diff
changeset
|
1087 |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1088 /* get login_key */ |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1089 bytes += qq_getdata(qd->ld.login_key, sizeof(qd->ld.login_key), data + bytes); |
24146
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24145
diff
changeset
|
1090 /* qq_show_packet("Get login key", qd->ld.login_key, sizeof(qd->ld.login_key)); */ |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1091 return QQ_LOGIN_REPLY_OK; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1092 } |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1093 |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1094 switch (ret) |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1095 { |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1096 case 0x34: /* invalid password */ |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1097 if (!purple_account_get_remember_password(gc->account)) { |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1098 purple_account_set_password(gc->account, NULL); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1099 } |
24431
75545fdf8944
String changes. I'm kind of blindly making changes to the qq strings
Mark Doliner <mark@kingant.net>
parents:
24161
diff
changeset
|
1100 error = g_strdup(_("Incorrect password.")); |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1101 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1102 break; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1103 case 0x33: /* need activation */ |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1104 case 0x51: /* need activation */ |
24431
75545fdf8944
String changes. I'm kind of blindly making changes to the qq strings
Mark Doliner <mark@kingant.net>
parents:
24161
diff
changeset
|
1105 error = g_strdup(_("Activation required")); |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1106 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1107 break; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1108 case 0xBF: /* uid is not exist */ |
24431
75545fdf8944
String changes. I'm kind of blindly making changes to the qq strings
Mark Doliner <mark@kingant.net>
parents:
24161
diff
changeset
|
1109 error = g_strdup(_("Invalid username.")); |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1110 reason = PURPLE_CONNECTION_ERROR_INVALID_USERNAME; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1111 break; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1112 default: |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1113 qq_hex_dump(PURPLE_DEBUG_WARNING, "QQ", data, data_len, |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1114 ">>> [default] decrypt and dump"); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1115 error = g_strdup_printf( |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
1116 _("Unknown reply when checking password (0x%02X)"), |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1117 ret ); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1118 reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1119 break; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1120 } |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1121 |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1122 bytes += qq_get16(&msg_len, data + bytes); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1123 |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1124 msg = g_strndup((gchar *)data + bytes, msg_len); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1125 msg_utf8 = qq_to_utf8(msg, QQ_CHARSET_DEFAULT); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1126 |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1127 purple_debug_error("QQ", "%s: %s\n", error, msg_utf8); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1128 purple_connection_error_reason(gc, reason, msg_utf8); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1129 |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1130 g_free(error); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1131 g_free(msg); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1132 g_free(msg_utf8); |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1133 return QQ_LOGIN_REPLY_ERR; |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1134 } |
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1135 |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1136 void qq_request_login_2007(PurpleConnection *gc) |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1137 { |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1138 qq_data *qd; |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1139 guint8 *buf, *raw_data; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1140 gint bytes; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1141 guint8 *encrypted; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1142 gint encrypted_len; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1143 static const guint8 login_1_16[] = { |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1144 0x56, 0x4E, 0xC8, 0xFB, 0x0A, 0x4F, 0xEF, 0xB3, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1145 0x7A, 0x5D, 0xD8, 0x86, 0x0F, 0xAC, 0xE5, 0x1A |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1146 }; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1147 static const guint8 login_2_16[] = { |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1148 0x5E, 0x22, 0x3A, 0xBE, 0x13, 0xBF, 0xDA, 0x4C, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1149 0xA9, 0xB7, 0x0B, 0x43, 0x63, 0x51, 0x8E, 0x28 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1150 }; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1151 static const guint8 login_3_83[] = { |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1152 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1153 0x00, 0x00, 0x01, 0x40, 0x01, 0x01, 0x58, 0x83, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1154 0xD0, 0x00, 0x10, 0x9D, 0x14, 0x64, 0x0A, 0x2E, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1155 0xE2, 0x11, 0xF7, 0x90, 0xF0, 0xB5, 0x5F, 0x16, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1156 0xFB, 0x41, 0x5D, 0x00, 0x00, 0x00, 0x00, 0x00, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1157 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1158 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1159 0x00, 0x00, 0x00, 0x00, 0x02, 0x76, 0x3C, 0xEE, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1160 0x4A, 0x00, 0x10, 0x86, 0x81, 0xAD, 0x1F, 0xC8, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1161 0xC9, 0xCC, 0xCF, 0xCA, 0x9F, 0xFF, 0x88, 0xC0, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1162 0x5C, 0x88, 0xD5 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1163 }; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1164 g_return_if_fail(gc != NULL && gc->proto_data != NULL); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1165 qd = (qq_data *) gc->proto_data; |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1166 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1167 g_return_if_fail(qd->ld.token != NULL && qd->ld.token_len > 0); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1168 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1169 raw_data = g_newa(guint8, MAX_PACKET_SIZE - 16); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1170 memset(raw_data, 0, MAX_PACKET_SIZE - 16); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1171 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1172 encrypted = g_newa(guint8, MAX_PACKET_SIZE); /* 16 bytes more */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1173 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1174 /* Encrypted password and put in encrypted */ |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1175 bytes = 0; |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1176 bytes += qq_putdata(raw_data + bytes, qd->ld.pwd_md5, sizeof(qd->ld.pwd_md5)); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1177 bytes += qq_put16(raw_data + bytes, 0); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1178 bytes += qq_put16(raw_data + bytes, 0xffff); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1179 |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1180 encrypted_len = qq_encrypt(encrypted, raw_data, bytes, qd->ld.pwd_twice_md5); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1181 |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1182 /* create packet */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1183 bytes = 0; |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1184 bytes += qq_put16(raw_data + bytes, 0); /* Unknow */ |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1185 /* password encrypted */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1186 bytes += qq_put16(raw_data + bytes, encrypted_len); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1187 bytes += qq_putdata(raw_data + bytes, encrypted, encrypted_len); |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1188 /* put data which NULL string encrypted by key pwd_twice_md5 */ |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1189 encrypted_len = qq_encrypt(encrypted, (guint8 *) "", 0, qd->ld.pwd_twice_md5); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1190 g_return_if_fail(encrypted_len == 16); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1191 bytes += qq_putdata(raw_data + bytes, encrypted, encrypted_len); |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1192 /* unknow fill 0 */ |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1193 memset(raw_data + bytes, 0, 19); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1194 bytes += 19; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1195 bytes += qq_putdata(raw_data + bytes, login_1_16, sizeof(login_1_16)); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1196 |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1197 bytes += qq_put8(raw_data + bytes, rand() & 0xff); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1198 bytes += qq_put8(raw_data + bytes, qd->login_mode); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1199 /* unknow 10 bytes zero filled*/ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1200 memset(raw_data + bytes, 0, 10); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1201 bytes += 10; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1202 /* redirect data, 15 bytes */ |
24146
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24145
diff
changeset
|
1203 /* qq_show_packet("Redirect", qd->redirect, qd->redirect_len); */ |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1204 bytes += qq_putdata(raw_data + bytes, qd->redirect, qd->redirect_len); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1205 /* unknow fill */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1206 bytes += qq_putdata(raw_data + bytes, login_2_16, sizeof(login_2_16)); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1207 /* captcha token get from qq_process_token_ex */ |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1208 bytes += qq_put8(raw_data + bytes, (guint8)(qd->ld.token_ex_len & 0xff)); |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1209 bytes += qq_putdata(raw_data + bytes, qd->ld.token_ex, qd->ld.token_ex_len); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1210 /* unknow fill */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1211 bytes += qq_putdata(raw_data + bytes, login_3_83, sizeof(login_3_83)); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1212 memset(raw_data + bytes, 0, 332 - sizeof(login_3_83)); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1213 bytes += 332 - sizeof(login_3_83); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1214 |
24146
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24145
diff
changeset
|
1215 /* qq_show_packet("Login", raw_data, bytes); */ |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1216 |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1217 encrypted_len = qq_encrypt(encrypted, raw_data, bytes, qd->ld.login_key); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1218 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1219 buf = g_newa(guint8, MAX_PACKET_SIZE); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1220 memset(buf, 0, MAX_PACKET_SIZE); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1221 bytes = 0; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1222 /* logint token get from qq_process_check_pwd_2007 */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1223 bytes += qq_put16(buf + bytes, qd->ld.login_token_len); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1224 bytes += qq_putdata(buf + bytes, qd->ld.login_token, qd->ld.login_token_len); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1225 bytes += qq_putdata(buf + bytes, encrypted, encrypted_len); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1226 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1227 qd->send_seq++; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1228 qq_send_cmd_encrypted(gc, QQ_CMD_LOGIN, qd->send_seq, buf, bytes, TRUE); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1229 } |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1230 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1231 /* process the login reply packet */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1232 guint8 qq_process_login_2007( PurpleConnection *gc, guint8 *data, gint data_len) |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1233 { |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1234 qq_data *qd; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1235 gint bytes; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1236 guint8 ret; |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1237 guint32 uid; |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1238 gchar *error; |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1239 gchar *msg; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1240 gchar *msg_utf8; |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1241 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1242 g_return_val_if_fail(data != NULL && data_len != 0, QQ_LOGIN_REPLY_ERR); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1243 |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1244 qd = (qq_data *) gc->proto_data; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1245 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1246 bytes = 0; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1247 bytes += qq_get8(&ret, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1248 if (ret != 0) { |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1249 msg = g_strndup((gchar *)data + bytes, data_len - bytes); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1250 msg_utf8 = qq_to_utf8(msg, QQ_CHARSET_DEFAULT); |
24161
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
1251 g_free(msg); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1252 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1253 switch (ret) { |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1254 case 0x05: |
24161
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
1255 purple_debug_error("QQ", "Server busy for %s\n", msg_utf8); |
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
1256 return QQ_LOGIN_REPLY_REDIRECT; |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1257 case 0x0A: |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1258 /* 0a 2d 9a 4b 9a 01 01 00 00 00 05 00 00 00 00 79 0e 5f fd */ |
24146
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24145
diff
changeset
|
1259 /* Missing get server before login*/ |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1260 default: |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1261 error = g_strdup_printf( |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
1262 _("Unknown reply code when logging in (0x%02X):\n%s"), |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1263 ret, msg_utf8); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1264 break; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1265 } |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1266 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1267 purple_debug_error("QQ", "%s\n", error); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1268 purple_connection_error_reason(gc, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1269 PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1270 error); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1271 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1272 qq_hex_dump(PURPLE_DEBUG_WARNING, "QQ", data, data_len, error); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1273 |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1274 g_free(error); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1275 g_free(msg_utf8); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1276 return QQ_LOGIN_REPLY_ERR; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1277 } |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1278 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1279 bytes += qq_getdata(qd->session_key, sizeof(qd->session_key), data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1280 purple_debug_info("QQ", "Got session_key\n"); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1281 get_session_md5(qd->session_md5, qd->uid, qd->session_key); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1282 |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1283 bytes += qq_get32(&uid, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1284 if (uid != qd->uid) { |
24622
d8af9602c1b1
Correct QQ2005's login reply length
Hu Yong <ccpaging@gmail.com>
parents:
24161
diff
changeset
|
1285 purple_debug_warning("QQ", "My uid in login reply is %u, not %u\n", uid, qd->uid); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1286 } |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1287 bytes += qq_getIP(&qd->my_ip, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1288 bytes += qq_get16(&qd->my_port, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1289 bytes += qq_getIP(&qd->my_local_ip, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1290 bytes += qq_get16(&qd->my_local_port, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1291 bytes += qq_getime(&qd->login_time, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1292 /* skip unknow 50 byte */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1293 bytes += 50; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1294 /* skip client key 32 byte */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1295 bytes += 32; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1296 /* skip unknow 12 byte */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1297 bytes += 12; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1298 /* last login */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1299 bytes += qq_getIP(&qd->last_login_ip, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1300 bytes += qq_getime(&qd->last_login_time[0], data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1301 purple_debug_info("QQ", "Last Login: %s, %s\n", |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1302 inet_ntoa(qd->last_login_ip), ctime(&qd->last_login_time[0])); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1303 return QQ_LOGIN_REPLY_OK; |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1304 } |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1305 |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1306 void qq_request_login_2008(PurpleConnection *gc) |
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1307 { |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1308 qq_data *qd; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1309 guint8 *buf, *raw_data; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1310 gint bytes; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1311 guint8 *encrypted; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1312 gint encrypted_len; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1313 guint8 index, count; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1314 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1315 static const guint8 login_1_16[] = { |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1316 0xD2, 0x41, 0x75, 0x12, 0xC2, 0x86, 0x57, 0x10, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1317 0x78, 0x57, 0xDC, 0x24, 0x8C, 0xAA, 0x8F, 0x4E |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1318 }; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1319 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1320 static const guint8 login_2_16[] = { |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1321 0x94, 0x0B, 0x73, 0x7A, 0xA2, 0x51, 0xF0, 0x4B, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1322 0x95, 0x2F, 0xC6, 0x0A, 0x5B, 0xF6, 0x76, 0x52 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1323 }; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1324 static const guint8 login_3_18[] = { |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1325 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1326 0x00, 0x00, 0x01, 0x40, 0x01, 0x1b, 0x02, 0x84, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1327 0x50, 0x00 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1328 }; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1329 static const guint8 login_4_16[] = { |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1330 0x2D, 0x49, 0x15, 0x55, 0x78, 0xFC, 0xF3, 0xD4, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1331 0x53, 0x55, 0x60, 0x9C, 0x37, 0x9F, 0xE9, 0x59 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1332 }; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1333 static const guint8 login_5_6[] = { |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1334 0x02, 0x68, 0xe8, 0x07, 0x83, 0x00 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1335 }; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1336 static const guint8 login_6_16[] = { |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1337 0x3B, 0xCE, 0x43, 0xF1, 0x8B, 0xA4, 0x2B, 0xB5, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1338 0xB3, 0x51, 0x57, 0xF7, 0x06, 0x4B, 0x18, 0xFC |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1339 }; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1340 g_return_if_fail(gc != NULL && gc->proto_data != NULL); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1341 qd = (qq_data *) gc->proto_data; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1342 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1343 g_return_if_fail(qd->ld.token != NULL && qd->ld.token_len > 0); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1344 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1345 raw_data = g_newa(guint8, MAX_PACKET_SIZE - 16); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1346 memset(raw_data, 0, MAX_PACKET_SIZE - 16); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1347 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1348 encrypted = g_newa(guint8, MAX_PACKET_SIZE); /* 16 bytes more */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1349 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1350 /* Encrypted password and put in encrypted */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1351 bytes = 0; |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1352 bytes += qq_putdata(raw_data + bytes, qd->ld.pwd_md5, sizeof(qd->ld.pwd_md5)); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1353 bytes += qq_put16(raw_data + bytes, 0); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1354 bytes += qq_put16(raw_data + bytes, 0xffff); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1355 |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1356 encrypted_len = qq_encrypt(encrypted, raw_data, bytes, qd->ld.pwd_twice_md5); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1357 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1358 /* create packet */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1359 bytes = 0; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1360 bytes += qq_put16(raw_data + bytes, 0); /* Unknow */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1361 /* password encrypted */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1362 bytes += qq_put16(raw_data + bytes, encrypted_len); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1363 bytes += qq_putdata(raw_data + bytes, encrypted, encrypted_len); |
24138
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1364 /* put data which NULL string encrypted by key pwd_twice_md5 */ |
dc112387190f
2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24137
diff
changeset
|
1365 encrypted_len = qq_encrypt(encrypted, (guint8 *) "", 0, qd->ld.pwd_twice_md5); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1366 g_return_if_fail(encrypted_len == 16); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1367 bytes += qq_putdata(raw_data + bytes, encrypted, encrypted_len); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1368 /* unknow 19 bytes zero filled*/ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1369 memset(raw_data + bytes, 0, 19); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1370 bytes += 19; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1371 bytes += qq_putdata(raw_data + bytes, login_1_16, sizeof(login_1_16)); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1372 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1373 index = rand() % 3; /* can be set as 1 */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1374 for( count = 0; count < encrypted_len; count++ ) |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1375 index ^= encrypted[count]; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1376 for( count = 0; count < sizeof(login_1_16); count++ ) |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1377 index ^= login_1_16[count]; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1378 bytes += qq_put8(raw_data + bytes, index); /* random in QQ 2007*/ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1379 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1380 bytes += qq_put8(raw_data + bytes, qd->login_mode); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1381 /* unknow 10 bytes zero filled*/ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1382 memset(raw_data + bytes, 0, 10); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1383 bytes += 10; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1384 /* redirect data, 15 bytes */ |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1385 bytes += qq_putdata(raw_data + bytes, qd->redirect, qd->redirect_len); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1386 /* unknow fill */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1387 bytes += qq_putdata(raw_data + bytes, login_2_16, sizeof(login_2_16)); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1388 /* captcha token get from qq_process_token_ex */ |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1389 bytes += qq_put8(raw_data + bytes, (guint8)(qd->ld.token_ex_len & 0xff)); |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1390 bytes += qq_putdata(raw_data + bytes, qd->ld.token_ex, qd->ld.token_ex_len); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1391 /* unknow fill */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1392 bytes += qq_putdata(raw_data + bytes, login_3_18, sizeof(login_3_18)); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1393 bytes += qq_put8(raw_data + bytes , sizeof(login_4_16)); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1394 bytes += qq_putdata(raw_data + bytes, login_4_16, sizeof(login_4_16)); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1395 /* unknow 10 bytes zero filled*/ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1396 memset(raw_data + bytes, 0, 10); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1397 bytes += 10; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1398 /* redirect data, 15 bytes */ |
24139
832178d951ca
2008.09.30 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24138
diff
changeset
|
1399 bytes += qq_putdata(raw_data + bytes, qd->redirect, qd->redirect_len); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1400 /* unknow fill */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1401 bytes += qq_putdata(raw_data + bytes, login_5_6, sizeof(login_5_6)); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1402 bytes += qq_put8(raw_data + bytes , sizeof(login_6_16)); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1403 bytes += qq_putdata(raw_data + bytes, login_6_16, sizeof(login_6_16)); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1404 /* unknow 249 bytes zero filled*/ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1405 memset(raw_data + bytes, 0, 249); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1406 bytes += 249; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1407 |
24146
ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24145
diff
changeset
|
1408 /* qq_show_packet("Login request", raw_data, bytes); */ |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1409 encrypted_len = qq_encrypt(encrypted, raw_data, bytes, qd->ld.login_key); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1410 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1411 buf = g_newa(guint8, MAX_PACKET_SIZE); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1412 memset(buf, 0, MAX_PACKET_SIZE); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1413 bytes = 0; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1414 /* logint token get from qq_process_check_pwd_2007 */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1415 bytes += qq_put16(buf + bytes, qd->ld.login_token_len); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1416 bytes += qq_putdata(buf + bytes, qd->ld.login_token, qd->ld.login_token_len); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1417 bytes += qq_putdata(buf + bytes, encrypted, encrypted_len); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1418 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1419 qd->send_seq++; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1420 qq_send_cmd_encrypted(gc, QQ_CMD_LOGIN, qd->send_seq, buf, bytes, TRUE); |
24135
dbc7a9742f8d
2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24134
diff
changeset
|
1421 } |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1422 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1423 guint8 qq_process_login_2008( PurpleConnection *gc, guint8 *data, gint data_len) |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1424 { |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1425 qq_data *qd; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1426 gint bytes; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1427 guint8 ret; |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1428 guint32 uid; |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1429 gchar *error; |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1430 gchar *msg; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1431 gchar *msg_utf8; |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1432 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1433 g_return_val_if_fail(data != NULL && data_len != 0, QQ_LOGIN_REPLY_ERR); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1434 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1435 qd = (qq_data *) gc->proto_data; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1436 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1437 bytes = 0; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1438 bytes += qq_get8(&ret, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1439 if (ret != 0) { |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1440 msg = g_strndup((gchar *)data + bytes, data_len - bytes); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1441 msg_utf8 = qq_to_utf8(msg, QQ_CHARSET_DEFAULT); |
24161
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
1442 g_free(msg); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1443 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1444 switch (ret) { |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1445 case 0x05: |
24161
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
1446 purple_debug_error("QQ", "Server busy for %s\n", msg_utf8); |
7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24146
diff
changeset
|
1447 return QQ_LOGIN_REPLY_REDIRECT; |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1448 break; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1449 default: |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1450 error = g_strdup_printf( |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24679
diff
changeset
|
1451 _("Unknown reply code when logging in (0x%02X):\n%s"), |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1452 ret, msg_utf8); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1453 break; |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1454 } |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1455 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1456 purple_debug_error("QQ", "%s\n", error); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1457 purple_connection_error_reason(gc, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1458 PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1459 error); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1460 |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1461 qq_hex_dump(PURPLE_DEBUG_WARNING, "QQ", data, data_len, error); |
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1462 |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1463 g_free(error); |
24140
619ac2303c46
2009.10.02 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24139
diff
changeset
|
1464 g_free(msg_utf8); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1465 return QQ_LOGIN_REPLY_ERR; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1466 } |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1467 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1468 bytes += qq_getdata(qd->session_key, sizeof(qd->session_key), data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1469 purple_debug_info("QQ", "Got session_key\n"); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1470 get_session_md5(qd->session_md5, qd->uid, qd->session_key); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1471 |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1472 bytes += qq_get32(&uid, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1473 if (uid != qd->uid) { |
24622
d8af9602c1b1
Correct QQ2005's login reply length
Hu Yong <ccpaging@gmail.com>
parents:
24161
diff
changeset
|
1474 purple_debug_warning("QQ", "My uid in login reply is %u, not %u\n", uid, qd->uid); |
24137
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1475 } |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1476 bytes += qq_getIP(&qd->my_ip, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1477 bytes += qq_get16(&qd->my_port, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1478 bytes += qq_getIP(&qd->my_local_ip, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1479 bytes += qq_get16(&qd->my_local_port, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1480 bytes += qq_getime(&qd->login_time, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1481 /* skip 1 byte, always 0x03 */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1482 /* skip 1 byte, login mode */ |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1483 bytes = 131; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1484 bytes += qq_getIP(&qd->last_login_ip, data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1485 bytes += qq_getime(&qd->last_login_time[0], data + bytes); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1486 purple_debug_info("QQ", "Last Login: %s, %s\n", |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1487 inet_ntoa(qd->last_login_ip), ctime(&qd->last_login_time[0])); |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1488 return QQ_LOGIN_REPLY_OK; |
87e61a85f5dd
2008.09.28 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents:
24135
diff
changeset
|
1489 } |