changeset 29536:75780bc426d0

ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
author Paul Aurich <paul@darkrain42.org>
date Fri, 05 Mar 2010 22:20:00 +0000
parents 1cc870f328ab
children 1b861e13ae45
files libpurple/ft.c
diffstat 1 files changed, 34 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/ft.c	Fri Mar 05 22:15:16 2010 +0000
+++ b/libpurple/ft.c	Fri Mar 05 22:20:00 2010 +0000
@@ -1088,6 +1088,7 @@
 		size_t result = 0;
 		size_t s = MIN(purple_xfer_get_bytes_remaining(xfer), xfer->current_buffer_size);
 		PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer);
+		gboolean read = TRUE;
 
 		/* this is so the prpl can keep the connection open
 		   if it needs to for some odd reason. */
@@ -1099,41 +1100,41 @@
 			return;
 		}
 
-		if (ui_ops && ui_ops->ui_read) {
-			gssize tmp = ui_ops->ui_read(xfer, &buffer, s);
-			if (tmp == 0) {
-				/*
-				 * The UI claimed it was ready, but didn't have any data for
-				 * us...  It will call purple_xfer_ui_ready when ready, which
-				 * sets back up this watcher.
-				 */
-				if (xfer->watcher != 0) {
-					purple_input_remove(xfer->watcher);
-					xfer->watcher = 0;
+		if (priv->buffer) {
+			if (priv->buffer->len < s) {
+				s -= priv->buffer->len;
+				read = TRUE;
+			} else {
+				read = FALSE;
+			}
+		}
+
+		if (read) {
+			if (ui_ops && ui_ops->ui_read) {
+				gssize tmp = ui_ops->ui_read(xfer, &buffer, s);
+				if (tmp == 0) {
+					/*
+					 * The UI claimed it was ready, but didn't have any data for
+					 * us...  It will call purple_xfer_ui_ready when ready, which
+					 * sets back up this watcher.
+					 */
+					if (xfer->watcher != 0) {
+						purple_input_remove(xfer->watcher);
+						xfer->watcher = 0;
+					}
+
+					/* Need to indicate the prpl is still ready... */
+					priv->ready |= PURPLE_XFER_READY_PRPL;
+
+					g_return_if_reached();
+				} else if (tmp < 0) {
+					purple_debug_error("filetransfer", "Unable to read whole buffer.\n");
+					purple_xfer_cancel_local(xfer);
+					return;
 				}
 
-				/* Need to indicate the prpl is still ready... */
-				priv->ready |= PURPLE_XFER_READY_PRPL;
-
-				g_return_if_reached();
-			} else if (tmp < 0) {
-				purple_debug_error("filetransfer", "Unable to read whole buffer.\n");
-				purple_xfer_cancel_local(xfer);
-				return;
-			}
-
-			result = tmp;
-		} else {
-			gboolean read = TRUE;
-			if (priv->buffer) {
-				if (priv->buffer->len < s) {
-					s -= priv->buffer->len;
-					read = TRUE;
-				} else {
-					read = FALSE;
-				}
-			}
-			if (read) {
+				result = tmp;
+			} else {
 				buffer = g_malloc(s);
 				result = fread(buffer, 1, s, xfer->dest_fp);
 				if (result != s) {