Mercurial > pidgin
comparison libgaim/protocols/msn/contact.c @ 20393:40a04930b233
The second msn-p13-merge-head.diff.gz from SF Patch #162854 from Ka-Hing Cheung.
"A little late, but here is a version that should remember your friendly
name. Also has a fix for a crasher when MSN sends you back:
<faultstring>Need to do full sync. Can't sync deltas Client
has too old a copy for us to do a delta sync</faultstring>
In this case, I make gaim re-request the full contact list/address book.
I haven't look too deeply into the reverse list problem, but I think the
solution would involve caching the reverse list, which may require
extending the privacy api."
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 15 Apr 2007 03:02:48 +0000 |
parents | 0b0ecee55091 |
children |
comparison
equal
deleted
inserted
replaced
20392:9ba7dee775e1 | 20393:40a04930b233 |
---|---|
31 #include "group.h" | 31 #include "group.h" |
32 | 32 |
33 /*define This to debug the Contact Server*/ | 33 /*define This to debug the Contact Server*/ |
34 #undef MSN_CONTACT_SOAP_DEBUG | 34 #undef MSN_CONTACT_SOAP_DEBUG |
35 | 35 |
36 void msn_contact_connect_init(MsnSoapConn *soapconn); | |
37 | |
38 /*new a contact*/ | 36 /*new a contact*/ |
39 MsnContact * | 37 MsnContact * |
40 msn_contact_new(MsnSession *session) | 38 msn_contact_new(MsnSession *session) |
41 { | 39 { |
42 MsnContact *contact; | 40 MsnContact *contact; |
142 } | 140 } |
143 gaim_debug_misc("MSNCL","node{%p},name:%s,child:%s,last:%s\n",node,node->name,node->child->name,node->lastchild->name); | 141 gaim_debug_misc("MSNCL","node{%p},name:%s,child:%s,last:%s\n",node,node->name,node->child->name,node->lastchild->name); |
144 body = xmlnode_get_child(node,"Body"); | 142 body = xmlnode_get_child(node,"Body"); |
145 gaim_debug_misc("MSNCL","body{%p},name:%s\n",body,body->name); | 143 gaim_debug_misc("MSNCL","body{%p},name:%s\n",body,body->name); |
146 response = xmlnode_get_child(body,"FindMembershipResponse"); | 144 response = xmlnode_get_child(body,"FindMembershipResponse"); |
145 | |
146 if (response == NULL) { | |
147 /* we may get a response if our cache data is too old: | |
148 * | |
149 * <faultstring>Need to do full sync. Can't sync deltas Client | |
150 * has too old a copy for us to do a delta sync</faultstring> | |
151 */ | |
152 msn_get_contact_list(contact, NULL); | |
153 return; | |
154 } | |
155 | |
147 gaim_debug_misc("MSNCL","response{%p},name:%s\n",response,response->name); | 156 gaim_debug_misc("MSNCL","response{%p},name:%s\n",response,response->name); |
148 result =xmlnode_get_child(response,"FindMembershipResult"); | 157 result =xmlnode_get_child(response,"FindMembershipResult"); |
149 if(result == NULL){ | 158 if(result == NULL){ |
150 gaim_debug_misc("MSNCL","receive No Update!\n"); | 159 gaim_debug_misc("MSNCL","receive No Update!\n"); |
151 return; | 160 return; |
261 gaim_debug_info("MSNCL","last update time:{%s}\n",update_time); | 270 gaim_debug_info("MSNCL","last update time:{%s}\n",update_time); |
262 update_str = g_strdup_printf(MSN_GET_CONTACT_UPDATE_XML,update_time); | 271 update_str = g_strdup_printf(MSN_GET_CONTACT_UPDATE_XML,update_time); |
263 }else{ | 272 }else{ |
264 update_str = g_strdup(""); | 273 update_str = g_strdup(""); |
265 } | 274 } |
266 body = g_strdup_printf(MSN_GET_CONTACT_TEMPLATE,update_str); | 275 body = g_strdup_printf(MSN_GET_CONTACT_TEMPLATE, update_str); |
267 soap_request = msn_soap_request_new(MSN_CONTACT_SERVER, | 276 soap_request = msn_soap_request_new(MSN_CONTACT_SERVER, |
268 MSN_GET_CONTACT_POST_URL,MSN_GET_CONTACT_SOAP_ACTION, | 277 MSN_GET_CONTACT_POST_URL,MSN_GET_CONTACT_SOAP_ACTION, |
269 body, | 278 body, |
270 msn_get_contact_list_cb, | 279 msn_get_contact_list_cb, |
271 msn_get_contact_written_cb); | 280 msn_get_contact_written_cb); |
272 msn_soap_post(contact->soapconn,soap_request,msn_contact_connect_init); | 281 msn_soap_post(contact->soapconn,soap_request,msn_contact_connect_init); |
273 g_free(update_str); | 282 g_free(update_str); |
274 g_free(body); | 283 g_free(body); |
275 } | 284 } |
276 | 285 |
277 static void | 286 static gboolean |
278 msn_parse_addressbook(MsnContact * contact) | 287 msn_parse_addressbook(MsnContact * contact) |
279 { | 288 { |
280 MsnSession * session; | 289 MsnSession * session; |
281 xmlnode * node,*body,*response,*result; | 290 xmlnode * node,*body,*response,*result; |
282 xmlnode *groups,*group,*groupname,*groupId,*groupInfo; | 291 xmlnode *groups,*group,*groupname,*groupId,*groupInfo; |
288 gaim_debug_misc("xml","parse addressbook:{%s}\nsize:%d\n",contact->soapconn->body,contact->soapconn->body_len); | 297 gaim_debug_misc("xml","parse addressbook:{%s}\nsize:%d\n",contact->soapconn->body,contact->soapconn->body_len); |
289 node = xmlnode_from_str(contact->soapconn->body, contact->soapconn->body_len); | 298 node = xmlnode_from_str(contact->soapconn->body, contact->soapconn->body_len); |
290 | 299 |
291 if(node == NULL){ | 300 if(node == NULL){ |
292 gaim_debug_misc("xml","parse from str err!\n"); | 301 gaim_debug_misc("xml","parse from str err!\n"); |
293 return; | 302 return FALSE; |
294 } | 303 } |
295 gaim_debug_misc("xml","node{%p},name:%s,child:%s,last:%s\n",node,node->name,node->child->name,node->lastchild->name); | 304 gaim_debug_misc("xml","node{%p},name:%s,child:%s,last:%s\n",node,node->name,node->child->name,node->lastchild->name); |
296 body = xmlnode_get_child(node,"Body"); | 305 body = xmlnode_get_child(node,"Body"); |
297 gaim_debug_misc("xml","body{%p},name:%s\n",body,body->name); | 306 gaim_debug_misc("xml","body{%p},name:%s\n",body,body->name); |
298 response = xmlnode_get_child(body,"ABFindAllResponse"); | 307 response = xmlnode_get_child(body,"ABFindAllResponse"); |
308 | |
309 if (response == NULL) { | |
310 return FALSE; | |
311 } | |
312 | |
299 gaim_debug_misc("xml","response{%p},name:%s\n",response,response->name); | 313 gaim_debug_misc("xml","response{%p},name:%s\n",response,response->name); |
300 result =xmlnode_get_child(response,"ABFindAllResult"); | 314 result =xmlnode_get_child(response,"ABFindAllResult"); |
301 if(result == NULL){ | 315 if(result == NULL){ |
302 gaim_debug_misc("MSNAB","receive no address book update\n"); | 316 gaim_debug_misc("MSNAB","receive no address book update\n"); |
303 return; | 317 return TRUE; |
304 } | 318 } |
305 gaim_debug_misc("xml","result{%p},name:%s\n",result,result->name); | 319 gaim_debug_misc("xml","result{%p},name:%s\n",result,result->name); |
306 | 320 |
307 /*Process Group List*/ | 321 /*Process Group List*/ |
308 groups =xmlnode_get_child(result,"groups"); | 322 groups =xmlnode_get_child(result,"groups"); |
478 gaim_blist_node_set_string(msn_session_get_bnode(contact->session),"DynamicItemLastChanged",lastchange); | 492 gaim_blist_node_set_string(msn_session_get_bnode(contact->session),"DynamicItemLastChanged",lastchange); |
479 } | 493 } |
480 | 494 |
481 xmlnode_free(node); | 495 xmlnode_free(node); |
482 msn_soap_free_read_buf(contact->soapconn); | 496 msn_soap_free_read_buf(contact->soapconn); |
497 return TRUE; | |
483 } | 498 } |
484 | 499 |
485 static void | 500 static void |
486 msn_get_address_cb(gpointer data, gint source, GaimInputCondition cond) | 501 msn_get_address_cb(gpointer data, gint source, GaimInputCondition cond) |
487 { | 502 { |
493 g_return_if_fail(contact != NULL); | 508 g_return_if_fail(contact != NULL); |
494 session = soapconn->session; | 509 session = soapconn->session; |
495 g_return_if_fail(session != NULL); | 510 g_return_if_fail(session != NULL); |
496 | 511 |
497 // gaim_debug_misc("msn", "soap contact server Reply: {%s}\n", soapconn->read_buf); | 512 // gaim_debug_misc("msn", "soap contact server Reply: {%s}\n", soapconn->read_buf); |
498 msn_parse_addressbook(contact); | 513 if (msn_parse_addressbook(contact)) { |
499 | 514 msn_notification_dump_contact(session); |
500 msn_notification_dump_contact(session); | 515 msn_set_psm(session); |
501 msn_set_psm(session); | 516 msn_session_finish_login(session); |
502 msn_session_finish_login(session); | 517 } else { |
518 msn_get_address_book(contact, NULL, NULL); | |
519 } | |
503 | 520 |
504 /*free the read buffer*/ | 521 /*free the read buffer*/ |
505 msn_soap_free_read_buf(soapconn); | 522 msn_soap_free_read_buf(soapconn); |
506 } | 523 } |
507 | 524 |