From: Mikel Astiz <mikel.astiz.oss@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Mikel Astiz <mikel.astiz@bmw-carit.de>
Subject: [PATCH obexd v1 10/16] client: Remove internal transfer progress report
Date: Fri, 25 May 2012 12:11:27 +0200 [thread overview]
Message-ID: <1337940693-3417-11-git-send-email-mikel.astiz.oss@gmail.com> (raw)
In-Reply-To: <1337940693-3417-1-git-send-email-mikel.astiz.oss@gmail.com>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
The new D-Bus API uses signals to report the progress updates, so the
internal progress callback is not needed any more.
---
client/session.c | 25 ++++++-------------------
client/transfer.c | 18 +++---------------
client/transfer.h | 3 +--
3 files changed, 10 insertions(+), 36 deletions(-)
diff --git a/client/session.c b/client/session.c
index 989439c..8e21da4 100644
--- a/client/session.c
+++ b/client/session.c
@@ -103,9 +103,8 @@ static void session_start_transfer(gpointer data, gpointer user_data);
static void session_terminate_transfer(struct obc_session *session,
struct obc_transfer *transfer,
GError *gerr);
-static void transfer_progress(struct obc_transfer *transfer,
- gint64 transferred, GError *err,
- void *user_data);
+static void transfer_complete(struct obc_transfer *transfer,
+ GError *err, void *user_data);
static GQuark obex_io_error_quark(void)
{
@@ -669,7 +668,7 @@ guint obc_session_queue(struct obc_session *session,
return 0;
}
- obc_transfer_set_callback(transfer, transfer_progress, session);
+ obc_transfer_set_callback(transfer, transfer_complete, session);
p = pending_request_new(session, transfer, session_start_transfer,
func, user_data);
@@ -786,27 +785,15 @@ static void session_notify_error(struct obc_session *session,
session_terminate_transfer(session, transfer, err);
}
-static void session_notify_progress(struct obc_session *session,
- struct obc_transfer *transfer,
- gint64 transferred)
-{
- DBG("Transfer(%p) progress: %ld bytes", transfer,
- (long int ) transferred);
-
- if (transferred == obc_transfer_get_size(transfer))
- session_notify_complete(session, transfer);
-}
-
-static void transfer_progress(struct obc_transfer *transfer,
- gint64 transferred, GError *err,
- void *user_data)
+static void transfer_complete(struct obc_transfer *transfer,
+ GError *err, void *user_data)
{
struct obc_session *session = user_data;
if (err != 0)
goto fail;
- session_notify_progress(session, transfer, transferred);
+ session_notify_complete(session, transfer);
return;
diff --git a/client/transfer.c b/client/transfer.c
index f631843..4599995 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -136,15 +136,13 @@ static void abort_complete(GObex *obex, GError *err, gpointer user_data)
return;
if (err) {
- callback->func(transfer, transfer->transferred, err,
- callback->data);
+ callback->func(transfer, err, callback->data);
} else {
GError *abort_err;
abort_err = g_error_new(OBC_TRANSFER_ERROR, -ECANCELED, "%s",
"Transfer cancelled by user");
- callback->func(transfer, transfer->transferred, abort_err,
- callback->data);
+ callback->func(transfer, abort_err, callback->data);
g_error_free(abort_err);
}
}
@@ -429,7 +427,6 @@ static gboolean get_xfer_progress(const void *buf, gsize len,
gpointer user_data)
{
struct obc_transfer *transfer = user_data;
- struct transfer_callback *callback = transfer->callback;
if (transfer->fd > 0) {
gint w;
@@ -441,10 +438,6 @@ static gboolean get_xfer_progress(const void *buf, gsize len,
transfer->transferred += w;
}
- if (callback && transfer->transferred != transfer->size)
- callback->func(transfer, transfer->transferred, NULL,
- callback->data);
-
transfer_notify_progress(transfer);
return TRUE;
@@ -472,7 +465,7 @@ static void xfer_complete(GObex *obex, GError *err, gpointer user_data)
DBUS_TYPE_INVALID);
if (callback)
- callback->func(transfer, transfer->size, err, callback->data);
+ callback->func(transfer, err, callback->data);
}
static void get_xfer_progress_first(GObex *obex, GError *err, GObexPacket *rsp,
@@ -539,17 +532,12 @@ static void get_xfer_progress_first(GObex *obex, GError *err, GObexPacket *rsp,
static gssize put_xfer_progress(void *buf, gsize len, gpointer user_data)
{
struct obc_transfer *transfer = user_data;
- struct transfer_callback *callback = transfer->callback;
gssize size;
size = read(transfer->fd, buf, len);
if (size <= 0)
return size;
- if (callback)
- callback->func(transfer, transfer->transferred, NULL,
- callback->data);
-
transfer->transferred += size;
transfer_notify_progress(transfer);
diff --git a/client/transfer.h b/client/transfer.h
index bfa166d..15c157a 100644
--- a/client/transfer.h
+++ b/client/transfer.h
@@ -24,8 +24,7 @@
struct obc_transfer;
typedef void (*transfer_callback_t) (struct obc_transfer *transfer,
- gint64 transferred, GError *err,
- void *user_data);
+ GError *err, void *user_data);
struct obc_transfer *obc_transfer_get(const char *type, const char *name,
const char *filename, GError **err);
--
1.7.7.6
next prev parent reply other threads:[~2012-05-25 10:11 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-25 10:11 [PATCH obexd v1 00/16] client: Remove D-Bus agent Mikel Astiz
2012-05-25 10:11 ` [PATCH obexd v1 01/16] client: Add D-Bus helper library Mikel Astiz
2012-05-25 10:11 ` [PATCH obexd v1 02/16] client-doc: Add progress property to transfer Mikel Astiz
2012-05-25 10:11 ` [PATCH obexd v1 03/16] client: " Mikel Astiz
2012-05-25 10:15 ` Mikel Astiz
2012-05-25 10:35 ` Luiz Augusto von Dentz
2012-05-25 10:45 ` Mikel Astiz
2012-05-25 10:55 ` Luiz Augusto von Dentz
2012-05-25 11:02 ` Mikel Astiz
2012-05-25 10:11 ` [PATCH obexd v1 04/16] client-doc: Add transfer event-reporting signals Mikel Astiz
2012-05-25 10:50 ` Luiz Augusto von Dentz
2012-05-25 10:57 ` Mikel Astiz
2012-05-25 10:11 ` [PATCH obexd v1 05/16] client: " Mikel Astiz
2012-05-25 10:11 ` [PATCH obexd v1 06/16] client-doc: Remove D-Bus agent Mikel Astiz
2012-05-25 10:11 ` [PATCH obexd v1 07/16] client: Use transfer owner instead of agent Mikel Astiz
2012-05-25 10:11 ` [PATCH obexd v1 08/16] client: Remove D-Bus agent Mikel Astiz
2012-05-25 10:11 ` [PATCH obexd v1 09/16] client: Remove unused functions in transfer API Mikel Astiz
2012-05-25 10:11 ` Mikel Astiz [this message]
2012-05-25 10:11 ` [PATCH obexd v1 11/16] client: Remove obsolete authentication code Mikel Astiz
2012-05-25 10:11 ` [PATCH obexd v1 12/16] client: Make D-Bus exposure of transfers optional Mikel Astiz
2012-05-25 10:11 ` [PATCH obexd v1 13/16] client-doc: Add signal to report new transfers Mikel Astiz
2012-05-25 10:11 ` [PATCH obexd v1 14/16] client: Expose D-Bus data in internal transfer API Mikel Astiz
2012-05-25 10:11 ` [PATCH obexd v1 15/16] client: Add signal to report new transfers Mikel Astiz
2012-05-25 10:11 ` [PATCH obexd v1 16/16] client-test: Remove agent from ftp-client Mikel Astiz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1337940693-3417-11-git-send-email-mikel.astiz.oss@gmail.com \
--to=mikel.astiz.oss@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=mikel.astiz@bmw-carit.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox