Sun, 07 Feb 2010 09:30:49 +0000
Add back Paul's error message from revision 315ffdf6a4550e47b2bc6e5a29af0e47e107abc6
(disapproved in revision 7e3a0cb4e40e22ed38733ad9aebf61031b7e20d6) with
a slightly improved error message. Thanks for adding this in the first place,
Paul! Sorry it took me months to re-instate it after I complained!
Hopefully AOL won't start asking users to fill out CAPTCHAs in order to
log in, because that would be messy (both our implementation and the
user experience).
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
1 | /* |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
2 | * Purple's oscar protocol plugin |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
3 | * This file is the legal property of its developers. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
4 | * Please see the AUTHORS file distributed alongside this file. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
5 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
6 | * This library is free software; you can redistribute it and/or |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
7 | * modify it under the terms of the GNU Lesser General Public |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
8 | * License as published by the Free Software Foundation; either |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
9 | * version 2 of the License, or (at your option) any later version. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
10 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
11 | * This library is distributed in the hope that it will be useful, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
14 | * Lesser General Public License for more details. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
15 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
16 | * You should have received a copy of the GNU Lesser General Public |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
17 | * License along with this library; if not, write to the Free Software |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
19 | */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
20 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
21 | /** |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
22 | * This file implements AIM's clientLogin procedure for authenticating |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
23 | * users. This replaces the older MD5-based and XOR-based |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
24 | * authentication methods that use SNAC family 0x0017. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
25 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
26 | * This doesn't use SNACs or FLAPs at all. It makes http and https |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
27 | * POSTs to AOL to validate the user based on the password they |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
28 | * provided to us. Upon successful authentication we request a |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
29 | * connection to the BOS server by calling startOSCARsession. The |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
30 | * AOL server gives us the hostname and port number to use, as well |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
31 | * as the cookie to use to authenticate to the BOS server. And then |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
32 | * everything else is the same as with BUCP. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
33 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
34 | * For details, see: |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
35 | * http://dev.aol.com/aim/oscar/#AUTH |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
36 | * http://dev.aol.com/authentication_for_clients |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
37 | */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
38 | |
|
29106
51c7b2177e42
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <darkrain42@pidgin.im>
parents:
29100
diff
changeset
|
39 | #include "oscar.h" |
|
51c7b2177e42
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <darkrain42@pidgin.im>
parents:
29100
diff
changeset
|
40 | #include "oscarcommon.h" |
|
51c7b2177e42
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <darkrain42@pidgin.im>
parents:
29100
diff
changeset
|
41 | |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
42 | #include "cipher.h" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
43 | #include "core.h" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
44 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
45 | #define URL_CLIENT_LOGIN "https://api.screenname.aol.com/auth/clientLogin" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
46 | #define URL_START_OSCAR_SESSION "http://api.oscar.aol.com/aim/startOSCARSession" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
47 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
48 | /* |
|
27684
f85539a9fc3a
Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents:
27635
diff
changeset
|
49 | * Using clientLogin requires a developer ID. This key is for libpurple. |
|
f85539a9fc3a
Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents:
27635
diff
changeset
|
50 | * It is the default key for all libpurple-based clients. AOL encourages |
|
f85539a9fc3a
Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents:
27635
diff
changeset
|
51 | * UIs (especially ones with lots of users) to override this with their |
|
f85539a9fc3a
Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents:
27635
diff
changeset
|
52 | * own key. This key is owned by the AIM account "markdoliner" |
|
f85539a9fc3a
Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents:
27635
diff
changeset
|
53 | * |
|
f85539a9fc3a
Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents:
27635
diff
changeset
|
54 | * Keys can be managed at http://developer.aim.com/manageKeys.jsp |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
55 | */ |
|
27684
f85539a9fc3a
Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents:
27635
diff
changeset
|
56 | #define DEFAULT_CLIENT_KEY "ma15d7JTxbmVG-RP" |
|
f85539a9fc3a
Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents:
27635
diff
changeset
|
57 | |
|
f85539a9fc3a
Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents:
27635
diff
changeset
|
58 | static const char *get_client_key(OscarData *od) |
|
f85539a9fc3a
Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents:
27635
diff
changeset
|
59 | { |
|
27686
c790e9057b4e
Create a oscar_get_ui_info_string() function that looks up a value in the
Mark Doliner <markdoliner@pidgin.im>
parents:
27684
diff
changeset
|
60 | return oscar_get_ui_info_string( |
|
c790e9057b4e
Create a oscar_get_ui_info_string() function that looks up a value in the
Mark Doliner <markdoliner@pidgin.im>
parents:
27684
diff
changeset
|
61 | od->icq ? "prpl-icq-clientkey" : "prpl-aim-clientkey", |
|
c790e9057b4e
Create a oscar_get_ui_info_string() function that looks up a value in the
Mark Doliner <markdoliner@pidgin.im>
parents:
27684
diff
changeset
|
62 | DEFAULT_CLIENT_KEY); |
|
27684
f85539a9fc3a
Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents:
27635
diff
changeset
|
63 | } |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
64 | |
|
29233
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
65 | static gchar *generate_error_message(xmlnode *resp, const char *url) |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
66 | { |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
67 | xmlnode *text; |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
68 | gchar *err = NULL; |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
69 | gchar *details = NULL; |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
70 | |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
71 | if (resp && (text = xmlnode_get_child(resp, "statusText"))) { |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
72 | details = xmlnode_get_data(text); |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
73 | } |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
74 | |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
75 | if (details && *details) { |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
76 | err = g_strdup_printf(_("Received unexpected response from %s: %s"), url, details); |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
77 | } else { |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
78 | err = g_strdup_printf(_("Received unexpected response from %s"), url); |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
79 | } |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
80 | |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
81 | g_free(details); |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
82 | return err; |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
83 | } |
|
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
84 | |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
85 | /** |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
86 | * @return A null-terminated base64 encoded version of the HMAC |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
87 | * calculated using the given key and data. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
88 | */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
89 | static gchar *hmac_sha256(const char *key, const char *message) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
90 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
91 | PurpleCipherContext *context; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
92 | guchar digest[32]; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
93 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
94 | context = purple_cipher_context_new_by_name("hmac", NULL); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
95 | purple_cipher_context_set_option(context, "hash", "sha256"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
96 | purple_cipher_context_set_key(context, (guchar *)key); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
97 | purple_cipher_context_append(context, (guchar *)message, strlen(message)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
98 | purple_cipher_context_digest(context, sizeof(digest), digest, NULL); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
99 | purple_cipher_context_destroy(context); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
100 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
101 | return purple_base64_encode(digest, sizeof(digest)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
102 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
103 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
104 | /** |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
105 | * @return A base-64 encoded HMAC-SHA256 signature created using the |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
106 | * technique documented at |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
107 | * http://dev.aol.com/authentication_for_clients#signing |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
108 | */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
109 | static gchar *generate_signature(const char *method, const char *url, const char *parameters, const char *session_key) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
110 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
111 | char *encoded_url, *signature_base_string, *signature; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
112 | const char *encoded_parameters; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
113 | |
|
28538
fb879aa298ee
Change purple_url_encode() to not encode . _ - ~ because it's not
Mark Doliner <markdoliner@pidgin.im>
parents:
28274
diff
changeset
|
114 | encoded_url = g_strdup(purple_url_encode(url)); |
|
fb879aa298ee
Change purple_url_encode() to not encode . _ - ~ because it's not
Mark Doliner <markdoliner@pidgin.im>
parents:
28274
diff
changeset
|
115 | encoded_parameters = purple_url_encode(parameters); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
116 | signature_base_string = g_strdup_printf("%s&%s&%s", |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
117 | method, encoded_url, encoded_parameters); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
118 | g_free(encoded_url); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
119 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
120 | signature = hmac_sha256(session_key, signature_base_string); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
121 | g_free(signature_base_string); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
122 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
123 | return signature; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
124 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
125 | |
|
28824
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
126 | static gboolean parse_start_oscar_session_response(PurpleConnection *gc, const gchar *response, gsize response_len, char **host, unsigned short *port, char **cookie, char **tls_certname) |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
127 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
128 | xmlnode *response_node, *tmp_node, *data_node; |
|
28824
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
129 | xmlnode *host_node = NULL, *port_node = NULL, *cookie_node = NULL, *tls_node = NULL; |
|
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
130 | gboolean use_tls; |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
131 | char *tmp; |
|
28837
e9b208719e54
oscar: According to the online docs, statusCode 607 is rate limit (confirmed
Paul Aurich <darkrain42@pidgin.im>
parents:
28825
diff
changeset
|
132 | guint code; |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
133 | |
|
28824
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
134 | use_tls = purple_account_get_bool(purple_connection_get_account(gc), "use_ssl", OSCAR_DEFAULT_USE_SSL); |
|
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
135 | |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
136 | /* Parse the response as XML */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
137 | response_node = xmlnode_from_str(response, response_len); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
138 | if (response_node == NULL) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
139 | { |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
140 | char *msg; |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
141 | purple_debug_error("oscar", "startOSCARSession could not parse " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
142 | "response as XML: %s\n", response); |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
143 | /* Note to translators: %s in this string is a URL */ |
|
29233
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
144 | msg = generate_error_message(response_node, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
145 | URL_START_OSCAR_SESSION); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
146 | purple_connection_error_reason(gc, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
147 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
148 | g_free(msg); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
149 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
150 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
151 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
152 | /* Grab the necessary XML nodes */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
153 | tmp_node = xmlnode_get_child(response_node, "statusCode"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
154 | data_node = xmlnode_get_child(response_node, "data"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
155 | if (data_node != NULL) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
156 | host_node = xmlnode_get_child(data_node, "host"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
157 | port_node = xmlnode_get_child(data_node, "port"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
158 | cookie_node = xmlnode_get_child(data_node, "cookie"); |
|
28824
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
159 | tls_node = xmlnode_get_child(data_node, "tlsCertName"); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
160 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
161 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
162 | /* Make sure we have a status code */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
163 | if (tmp_node == NULL || (tmp = xmlnode_get_data_unescaped(tmp_node)) == NULL) { |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
164 | char *msg; |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
165 | purple_debug_error("oscar", "startOSCARSession response was " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
166 | "missing statusCode: %s\n", response); |
|
29233
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
167 | msg = generate_error_message(response_node, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
168 | URL_START_OSCAR_SESSION); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
169 | purple_connection_error_reason(gc, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
170 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
171 | g_free(msg); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
172 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
173 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
174 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
175 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
176 | /* Make sure the status code was 200 */ |
|
28837
e9b208719e54
oscar: According to the online docs, statusCode 607 is rate limit (confirmed
Paul Aurich <darkrain42@pidgin.im>
parents:
28825
diff
changeset
|
177 | code = atoi(tmp); |
|
e9b208719e54
oscar: According to the online docs, statusCode 607 is rate limit (confirmed
Paul Aurich <darkrain42@pidgin.im>
parents:
28825
diff
changeset
|
178 | if (code != 200) |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
179 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
180 | purple_debug_error("oscar", "startOSCARSession response statusCode " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
181 | "was %s: %s\n", tmp, response); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
182 | |
|
28837
e9b208719e54
oscar: According to the online docs, statusCode 607 is rate limit (confirmed
Paul Aurich <darkrain42@pidgin.im>
parents:
28825
diff
changeset
|
183 | if (code == 401 || code == 607) |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
184 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
185 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
186 | _("You have been connecting and disconnecting too " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
187 | "frequently. Wait ten minutes and try again. If " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
188 | "you continue to try, you will need to wait even " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
189 | "longer.")); |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
190 | else { |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
191 | char *msg; |
|
29233
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
192 | msg = generate_error_message(response_node, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
193 | URL_START_OSCAR_SESSION); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
194 | purple_connection_error_reason(gc, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
195 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, msg); |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
196 | g_free(msg); |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
197 | } |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
198 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
199 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
200 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
201 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
202 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
203 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
204 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
205 | /* Make sure we have everything else */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
206 | if (data_node == NULL || host_node == NULL || |
|
28824
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
207 | port_node == NULL || cookie_node == NULL || |
|
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
208 | (use_tls && tls_node == NULL)) |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
209 | { |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
210 | char *msg; |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
211 | purple_debug_error("oscar", "startOSCARSession response was missing " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
212 | "something: %s\n", response); |
|
29233
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
213 | msg = generate_error_message(response_node, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
214 | URL_START_OSCAR_SESSION); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
215 | purple_connection_error_reason(gc, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
216 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
217 | g_free(msg); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
218 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
219 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
220 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
221 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
222 | /* Extract data from the XML */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
223 | *host = xmlnode_get_data_unescaped(host_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
224 | tmp = xmlnode_get_data_unescaped(port_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
225 | *cookie = xmlnode_get_data_unescaped(cookie_node); |
|
28824
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
226 | |
|
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
227 | if (use_tls) |
|
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
228 | *tls_certname = xmlnode_get_data_unescaped(tls_node); |
|
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
229 | |
|
28825
c40c8701e99c
oscar: Pretty sure this was a typo; cookie is a char ** (passed in as arg).
Paul Aurich <darkrain42@pidgin.im>
parents:
28824
diff
changeset
|
230 | if (*host == NULL || **host == '\0' || tmp == NULL || *tmp == '\0' || *cookie == NULL || **cookie == '\0' || |
|
28824
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
231 | (use_tls && (*tls_certname == NULL || **tls_certname == '\0'))) |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
232 | { |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
233 | char *msg; |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
234 | purple_debug_error("oscar", "startOSCARSession response was missing " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
235 | "something: %s\n", response); |
|
29233
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
236 | msg = generate_error_message(response_node, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
237 | URL_START_OSCAR_SESSION); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
238 | purple_connection_error_reason(gc, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
239 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
240 | g_free(msg); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
241 | g_free(*host); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
242 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
243 | g_free(*cookie); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
244 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
245 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
246 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
247 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
248 | *port = atoi(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
249 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
250 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
251 | return TRUE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
252 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
253 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
254 | static void start_oscar_session_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
255 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
256 | OscarData *od; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
257 | PurpleConnection *gc; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
258 | char *host, *cookie; |
|
28824
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
259 | char *tls_certname = NULL; |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
260 | unsigned short port; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
261 | guint8 *cookiedata; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
262 | gsize cookiedata_len; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
263 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
264 | od = user_data; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
265 | gc = od->gc; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
266 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
267 | od->url_data = NULL; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
268 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
269 | if (error_message != NULL || len == 0) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
270 | gchar *tmp; |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
271 | /* Note to translators: The first %s is a URL, the second is an |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
272 | error message. */ |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
273 | tmp = g_strdup_printf(_("Error requesting %s: %s"), |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
274 | URL_START_OSCAR_SESSION, error_message); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
275 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
276 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
277 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
278 | return; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
279 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
280 | |
|
28824
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
281 | if (!parse_start_oscar_session_response(gc, url_text, len, &host, &port, &cookie, &tls_certname)) |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
282 | return; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
283 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
284 | cookiedata = purple_base64_decode(cookie, &cookiedata_len); |
|
28824
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
285 | oscar_connect_to_bos(gc, od, host, port, cookiedata, cookiedata_len, tls_certname); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
286 | g_free(cookiedata); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
287 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
288 | g_free(host); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
289 | g_free(cookie); |
|
28824
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
290 | g_free(tls_certname); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
291 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
292 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
293 | static void send_start_oscar_session(OscarData *od, const char *token, const char *session_key, time_t hosttime) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
294 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
295 | char *query_string, *signature, *url; |
|
28824
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
296 | gboolean use_tls = purple_account_get_bool(purple_connection_get_account(od->gc), "use_ssl", OSCAR_DEFAULT_USE_SSL); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
297 | |
|
29071
a1e2c4649516
This magic number is documented in oscar.h, but it makes sense to
Mark Doliner <markdoliner@pidgin.im>
parents:
29070
diff
changeset
|
298 | /* |
|
a1e2c4649516
This magic number is documented in oscar.h, but it makes sense to
Mark Doliner <markdoliner@pidgin.im>
parents:
29070
diff
changeset
|
299 | * Construct the GET parameters. 0x00000611 is the distid given to |
|
a1e2c4649516
This magic number is documented in oscar.h, but it makes sense to
Mark Doliner <markdoliner@pidgin.im>
parents:
29070
diff
changeset
|
300 | * us by AOL for use as the default libpurple distid. |
|
a1e2c4649516
This magic number is documented in oscar.h, but it makes sense to
Mark Doliner <markdoliner@pidgin.im>
parents:
29070
diff
changeset
|
301 | */ |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
302 | query_string = g_strdup_printf("a=%s" |
|
29070
a255a2bc015b
Send our distid when calling startOSCARSession, as request by AOL
Mark Doliner <markdoliner@pidgin.im>
parents:
28837
diff
changeset
|
303 | "&distId=%d" |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
304 | "&f=xml" |
|
27684
f85539a9fc3a
Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents:
27635
diff
changeset
|
305 | "&k=%s" |
|
27705
06cdb9c6366f
Fix this compiler warning:
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27686
diff
changeset
|
306 | "&ts=%" PURPLE_TIME_T_MODIFIER |
|
28824
e23d22216f58
oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents:
28538
diff
changeset
|
307 | "&useTLS=%d", |
|
29070
a255a2bc015b
Send our distid when calling startOSCARSession, as request by AOL
Mark Doliner <markdoliner@pidgin.im>
parents:
28837
diff
changeset
|
308 | purple_url_encode(token), |
|
a255a2bc015b
Send our distid when calling startOSCARSession, as request by AOL
Mark Doliner <markdoliner@pidgin.im>
parents:
28837
diff
changeset
|
309 | oscar_get_ui_info_int(od->icq ? "prpl-icq-distid" |
|
a255a2bc015b
Send our distid when calling startOSCARSession, as request by AOL
Mark Doliner <markdoliner@pidgin.im>
parents:
28837
diff
changeset
|
310 | : "prpl-aim-distid", 0x00000611), |
|
a255a2bc015b
Send our distid when calling startOSCARSession, as request by AOL
Mark Doliner <markdoliner@pidgin.im>
parents:
28837
diff
changeset
|
311 | get_client_key(od), hosttime, use_tls); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
312 | signature = generate_signature("GET", URL_START_OSCAR_SESSION, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
313 | query_string, session_key); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
314 | url = g_strdup_printf(URL_START_OSCAR_SESSION "?%s&sig_sha256=%s", |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
315 | query_string, signature); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
316 | g_free(query_string); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
317 | g_free(signature); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
318 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
319 | /* Make the request */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
320 | od->url_data = purple_util_fetch_url(url, TRUE, NULL, FALSE, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
321 | start_oscar_session_cb, od); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
322 | g_free(url); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
323 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
324 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
325 | /** |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
326 | * This function parses the given response from a clientLogin request |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
327 | * and extracts the useful information. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
328 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
329 | * @param gc The PurpleConnection. If the response data does |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
330 | * not indicate then purple_connection_error_reason() |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
331 | * will be called to close this connection. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
332 | * @param response The response data from the clientLogin request. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
333 | * @param response_len The length of the above response, or -1 if |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
334 | * @response is NUL terminated. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
335 | * @param token If parsing was successful then this will be set to |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
336 | * a newly allocated string containing the token. The |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
337 | * caller should g_free this string when it is finished |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
338 | * with it. On failure this value will be untouched. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
339 | * @param secret If parsing was successful then this will be set to |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
340 | * a newly allocated string containing the secret. The |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
341 | * caller should g_free this string when it is finished |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
342 | * with it. On failure this value will be untouched. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
343 | * @param hosttime If parsing was successful then this will be set to |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
344 | * the time on the OpenAuth Server in seconds since the |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
345 | * Unix epoch. On failure this value will be untouched. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
346 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
347 | * @return TRUE if the request was successful and we were able to |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
348 | * extract all info we need. Otherwise FALSE. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
349 | */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
350 | static gboolean parse_client_login_response(PurpleConnection *gc, const gchar *response, gsize response_len, char **token, char **secret, time_t *hosttime) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
351 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
352 | xmlnode *response_node, *tmp_node, *data_node; |
|
27442
754d246cd697
Silence some warnings from gcc on OS X. None of these were actually valid.
Paul Aurich <darkrain42@pidgin.im>
parents:
27414
diff
changeset
|
353 | xmlnode *secret_node = NULL, *hosttime_node = NULL, *token_node = NULL, *tokena_node = NULL; |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
354 | char *tmp; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
355 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
356 | /* Parse the response as XML */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
357 | response_node = xmlnode_from_str(response, response_len); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
358 | if (response_node == NULL) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
359 | { |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
360 | char *msg; |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
361 | purple_debug_error("oscar", "clientLogin could not parse " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
362 | "response as XML: %s\n", response); |
|
29233
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
363 | msg = generate_error_message(response_node, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
364 | URL_CLIENT_LOGIN); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
365 | purple_connection_error_reason(gc, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
366 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
367 | g_free(msg); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
368 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
369 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
370 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
371 | /* Grab the necessary XML nodes */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
372 | tmp_node = xmlnode_get_child(response_node, "statusCode"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
373 | data_node = xmlnode_get_child(response_node, "data"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
374 | if (data_node != NULL) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
375 | secret_node = xmlnode_get_child(data_node, "sessionSecret"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
376 | hosttime_node = xmlnode_get_child(data_node, "hostTime"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
377 | token_node = xmlnode_get_child(data_node, "token"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
378 | if (token_node != NULL) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
379 | tokena_node = xmlnode_get_child(token_node, "a"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
380 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
381 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
382 | /* Make sure we have a status code */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
383 | if (tmp_node == NULL || (tmp = xmlnode_get_data_unescaped(tmp_node)) == NULL) { |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
384 | char *msg; |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
385 | purple_debug_error("oscar", "clientLogin response was " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
386 | "missing statusCode: %s\n", response); |
|
29233
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
387 | msg = generate_error_message(response_node, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
388 | URL_CLIENT_LOGIN); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
389 | purple_connection_error_reason(gc, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
390 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
391 | g_free(msg); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
392 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
393 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
394 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
395 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
396 | /* Make sure the status code was 200 */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
397 | if (strcmp(tmp, "200") != 0) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
398 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
399 | int status_code, status_detail_code = 0; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
400 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
401 | status_code = atoi(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
402 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
403 | tmp_node = xmlnode_get_child(response_node, "statusDetailCode"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
404 | if (tmp_node != NULL && (tmp = xmlnode_get_data_unescaped(tmp_node)) != NULL) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
405 | status_detail_code = atoi(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
406 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
407 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
408 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
409 | purple_debug_error("oscar", "clientLogin response statusCode " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
410 | "was %d (%d): %s\n", status_code, status_detail_code, response); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
411 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
412 | if (status_code == 330 && status_detail_code == 3011) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
413 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
414 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27442
diff
changeset
|
415 | _("Incorrect password")); |
|
29317
d46d080a42cc
Add back Paul's error message from revision 315ffdf6a4550e47b2bc6e5a29af0e47e107abc6
Mark Doliner <markdoliner@pidgin.im>
parents:
29233
diff
changeset
|
416 | } else if (status_code == 330 && status_detail_code == 3015) { |
|
d46d080a42cc
Add back Paul's error message from revision 315ffdf6a4550e47b2bc6e5a29af0e47e107abc6
Mark Doliner <markdoliner@pidgin.im>
parents:
29233
diff
changeset
|
417 | purple_connection_error_reason(gc, |
|
d46d080a42cc
Add back Paul's error message from revision 315ffdf6a4550e47b2bc6e5a29af0e47e107abc6
Mark Doliner <markdoliner@pidgin.im>
parents:
29233
diff
changeset
|
418 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, |
|
d46d080a42cc
Add back Paul's error message from revision 315ffdf6a4550e47b2bc6e5a29af0e47e107abc6
Mark Doliner <markdoliner@pidgin.im>
parents:
29233
diff
changeset
|
419 | _("Server requested that you fill out a CAPTCHA in order to " |
|
d46d080a42cc
Add back Paul's error message from revision 315ffdf6a4550e47b2bc6e5a29af0e47e107abc6
Mark Doliner <markdoliner@pidgin.im>
parents:
29233
diff
changeset
|
420 | "sign in, but this client does not currently support CAPTCHAs.")); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
421 | } else if (status_code == 401 && status_detail_code == 3019) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
422 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
423 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27442
diff
changeset
|
424 | _("AOL does not allow your screen name to authenticate here")); |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
425 | } else { |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
426 | char *msg; |
|
29233
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
427 | msg = generate_error_message(response_node, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
428 | URL_CLIENT_LOGIN); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
429 | purple_connection_error_reason(gc, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
430 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, msg); |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
431 | g_free(msg); |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
432 | } |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
433 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
434 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
435 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
436 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
437 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
438 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
439 | /* Make sure we have everything else */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
440 | if (data_node == NULL || secret_node == NULL || |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
441 | token_node == NULL || tokena_node == NULL) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
442 | { |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
443 | char *msg; |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
444 | purple_debug_error("oscar", "clientLogin response was missing " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
445 | "something: %s\n", response); |
|
29233
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
446 | msg = generate_error_message(response_node, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
447 | URL_CLIENT_LOGIN); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
448 | purple_connection_error_reason(gc, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
449 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
450 | g_free(msg); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
451 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
452 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
453 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
454 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
455 | /* Extract data from the XML */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
456 | *token = xmlnode_get_data_unescaped(tokena_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
457 | *secret = xmlnode_get_data_unescaped(secret_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
458 | tmp = xmlnode_get_data_unescaped(hosttime_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
459 | if (*token == NULL || **token == '\0' || *secret == NULL || **secret == '\0' || tmp == NULL || *tmp == '\0') |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
460 | { |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
461 | char *msg; |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
462 | purple_debug_error("oscar", "clientLogin response was missing " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
463 | "something: %s\n", response); |
|
29233
a686b1d2f50f
oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29106
diff
changeset
|
464 | msg = generate_error_message(response_node, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
465 | URL_CLIENT_LOGIN); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
466 | purple_connection_error_reason(gc, |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
467 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
468 | g_free(msg); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
469 | g_free(*token); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
470 | g_free(*secret); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
471 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
472 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
473 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
474 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
475 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
476 | *hosttime = strtol(tmp, NULL, 10); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
477 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
478 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
479 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
480 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
481 | return TRUE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
482 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
483 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
484 | static void client_login_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
485 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
486 | OscarData *od; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
487 | PurpleConnection *gc; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
488 | char *token, *secret, *session_key; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
489 | time_t hosttime; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
490 | int password_len; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
491 | char *password; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
492 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
493 | od = user_data; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
494 | gc = od->gc; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
495 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
496 | od->url_data = NULL; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
497 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
498 | if (error_message != NULL || len == 0) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
499 | gchar *tmp; |
|
28274
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
500 | tmp = g_strdup_printf(_("Error requesting %s: %s"), |
|
4eca816a16a2
Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents:
27705
diff
changeset
|
501 | URL_CLIENT_LOGIN, error_message); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
502 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
503 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
504 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
505 | return; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
506 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
507 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
508 | if (!parse_client_login_response(gc, url_text, len, &token, &secret, &hosttime)) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
509 | return; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
510 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
511 | password_len = strlen(purple_connection_get_password(gc)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
512 | password = g_strdup_printf("%.*s", |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
513 | od->icq ? MIN(password_len, MAXICQPASSLEN) : password_len, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
514 | purple_connection_get_password(gc)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
515 | session_key = hmac_sha256(password, secret); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
516 | g_free(password); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
517 | g_free(secret); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
518 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
519 | send_start_oscar_session(od, token, session_key, hosttime); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
520 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
521 | g_free(token); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
522 | g_free(session_key); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
523 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
524 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
525 | /** |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
526 | * This function sends a request to |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
527 | * https://api.screenname.aol.com/auth/clientLogin with the user's |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
528 | * username and password and receives the user's session key, which is |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
529 | * used to request a connection to the BOSS server. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
530 | */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
531 | void send_client_login(OscarData *od, const char *username) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
532 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
533 | PurpleConnection *gc; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
534 | GString *request, *body; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
535 | const char *tmp; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
536 | char *password; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
537 | int password_len; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
538 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
539 | gc = od->gc; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
540 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
541 | /* |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
542 | * We truncate ICQ passwords to 8 characters. There is probably a |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
543 | * limit for AIM passwords, too, but we really only need to do |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
544 | * this for ICQ because older ICQ clients let you enter a password |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
545 | * as long as you wanted and then they truncated it silently. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
546 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
547 | * And we can truncate based on the number of bytes and not the |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
548 | * number of characters because passwords for AIM and ICQ are |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
549 | * supposed to be plain ASCII (I don't know if this has always been |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
550 | * the case, though). |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
551 | */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
552 | tmp = purple_connection_get_password(gc); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
553 | password_len = strlen(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
554 | password = g_strndup(tmp, od->icq ? MIN(password_len, MAXICQPASSLEN) : password_len); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
555 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
556 | /* Construct the body of the HTTP POST request */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
557 | body = g_string_new(""); |
|
27684
f85539a9fc3a
Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents:
27635
diff
changeset
|
558 | g_string_append_printf(body, "devId=%s", get_client_key(od)); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
559 | g_string_append_printf(body, "&f=xml"); |
|
28538
fb879aa298ee
Change purple_url_encode() to not encode . _ - ~ because it's not
Mark Doliner <markdoliner@pidgin.im>
parents:
28274
diff
changeset
|
560 | g_string_append_printf(body, "&pwd=%s", purple_url_encode(password)); |
|
fb879aa298ee
Change purple_url_encode() to not encode . _ - ~ because it's not
Mark Doliner <markdoliner@pidgin.im>
parents:
28274
diff
changeset
|
561 | g_string_append_printf(body, "&s=%s", purple_url_encode(username)); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
562 | g_free(password); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
563 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
564 | /* Construct an HTTP POST request */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
565 | request = g_string_new("POST /auth/clientLogin HTTP/1.0\r\n" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
566 | "Connection: close\r\n" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
567 | "Accept: */*\r\n"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
568 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
569 | /* Tack on the body */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
570 | g_string_append_printf(request, "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n"); |
|
27414
b676cf2259c7
Dear Compiler, Shut up!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27385
diff
changeset
|
571 | g_string_append_printf(request, "Content-Length: %" G_GSIZE_FORMAT "\r\n\r\n", body->len); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
572 | g_string_append_len(request, body->str, body->len); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
573 | g_string_free(body, TRUE); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
574 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
575 | /* Send the POST request */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
576 | od->url_data = purple_util_fetch_url_request(URL_CLIENT_LOGIN, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
577 | TRUE, NULL, FALSE, request->str, FALSE, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
578 | client_login_cb, od); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
579 | g_string_free(request, TRUE); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
580 | } |