From e12802a76b6a26d7556be8392aa9af75b8e983c5 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 30 Aug 2011 12:30:39 +0300 Subject: [PATCH] gobex: Add Action command convenience functions --- gobex/gobex-header.h | 5 +++++ gobex/gobex.c | 30 ++++++++++++++++++++++++++++++ gobex/gobex.h | 8 ++++++++ 3 files changed, 43 insertions(+) diff --git a/gobex/gobex-header.h b/gobex/gobex-header.h index b7d23eb82..2420e750f 100644 --- a/gobex/gobex-header.h +++ b/gobex/gobex-header.h @@ -55,6 +55,11 @@ #define G_OBEX_HDR_SRM 0x97 #define G_OBEX_HDR_SRM_PARAMETERS 0x98 +/* Action header values */ +#define G_OBEX_ACTION_COPY 0x00 +#define G_OBEX_ACTION_MOVE 0x01 +#define G_OBEX_ACTION_SETPERM 0x02 + typedef struct _GObexHeader GObexHeader; gboolean g_obex_header_get_unicode(GObexHeader *header, const char **str); diff --git a/gobex/gobex.c b/gobex/gobex.c index 7c2fbcccb..5d63c6e9d 100644 --- a/gobex/gobex.c +++ b/gobex/gobex.c @@ -1008,3 +1008,33 @@ guint g_obex_delete(GObex *obex, const char *name, GObexResponseFunc func, return g_obex_send_req(obex, req, -1, func, user_data, err); } + +guint g_obex_copy(GObex *obex, const char *name, const char *dest, + GObexResponseFunc func, gpointer user_data, + GError **err) +{ + GObexPacket *req; + + req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, + G_OBEX_HDR_ACTION, G_OBEX_ACTION_COPY, + G_OBEX_HDR_NAME, name, + G_OBEX_HDR_DESTNAME, dest, + G_OBEX_HDR_INVALID); + + return g_obex_send_req(obex, req, -1, func, user_data, err); +} + +guint g_obex_move(GObex *obex, const char *name, const char *dest, + GObexResponseFunc func, gpointer user_data, + GError **err) +{ + GObexPacket *req; + + req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, + G_OBEX_HDR_ACTION, G_OBEX_ACTION_MOVE, + G_OBEX_HDR_NAME, name, + G_OBEX_HDR_DESTNAME, dest, + G_OBEX_HDR_INVALID); + + return g_obex_send_req(obex, req, -1, func, user_data, err); +} diff --git a/gobex/gobex.h b/gobex/gobex.h index a8424f32e..e210e7954 100644 --- a/gobex/gobex.h +++ b/gobex/gobex.h @@ -82,6 +82,14 @@ guint g_obex_mkdir(GObex *obex, const char *path, GObexResponseFunc func, guint g_obex_delete(GObex *obex, const char *name, GObexResponseFunc func, gpointer user_data, GError **err); +guint g_obex_copy(GObex *obex, const char *name, const char *dest, + GObexResponseFunc func, gpointer user_data, + GError **err); + +guint g_obex_move(GObex *obex, const char *name, const char *dest, + GObexResponseFunc func, gpointer user_data, + GError **err); + /* Transfer related high-level functions */ guint g_obex_put_req(GObex *obex, GObexDataProducer data_func, -- 2.47.3