This function sends request to https api screenname aol com auth clien

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* This function sends a request to
* https://api.screenname.aol.com/auth/clientLogin with the user's
* username and password and receives the user's session key, which is
* used to request a connection to the BOSS server.
*/
void send_client_login(OscarData *od, const char *username)
{
PurpleConnection *gc;
GString *request, *body;
const char *tmp;
char *password;
int password_len;
gc = od->gc;
/*
* We truncate ICQ passwords to 8 characters. There is probably a
* limit for AIM passwords, too, but we really only need to do
* this for ICQ because older ICQ clients let you enter a password
* as long as you wanted and then they truncated it silently.
*
* And we can truncate based on the number of bytes and not the
* number of characters because passwords for AIM and ICQ are
* supposed to be plain ASCII (I don't know if this has always been
* the case, though).
*/
tmp = purple_connection_get_password(gc);
password_len = strlen(tmp);
password = g_strndup(tmp, od->icq ? MIN(password_len, MAXICQPASSLEN) : password_len);
/* Construct the body of the HTTP POST request */
body = g_string_new("");
g_string_append_printf(body, "devId=%s", get_client_key(od));
g_string_append_printf(body, "&f=xml");
g_string_append_printf(body, "&pwd=%s", purple_url_encode(password));
g_string_append_printf(body, "&s=%s", purple_url_encode(username));
g_free(password);
/* Construct an HTTP POST request */
request = g_string_new("POST /auth/clientLogin HTTP/1.0\r\n"
"Connection: close\r\n"
"Accept: */*\r\n");
/* Tack on the body */
g_string_append_printf(request, "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n");
g_string_append_printf(request, "Content-Length: %" G_GSIZE_FORMAT "\r\n\r\n", body->len);
g_string_append_len(request, body->str, body->len);
g_string_free(body, TRUE);
/* Send the POST request */
od->url_data = purple_util_fetch_url_request_len_with_account(
purple_connection_get_account(gc), get_client_login_url(od),
TRUE, NULL, FALSE, request->str, FALSE, -1,
client_login_cb, od);
g_string_free(request, TRUE);
}