update service list in init 27/210627/2
authorAbhay agarwal <ay.agarwal@samsung.com>
Mon, 22 Jul 2019 13:35:26 +0000 (19:05 +0530)
committersaerome.kim <saerome.kim@samsung.com>
Tue, 23 Jul 2019 11:38:03 +0000 (20:38 +0900)
Change-Id: I109b9ced98f5701fa72f0f27322f05e72dae5ac2
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
ua-daemon/src/ua-manager-core.c

index 6aee071..d29918b 100644 (file)
@@ -1879,6 +1879,7 @@ int _uam_core_init(void)
        FUNC_ENTRY;
        GSList *db_users;
        GSList *db_devices;
+       GSList *db_svc_list;
        GSList *l;
 
        /* Init database */
@@ -1912,6 +1913,31 @@ int _uam_core_init(void)
                users = g_slist_prepend(users, user);
        }
 
+       /* Fetch service list */
+       db_svc_list = _ua_service_db_get_all_services();
+       if (!db_svc_list) {
+               UAM_INFO_C("No services in database");
+               return UAM_ERROR_NONE;
+       }
+
+       for (l = db_svc_list; NULL != l; l = g_slist_next(l)) {
+               db_service_info_t *db_svc = l->data;
+               uam_db_service_info_t *service;
+               GSList *l1;
+
+               if (!db_svc)
+                       continue;
+
+               l1 = g_slist_find_custom(services,
+                               db_svc->service_name, __compare_svc_name);
+               if (!l1) {
+                       service = g_new0(uam_db_service_info_t, 1);
+                       service->name = g_strdup(db_svc->service_name);
+                       service->cycle = db_svc->cycle;
+                       services = g_slist_append(services, service);
+               }
+       }
+
        /* Fetch device list */
        db_devices = _ua_device_db_get_all_devices();
        if (!db_devices) {
@@ -1949,6 +1975,7 @@ int _uam_core_init(void)
 
        g_slist_free_full(db_devices, g_free);
        g_slist_free_full(db_users, g_free);
+       g_slist_free_full(db_svc_list, g_free);
 
        /* Set/update registered device list to plugins */
        if (UAM_ERROR_NONE != _uam_pm_set_registered_devices(devices))
@@ -2784,7 +2811,6 @@ int _uam_core_register_service(const char *svc_name)
        int service_number = 0;
 
        retv_if(NULL == svc_name, UAM_ERROR_INVALID_PARAMETER);
-       retv_if(0 == g_strcmp0(svc_name, UAM_SERVICE_DEFAULT), UAM_ERROR_PERMISSION_DENIED);
 
        /* Retrieve service from list */
        l = g_slist_find_custom(services, svc_name, __compare_svc_name);
@@ -2805,7 +2831,7 @@ int _uam_core_register_service(const char *svc_name)
 
        /* Send service registered event to application */
        if (UAM_ERROR_NONE != _uam_manager_send_event(NULL,
-                               UAM_EVENT_SERVICE_REGISTERED, g_variant_new("(iss)",
+                               UAM_EVENT_SERVICE_REGISTERED, g_variant_new("(is)",
                                        UAM_ERROR_NONE, service->name)))
                UAM_ERR("Failed to send UAM_EVENT_SERVICE_REGISTERED");
 
@@ -2986,7 +3012,7 @@ static void __get_service_user_list(
                        svc_user_list = g_slist_append(svc_user_list, db_info);
        }
 
-       *count = g_slist_length(users);
+       *count = g_slist_length(svc_user_list);
        *user_list = g_new0(uam_user_info_s, *count);
 
        /* Copy users */