summaryrefslogtreecommitdiff
path: root/gdbus
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.de.marchi@gmail.com>2012-11-29 11:19:32 -0200
committerMarcel Holtmann <marcel@holtmann.org>2012-11-29 17:39:50 +0100
commit2ac19406bac262098feef0a13b686a103cb2036a (patch)
treef42b9f1ccfb03bc82a81a67e364767ab5067060c /gdbus
parent912ee62e8053a4cf797351d64f27cab8ead2b820 (diff)
downloadconnman-2ac19406bac262098feef0a13b686a103cb2036a.tar.gz
connman-2ac19406bac262098feef0a13b686a103cb2036a.tar.bz2
connman-2ac19406bac262098feef0a13b686a103cb2036a.zip
gdbus: Don't automatically attach ObjectManager
Let each project attach the object manager interface instead of registering it automatically.
Diffstat (limited to 'gdbus')
-rw-r--r--gdbus/gdbus.h3
-rw-r--r--gdbus/object.c54
2 files changed, 36 insertions, 21 deletions
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index ba496211..6aafc615 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -257,6 +257,9 @@ void g_dbus_emit_property_changed(DBusConnection *connection,
gboolean g_dbus_get_properties(DBusConnection *connection, const char *path,
const char *interface, DBusMessageIter *iter);
+gboolean g_dbus_attach_object_manager(DBusConnection *connection);
+gboolean g_dbus_detach_object_manager(DBusConnection *connection);
+
#ifdef __cplusplus
}
#endif
diff --git a/gdbus/object.c b/gdbus/object.c
index 47116bd5..7cbd6121 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -84,6 +84,8 @@ struct property_data {
DBusMessage *message;
};
+static struct generic_data *root;
+
static gboolean process_changes(gpointer user_data);
static void process_properties_from_interface(struct generic_data *data,
struct interface_data *iface);
@@ -569,16 +571,11 @@ static void emit_interfaces_added(struct generic_data *data)
{
DBusMessage *signal;
DBusMessageIter iter, array;
- struct generic_data *parent = data->parent;
- if (parent == NULL)
+ if (root == NULL || data == root)
return;
- /* Find root data */
- while (parent->parent)
- parent = parent->parent;
-
- signal = dbus_message_new_signal(parent->path,
+ signal = dbus_message_new_signal(root->path,
DBUS_INTERFACE_OBJECT_MANAGER,
"InterfacesAdded");
if (signal == NULL)
@@ -943,16 +940,11 @@ static void emit_interfaces_removed(struct generic_data *data)
{
DBusMessage *signal;
DBusMessageIter iter, array;
- struct generic_data *parent = data->parent;
- if (parent == NULL)
+ if (root == NULL || data == root)
return;
- /* Find root data */
- while (parent->parent)
- parent = parent->parent;
-
- signal = dbus_message_new_signal(parent->path,
+ signal = dbus_message_new_signal(root->path,
DBUS_INTERFACE_OBJECT_MANAGER,
"InterfacesRemoved");
if (signal == NULL)
@@ -1207,12 +1199,6 @@ static struct generic_data *object_path_ref(DBusConnection *connection,
add_interface(data, DBUS_INTERFACE_INTROSPECTABLE, introspect_methods,
NULL, NULL, data, NULL);
- /* Only root path export ObjectManager interface */
- if (data->parent == NULL)
- add_interface(data, DBUS_INTERFACE_OBJECT_MANAGER,
- manager_methods, manager_signals,
- NULL, data, NULL);
-
return data;
}
@@ -1234,7 +1220,6 @@ static void object_path_unref(DBusConnection *connection, const char *path)
remove_interface(data, DBUS_INTERFACE_INTROSPECTABLE);
remove_interface(data, DBUS_INTERFACE_PROPERTIES);
- remove_interface(data, DBUS_INTERFACE_OBJECT_MANAGER);
invalidate_parent_data(data->conn, data->path);
@@ -1645,3 +1630,30 @@ gboolean g_dbus_get_properties(DBusConnection *connection, const char *path,
return TRUE;
}
+
+gboolean g_dbus_attach_object_manager(DBusConnection *connection)
+{
+ struct generic_data *data;
+
+ data = object_path_ref(connection, "/");
+ if (data == NULL)
+ return FALSE;
+
+ add_interface(data, DBUS_INTERFACE_OBJECT_MANAGER,
+ manager_methods, manager_signals,
+ NULL, data, NULL);
+ root = data;
+
+ return TRUE;
+}
+
+gboolean g_dbus_detach_object_manager(DBusConnection *connection)
+{
+ if (!g_dbus_unregister_interface(connection, "/",
+ DBUS_INTERFACE_OBJECT_MANAGER))
+ return FALSE;
+
+ root = NULL;
+
+ return TRUE;
+}