From: Mikel Astiz <[email protected]>
These patches review the naming convention in transfer.h and session.h, in order to avoid misleading use of the terms "name", "filename" and "targetname".
In addition these terms were incorrectly used for get operations, leading to incorrect exposure of transfer properties in D-Bus.
Mikel Astiz (3):
client: fix naming convention in transfer api
client: refactor naming convention in session api
client: simplify obc_session_pull
client/session.c | 57 ++++++++++++++++------------------------------------
client/session.h | 12 +++++-----
client/transfer.c | 14 ++++++------
client/transfer.h | 3 +-
4 files changed, 33 insertions(+), 53 deletions(-)
--
1.7.6.5
Hi Mikel,
On Fri, Mar 2, 2012 at 2:41 PM, Mikel Astiz <[email protected]> wrote:
> From: Mikel Astiz <[email protected]>
>
> Functions obc_session_get and obc_session_pull nearly share the same
> code, so the later can be achieved by just calling the first one.
>
> The session api is not modified in this patch.
> ---
> ?client/session.c | ? 22 +---------------------
> ?1 files changed, 1 insertions(+), 21 deletions(-)
>
> diff --git a/client/session.c b/client/session.c
> index 6497d70..595f684 100644
> --- a/client/session.c
> +++ b/client/session.c
> @@ -1001,27 +1001,7 @@ int obc_session_pull(struct obc_session *session,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const char *type, const char *targetfile,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?session_callback_t function, void *user_data)
> ?{
> - ? ? ? struct obc_transfer *transfer;
> - ? ? ? const char *agent;
> -
> - ? ? ? if (session->obex == NULL)
> - ? ? ? ? ? ? ? return -ENOTCONN;
> -
> - ? ? ? if (session->agent != NULL)
> - ? ? ? ? ? ? ? agent = obc_agent_get_name(session->agent);
> - ? ? ? else
> - ? ? ? ? ? ? ? agent = NULL;
> -
> - ? ? ? transfer = obc_transfer_register(session->conn, session->obex,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? agent,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? targetfile,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? NULL, type,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? NULL);
> - ? ? ? if (transfer == NULL) {
> - ? ? ? ? ? ? ? return -EIO;
> - ? ? ? }
> -
> - ? ? ? return session_request(session, transfer, session_prepare_get,
> + ? ? ? return obc_session_get(session, type, NULL, targetfile, NULL, 0,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?function, user_data);
> ?}
>
> --
> 1.7.6.5
Sounds good, ack.
--
Luiz Augusto von Dentz
Hi Mikel,
On Fri, Mar 2, 2012 at 2:41 PM, Mikel Astiz <[email protected]> wrote:
> From: Mikel Astiz <[email protected]>
>
> The terms "name", "filename" and "targetname" are used in session.h that
> can be confusing. This patch proposes to follow the terminology in the
> D-Bus api:
> ? ? ? ?- Name: the remote name of the object being transferred
> ? ? ? ?- Filename: the local filesystem name of a file being sent
> ? ? ? ?- Targetfile: the local filesystem name of a file being
> ? ? ? ? ? ? ? ?received
> ---
> ?client/session.c | ? 30 +++++++++++++++---------------
> ?client/session.h | ? 12 ++++++------
> ?2 files changed, 21 insertions(+), 21 deletions(-)
>
> diff --git a/client/session.c b/client/session.c
> index 06022b5..6497d70 100644
> --- a/client/session.c
> +++ b/client/session.c
> @@ -931,7 +931,7 @@ static void session_prepare_get(gpointer data, gpointer user_data)
> ?}
>
> ?int obc_session_get(struct obc_session *session, const char *type,
> - ? ? ? ? ? ? ? const char *filename, const char *targetname,
> + ? ? ? ? ? ? ? const char *name, const char *targetfile,
> ? ? ? ? ? ? ? ?const guint8 *apparam, gint apparam_size,
> ? ? ? ? ? ? ? ?session_callback_t func, void *user_data)
> ?{
> @@ -955,9 +955,8 @@ int obc_session_get(struct obc_session *session, const char *type,
> ? ? ? ? ? ? ? ?agent = NULL;
>
> ? ? ? ?transfer = obc_transfer_register(session->conn, session->obex,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? agent, targetname,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? filename, type,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? params);
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? agent, targetfile,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? name, type, params);
> ? ? ? ?if (transfer == NULL) {
> ? ? ? ? ? ? ? ?if (params != NULL) {
> ? ? ? ? ? ? ? ? ? ? ? ?g_free(params->data);
> @@ -971,7 +970,7 @@ int obc_session_get(struct obc_session *session, const char *type,
> ?}
>
> ?int obc_session_send(struct obc_session *session, const char *filename,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const char *targetname)
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const char *name)
> ?{
> ? ? ? ?struct obc_transfer *transfer;
> ? ? ? ?const char *agent;
> @@ -984,8 +983,7 @@ int obc_session_send(struct obc_session *session, const char *filename,
>
> ? ? ? ?transfer = obc_transfer_register(session->conn, session->obex,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?agent, filename,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? targetname, NULL,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? NULL);
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? name, NULL, NULL);
> ? ? ? ?if (transfer == NULL)
> ? ? ? ? ? ? ? ?return -EINVAL;
>
> @@ -1000,7 +998,7 @@ int obc_session_send(struct obc_session *session, const char *filename,
> ?}
>
> ?int obc_session_pull(struct obc_session *session,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const char *type, const char *filename,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const char *type, const char *targetfile,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?session_callback_t function, void *user_data)
> ?{
> ? ? ? ?struct obc_transfer *transfer;
> @@ -1015,7 +1013,8 @@ int obc_session_pull(struct obc_session *session,
> ? ? ? ? ? ? ? ?agent = NULL;
>
> ? ? ? ?transfer = obc_transfer_register(session->conn, session->obex,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? agent, filename,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? agent,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? targetfile,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?NULL, type,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?NULL);
> ? ? ? ?if (transfer == NULL) {
> @@ -1076,7 +1075,7 @@ static void session_prepare_put(gpointer data, gpointer user_data)
> ? ? ? ?DBG("Transfer(%p) started", transfer);
> ?}
>
> -int obc_session_put(struct obc_session *session, char *buf, const char *targetname)
> +int obc_session_put(struct obc_session *session, char *buf, const char *name)
> ?{
> ? ? ? ?struct obc_transfer *transfer;
> ? ? ? ?const char *agent;
> @@ -1090,7 +1089,8 @@ int obc_session_put(struct obc_session *session, char *buf, const char *targetna
>
> ? ? ? ?transfer = obc_transfer_register(session->conn, session->obex,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?agent, NULL,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? targetname, NULL, NULL);
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? name, NULL,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? NULL);
> ? ? ? ?if (transfer == NULL) {
> ? ? ? ? ? ? ? ?g_free(buf);
> ? ? ? ? ? ? ? ?return -EIO;
> @@ -1382,7 +1382,7 @@ guint obc_session_mkdir(struct obc_session *session, const char *folder,
> ? ? ? ?return p->id;
> ?}
>
> -guint obc_session_copy(struct obc_session *session, const char *filename,
> +guint obc_session_copy(struct obc_session *session, const char *srcname,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const char *destname, session_callback_t func,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?void *user_data, GError **err)
> ?{
> @@ -1401,7 +1401,7 @@ guint obc_session_copy(struct obc_session *session, const char *filename,
>
> ? ? ? ?p = pending_request_new(session, NULL, NULL, func, user_data);
>
> - ? ? ? p->req_id = g_obex_copy(session->obex, filename, destname, async_cb, p,
> + ? ? ? p->req_id = g_obex_copy(session->obex, srcname, destname, async_cb, p,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?err);
> ? ? ? ?if (*err != NULL) {
> ? ? ? ? ? ? ? ?pending_request_free(p);
> @@ -1412,7 +1412,7 @@ guint obc_session_copy(struct obc_session *session, const char *filename,
> ? ? ? ?return p->id;
> ?}
>
> -guint obc_session_move(struct obc_session *session, const char *filename,
> +guint obc_session_move(struct obc_session *session, const char *srcname,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const char *destname, session_callback_t func,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?void *user_data, GError **err)
> ?{
> @@ -1431,7 +1431,7 @@ guint obc_session_move(struct obc_session *session, const char *filename,
>
> ? ? ? ?p = pending_request_new(session, NULL, NULL, func, user_data);
>
> - ? ? ? p->req_id = g_obex_move(session->obex, filename, destname, async_cb, p,
> + ? ? ? p->req_id = g_obex_move(session->obex, srcname, destname, async_cb, p,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?err);
> ? ? ? ?if (*err != NULL) {
> ? ? ? ? ? ? ? ?pending_request_free(p);
> diff --git a/client/session.h b/client/session.h
> index a19b31f..4bfb41d 100644
> --- a/client/session.h
> +++ b/client/session.h
> @@ -56,18 +56,18 @@ const char *obc_session_get_buffer(struct obc_session *session, size_t *size);
> ?void *obc_session_get_params(struct obc_session *session, size_t *size);
>
> ?int obc_session_send(struct obc_session *session, const char *filename,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const char *remotename);
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const char *name);
> ?int obc_session_get(struct obc_session *session, const char *type,
> - ? ? ? ? ? ? ? const char *filename, const char *targetname,
> + ? ? ? ? ? ? ? const char *name, const char *targetfile,
> ? ? ? ? ? ? ? ?const guint8 ?*apparam, gint apparam_size,
> ? ? ? ? ? ? ? ?session_callback_t func, void *user_data);
> ?int obc_session_pull(struct obc_session *session,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const char *type, const char *filename,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const char *type, const char *targetfile,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?session_callback_t function, void *user_data);
> ?const char *obc_session_register(struct obc_session *session,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?GDBusDestroyFunction destroy);
> ?int obc_session_put(struct obc_session *session, char *buf,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const char *targetname);
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const char *name);
>
> ?guint obc_session_setpath(struct obc_session *session, const char *path,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?session_callback_t func, void *user_data,
> @@ -75,10 +75,10 @@ guint obc_session_setpath(struct obc_session *session, const char *path,
> ?guint obc_session_mkdir(struct obc_session *session, const char *folder,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?session_callback_t func, void *user_data,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?GError **err);
> -guint obc_session_copy(struct obc_session *session, const char *filename,
> +guint obc_session_copy(struct obc_session *session, const char *srcname,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const char *destname, session_callback_t func,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?void *user_data, GError **err);
> -guint obc_session_move(struct obc_session *session, const char *filename,
> +guint obc_session_move(struct obc_session *session, const char *srcname,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const char *destname, session_callback_t func,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?void *user_data, GError **err);
> ?guint obc_session_delete(struct obc_session *session, const char *file,
> --
> 1.7.6.5
Ack
--
Luiz Augusto von Dentz
Hi Mikel,
On Fri, Mar 2, 2012 at 2:41 PM, Mikel Astiz <[email protected]> wrote:
> From: Mikel Astiz <[email protected]>
>
> 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 also 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.
Please split this, have the fix to swapped parameters and then the
name modification in separated patch.
--
Luiz Augusto von Dentz
From: Mikel Astiz <[email protected]>
Functions obc_session_get and obc_session_pull nearly share the same
code, so the later can be achieved by just calling the first one.
The session api is not modified in this patch.
---
client/session.c | 22 +---------------------
1 files changed, 1 insertions(+), 21 deletions(-)
diff --git a/client/session.c b/client/session.c
index 6497d70..595f684 100644
--- a/client/session.c
+++ b/client/session.c
@@ -1001,27 +1001,7 @@ int obc_session_pull(struct obc_session *session,
const char *type, const char *targetfile,
session_callback_t function, void *user_data)
{
- struct obc_transfer *transfer;
- const char *agent;
-
- if (session->obex == NULL)
- return -ENOTCONN;
-
- if (session->agent != NULL)
- agent = obc_agent_get_name(session->agent);
- else
- agent = NULL;
-
- transfer = obc_transfer_register(session->conn, session->obex,
- agent,
- targetfile,
- NULL, type,
- NULL);
- if (transfer == NULL) {
- return -EIO;
- }
-
- return session_request(session, transfer, session_prepare_get,
+ return obc_session_get(session, type, NULL, targetfile, NULL, 0,
function, user_data);
}
--
1.7.6.5
From: Mikel Astiz <[email protected]>
The terms "name", "filename" and "targetname" are used in session.h that
can be confusing. This patch proposes to follow the terminology in the
D-Bus api:
- Name: the remote name of the object being transferred
- Filename: the local filesystem name of a file being sent
- Targetfile: the local filesystem name of a file being
received
---
client/session.c | 30 +++++++++++++++---------------
client/session.h | 12 ++++++------
2 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/client/session.c b/client/session.c
index 06022b5..6497d70 100644
--- a/client/session.c
+++ b/client/session.c
@@ -931,7 +931,7 @@ static void session_prepare_get(gpointer data, gpointer user_data)
}
int obc_session_get(struct obc_session *session, const char *type,
- const char *filename, const char *targetname,
+ const char *name, const char *targetfile,
const guint8 *apparam, gint apparam_size,
session_callback_t func, void *user_data)
{
@@ -955,9 +955,8 @@ int obc_session_get(struct obc_session *session, const char *type,
agent = NULL;
transfer = obc_transfer_register(session->conn, session->obex,
- agent, targetname,
- filename, type,
- params);
+ agent, targetfile,
+ name, type, params);
if (transfer == NULL) {
if (params != NULL) {
g_free(params->data);
@@ -971,7 +970,7 @@ int obc_session_get(struct obc_session *session, const char *type,
}
int obc_session_send(struct obc_session *session, const char *filename,
- const char *targetname)
+ const char *name)
{
struct obc_transfer *transfer;
const char *agent;
@@ -984,8 +983,7 @@ int obc_session_send(struct obc_session *session, const char *filename,
transfer = obc_transfer_register(session->conn, session->obex,
agent, filename,
- targetname, NULL,
- NULL);
+ name, NULL, NULL);
if (transfer == NULL)
return -EINVAL;
@@ -1000,7 +998,7 @@ int obc_session_send(struct obc_session *session, const char *filename,
}
int obc_session_pull(struct obc_session *session,
- const char *type, const char *filename,
+ const char *type, const char *targetfile,
session_callback_t function, void *user_data)
{
struct obc_transfer *transfer;
@@ -1015,7 +1013,8 @@ int obc_session_pull(struct obc_session *session,
agent = NULL;
transfer = obc_transfer_register(session->conn, session->obex,
- agent, filename,
+ agent,
+ targetfile,
NULL, type,
NULL);
if (transfer == NULL) {
@@ -1076,7 +1075,7 @@ static void session_prepare_put(gpointer data, gpointer user_data)
DBG("Transfer(%p) started", transfer);
}
-int obc_session_put(struct obc_session *session, char *buf, const char *targetname)
+int obc_session_put(struct obc_session *session, char *buf, const char *name)
{
struct obc_transfer *transfer;
const char *agent;
@@ -1090,7 +1089,8 @@ int obc_session_put(struct obc_session *session, char *buf, const char *targetna
transfer = obc_transfer_register(session->conn, session->obex,
agent, NULL,
- targetname, NULL, NULL);
+ name, NULL,
+ NULL);
if (transfer == NULL) {
g_free(buf);
return -EIO;
@@ -1382,7 +1382,7 @@ guint obc_session_mkdir(struct obc_session *session, const char *folder,
return p->id;
}
-guint obc_session_copy(struct obc_session *session, const char *filename,
+guint obc_session_copy(struct obc_session *session, const char *srcname,
const char *destname, session_callback_t func,
void *user_data, GError **err)
{
@@ -1401,7 +1401,7 @@ guint obc_session_copy(struct obc_session *session, const char *filename,
p = pending_request_new(session, NULL, NULL, func, user_data);
- p->req_id = g_obex_copy(session->obex, filename, destname, async_cb, p,
+ p->req_id = g_obex_copy(session->obex, srcname, destname, async_cb, p,
err);
if (*err != NULL) {
pending_request_free(p);
@@ -1412,7 +1412,7 @@ guint obc_session_copy(struct obc_session *session, const char *filename,
return p->id;
}
-guint obc_session_move(struct obc_session *session, const char *filename,
+guint obc_session_move(struct obc_session *session, const char *srcname,
const char *destname, session_callback_t func,
void *user_data, GError **err)
{
@@ -1431,7 +1431,7 @@ guint obc_session_move(struct obc_session *session, const char *filename,
p = pending_request_new(session, NULL, NULL, func, user_data);
- p->req_id = g_obex_move(session->obex, filename, destname, async_cb, p,
+ p->req_id = g_obex_move(session->obex, srcname, destname, async_cb, p,
err);
if (*err != NULL) {
pending_request_free(p);
diff --git a/client/session.h b/client/session.h
index a19b31f..4bfb41d 100644
--- a/client/session.h
+++ b/client/session.h
@@ -56,18 +56,18 @@ const char *obc_session_get_buffer(struct obc_session *session, size_t *size);
void *obc_session_get_params(struct obc_session *session, size_t *size);
int obc_session_send(struct obc_session *session, const char *filename,
- const char *remotename);
+ const char *name);
int obc_session_get(struct obc_session *session, const char *type,
- const char *filename, const char *targetname,
+ const char *name, const char *targetfile,
const guint8 *apparam, gint apparam_size,
session_callback_t func, void *user_data);
int obc_session_pull(struct obc_session *session,
- const char *type, const char *filename,
+ const char *type, const char *targetfile,
session_callback_t function, void *user_data);
const char *obc_session_register(struct obc_session *session,
GDBusDestroyFunction destroy);
int obc_session_put(struct obc_session *session, char *buf,
- const char *targetname);
+ const char *name);
guint obc_session_setpath(struct obc_session *session, const char *path,
session_callback_t func, void *user_data,
@@ -75,10 +75,10 @@ guint obc_session_setpath(struct obc_session *session, const char *path,
guint obc_session_mkdir(struct obc_session *session, const char *folder,
session_callback_t func, void *user_data,
GError **err);
-guint obc_session_copy(struct obc_session *session, const char *filename,
+guint obc_session_copy(struct obc_session *session, const char *srcname,
const char *destname, session_callback_t func,
void *user_data, GError **err);
-guint obc_session_move(struct obc_session *session, const char *filename,
+guint obc_session_move(struct obc_session *session, const char *srcname,
const char *destname, session_callback_t func,
void *user_data, GError **err);
guint obc_session_delete(struct obc_session *session, const char *file,
--
1.7.6.5
From: Mikel Astiz <[email protected]>
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 also 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.
---
client/session.c | 21 ++++++++++-----------
client/transfer.c | 14 +++++++-------
client/transfer.h | 3 ++-
3 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/client/session.c b/client/session.c
index 57a5b06..06022b5 100644
--- a/client/session.c
+++ b/client/session.c
@@ -659,7 +659,7 @@ static void session_request_reply(DBusPendingCall *call, gpointer user_data)
struct pending_request *p = session->p;
struct obc_transfer *transfer = p->transfer;
DBusMessage *reply = dbus_pending_call_steal_reply(call);
- const char *name;
+ const char *filename;
DBusError derr;
dbus_error_init(&derr);
@@ -680,13 +680,13 @@ static void session_request_reply(DBusPendingCall *call, gpointer user_data)
}
dbus_message_get_args(reply, NULL,
- DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_STRING, &filename,
DBUS_TYPE_INVALID);
- DBG("Agent.Request() reply: %s", name);
+ DBG("Agent.Request() reply: %s", filename);
- if (strlen(name))
- obc_transfer_set_name(transfer, name);
+ if (strlen(filename))
+ obc_transfer_set_filename(transfer, filename);
if (p->auth_complete)
p->auth_complete(session, transfer);
@@ -955,8 +955,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 +1015,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;
@@ -1090,8 +1090,7 @@ int obc_session_put(struct obc_session *session, char *buf, const char *targetna
transfer = obc_transfer_register(session->conn, session->obex,
agent, NULL,
- targetname, NULL,
- NULL);
+ targetname, NULL, NULL);
if (transfer == NULL) {
g_free(buf);
return -EIO;
diff --git a/client/transfer.c b/client/transfer.c
index d1edef2..8049c25 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,
@@ -639,10 +638,11 @@ void obc_transfer_set_buffer(struct obc_transfer *transfer, char *buffer)
transfer->buffer = buffer;
}
-void obc_transfer_set_name(struct obc_transfer *transfer, const char *name)
+void obc_transfer_set_filename(struct obc_transfer *transfer,
+ const char *filename)
{
- g_free(transfer->name);
- transfer->name = g_strdup(name);
+ g_free(transfer->filename);
+ transfer->filename = g_strdup(filename);
}
const char *obc_transfer_get_path(struct obc_transfer *transfer)
diff --git a/client/transfer.h b/client/transfer.h
index e7e1000..bb4acc4 100644
--- a/client/transfer.h
+++ b/client/transfer.h
@@ -55,7 +55,8 @@ const char *obc_transfer_get_buffer(struct obc_transfer *transfer, size_t *size)
void obc_transfer_set_buffer(struct obc_transfer *transfer, char *buffer);
void obc_transfer_clear_buffer(struct obc_transfer *transfer);
-void obc_transfer_set_name(struct obc_transfer *transfer, const char *name);
+void obc_transfer_set_filename(struct obc_transfer *transfer,
+ const char *filename);
const char *obc_transfer_get_path(struct obc_transfer *transfer);
gint64 obc_transfer_get_size(struct obc_transfer *transfer);
int obc_transfer_set_file(struct obc_transfer *transfer);
--
1.7.6.5