diff --git a/gobex/gobex.c b/gobex/gobex.c
index 8ae23b8..ef0feef 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
#include "gobex.h"
+struct _GObexRequest {
+ uint8_t opcode;
+ GSList *headers;
+};
+
struct _GObex {
gint ref_count;
GIOChannel *io;
+
+ GQueue *req_queue;
};
+GObexRequest *g_obex_request_new(uint8_t opcode)
+{
+ GObexRequest *req;
+
+ req = g_new0(GObexRequest, 1);
+
+ req->opcode = opcode;
+
+ return req;
+}
+
+void g_obex_request_free(GObexRequest *req)
+{
+ g_free(req);
+}
+
+gboolean g_obex_send(GObex *obex, GObexRequest *req)
+{
+ if (obex == NULL || req == NULL)
+ return FALSE;
+
+ g_queue_push_tail(obex->req_queue, req);
+
+ return TRUE;
+}
+
GObex *g_obex_new(GIOChannel *io)
{
GObex *obex;
obex->io = io;
obex->ref_count = 1;
+ obex->req_queue = g_queue_new();
return obex;
}
if (!last_ref)
return;
+ g_queue_foreach(obex->req_queue, (GFunc) g_obex_request_free, NULL);
+ g_queue_free(obex->req_queue);
+
g_io_channel_unref(obex->io);
g_free(obex);
diff --git a/gobex/gobex.h b/gobex/gobex.h
index cdc7f77..3910367 100644
--- a/gobex/gobex.h
+++ b/gobex/gobex.h
#include <stdint.h>
#include <glib.h>
+#include <gobex/obex.h>
+
typedef struct _GObex GObex;
+typedef struct _GObexRequest GObexRequest;
+
+GObexRequest *g_obex_request_new(uint8_t opcode);
+void g_obex_request_free(GObexRequest *req);
+
+gboolean g_obex_send(GObex *obex, GObexRequest *req);
GObex *g_obex_new(GIOChannel *io);
diff --git a/unit/test-gobex.c b/unit/test-gobex.c
index 1f5c8b9..a1fabf2 100644
--- a/unit/test-gobex.c
+++ b/unit/test-gobex.c
return g_obex_new(io);
}
+static void test_req(void)
+{
+ GObexRequest *req;
+
+ req = g_obex_request_new(G_OBEX_OP_PUT);
+
+ g_assert(req != NULL);
+
+ g_obex_request_free(req);
+}
+
static void test_ref_unref(void)
{
GObex *obex;
g_test_add_func("/gobex/basic", test_basic);
g_test_add_func("/gobex/ref_unref", test_ref_unref);
+ g_test_add_func("/gobex/test_req", test_req);
+
g_test_run();
return 0;