Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/contact.c @ 20479:6a8463be5b23
Improve MSN_SOAP_DEBUG and workaround a Win32 bug which would case Pidgin to consume insane amounts of memory when printing a large string to the Debug Window.
author | Carlos Silva <typ0@pidgin.im> |
---|---|
date | Wed, 08 Aug 2007 23:01:44 +0000 |
parents | 9a2a4a0c0003 |
children | eb93710aec4d |
comparison
equal
deleted
inserted
replaced
20478:c1c4468207fa | 20479:6a8463be5b23 |
---|---|
179 static void | 179 static void |
180 msn_parse_contact_list(MsnContact * contact) | 180 msn_parse_contact_list(MsnContact * contact) |
181 { | 181 { |
182 MsnSession * session; | 182 MsnSession * session; |
183 int list_op = 0; | 183 int list_op = 0; |
184 char * passport, *debugdata, *typedata; | 184 char * passport, *typedata; |
185 xmlnode *fault, *faultstringnode, *faultdetail, *errorcode; | 185 xmlnode *fault, *faultstringnode, *faultdetail, *errorcode; |
186 xmlnode *node, *body, *response, *result, *services; | 186 xmlnode *node, *body, *response, *result, *services; |
187 xmlnode *service, *memberships, *info, *handle, *handletype; | 187 xmlnode *service, *memberships, *info, *handle, *handletype; |
188 xmlnode *LastChangeNode; | 188 xmlnode *LastChangeNode; |
189 xmlnode *membershipnode, *members, *member, *passportNode; | 189 xmlnode *membershipnode, *members, *member, *passportNode; |
190 char *LastChangeStr; | 190 char *LastChangeStr; |
191 | 191 |
192 purple_debug_info("::","msn_parse_contact_list()\n"); | |
193 | |
194 session = contact->session; | 192 session = contact->session; |
195 node = xmlnode_from_str(contact->soapconn->body, contact->soapconn->body_len); | 193 node = xmlnode_from_str(contact->soapconn->body, contact->soapconn->body_len); |
196 | 194 |
197 if (node == NULL) { | 195 if (node == NULL) { |
198 purple_debug_error("MSNCL","Unable to parse SOAP data!\n"); | 196 purple_debug_error("MSNCL","Unable to parse SOAP data!\n"); |
199 return; | 197 return; |
200 } | 198 } |
201 | 199 |
202 #ifdef MSN_SOAP_DEBUG | 200 purple_debug_misc("MSNCL","Parsing contact list with size %d\n", contact->soapconn->body_len); |
203 debugdata = xmlnode_to_formatted_str(node, NULL); | 201 |
204 purple_debug_info("MSNCL","Received contact list, parsing:\n%s", debugdata); | 202 purple_debug_misc("MSNCL","Root node @ %p: Name: '%s', child: '%s', lastchild: '%s'\n",node,node->name,node->child->name,node->lastchild->name); |
205 g_free(debugdata); | |
206 #endif | |
207 | |
208 | |
209 purple_debug_info("MSNCL","Root node @ %p: Name: '%s', child: '%s', lastchild: '%s'\n",node,node->name,node->child->name,node->lastchild->name); | |
210 body = xmlnode_get_child(node,"Body"); | 203 body = xmlnode_get_child(node,"Body"); |
211 | 204 |
212 if (body == NULL) { | 205 if (body == NULL) { |
213 purple_debug_warning("MSNCL", "Failed to parse contact list Body node\n"); | 206 purple_debug_warning("MSNCL", "Failed to parse contact list Body node\n"); |
214 xmlnode_free(node); | 207 xmlnode_free(node); |
219 /* Did we receive a <Fault> ? */ | 212 /* Did we receive a <Fault> ? */ |
220 if ( (fault = xmlnode_get_child(body, "Fault")) != NULL) { | 213 if ( (fault = xmlnode_get_child(body, "Fault")) != NULL) { |
221 purple_debug_info("MSNCL","Fault received from SOAP server!\n"); | 214 purple_debug_info("MSNCL","Fault received from SOAP server!\n"); |
222 | 215 |
223 if ( (faultstringnode = xmlnode_get_child(fault, "faultstring")) != NULL ) { | 216 if ( (faultstringnode = xmlnode_get_child(fault, "faultstring")) != NULL ) { |
224 gchar * faultstring = xmlnode_get_data(faultstring); | 217 gchar * faultstring = xmlnode_get_data(faultstringnode); |
225 purple_debug_info("MSNCL","Faultstring: %s\n", faultstring); | 218 purple_debug_info("MSNCL","Faultstring: %s\n", faultstring); |
226 g_free(faultstring); | 219 g_free(faultstring); |
227 } | 220 } |
228 if ( (faultdetail = xmlnode_get_child(fault, "detail")) != NULL ) { | 221 if ( (faultdetail = xmlnode_get_child(fault, "detail")) != NULL ) { |
229 purple_debug_info("MSNCL","detail @ %p, name: %s\n",faultdetail, faultdetail->name); | 222 purple_debug_info("MSNCL","detail @ %p, name: %s\n",faultdetail, faultdetail->name); |
390 MsnContact *contact; | 383 MsnContact *contact; |
391 MsnSession *session; | 384 MsnSession *session; |
392 const char *abLastChange; | 385 const char *abLastChange; |
393 const char *dynamicItemLastChange; | 386 const char *dynamicItemLastChange; |
394 | 387 |
395 purple_debug_info("::","msn_get_contact_list_cb()\n"); | 388 purple_debug_misc("MSNCL","Got the contact list!\n"); |
396 | 389 |
397 contact = soapconn->parent; | 390 contact = soapconn->parent; |
398 g_return_if_fail(contact != NULL); | 391 g_return_if_fail(contact != NULL); |
399 session = soapconn->session; | 392 session = soapconn->session; |
400 g_return_if_fail(session != NULL); | 393 g_return_if_fail(session != NULL); |
401 | 394 |
402 #ifdef MSN_SOAP_DEBUG | |
403 purple_debug_info("MSNCL", "SOAP server reply: \n%s\n", soapconn->read_buf); | |
404 #endif | |
405 msn_parse_contact_list(contact); | 395 msn_parse_contact_list(contact); |
406 /*free the read buffer*/ | 396 /*free the read buffer*/ |
407 msn_soap_free_read_buf(soapconn); | 397 msn_soap_free_read_buf(soapconn); |
408 | 398 |
409 abLastChange = purple_account_get_string(session->account, "ablastChange", NULL); | 399 abLastChange = purple_account_get_string(session->account, "ablastChange", NULL); |
423 static void | 413 static void |
424 msn_get_contact_written_cb(gpointer data, gint source, PurpleInputCondition cond) | 414 msn_get_contact_written_cb(gpointer data, gint source, PurpleInputCondition cond) |
425 { | 415 { |
426 MsnSoapConn * soapconn = data; | 416 MsnSoapConn * soapconn = data; |
427 | 417 |
428 purple_debug_info("MSNP14","finish contact written\n"); | 418 purple_debug_misc("MSNCL","Sent SOAP request for the contact list.\n"); |
429 soapconn->read_cb = msn_get_contact_list_cb; | 419 soapconn->read_cb = msn_get_contact_list_cb; |
430 // msn_soap_read_cb(data,source,cond); | 420 // msn_soap_read_cb(data,source,cond); |
431 } | 421 } |
432 | 422 |
433 /*SOAP get contact list*/ | 423 /*SOAP get contact list*/ |
436 { | 426 { |
437 MsnSoapReq *soap_request; | 427 MsnSoapReq *soap_request; |
438 char *body = NULL; | 428 char *body = NULL; |
439 char * update_str; | 429 char * update_str; |
440 | 430 |
441 purple_debug_info("::","msn_get_contact_list()\n"); | 431 purple_debug_misc("MSNCL","Getting Contact List.\n"); |
442 | |
443 purple_debug_info("MSNP14","Getting Contact List.\n"); | |
444 if ( update_time != NULL ) { | 432 if ( update_time != NULL ) { |
445 purple_debug_info("MSNCL","last update time:{%s}\n",update_time); | 433 purple_debug_info("MSNCL","Last update time: %s\n",update_time); |
446 update_str = g_strdup_printf(MSN_GET_CONTACT_UPDATE_XML,update_time); | 434 update_str = g_strdup_printf(MSN_GET_CONTACT_UPDATE_XML,update_time); |
447 } else { | 435 } else { |
448 update_str = g_strdup(""); | 436 update_str = g_strdup(""); |
449 } | 437 } |
450 body = g_strdup_printf(MSN_GET_CONTACT_TEMPLATE, update_str); | 438 body = g_strdup_printf(MSN_GET_CONTACT_TEMPLATE, update_str); |
463 msn_parse_addressbook_groups(MsnContact *contact, xmlnode *node) | 451 msn_parse_addressbook_groups(MsnContact *contact, xmlnode *node) |
464 { | 452 { |
465 MsnSession *session = contact->session; | 453 MsnSession *session = contact->session; |
466 xmlnode *group; | 454 xmlnode *group; |
467 | 455 |
468 purple_debug_info("::","msn_parse_addressbook_groups()\n"); | 456 purple_debug_info("MsnAb","msn_parse_addressbook_groups()\n"); |
469 | 457 |
470 for(group = xmlnode_get_child(node, "Group"); group; | 458 for(group = xmlnode_get_child(node, "Group"); group; |
471 group = xmlnode_get_next_twin(group)){ | 459 group = xmlnode_get_next_twin(group)){ |
472 xmlnode *groupId, *groupInfo, *groupname; | 460 xmlnode *groupId, *groupInfo, *groupname; |
473 char *group_id, *group_name; | 461 char *group_id, *group_name; |
622 xmlnode * node,*body,*response,*result; | 610 xmlnode * node,*body,*response,*result; |
623 xmlnode *groups; | 611 xmlnode *groups; |
624 xmlnode *contacts; | 612 xmlnode *contacts; |
625 xmlnode *abNode; | 613 xmlnode *abNode; |
626 xmlnode *fault, *faultstringnode, *faultdetail, *errorcode; | 614 xmlnode *fault, *faultstringnode, *faultdetail, *errorcode; |
627 gchar *printabledata; | |
628 | 615 |
629 session = contact->session; | 616 session = contact->session; |
630 | 617 |
631 | 618 |
632 | 619 |
633 node = xmlnode_from_str(contact->soapconn->body, contact->soapconn->body_len); | 620 node = xmlnode_from_str(contact->soapconn->body, contact->soapconn->body_len); |
634 if ( node == NULL ) { | 621 if ( node == NULL ) { |
635 purple_debug_error("MSN AddressBook","Error parsing received Address Book with size %d:\n \"%s\"\n", contact->soapconn->body_len, contact->soapconn->body); | 622 purple_debug_error("MSN AddressBook","Error parsing Address Book with size %d\n", contact->soapconn->body_len); |
636 return FALSE; | 623 return FALSE; |
637 } | 624 } |
638 | 625 |
639 printabledata = xmlnode_to_formatted_str(node, NULL); | 626 purple_debug_misc("MSN AddressBook", "Parsing Address Book with size %d\n", contact->soapconn->body_len); |
640 purple_debug_misc("MSN AddressBook","Received Address Book with size %d:\n %s\n", contact->soapconn->body_len, (char *) printabledata); | |
641 g_free(printabledata); | |
642 | 627 |
643 purple_debug_misc("MSN AddressBook","node{%p},name:%s,child:%s,last:%s\n",node,node->name,node->child->name,node->lastchild->name); | 628 purple_debug_misc("MSN AddressBook","node{%p},name:%s,child:%s,last:%s\n",node,node->name,node->child->name,node->lastchild->name); |
644 | 629 |
645 body = xmlnode_get_child(node,"Body"); | 630 body = xmlnode_get_child(node,"Body"); |
646 purple_debug_misc("MSN AddressBook","body{%p},name:%s\n",body,body->name); | 631 purple_debug_misc("MSN AddressBook","body{%p},name:%s\n",body,body->name); |
647 | 632 |
648 if ( (fault = xmlnode_get_child(body, "Fault")) != NULL) { | 633 if ( (fault = xmlnode_get_child(body, "Fault")) != NULL) { |
649 purple_debug_info("MSN AddressBook","Fault received from SOAP server!\n"); | 634 purple_debug_info("MSN AddressBook","Fault received from SOAP server!\n"); |
650 | 635 |
651 if ( (faultstringnode = xmlnode_get_child(fault, "faultstring")) != NULL ) { | 636 if ( (faultstringnode = xmlnode_get_child(fault, "faultstring")) != NULL ) { |
652 gchar *faultstring = xmlnode_get_data(faultstring); | 637 gchar *faultstring = xmlnode_get_data(faultstringnode); |
653 purple_debug_info("MSN AddressBook","Faultstring: %s\n", faultstring); | 638 purple_debug_info("MSN AddressBook","Faultstring: %s\n", faultstring); |
654 g_free(faultstring); | 639 g_free(faultstring); |
655 } | 640 } |
656 if ( (faultdetail = xmlnode_get_child(fault, "detail")) != NULL ) { | 641 if ( (faultdetail = xmlnode_get_child(fault, "detail")) != NULL ) { |
657 purple_debug_info("MSN AddressBook","detail @ %p, name: %s\n",faultdetail, faultdetail->name); | 642 purple_debug_info("MSN AddressBook","detail @ %p, name: %s\n",faultdetail, faultdetail->name); |
752 contact = soapconn->parent; | 737 contact = soapconn->parent; |
753 g_return_if_fail(contact != NULL); | 738 g_return_if_fail(contact != NULL); |
754 session = soapconn->session; | 739 session = soapconn->session; |
755 g_return_if_fail(session != NULL); | 740 g_return_if_fail(session != NULL); |
756 | 741 |
757 // purple_debug_misc("msn", "soap contact server Reply: {%s}\n", soapconn->read_buf); | 742 purple_debug_misc("MSN AddressBook", "Got the Address Book!\n"); |
743 | |
758 if ( msn_parse_addressbook(contact) ) { | 744 if ( msn_parse_addressbook(contact) ) { |
759 msn_soap_free_read_buf(soapconn); | 745 msn_soap_free_read_buf(soapconn); |
760 | 746 |
761 msn_send_privacy(session->account->gc); | 747 msn_send_privacy(session->account->gc); |
762 msn_notification_dump_contact(session); | 748 msn_notification_dump_contact(session); |
779 static void | 765 static void |
780 msn_address_written_cb(gpointer data, gint source, PurpleInputCondition cond) | 766 msn_address_written_cb(gpointer data, gint source, PurpleInputCondition cond) |
781 { | 767 { |
782 MsnSoapConn * soapconn = data; | 768 MsnSoapConn * soapconn = data; |
783 | 769 |
784 purple_debug_info("MSNP14","finish contact written\n"); | 770 purple_debug_misc("MSN AddressBook","Sent SOAP request for the Address Book.\n"); |
785 soapconn->read_cb = msn_get_address_cb; | 771 soapconn->read_cb = msn_get_address_cb; |
786 } | 772 } |
787 | 773 |
788 /*get the address book*/ | 774 /*get the address book*/ |
789 void | 775 void |
791 { | 777 { |
792 MsnSoapReq *soap_request; | 778 MsnSoapReq *soap_request; |
793 char *body = NULL; | 779 char *body = NULL; |
794 char *ab_update_str,*update_str; | 780 char *ab_update_str,*update_str; |
795 | 781 |
796 purple_debug_info("::","msn_get_address_book()\n"); | 782 purple_debug_misc("MSN AddressBook","Getting Address Book\n"); |
797 | 783 |
798 /*build SOAP and POST it*/ | 784 /*build SOAP and POST it*/ |
799 if ( LastChanged != NULL ) { | 785 if ( LastChanged != NULL ) { |
800 ab_update_str = g_strdup_printf(MSN_GET_ADDRESS_UPDATE_XML,LastChanged); | 786 ab_update_str = g_strdup_printf(MSN_GET_ADDRESS_UPDATE_XML,LastChanged); |
801 } else { | 787 } else { |
844 MsnSoapReq *soap_request; | 830 MsnSoapReq *soap_request; |
845 char *body = NULL; | 831 char *body = NULL; |
846 char *contact_xml = NULL; | 832 char *contact_xml = NULL; |
847 char *soap_action; | 833 char *soap_action; |
848 | 834 |
849 purple_debug_info("::","msn_add_contact()\n"); | 835 purple_debug_info("MSNCL","msn_add_contact()\n"); |
850 contact_xml = g_strdup_printf(MSN_CONTACT_XML,passport); | 836 contact_xml = g_strdup_printf(MSN_CONTACT_XML,passport); |
851 if ( groupId == NULL ) { | 837 if ( groupId == NULL ) { |
852 body = g_strdup_printf(MSN_ADD_CONTACT_TEMPLATE,contact_xml); | 838 body = g_strdup_printf(MSN_ADD_CONTACT_TEMPLATE,contact_xml); |
853 g_free(contact_xml); | 839 g_free(contact_xml); |
854 /*build SOAP and POST it*/ | 840 /*build SOAP and POST it*/ |