Diff between fa413ebabcd132a0102a6091eb9cd5efeaddb59c and b5891ebfa01ab1867f9af9a9aae6f4d8a890198d

Changed Files

File Additions Deletions Status
obexd/src/dbus.h +4 -0 modified
obexd/src/manager.c +66 -1 modified
obexd/src/obex.c +6 -0 modified

Full Patch

diff --git a/obexd/src/dbus.h b/obexd/src/dbus.h
index a4234c2..3c85aae 100644
--- a/obexd/src/dbus.h
+++ b/obexd/src/dbus.h
@@ -21,6 +21,10 @@
  *
  */
 
+void emit_session_created(guint32 id);
+
+void emit_session_removed(guint32 id);
+
 void emit_transfer_started(guint32 id);
 
 void emit_transfer_completed(guint32 id, gboolean success);
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index e165c80..5c19e59 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -38,6 +38,7 @@
 #include "logging.h"
 
 #define TRANSFER_INTERFACE OPENOBEX_SERVICE ".Transfer"
+#define SESSION_INTERFACE OPENOBEX_SERVICE ".Session"
 
 #define TIMEOUT 60*1000 /* Timeout for user response (miliseconds) */
 
@@ -147,6 +148,13 @@ static DBusMessage *unregister_agent(DBusConnection *conn,
 	return dbus_message_new_method_return(msg);
 }
 
+static DBusMessage *get_properties(DBusConnection *conn,
+				DBusMessage *msg, void *data)
+{
+	/* FIXME: */
+	return NULL;
+}
+
 static GDBusMethodTable manager_methods[] = {
 	{ "RegisterAgent",	"o",	"",	register_agent		},
 	{ "UnregisterAgent",	"o",	"",	unregister_agent	},
@@ -155,7 +163,9 @@ static GDBusMethodTable manager_methods[] = {
 
 static GDBusSignalTable manager_signals[] = {
 	{ "TransferStarted", 	"o" 	},
-	{ "TransferCompleted",	"ob"	},
+	{ "TransferCompleted", 	"ob" 	},
+	{ "SessionCreated", 	"o" 	},
+	{ "SessionRemoved",	"o"	},
 	{ }
 };
 
@@ -169,6 +179,11 @@ static GDBusSignalTable transfer_signals[] = {
 	{ }
 };
 
+static GDBusMethodTable session_methods[] = {
+	{ "GetProperties",	"",	"{sv}",	get_properties	},
+	{ }
+};
+
 static DBusConnection *connection = NULL;
 
 gboolean manager_init(DBusConnection *conn)
@@ -200,6 +215,30 @@ void manager_cleanup(void)
 	dbus_connection_unref(connection);
 }
 
+void emit_session_created(guint32 id)
+{
+	gchar *path = g_strdup_printf("/session%u", id);
+
+	g_dbus_emit_signal(connection, OPENOBEX_MANAGER_PATH,
+			OPENOBEX_MANAGER_INTERFACE, "SessionCreated",
+			DBUS_TYPE_OBJECT_PATH, &path,
+			DBUS_TYPE_INVALID);
+
+	g_free(path);
+}
+
+void emit_session_removed(guint32 id)
+{
+	gchar *path = g_strdup_printf("/session%u", id);
+
+	g_dbus_emit_signal(connection, OPENOBEX_MANAGER_PATH,
+			OPENOBEX_MANAGER_INTERFACE, "SessionRemoved",
+			DBUS_TYPE_OBJECT_PATH, &path,
+			DBUS_TYPE_INVALID);
+
+	g_free(path);
+}
+
 void emit_transfer_started(guint32 id)
 {
 	gchar *path = g_strdup_printf("/transfer%u", id);
@@ -366,3 +405,29 @@ int request_authorization(gint32 cid, int fd, const gchar *filename,
 
 	return 0;
 }
+
+void register_session(guint32 id)
+{
+	gchar *path = g_strdup_printf("/session%u", id);
+
+	if (!g_dbus_register_interface(connection, path,
+				SESSION_INTERFACE,
+				session_methods, NULL,
+				NULL, NULL, NULL)) {
+		error("Cannot register Session interface.");
+		g_free(path);
+		return;
+	}
+
+	g_free(path);
+}
+
+void unregister_session(guint32 id)
+{
+	gchar *path = g_strdup_printf("/session%u", id);
+
+	g_dbus_unregister_interface(connection, path,
+				SESSION_INTERFACE);
+
+	g_free(path);
+}
diff --git a/obexd/src/obex.c b/obexd/src/obex.c
index f9d2784..1b89385 100644
--- a/obexd/src/obex.c
+++ b/obexd/src/obex.c
@@ -211,6 +211,11 @@ static void cmd_connect(struct obex_session *os,
 		return;
 	}
 
+	/* FIXME: Request authorization */
+
+	register_session(cid);
+	emit_session_created(cid);
+
 	/* Append received UUID in WHO header */
 	OBEX_ObjectAddHeader(obex, obj,
 			OBEX_HDR_WHO, hd, TARGET_SIZE,
@@ -746,6 +751,7 @@ static void obex_handle_destroy(gpointer user_data)
 	if (os->fd >= 0)
 		emit_transfer_completed(os->cid, os->offset == os->size);
 
+	/* FIXME: SessionRemoved/TransferCompleted signal? */
 	unregister_transfer(os->cid);
 
 	obex_session_free(os);