[maemo-commits] [maemo-commits] r17990 - projects/connectivity/osso-gwobex/trunk/src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Thu Apr 2 13:59:09 EEST 2009
- Previous message: [maemo-commits] r17989 - projects/haf/trunk/hildon-welcome/src
- Next message: [maemo-commits] r17991 - in projects/connectivity/osso-gwobex/trunk: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: jh
Date: 2009-04-02 13:59:08 +0300 (Thu, 02 Apr 2009)
New Revision: 17990
Modified:
projects/connectivity/osso-gwobex/trunk/src/gw-obex.c
projects/connectivity/osso-gwobex/trunk/src/gw-obex.h
projects/connectivity/osso-gwobex/trunk/src/obex-priv.c
projects/connectivity/osso-gwobex/trunk/src/obex-priv.h
projects/connectivity/osso-gwobex/trunk/src/obex-xfer.c
projects/connectivity/osso-gwobex/trunk/src/obex-xfer.h
Log:
Merge gwobex updates from obexd
Modified: projects/connectivity/osso-gwobex/trunk/src/gw-obex.c
===================================================================
--- projects/connectivity/osso-gwobex/trunk/src/gw-obex.c 2009-04-02 10:32:47 UTC (rev 17989)
+++ projects/connectivity/osso-gwobex/trunk/src/gw-obex.c 2009-04-02 10:59:08 UTC (rev 17990)
@@ -44,7 +44,7 @@
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 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 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 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 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,13 +122,50 @@
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);
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);
@@ -158,7 +195,7 @@
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 +218,7 @@
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 +251,7 @@
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;
Modified: projects/connectivity/osso-gwobex/trunk/src/gw-obex.h
===================================================================
--- projects/connectivity/osso-gwobex/trunk/src/gw-obex.h 2009-04-02 10:32:47 UTC (rev 17989)
+++ projects/connectivity/osso-gwobex/trunk/src/gw-obex.h 2009-04-02 10:59:08 UTC (rev 17990)
@@ -88,6 +88,12 @@
/** Length of OBEX_PBAP_UUID */
#define OBEX_PBAP_UUID_LEN 16
+/** IrMC Sync Profile UUID */
+#define OBEX_SYNC_UUID \
+ "IRMC-SYNC"
+/** Length of OBEX_SYNC_UUID */
+#define OBEX_SYNC_UUID_LEN 9
+
/** Struct containing the context of a gwobex connection */
typedef struct gw_obex GwObex;
@@ -365,6 +371,48 @@
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()
@@ -474,7 +522,22 @@
*/
GwObexXfer *gw_obex_get_async(GwObex *ctx, const char *name, const char *type, gint *error);
+/** Start a GET operation asynchronously with application parameters
+ *
+ * @param ctx Pointer returned by gw_obex_setup()
+ * @param name Name of the object (null terminated UTF-8)
+ * @param type Type of the object (null terminated UTF-8), or NULL
+ * @param apparam Application parameters of the object
+ * @param apparam_size Application paramters' size
+ * @param error Place to store error code on failure (NULL if not interested)
+ *
+ * @returns a new GwObexXfer object on success, NULL on failure
+ */
+GwObexXfer *gw_obex_get_async_with_apparam(GwObex *ctx, const char *name, const char *type,
+ const guint8 *apparam, gint apparam_size, gint *error);
+
+
/** Set a callback function for a GwObexXfer object
* The callback function will be called in the following situations:
* <ul>
@@ -511,6 +574,16 @@
gint gw_obex_xfer_object_size(GwObexXfer *xfer);
+/** Get the contents of the application parameters header
+ *
+ * @param xfer Pointer returned by gw_obex_put_async or gw_obex_get_async
+ * @param apparam_size Return value for the size of the application parameters header.
+ *
+ * @returns The pointer to the buffer that hold the contents.
+ */
+unsigned char *gw_obex_xfer_object_apparam(GwObexXfer *xfer, size_t *apparam_size);
+
+
/** Returns if a transfer is already done
*
* @param xfer Pointer returned by gw_obex_put_async or gw_obex_get_async
Modified: projects/connectivity/osso-gwobex/trunk/src/obex-priv.c
===================================================================
--- projects/connectivity/osso-gwobex/trunk/src/obex-priv.c 2009-04-02 10:32:47 UTC (rev 17989)
+++ projects/connectivity/osso-gwobex/trunk/src/obex-priv.c 2009-04-02 10:59:08 UTC (rev 17990)
@@ -330,23 +330,33 @@
}
}
-static void get_target_size_and_time(obex_t *handle, obex_object_t *object,
- gint *size, time_t *time) {
+static void get_non_body_headers(obex_t *handle, obex_object_t *object,
+ struct gw_obex_xfer *xfer) {
obex_headerdata_t hv;
uint8_t hi;
unsigned int hlen;
- *size = GW_OBEX_UNKNOWN_LENGTH;
- *time = -1;
+ xfer->target_size = GW_OBEX_UNKNOWN_LENGTH;
+ xfer->modtime = -1;
while (OBEX_ObjectGetNextHeader(handle, object, &hi, &hv, &hlen)) {
switch (hi) {
case OBEX_HDR_LENGTH:
- *size = hv.bq4; //(gint) g_ntohl(hv.bq4);
+ xfer->target_size = hv.bq4; //(gint) g_ntohl(hv.bq4);
break;
case OBEX_HDR_TIME:
- *time = parse_iso8601((char *)hv.bs, hlen);
+ xfer->modtime = parse_iso8601((char *)hv.bs, hlen);
break;
+ case OBEX_HDR_APPARAM:
+ g_free(xfer->apparam_buf);
+ xfer->apparam_buf = g_try_malloc(hlen);
+ if (xfer->apparam_buf) {
+ memcpy(xfer->apparam_buf, hv.bs, hlen);
+ xfer->apparam_size = hlen;
+ }
+ else
+ xfer->apparam_size = 0;
+ break;
default:
break;
}
@@ -370,8 +380,7 @@
}
if (ctx->xfer->counter == 0) {
- get_target_size_and_time(ctx->handle, object,
- &xfer->target_size, &xfer->modtime);
+ get_non_body_headers(ctx->handle, object, xfer);
show_headers(ctx->handle, object);
}
@@ -829,6 +838,7 @@
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 +864,11 @@
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 +955,7 @@
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 +1032,11 @@
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;
Modified: projects/connectivity/osso-gwobex/trunk/src/obex-priv.h
===================================================================
--- projects/connectivity/osso-gwobex/trunk/src/obex-priv.h 2009-04-02 10:32:47 UTC (rev 17989)
+++ projects/connectivity/osso-gwobex/trunk/src/obex-priv.h 2009-04-02 10:59:08 UTC (rev 17990)
@@ -197,6 +197,7 @@
*/
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_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);
Modified: projects/connectivity/osso-gwobex/trunk/src/obex-xfer.c
===================================================================
--- projects/connectivity/osso-gwobex/trunk/src/obex-xfer.c 2009-04-02 10:32:47 UTC (rev 17989)
+++ projects/connectivity/osso-gwobex/trunk/src/obex-xfer.c 2009-04-02 10:59:08 UTC (rev 17990)
@@ -117,7 +117,7 @@
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,13 +128,25 @@
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);
return ret ? ctx->xfer : NULL;
}
+GwObexXfer *gw_obex_get_async_with_apparam(GwObex *ctx, const char *name, const char *type,
+ const guint8 *apparam, gint apparam_size, gint *error) {
+ gboolean ret;
+ GW_OBEX_LOCK(ctx);
+ CHECK_DISCONNECT(NULL, error, ctx);
+ ret = gw_obex_get(ctx, NULL, name, type, apparam, apparam_size, NULL, NULL, -1, TRUE);
+ if (ret == FALSE)
+ gw_obex_get_error(ctx, error);
+ GW_OBEX_UNLOCK(ctx);
+ return ret ? ctx->xfer : NULL;
+}
+
static gboolean gw_obex_put_idle(GwObexXfer *xfer) {
struct gw_obex *ctx = xfer->ctx;
@@ -184,6 +196,12 @@
return xfer->target_size;
}
+unsigned char *gw_obex_xfer_object_apparam(GwObexXfer *xfer, size_t *apparam_size) {
+ if (apparam_size)
+ *apparam_size = xfer->apparam_size;
+ return xfer->apparam_buf;
+}
+
gboolean gw_obex_xfer_object_done(GwObexXfer *xfer) {
return xfer->ctx->done;
}
@@ -241,7 +259,7 @@
}
if (xfer->data_length >= ctx->tx_max || !free_space) {
- gint old_length = xfer->data_length;
+ guint old_length = xfer->data_length;
debug("OBEX_ResumeRequest at %s:%d (%s)\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
OBEX_ResumeRequest(ctx->handle);
@@ -283,6 +301,7 @@
gboolean gw_obex_xfer_read(GwObexXfer *xfer, char *buf, gint buf_size,
gint *bytes_read, gint *err) {
GwObex *ctx = xfer->ctx;
+ gint data_length;
gboolean ret = TRUE;
debug("gw_obex_xfer_read(buf_size=%d): entered\n", buf_size);
@@ -331,7 +350,8 @@
}
}
- *bytes_read = buf_size < xfer->data_length ? buf_size : xfer->data_length;
+ data_length = xfer->data_length;
+ *bytes_read = buf_size < data_length ? buf_size : data_length;
memcpy(buf, &xfer->buf[xfer->data_start], *bytes_read);
@@ -400,6 +420,7 @@
void _gw_obex_xfer_free(struct gw_obex_xfer *xfer) {
g_free(xfer->buf);
+ g_free(xfer->apparam_buf);
g_free(xfer);
}
Modified: projects/connectivity/osso-gwobex/trunk/src/obex-xfer.h
===================================================================
--- projects/connectivity/osso-gwobex/trunk/src/obex-xfer.h 2009-04-02 10:32:47 UTC (rev 17989)
+++ projects/connectivity/osso-gwobex/trunk/src/obex-xfer.h 2009-04-02 10:59:08 UTC (rev 17990)
@@ -58,6 +58,10 @@
unsigned char *buf;
size_t buf_size;
+ /* Buffer and size for Application parameters */
+ unsigned char *apparam_buf;
+ size_t apparam_size;
+
/* These two elements are only used for async transfers */
size_t data_start;
size_t data_length;
- Previous message: [maemo-commits] r17989 - projects/haf/trunk/hildon-welcome/src
- Next message: [maemo-commits] r17991 - in projects/connectivity/osso-gwobex/trunk: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
