mirror of git://git.sysmocom.de/ofono
gdbus: Don't automatically attach ObjectManager
Let each project attach the object manager interface instead of registering it automatically.
This commit is contained in:
parent
959d23833f
commit
2e9bea7af6
|
@ -257,6 +257,9 @@ void g_dbus_emit_property_changed(DBusConnection *connection,
|
||||||
gboolean g_dbus_get_properties(DBusConnection *connection, const char *path,
|
gboolean g_dbus_get_properties(DBusConnection *connection, const char *path,
|
||||||
const char *interface, DBusMessageIter *iter);
|
const char *interface, DBusMessageIter *iter);
|
||||||
|
|
||||||
|
gboolean g_dbus_attach_object_manager(DBusConnection *connection);
|
||||||
|
gboolean g_dbus_detach_object_manager(DBusConnection *connection);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -84,6 +84,8 @@ struct property_data {
|
||||||
DBusMessage *message;
|
DBusMessage *message;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct generic_data *root;
|
||||||
|
|
||||||
static gboolean process_changes(gpointer user_data);
|
static gboolean process_changes(gpointer user_data);
|
||||||
static void process_properties_from_interface(struct generic_data *data,
|
static void process_properties_from_interface(struct generic_data *data,
|
||||||
struct interface_data *iface);
|
struct interface_data *iface);
|
||||||
|
@ -569,16 +571,11 @@ static void emit_interfaces_added(struct generic_data *data)
|
||||||
{
|
{
|
||||||
DBusMessage *signal;
|
DBusMessage *signal;
|
||||||
DBusMessageIter iter, array;
|
DBusMessageIter iter, array;
|
||||||
struct generic_data *parent = data->parent;
|
|
||||||
|
|
||||||
if (parent == NULL)
|
if (root == NULL || data == root)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Find root data */
|
signal = dbus_message_new_signal(root->path,
|
||||||
while (parent->parent)
|
|
||||||
parent = parent->parent;
|
|
||||||
|
|
||||||
signal = dbus_message_new_signal(parent->path,
|
|
||||||
DBUS_INTERFACE_OBJECT_MANAGER,
|
DBUS_INTERFACE_OBJECT_MANAGER,
|
||||||
"InterfacesAdded");
|
"InterfacesAdded");
|
||||||
if (signal == NULL)
|
if (signal == NULL)
|
||||||
|
@ -943,16 +940,11 @@ static void emit_interfaces_removed(struct generic_data *data)
|
||||||
{
|
{
|
||||||
DBusMessage *signal;
|
DBusMessage *signal;
|
||||||
DBusMessageIter iter, array;
|
DBusMessageIter iter, array;
|
||||||
struct generic_data *parent = data->parent;
|
|
||||||
|
|
||||||
if (parent == NULL)
|
if (root == NULL || data == root)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Find root data */
|
signal = dbus_message_new_signal(root->path,
|
||||||
while (parent->parent)
|
|
||||||
parent = parent->parent;
|
|
||||||
|
|
||||||
signal = dbus_message_new_signal(parent->path,
|
|
||||||
DBUS_INTERFACE_OBJECT_MANAGER,
|
DBUS_INTERFACE_OBJECT_MANAGER,
|
||||||
"InterfacesRemoved");
|
"InterfacesRemoved");
|
||||||
if (signal == NULL)
|
if (signal == NULL)
|
||||||
|
@ -1207,12 +1199,6 @@ static struct generic_data *object_path_ref(DBusConnection *connection,
|
||||||
add_interface(data, DBUS_INTERFACE_INTROSPECTABLE, introspect_methods,
|
add_interface(data, DBUS_INTERFACE_INTROSPECTABLE, introspect_methods,
|
||||||
NULL, NULL, data, NULL);
|
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;
|
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_INTROSPECTABLE);
|
||||||
remove_interface(data, DBUS_INTERFACE_PROPERTIES);
|
remove_interface(data, DBUS_INTERFACE_PROPERTIES);
|
||||||
remove_interface(data, DBUS_INTERFACE_OBJECT_MANAGER);
|
|
||||||
|
|
||||||
invalidate_parent_data(data->conn, data->path);
|
invalidate_parent_data(data->conn, data->path);
|
||||||
|
|
||||||
|
@ -1645,3 +1630,30 @@ gboolean g_dbus_get_properties(DBusConnection *connection, const char *path,
|
||||||
|
|
||||||
return TRUE;
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue