libpurple/protocols/oscar/clientlogin.c

Fri, 31 Jan 2014 18:14:33 +0530

author
Ankit Vani <a@nevitus.org>
date
Fri, 31 Jan 2014 18:14:33 +0530
branch
gtkdoc-conversion
changeset 35393
00f876b129bc
parent 34935
686fa55b0deb
child 36135
b46d29bc9b35
child 36692
324db2a53c4c
permissions
-rw-r--r--

Initial replacements for gtk-doc style comments

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"
34557
295cd5bf4c41 Refactored protocols msn, myspace, oscar, simple, yahoo to use GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 34175
diff changeset
41 #include "core.h"
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
42
34567
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34557
diff changeset
43 #include "ciphers/hmaccipher.h"
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34557
diff changeset
44 #include "ciphers/sha256hash.h"
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
45
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
46 #define AIM_LOGIN_HOST "api.screenname.aol.com"
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
47 #define ICQ_LOGIN_HOST "api.login.icq.net"
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
48
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
49 #define AIM_API_HOST "api.oscar.aol.com"
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
50 #define ICQ_API_HOST "api.icq.net"
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
51
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
52 #define CLIENT_LOGIN_PAGE "/auth/clientLogin"
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
53 #define START_OSCAR_SESSION_PAGE "/aim/startOSCARSession"
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
54
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
55 #define HTTPS_FORMAT_URL(host, page) "https://" host page
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
56
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
57 static const gchar *client_login_urls[] = {
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
58 HTTPS_FORMAT_URL(AIM_LOGIN_HOST, CLIENT_LOGIN_PAGE),
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
59 HTTPS_FORMAT_URL(ICQ_LOGIN_HOST, CLIENT_LOGIN_PAGE),
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
60 };
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
61
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
62 static const gchar *start_oscar_session_urls[] = {
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
63 HTTPS_FORMAT_URL(AIM_API_HOST, START_OSCAR_SESSION_PAGE),
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
64 HTTPS_FORMAT_URL(ICQ_API_HOST, START_OSCAR_SESSION_PAGE),
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
65 };
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
66
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
67 static const gchar *get_client_login_url(OscarData *od)
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
68 {
31088
7b3be28cc5e7 Continuing Daniel's quest for safety in Pidginland (see b01c2771dfe0c2c521afb1699a3a9c509c12567d).
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30888
diff changeset
69 return client_login_urls[od->icq ? 1 : 0];
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
70 }
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
71
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
72 static const gchar *get_start_oscar_session_url(OscarData *od)
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
73 {
31088
7b3be28cc5e7 Continuing Daniel's quest for safety in Pidginland (see b01c2771dfe0c2c521afb1699a3a9c509c12567d).
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30888
diff changeset
74 return start_oscar_session_urls[od->icq ? 1 : 0];
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
75 }
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
76
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
77 /*
27684
f85539a9fc3a Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents: 27635
diff changeset
78 * 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
79 * 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
80 * 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
81 * 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
82 *
f85539a9fc3a Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents: 27635
diff changeset
83 * 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
84 */
27684
f85539a9fc3a Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents: 27635
diff changeset
85 #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
86
f85539a9fc3a Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents: 27635
diff changeset
87 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
88 {
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
89 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
90 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
91 DEFAULT_CLIENT_KEY);
27684
f85539a9fc3a Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents: 27635
diff changeset
92 }
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
93
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
94 static gchar *generate_error_message(PurpleXmlNode *resp, const char *url)
29233
a686b1d2f50f oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29106
diff changeset
95 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
96 PurpleXmlNode *text;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
97 PurpleXmlNode *status_code_node;
31099
fd0610d6661c The end user is not going to be amused when he sees a "<URL>: Ok" connection
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31088
diff changeset
98 gchar *status_code;
fd0610d6661c The end user is not going to be amused when he sees a "<URL>: Ok" connection
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31088
diff changeset
99 gboolean have_error_code = TRUE;
29233
a686b1d2f50f oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29106
diff changeset
100 gchar *err = NULL;
a686b1d2f50f oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29106
diff changeset
101 gchar *details = NULL;
a686b1d2f50f oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29106
diff changeset
102
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
103 status_code_node = purple_xmlnode_get_child(resp, "statusCode");
31099
fd0610d6661c The end user is not going to be amused when he sees a "<URL>: Ok" connection
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31088
diff changeset
104 if (status_code_node) {
fd0610d6661c The end user is not going to be amused when he sees a "<URL>: Ok" connection
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31088
diff changeset
105 /* We can get 200 OK here if the server omitted something we think it shouldn't have (see #12783).
fd0610d6661c The end user is not going to be amused when he sees a "<URL>: Ok" connection
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31088
diff changeset
106 * No point in showing the "Ok" string to the user.
fd0610d6661c The end user is not going to be amused when he sees a "<URL>: Ok" connection
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31088
diff changeset
107 */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
108 if ((status_code = purple_xmlnode_get_data_unescaped(status_code_node)) && strcmp(status_code, "200") == 0) {
31099
fd0610d6661c The end user is not going to be amused when he sees a "<URL>: Ok" connection
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31088
diff changeset
109 have_error_code = FALSE;
fd0610d6661c The end user is not going to be amused when he sees a "<URL>: Ok" connection
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31088
diff changeset
110 }
fd0610d6661c The end user is not going to be amused when he sees a "<URL>: Ok" connection
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31088
diff changeset
111 }
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
112 if (have_error_code && resp && (text = purple_xmlnode_get_child(resp, "statusText"))) {
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
113 details = purple_xmlnode_get_data(text);
29233
a686b1d2f50f oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29106
diff changeset
114 }
a686b1d2f50f oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29106
diff changeset
115
a686b1d2f50f oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29106
diff changeset
116 if (details && *details) {
a686b1d2f50f oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29106
diff changeset
117 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
118 } else {
a686b1d2f50f oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29106
diff changeset
119 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
120 }
a686b1d2f50f oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29106
diff changeset
121
a686b1d2f50f oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29106
diff changeset
122 g_free(details);
a686b1d2f50f oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29106
diff changeset
123 return err;
a686b1d2f50f oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29106
diff changeset
124 }
a686b1d2f50f oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29106
diff changeset
125
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
126 /**
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
127 * @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
128 * 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
129 */
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
130 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
131 {
34567
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34557
diff changeset
132 PurpleCipher *cipher;
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34557
diff changeset
133 PurpleHash *hash;
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
134 guchar digest[32];
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
135
34567
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34557
diff changeset
136 hash = purple_sha256_hash_new();
34557
295cd5bf4c41 Refactored protocols msn, myspace, oscar, simple, yahoo to use GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 34175
diff changeset
137 cipher = purple_hmac_cipher_new(hash);
295cd5bf4c41 Refactored protocols msn, myspace, oscar, simple, yahoo to use GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 34175
diff changeset
138 purple_cipher_set_key(cipher, (guchar *)key, strlen(key));
295cd5bf4c41 Refactored protocols msn, myspace, oscar, simple, yahoo to use GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 34175
diff changeset
139 purple_cipher_append(cipher, (guchar *)message, strlen(message));
295cd5bf4c41 Refactored protocols msn, myspace, oscar, simple, yahoo to use GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 34175
diff changeset
140 purple_cipher_digest(cipher, digest, sizeof(digest));
295cd5bf4c41 Refactored protocols msn, myspace, oscar, simple, yahoo to use GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 34175
diff changeset
141 g_object_unref(cipher);
295cd5bf4c41 Refactored protocols msn, myspace, oscar, simple, yahoo to use GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 34175
diff changeset
142 g_object_unref(hash);
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
143
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
144 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
145 }
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
146
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
147 /**
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
148 * @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
149 * technique documented at
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
150 * 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
151 */
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
152 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
153 {
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
154 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
155 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
156
28538
fb879aa298ee Change purple_url_encode() to not encode . _ - ~ because it's not
Mark Doliner <markdoliner@pidgin.im>
parents: 28274
diff changeset
157 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
158 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
159 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
160 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
161 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
162
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
163 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
164 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
165
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
166 return signature;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
167 }
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
168
28824
e23d22216f58 oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents: 28538
diff changeset
169 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
170 {
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
171 OscarData *od = purple_connection_get_protocol_data(gc);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
172 PurpleXmlNode *response_node, *tmp_node, *data_node;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
173 PurpleXmlNode *host_node = NULL, *port_node = NULL, *cookie_node = NULL, *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
174 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
175 guint code;
31100
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
176 const gchar *encryption_type = purple_account_get_string(purple_connection_get_account(gc), "encryption", OSCAR_DEFAULT_ENCRYPTION);
28824
e23d22216f58 oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents: 28538
diff changeset
177
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
178 /* Parse the response as XML */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
179 response_node = purple_xmlnode_from_str(response, response_len);
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
180 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
181 {
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
182 char *msg;
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
183 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
184 "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
185 /* 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
186 msg = generate_error_message(response_node,
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
187 get_start_oscar_session_url(od));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
188 purple_connection_error(gc,
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
189 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
190 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
191 return FALSE;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
192 }
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
193
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
194 /* Grab the necessary XML nodes */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
195 tmp_node = purple_xmlnode_get_child(response_node, "statusCode");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
196 data_node = purple_xmlnode_get_child(response_node, "data");
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
197 if (data_node != NULL) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
198 host_node = purple_xmlnode_get_child(data_node, "host");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
199 port_node = purple_xmlnode_get_child(data_node, "port");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
200 cookie_node = purple_xmlnode_get_child(data_node, "cookie");
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
201 }
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 /* Make sure we have a status code */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
204 if (tmp_node == NULL || (tmp = purple_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
205 char *msg;
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
206 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
207 "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
208 msg = generate_error_message(response_node,
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
209 get_start_oscar_session_url(od));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
210 purple_connection_error(gc,
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
211 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
212 g_free(msg);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
213 purple_xmlnode_free(response_node);
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
214 return FALSE;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
215 }
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
216
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
217 /* 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
218 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
219 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
220 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
221 PurpleXmlNode *status_detail_node;
29737
0adc09e12a5a 401/1014 is a bad signature (it's what I've been getting while testing startOSCARSession over https).
Paul Aurich <darkrain42@pidgin.im>
parents: 29734
diff changeset
222 guint status_detail = 0;
0adc09e12a5a 401/1014 is a bad signature (it's what I've been getting while testing startOSCARSession over https).
Paul Aurich <darkrain42@pidgin.im>
parents: 29734
diff changeset
223
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
224 status_detail_node = purple_xmlnode_get_child(response_node,
29737
0adc09e12a5a 401/1014 is a bad signature (it's what I've been getting while testing startOSCARSession over https).
Paul Aurich <darkrain42@pidgin.im>
parents: 29734
diff changeset
225 "statusDetailCode");
0adc09e12a5a 401/1014 is a bad signature (it's what I've been getting while testing startOSCARSession over https).
Paul Aurich <darkrain42@pidgin.im>
parents: 29734
diff changeset
226 if (status_detail_node) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
227 gchar *data = purple_xmlnode_get_data(status_detail_node);
29737
0adc09e12a5a 401/1014 is a bad signature (it's what I've been getting while testing startOSCARSession over https).
Paul Aurich <darkrain42@pidgin.im>
parents: 29734
diff changeset
228 if (data) {
0adc09e12a5a 401/1014 is a bad signature (it's what I've been getting while testing startOSCARSession over https).
Paul Aurich <darkrain42@pidgin.im>
parents: 29734
diff changeset
229 status_detail = atoi(data);
0adc09e12a5a 401/1014 is a bad signature (it's what I've been getting while testing startOSCARSession over https).
Paul Aurich <darkrain42@pidgin.im>
parents: 29734
diff changeset
230 g_free(data);
0adc09e12a5a 401/1014 is a bad signature (it's what I've been getting while testing startOSCARSession over https).
Paul Aurich <darkrain42@pidgin.im>
parents: 29734
diff changeset
231 }
0adc09e12a5a 401/1014 is a bad signature (it's what I've been getting while testing startOSCARSession over https).
Paul Aurich <darkrain42@pidgin.im>
parents: 29734
diff changeset
232 }
0adc09e12a5a 401/1014 is a bad signature (it's what I've been getting while testing startOSCARSession over https).
Paul Aurich <darkrain42@pidgin.im>
parents: 29734
diff changeset
233
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 statusCode "
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
235 "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
236
29737
0adc09e12a5a 401/1014 is a bad signature (it's what I've been getting while testing startOSCARSession over https).
Paul Aurich <darkrain42@pidgin.im>
parents: 29734
diff changeset
237 if ((code == 401 && status_detail != 1014) || code == 607)
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
238 purple_connection_error(gc,
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
239 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
240 _("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
241 "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
242 "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
243 "longer."));
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
244 else {
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
245 char *msg;
29233
a686b1d2f50f oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29106
diff changeset
246 msg = generate_error_message(response_node,
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
247 get_start_oscar_session_url(od));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
248 purple_connection_error(gc,
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
249 PURPLE_CONNECTION_ERROR_OTHER_ERROR, msg);
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
250 g_free(msg);
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
251 }
27385
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 g_free(tmp);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
254 purple_xmlnode_free(response_node);
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
255 return FALSE;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
256 }
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
257 g_free(tmp);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
258
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
259 /* Make sure we have everything else */
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
260 if (data_node == NULL || host_node == NULL || port_node == NULL || cookie_node == NULL)
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
261 {
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
262 char *msg;
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
263 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
264 "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
265 msg = generate_error_message(response_node,
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
266 get_start_oscar_session_url(od));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
267 purple_connection_error(gc,
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
268 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
269 g_free(msg);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
270 purple_xmlnode_free(response_node);
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
271 return FALSE;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
272 }
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
273
31100
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
274 if (strcmp(encryption_type, OSCAR_NO_ENCRYPTION) != 0) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
275 tls_node = purple_xmlnode_get_child(data_node, "tlsCertName");
31100
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
276 if (tls_node != NULL) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
277 *tls_certname = purple_xmlnode_get_data_unescaped(tls_node);
31100
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
278 } else {
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
279 if (strcmp(encryption_type, OSCAR_OPPORTUNISTIC_ENCRYPTION) == 0) {
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
280 purple_debug_warning("oscar", "We haven't received a tlsCertName to use. We will not do SSL to BOS.\n");
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
281 } else {
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
282 purple_debug_error("oscar", "startOSCARSession was missing tlsCertName: %s\n", response);
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
283 purple_connection_error(
31100
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
284 gc,
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
285 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
286 _("You required encryption in your account settings, but one of the servers doesn't support it."));
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
287 purple_xmlnode_free(response_node);
31100
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
288 return FALSE;
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
289 }
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
290 }
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
291 }
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
292
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
293 /* Extract data from the XML */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
294 *host = purple_xmlnode_get_data_unescaped(host_node);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
295 tmp = purple_xmlnode_get_data_unescaped(port_node);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
296 *cookie = purple_xmlnode_get_data_unescaped(cookie_node);
28824
e23d22216f58 oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents: 28538
diff changeset
297
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
298 if (*host == NULL || **host == '\0' || tmp == NULL || *tmp == '\0' || *cookie == NULL || **cookie == '\0')
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
299 {
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
300 char *msg;
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
301 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
302 "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
303 msg = generate_error_message(response_node,
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
304 get_start_oscar_session_url(od));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
305 purple_connection_error(gc,
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
306 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
307 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
308 g_free(*host);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
309 g_free(tmp);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
310 g_free(*cookie);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
311 purple_xmlnode_free(response_node);
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
312 return FALSE;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
313 }
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
314
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
315 *port = atoi(tmp);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
316 g_free(tmp);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
317
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
318 return TRUE;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
319 }
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
320
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
321 static void
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
322 start_oscar_session_cb(PurpleHttpConnection *http_conn,
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
323 PurpleHttpResponse *response, gpointer _od)
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
324 {
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
325 OscarData *od = _od;
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
326 PurpleConnection *gc;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
327 char *host, *cookie;
28824
e23d22216f58 oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents: 28538
diff changeset
328 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
329 unsigned short port;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
330 guint8 *cookiedata;
30857
1a7e2da2ab01 Fix for CVE-2010-3711. Properly validate the return value from
Daniel Atallah <datallah@pidgin.im>
parents: 30004
diff changeset
331 gsize cookiedata_len = 0;
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
332 const gchar *got_data;
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
333 size_t got_len;
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
334
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
335 gc = od->gc;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
336
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
337 od->hc = NULL;
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
338
34287
6cd0c77b1f6a HTTP: successful is spelled with one l
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34237
diff changeset
339 if (!purple_http_response_is_successful(response)) {
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
340 gchar *tmp;
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
341 /* 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
342 error message. */
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
343 tmp = g_strdup_printf(_("Error requesting %s: %s"),
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
344 get_start_oscar_session_url(od),
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
345 purple_http_response_get_error(response));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
346 purple_connection_error(gc,
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
347 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
348 g_free(tmp);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
349 return;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
350 }
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
351
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
352 got_data = purple_http_response_get_data(response, &got_len);
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
353 if (!parse_start_oscar_session_response(gc, got_data, got_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
354 return;
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 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
357 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
358 g_free(cookiedata);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
359
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
360 g_free(host);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
361 g_free(cookie);
28824
e23d22216f58 oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents: 28538
diff changeset
362 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
363 }
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
364
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
365 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
366 {
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
367 char *query_string, *signature;
31100
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
368 PurpleAccount *account = purple_connection_get_account(od->gc);
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
369 const gchar *encryption_type = purple_account_get_string(account, "encryption", OSCAR_DEFAULT_ENCRYPTION);
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
370
29071
a1e2c4649516 This magic number is documented in oscar.h, but it makes sense to
Mark Doliner <markdoliner@pidgin.im>
parents: 29070
diff changeset
371 /*
a1e2c4649516 This magic number is documented in oscar.h, but it makes sense to
Mark Doliner <markdoliner@pidgin.im>
parents: 29070
diff changeset
372 * 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
373 * 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
374 */
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
375 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
376 "&distId=%d"
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
377 "&f=xml"
27684
f85539a9fc3a Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents: 27635
diff changeset
378 "&k=%s"
27705
06cdb9c6366f Fix this compiler warning:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 27686
diff changeset
379 "&ts=%" PURPLE_TIME_T_MODIFIER
28824
e23d22216f58 oscar: Properly support TLS when using clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents: 28538
diff changeset
380 "&useTLS=%d",
29070
a255a2bc015b Send our distid when calling startOSCARSession, as request by AOL
Mark Doliner <markdoliner@pidgin.im>
parents: 28837
diff changeset
381 purple_url_encode(token),
31100
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
382 oscar_get_ui_info_int(od->icq ? "prpl-icq-distid" : "prpl-aim-distid", 0x00000611),
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
383 get_client_key(od),
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
384 hosttime,
c31129fd32ad A followup commit to 5d0b140eab3e0acd0515c6ac215ed5accd68e3f8.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 31099
diff changeset
385 strcmp(encryption_type, OSCAR_NO_ENCRYPTION) != 0 ? 1 : 0);
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
386 signature = generate_signature("GET", get_start_oscar_session_url(od),
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
387 query_string, session_key);
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
388
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
389 od->hc = purple_http_get_printf(od->gc, start_oscar_session_cb, od,
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
390 "%s?%s&sig_sha256=%s", get_start_oscar_session_url(od),
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
391 query_string, signature);
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
392
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
393 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
394 g_free(signature);
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
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
397 /**
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
398 * 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
399 * 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
400 *
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
401 * @param gc The PurpleConnection. If the response data does
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
402 * not indicate then purple_connection_error()
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
403 * 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
404 * @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
405 * @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
406 * @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
407 * @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
408 * 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
409 * 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
410 * 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
411 * @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
412 * 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
413 * 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
414 * 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
415 * @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
416 * 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
417 * 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
418 *
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
419 * @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
420 * 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
421 */
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
422 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
423 {
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
424 OscarData *od = purple_connection_get_protocol_data(gc);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
425 PurpleXmlNode *response_node, *tmp_node, *data_node;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
426 PurpleXmlNode *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
427 char *tmp;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
428
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
429 /* Parse the response as XML */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
430 response_node = purple_xmlnode_from_str(response, response_len);
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
431 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
432 {
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
433 char *msg;
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
434 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
435 "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
436 msg = generate_error_message(response_node,
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
437 get_client_login_url(od));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
438 purple_connection_error(gc,
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
439 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
440 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
441 return FALSE;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
442 }
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
443
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
444 /* Grab the necessary XML nodes */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
445 tmp_node = purple_xmlnode_get_child(response_node, "statusCode");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
446 data_node = purple_xmlnode_get_child(response_node, "data");
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
447 if (data_node != NULL) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
448 secret_node = purple_xmlnode_get_child(data_node, "sessionSecret");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
449 hosttime_node = purple_xmlnode_get_child(data_node, "hostTime");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
450 token_node = purple_xmlnode_get_child(data_node, "token");
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
451 if (token_node != NULL)
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
452 tokena_node = purple_xmlnode_get_child(token_node, "a");
27385
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 /* Make sure we have a status code */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
456 if (tmp_node == NULL || (tmp = purple_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
457 char *msg;
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
458 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
459 "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
460 msg = generate_error_message(response_node,
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
461 get_client_login_url(od));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
462 purple_connection_error(gc,
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
463 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
464 g_free(msg);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
465 purple_xmlnode_free(response_node);
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
466 return FALSE;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
467 }
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
468
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
469 /* 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
470 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
471 {
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
472 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
473
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
474 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
475 g_free(tmp);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
476 tmp_node = purple_xmlnode_get_child(response_node, "statusDetailCode");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
477 if (tmp_node != NULL && (tmp = purple_xmlnode_get_data_unescaped(tmp_node)) != NULL) {
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
478 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
479 g_free(tmp);
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
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
482 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
483 "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
484
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
485 if (status_code == 330 && status_detail_code == 3011) {
30004
7de569e20a6b oscar: Forget un-remembered passwords on Incorrect Password w/ clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents: 29983
diff changeset
486 PurpleAccount *account = purple_connection_get_account(gc);
7de569e20a6b oscar: Forget un-remembered passwords on Incorrect Password w/ clientLogin.
Paul Aurich <darkrain42@pidgin.im>
parents: 29983
diff changeset
487 if (!purple_account_get_remember_password(account))
34029
059c1270db1f Remove the silly destroy argument from purple_account_set_password and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34028
diff changeset
488 purple_account_set_password(account, NULL, NULL, NULL);
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
489 purple_connection_error(gc,
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
490 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED,
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27442
diff changeset
491 _("Incorrect password"));
29317
d46d080a42cc Add back Paul's error message from revision 315ffdf6a4550e47b2bc6e5a29af0e47e107abc6
Mark Doliner <markdoliner@pidgin.im>
parents: 29233
diff changeset
492 } else if (status_code == 330 && status_detail_code == 3015) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
493 purple_connection_error(gc,
29317
d46d080a42cc Add back Paul's error message from revision 315ffdf6a4550e47b2bc6e5a29af0e47e107abc6
Mark Doliner <markdoliner@pidgin.im>
parents: 29233
diff changeset
494 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED,
d46d080a42cc Add back Paul's error message from revision 315ffdf6a4550e47b2bc6e5a29af0e47e107abc6
Mark Doliner <markdoliner@pidgin.im>
parents: 29233
diff changeset
495 _("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
496 "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
497 } else if (status_code == 401 && status_detail_code == 3019) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
498 purple_connection_error(gc,
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
499 PURPLE_CONNECTION_ERROR_OTHER_ERROR,
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27442
diff changeset
500 _("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
501 } else {
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
502 char *msg;
29233
a686b1d2f50f oscar: Try to make the error message more verbose.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29106
diff changeset
503 msg = generate_error_message(response_node,
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
504 get_client_login_url(od));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
505 purple_connection_error(gc,
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
506 PURPLE_CONNECTION_ERROR_OTHER_ERROR, msg);
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
507 g_free(msg);
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
508 }
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
509
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
510 purple_xmlnode_free(response_node);
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
511 return FALSE;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
512 }
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
513 g_free(tmp);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
514
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
515 /* 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
516 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
517 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
518 {
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
519 char *msg;
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
520 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
521 "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
522 msg = generate_error_message(response_node,
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
523 get_client_login_url(od));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
524 purple_connection_error(gc,
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
525 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
526 g_free(msg);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
527 purple_xmlnode_free(response_node);
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
528 return FALSE;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
529 }
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 /* Extract data from the XML */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
532 *token = purple_xmlnode_get_data_unescaped(tokena_node);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
533 *secret = purple_xmlnode_get_data_unescaped(secret_node);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
534 tmp = purple_xmlnode_get_data_unescaped(hosttime_node);
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
535 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
536 {
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
537 char *msg;
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
538 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
539 "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
540 msg = generate_error_message(response_node,
30888
21a931e7747e Merged everything related to ICQ server changes.
Ivan Komarov <ivan.komarov@pidgin.im>
parents: 30857
diff changeset
541 get_client_login_url(od));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
542 purple_connection_error(gc,
28274
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
543 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
4eca816a16a2 Make the strings in this file more localizable
Mark Doliner <markdoliner@pidgin.im>
parents: 27705
diff changeset
544 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
545 g_free(*token);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
546 g_free(*secret);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
547 g_free(tmp);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
548 purple_xmlnode_free(response_node);
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
549 return FALSE;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
550 }
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 *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
553 g_free(tmp);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
554
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
555 purple_xmlnode_free(response_node);
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
556
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
557 return TRUE;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
558 }
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
559
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
560 static void
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
561 client_login_cb(PurpleHttpConnection *http_conn,
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
562 PurpleHttpResponse *response, gpointer _od)
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
563 {
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
564 OscarData *od = _od;
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
565 PurpleConnection *gc;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
566 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
567 time_t hosttime;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
568 int password_len;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
569 char *password;
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
570 const gchar *got_data;
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
571 size_t got_len;
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
572
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
573 gc = od->gc;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
574
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
575 od->hc = NULL;
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
576
34287
6cd0c77b1f6a HTTP: successful is spelled with one l
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34237
diff changeset
577 if (!purple_http_response_is_successful(response)) {
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
578 gchar *tmp;
31154
d285b9000fbe Apply Mark's specific changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31100
diff changeset
579 tmp = g_strdup_printf(_("Error requesting %s: %s"),
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
580 get_client_login_url(od),
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
581 purple_http_response_get_error(response));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32147
diff changeset
582 purple_connection_error(gc,
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
583 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
584 g_free(tmp);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
585 return;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
586 }
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
587
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
588 got_data = purple_http_response_get_data(response, &got_len);
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
589 if (!parse_client_login_response(gc, got_data, got_len, &token, &secret,
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
590 &hosttime))
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
591 {
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
592 return;
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
593 }
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
594
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
595 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
596 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
597 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
598 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
599 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
600 g_free(password);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
601 g_free(secret);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
602
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
603 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
604
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
605 g_free(token);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
606 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
607 }
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
608
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
609 /**
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
610 * 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
611 * 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
612 * 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
613 * 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
614 */
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
615 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
616 {
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
617 PurpleConnection *gc;
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
618 PurpleHttpRequest *req;
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
619 GString *body;
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
620 const char *tmp;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
621 char *password;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
622 int password_len;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
623
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
624 gc = od->gc;
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
625
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
626 /*
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
627 * 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
628 * 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
629 * 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
630 * 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
631 *
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
632 * 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
633 * 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
634 * 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
635 * the case, though).
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
636 */
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
637 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
638 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
639 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
640
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
641 /* 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
642 body = g_string_new("");
27684
f85539a9fc3a Allow UIs to specify their own AOL client key
Mark Doliner <markdoliner@pidgin.im>
parents: 27635
diff changeset
643 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
644 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
645 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
646 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
647 g_free(password);
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
648
34237
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
649 req = purple_http_request_new(get_client_login_url(od));
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
650 purple_http_request_set_method(req, "POST");
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
651 purple_http_request_header_set(req, "Content-Type",
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
652 "application/x-www-form-urlencoded; charset=UTF-8");
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
653 purple_http_request_set_contents(req, body->str, body->len);
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
654 od->hc = purple_http_request(gc, req, client_login_cb, od);
fc7e934ad8b3 HTTP: migrate purple_util_fetch_url_request to new API for oscar prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34175
diff changeset
655 purple_http_request_unref(req);
27385
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
656
cd0d721fec8f Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
657 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
658 }

mercurial