mesh: Register D-Bus management interface
authorMichał Lowas-Rzechonek <michal.lowas-rzechonek@silvair.com>
Fri, 28 Jun 2019 08:27:34 +0000 (10:27 +0200)
committerAnupam Roy <anupam.r@samsung.com>
Tue, 17 Dec 2019 15:20:16 +0000 (20:50 +0530)
When application Attach()es itself, start exposing both Node1 and
Management1 D-Bus interfaces.

Change-Id: I2a94441cce59cee62e219ee40b07d6f3124290df
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
mesh/node.c

index b1f1c73..3f5c580 100644 (file)
@@ -246,9 +246,14 @@ static void free_node_resources(void *data)
        if (node->disc_watch)
                l_dbus_remove_watch(dbus_get_bus(), node->disc_watch);
 
-       if (node->path)
+       if (node->path) {
                l_dbus_object_remove_interface(dbus_get_bus(), node->path,
                                                        MESH_NODE_INTERFACE);
+
+               l_dbus_object_remove_interface(dbus_get_bus(), node->path,
+                                              MESH_MANAGEMENT_INTERFACE);
+       }
+
        l_free(node->path);
 
        l_free(node);
@@ -421,6 +426,7 @@ void node_cleanup_all(void)
 {
        l_queue_destroy(nodes, cleanup_node);
        l_dbus_unregister_interface(dbus_get_bus(), MESH_NODE_INTERFACE);
+       l_dbus_unregister_interface(dbus_get_bus(), MESH_MANAGEMENT_INTERFACE);
 }
 
 bool node_is_provisioned(struct mesh_node *node)
@@ -1012,7 +1018,11 @@ static bool register_node_object(struct mesh_node *node)
                                                                "%s", uuid);
 
        if (!l_dbus_object_add_interface(dbus_get_bus(), node->path,
-                                       MESH_NODE_INTERFACE, node))
+                                               MESH_NODE_INTERFACE, node))
+               return false;
+
+       if (!l_dbus_object_add_interface(dbus_get_bus(), node->path,
+                                       MESH_MANAGEMENT_INTERFACE, node))
                return false;
 
        return true;
@@ -1034,6 +1044,9 @@ static void app_disc_cb(struct l_dbus *bus, void *user_data)
        if (node->path) {
                l_dbus_object_remove_interface(dbus_get_bus(), node->path,
                                                        MESH_NODE_INTERFACE);
+
+               l_dbus_object_remove_interface(dbus_get_bus(), node->path,
+                                               MESH_MANAGEMENT_INTERFACE);
                l_free(node->app_path);
                node->app_path = NULL;
        }