diff --git a/gobex/gobex.c b/gobex/gobex.c
index f98551e..8cd7f17 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
/* Higher level functions */
-guint g_obex_connect(GObex *obex, void *target, gsize target_len,
- GObexResponseFunc func, gpointer user_data,
- GError **err)
+guint g_obex_connect(GObex *obex, GObexResponseFunc func, gpointer user_data,
+ GError **err, guint8 first_hdr_id, ...)
{
GObexPacket *req;
struct connect_data data;
+ va_list args;
- req = g_obex_packet_new(G_OBEX_OP_CONNECT, TRUE, G_OBEX_HDR_INVALID);
+ va_start(args, first_hdr_id);
+ req = g_obex_packet_new_valist(G_OBEX_OP_CONNECT, TRUE,
+ first_hdr_id, args);
+ va_end(args);
init_connect_data(obex, &data);
g_obex_packet_set_data(req, &data, sizeof(data), G_OBEX_DATA_COPY);
- if (target != NULL) {
- GObexHeader *hdr;
- hdr = g_obex_header_new_bytes(G_OBEX_HDR_TARGET,
- target, target_len);
- g_obex_packet_add_header(req, hdr);
- }
-
return g_obex_send_req(obex, req, -1, func, user_data, err);
}
gpointer user_data, GError **err)
{
GObexPacket *req;
- GObexHeader *hdr;
struct setpath_data data;
- req = g_obex_packet_new(G_OBEX_OP_SETPATH, TRUE, G_OBEX_HDR_INVALID);
+ req = g_obex_packet_new(G_OBEX_OP_SETPATH, TRUE,
+ G_OBEX_HDR_NAME, path,
+ G_OBEX_HDR_INVALID);
memset(&data, 0, sizeof(data));
- hdr = g_obex_header_new_unicode(G_OBEX_HDR_NAME, path);
- g_obex_packet_add_header(req, hdr);
-
g_obex_packet_set_data(req, &data, sizeof(data), G_OBEX_DATA_COPY);
return g_obex_send_req(obex, req, -1, func, user_data, err);
gpointer user_data, GError **err)
{
GObexPacket *req;
- GObexHeader *hdr;
-
- req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_INVALID);
- hdr = g_obex_header_new_unicode(G_OBEX_HDR_NAME, name);
- g_obex_packet_add_header(req, hdr);
+ req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE,
+ G_OBEX_HDR_NAME, name,
+ 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 1c0e170..cfe9235 100644
--- a/gobex/gobex.h
+++ b/gobex/gobex.h
#ifndef __GOBEX_H
#define __GOBEX_H
+#include <stdarg.h>
#include <glib.h>
#include <gobex/gobex-packet.h>
/* Higher level functions */
-guint g_obex_connect(GObex *obex, void *target, gsize target_len,
- GObexResponseFunc func, gpointer user_data,
- GError **err);
+guint g_obex_connect(GObex *obex, GObexResponseFunc func, gpointer user_data,
+ GError **err, guint8 first_hdr_id, ...);
guint g_obex_setpath(GObex *obex, const char *path, GObexResponseFunc func,
gpointer user_data, GError **err);
diff --git a/tools/obex-client-tool.c b/tools/obex-client-tool.c
index 9b3279a..a621ec2 100644
--- a/tools/obex-client-tool.c
+++ b/tools/obex-client-tool.c
static void cmd_connect(int argc, char **argv)
{
- g_obex_connect(obex, NULL, 0, conn_complete, NULL, NULL);
+ g_obex_connect(obex, conn_complete, NULL, NULL, G_OBEX_HDR_INVALID);
}
struct put_data {
diff --git a/unit/test-gobex.c b/unit/test-gobex.c
index 005fe3e..bf363f4 100644
--- a/unit/test-gobex.c
+++ b/unit/test-gobex.c
timer_id = g_timeout_add_seconds(1, test_timeout, &d);
- g_obex_connect(obex, NULL, 0, req_complete, &d, &d.err);
+ g_obex_connect(obex, req_complete, &d, &d.err, G_OBEX_HDR_INVALID);
g_assert_no_error(d.err);
g_main_loop_run(d.mainloop);