comparison libpurple/ft.c @ 27901:c93ed4d7cabe

merge of 'abdecd59fbf18da0d4f391df390910b525356ffb' and 'f005961acc673854916055d8bc491c28f9fb63f0'
author Paul Aurich <paul@darkrain42.org>
date Thu, 13 Aug 2009 03:28:38 +0000
parents dad4cb8f81df
children e30de9ebfa69
comparison
equal deleted inserted replaced
27900:32a707746454 27901:c93ed4d7cabe
535 535
536 purple_xfer_unref(xfer); 536 purple_xfer_unref(xfer);
537 return; 537 return;
538 } 538 }
539 539
540 if (ui_ops == NULL || (ui_ops->read == NULL && ui_ops->write == NULL)) { 540 if (ui_ops == NULL || (ui_ops->ui_read == NULL && ui_ops->ui_write == NULL)) {
541 if (g_stat(filename, &st) == -1) { 541 if (g_stat(filename, &st) == -1) {
542 purple_xfer_show_file_error(xfer, filename); 542 purple_xfer_show_file_error(xfer, filename);
543 purple_xfer_unref(xfer); 543 purple_xfer_unref(xfer);
544 return; 544 return;
545 } 545 }
991 991
992 if (xfer->type == PURPLE_XFER_RECEIVE) { 992 if (xfer->type == PURPLE_XFER_RECEIVE) {
993 r = purple_xfer_read(xfer, &buffer); 993 r = purple_xfer_read(xfer, &buffer);
994 if (r > 0) { 994 if (r > 0) {
995 size_t wc; 995 size_t wc;
996 if (ui_ops && ui_ops->write) 996 if (ui_ops && ui_ops->ui_write)
997 wc = ui_ops->write(xfer, buffer, r); 997 wc = ui_ops->ui_write(xfer, buffer, r);
998 else 998 else
999 wc = fwrite(buffer, 1, r, xfer->dest_fp); 999 wc = fwrite(buffer, 1, r, xfer->dest_fp);
1000 1000
1001 if (wc != r) { 1001 if (wc != r) {
1002 purple_debug_error("filetransfer", "Unable to write whole buffer.\n"); 1002 purple_debug_error("filetransfer", "Unable to write whole buffer.\n");
1021 xfer->watcher = 0; 1021 xfer->watcher = 0;
1022 } 1022 }
1023 return; 1023 return;
1024 } 1024 }
1025 1025
1026 if (ui_ops && ui_ops->read) { 1026 if (ui_ops && ui_ops->ui_read) {
1027 gssize tmp = ui_ops->read(xfer, &buffer, s); 1027 gssize tmp = ui_ops->ui_read(xfer, &buffer, s);
1028 if (tmp == 0) { 1028 if (tmp == 0) {
1029 /* 1029 /*
1030 * UI isn't ready to send data. It will call 1030 * UI isn't ready to send data. It will call
1031 * purple_xfer_ui_ready when ready, which sets back up this 1031 * purple_xfer_ui_ready when ready, which sets back up this
1032 * watcher. 1032 * watcher.
1061 if (r == -1) { 1061 if (r == -1) {
1062 purple_xfer_cancel_remote(xfer); 1062 purple_xfer_cancel_remote(xfer);
1063 g_free(buffer); 1063 g_free(buffer);
1064 return; 1064 return;
1065 } else if (r < result) { 1065 } else if (r < result) {
1066 if (ui_ops == NULL || (ui_ops->read == NULL && ui_ops->write == NULL)) { 1066 if (ui_ops == NULL || (ui_ops->ui_read == NULL && ui_ops->ui_write == NULL)) {
1067 /* We have to seek back in the file now. */ 1067 /* We have to seek back in the file now. */
1068 fseek(xfer->dest_fp, r - s, SEEK_CUR); 1068 fseek(xfer->dest_fp, r - s, SEEK_CUR);
1069 } 1069 }
1070 else { 1070 else {
1071 ui_ops->data_not_sent(xfer, buffer + r, result - r); 1071 ui_ops->data_not_sent(xfer, buffer + r, result - r);
1124 begin_transfer(PurpleXfer *xfer, PurpleInputCondition cond) 1124 begin_transfer(PurpleXfer *xfer, PurpleInputCondition cond)
1125 { 1125 {
1126 PurpleXferType type = purple_xfer_get_type(xfer); 1126 PurpleXferType type = purple_xfer_get_type(xfer);
1127 PurpleXferUiOps *ui_ops = purple_xfer_get_ui_ops(xfer); 1127 PurpleXferUiOps *ui_ops = purple_xfer_get_ui_ops(xfer);
1128 1128
1129 if (ui_ops == NULL || (ui_ops->read == NULL && ui_ops->write == NULL)) { 1129 if (ui_ops == NULL || (ui_ops->ui_read == NULL && ui_ops->ui_write == NULL)) {
1130 xfer->dest_fp = g_fopen(purple_xfer_get_local_filename(xfer), 1130 xfer->dest_fp = g_fopen(purple_xfer_get_local_filename(xfer),
1131 type == PURPLE_XFER_RECEIVE ? "wb" : "rb"); 1131 type == PURPLE_XFER_RECEIVE ? "wb" : "rb");
1132 1132
1133 if (xfer->dest_fp == NULL) { 1133 if (xfer->dest_fp == NULL) {
1134 purple_xfer_show_file_error(xfer, purple_xfer_get_local_filename(xfer)); 1134 purple_xfer_show_file_error(xfer, purple_xfer_get_local_filename(xfer));