Thread (22 messages) flat view 22 messages, 3 authors, 2012-03-19

Re: [PATCH obexd v0 03/11] client: refactor transfer callback use

From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Date: 2012-03-19 12:59:37

Hi Mikel,

On Mon, Mar 12, 2012 at 10:32 AM, Mikel Astiz [off-list ref] wrote:
quoted hunk ↗ jump to hunk
From: Mikel Astiz <redacted>

Separated internal functions are used to report success, failure, and
progress, instead of using the callback directly.

This makes the code more readable.
---
 client/transfer.c |   86 ++++++++++++++++++++++++++++++++--------------------
 1 files changed, 53 insertions(+), 33 deletions(-)
diff --git a/client/transfer.c b/client/transfer.c
index a609aa9..f2a153c 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -138,10 +138,47 @@ static DBusMessage *obc_transfer_get_properties(DBusConnection *connection,
       return reply;
 }

-static void obc_transfer_abort(struct obc_transfer *transfer)
+static void transfer_notify_progress(struct obc_transfer *transfer)
+{
+       struct transfer_callback *callback = transfer->callback;
+
+       DBG("%p", transfer);
+
+       if ((callback != NULL) && (transfer->transferred != transfer->size))
+               callback->func(transfer, transfer->transferred, NULL,
+                                                               callback->data);
+}
Usually we use early returns and simple statements to be more
readable, so if (callback == NULL) return would have been better. Also
I guess we don't really need this check for transferred != size since
gobex has a complete callback and latter you set it to NULL.


-- 
Luiz Augusto von Dentz
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help