Mercurial > pidgin
comparison libpurple/protocols/yahoo/yahoo_filexfer.c @ 26168:1520b67d792f
When acting as a p2p server, send HTTP OK after receiving file.
author | Sulabh Mahajan <sulabh@soc.pidgin.im> |
---|---|
date | Sun, 01 Mar 2009 09:50:59 +0000 |
parents | eb21f65728c0 |
children | 430298a61512 |
comparison
equal
deleted
inserted
replaced
26167:4cbe258db067 | 26168:1520b67d792f |
---|---|
607 if (xfer_data) | 607 if (xfer_data) |
608 yahoo_xfer_data_free(xfer_data); | 608 yahoo_xfer_data_free(xfer_data); |
609 xfer->data = NULL; | 609 xfer->data = NULL; |
610 } | 610 } |
611 | 611 |
612 /* Send HTTP OK after receiving file */ | |
613 static void yahoo_p2p_ft_server_send_OK(PurpleXfer *xfer) | |
614 { | |
615 char *tx = NULL; | |
616 int written; | |
617 | |
618 tx = g_strdup_printf("HTTP/1.1 200 OK\r\nContent-Length: 0\r\nContent-Type: application/octet-stream\r\nConnection: close\r\n\r\n"); | |
619 written = write(xfer->fd, tx, strlen(tx)); | |
620 | |
621 if (written < 0 && errno == EAGAIN) | |
622 written = 0; | |
623 else if (written <= 0) | |
624 purple_debug_info("yahoo", "p2p filetransfer: Unable to write HTTP OK"); | |
625 | |
626 /* close connection */ | |
627 close(xfer->fd); | |
628 xfer->fd = -1; | |
629 g_free(tx); | |
630 } | |
631 | |
612 static void yahoo_xfer_end(PurpleXfer *xfer_old) | 632 static void yahoo_xfer_end(PurpleXfer *xfer_old) |
613 { | 633 { |
614 struct yahoo_xfer_data *xfer_data; | 634 struct yahoo_xfer_data *xfer_data; |
615 PurpleXfer *xfer = NULL; | 635 PurpleXfer *xfer = NULL; |
616 PurpleConnection *gc; | 636 PurpleConnection *gc; |
618 | 638 |
619 xfer_data = xfer_old->data; | 639 xfer_data = xfer_old->data; |
620 if(xfer_data && xfer_data->version == 15 | 640 if(xfer_data && xfer_data->version == 15 |
621 && purple_xfer_get_type(xfer_old) == PURPLE_XFER_RECEIVE | 641 && purple_xfer_get_type(xfer_old) == PURPLE_XFER_RECEIVE |
622 && xfer_data->filename_list) { | 642 && xfer_data->filename_list) { |
643 | |
644 /* Send HTTP OK in case of p2p transfer, when we act as server */ | |
645 if((xfer_data->xfer_url != NULL) && (xfer_old->fd >=0) && (purple_xfer_get_status(xfer_old) == PURPLE_XFER_STATUS_DONE)) | |
646 yahoo_p2p_ft_server_send_OK(xfer_old); | |
623 | 647 |
624 /* removing top of filename & size list completely */ | 648 /* removing top of filename & size list completely */ |
625 g_free( xfer_data->filename_list->data ); | 649 g_free( xfer_data->filename_list->data ); |
626 g_free( xfer_data->size_list->data ); | 650 g_free( xfer_data->size_list->data ); |
627 | 651 |