comparison libpurple/protocols/msn/soap.c @ 20481:eb93710aec4d

Make buddy and group management actually work, add some SOAP templates, redesign some parts of code and separate some bigger functions into its smaller tasks which are completely unrelated to each other
author Carlos Silva <typ0@pidgin.im>
date Tue, 28 Aug 2007 03:54:18 +0000
parents 6a8463be5b23
children 321d25932f5e
comparison
equal deleted inserted replaced
20480:7d3e53e3f623 20481:eb93710aec4d
484 } 484 }
485 485
486 void 486 void
487 msn_soap_free_read_buf(MsnSoapConn *soapconn) 487 msn_soap_free_read_buf(MsnSoapConn *soapconn)
488 { 488 {
489 g_return_if_fail(soapconn != NULL);
490
489 if (soapconn->read_buf) { 491 if (soapconn->read_buf) {
490 g_free(soapconn->read_buf); 492 g_free(soapconn->read_buf);
491 } 493 }
492 soapconn->read_buf = NULL; 494 soapconn->read_buf = NULL;
493 soapconn->read_len = 0; 495 soapconn->read_len = 0;
495 } 497 }
496 498
497 void 499 void
498 msn_soap_free_write_buf(MsnSoapConn *soapconn) 500 msn_soap_free_write_buf(MsnSoapConn *soapconn)
499 { 501 {
500 if(soapconn->write_buf){ 502 g_return_if_fail(soapconn != NULL);
503
504 if (soapconn->write_buf) {
501 g_free(soapconn->write_buf); 505 g_free(soapconn->write_buf);
502 } 506 }
503 soapconn->write_buf = NULL; 507 soapconn->write_buf = NULL;
504 soapconn->written_len = 0; 508 soapconn->written_len = 0;
509 }
510
511 void
512 msn_soap_free_data_cb(MsnSoapConn *soapconn)
513 {
514 if (soapconn->data_cb) {
515 g_free(soapconn->data_cb);
516 }
505 } 517 }
506 518
507 /*Soap write process func*/ 519 /*Soap write process func*/
508 static void 520 static void
509 msn_soap_write_cb(gpointer data, gint source, PurpleInputCondition cond) 521 msn_soap_write_cb(gpointer data, gint source, PurpleInputCondition cond)
580 } 592 }
581 593
582 /* New a soap request*/ 594 /* New a soap request*/
583 MsnSoapReq * 595 MsnSoapReq *
584 msn_soap_request_new(const char *host,const char *post_url,const char *soap_action, 596 msn_soap_request_new(const char *host,const char *post_url,const char *soap_action,
585 const char *body, 597 const char *body, const gpointer data_cb,
586 PurpleInputFunction read_cb,PurpleInputFunction written_cb) 598 PurpleInputFunction read_cb,PurpleInputFunction written_cb)
587 { 599 {
588 MsnSoapReq *request; 600 MsnSoapReq *request;
589 601
590 request = g_new0(MsnSoapReq, 1); 602 request = g_new0(MsnSoapReq, 1);
592 604
593 request->login_host = g_strdup(host); 605 request->login_host = g_strdup(host);
594 request->login_path = g_strdup(post_url); 606 request->login_path = g_strdup(post_url);
595 request->soap_action = g_strdup(soap_action); 607 request->soap_action = g_strdup(soap_action);
596 request->body = g_strdup(body); 608 request->body = g_strdup(body);
609 request->data_cb = data_cb;
597 request->read_cb = read_cb; 610 request->read_cb = read_cb;
598 request->written_cb = written_cb; 611 request->written_cb = written_cb;
599 612
600 return request; 613 return request;
601 } 614 }
608 621
609 g_free(request->login_host); 622 g_free(request->login_host);
610 g_free(request->login_path); 623 g_free(request->login_path);
611 g_free(request->soap_action); 624 g_free(request->soap_action);
612 g_free(request->body); 625 g_free(request->body);
626 g_free(request->data_cb);
613 request->read_cb = NULL; 627 request->read_cb = NULL;
614 request->written_cb = NULL; 628 request->written_cb = NULL;
615 629
616 g_free(request); 630 g_free(request);
617 } 631 }
647 purple_debug_misc("MSN SOAP","No connection to SOAP server. Connecting...\n"); 661 purple_debug_misc("MSN SOAP","No connection to SOAP server. Connecting...\n");
648 msn_soap_init_func(soapconn); 662 msn_soap_init_func(soapconn);
649 msn_soap_connect(soapconn); 663 msn_soap_connect(soapconn);
650 return; 664 return;
651 } 665 }
652 purple_debug_misc("MSN SOAP","Connected to SOAP server!\n"); 666 purple_debug_misc("MSN SOAP","Connected to SOAP server\n");
653 667
654 /*if connected, what we only needed to do is to queue the request, 668 /*if connected, what we only needed to do is to queue the request,
655 * when SOAP request in the queue processed done, will do this command. 669 * when SOAP request in the queue processed done, will do this command.
656 * we just waiting... 670 * we just waiting...
657 * If we send the request this time,error may occure 671 * If we send the request this time,error may occure
708 purple_debug_info("MSN SOAP","Failed to parse SOAP request being sent:\n%s\n", request_str); 722 purple_debug_info("MSN SOAP","Failed to parse SOAP request being sent:\n%s\n", request_str);
709 #endif 723 #endif
710 724
711 g_free(soap_head); 725 g_free(soap_head);
712 /*free read buffer*/ 726 /*free read buffer*/
713 msn_soap_free_read_buf(soapconn); 727 // msn_soap_free_read_buf(soapconn);
714 /*post it to server*/ 728 /*post it to server*/
715 msn_soap_write(soapconn,request_str,request->written_cb); 729 soapconn->data_cb = request->data_cb;
716 } 730 msn_soap_write(soapconn, request_str, request->written_cb);
717 731 }
732