Mercurial > pidgin.yaz
comparison libpurple/protocols/bonjour/bonjour_ft.c @ 21441:da75dd6c41fb
Leak fix, cleanup and code reuse.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Mon, 12 Nov 2007 05:09:17 +0000 |
parents | d8106b63b0a4 |
children | e489c81e1f6f |
comparison
equal
deleted
inserted
replaced
21440:d8106b63b0a4 | 21441:da75dd6c41fb |
---|---|
301 BonjourData *bd = NULL; | 301 BonjourData *bd = NULL; |
302 if(xfer == NULL) { | 302 if(xfer == NULL) { |
303 purple_debug_info("Bonjour", "bonjour-free-xfer-null.\n"); | 303 purple_debug_info("Bonjour", "bonjour-free-xfer-null.\n"); |
304 return; | 304 return; |
305 } | 305 } |
306 purple_debug_info("Bonjour", "bonjour-free-xfer-%x.\n", (int)xfer); | 306 purple_debug_info("Bonjour", "bonjour-free-xfer-%p.\n", xfer); |
307 xf = (XepXfer*)xfer->data; | 307 xf = (XepXfer*)xfer->data; |
308 if(xf != NULL){ | 308 if(xf != NULL){ |
309 bd = (BonjourData*)xf->data; | 309 bd = (BonjourData*)xf->data; |
310 if(bd != NULL){ | 310 if(bd != NULL){ |
311 bd->xfer_lists = g_list_remove(bd->xfer_lists, xfer); | 311 bd->xfer_lists = g_list_remove(bd->xfer_lists, xfer); |
312 purple_debug_info("Bonjour", "B free xfer from lists(0x%x).\n", (int)bd->xfer_lists); | 312 purple_debug_info("Bonjour", "B free xfer from lists(%p).\n", bd->xfer_lists); |
313 } | 313 } |
314 if (xf->proxy_connection != NULL) | 314 if (xf->proxy_connection != NULL) |
315 purple_proxy_connect_cancel(xf->proxy_connection); | 315 purple_proxy_connect_cancel(xf->proxy_connection); |
316 if (xf->listen_data != NULL) | 316 if (xf->listen_data != NULL) |
317 purple_network_listen_cancel(xf->listen_data); | 317 purple_network_listen_cancel(xf->listen_data); |
318 g_free(xf->jid); | 318 g_free(xf->jid); |
319 g_free(xf->proxy_host); | 319 g_free(xf->proxy_host); |
320 g_free(xf->buddy_ip); | 320 g_free(xf->buddy_ip); |
321 g_free(xf->sid); | |
321 g_free(xf); | 322 g_free(xf); |
322 xfer->data = NULL; | 323 xfer->data = NULL; |
323 } | 324 } |
324 purple_debug_info("Bonjour", "Need close socket=0x%x.\n", xfer->fd); | 325 purple_debug_info("Bonjour", "Need close socket=%d.\n", xfer->fd); |
325 } | 326 } |
326 | 327 |
327 PurpleXfer * | 328 PurpleXfer * |
328 bonjour_new_xfer(PurpleConnection *gc, const char *who) | 329 bonjour_new_xfer(PurpleConnection *gc, const char *who) |
329 { | 330 { |
345 if(xep_xfer == NULL){ | 346 if(xep_xfer == NULL){ |
346 bonjour_free_xfer(xfer); | 347 bonjour_free_xfer(xfer); |
347 return NULL; | 348 return NULL; |
348 } | 349 } |
349 xep_xfer->data = bd; | 350 xep_xfer->data = bd; |
350 purple_debug_info("Bonjour", "Bonjour-new-xfer bd=0x%x data=0x%x.\n",(int)bd, (int)xep_xfer->data); | 351 purple_debug_info("Bonjour", "Bonjour-new-xfer bd=%p data=%p.\n", bd, xep_xfer->data); |
351 xep_xfer->mode = XEP_BYTESTREAMS | XEP_IBB; | 352 xep_xfer->mode = XEP_BYTESTREAMS | XEP_IBB; |
352 xfer->data = xep_xfer; | 353 xfer->data = xep_xfer; |
353 xep_xfer->sid = NULL; | 354 xep_xfer->sid = NULL; |
354 purple_xfer_set_init_fnc(xfer, bonjour_xfer_init); | 355 purple_xfer_set_init_fnc(xfer, bonjour_xfer_init); |
355 purple_xfer_set_cancel_send_fnc(xfer, bonjour_xfer_cancel_send); | 356 purple_xfer_set_cancel_send_fnc(xfer, bonjour_xfer_cancel_send); |
459 purple_debug_info("Bonjour", "xfer find fail.\n"); | 460 purple_debug_info("Bonjour", "xfer find fail.\n"); |
460 } else { | 461 } else { |
461 purple_xfer_cancel_remote(xfer); | 462 purple_xfer_cancel_remote(xfer); |
462 } | 463 } |
463 } else { | 464 } else { |
464 purple_debug_info("Bonjour", "si offer Message type - Unknown-%d.\n",type); | 465 purple_debug_info("Bonjour", "si offer Message type - Unknown-%d.\n", type); |
465 } | 466 } |
466 } | 467 } |
467 } | 468 } |
468 | 469 |
469 void | 470 void |
502 if(!strcmp(host, xf->buddy_ip)) { | 503 if(!strcmp(host, xf->buddy_ip)) { |
503 xf->jid = g_strdup(jid); | 504 xf->jid = g_strdup(jid); |
504 xf->proxy_host = g_strdup(host); | 505 xf->proxy_host = g_strdup(host); |
505 xf->proxy_port = portnum; | 506 xf->proxy_port = portnum; |
506 purple_debug_info("Bonjour", "bytestream offer parse" | 507 purple_debug_info("Bonjour", "bytestream offer parse" |
507 "jid=%s host=%s port=0x%x.\n",jid, host, portnum); | 508 "jid=%s host=%s port=%d.\n", jid, host, portnum); |
508 bonjour_bytestreams_connect(xfer); | 509 bonjour_bytestreams_connect(xfer); |
509 } | 510 } |
510 } else { | 511 } else { |
511 purple_debug_info("Bonjour", "bytestream offer Message parse error.\n"); | 512 purple_debug_info("Bonjour", "bytestream offer Message parse error.\n"); |
512 } | 513 } |
514 } else { | 515 } else { |
515 | 516 |
516 } | 517 } |
517 | 518 |
518 } else { | 519 } else { |
519 purple_debug_info("Bonjour", "bytestream offer Message type - Unknown-%d.\n",type); | 520 purple_debug_info("Bonjour", "bytestream offer Message type - Unknown-%d.\n", type); |
520 } | 521 } |
521 } | 522 } |
522 } | 523 } |
523 | 524 |
524 static void | 525 static void |
629 if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK )) { | 630 if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK )) { |
630 | 631 |
631 } else if(acceptfd == -1) { | 632 } else if(acceptfd == -1) { |
632 | 633 |
633 } else { | 634 } else { |
634 purple_debug_info("Bonjour", "Conjour-sock5-request-cb. state= %d, accept=%d\n", xf->sock5_req_state,acceptfd); | 635 purple_debug_info("Bonjour", "Conjour-sock5-request-cb. state= %d, accept=%d\n", xf->sock5_req_state, acceptfd); |
635 purple_input_remove(xfer->watcher); | 636 purple_input_remove(xfer->watcher); |
636 close(source); | 637 close(source); |
637 xfer->watcher = purple_input_add(acceptfd, PURPLE_INPUT_READ, | 638 xfer->watcher = purple_input_add(acceptfd, PURPLE_INPUT_READ, |
638 bonjour_sock5_request_cb, xfer); | 639 bonjour_sock5_request_cb, xfer); |
639 xf->sock5_req_state++; | 640 xf->sock5_req_state++; |