linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jaganath Kanakkassery <jaganath.k@samsung.com>
To: linux-bluetooth@vger.kernel.org
Cc: Jaganath Kanakkassery <jaganath.k@samsung.com>
Subject: [PATCH obexd v2 1/3] gobex: Add callback and userdata parameter to g_obex_cancel_transfer()
Date: Fri, 04 May 2012 15:27:04 +0530	[thread overview]
Message-ID: <1336125426-30445-1-git-send-email-jaganath.k@samsung.com> (raw)

If callback is provided in g_obex_cancel_transfer() current complete
callback will be replaced by the new one and user will be informed
when abort completes.
---
 gobex/gobex-transfer.c |   17 +++++++++++++++--
 gobex/gobex.c          |    4 ++--
 gobex/gobex.h          |    5 ++++-
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/gobex/gobex-transfer.c b/gobex/gobex-transfer.c
index c62a91e..724c788 100644
--- a/gobex/gobex-transfer.c
+++ b/gobex/gobex-transfer.c
@@ -624,9 +624,11 @@ guint g_obex_get_rsp(GObex *obex, GObexDataProducer data_func,
 							user_data, err);
 }
 
-gboolean g_obex_cancel_transfer(guint id)
+gboolean g_obex_cancel_transfer(guint id, GObexFunc complete_func,
+			gpointer user_data)
 {
 	struct transfer *transfer = NULL;
+	gboolean ret = TRUE;
 
 	g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", id);
 
@@ -635,6 +637,17 @@ gboolean g_obex_cancel_transfer(guint id)
 	if (transfer == NULL)
 		return FALSE;
 
+	if (complete_func == NULL)
+		goto done;
+
+	transfer->complete_func = complete_func;
+	transfer->user_data = user_data;
+
+	ret = g_obex_pending_req_abort(transfer->obex, NULL);
+	if (ret)
+		return TRUE;
+
+done:
 	transfer_free(transfer);
-	return TRUE;
+	return ret;
 }
diff --git a/gobex/gobex.c b/gobex/gobex.c
index f31b733..b20542d 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -684,7 +684,7 @@ static gint pending_pkt_cmp(gconstpointer a, gconstpointer b)
 	return (p->id - id);
 }
 
-static gboolean pending_req_abort(GObex *obex, GError **err)
+gboolean g_obex_pending_req_abort(GObex *obex, GError **err)
 {
 	struct pending_pkt *p = obex->pending_req;
 	GObexPacket *req;
@@ -728,7 +728,7 @@ gboolean g_obex_cancel_req(GObex *obex, guint req_id, gboolean remove_callback)
 	struct pending_pkt *p;
 
 	if (obex->pending_req && obex->pending_req->id == req_id) {
-		if (!pending_req_abort(obex, NULL)) {
+		if (!g_obex_pending_req_abort(obex, NULL)) {
 			p = obex->pending_req;
 			obex->pending_req = NULL;
 			goto immediate_completion;
diff --git a/gobex/gobex.h b/gobex/gobex.h
index aacdb53..3120da2 100644
--- a/gobex/gobex.h
+++ b/gobex/gobex.h
@@ -49,6 +49,8 @@ guint g_obex_send_req(GObex *obex, GObexPacket *req, gint timeout,
 gboolean g_obex_cancel_req(GObex *obex, guint req_id,
 						gboolean remove_callback);
 
+gboolean g_obex_pending_req_abort(GObex *obex, GError **err);
+
 gboolean g_obex_send_rsp(GObex *obex, guint8 rspcode, GError **err,
 						guint8 first_hdr_type, ...);
 
@@ -122,7 +124,8 @@ guint g_obex_get_rsp_pkt(GObex *obex, GObexPacket *rsp,
 			GObexDataProducer data_func, GObexFunc complete_func,
 			gpointer user_data, GError **err);
 
-gboolean g_obex_cancel_transfer(guint id);
+gboolean g_obex_cancel_transfer(guint id, GObexFunc complete_func,
+							gpointer user_data);
 
 const char *g_obex_strerror(guint8 err_code);
 guint8 g_obex_errno_to_rsp(int err);
-- 
1.7.1


             reply	other threads:[~2012-05-04  9:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-04  9:57 Jaganath Kanakkassery [this message]
2012-05-04  9:57 ` [PATCH obexd v2 2/3] client: Wait for abort completion before Transfer.Cancel returns Jaganath Kanakkassery
2012-05-04  9:57 ` [PATCH obexd v2 3/3] gobex: Remove g_idle_add to exit main loop in test_stream_put_req_abort() Jaganath Kanakkassery
2012-05-04 14:05 ` [PATCH obexd v2 1/3] gobex: Add callback and userdata parameter to g_obex_cancel_transfer() Luiz Augusto von Dentz

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=1336125426-30445-1-git-send-email-jaganath.k@samsung.com \
    --to=jaganath.k@samsung.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).