linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH obexd 2/3] gobex: introduce g_obex_get_rsp_pkt
Date: Wed, 11 Jan 2012 15:22:02 +0200	[thread overview]
Message-ID: <1326288123-31807-2-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1326288123-31807-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

g_obex_get_rsp_pkt takes a response packet which sometimes is more
convenient for adding headers.
---
 gobex/gobex-transfer.c |   35 +++++++++++++++++++++++------------
 gobex/gobex.h          |    4 ++++
 2 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/gobex/gobex-transfer.c b/gobex/gobex-transfer.c
index 614d2d1..a779e4f 100644
--- a/gobex/gobex-transfer.c
+++ b/gobex/gobex-transfer.c
@@ -543,16 +543,12 @@ static gssize get_get_data(void *buf, gsize len, gpointer user_data)
 	return ret;
 }
 
-static void transfer_get_req_first(struct transfer *transfer,
-					guint8 first_hdr_id, va_list args)
+static void transfer_get_req_first(struct transfer *transfer, GObexPacket *rsp)
 {
 	GError *err = NULL;
-	GObexPacket *rsp;
 
 	g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id);
 
-	rsp = g_obex_packet_new_valist(G_OBEX_RSP_CONTINUE, TRUE,
-							first_hdr_id, args);
 	g_obex_packet_add_body(rsp, get_get_data, transfer);
 
 	if (!g_obex_send(transfer->obex, rsp, &err)) {
@@ -578,12 +574,11 @@ static void transfer_get_req(GObex *obex, GObexPacket *req, gpointer user_data)
 	}
 }
 
-guint g_obex_get_rsp(GObex *obex, GObexDataProducer data_func,
-			GObexFunc complete_func, gpointer user_data,
-			GError **err, guint8 first_hdr_id, ...)
+guint g_obex_get_rsp_pkt(GObex *obex, GObexPacket *rsp,
+			GObexDataProducer data_func, GObexFunc complete_func,
+			gpointer user_data, GError **err)
 {
 	struct transfer *transfer;
-	va_list args;
 	guint id;
 
 	g_obex_debug(G_OBEX_DEBUG_TRANSFER, "obex %p", obex);
@@ -591,9 +586,7 @@ guint g_obex_get_rsp(GObex *obex, GObexDataProducer data_func,
 	transfer = transfer_new(obex, G_OBEX_OP_GET, complete_func, user_data);
 	transfer->data_producer = data_func;
 
-	va_start(args, first_hdr_id);
-	transfer_get_req_first(transfer, first_hdr_id, args);
-	va_end(args);
+	transfer_get_req_first(transfer, rsp);
 
 	if (!g_slist_find(transfers, transfer))
 		return 0;
@@ -611,6 +604,24 @@ guint g_obex_get_rsp(GObex *obex, GObexDataProducer data_func,
 	return transfer->id;
 }
 
+guint g_obex_get_rsp(GObex *obex, GObexDataProducer data_func,
+			GObexFunc complete_func, gpointer user_data,
+			GError **err, guint8 first_hdr_id, ...)
+{
+	GObexPacket *rsp;
+	va_list args;
+
+	g_obex_debug(G_OBEX_DEBUG_TRANSFER, "obex %p", obex);
+
+	va_start(args, first_hdr_id);
+	rsp = g_obex_packet_new_valist(G_OBEX_RSP_CONTINUE, TRUE,
+							first_hdr_id, args);
+	va_end(args);
+
+	return g_obex_get_rsp_pkt(obex, rsp, data_func, complete_func,
+							user_data, err);
+}
+
 gboolean g_obex_cancel_transfer(guint id)
 {
 	struct transfer *transfer = NULL;
diff --git a/gobex/gobex.h b/gobex/gobex.h
index f3a7f94..1c47c68 100644
--- a/gobex/gobex.h
+++ b/gobex/gobex.h
@@ -118,6 +118,10 @@ guint g_obex_get_rsp(GObex *obex, GObexDataProducer data_func,
 			GObexFunc complete_func, gpointer user_data,
 			GError **err, guint8 first_hdr_id, ...);
 
+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);
 
 const char *g_obex_strerror(guint8 err_code);
-- 
1.7.7.5


  reply	other threads:[~2012-01-11 13:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-11 13:22 [PATCH obexd 1/3] Fix not responding when driver_get_headers return 0 Luiz Augusto von Dentz
2012-01-11 13:22 ` Luiz Augusto von Dentz [this message]
2012-01-11 13:22 ` [PATCH obexd 3/3] Fix not responding SUCCESS code to GET in some conditions Luiz Augusto von Dentz
2012-01-11 13:55 ` [PATCH obexd 1/3] Fix not responding when driver_get_headers return 0 Johan Hedberg

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=1326288123-31807-2-git-send-email-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.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).