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/2] client: Return request id when generating a request in session API
Date: Thu, 26 Apr 2012 17:37:59 +0300	[thread overview]
Message-ID: <1335451079-11868-2-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1335451079-11868-1-git-send-email-luiz.dentz@gmail.com>

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

This is more consistent with other functions and allow the caller to
cancel the request using obc_session_cancel.
---
 client/session.c |   16 ++++++++--------
 client/session.h |    8 ++++----
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/client/session.c b/client/session.c
index 1c923f4..92d3626 100644
--- a/client/session.c
+++ b/client/session.c
@@ -743,7 +743,7 @@ static int pending_request_auth(struct pending_request *p)
 									NULL);
 }
 
-static gboolean session_request(struct obc_session *session,
+static guint session_request(struct obc_session *session,
 					struct obc_transfer *transfer,
 					session_callback_t func,
 					void *data, GError **err)
@@ -757,19 +757,19 @@ static gboolean session_request(struct obc_session *session,
 								func, data);
 	if (session->p) {
 		g_queue_push_tail(session->queue, p);
-		return TRUE;
+		return p->id;
 	}
 
 	perr = pending_request_auth(p);
 	if (perr < 0) {
 		g_set_error(err, OBEX_IO_ERROR, perr, "Authorization failed");
 		pending_request_free(p);
-		return FALSE;
+		return 0;
 	}
 
 	session->p = p;
 
-	return TRUE;
+	return p->id;
 }
 
 static void session_process_queue(struct obc_session *session)
@@ -946,7 +946,7 @@ static void session_start_transfer(gpointer data, gpointer user_data)
 	DBG("Transfer(%p) started", transfer);
 }
 
-gboolean obc_session_get(struct obc_session *session, const char *type,
+guint obc_session_get(struct obc_session *session, const char *type,
 				const char *name, const char *targetfile,
 				const guint8 *apparam, gint apparam_size,
 				session_callback_t func, void *user_data,
@@ -987,7 +987,7 @@ gboolean obc_session_get(struct obc_session *session, const char *type,
 	return session_request(session, transfer, func, user_data, err);
 }
 
-gboolean obc_session_send(struct obc_session *session, const char *filename,
+guint obc_session_send(struct obc_session *session, const char *filename,
 				const char *name, GError **err)
 {
 	struct obc_transfer *transfer;
@@ -1006,7 +1006,7 @@ gboolean obc_session_send(struct obc_session *session, const char *filename,
 	return session_request(session, transfer, NULL, NULL, err);
 }
 
-gboolean obc_session_pull(struct obc_session *session,
+guint obc_session_pull(struct obc_session *session,
 				const char *type, const char *targetfile,
 				session_callback_t function, void *user_data,
 				GError **err)
@@ -1045,7 +1045,7 @@ fail:
 	return NULL;
 }
 
-gboolean obc_session_put(struct obc_session *session, const char *contents,
+guint obc_session_put(struct obc_session *session, const char *contents,
 				size_t size, const char *name, GError **err)
 {
 	struct obc_transfer *transfer;
diff --git a/client/session.h b/client/session.h
index a0ee321..c443392 100644
--- a/client/session.h
+++ b/client/session.h
@@ -56,20 +56,20 @@ int obc_session_get_contents(struct obc_session *session, char **contents,
 								size_t *size);
 void *obc_session_get_params(struct obc_session *session, size_t *size);
 
-gboolean obc_session_send(struct obc_session *session, const char *filename,
+guint obc_session_send(struct obc_session *session, const char *filename,
 				const char *name, GError **err);
-gboolean obc_session_get(struct obc_session *session, const char *type,
+guint obc_session_get(struct obc_session *session, const char *type,
 				const char *name, const char *targetfile,
 				const guint8  *apparam, gint apparam_size,
 				session_callback_t func, void *user_data,
 				GError **err);
-gboolean obc_session_pull(struct obc_session *session,
+guint obc_session_pull(struct obc_session *session,
 				const char *type, const char *targetfile,
 				session_callback_t function, void *user_data,
 				GError **err);
 const char *obc_session_register(struct obc_session *session,
 						GDBusDestroyFunction destroy);
-gboolean obc_session_put(struct obc_session *session, const char *contents,
+guint obc_session_put(struct obc_session *session, const char *contents,
 				size_t size, const char *name, GError **err);
 
 guint obc_session_setpath(struct obc_session *session, const char *path,
-- 
1.7.7.6


  reply	other threads:[~2012-04-26 14:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-26 14:37 [PATCH obexd 1/2] client: Fix not propagating GError in session API functions Luiz Augusto von Dentz
2012-04-26 14:37 ` Luiz Augusto von Dentz [this message]
2012-04-26 14:58 ` Johan Hedberg
2012-04-26 15:01   ` Luiz Augusto von Dentz
2012-04-26 15:05 ` 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=1335451079-11868-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).