From 5b344ddcfa2f97f0c32527676f8a5cd157a97d41 Mon Sep 17 00:00:00 2001 From: Abhay agarwal Date: Tue, 23 Jul 2019 16:42:55 +0530 Subject: [PATCH] remove device from service when device being removed Change-Id: I6f484976fe27e8bc054f35e7773bb43b5c080c70 Signed-off-by: Abhay agarwal --- ua-daemon/src/ua-manager-core.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/ua-daemon/src/ua-manager-core.c b/ua-daemon/src/ua-manager-core.c index d29918b..835cf7f 100644 --- a/ua-daemon/src/ua-manager-core.c +++ b/ua-daemon/src/ua-manager-core.c @@ -903,6 +903,15 @@ int _uam_core_remove_device(const char *account, const uam_device_info_s *dev_in dev_info->device_id, dev_info->type, dev_info->mac)) UAM_ERR("_ua_device_db_delete_device_info failed"); + /* Remove device from service */ + for (l = tech->svc_list; l; l = g_slist_next(l)) { + uam_db_service_info_t *svc = l->data; + + if (!svc || !svc->name) + continue; + _uam_core_service_remove_device(svc->name, dev_info->device_id, dev_info->type); + } + /* Remove tech info from device's tech list */ device->tech_list = g_slist_remove(device->tech_list, tech); device->supported_techs &= ~(tech->tech_type); @@ -974,6 +983,15 @@ int _uam_core_remove_device_by_device_id(const char *device_id, int tech_type) dev_info.device_id, dev_info.type, dev_info.mac)) UAM_ERR("_ua_device_db_delete_device_info failed"); + /* Remove device from service */ + for (l = tech->svc_list; l; l = g_slist_next(l)) { + uam_db_service_info_t *svc = l->data; + + if (!svc || !svc->name) + continue; + _uam_core_service_remove_device(svc->name, dev_info.device_id, dev_info.type); + } + /* Remove tech info from device's tech list */ device->tech_list = g_slist_remove(device->tech_list, tech); device->supported_techs &= ~(tech->tech_type); @@ -1007,6 +1025,7 @@ int _uam_core_remove_device_by_mac(const char *mac) uam_db_tech_info_t *tech; uam_db_device_info_t *device; uam_device_info_s dev_info; + GSList *l; int ret; retv_if(NULL == mac, UAM_ERROR_INVALID_PARAMETER); @@ -1036,6 +1055,15 @@ int _uam_core_remove_device_by_mac(const char *mac) dev_info.device_id, dev_info.type, dev_info.mac)) UAM_ERR("_ua_device_db_delete_device_info failed"); + /* Remove device from service */ + for (l = tech->svc_list; l; l = g_slist_next(l)) { + uam_db_service_info_t *svc = l->data; + + if (!svc || !svc->name) + continue; + _uam_core_service_remove_device(svc->name, dev_info.device_id, dev_info.type); + } + /* Remove tech info from device's tech list */ device->tech_list = g_slist_remove(device->tech_list, tech); device->supported_techs &= ~(tech->tech_type); -- 2.7.4