From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH obexd 4/6 v2] client: transfers take gobex when starting
Date: Fri, 20 Apr 2012 14:40:04 +0300 [thread overview]
Message-ID: <1334922006-19654-4-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1334922006-19654-1-git-send-email-luiz.dentz@gmail.com>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
gobex api should not be used by a transfer until it is started. This
seems more explicit if the pointer is not passed during creation.
---
client/session.c | 20 +++++++-------------
client/transfer.c | 6 +++---
client/transfer.h | 4 ++--
3 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/client/session.c b/client/session.c
index ab20b88..306e2ba 100644
--- a/client/session.c
+++ b/client/session.c
@@ -923,7 +923,7 @@ static void session_start_transfer(gpointer data, gpointer user_data)
struct obc_transfer *transfer = user_data;
GError *err = NULL;
- if (!obc_transfer_start(transfer, &err)) {
+ if (!obc_transfer_start(transfer, session->obex, &err)) {
session_notify_error(session, transfer, err);
g_clear_error(&err);
return;
@@ -956,10 +956,8 @@ int obc_session_get(struct obc_session *session, const char *type,
else
agent = NULL;
- transfer = obc_transfer_register(session->conn, session->obex,
- agent, G_OBEX_OP_GET,
- targetfile, name,
- type, params);
+ transfer = obc_transfer_register(session->conn, agent, G_OBEX_OP_GET,
+ targetfile, name, type, params);
if (transfer == NULL) {
if (params != NULL) {
g_free(params->data);
@@ -983,10 +981,8 @@ int obc_session_send(struct obc_session *session, const char *filename,
agent = obc_agent_get_name(session->agent);
- transfer = obc_transfer_register(session->conn, session->obex,
- agent, G_OBEX_OP_PUT,
- filename, name,
- NULL, NULL);
+ transfer = obc_transfer_register(session->conn, agent, G_OBEX_OP_PUT,
+ filename, name, NULL, NULL);
if (transfer == NULL)
return -EINVAL;
@@ -1049,10 +1045,8 @@ int obc_session_put(struct obc_session *session, const char *contents,
agent = obc_agent_get_name(session->agent);
- transfer = obc_transfer_register(session->conn, session->obex,
- agent, G_OBEX_OP_PUT,
- NULL, name,
- NULL, NULL);
+ transfer = obc_transfer_register(session->conn, agent, G_OBEX_OP_PUT,
+ NULL, name, NULL, NULL);
if (transfer == NULL)
return -EIO;
diff --git a/client/transfer.c b/client/transfer.c
index 34dc277..35e8940 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -220,7 +220,6 @@ static void obc_transfer_free(struct obc_transfer *transfer)
}
struct obc_transfer *obc_transfer_register(DBusConnection *conn,
- GObex *obex,
const char *agent,
guint8 op,
const char *filename,
@@ -231,7 +230,6 @@ struct obc_transfer *obc_transfer_register(DBusConnection *conn,
struct obc_transfer *transfer;
transfer = g_new0(struct obc_transfer, 1);
- transfer->obex = g_obex_ref(obex);
transfer->op = op;
transfer->agent = g_strdup(agent);
transfer->filename = g_strdup(filename);
@@ -522,8 +520,10 @@ static gboolean transfer_start_put(struct obc_transfer *transfer, GError **err)
return TRUE;
}
-gboolean obc_transfer_start(struct obc_transfer *transfer, GError **err)
+gboolean obc_transfer_start(struct obc_transfer *transfer, GObex *obex, GError **err)
{
+ transfer->obex = g_obex_ref(obex);
+
switch (transfer->op) {
case G_OBEX_OP_GET:
return transfer_start_get(transfer, err);
diff --git a/client/transfer.h b/client/transfer.h
index 7858423..b044ce1 100644
--- a/client/transfer.h
+++ b/client/transfer.h
@@ -33,7 +33,6 @@ typedef void (*transfer_callback_t) (struct obc_transfer *transfer,
void *user_data);
struct obc_transfer *obc_transfer_register(DBusConnection *conn,
- GObex *obex,
const char *agent,
guint8 op,
const char *filename,
@@ -47,7 +46,8 @@ gboolean obc_transfer_set_callback(struct obc_transfer *transfer,
transfer_callback_t func,
void *user_data);
-gboolean obc_transfer_start(struct obc_transfer *transfer, GError **err);
+gboolean obc_transfer_start(struct obc_transfer *transfer, GObex *obex,
+ GError **err);
guint8 obc_transfer_get_operation(struct obc_transfer *transfer);
int obc_transfer_get_params(struct obc_transfer *transfer,
--
1.7.7.6
next prev parent reply other threads:[~2012-04-20 11:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-20 11:40 [PATCH obexd 1/6 v2] client: Remove buffer based transfer Luiz Augusto von Dentz
2012-04-20 11:40 ` [PATCH obexd 2/6 v2] client: remove unused field Luiz Augusto von Dentz
2012-04-20 11:40 ` [PATCH obexd 3/6] client: transfer api merges put and get Luiz Augusto von Dentz
2012-04-20 11:40 ` Luiz Augusto von Dentz [this message]
2012-04-20 11:40 ` [PATCH obexd 5/6 v2] client: open file during transfer creation Luiz Augusto von Dentz
2012-04-20 11:40 ` [PATCH obexd 6/6 v2] client: Remove file in case of error 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=1334922006-19654-4-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).