annotate src/protocols/msn/nexus.c @ 19789:7e36832172a9

[gaim-migrate @ 16601] change Windows Live ID authentication code style to simplify the code. add some comments committed by Ma Yuan<mayuan2006@gmail.com> committer: Ethan Blanton <elb@pidgin.im>
author Ma Yuan <mayuan2006@gmail.com>
date Sun, 30 Jul 2006 15:55:30 +0000
parents 23258253c7a0
children cabf9165c9ce
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"
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
25 #include "soap.h"
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 #include "nexus.h"
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 #include "notification.h"
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
29 /*Local Function Prototype*/
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
30 static void nexus_login_connect_cb(gpointer data, GaimSslConnection *gsc,GaimInputCondition cond);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
31
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 /**************************************************************************
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
33 * Main
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
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
36 MsnNexus *
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
37 msn_nexus_new(MsnSession *session)
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
38 {
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
39 MsnNexus *nexus;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
40
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
41 nexus = g_new0(MsnNexus, 1);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
42 nexus->session = session;
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
43 /*we must use SSL connection to do Windows Live ID authentication*/
19785
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 19784
diff changeset
44 nexus->soapconn = msn_soap_new(session,nexus,1);
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 19784
diff changeset
45
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
46 nexus->challenge_data = g_hash_table_new_full(g_str_hash,
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
47 g_str_equal, g_free, g_free);
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
48
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
49 return nexus;
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
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
52 void
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
53 msn_nexus_destroy(MsnNexus *nexus)
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
54 {
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
55 if (nexus->challenge_data != NULL)
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
56 g_hash_table_destroy(nexus->challenge_data);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
57
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
58 msn_soap_destroy(nexus->soapconn);
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
59 g_free(nexus);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
60 }
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
61
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
62 /**************************************************************************
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 * Login
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 **************************************************************************/
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 static void
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
66 nexus_login_error_cb(GaimSslConnection *gsc, GaimSslErrorType error, void *data)
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 {
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
68 MsnSoapConn * soapconn = data;
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 MsnSession *session;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
71 session = soapconn->session;
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 g_return_if_fail(session != NULL);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
74 msn_session_set_error(session, MSN_ERROR_AUTH, _("Windows Live ID authentication:Unable to connect"));
10568
fed2a7c2471d [gaim-migrate @ 11954]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10519
diff changeset
75 /* 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
76 * to destroy it here, or we'd crash */
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 }
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
79 /*process the SOAP reply, get the Authentication Info*/
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 static void
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
81 nexus_login_read_cb(gpointer data, gint source, GaimInputCondition cond)
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
82 {
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
83 MsnSoapConn * soapconn = data;
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
84 MsnNexus *nexus;
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
85 MsnSession *session;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
86
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
87 char *base, *c;
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
88 char *msn_twn_t,*msn_twn_p;
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
89 char *login_params;
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
90 char **elems, **cur, **tokens;
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
91 char * cert_str;
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
92
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
93 nexus = soapconn->parent;
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
94 g_return_if_fail(nexus != NULL);
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
95 session = nexus->session;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
96 g_return_if_fail(session != NULL);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
97
19786
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
98 // gaim_debug_misc("msn", "TWN Server Reply: {%s}\n", soapconn->read_buf);
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
99
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
100 /*reply OK, we should process the SOAP body*/
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
101 gaim_debug_info("MaYuan","Windows Live ID Reply OK!\n");
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
102
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
103 //TODO: we should parse it using XML
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
104 base = g_strstr_len(soapconn->read_buf, soapconn->read_len, TWN_START_TOKEN);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
105 base += strlen(TWN_START_TOKEN);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
106 c = g_strstr_len(soapconn->read_buf, soapconn->read_len, TWN_END_TOKEN);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
107 login_params = g_strndup(base, c - base);
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
108
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
109 // gaim_debug_info("msn", "TWN Cert: {%s}\n", login_params);
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
110
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
111 /* Parse the challenge data. */
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
112 elems = g_strsplit(login_params, "&amp;", 0);
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
113
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
114 for (cur = elems; *cur != NULL; cur++){
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
115 tokens = g_strsplit(*cur, "=", 2);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
116 g_hash_table_insert(nexus->challenge_data, tokens[0], tokens[1]);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
117 /* Don't free each of the tokens, only the array. */
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
118 g_free(tokens);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
119 }
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
120
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
121 g_strfreev(elems);
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
122
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
123 msn_twn_t = (char *)g_hash_table_lookup(nexus->challenge_data, "t");
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
124 msn_twn_p = (char *)g_hash_table_lookup(nexus->challenge_data, "p");
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
125
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
126 /*setup the t and p parameter for session*/
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
127 if (session->passport_info.t != NULL){
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
128 g_free(session->passport_info.t);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
129 }
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
130 session->passport_info.t = g_strdup(msn_twn_t);
19783
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
131
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
132 if (session->passport_info.p != NULL)
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
133 g_free(session->passport_info.p);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
134 session->passport_info.p = g_strdup(msn_twn_p);
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
135
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
136 cert_str = g_strdup_printf("t=%s&p=%s",msn_twn_t,msn_twn_p);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
137 msn_got_login_params(session, cert_str);
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
138
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
139 gaim_debug_info("MaYuan","close nexus connection! \n");
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
140 g_free(cert_str);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
141 g_free(login_params);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
142 msn_nexus_destroy(nexus);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
143 session->nexus = NULL;
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
144
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
145 return;
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
146 }
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
147
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
148 static void
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
149 nexus_login_written_cb(gpointer data, gint source, GaimInputCondition cond)
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
150 {
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
151 MsnSoapConn * soapconn = data;
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
152
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
153 soapconn->read_cb = nexus_login_read_cb;
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
154 msn_soap_read_cb(data,source,cond);
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
155 }
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
156
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
157
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
158 /*when connect, do the SOAP Style windows Live ID authentication */
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
159 void
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
160 nexus_login_connect_cb(gpointer data, GaimSslConnection *gsc,
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 GaimInputCondition cond)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 {
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
163 MsnSoapConn *soapconn;
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
164 MsnNexus * nexus;
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 MsnSession *session;
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 char *username, *password;
19783
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
167 char *request_str, *head, *tail,*challenge_str;
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168
19783
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
169 gaim_debug_info("MaYuan","starting Windows Live ID authentication\n");
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
170
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
171 soapconn = data;
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
172 g_return_if_fail(soapconn != NULL);
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
173
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
174 nexus = soapconn->parent;
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 g_return_if_fail(nexus != NULL);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
177 session = soapconn->session;
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 g_return_if_fail(session != NULL);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179
10519
bec9130b24d2 [gaim-migrate @ 11833]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
180 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
181
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
182 /*prepare the Windows Live ID authentication token*/
19783
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
183 username = g_strdup(gaim_account_get_username(session->account));
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
184 password = g_strdup(gaim_connection_get_password(session->account->gc));
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
185 // g_strdup(gaim_url_encode(gaim_connection_get_password(session->account->gc)));
12457
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
186
19783
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
187 challenge_str = g_strdup_printf(
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
188 "lc=%s&amp;id=%s&amp;tw=%s&amp;fs=%s&amp;ru=%s&amp;ct=%s&amp;kpp=%s&amp;kv=%s&amp;ver=%s&amp;rn=%s&amp;tpf=%s\r\n",
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 (char *)g_hash_table_lookup(nexus->challenge_data, "lc"),
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 (char *)g_hash_table_lookup(nexus->challenge_data, "id"),
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 (char *)g_hash_table_lookup(nexus->challenge_data, "tw"),
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 (char *)g_hash_table_lookup(nexus->challenge_data, "fs"),
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 (char *)g_hash_table_lookup(nexus->challenge_data, "ru"),
19783
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
194 (char *)g_hash_table_lookup(nexus->challenge_data, "ct"),
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 (char *)g_hash_table_lookup(nexus->challenge_data, "kpp"),
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 (char *)g_hash_table_lookup(nexus->challenge_data, "kv"),
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 (char *)g_hash_table_lookup(nexus->challenge_data, "ver"),
19783
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
198 (char *)g_hash_table_lookup(nexus->challenge_data, "rn"),
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
199 (char *)g_hash_table_lookup(nexus->challenge_data, "tpf")
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
200 );
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
201
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
202 /*build the SOAP windows Live ID XML body */
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
203 tail = g_strdup_printf(TWN_ENVELOP_TEMPLATE,username,password,challenge_str );
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
205 soapconn->login_path = g_strdup(TWN_POST_URL);
19783
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
206 head = g_strdup_printf(
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
207 "POST %s HTTP/1.1\r\n"
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
208 "Accept: text/*\r\n"
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
209 "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n"
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
210 "Host: %s\r\n"
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
211 "Content-Length: %d\r\n"
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
212 "Connection: Keep-Alive\r\n"
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
213 "Cache-Control: no-cache\r\n\r\n",
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
214 soapconn->login_path,soapconn->login_host,strlen(tail));
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215
19783
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
216 request_str = g_strdup_printf("%s%s", head,tail);
19786
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
217 // gaim_debug_misc("msn", "TWN Sending: {%s}\n", request_str);
12457
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
218
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
219 g_free(head);
e585695bc16b [gaim-migrate @ 14766]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
220 g_free(tail);
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 g_free(username);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 g_free(password);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
224 /*prepare to send the SOAP request*/
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
225 msn_soap_write(soapconn,request_str,nexus_login_written_cb);
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
226
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
227 return;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
228 }
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229
19783
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
230 /**************************************************************************
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
231 * Connect
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
232 **************************************************************************/
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
233 void
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
234 msn_nexus_connect(MsnNexus *nexus)
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
235 {
19783
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
236 /* Authenticate via Windows Live ID. */
995aea35b05c [gaim-migrate @ 16329]
Ma Yuan <mayuan2006@gmail.com>
parents: 13200
diff changeset
237 gaim_debug_info("MaYuan","msn_nexus_connect...\n");
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
238
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19786
diff changeset
239 msn_soap_init(nexus->soapconn,MSN_TWN_SERVER,1,nexus_login_connect_cb,nexus_login_error_cb);
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12457
diff changeset
240 }
19784
bc30c6270d9f [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 19783
diff changeset
241