From 7f18c7db870ac0e814bb7755d3a99f69fe89774c Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 26 Nov 2008 10:06:09 +0100 Subject: [PATCH] obexd: Change low-level functions to support application parameters --- obexd/gwobex/gw-obex.c | 18 +++++++++--------- obexd/gwobex/obex-priv.c | 12 ++++++++++++ obexd/gwobex/obex-priv.h | 2 ++ obexd/gwobex/obex-xfer.c | 4 ++-- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/obexd/gwobex/gw-obex.c b/obexd/gwobex/gw-obex.c index 061e9e933..ef32ff8fa 100644 --- a/obexd/gwobex/gw-obex.c +++ b/obexd/gwobex/gw-obex.c @@ -44,7 +44,7 @@ gboolean gw_obex_get_file(GwObex *ctx, gboolean ret; GW_OBEX_LOCK(ctx); CHECK_DISCONNECT(FALSE, error, ctx); - ret = gw_obex_get(ctx, local, remote, type, NULL, NULL, -1, FALSE); + ret = gw_obex_get(ctx, local, remote, type, NULL, 0, NULL, NULL, -1, FALSE); if (ret == FALSE) gw_obex_get_error(ctx, error); GW_OBEX_UNLOCK(ctx); @@ -59,7 +59,7 @@ gboolean gw_obex_get_fd(GwObex *ctx, gboolean ret; GW_OBEX_LOCK(ctx); CHECK_DISCONNECT(FALSE, error, ctx); - ret = gw_obex_get(ctx, NULL, remote, type, NULL, NULL, fd, FALSE); + ret = gw_obex_get(ctx, NULL, remote, type, NULL, 0, NULL, NULL, fd, FALSE); if (ret == FALSE) gw_obex_get_error(ctx, error); GW_OBEX_UNLOCK(ctx); @@ -74,7 +74,7 @@ gboolean gw_obex_put_fd(GwObex *ctx, gboolean ret; GW_OBEX_LOCK(ctx); CHECK_DISCONNECT(FALSE, error, ctx); - ret = gw_obex_put(ctx, NULL, remote, type, NULL, 0, -1, fd, FALSE); + ret = gw_obex_put(ctx, NULL, remote, type, NULL, 0, NULL, 0, -1, fd, FALSE); if (ret == FALSE) gw_obex_get_error(ctx, error); GW_OBEX_UNLOCK(ctx); @@ -89,7 +89,7 @@ gboolean gw_obex_put_file(GwObex *ctx, gboolean ret; GW_OBEX_LOCK(ctx); CHECK_DISCONNECT(FALSE, error, ctx); - ret = gw_obex_put(ctx, local, remote, type, NULL, 0, -1, -1, FALSE); + ret = gw_obex_put(ctx, local, remote, type, NULL, 0, NULL, 0, -1, -1, FALSE); if (ret == FALSE) gw_obex_get_error(ctx, error); GW_OBEX_UNLOCK(ctx); @@ -105,7 +105,7 @@ gboolean gw_obex_get_buf(GwObex *ctx, gboolean ret; GW_OBEX_LOCK(ctx); CHECK_DISCONNECT(FALSE, error, ctx); - ret = gw_obex_get(ctx, NULL, remote, type, buf, buf_size, -1, FALSE); + ret = gw_obex_get(ctx, NULL, remote, type, NULL, 0, buf, buf_size, -1, FALSE); if (ret == FALSE) gw_obex_get_error(ctx, error); GW_OBEX_UNLOCK(ctx); @@ -122,7 +122,7 @@ gboolean gw_obex_put_buf(GwObex *ctx, gboolean ret; GW_OBEX_LOCK(ctx); CHECK_DISCONNECT(FALSE, error, ctx); - ret = gw_obex_put(ctx, NULL, remote, type, buf, buf_size, time, -1, FALSE); + ret = gw_obex_put(ctx, NULL, remote, type, NULL, 0, buf, buf_size, time, -1, FALSE); if (ret == FALSE) gw_obex_get_error(ctx, error); GW_OBEX_UNLOCK(ctx); @@ -158,7 +158,7 @@ gboolean gw_obex_read_dir(GwObex *ctx, const gchar *dir, gboolean ret; GW_OBEX_LOCK(ctx); CHECK_DISCONNECT(FALSE, error, ctx); - ret = gw_obex_get(ctx, NULL, dir ? dir : "", LST_TYPE, buf, buf_size, -1, FALSE); + ret = gw_obex_get(ctx, NULL, dir ? dir : "", LST_TYPE, NULL, 0, buf, buf_size, -1, FALSE); if (ret == FALSE) gw_obex_get_error(ctx, error); else if (*buf_size > 0) { @@ -181,7 +181,7 @@ gboolean gw_obex_delete(GwObex *ctx, const gchar *name, gint *error) { gboolean ret; GW_OBEX_LOCK(ctx); CHECK_DISCONNECT(FALSE, error, ctx); - ret = gw_obex_put(ctx, NULL, name, NULL, NULL, 0, -1, -1, FALSE); + ret = gw_obex_put(ctx, NULL, name, NULL, NULL, 0, NULL, 0, -1, -1, FALSE); if (ret == FALSE) gw_obex_get_error(ctx, error); GW_OBEX_UNLOCK(ctx); @@ -214,7 +214,7 @@ gboolean gw_obex_get_capability(GwObex *ctx, gchar **cap, gint *cap_len, gint *e gboolean ret; GW_OBEX_LOCK(ctx); CHECK_DISCONNECT(FALSE, error, ctx); - ret = gw_obex_get(ctx, NULL, NULL, CAP_TYPE, cap, cap_len, -1, FALSE); + ret = gw_obex_get(ctx, NULL, NULL, CAP_TYPE, NULL, 0, cap, cap_len, -1, FALSE); if (ret == FALSE) { *cap = NULL; *cap_len = 0; diff --git a/obexd/gwobex/obex-priv.c b/obexd/gwobex/obex-priv.c index 7352cdc31..d67a4ac71 100644 --- a/obexd/gwobex/obex-priv.c +++ b/obexd/gwobex/obex-priv.c @@ -829,6 +829,7 @@ out: gboolean gw_obex_get(GwObex *ctx, const gchar *local, const gchar *remote, const gchar *type, + const guint8 *apparam, gint apparam_size, gchar **buf, gint *buf_size, int stream_fd, gboolean async) { gboolean ret = FALSE; @@ -854,6 +855,11 @@ gboolean gw_obex_get(GwObex *ctx, OBEX_ObjectAddHeader(ctx->handle, object, OBEX_HDR_CONNECTION, hv, 4, 0); } + if (apparam && apparam_size > 0) { + hv.bs = (unsigned char *)apparam; + OBEX_ObjectAddHeader(ctx->handle, object, OBEX_HDR_APPARAM, hv, apparam_size, 0); + } + if (type) { hv.bs = (unsigned char *)type; OBEX_ObjectAddHeader(ctx->handle, object, OBEX_HDR_TYPE, hv, strlen(type) + 1, 0); @@ -940,6 +946,7 @@ out: gboolean gw_obex_put(GwObex *ctx, const gchar *local, const gchar *remote, const gchar *type, + const guint8 *apparam, gint apparam_size, const gchar *buf, gint object_size, time_t object_time, int stream_fd, gboolean async) { gboolean ret = FALSE; @@ -1016,6 +1023,11 @@ gboolean gw_obex_put(GwObex *ctx, OBEX_ObjectAddHeader(ctx->handle, object, OBEX_HDR_TYPE, hv, strlen(type) + 1, 0); } + if (apparam && apparam_size > 0) { + hv.bs = (unsigned char *)apparam; + OBEX_ObjectAddHeader(ctx->handle, object, OBEX_HDR_APPARAM, hv, apparam_size, 0); + } + /* Try to figure out modification time if none was given */ if (ctx->xfer->stream_fd >= 0) { struct stat stats; diff --git a/obexd/gwobex/obex-priv.h b/obexd/gwobex/obex-priv.h index b6cbbf650..01d7b8bd4 100644 --- a/obexd/gwobex/obex-priv.h +++ b/obexd/gwobex/obex-priv.h @@ -197,6 +197,7 @@ gboolean gw_obex_setpath(GwObex *ctx, const gchar *path, int flags); */ gboolean gw_obex_get(GwObex *ctx, const gchar *local, const gchar *remote, const gchar *type, + const guint8 *apparam, gint apparam_size, gchar **buf, gint *buf_size, int stream_fd, gboolean async); @@ -209,6 +210,7 @@ gboolean gw_obex_get(GwObex *ctx, */ gboolean gw_obex_put(GwObex *ctx, const gchar *local, const gchar *remote, const gchar *type, + const guint8 *apparam, gint apparam_size, const gchar *buf, gint buf_size, time_t object_time, int stream_fd, gboolean async); diff --git a/obexd/gwobex/obex-xfer.c b/obexd/gwobex/obex-xfer.c index 0f3248d7c..c7ebbd553 100644 --- a/obexd/gwobex/obex-xfer.c +++ b/obexd/gwobex/obex-xfer.c @@ -117,7 +117,7 @@ GwObexXfer *gw_obex_put_async(GwObex *ctx, const char *name, const char *type, gboolean ret; GW_OBEX_LOCK(ctx); CHECK_DISCONNECT(NULL, error, ctx); - ret = gw_obex_put(ctx, NULL, name, type, NULL, size, time, -1, TRUE); + ret = gw_obex_put(ctx, NULL, name, type, NULL, 0, NULL, size, time, -1, TRUE); if (ret == FALSE) gw_obex_get_error(ctx, error); GW_OBEX_UNLOCK(ctx); @@ -128,7 +128,7 @@ GwObexXfer *gw_obex_get_async(GwObex *ctx, const char *name, const char *type, g gboolean ret; GW_OBEX_LOCK(ctx); CHECK_DISCONNECT(NULL, error, ctx); - ret = gw_obex_get(ctx, NULL, name, type, NULL, NULL, -1, TRUE); + ret = gw_obex_get(ctx, NULL, name, type, NULL, 0, NULL, NULL, -1, TRUE); if (ret == FALSE) gw_obex_get_error(ctx, error); GW_OBEX_UNLOCK(ctx); -- 2.47.3