summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-01-18 14:28:18 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-01-18 14:28:18 +0000
commitc6cd1ad500588247d4293b96db66d7a140ee81ec (patch)
treece2a78fe6936d79e3cedd39cb3809af9b0203987 /input
parent8a7d17430468d08c3d0660e2159cc046eebc5dfc (diff)
Added unregister code for input manager path
Diffstat (limited to 'input')
-rw-r--r--input/input-service.c36
-rw-r--r--input/input-service.h1
-rw-r--r--input/main.c2
3 files changed, 38 insertions, 1 deletions
diff --git a/input/input-service.c b/input/input-service.c
index 54e745a4..23dbce8b 100644
--- a/input/input-service.c
+++ b/input/input-service.c
@@ -51,11 +51,15 @@ static DBusConnection *connection = NULL;
static DBusHandlerResult manager_message(DBusConnection *conn,
DBusMessage *msg, void *data);
+
+static void manager_unregister(DBusConnection *conn, void *data);
+
static DBusHandlerResult device_message(DBusConnection *conn,
DBusMessage *msg, void *data);
static const DBusObjectPathVTable manager_table = {
.message_function = manager_message,
+ .unregister_function = manager_unregister,
};
static const DBusObjectPathVTable device_table = {
@@ -84,6 +88,10 @@ static DBusHandlerResult err_unknown_method(DBusConnection *conn, DBusMessage *m
/*
* Input Manager methods
*/
+struct input_manager {
+ GList *paths;
+};
+
static DBusHandlerResult manager_create_device(DBusConnection *conn,
DBusMessage *msg, void *udata)
{
@@ -131,6 +139,18 @@ static DBusHandlerResult manager_message(DBusConnection *conn,
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
+static void manager_unregister(DBusConnection *conn, void *data)
+{
+ struct input_manager *mgr = data;
+
+ info("Unregistered manager path");
+
+ if (mgr->paths)
+ g_list_foreach(mgr->paths, (GFunc) free, NULL);
+
+ free(mgr);
+}
+
/*
* Input Device methods
*/
@@ -233,13 +253,19 @@ static DBusHandlerResult device_message(DBusConnection *conn,
int input_dbus_init(void)
{
+ struct input_manager *mgr;
connection = init_dbus(INPUT_SERVICE, NULL, NULL);
if (!connection)
return -1;
+ dbus_connection_set_exit_on_disconnect(connection, TRUE);
+
+ mgr = malloc(sizeof(struct input_manager));
+ memset(mgr, 0, sizeof(struct input_manager));
+
/* Fallback to catch invalid device path */
if (!dbus_connection_register_fallback(connection, INPUT_PATH,
- &manager_table, NULL)) {
+ &manager_table, mgr)) {
error("D-Bus failed to register %s path", INPUT_PATH);
return -1;
}
@@ -248,3 +274,11 @@ int input_dbus_init(void)
return 0;
}
+
+void input_dbus_exit(void)
+{
+ dbus_connection_unregister_object_path(connection, INPUT_PATH);
+
+ dbus_connection_unref(connection);
+}
+
diff --git a/input/input-service.h b/input/input-service.h
index 6cc0b413..acda934d 100644
--- a/input/input-service.h
+++ b/input/input-service.h
@@ -25,5 +25,6 @@
#define __INPUT_SERVICE_H
int input_dbus_init(void);
+void input_dbus_exit(void);
#endif /* __INPUT_SERVICE_H */
diff --git a/input/main.c b/input/main.c
index 5523b67f..9386caf9 100644
--- a/input/main.c
+++ b/input/main.c
@@ -102,5 +102,7 @@ int main(int argc, char *argv[])
g_main_run(main_loop);
+ input_dbus_exit();
+
return 0;
}