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
*
*/
+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
#include "logging.h"
#define TRANSFER_INTERFACE OPENOBEX_SERVICE ".Transfer"
+#define SESSION_INTERFACE OPENOBEX_SERVICE ".Session"
#define TIMEOUT 60*1000 /* Timeout for user response (miliseconds) */
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 },
static GDBusSignalTable manager_signals[] = {
{ "TransferStarted", "o" },
- { "TransferCompleted", "ob" },
+ { "TransferCompleted", "ob" },
+ { "SessionCreated", "o" },
+ { "SessionRemoved", "o" },
{ }
};
{ }
};
+static GDBusMethodTable session_methods[] = {
+ { "GetProperties", "", "{sv}", get_properties },
+ { }
+};
+
static DBusConnection *connection = NULL;
gboolean manager_init(DBusConnection *conn)
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);
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
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,
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);