diff --git a/obexd/client/map.c b/obexd/client/map.c
index 4b5f8a2..e78cd68 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
struct obc_transfer *transfer;
GError *err = NULL;
DBusMessage *reply;
- guint8 buf[8];
- gsize len;
-
- len = g_obex_apparam_encode(apparam, buf, sizeof(buf));
- g_obex_apparam_free(apparam);
transfer = obc_transfer_get("x-obex/folder-listing", NULL, NULL, &err);
- if (transfer == NULL)
+ if (transfer == NULL) {
+ g_obex_apparam_free(apparam);
goto fail;
+ }
- obc_transfer_set_params(transfer, buf, len);
+ obc_transfer_set_apparam(transfer, apparam);
if (obc_session_queue(map->session, transfer, folder_listing_cb, map,
&err)) {
GError *err = NULL;
DBusMessage *reply;
GObexApparam *apparam;
- guint8 buf[6];
- gsize len;
if (dbus_message_get_args(message, NULL,
DBUS_TYPE_STRING, &target_file,
attachment);
apparam = g_obex_apparam_set_uint8(apparam, MAP_AP_CHARSET,
CHARSET_UTF8);
- len = g_obex_apparam_encode(apparam, buf, sizeof(buf));
-
- obc_transfer_set_params(transfer, buf, len);
- g_obex_apparam_free(apparam);
+ obc_transfer_set_apparam(transfer, apparam);
if (!obc_session_queue(msg->data->session, transfer, NULL, NULL, &err))
goto fail;
struct obc_transfer *transfer;
GError *err = NULL;
DBusMessage *reply;
- guint8 buf[1024];
- gsize len;
-
- len = g_obex_apparam_encode(apparam, buf, sizeof(buf));
- g_obex_apparam_free(apparam);
transfer = obc_transfer_get("x-bt/MAP-msg-listing", folder, NULL, &err);
- if (transfer == NULL)
+ if (transfer == NULL) {
+ g_obex_apparam_free(apparam);
goto fail;
+ }
- obc_transfer_set_params(transfer, buf, len);
+ obc_transfer_set_apparam(transfer, apparam);
if (obc_session_queue(map->session, transfer, message_listing_cb, map,
&err)) {
diff --git a/obexd/client/pbap.c b/obexd/client/pbap.c
index a8db1cf..ea4a023 100644
--- a/obexd/client/pbap.c
+++ b/obexd/client/pbap.c
guint16 *phone_book_size, guint8 *new_missed_calls)
{
GObexApparam *apparam;
- const guint8 *data;
- size_t size;
*phone_book_size = 0;
*new_missed_calls = 0;
- data = obc_transfer_get_params(transfer, &size);
- if (data == NULL)
- return;
-
- apparam = g_obex_apparam_decode(data, size);
+ apparam = obc_transfer_get_apparam(transfer);
if (apparam == NULL)
return;
g_obex_apparam_get_uint8(apparam, NEWMISSEDCALLS_TAG,
new_missed_calls);
-
g_obex_apparam_free(apparam);
}
struct pending_request *request;
struct obc_transfer *transfer;
char *name;
- guint8 buf[32];
- gsize len;
session_callback_t func;
DBusMessage *reply;
GError *err = NULL;
name = g_strconcat(pbap->path, ".vcf", NULL);
- len = g_obex_apparam_encode(apparam, buf, sizeof(buf));
- g_obex_apparam_free(apparam);
-
transfer = obc_transfer_get("x-bt/phonebook", name, targetfile, &err);
- if (transfer == NULL)
+ if (transfer == NULL) {
+ g_obex_apparam_free(apparam);
goto fail;
+ }
switch (type) {
case PULLPHONEBOOK:
return NULL;
}
- obc_transfer_set_params(transfer, buf, len);
+ obc_transfer_set_apparam(transfer, apparam);
if (!obc_session_queue(pbap->session, transfer, func, request, &err)) {
if (request != NULL)
{
struct pending_request *request;
struct obc_transfer *transfer;
- guint8 buf[272];
- gsize len;
GError *err = NULL;
DBusMessage *reply;
- len = g_obex_apparam_encode(apparam, buf, sizeof(buf));
- g_obex_apparam_free(apparam);
-
transfer = obc_transfer_get("x-bt/vcard-listing", name, NULL, &err);
- if (transfer == NULL)
+ if (transfer == NULL) {
+ g_obex_apparam_free(apparam);
goto fail;
+ }
- obc_transfer_set_params(transfer, buf, len);
+ obc_transfer_set_apparam(transfer, apparam);
request = pending_request_new(pbap, message);
if (obc_session_queue(pbap->session, transfer,
struct obc_transfer *transfer;
DBusMessage *reply;
GError *err = NULL;
- guint8 buf[32];
- gsize len;
-
- len = g_obex_apparam_encode(apparam, buf, sizeof(buf));
- g_obex_apparam_free(apparam);
transfer = obc_transfer_get("x-bt/vcard", name, targetfile, &err);
- if (transfer == NULL)
+ if (transfer == NULL) {
+ g_obex_apparam_free(apparam);
goto fail;
+ }
- obc_transfer_set_params(transfer, buf, len);
+ obc_transfer_set_apparam(transfer, apparam);
if (!obc_session_queue(pbap->session, transfer, NULL, NULL, &err))
goto fail;
diff --git a/obexd/client/transfer.c b/obexd/client/transfer.c
index e9fabfb..bd5277b 100644
--- a/obexd/client/transfer.c
+++ b/obexd/client/transfer.c
void *data;
};
-struct obc_transfer_params {
- void *data;
- size_t size;
-};
-
struct obc_transfer {
GObex *obex;
+ GObexApparam *apparam;
guint8 op;
- struct obc_transfer_params *params;
struct transfer_callback *callback;
DBusConnection *conn;
DBusMessage *msg;
if (transfer->fd > 0)
close(transfer->fd);
- if (transfer->params != NULL) {
- g_free(transfer->params->data);
- g_free(transfer->params);
- }
+ if (transfer->apparam != NULL)
+ g_obex_apparam_free(transfer->apparam);
if (transfer->conn)
dbus_connection_unref(transfer->conn);
struct obc_transfer *transfer = user_data;
GObexPacket *req;
GObexHeader *hdr;
+ GObexApparam *apparam;
const guint8 *buf;
gsize len;
guint8 rspcode;
hdr = g_obex_packet_get_header(rsp, G_OBEX_HDR_APPARAM);
if (hdr) {
- g_obex_header_get_bytes(hdr, &buf, &len);
- if (len != 0) {
- if (transfer->params == NULL)
- transfer->params =
- g_new0(struct obc_transfer_params, 1);
- else
- g_free(transfer->params->data);
-
- transfer->params->data = g_memdup(buf, len);
- transfer->params->size = len;
- }
+ apparam = g_obex_header_get_apparam(hdr);
+ if (apparam != NULL)
+ obc_transfer_set_apparam(transfer, apparam);
}
hdr = g_obex_packet_get_body(rsp);
static gboolean transfer_start_get(struct obc_transfer *transfer, GError **err)
{
GObexPacket *req;
+ GObexHeader *hdr;
if (transfer->xfer > 0) {
g_set_error(err, OBC_TRANSFER_ERROR, -EALREADY,
g_obex_packet_add_bytes(req, G_OBEX_HDR_TYPE, transfer->type,
strlen(transfer->type) + 1);
- if (transfer->params != NULL)
- g_obex_packet_add_bytes(req, G_OBEX_HDR_APPARAM,
- transfer->params->data,
- transfer->params->size);
+ if (transfer->apparam != NULL) {
+ hdr = g_obex_header_new_apparam(transfer->apparam);
+ g_obex_packet_add_header(req, hdr);
+ }
transfer->xfer = g_obex_send_req(transfer->obex, req,
FIRST_PACKET_TIMEOUT,
static gboolean transfer_start_put(struct obc_transfer *transfer, GError **err)
{
GObexPacket *req;
+ GObexHeader *hdr;
if (transfer->xfer > 0) {
g_set_error(err, OBC_TRANSFER_ERROR, -EALREADY,
if (transfer->size < UINT32_MAX)
g_obex_packet_add_uint32(req, G_OBEX_HDR_LENGTH, transfer->size);
- if (transfer->params != NULL)
- g_obex_packet_add_bytes(req, G_OBEX_HDR_APPARAM,
- transfer->params->data,
- transfer->params->size);
+ if (transfer->apparam != NULL) {
+ hdr = g_obex_header_new_apparam(transfer->apparam);
+ g_obex_packet_add_header(req, hdr);
+ }
transfer->xfer = g_obex_put_req_pkt(transfer->obex, req,
put_xfer_progress, xfer_complete,
return transfer->op;
}
-void obc_transfer_set_params(struct obc_transfer *transfer,
- const void *data, size_t size)
+void obc_transfer_set_apparam(struct obc_transfer *transfer, void *data)
{
- if (transfer->params != NULL) {
- g_free(transfer->params->data);
- g_free(transfer->params);
- }
+ if (transfer->apparam != NULL)
+ g_obex_apparam_free(transfer->apparam);
if (data == NULL)
return;
- transfer->params = g_new0(struct obc_transfer_params, 1);
- transfer->params->data = g_memdup(data, size);
- transfer->params->size = size;
+ transfer->apparam = data;
}
-const void *obc_transfer_get_params(struct obc_transfer *transfer, size_t *size)
+void *obc_transfer_get_apparam(struct obc_transfer *transfer)
{
- if (transfer->params == NULL)
- return NULL;
-
- if (size != NULL)
- *size = transfer->params->size;
-
- return transfer->params->data;
+ return transfer->apparam;
}
int obc_transfer_get_contents(struct obc_transfer *transfer, char **contents,
diff --git a/obexd/client/transfer.h b/obexd/client/transfer.h
index 968903a..f7d0423 100644
--- a/obexd/client/transfer.h
+++ b/obexd/client/transfer.h
GError **err);
guint8 obc_transfer_get_operation(struct obc_transfer *transfer);
-void obc_transfer_set_params(struct obc_transfer *transfer,
- const void *data, size_t size);
-const void *obc_transfer_get_params(struct obc_transfer *transfer,
- size_t *size);
+void obc_transfer_set_apparam(struct obc_transfer *transfer, void *data);
+void *obc_transfer_get_apparam(struct obc_transfer *transfer);
int obc_transfer_get_contents(struct obc_transfer *transfer, char **contents,
size_t *size);