Mercurial > pidgin
comparison libpurple/protocols/msn/oim.c @ 20989:2097b1664fa3
Fix some leaks and prevent some unnecessary allocations and frees.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Thu, 18 Oct 2007 23:51:10 +0000 |
parents | 703147a8b0a7 |
children | f387e8c671a4 |
comparison
equal
deleted
inserted
replaced
20988:9375e1a9a196 | 20989:2097b1664fa3 |
---|---|
38 static void msn_oim_retrieve_connect_init(MsnSoapConn *soapconn); | 38 static void msn_oim_retrieve_connect_init(MsnSoapConn *soapconn); |
39 static void msn_oim_send_connect_init(MsnSoapConn *soapconn); | 39 static void msn_oim_send_connect_init(MsnSoapConn *soapconn); |
40 static void msn_oim_free_send_req(MsnOimSendReq *req); | 40 static void msn_oim_free_send_req(MsnOimSendReq *req); |
41 static void msn_oim_report_to_user(MsnOim *oim, const char *msg_str); | 41 static void msn_oim_report_to_user(MsnOim *oim, const char *msg_str); |
42 static void msn_oim_get_process(MsnOim *oim, const char *oim_msg); | 42 static void msn_oim_get_process(MsnOim *oim, const char *oim_msg); |
43 static char *msn_oim_msg_to_str(MsnOim *oim, const char *body); | 43 static gchar *msn_oim_msg_to_str(MsnOim *oim, const char *body); |
44 static void msn_oim_send_process(MsnOim *oim, const char *body, int len); | 44 static void msn_oim_send_process(MsnOim *oim, const char *body, int len); |
45 | 45 |
46 /*new a OIM object*/ | 46 /*new a OIM object*/ |
47 MsnOim * | 47 MsnOim * |
48 msn_oim_new(MsnSession *session) | 48 msn_oim_new(MsnSession *session) |
113 | 113 |
114 /**************************************** | 114 /**************************************** |
115 * OIM send SOAP request | 115 * OIM send SOAP request |
116 * **************************************/ | 116 * **************************************/ |
117 /*encode the message to OIM Message Format*/ | 117 /*encode the message to OIM Message Format*/ |
118 static char * | 118 static gchar * |
119 msn_oim_msg_to_str(MsnOim *oim, const char *body) | 119 msn_oim_msg_to_str(MsnOim *oim, const char *body) |
120 { | 120 { |
121 char *oim_body,*oim_base64; | 121 char *oim_body,*oim_base64; |
122 | 122 |
123 purple_debug_info("MSN OIM","encode OIM Message...\n"); | 123 purple_debug_info("MSN OIM","encode OIM Message...\n"); |
124 oim_base64 = purple_base64_encode((const guchar *)body, strlen(body)); | 124 oim_base64 = purple_base64_encode((const guchar *)body, strlen(body)); |
125 purple_debug_info("MSN OIM","encoded base64 body:{%s}\n",oim_base64); | 125 purple_debug_info("MSN OIM","encoded base64 body:{%s}\n",oim_base64); |
126 oim_body = g_strdup_printf(MSN_OIM_MSG_TEMPLATE, | 126 oim_body = g_strdup_printf(MSN_OIM_MSG_TEMPLATE, |
127 oim->run_id,oim->send_seq,oim_base64); | 127 oim->run_id,oim->send_seq,oim_base64); |
128 g_free(oim_base64); | |
128 | 129 |
129 return oim_body; | 130 return oim_body; |
130 } | 131 } |
131 | 132 |
132 /*oim SOAP server login error*/ | 133 /*oim SOAP server login error*/ |
278 msn_oim_send_msg(MsnOim *oim) | 279 msn_oim_send_msg(MsnOim *oim) |
279 { | 280 { |
280 MsnSoapReq *soap_request; | 281 MsnSoapReq *soap_request; |
281 MsnOimSendReq *oim_request; | 282 MsnOimSendReq *oim_request; |
282 char *soap_body,*mspauth; | 283 char *soap_body,*mspauth; |
283 char *msg_body; | 284 gchar *msg_body; |
284 char buf[33]; | 285 char buf[33]; |
285 | 286 |
286 g_return_if_fail(oim != NULL); | 287 g_return_if_fail(oim != NULL); |
287 oim_request = g_queue_pop_head(oim->send_queue); | 288 oim_request = g_queue_pop_head(oim->send_queue); |
288 g_return_if_fail(oim_request != NULL); | 289 g_return_if_fail(oim_request != NULL); |
360 /*Post to get the Offline Instant Message*/ | 361 /*Post to get the Offline Instant Message*/ |
361 static void | 362 static void |
362 msn_oim_post_delete_msg(MsnOim *oim,const char *msgid) | 363 msn_oim_post_delete_msg(MsnOim *oim,const char *msgid) |
363 { | 364 { |
364 MsnSoapReq *soap_request; | 365 MsnSoapReq *soap_request; |
365 const char *soap_body,*t,*p; | 366 gchar *soap_body; |
367 const char *t,*p; | |
366 | 368 |
367 g_return_if_fail(oim != NULL); | 369 g_return_if_fail(oim != NULL); |
368 g_return_if_fail(msgid != NULL); | 370 g_return_if_fail(msgid != NULL); |
369 | 371 |
370 purple_debug_info("MSN OIM","Delete single OIM Message {%s}\n",msgid); | 372 purple_debug_info("MSN OIM","Delete single OIM Message {%s}\n",msgid); |
382 soap_body, | 384 soap_body, |
383 NULL, | 385 NULL, |
384 msn_oim_delete_read_cb, | 386 msn_oim_delete_read_cb, |
385 msn_oim_delete_written_cb, | 387 msn_oim_delete_written_cb, |
386 msn_oim_retrieve_connect_init); | 388 msn_oim_retrieve_connect_init); |
389 g_free(soap_body); | |
387 msn_soap_post(oim->retrieveconn,soap_request); | 390 msn_soap_post(oim->retrieveconn,soap_request); |
388 } | 391 } |
389 | 392 |
390 /**************************************** | 393 /**************************************** |
391 * OIM get SOAP request | 394 * OIM get SOAP request |
667 /*Post to get the Offline Instant Message*/ | 670 /*Post to get the Offline Instant Message*/ |
668 static void | 671 static void |
669 msn_oim_post_single_get_msg(MsnOim *oim,const char *msgid) | 672 msn_oim_post_single_get_msg(MsnOim *oim,const char *msgid) |
670 { | 673 { |
671 MsnSoapReq *soap_request; | 674 MsnSoapReq *soap_request; |
672 const char *soap_body,*t,*p; | 675 gchar *soap_body; |
676 const char *t,*p; | |
673 | 677 |
674 purple_debug_info("MSN OIM","Get single OIM Message\n"); | 678 purple_debug_info("MSN OIM","Get single OIM Message\n"); |
675 t = oim->session->passport_info.t; | 679 t = oim->session->passport_info.t; |
676 p = oim->session->passport_info.p; | 680 p = oim->session->passport_info.p; |
677 | 681 |
686 soap_body, | 690 soap_body, |
687 NULL, | 691 NULL, |
688 msn_oim_get_read_cb, | 692 msn_oim_get_read_cb, |
689 msn_oim_get_written_cb, | 693 msn_oim_get_written_cb, |
690 msn_oim_retrieve_connect_init); | 694 msn_oim_retrieve_connect_init); |
695 g_free(soap_body); | |
691 msn_soap_post(oim->retrieveconn,soap_request); | 696 msn_soap_post(oim->retrieveconn,soap_request); |
692 } | 697 } |
693 | 698 |
694 /*msn oim retrieve server connect init */ | 699 /*msn oim retrieve server connect init */ |
695 static void | 700 static void |