Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/nexus.c @ 20539:2c8c6d77f12c
Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Delete a user from the userlist after the contact is deleted from the server.
author | Carlos Silva <typ0@pidgin.im> |
---|---|
date | Wed, 19 Sep 2007 06:08:42 +0000 |
parents | 723b5a2f91ce |
children | 48ee7ec3426d |
comparison
equal
deleted
inserted
replaced
20525:5bef3197383a | 20539:2c8c6d77f12c |
---|---|
27 #include "notification.h" | 27 #include "notification.h" |
28 | 28 |
29 #undef NEXUS_LOGIN_TWN | 29 #undef NEXUS_LOGIN_TWN |
30 | 30 |
31 /*Local Function Prototype*/ | 31 /*Local Function Prototype*/ |
32 static void nexus_login_connect_cb(gpointer data, PurpleSslConnection *gsc,PurpleInputCondition cond); | 32 static gboolean nexus_login_connect_cb(MsnSoapConn *soapconn, PurpleSslConnection *gsc); |
33 | 33 |
34 /************************************************************************** | 34 /************************************************************************** |
35 * Main | 35 * Main |
36 **************************************************************************/ | 36 **************************************************************************/ |
37 | 37 |
123 #endif | 123 #endif |
124 /************************************************************************** | 124 /************************************************************************** |
125 * Login | 125 * Login |
126 **************************************************************************/ | 126 **************************************************************************/ |
127 static void | 127 static void |
128 nexus_login_error_cb(PurpleSslConnection *gsc, PurpleSslErrorType error, void *data) | 128 nexus_login_error_cb(MsnSoapConn *soapconn, PurpleSslConnection *gsc, PurpleSslErrorType error) |
129 { | 129 { |
130 MsnSoapConn * soapconn = data; | |
131 MsnSession *session; | 130 MsnSession *session; |
132 | 131 |
133 session = soapconn->session; | 132 session = soapconn->session; |
134 g_return_if_fail(session != NULL); | 133 g_return_if_fail(session != NULL); |
135 | 134 |
139 /* the above line will result in nexus being destroyed, so we don't want | 138 /* the above line will result in nexus being destroyed, so we don't want |
140 * to destroy it here, or we'd crash */ | 139 * to destroy it here, or we'd crash */ |
141 } | 140 } |
142 | 141 |
143 /*process the SOAP reply, get the Authentication Info*/ | 142 /*process the SOAP reply, get the Authentication Info*/ |
144 static void | 143 static gboolean |
145 nexus_login_read_cb(gpointer data, gint source, PurpleInputCondition cond) | 144 nexus_login_read_cb(MsnSoapConn *soapconn) |
146 { | 145 { |
147 MsnSoapConn * soapconn = data; | |
148 MsnNexus *nexus; | 146 MsnNexus *nexus; |
149 MsnSession *session; | 147 MsnSession *session; |
150 | 148 |
151 char *base, *c; | 149 char *base, *c; |
152 char *msn_twn_t,*msn_twn_p; | 150 char *msn_twn_t,*msn_twn_p; |
153 char *login_params; | 151 char *login_params; |
154 char **elems, **cur, **tokens; | 152 char **elems, **cur, **tokens; |
155 char * cert_str; | 153 char * cert_str; |
156 | 154 |
157 nexus = soapconn->parent; | 155 nexus = soapconn->parent; |
158 g_return_if_fail(nexus != NULL); | 156 g_return_val_if_fail(nexus != NULL, TRUE); |
159 session = nexus->session; | 157 session = nexus->session; |
160 g_return_if_fail(session != NULL); | 158 g_return_val_if_fail(session != NULL, FALSE); |
161 | 159 |
162 /*reply OK, we should process the SOAP body*/ | 160 /*reply OK, we should process the SOAP body*/ |
163 purple_debug_info("MSN Nexus","TWN Server Windows Live ID Reply OK!\n"); | 161 purple_debug_info("MSN Nexus","TWN Server Windows Live ID Reply OK!\n"); |
164 | 162 |
165 //TODO: we should parse it using XML | 163 //TODO: we should parse it using XML |
208 g_free(cert_str); | 206 g_free(cert_str); |
209 g_free(login_params); | 207 g_free(login_params); |
210 msn_nexus_destroy(nexus); | 208 msn_nexus_destroy(nexus); |
211 session->nexus = NULL; | 209 session->nexus = NULL; |
212 | 210 |
213 return; | 211 return FALSE; |
214 } | 212 } |
215 | 213 |
216 static void | 214 static void |
217 nexus_login_written_cb(gpointer data, gint source, PurpleInputCondition cond) | 215 nexus_login_written_cb(MsnSoapConn *soapconn) |
218 { | 216 { |
219 MsnSoapConn * soapconn = data; | |
220 | |
221 soapconn->read_cb = nexus_login_read_cb; | 217 soapconn->read_cb = nexus_login_read_cb; |
222 // msn_soap_read_cb(data,source,cond); | 218 // msn_soap_read_cb(data,source,cond); |
223 } | 219 } |
224 | 220 |
225 | 221 |
226 /*when connect, do the SOAP Style windows Live ID authentication */ | 222 /*when connect, do the SOAP Style windows Live ID authentication */ |
227 void | 223 gboolean |
228 nexus_login_connect_cb(gpointer data, PurpleSslConnection *gsc, | 224 nexus_login_connect_cb(MsnSoapConn *soapconn, PurpleSslConnection *gsc) |
229 PurpleInputCondition cond) | 225 { |
230 { | |
231 MsnSoapConn *soapconn; | |
232 MsnNexus * nexus; | 226 MsnNexus * nexus; |
233 MsnSession *session; | 227 MsnSession *session; |
234 char *ru,*lc,*id,*tw,*ct,*kpp,*kv,*ver,*rn,*tpf; | 228 char *ru,*lc,*id,*tw,*ct,*kpp,*kv,*ver,*rn,*tpf; |
235 char *fs0,*fs; | 229 char *fs0,*fs; |
236 char *username, *password; | 230 char *username, *password; |
238 #ifdef NEXUS_LOGIN_TWN | 232 #ifdef NEXUS_LOGIN_TWN |
239 char *challenge_str; | 233 char *challenge_str; |
240 #else | 234 #else |
241 char *rst1_str,*rst2_str,*rst3_str; | 235 char *rst1_str,*rst2_str,*rst3_str; |
242 #endif | 236 #endif |
243 | 237 |
244 purple_debug_info("MSN Nexus","Starting Windows Live ID authentication\n"); | 238 purple_debug_info("MSN Nexus","Starting Windows Live ID authentication\n"); |
245 | 239 |
246 soapconn = data; | 240 g_return_val_if_fail(soapconn != NULL, FALSE); |
247 g_return_if_fail(soapconn != NULL); | |
248 | 241 |
249 nexus = soapconn->parent; | 242 nexus = soapconn->parent; |
250 g_return_if_fail(nexus != NULL); | 243 g_return_val_if_fail(nexus != NULL, TRUE); |
251 | 244 |
252 session = soapconn->session; | 245 session = soapconn->session; |
253 g_return_if_fail(session != NULL); | 246 g_return_val_if_fail(session != NULL, FALSE); |
247 | |
248 msn_soap_set_process_step(soapconn, MSN_SOAP_PROCESSING); | |
254 | 249 |
255 msn_session_set_login_step(session, MSN_LOGIN_STEP_GET_COOKIE); | 250 msn_session_set_login_step(session, MSN_LOGIN_STEP_GET_COOKIE); |
256 | 251 |
257 /*prepare the Windows Live ID authentication token*/ | 252 /*prepare the Windows Live ID authentication token*/ |
258 username = g_strdup(purple_account_get_username(session->account)); | 253 username = g_strdup(purple_account_get_username(session->account)); |
281 g_free(username); | 276 g_free(username); |
282 g_free(password); | 277 g_free(password); |
283 purple_ssl_close(gsc); | 278 purple_ssl_close(gsc); |
284 msn_nexus_destroy(nexus); | 279 msn_nexus_destroy(nexus); |
285 session->nexus = NULL; | 280 session->nexus = NULL; |
286 return; | 281 return FALSE; |
287 } | 282 } |
288 | 283 |
289 /* | 284 /* |
290 * in old MSN NS server's "USR TWN S" return,didn't include fs string | 285 * in old MSN NS server's "USR TWN S" return,didn't include fs string |
291 * so we use a default "1" for fs. | 286 * so we use a default "1" for fs. |
326 head = g_strdup_printf( | 321 head = g_strdup_printf( |
327 "POST %s HTTP/1.1\r\n" | 322 "POST %s HTTP/1.1\r\n" |
328 "Accept: text/*\r\n" | 323 "Accept: text/*\r\n" |
329 "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n" | 324 "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n" |
330 "Host: %s\r\n" | 325 "Host: %s\r\n" |
331 "Content-Length: %d\r\n" | 326 "Content-Length: %" G_GSIZE_FORMAT "\r\n" |
332 "Connection: Keep-Alive\r\n" | 327 "Connection: Keep-Alive\r\n" |
333 "Cache-Control: no-cache\r\n\r\n", | 328 "Cache-Control: no-cache\r\n\r\n", |
334 soapconn->login_path,soapconn->login_host,(int)strlen(tail)); | 329 soapconn->login_path, soapconn->login_host, strlen(tail)); |
335 | 330 |
336 request_str = g_strdup_printf("%s%s", head,tail); | 331 request_str = g_strdup_printf("%s%s", head,tail); |
337 | 332 |
338 #ifdef MSN_SOAP_DEBUG | 333 #ifdef MSN_SOAP_DEBUG |
339 purple_debug_misc("MSN Nexus", "TWN Sending:\n%s\n", request_str); | 334 purple_debug_misc("MSN Nexus", "TWN Sending:\n%s\n", request_str); |
342 g_free(tail); | 337 g_free(tail); |
343 g_free(username); | 338 g_free(username); |
344 g_free(password); | 339 g_free(password); |
345 | 340 |
346 /*prepare to send the SOAP request*/ | 341 /*prepare to send the SOAP request*/ |
347 msn_soap_write(soapconn,request_str,nexus_login_written_cb); | 342 msn_soap_write(soapconn, request_str, nexus_login_written_cb); |
348 | 343 |
349 return; | 344 return TRUE; |
350 } | 345 } |
351 | 346 |
352 #if 0 /* khc */ | 347 #if 0 /* khc */ |
353 static void | 348 static void |
354 nexus_connect_written_cb(gpointer data, gint source, PurpleInputCondition cond) | 349 nexus_connect_written_cb(gpointer data, gint source, PurpleInputCondition cond) |
466 | 461 |
467 void | 462 void |
468 msn_nexus_connect(MsnNexus *nexus) | 463 msn_nexus_connect(MsnNexus *nexus) |
469 { | 464 { |
470 /* Authenticate via Windows Live ID. */ | 465 /* Authenticate via Windows Live ID. */ |
471 purple_debug_info("MSN Nexus","msn_nexus_connect()\n"); | 466 msn_soap_init(nexus->soapconn, MSN_TWN_SERVER, 1, nexus_login_connect_cb, nexus_login_error_cb); |
472 msn_soap_init(nexus->soapconn,MSN_TWN_SERVER,1,nexus_login_connect_cb,nexus_login_error_cb); | |
473 msn_soap_connect(nexus->soapconn); | 467 msn_soap_connect(nexus->soapconn); |
474 } | 468 } |