From 7ae0a229fbb3dd06174741be6112064990bea6e9 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 27 Nov 2008 14:46:26 +0100 Subject: [PATCH] obexd: Add more functions for dealing with application parameters --- obexd/gwobex/gw-obex.c | 37 +++++++++++++++++++++++++++++++++++++ obexd/gwobex/gw-obex.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/obexd/gwobex/gw-obex.c b/obexd/gwobex/gw-obex.c index ef32ff8fa..e65669296 100644 --- a/obexd/gwobex/gw-obex.c +++ b/obexd/gwobex/gw-obex.c @@ -129,6 +129,43 @@ gboolean gw_obex_put_buf(GwObex *ctx, return ret; } +gboolean gw_obex_get_buf_with_apparam(GwObex *ctx, + const gchar *remote, + const gchar *type, + const guint8 *apparam, + gint apparam_size, + gchar **buf, + gint *buf_size, + gint *error) { + gboolean ret; + GW_OBEX_LOCK(ctx); + CHECK_DISCONNECT(FALSE, error, ctx); + ret = gw_obex_get(ctx, NULL, remote, type, apparam, apparam_size, buf, buf_size, -1, FALSE); + if (ret == FALSE) + gw_obex_get_error(ctx, error); + GW_OBEX_UNLOCK(ctx); + return ret; +} + +gboolean gw_obex_put_buf_with_apparam(GwObex *ctx, + const gchar *remote, + const gchar *type, + const guint8 *apparam, + gint apparam_size, + const gchar *buf, + gint buf_size, + gint time, + gint *error) { + gboolean ret; + GW_OBEX_LOCK(ctx); + CHECK_DISCONNECT(FALSE, error, ctx); + ret = gw_obex_put(ctx, NULL, remote, type, apparam, apparam_size, buf, buf_size, time, -1, FALSE); + if (ret == FALSE) + gw_obex_get_error(ctx, error); + GW_OBEX_UNLOCK(ctx); + return ret; +} + gboolean gw_obex_chdir(GwObex *ctx, const gchar *dir, gint *error) { gboolean ret; GW_OBEX_LOCK(ctx); diff --git a/obexd/gwobex/gw-obex.h b/obexd/gwobex/gw-obex.h index fcbb40ab1..6f9943096 100644 --- a/obexd/gwobex/gw-obex.h +++ b/obexd/gwobex/gw-obex.h @@ -365,6 +365,48 @@ gboolean gw_obex_put_buf(GwObex *ctx, const gchar *remote, const gchar *type, const gchar *buf, gint buf_size, gint time, gint *error); +/** Get an object from the remote device and store it in a memory buffer. + * Either remote filename or type must be supplied (or both). + * + * @param ctx Pointer returned by gw_obex_setup() + * @param remote Remote filename (null terminated UTF-8) + * @param type MIME-type of the object + * @param apparam Application parameters of the object + * @param apparam_size Application parameters size + * @param buf Buffer to store the object in. + * g_free() when not needed anymore. + * @param buf_size Place to store length of fetched object + * @param error Place to store error code on failure + * (NULL if not interested) + * + * @returns TRUE on success, FALSE on failure + */ +gboolean gw_obex_get_buf_with_apparam(GwObex *ctx, const gchar *remote, const gchar *type, + const guint8 *apparam, gint apparam_size, + gchar **buf, gint *buf_size, gint *error); + + +/** Send a object located in a memory buffer to the remote device. + * Either remote filename or type must be supplied (or both) + * + * @param ctx Pointer returned by gw_obex_setup() + * @param remote Remote filename (null terminated UTF-8) + * @param type MIME-type of the object + * @param apparam Application parameters of the object + * @param apparam_size Application parameters size + * @param buf Buffer containing the object + * @param buf_size Buffer (object) size + * @param time Last modification time of object (or -1 if not known) + * @param error Place to store error code on failure + * (NULL if not interested) + * + * @returns TRUE on success, FALSE on failure + */ +gboolean gw_obex_put_buf_with_apparam(GwObex *ctx, const gchar *remote, const gchar *type, + const guint8 *apparam, gint apparam_size, + const gchar *buf, gint buf_size, gint time, gint *error); + + /** Change directory (relative to the current one). * * @param ctx Pointer returned by gw_obex_setup() -- 2.47.3