annotate libpurple/protocols/oscar/clientlogin.c @ 28547:158d7fc55fda

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