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 v2 2/4] client: fix naming convention in transfer api
Date: Wed, 7 Mar 2012 15:50:27 +0100 [thread overview]
Message-ID: <1331131829-28509-3-git-send-email-mikel.astiz.oss@gmail.com> (raw)
In-Reply-To: <1331131829-28509-1-git-send-email-mikel.astiz.oss@gmail.com>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
The terms can be quite misleading, so this patch proposes to follow the
terminology in the D-Bus api:
- Name: the remote name of the object being transferred
- Filename: the name of the file in local the filesystem
Both values can be NULL independently.
This fixes the problem of using the terms differently in get and put
operations. The result was that the properties "Name" and "Filename" were
swapped in D-Bus in the case of get.
Once the fields map to obex fields, the interpretation of the response
from the agent becomes more complicated. Depending on the transfer type,
either the name or the filename field must be updated.
---
client/session.c | 16 ++++++++++------
client/transfer.c | 7 +++----
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/client/session.c b/client/session.c
index 57a5b06..28fae03 100644
--- a/client/session.c
+++ b/client/session.c
@@ -685,8 +685,12 @@ static void session_request_reply(DBusPendingCall *call, gpointer user_data)
DBG("Agent.Request() reply: %s", name);
- if (strlen(name))
- obc_transfer_set_name(transfer, name);
+ if (strlen(name)) {
+ if (p->auth_complete == session_prepare_put)
+ obc_transfer_set_name(transfer, name);
+ else
+ obc_transfer_set_filename(transfer, name);
+ }
if (p->auth_complete)
p->auth_complete(session, transfer);
@@ -955,8 +959,8 @@ int obc_session_get(struct obc_session *session, const char *type,
agent = NULL;
transfer = obc_transfer_register(session->conn, session->obex,
- agent, filename,
- targetname, type,
+ agent, targetname,
+ filename, type,
params);
if (transfer == NULL) {
if (params != NULL) {
@@ -1015,8 +1019,8 @@ int obc_session_pull(struct obc_session *session,
agent = NULL;
transfer = obc_transfer_register(session->conn, session->obex,
- agent, NULL,
- filename, type,
+ agent, filename,
+ NULL, type,
NULL);
if (transfer == NULL) {
return -EIO;
diff --git a/client/transfer.c b/client/transfer.c
index 3471655..60c2e4f 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -526,9 +526,8 @@ int obc_transfer_get(struct obc_transfer *transfer)
strncmp(transfer->type, "x-bt/", 5) == 0)) {
rsp_cb = get_buf_xfer_progress;
} else {
- int fd = open(transfer->name ? : transfer->filename,
+ int fd = open(transfer->filename ? : transfer->name,
O_WRONLY | O_CREAT, 0600);
-
if (fd < 0) {
error("open(): %s(%d)", strerror(errno), errno);
return -errno;
@@ -540,9 +539,9 @@ int obc_transfer_get(struct obc_transfer *transfer)
req = g_obex_packet_new(G_OBEX_OP_GET, TRUE, G_OBEX_HDR_INVALID);
- if (transfer->filename != NULL)
+ if (transfer->name != NULL)
g_obex_packet_add_unicode(req, G_OBEX_HDR_NAME,
- transfer->filename);
+ transfer->name);
if (transfer->type != NULL)
g_obex_packet_add_bytes(req, G_OBEX_HDR_TYPE, transfer->type,
--
1.7.6.5
next prev parent reply other threads:[~2012-03-07 14:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-07 14:50 [PATCH obexd v2 0/4] client: parameter naming convention Mikel Astiz
2012-03-07 14:50 ` [PATCH obexd v2 1/4] client: add obc_transfer_set_filename Mikel Astiz
2012-03-07 14:50 ` Mikel Astiz [this message]
2012-03-07 14:50 ` [PATCH obexd v2 3/4] client: refactor naming convention in session api Mikel Astiz
2012-03-07 14:50 ` [PATCH obexd v2 4/4] client: simplify obc_session_pull Mikel Astiz
2012-03-08 10:28 ` [PATCH obexd v2 0/4] client: parameter naming convention Luiz Augusto von Dentz
2012-03-09 0:01 ` 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=1331131829-28509-3-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;
as well as URLs for NNTP newsgroup(s).