2012-04-27 10:33:34

by Mikel Astiz

[permalink] [raw]
Subject: [PATCH obexd v0 0/6] client: rethink transfer data access in session API

This patch series proposes a change in the session API such that the concept of "active transfer" (session->p) is removed from the API. This is possible once the callbacks provide the pointer to the transfer object, which can be used by the modules to access the data they are interested in.

This transfer object pointer is guaranteed to be valid during the duration of the callback, but nothing else can be assumed. In particular there is no ownership change involved.

The new approach is less error-prone and avoids API duplication between transfer and session APIs.

Mikel Astiz (6):
client: Minor buffer access API changes
client: Give transfer pointer in session callbacks
client: Avoid GObex dependency from transfer.h
client: Use new session callback style in modules
client: Remove deprecated part of session API
client: Remove transfer from queue before callback

client/ftp.c | 9 +++--
client/manager.c | 5 ++-
client/map.c | 8 +++--
client/pbap.c | 18 ++++++----
client/session.c | 105 ++++++++++++++++++-----------------------------------
client/session.h | 15 ++++----
client/sync.c | 4 ++-
client/transfer.c | 14 ++++---
client/transfer.h | 8 ++--
9 files changed, 84 insertions(+), 102 deletions(-)

--
1.7.7.6



2012-04-27 10:33:38

by Mikel Astiz

[permalink] [raw]
Subject: [PATCH obexd v0 4/6] client: Use new session callback style in modules

The session API now provides the transfer object in the callback, so
the modules can directly access the transfer object.
---
client/ftp.c | 3 ++-
client/manager.c | 3 ++-
client/map.c | 3 ++-
client/pbap.c | 11 ++++++-----
client/sync.c | 3 ++-
5 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/client/ftp.c b/client/ftp.c
index baeeb2d..d7800b0 100644
--- a/client/ftp.c
+++ b/client/ftp.c
@@ -33,6 +33,7 @@
#include "log.h"

#include "session.h"
+#include "transfer.h"
#include "driver.h"
#include "ftp.h"

@@ -203,7 +204,7 @@ static void list_folder_callback(struct obc_session *session,

reply = dbus_message_new_method_return(msg);

- if (obc_session_get_contents(session, &contents, &size) < 0)
+ if (obc_transfer_get_contents(transfer, &contents, &size) < 0)
goto done;

dbus_message_iter_init_append(reply, &iter);
diff --git a/client/manager.c b/client/manager.c
index 2eb944e..783367b 100644
--- a/client/manager.c
+++ b/client/manager.c
@@ -36,6 +36,7 @@

#include "log.h"
#include "session.h"
+#include "transfer.h"
#include "manager.h"
#include "bluetooth.h"
#include "opp.h"
@@ -465,7 +466,7 @@ static void capabilities_complete_callback(struct obc_session *session,
goto done;
}

- perr = obc_session_get_contents(session, &contents, &size);
+ perr = obc_transfer_get_contents(transfer, &contents, &size);
if (perr < 0) {
DBusMessage *error = g_dbus_create_error(data->message,
"org.openobex.Error.Failed",
diff --git a/client/map.c b/client/map.c
index 05ba6aa..e05850f 100644
--- a/client/map.c
+++ b/client/map.c
@@ -33,6 +33,7 @@

#include "map.h"
#include "session.h"
+#include "transfer.h"
#include "driver.h"

#define OBEX_MAS_UUID \
@@ -111,7 +112,7 @@ static void buffer_cb(struct obc_session *session,
goto done;
}

- perr = obc_session_get_contents(session, &contents, &size);
+ perr = obc_transfer_get_contents(transfer, &contents, &size);
if (perr < 0) {
reply = g_dbus_create_error(map->msg,
"org.openobex.Error.Failed",
diff --git a/client/pbap.c b/client/pbap.c
index 0912ac0..925662d 100644
--- a/client/pbap.c
+++ b/client/pbap.c
@@ -37,6 +37,7 @@
#include "log.h"

#include "session.h"
+#include "transfer.h"
#include "driver.h"
#include "pbap.h"

@@ -291,7 +292,7 @@ static void pbap_setpath_cb(struct obc_session *session, GError *err,
pending_request_free(request);
}

-static void read_return_apparam(struct obc_session *session,
+static void read_return_apparam(struct obc_transfer *transfer,
guint16 *phone_book_size, guint8 *new_missed_calls)
{
const struct apparam_hdr *hdr;
@@ -300,7 +301,7 @@ static void read_return_apparam(struct obc_session *session,
*phone_book_size = 0;
*new_missed_calls = 0;

- hdr = obc_session_get_params(session, &size);
+ hdr = obc_transfer_get_params(transfer, &size);
if (hdr == NULL)
return;

@@ -355,7 +356,7 @@ static void pull_phonebook_callback(struct obc_session *session,
goto send;
}

- perr = obc_session_get_contents(session, &contents, &size);
+ perr = obc_transfer_get_contents(transfer, &contents, &size);
if (perr < 0) {
reply = g_dbus_create_error(request->msg,
"org.openobex.Error.Failed",
@@ -395,7 +396,7 @@ static void phonebook_size_callback(struct obc_session *session,

reply = dbus_message_new_method_return(request->msg);

- read_return_apparam(session, &phone_book_size, &new_missed_calls);
+ read_return_apparam(transfer, &phone_book_size, &new_missed_calls);

dbus_message_append_args(reply,
DBUS_TYPE_UINT16, &phone_book_size,
@@ -425,7 +426,7 @@ static void pull_vcard_listing_callback(struct obc_session *session,
goto send;
}

- perr = obc_session_get_contents(session, &contents, &size);
+ perr = obc_transfer_get_contents(transfer, &contents, &size);
if (perr < 0) {
reply = g_dbus_create_error(request->msg,
"org.openobex.Error.Failed",
diff --git a/client/sync.c b/client/sync.c
index e3a78d5..96cf486 100644
--- a/client/sync.c
+++ b/client/sync.c
@@ -35,6 +35,7 @@
#include "log.h"

#include "session.h"
+#include "transfer.h"
#include "driver.h"
#include "sync.h"

@@ -100,7 +101,7 @@ static void sync_getphonebook_callback(struct obc_session *session,
goto send;
}

- perr = obc_session_get_contents(session, &contents, &size);
+ perr = obc_transfer_get_contents(transfer, &contents, &size);
if (perr < 0) {
reply = g_dbus_create_error(sync->msg,
"org.openobex.Error.Failed",
--
1.7.7.6


2012-04-27 10:33:39

by Mikel Astiz

[permalink] [raw]
Subject: [PATCH obexd v0 5/6] client: Remove deprecated part of session API

Once the modules are using the new callback style, the session API can
be simplified and the old functions to access session->p removed.
---
client/session.c | 40 ----------------------------------------
client/session.h | 3 ---
2 files changed, 0 insertions(+), 43 deletions(-)

diff --git a/client/session.c b/client/session.c
index 50947d3..ea717a6 100644
--- a/client/session.c
+++ b/client/session.c
@@ -1140,46 +1140,6 @@ const char *obc_session_get_target(struct obc_session *session)
return session->driver->target;
}

-static struct obc_transfer *obc_session_get_transfer(
- struct obc_session *session)
-{
- if (session->p == NULL)
- return NULL;
-
- return session->p->transfer;
-}
-
-int obc_session_get_contents(struct obc_session *session, char **contents,
- size_t *size)
-{
- struct obc_transfer *transfer;
-
- transfer = obc_session_get_transfer(session);
- if (transfer == NULL) {
- if (size != NULL)
- *size = 0;
-
- return -EINVAL;
- }
-
- return obc_transfer_get_contents(transfer, contents, size);
-}
-
-const void *obc_session_get_params(struct obc_session *session, size_t *size)
-{
- struct obc_transfer *transfer;
-
- transfer = obc_session_get_transfer(session);
- if (transfer == NULL) {
- if (size != NULL)
- *size = 0;
-
- return NULL;
- }
-
- return obc_transfer_get_params(transfer, size);
-}
-
static void setpath_complete(struct obc_session *session, GError *err,
void *user_data)
{
diff --git a/client/session.h b/client/session.h
index d97abc3..2717194 100644
--- a/client/session.h
+++ b/client/session.h
@@ -56,9 +56,6 @@ const char *obc_session_get_agent(struct obc_session *session);

const char *obc_session_get_path(struct obc_session *session);
const char *obc_session_get_target(struct obc_session *session);
-int obc_session_get_contents(struct obc_session *session, char **contents,
- size_t *size);
-const void *obc_session_get_params(struct obc_session *session, size_t *size);

guint obc_session_send(struct obc_session *session, const char *filename,
const char *name, GError **err);
--
1.7.7.6


2012-04-27 10:33:40

by Mikel Astiz

[permalink] [raw]
Subject: [PATCH obexd v0 6/6] client: Remove transfer from queue before callback

It is safer to remove the transfer from the internal queue (including
session->p) before calling the transfer callback. This makes sure the
callback will not manipulate the session in a way that the transfer is
removed more than once.

This was previously protected with session->p->id != 0 checks, but once
the new callbacks have been adopted in session API, this logic can be
removed.
---
client/session.c | 20 +++++++++-----------
1 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/client/session.c b/client/session.c
index ea717a6..bb00684 100644
--- a/client/session.c
+++ b/client/session.c
@@ -496,15 +496,16 @@ void obc_session_shutdown(struct obc_session *session)
err = g_error_new(OBEX_IO_ERROR, OBEX_IO_DISCONNECTED,
"Session closed by user");

- if (session->p != NULL && session->p->id != 0) {
+ if (session->p != NULL) {
session_transfer_callback_t callback = session->p->func;

+ p = session->p;
+ session->p = NULL;
+
if (callback)
- callback(session, session->p->transfer, err,
- session->p->data);
+ callback(session, p->transfer, err, p->data);

- pending_request_free(session->p);
- session->p = NULL;
+ pending_request_free(p);
}

while ((p = g_queue_pop_head(session->queue))) {
@@ -843,9 +844,8 @@ static void session_terminate_transfer(struct obc_session *session,

p = match->data;
g_queue_delete_link(session->queue, match);
- }
-
- p->id = 0;
+ } else
+ session->p = NULL;

obc_session_ref(session);

@@ -855,10 +855,8 @@ static void session_terminate_transfer(struct obc_session *session,

pending_request_free(p);

- if (p == session->p) {
- session->p = NULL;
+ if (session->p == NULL)
session_process_queue(session);
- }

obc_session_unref(session);
}
--
1.7.7.6


2012-04-27 10:33:36

by Mikel Astiz

[permalink] [raw]
Subject: [PATCH obexd v0 2/6] client: Give transfer pointer in session callbacks

Operations involving a transfer object in session.h should use a
callback that provides access to the transfer object.

Note that the ownership of this object is not changed in any way,
meaning that the session is still responsible for it. However this
pointer can be useful during the execution of the callback, in order to
access data members of the transfer.
---
client/ftp.c | 6 ++++--
client/manager.c | 2 ++
client/map.c | 5 +++--
client/pbap.c | 5 ++++-
client/session.c | 48 +++++++++++++++++++++++++++++-------------------
client/session.h | 12 ++++++++----
client/sync.c | 1 +
7 files changed, 51 insertions(+), 28 deletions(-)

diff --git a/client/ftp.c b/client/ftp.c
index 0e6af47..baeeb2d 100644
--- a/client/ftp.c
+++ b/client/ftp.c
@@ -172,8 +172,9 @@ static const GMarkupParser parser = {
NULL
};

-static void get_file_callback(struct obc_session *session, GError *err,
- void *user_data)
+static void get_file_callback(struct obc_session *session,
+ struct obc_transfer *transfer,
+ GError *err, void *user_data)
{
DBusMessage *msg = user_data;
DBusMessage *reply;
@@ -190,6 +191,7 @@ static void get_file_callback(struct obc_session *session, GError *err,
}

static void list_folder_callback(struct obc_session *session,
+ struct obc_transfer *transfer,
GError *err, void *user_data)
{
DBusMessage *msg = user_data;
diff --git a/client/manager.c b/client/manager.c
index 6d08702..2eb944e 100644
--- a/client/manager.c
+++ b/client/manager.c
@@ -247,6 +247,7 @@ static DBusMessage *send_files(DBusConnection *connection,
}

static void pull_complete_callback(struct obc_session *session,
+ struct obc_transfer *transfer,
GError *err, void *user_data)
{
struct send_data *data = user_data;
@@ -448,6 +449,7 @@ static DBusMessage *remove_session(DBusConnection *connection,
}

static void capabilities_complete_callback(struct obc_session *session,
+ struct obc_transfer *transfer,
GError *err, void *user_data)
{
struct send_data *data = user_data;
diff --git a/client/map.c b/client/map.c
index 1b4e404..05ba6aa 100644
--- a/client/map.c
+++ b/client/map.c
@@ -94,8 +94,9 @@ static DBusMessage *map_setpath(DBusConnection *connection,
return NULL;
}

-static void buffer_cb(struct obc_session *session, GError *err,
- void *user_data)
+static void buffer_cb(struct obc_session *session,
+ struct obc_transfer *transfer,
+ GError *err, void *user_data)
{
struct map_data *map = user_data;
DBusMessage *reply;
diff --git a/client/pbap.c b/client/pbap.c
index d96b651..0912ac0 100644
--- a/client/pbap.c
+++ b/client/pbap.c
@@ -339,6 +339,7 @@ static void read_return_apparam(struct obc_session *session,
}

static void pull_phonebook_callback(struct obc_session *session,
+ struct obc_transfer *transfer,
GError *err, void *user_data)
{
struct pending_request *request = user_data;
@@ -377,6 +378,7 @@ send:
}

static void phonebook_size_callback(struct obc_session *session,
+ struct obc_transfer *transfer,
GError *err, void *user_data)
{
struct pending_request *request = user_data;
@@ -405,6 +407,7 @@ send:
}

static void pull_vcard_listing_callback(struct obc_session *session,
+ struct obc_transfer *transfer,
GError *err, void *user_data)
{
struct pending_request *request = user_data;
@@ -457,7 +460,7 @@ static DBusMessage *pull_phonebook(struct pbap_data *pbap,
{
struct pending_request *request;
struct pullphonebook_apparam apparam;
- session_callback_t func;
+ session_transfer_callback_t func;
GError *err = NULL;

apparam.filter_tag = FILTER_TAG;
diff --git a/client/session.c b/client/session.c
index 824ef49..50947d3 100644
--- a/client/session.c
+++ b/client/session.c
@@ -69,7 +69,7 @@ struct pending_request {
struct obc_session *session;
struct obc_transfer *transfer;
GFunc auth_complete;
- session_callback_t func;
+ void *func; /* session_callback_t or session_transfer_callback_t */
void *data;
};

@@ -142,7 +142,7 @@ static void session_unregistered(struct obc_session *session)
static struct pending_request *pending_request_new(struct obc_session *session,
struct obc_transfer *transfer,
GFunc auth_complete,
- session_callback_t func,
+ void *func,
void *data)
{
struct pending_request *p;
@@ -497,16 +497,21 @@ void obc_session_shutdown(struct obc_session *session)
"Session closed by user");

if (session->p != NULL && session->p->id != 0) {
- if (session->p->func)
- session->p->func(session, err, session->p->data);
+ session_transfer_callback_t callback = session->p->func;
+
+ if (callback)
+ callback(session, session->p->transfer, err,
+ session->p->data);

pending_request_free(session->p);
session->p = NULL;
}

while ((p = g_queue_pop_head(session->queue))) {
- if (p->func)
- p->func(session, err, p->data);
+ session_transfer_callback_t callback = p->func;
+
+ if (callback)
+ callback(session, p->transfer, err, p->data);

pending_request_free(p);
}
@@ -745,7 +750,7 @@ static int pending_request_auth(struct pending_request *p)

static guint session_request(struct obc_session *session,
struct obc_transfer *transfer,
- session_callback_t func,
+ session_transfer_callback_t func,
void *data, GError **err)
{
struct pending_request *p;
@@ -785,6 +790,7 @@ static void session_process_queue(struct obc_session *session)
obc_session_ref(session);

while ((p = g_queue_pop_head(session->queue))) {
+ session_transfer_callback_t callback;
int err;

err = pending_request_auth(p);
@@ -793,12 +799,13 @@ static void session_process_queue(struct obc_session *session)
break;
}

- if (p->func) {
+ callback = p->func;
+ if (callback) {
GError *gerr = NULL;

g_set_error(&gerr, OBEX_IO_ERROR, err,
"Authorization failed");
- p->func(session, gerr, p->data);
+ callback(session, p->transfer, gerr, p->data);
g_error_free(gerr);
}

@@ -824,6 +831,7 @@ static void session_terminate_transfer(struct obc_session *session,
GError *gerr)
{
struct pending_request *p = session->p;
+ session_transfer_callback_t callback;

if (p == NULL || p->transfer != transfer) {
GList *match;
@@ -841,8 +849,9 @@ static void session_terminate_transfer(struct obc_session *session,

obc_session_ref(session);

- if (p->func)
- p->func(session, gerr, p->data);
+ callback = p->func;
+ if (callback)
+ callback(session, p->transfer, gerr, p->data);

pending_request_free(p);

@@ -949,8 +958,8 @@ static void session_start_transfer(gpointer data, gpointer user_data)
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)
+ session_transfer_callback_t func,
+ void *user_data, GError **err)
{
struct obc_transfer *transfer;
struct obc_transfer_params *params = NULL;
@@ -1011,8 +1020,8 @@ guint obc_session_send(struct obc_session *session, const char *filename,

guint obc_session_pull(struct obc_session *session,
const char *type, const char *targetfile,
- session_callback_t function, void *user_data,
- GError **err)
+ session_transfer_callback_t function,
+ void *user_data, GError **err)
{
return obc_session_get(session, type, NULL, targetfile, NULL, 0,
function, user_data, err);
@@ -1284,14 +1293,15 @@ static void async_cb(GObex *obex, GError *err, GObexPacket *rsp,
{
struct pending_request *p = user_data;
struct obc_session *session = p->session;
+ session_callback_t callback = p->func;
GError *gerr = NULL;
uint8_t code;

p->req_id = 0;

if (err != NULL) {
- if (p->func)
- p->func(p->session, err, p->data);
+ if (callback)
+ callback(p->session, err, p->data);
goto done;
}

@@ -1300,8 +1310,8 @@ static void async_cb(GObex *obex, GError *err, GObexPacket *rsp,
g_set_error(&gerr, OBEX_IO_ERROR, code, "%s",
g_obex_strerror(code));

- if (p->func)
- p->func(p->session, gerr, p->data);
+ if (callback)
+ callback(p->session, gerr, p->data);

if (gerr != NULL)
g_clear_error(&gerr);
diff --git a/client/session.h b/client/session.h
index b44cf3f..d97abc3 100644
--- a/client/session.h
+++ b/client/session.h
@@ -26,9 +26,13 @@
#include <gdbus.h>

struct obc_session;
+struct obc_transfer;

typedef void (*session_callback_t) (struct obc_session *session,
GError *err, void *user_data);
+typedef void (*session_transfer_callback_t) (struct obc_session *session,
+ struct obc_transfer *transfer,
+ GError *err, void *user_data);

struct obc_session *obc_session_create(const char *source,
const char *destination,
@@ -61,12 +65,12 @@ guint obc_session_send(struct obc_session *session, const char *filename,
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);
+ session_transfer_callback_t func,
+ void *user_data, GError **err);
guint obc_session_pull(struct obc_session *session,
const char *type, const char *targetfile,
- session_callback_t function, void *user_data,
- GError **err);
+ session_transfer_callback_t function,
+ void *user_data, GError **err);
const char *obc_session_register(struct obc_session *session,
GDBusDestroyFunction destroy);
guint obc_session_put(struct obc_session *session, const char *contents,
diff --git a/client/sync.c b/client/sync.c
index 9a26f5b..e3a78d5 100644
--- a/client/sync.c
+++ b/client/sync.c
@@ -84,6 +84,7 @@ static DBusMessage *sync_setlocation(DBusConnection *connection,
}

static void sync_getphonebook_callback(struct obc_session *session,
+ struct obc_transfer *transfer,
GError *err, void *user_data)
{
struct sync_data *sync = user_data;
--
1.7.7.6


2012-04-27 10:33:37

by Mikel Astiz

[permalink] [raw]
Subject: [PATCH obexd v0 3/6] client: Avoid GObex dependency from transfer.h

This workaround makes it possible to include transfer.h from the
modules, without adding a dependency to GObex.
---
client/transfer.c | 2 +-
client/transfer.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/client/transfer.c b/client/transfer.c
index 89690d0..411a7c0 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -610,7 +610,7 @@ static gboolean transfer_start_put(struct obc_transfer *transfer, GError **err)
return TRUE;
}

-gboolean obc_transfer_start(struct obc_transfer *transfer, GObex *obex,
+gboolean obc_transfer_start(struct obc_transfer *transfer, void *obex,
GError **err)
{
transfer->obex = g_obex_ref(obex);
diff --git a/client/transfer.h b/client/transfer.h
index f42e21f..1b83d18 100644
--- a/client/transfer.h
+++ b/client/transfer.h
@@ -55,7 +55,7 @@ gboolean obc_transfer_set_callback(struct obc_transfer *transfer,
transfer_callback_t func,
void *user_data);

-gboolean obc_transfer_start(struct obc_transfer *transfer, GObex *obex,
+gboolean obc_transfer_start(struct obc_transfer *transfer, void *obex,
GError **err);
guint8 obc_transfer_get_operation(struct obc_transfer *transfer);

--
1.7.7.6


2012-04-27 10:33:35

by Mikel Astiz

[permalink] [raw]
Subject: [PATCH obexd v0 1/6] client: Minor buffer access API changes

From: Mikel Astiz <[email protected]>

Trivial changes in buffer getters in both session and transfer,
regarding the access of transfer parameters:
- const qualifiers added, to avoid unwanted frees
- Buffers are now returned as void* instead of guint8*
---
client/pbap.c | 2 +-
client/session.c | 17 +++++++----------
client/session.h | 2 +-
client/transfer.c | 12 +++++++-----
client/transfer.h | 6 +++---
5 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/client/pbap.c b/client/pbap.c
index baf2ca6..d96b651 100644
--- a/client/pbap.c
+++ b/client/pbap.c
@@ -294,7 +294,7 @@ static void pbap_setpath_cb(struct obc_session *session, GError *err,
static void read_return_apparam(struct obc_session *session,
guint16 *phone_book_size, guint8 *new_missed_calls)
{
- struct apparam_hdr *hdr;
+ const struct apparam_hdr *hdr;
size_t size;

*phone_book_size = 0;
diff --git a/client/session.c b/client/session.c
index e277fa0..824ef49 100644
--- a/client/session.c
+++ b/client/session.c
@@ -1156,22 +1156,19 @@ int obc_session_get_contents(struct obc_session *session, char **contents,
return obc_transfer_get_contents(transfer, contents, size);
}

-void *obc_session_get_params(struct obc_session *session, size_t *size)
+const void *obc_session_get_params(struct obc_session *session, size_t *size)
{
struct obc_transfer *transfer;
- struct obc_transfer_params params;

- transfer= obc_session_get_transfer(session);
- if (transfer == NULL)
- return NULL;
+ transfer = obc_session_get_transfer(session);
+ if (transfer == NULL) {
+ if (size != NULL)
+ *size = 0;

- if (obc_transfer_get_params(transfer, &params) < 0)
return NULL;
+ }

- if (size)
- *size = params.size;
-
- return params.data;
+ return obc_transfer_get_params(transfer, size);
}

static void setpath_complete(struct obc_session *session, GError *err,
diff --git a/client/session.h b/client/session.h
index c443392..b44cf3f 100644
--- a/client/session.h
+++ b/client/session.h
@@ -54,7 +54,7 @@ const char *obc_session_get_path(struct obc_session *session);
const char *obc_session_get_target(struct obc_session *session);
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);
+const void *obc_session_get_params(struct obc_session *session, size_t *size);

guint obc_session_send(struct obc_session *session, const char *filename,
const char *name, GError **err);
diff --git a/client/transfer.c b/client/transfer.c
index 8b5d126..89690d0 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -631,13 +631,15 @@ guint8 obc_transfer_get_operation(struct obc_transfer *transfer)
return transfer->op;
}

-int obc_transfer_get_params(struct obc_transfer *transfer,
- struct obc_transfer_params *params)
+const void *obc_transfer_get_params(struct obc_transfer *transfer, size_t *size)
{
- params->data = transfer->params->data;
- params->size = transfer->params->size;
+ if (transfer->params == NULL)
+ return NULL;

- return 0;
+ if (size != NULL)
+ *size = transfer->params->size;
+
+ return transfer->params->data;
}

int obc_transfer_get_contents(struct obc_transfer *transfer, char **contents,
diff --git a/client/transfer.h b/client/transfer.h
index 3f5e22d..f42e21f 100644
--- a/client/transfer.h
+++ b/client/transfer.h
@@ -22,7 +22,7 @@
*/

struct obc_transfer_params {
- guint8 *data;
+ void *data;
size_t size;
};

@@ -59,8 +59,8 @@ 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,
- struct obc_transfer_params *params);
+const void *obc_transfer_get_params(struct obc_transfer *transfer,
+ size_t *size);
int obc_transfer_get_contents(struct obc_transfer *transfer, char **contents,
size_t *size);

--
1.7.7.6