annotate src/protocols/msn/nexus.c @ 12767:53218d758ba9

[gaim-migrate @ 15114] Make the dns lookup for udp connecting asynchronous. Thomas pointed out that it should be instantaneous anyway because the SRV lookup that has just been done, but this'll avoid blocking if the SRV lookup failed or something. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Sun, 08 Jan 2006 22:09:28 +0000
parents e585695bc16b
children 33bef17125c2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
1 /**
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
2 * @file nexus.c MSN Nexus functions
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
3 *
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
4 * gaim
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
5 *
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
6 * Gaim is the legal property of its developers, whose names are too numerous
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
8 * source distribution.
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
9 *
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
10 * This program is free software; you can redistribute it and/or modify
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
11 * it under the terms of the GNU General Public License as published by
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
13 * (at your option) any later version.
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
14 *
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
15 * This program is distributed in the hope that it will be useful,
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
18 * GNU General Public License for more details.
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
19 *
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
20 * You should have received a copy of the GNU General Public License
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
21 * along with this program; if not, write to the Free Software
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
23 */
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 #include "msn.h"
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #include "nexus.h"
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 #include "notification.h"
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 /**************************************************************************
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
29 * Main
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
30 **************************************************************************/
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
31
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
32 MsnNexus *
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
33 msn_nexus_new(MsnSession *session)
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
34 {
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
35 MsnNexus *nexus;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
36
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
37 nexus = g_new0(MsnNexus, 1);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
38 nexus->session = session;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
39 nexus->challenge_data = g_hash_table_new_full(g_str_hash, g_str_equal,
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
40 g_free, g_free);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
41
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
42 return nexus;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
43 }
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
44
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
45 void
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
46 msn_nexus_destroy(MsnNexus *nexus)
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
47 {
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
48 if (nexus->login_host != NULL)
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
49 g_free(nexus->login_host);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
50
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
51 if (nexus->login_path != NULL)
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
52 g_free(nexus->login_path);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
53
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
54 if (nexus->challenge_data != NULL)
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
55 g_hash_table_destroy(nexus->challenge_data);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
56
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
57 g_free(nexus);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
58 }
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
59
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
60 /**************************************************************************
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 * Util
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 **************************************************************************/
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 static size_t
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 msn_ssl_read(GaimSslConnection *gsc, char **dest_buffer)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 {
8925
577c76e1442d [gaim-migrate @ 9695]
Luke Schierer <lschiere@pidgin.im>
parents: 8808
diff changeset
67 gssize size = 0, s;
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 char *buffer = NULL;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 char temp_buf[4096];
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 while ((s = gaim_ssl_read(gsc, temp_buf, sizeof(temp_buf))) > 0)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 {
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 buffer = g_realloc(buffer, size + s + 1);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 strncpy(buffer + size, temp_buf, s);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 buffer[size + s] = '\0';
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 size += s;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 *dest_buffer = buffer;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 return size;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 /**************************************************************************
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 * Login
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 **************************************************************************/
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 static void
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 login_error_cb(GaimSslConnection *gsc, GaimSslErrorType error, void *data)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 {
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 MsnNexus *nexus;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 MsnSession *session;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 nexus = data;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 g_return_if_fail(nexus != NULL);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 session = nexus->session;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 g_return_if_fail(session != NULL);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
103 msn_session_set_error(session, MSN_ERROR_AUTH, _("Unable to connect"));
10568
fed2a7c2471d [gaim-migrate @ 11954]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10519
diff changeset
104 /* the above line will result in nexus being destroyed, so we don't want
fed2a7c2471d [gaim-migrate @ 11954]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10519
diff changeset
105 * to destroy it here, or we'd crash */
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 static void
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 login_connect_cb(gpointer data, GaimSslConnection *gsc,
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 GaimInputCondition cond)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 {
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 MsnNexus *nexus;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 MsnSession *session;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 char *username, *password;
12457
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
115 char *request_str, *head, *tail;
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 char *buffer = NULL;
9966
b15c177895b9 [gaim-migrate @ 10875]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
117 guint32 ctint;
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 size_t s;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 nexus = data;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 g_return_if_fail(nexus != NULL);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 session = nexus->session;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 g_return_if_fail(session != NULL);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125
10519
bec9130b24d2 [gaim-migrate @ 11833]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
126 msn_session_set_login_step(session, MSN_LOGIN_STEP_GET_COOKIE);
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
127
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 username =
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 g_strdup(gaim_url_encode(gaim_account_get_username(session->account)));
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 password =
10740
94cc67130789 [gaim-migrate @ 12342]
Mark Doliner <mark@kingant.net>
parents: 10568
diff changeset
132 g_strdup(gaim_url_encode(gaim_connection_get_password(session->account->gc)));
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133
9966
b15c177895b9 [gaim-migrate @ 10875]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
134 ctint = strtoul((char *)g_hash_table_lookup(nexus->challenge_data, "ct"), NULL, 10) + 200;
b15c177895b9 [gaim-migrate @ 10875]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
135
12457
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
136 head = g_strdup_printf(
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 "GET %s HTTP/1.1\r\n"
12457
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
138 "Authorization: Passport1.4 OrgVerb=GET,OrgURL=%s,sign-in=%s",
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
139 nexus->login_path,
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
140 (char *)g_hash_table_lookup(nexus->challenge_data, "ru"),
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
141 username);
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
142
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
143 tail = g_strdup_printf(
9966
b15c177895b9 [gaim-migrate @ 10875]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
144 "lc=%s,id=%s,tw=%s,fs=%s,ru=%s,ct=%" G_GUINT32_FORMAT ",kpp=%s,kv=%s,ver=%s,tpf=%s\r\n"
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 "User-Agent: MSMSGS\r\n"
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 "Host: %s\r\n"
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 "Connection: Keep-Alive\r\n"
12457
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
148 "Cache-Control: no-cache\r\n",
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 (char *)g_hash_table_lookup(nexus->challenge_data, "lc"),
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 (char *)g_hash_table_lookup(nexus->challenge_data, "id"),
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 (char *)g_hash_table_lookup(nexus->challenge_data, "tw"),
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 (char *)g_hash_table_lookup(nexus->challenge_data, "fs"),
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 (char *)g_hash_table_lookup(nexus->challenge_data, "ru"),
9966
b15c177895b9 [gaim-migrate @ 10875]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
154 ctint,
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155 (char *)g_hash_table_lookup(nexus->challenge_data, "kpp"),
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 (char *)g_hash_table_lookup(nexus->challenge_data, "kv"),
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 (char *)g_hash_table_lookup(nexus->challenge_data, "ver"),
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 (char *)g_hash_table_lookup(nexus->challenge_data, "tpf"),
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 nexus->login_host);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160
12457
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
161 buffer = g_strdup_printf("%s,pwd=XXXXXXXX,%s\r\n", head, tail);
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
162 request_str = g_strdup_printf("%s,pwd=%s,%s\r\n", head, password, tail);
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163
12457
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
164 gaim_debug_misc("msn", "Sending: {%s}\n", buffer);
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
165
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
166 g_free(buffer);
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
167 g_free(head);
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
168 g_free(tail);
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 g_free(username);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 g_free(password);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 if ((s = gaim_ssl_write(gsc, request_str, strlen(request_str))) <= 0)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173 {
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 g_free(request_str);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176 return;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 g_free(request_str);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 if ((s = msn_ssl_read(gsc, &buffer)) <= 0)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 return;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 gaim_ssl_close(gsc);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185
10345
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9966
diff changeset
186 gaim_debug_misc("msn", "ssl buffer: {%s}", buffer);
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 if (strstr(buffer, "HTTP/1.1 302") != NULL)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 {
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 /* Redirect. */
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 char *location, *c;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 location = strstr(buffer, "Location: ");
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 if (location == NULL)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 {
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 g_free(buffer);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 return;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200 location = strchr(location, ' ') + 1;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 if ((c = strchr(location, '\r')) != NULL)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 *c = '\0';
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 /* Skip the http:// */
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 if ((c = strchr(location, '/')) != NULL)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 location = c + 2;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 if ((c = strchr(location, '/')) != NULL)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210 {
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 g_free(nexus->login_path);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 nexus->login_path = g_strdup(c);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 *c = '\0';
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 g_free(nexus->login_host);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 nexus->login_host = g_strdup(location);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 gaim_ssl_connect(session->account, nexus->login_host,
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 GAIM_SSL_DEFAULT_PORT, login_connect_cb,
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 login_error_cb, nexus);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 else if (strstr(buffer, "HTTP/1.1 401 Unauthorized") != NULL)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 {
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
226 const char *error;
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 if ((error = strstr(buffer, "WWW-Authenticate")) != NULL)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 {
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 if ((error = strstr(error, "cbtxt=")) != NULL)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 {
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
232 const char *c;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
233 char *temp;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
234
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 error += strlen("cbtxt=");
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237 if ((c = strchr(error, '\n')) == NULL)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 c = error + strlen(error);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 temp = g_strndup(error, c - error);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241 error = gaim_url_decode(temp);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242 g_free(temp);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
246 msn_session_set_error(session, MSN_ERROR_AUTH, error);
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248 else if (strstr(buffer, "HTTP/1.1 200 OK"))
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 {
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 char *base, *c;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 char *login_params;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253 #if 0
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254 /* All your base are belong to us. */
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255 base = buffer;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257 /* For great cookie! */
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 while ((base = strstr(base, "Set-Cookie: ")) != NULL)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259 {
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260 base += strlen("Set-Cookie: ");
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262 c = strchr(base, ';');
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 session->login_cookies =
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265 g_list_append(session->login_cookies,
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266 g_strndup(base, c - base));
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
268 #endif
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270 base = strstr(buffer, "Authentication-Info: ");
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8925
diff changeset
272 g_return_if_fail(base != NULL);
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274 base = strstr(base, "from-PP='");
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 base += strlen("from-PP='");
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276 c = strchr(base, '\'');
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278 login_params = g_strndup(base, c - base);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8925
diff changeset
280 msn_got_login_params(session, login_params);
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282 g_free(login_params);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
283
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284 msn_nexus_destroy(nexus);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
285 session->nexus = NULL;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288 g_free(buffer);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
289 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
290
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
291 /**************************************************************************
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
292 * Connect
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
293 **************************************************************************/
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
294
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 static void
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
296 nexus_connect_cb(gpointer data, GaimSslConnection *gsc,
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297 GaimInputCondition cond)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
298 {
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299 MsnNexus *nexus;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300 MsnSession *session;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
301 char *request_str;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
302 char *da_login;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
303 char *base, *c;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304 char *buffer = NULL;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305 size_t s;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307 nexus = data;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
308 g_return_if_fail(nexus != NULL);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
309
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310 session = nexus->session;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
311 g_return_if_fail(session != NULL);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
312
10519
bec9130b24d2 [gaim-migrate @ 11833]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
313 msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH);
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
314
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
315 request_str = g_strdup_printf("GET /rdr/pprdr.asp\r\n\r\n");
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
316
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
317 if ((s = gaim_ssl_write(gsc, request_str, strlen(request_str))) <= 0)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318 {
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319 g_free(request_str);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320 return;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
321 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
322
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 g_free(request_str);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325 /* Get the PassportURLs line. */
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
326 if ((s = msn_ssl_read(gsc, &buffer)) <= 0)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
327 return;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
329 base = strstr(buffer, "PassportURLs");
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
330
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
331 if (base == NULL)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 {
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333 g_free(buffer);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
334 return;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
335 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337 if ((da_login = strstr(base, "DALogin=")) != NULL)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
338 {
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
339 if ((da_login = strchr(da_login, '=')) != NULL)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
340 da_login++;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
342 if ((c = strchr(da_login, ',')) != NULL)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
343 *c = '\0';
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
344
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
345 if ((c = strchr(da_login, '/')) != NULL)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346 {
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347 nexus->login_path = g_strdup(c);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
349 *c = '\0';
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
350 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
351
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
352 nexus->login_host = g_strdup(da_login);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
353 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
354
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
355 g_free(buffer);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
356
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
357 gaim_ssl_close(gsc);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
359 /* Now begin the connection to the login server. */
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
360 gaim_ssl_connect(session->account, nexus->login_host,
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
361 GAIM_SSL_DEFAULT_PORT, login_connect_cb,
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362 login_error_cb, nexus);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
363 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365 void
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366 msn_nexus_connect(MsnNexus *nexus)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367 {
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
368 gaim_ssl_connect(nexus->session->account, "nexus.passport.com",
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
369 GAIM_SSL_DEFAULT_PORT, nexus_connect_cb,
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
370 login_error_cb, nexus);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
371 }