Diff between 508cb6f8c221e1c431fe3ee25664d265a227d95b and c869ca28b82757500bb5c86d1f58cdcd9fe5ea52

Changed Files

File Additions Deletions Status
gobex/gobex.c +13 -21 modified
gobex/gobex.h +3 -3 modified
tools/obex-client-tool.c +1 -1 modified
unit/test-gobex.c +1 -1 modified

Full Patch

diff --git a/gobex/gobex.c b/gobex/gobex.c
index f98551e..8cd7f17 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -907,25 +907,21 @@ void g_obex_unref(GObex *obex)
 
 /* 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);
 }
 
@@ -957,15 +953,13 @@ guint g_obex_mkdir(GObex *obex, const char *path, GObexResponseFunc func,
 					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);
@@ -975,12 +969,10 @@ guint g_obex_delete(GObex *obex, const char *name, GObexResponseFunc func,
 					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
@@ -22,6 +22,7 @@
 #ifndef __GOBEX_H
 #define __GOBEX_H
 
+#include <stdarg.h>
 #include <glib.h>
 
 #include <gobex/gobex-packet.h>
@@ -65,9 +66,8 @@ void g_obex_unref(GObex *obex);
 
 /* 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
@@ -112,7 +112,7 @@ static void conn_complete(GObex *obex, GError *err, GObexPacket *rsp,
 
 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
@@ -841,7 +841,7 @@ static void test_connect(void)
 
 	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);