[PATCH obexd v3 05/11] Add functions to get, put w. a_header list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 gwobex/obex-priv.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 gwobex/obex-priv.h |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/gwobex/obex-priv.c b/gwobex/obex-priv.c
index 7d85045..2073c2c 100644
--- a/gwobex/obex-priv.c
+++ b/gwobex/obex-priv.c
@@ -847,6 +847,17 @@ gboolean gw_obex_get(GwObex *ctx,
                      const guint8 *apparam, gint apparam_size,
                      gchar **buf, gint *buf_size, int stream_fd,
                      gboolean async) {
+    return gw_obex_get_with_aheaders(ctx, local, remote, type,
+                                     apparam, apparam_size,
+                                     NULL, buf, buf_size, stream_fd, async);
+}
+
+gboolean gw_obex_get_with_aheaders(GwObex *ctx, const gchar *local,
+                                   const gchar *remote, const gchar *type,
+                                   const guint8 *apparam, gint apparam_size,
+                                   const GSList *aheaders,
+                                   gchar **buf, gint *buf_size, int stream_fd,
+                                   gboolean async) {
     gboolean ret = FALSE;
     obex_headerdata_t hv;
     obex_object_t *object;
@@ -911,6 +922,17 @@ gboolean gw_obex_get(GwObex *ctx,
         }
     }
 
+    if (aheaders) {
+        const GSList *hlist = aheaders;
+        struct a_header *ah;
+        while (hlist) {
+            ah = hlist->data;
+            hv = ah->hv;
+            OBEX_ObjectAddHeader(ctx->handle, object, ah->hi, hv, ah->hv_size, 0);
+            hlist = g_slist_next(hlist);
+        }
+    }
+
     OBEX_ObjectReadStream(ctx->handle, object, NULL);
 
     if (async) {
@@ -964,6 +986,20 @@ gboolean gw_obex_put(GwObex *ctx,
                      const guint8 *apparam, gint apparam_size,
                      const gchar *buf, gint object_size, time_t object_time,
                      int stream_fd, gboolean async) {
+    return gw_obex_put_with_aheaders(ctx, local, remote, type,
+                                     apparam, apparam_size,
+                                     NULL, buf, object_size, object_time,
+                                     stream_fd, async);
+}
+
+gboolean gw_obex_put_with_aheaders(GwObex *ctx,
+                                   const gchar *local, const gchar *remote,
+                                   const gchar *type,
+                                   const guint8 *apparam, gint apparam_size,
+                                   const GSList *aheaders,
+                                   const gchar *buf,
+                                   gint object_size, time_t object_time,
+                                   int stream_fd, gboolean async) {
     gboolean ret = FALSE;
     obex_headerdata_t hv;
     obex_object_t *object;
@@ -1042,6 +1078,17 @@ gboolean gw_obex_put(GwObex *ctx,
         OBEX_ObjectAddHeader(ctx->handle, object, OBEX_HDR_APPARAM, hv, apparam_size, 0);
     }
 
+    if (aheaders) {
+        const GSList *hlist = aheaders;
+        struct a_header *ah;
+        while (hlist) {
+            ah = hlist->data;
+            hv = ah->hv;
+            OBEX_ObjectAddHeader(ctx->handle, object, ah->hi, hv, ah->hv_size, 0);
+            hlist = g_slist_next(hlist);
+        }
+    }
+
     /* Try to figure out modification time if none was given */
     if (ctx->xfer->stream_fd >= 0) {
         struct stat stats;
diff --git a/gwobex/obex-priv.h b/gwobex/obex-priv.h
index f4e3e5b..0ae942c 100644
--- a/gwobex/obex-priv.h
+++ b/gwobex/obex-priv.h
@@ -214,4 +214,38 @@ gboolean gw_obex_put(GwObex *ctx,
                      const gchar *buf, gint buf_size, time_t object_time,
                      int stream_fd, gboolean async);
 
+
+/** Get an object from the server, specifying additional headers
+ * @param ctx Pointer returned by gw_obex_setup()
+ * @param local Local filename which contains the object
+ * @param remote Remote filename to store the object in
+ * @param type MIME-type of the object (NULL if not known)
+ * @param aheaders list of additional headers (NULL if empty)
+ * @returns TRUE on success, FALSE on failure
+ */
+gboolean gw_obex_get_with_aheaders(GwObex *ctx,
+                                   const gchar *local, const gchar *remote,
+                                   const gchar *type,
+                                   const guint8 *apparam, gint apparam_size,
+                                   const GSList *aheaders,
+                                   gchar **buf, gint *buf_size, int stream_fd,
+                                   gboolean async);
+
+/** Send an object to the server
+ * @param ctx Pointer returned by gw_obex_setup()
+ * @param local Local filename to store the objec in
+ * @param remote Remote filename which contains the object
+ * @param type MIME-type of the object (NULL if not known)
+ * @param aheaders list of additional headers (NULL if empty)
+ * @returns TRUE on success, FALSE on failure
+ */
+gboolean gw_obex_put_with_aheaders(GwObex *ctx,
+                                   const gchar *local, const gchar *remote,
+                                   const gchar *type,
+                                   const guint8 *apparam, gint apparam_size,
+                                   const GSList *aheaders,
+                                   const gchar *buf, gint buf_size,
+                                   time_t object_time,
+                                   int stream_fd, gboolean async);
+
 #endif /* _OBEX_PRIV_H_ */
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux