Diff between ed58b41924adc68310187726649b2464d3fe1b18 and aa38bd05293f1d90d65c5096d490de37d2d1a0d3

Changed Files

File Additions Deletions Status
obexd/client/session.c +64 -0 modified
obexd/client/session.h +3 -0 modified

Full Patch

diff --git a/obexd/client/session.c b/obexd/client/session.c
index e946cfd..2467e85 100644
--- a/obexd/client/session.c
+++ b/obexd/client/session.c
@@ -1241,3 +1241,67 @@ fail:
 	pending_request_free(p);
 	return 0;
 }
+
+static void async_cb(GObex *obex, GError *err, GObexPacket *rsp,
+							gpointer user_data)
+{
+	struct pending_request *p = user_data;
+	struct obc_session *session = p->session;
+	GError *gerr = NULL;
+	uint8_t code;
+
+	p->req_id = 0;
+
+	if (err != NULL) {
+		if (p->func)
+			p->func(p->session, err, p->data);
+		goto done;
+	}
+
+	code = g_obex_packet_get_operation(rsp, NULL);
+	if (code != G_OBEX_RSP_SUCCESS)
+		g_set_error(&gerr, OBEX_IO_ERROR, code, "%s",
+							g_obex_strerror(code));
+
+	if (p->func)
+		p->func(p->session, gerr, p->data);
+
+	if (gerr != NULL)
+		g_clear_error(&gerr);
+
+done:
+	pending_request_free(p);
+	session->p = NULL;
+
+	session_process_queue(session);
+}
+
+guint obc_session_mkdir(struct obc_session *session, const char *folder,
+				session_callback_t func, void *user_data,
+				GError **err)
+{
+	struct pending_request *p;
+
+	if (session->obex == NULL) {
+		g_set_error(err, OBEX_IO_ERROR, OBEX_IO_DISCONNECTED,
+						"Session disconnected");
+		return 0;
+	}
+
+	if (session->p != NULL) {
+		g_set_error(err, OBEX_IO_ERROR, OBEX_IO_BUSY, "Session busy");
+		return 0;
+	}
+
+
+	p = pending_request_new(session, NULL, NULL, func, user_data);
+
+	p->req_id = g_obex_mkdir(session->obex, folder, async_cb, p, err);
+	if (*err != NULL) {
+		pending_request_free(p);
+		return 0;
+	}
+
+	session->p = p;
+	return p->id;
+}
diff --git a/obexd/client/session.h b/obexd/client/session.h
index 65cf4bd..a424054 100644
--- a/obexd/client/session.h
+++ b/obexd/client/session.h
@@ -77,3 +77,6 @@ int obc_session_put(struct obc_session *session, char *buf,
 guint obc_session_setpath(struct obc_session *session, const char *path,
 				session_callback_t func, void *user_data,
 				GError **err);
+guint obc_session_mkdir(struct obc_session *session, const char *folder,
+				session_callback_t func, void *user_data,
+				GError **err);