Zigbee hal : Replace HAL interface with hal-api-zigbee 67/253267/1 accepted/tizen/unified/20210208.073159 submit/tizen/20210208.055637
authorJihoon Jung <jh8801.jung@samsung.com>
Mon, 8 Feb 2021 05:35:47 +0000 (14:35 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Mon, 8 Feb 2021 05:36:46 +0000 (14:36 +0900)
Change-Id: I95ebfb4fc2e90278bf015675b7c3125b420dacd6
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
packaging/zigbee-manager.spec
zigbee-daemon/CMakeLists.txt
zigbee-daemon/zigbee-interface/CMakeLists.txt
zigbee-daemon/zigbee-lib/CMakeLists.txt
zigbee-daemon/zigbee-lib/include/zblib_plugin.h [changed mode: 0644->0755]
zigbee-daemon/zigbee-lib/include/zblib_service.h [changed mode: 0644->0755]
zigbee-daemon/zigbee-lib/src/zblib_plugin.c [changed mode: 0644->0755]
zigbee-daemon/zigbee-lib/src/zblib_service.c [changed mode: 0644->0755]
zigbee-daemon/zigbee-service/CMakeLists.txt
zigbee-daemon/zigbee-service/src/zigbee_service.c [changed mode: 0644->0755]

index 5a72587..ce017db 100644 (file)
@@ -19,6 +19,8 @@ BuildRequires:  pkgconfig(gio-2.0)
 BuildRequires:  pkgconfig(gio-unix-2.0)
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(vconf)
+BuildRequires:  pkgconfig(hal-api-common)
+BuildRequires:  pkgconfig(hal-api-zigbee)
 
 %if 0%{?gtests:1}
 BuildRequires:  pkgconfig(gmock)
index 664da46..b514e4b 100644 (file)
@@ -13,7 +13,7 @@ SET(INCLUDEDIR "\${prefix}/include")
 
 # Set required packages
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 gio-2.0 gio-unix-2.0 dlog)
+pkg_check_modules(pkgs REQUIRED glib-2.0 gio-2.0 gio-unix-2.0 dlog hal-api-zigbee hal-api-common)
 
 FOREACH(flag ${pkgs_CFLAGS})
         SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index be71340..a55a886 100644 (file)
@@ -13,7 +13,7 @@ SET(INCLUDEDIR "\${prefix}/include")
 
 # Set required packages
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 gio-2.0 gio-unix-2.0 dlog)
+pkg_check_modules(pkgs REQUIRED glib-2.0 gio-2.0 gio-unix-2.0 dlog hal-api-zigbee hal-api-common)
 
 FOREACH(flag ${pkgs_CFLAGS})
         SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 42d75af..61346cf 100644 (file)
@@ -7,7 +7,7 @@ MESSAGE(===================================================================)
 
 ### Set required packages ###
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 dlog)
+pkg_check_modules(pkgs REQUIRED glib-2.0 dlog hal-api-common hal-api-zigbee)
 
 FOREACH(flag ${pkgs_CFLAGS})
         MESSAGE(flag-${flag})
old mode 100644 (file)
new mode 100755 (executable)
index cd77d97..de522a5
@@ -35,9 +35,7 @@ typedef struct {
 
 /* ZigBee vendor plug-in APIs */
 ZigBeePlugin *zblib_plugin_new(ZigBeeService *service,
-       const gchar *plugin_name,
-       const ZblibPluginDescriptor_t *descriptor,
-       void *plugin_handle);
+       const ZblibPluginDescriptor_t *descriptor);
 void zblib_plugin_free(ZigBeePlugin *plugin);
 
 const ZblibPluginDescriptor_t *zblib_plugin_get_descriptor(ZigBeePlugin *plugin);
old mode 100644 (file)
new mode 100755 (executable)
index e0dc480..5eb161f
@@ -25,15 +25,10 @@ void zblib_service_free(ZigBeeService *service);
 gboolean zblib_service_run(ZigBeeService *service);
 gboolean zblib_service_exit(ZigBeeService *service);
 
-gboolean zblib_service_add_plugin(ZigBeeService *service, ZigBeePlugin *plugin);
-gboolean zblib_service_remove_plugin(ZigBeeService *service, ZigBeePlugin *plugin);
-
-gboolean zblib_service_load_plugins(ZigBeeService *service, const char *plugin_path);
-gboolean zblib_service_initialize_plugins(ZigBeeService *service);
-gboolean zblib_service_initialize_async_plugins(ZigBeeService *service);
-gboolean zblib_service_unload_plugins(ZigBeeService *service);
-
-GSList *zblib_service_ref_plugins(ZigBeeService *service);
+gboolean zblib_service_load_plugin(ZigBeeService *service);
+gboolean zblib_service_initialize_plugin(ZigBeeService *service);
+gboolean zblib_service_initialize_async_plugin(ZigBeeService *service);
+gboolean zblib_service_unload_plugin(ZigBeeService *service);
 
 gboolean zblib_service_add_service_interface(ZigBeeService *service,
        ZigBeeServiceInterface *service_interface);
old mode 100644 (file)
new mode 100755 (executable)
index 5422fdf..dd20688
@@ -26,9 +26,7 @@
 
 /**< ZigBee plug-in object */
 struct zblib_plugin_type {
-       gchar *plugin_name; /**< ZigBee plug-in name */
        const ZblibPluginDescriptor_t *descriptor; /**< ZigBee plug-in descriptor */
-       void *plugin_handle; /**< ZigBee Plug-in .so handle */
 
        GSList *driver_list; /**< List of ZigBee drivers */
 
@@ -36,9 +34,7 @@ struct zblib_plugin_type {
 };
 
 ZigBeePlugin *zblib_plugin_new(ZigBeeService *service,
-       const gchar *plugin_name,
-       const ZblibPluginDescriptor_t *descriptor,
-       void *plugin_handle)
+       const ZblibPluginDescriptor_t *descriptor)
 {
        ZigBeePlugin *plugin = NULL;
 
@@ -48,9 +44,7 @@ ZigBeePlugin *zblib_plugin_new(ZigBeeService *service,
                return NULL;
 
        /* Update fields */
-       plugin->plugin_name = g_strdup(plugin_name);
        plugin->descriptor = descriptor;
-       plugin->plugin_handle = plugin_handle;
        plugin->service = service;
 
        Z_LOGI("Vendor plug-in created - Name [%s]", descriptor->name);
@@ -83,18 +77,8 @@ void zblib_plugin_free(ZigBeePlugin *plugin)
                plugin->driver_list = NULL;
        }
 
-       if (plugin->plugin_name) {
-               g_free(plugin->plugin_name);
-               plugin->plugin_name = NULL;
-       }
-
        plugin->descriptor = NULL;
 
-       if (plugin->plugin_handle) {
-               dlclose(plugin->plugin_handle);
-               plugin->plugin_handle = NULL;
-       }
-
        g_free(plugin);
 }
 
@@ -109,7 +93,7 @@ char *zblib_plugin_get_plugin_name(ZigBeePlugin *plugin)
 {
        zblib_check_null_ret_error("plugin", plugin, NULL);
 
-       return g_strdup(plugin->plugin_name);
+       return g_strdup(plugin->descriptor->name);
 }
 
 ZigBeeService *zblib_plugin_ref_service(ZigBeePlugin *plugin)
@@ -150,7 +134,7 @@ void zblib_plugin_link_driver(ZigBeePlugin *plugin, ZigBeeDriver *driver)
        zblib_check_null_ret("driver", driver);
 
        plugin->driver_list = g_slist_append(plugin->driver_list, driver);
-       Z_LOGD("Driver appended into plugin [%s]", plugin->plugin_name);
+       Z_LOGD("Driver appended into plugin [%s]", plugin->descriptor->name);
 }
 
 void zblib_plugin_unlink_driver(ZigBeePlugin *plugin, ZblibDriverType_e driver_type)
old mode 100644 (file)
new mode 100755 (executable)
index 3653a62..cbbfd1a
@@ -26,6 +26,7 @@
 #include <zblib_request.h>
 #include <zblib_driver.h>
 #include <zblib_driver_manager.h>
+#include <hal-zigbee.h>
 
 struct _zblib_async_init_info {
        gboolean is_initialized; /**< Does initialization succeeded? */
@@ -40,29 +41,15 @@ struct zblib_service_type {
        GMainLoop *main_loop; /**< Service main-loop */
 
        GSList *interface_objs; /**< ZigBee Service interface objects */
-       GSList *plugins; /**< ZigBee plug-ins */
+       ZigBeePlugin *plugin; /**< ZigBee plug-ins */
 
        GHashTable *request_table; /**< Request Hash table */
        guint request_id; /**< Request ID */
 
-       GSList *async_initializer; /**< Hash table for asynchronous initializer */
+       struct _zblib_async_init_info *async_initializer; /**< Information for asynchronous initializer */
        zblib_plugin_init_finished_cb callback; /**< Callback */
 };
 
-static GSList *__zblib_service_ref_async_initializer(ZigBeeService* service)
-{
-       zblib_check_null_ret_error("service", service, NULL);
-
-       return service->async_initializer;
-}
-
-static void __zblib_service_set_async_initializer(ZigBeeService* service, GSList* list)
-{
-       zblib_check_null_ret("service", service);
-
-       service->async_initializer = list;
-}
-
 static void __on_zblib_init_async_finished(gboolean result, void *user_data)
 {
        GSList *list_async = NULL;
@@ -71,10 +58,6 @@ static void __on_zblib_init_async_finished(gboolean result, void *user_data)
        struct _zblib_async_init_info *info = (struct _zblib_async_init_info*)user_data;
        char *plugin_name = NULL;
 
-       int i = 0;
-       int _finished_count = 0;
-       int _succeeded_count = 0;
-
        zblib_check_null_ret("info", info);
 
        plugin = info->plugin;
@@ -92,113 +75,26 @@ static void __on_zblib_init_async_finished(gboolean result, void *user_data)
        }
        g_free(plugin_name);
 
-       /* Check all async initializer list */
-       list_async = __zblib_service_ref_async_initializer(service);
-       while (list_async != NULL) {
-               /* Initialize each plug-in */
-               struct _zblib_async_init_info *in =
-                               (struct _zblib_async_init_info *)(list_async->data);
-               i++;
-               if (G_UNLIKELY(NULL == in)) {
-                       /* LCOV_EXCL_START */
-                       Z_LOGE("Invalid parameter !");
-                       list_async = g_slist_next(list_async);
-                       continue;
-                       /* LCOV_EXCL_STOP */
-               }
-
-               if (in->is_finished)
-                       _finished_count++;
-               if (in->is_initialized)
-                       _succeeded_count++;
-
+       /* Check async initializer */
+       struct _zblib_async_init_info *in = service->async_initializer;
+       if (G_UNLIKELY(NULL == in)) {
+               /* LCOV_EXCL_START */
+               Z_LOGE("Invalid parameter !");
                list_async = g_slist_next(list_async);
+               return;
+               /* LCOV_EXCL_STOP */
        }
 
-       if (i == _finished_count) {
+       if (in->is_finished) {
                gboolean ret = TRUE;
                guint driver_noti_id = (ZBLIB_DRIVER_TYPE_MANAGER << 24)
                                | ZBLIB_MANAGER_NOTI_ZIGBEE_ENABLED;
 
-               if (_finished_count == _succeeded_count) {
-                       /* All initializer finished successfully */
-                       Z_LOGD("All async init finished !");
-                       ret = TRUE;
-               } else {
-                       /* Some initializers are failed */
-                       /* LCOV_EXCL_START */
-                       Z_LOGE("There are some failed plugin initializer !");
-                       ret = FALSE;
-                       /* LCOV_EXCL_STOP */
-               }
-               /* Notify whether zigbee service is enabled or not */
                zblib_plugin_send_notification(plugin,
                        driver_noti_id, &ret, sizeof(ret));
        }
 }
 
-static void *__zblib_service_load_plugin(gchar *filename,
-       ZblibPluginDescriptor_t **descriptor_out)
-{
-       ZblibPluginDescriptor_t *descriptor = NULL;
-       void *handle = NULL;
-       struct stat stat_buf;
-       char file_date[27];
-
-       zblib_check_null_ret_error("descriptor_out", descriptor_out, NULL);
-
-       /* Open .so */
-       handle = dlopen(filename, RTLD_LAZY);
-       if (G_UNLIKELY(NULL == handle)) {
-               /* LCOV_EXCL_START */
-               Z_LOGE("dlopen() failed:[%s]", filename);
-               return NULL;
-               /* LCOV_EXCL_STOP */
-       }
-
-       /* Get symbol - "zigbee_plugin_descriptor" */
-       descriptor = dlsym(handle, "zigbee_plugin_descriptor");
-       if (G_UNLIKELY(NULL == descriptor)) {
-               /* LCOV_EXCL_START */
-               Z_LOGE("dlsym() failed:[%s]", "plugin_define_desc");
-               dlclose(handle);
-               return NULL;
-               /* LCOV_EXCL_STOP */
-       }
-
-       Z_LOGD("%s plugin", descriptor->name);
-       Z_LOGD(" - path = %s", filename);
-       Z_LOGD(" - version = %d", descriptor->version);
-
-       memset(&stat_buf, 0x00, sizeof(stat_buf));
-       memset(&file_date, '\0', sizeof(file_date));
-
-       if (0 == stat(filename, &stat_buf)) {
-               if (NULL != ctime_r(&stat_buf.st_mtime, file_date)) {
-                       if (1 < strlen(file_date))
-                               file_date[strlen(file_date)-1] = '\0';
-                       Z_LOGD(" - date = %s", file_date);
-               }
-       }
-
-       /* Load plug-in */
-       if (G_LIKELY(descriptor->load)) {
-               if (G_UNLIKELY(FALSE == descriptor->load())) {
-                       /* LCOV_EXCL_START */
-                       Z_LOGW("load() failed... Skip this plugin!");
-                       dlclose(handle);
-                       return NULL;
-                       /* LCOV_EXCL_STOP */
-               } else {
-                       Z_LOGI("Plug-in (%s) loaded!", descriptor->name);
-               }
-       }
-
-       *descriptor_out = descriptor;
-
-       return handle;
-}
-
 static gboolean __zblib_service_init_plugin(ZigBeePlugin *plugin)
 {
        const ZblibPluginDescriptor_t *descriptor = zblib_plugin_get_descriptor(plugin);
@@ -282,22 +178,6 @@ static void __zblib_service_remove_request_table_iter(gpointer key,
 }
 /* LCOV_EXCL_STOP */
 
-static void __zblib_service_remove_async_list(GSList *list_async)
-{
-       GSList *iter = NULL;
-       if (0 < g_slist_length(list_async)) {
-               iter = g_slist_nth(list_async, 0);
-               while (iter) {
-                       if (iter) {
-                               struct _zblib_async_init_info *async_plugin =
-                                       (struct _zblib_async_init_info *)(list_async->data);
-                               list_async = g_slist_remove(list_async, async_plugin);
-                       }
-                       iter = g_slist_nth(list_async, 0);
-               }
-       }
-}
-
 ZigBeeService *zblib_service_new()
 {
        ZigBeeService *service;
@@ -352,20 +232,6 @@ void zblib_service_free(ZigBeeService *service)
                }
        }
 
-       /* Free async initializer */
-       if (service->async_initializer) {
-               g_slist_free(service->async_initializer);
-               service->async_initializer = NULL;
-       }
-
-       /* Free plug-ins */
-       if (service->plugins) {
-               /* LCOV_EXCL_START */
-               g_slist_free(service->plugins);
-               service->plugins = NULL;
-               /* LCOV_EXCL_STOP */
-       }
-
        /* Unref 'g-main loop' */
        if (service->main_loop)
                g_main_loop_unref(service->main_loop);
@@ -393,216 +259,121 @@ gboolean zblib_service_exit(ZigBeeService *service)
        return TRUE;
 }
 
-gboolean zblib_service_add_plugin(ZigBeeService *service, ZigBeePlugin *plugin)
+gboolean zblib_service_load_plugin(ZigBeeService *service)
 {
-       gchar *plugin_name;
-
-       zblib_check_null_ret_error("service", service, FALSE);
-       zblib_check_null_ret_error("plugin", plugin, FALSE);
-
-       plugin_name = zblib_plugin_get_plugin_name(plugin);
-
-       /* All plug-ins would be appended */
-       service->plugins = g_slist_append(service->plugins, plugin);
-       Z_LOGD("%s added", plugin_name);
-       g_free(plugin_name);
-
-       return TRUE;
-}
-
-gboolean zblib_service_remove_plugin(ZigBeeService *service, ZigBeePlugin *plugin)
-{
-       zblib_check_null_ret_error("service", service, FALSE);
-       zblib_check_null_ret_error("plugin", plugin, FALSE);
-
-       /* Specific vendor plug-in would be removed */
-       service->plugins = g_slist_remove(service->plugins, plugin);
-
-       /* Deinitialize plugin */
-       zblib_plugin_free(plugin);
-
-       return TRUE;
-}
-
-gboolean zblib_service_load_plugins(ZigBeeService *service, const char *plugin_path)
-{
-       const gchar *file = NULL;
-       gchar *filename = NULL;
-       GDir *dir = NULL;
-       void *handle = NULL;
        ZblibPluginDescriptor_t *descriptor = NULL;
-       ZigBeePlugin *plugin = NULL;
-       gboolean ret;
 
        zblib_check_null_ret_error("service", service, FALSE);
-       zblib_check_null_ret_error("plugin_path", plugin_path, FALSE);
 
-       /* Open plug-in directory */
-       dir = g_dir_open(plugin_path, 0, NULL);
-       if (G_UNLIKELY(dir == NULL)) {
-               /* LCOV_EXCL_START */
-               Z_LOGE("Directory open failed!");
-               return FALSE;
-               /* LCOV_EXCL_STOP */
-       }
-
-       /* Scan through all libraries in plug-in directory */
-       while ((file = g_dir_read_name(dir)) != NULL) {
-               if ((g_str_has_prefix(file, "lib") == TRUE)
-                               || (g_str_has_suffix(file, ".so") == FALSE))
-                       continue; // LCOV_EXCL_LINE
+       hal_zigbee_get_backend();
 
-               filename = g_build_filename(plugin_path, file, NULL);
+       hal_zigbee_get_descriptor(&descriptor);
 
-               /* Load plug-in */
-               handle = __zblib_service_load_plugin(filename, &descriptor);
-               if (G_UNLIKELY(NULL == handle)) {
-                       /* LCOV_EXCL_START */
-                       g_free(filename);
-                       continue;
-                       /* LCOV_EXCL_STOP */
-               }
+       Z_LOGD("%s plugin", descriptor->name);
+       Z_LOGD(" - version = %d", descriptor->version);
 
-               /* Create new plug-in */
-               plugin = zblib_plugin_new(service, filename, descriptor, handle);
-               if (G_UNLIKELY(NULL == plugin)) {
+       /* Load plug-in */
+       if (G_LIKELY(descriptor->load)) {
+               if (G_UNLIKELY(FALSE == descriptor->load())) {
                        /* LCOV_EXCL_START */
-                       dlclose(handle);
-                       g_free(filename);
-                       continue;
+                       Z_LOGW("load() failed... Skip this plugin!");
+                       return FALSE;
                        /* LCOV_EXCL_STOP */
+               } else {
+                       Z_LOGI("Plug-in (%s) loaded!", descriptor->name);
                }
+       }
 
-               /* Add new plug-in */
-               ret = zblib_service_add_plugin(service, plugin);
-               if (G_UNLIKELY(FALSE == ret))
-                       zblib_plugin_free(plugin); // LCOV_EXCL_LINE
-
-               g_free(filename);
+       /* Create new plug-in */
+       service->plugin = zblib_plugin_new(service, descriptor);
+       if (G_UNLIKELY(NULL == service->plugin)) {
+               /* LCOV_EXCL_START */
+               return FALSE;
+               /* LCOV_EXCL_STOP */
        }
-       g_dir_close(dir);
 
        return TRUE;
 }
 
-gboolean zblib_service_initialize_plugins(ZigBeeService *service)
+gboolean zblib_service_initialize_plugin(ZigBeeService *service)
 {
-       GSList *list;
-       GSList *list_async;
-
        zblib_check_null_ret_error("service", service, FALSE);
 
-       /* Refer plug-in list */
-       list = zblib_service_ref_plugins(service);
-       list_async = __zblib_service_ref_async_initializer(service);
-       while (list != NULL) {
-               /* Initialize each plug-in */
-               ZigBeePlugin *plugin = (ZigBeePlugin *)(list->data);
-               if (FALSE == __zblib_service_init_plugin(plugin)) {
-                       /* If there is no initializer, it should have asynchronous one */
-                       const ZblibPluginDescriptor_t *descriptor =
-                                       zblib_plugin_get_descriptor(plugin);
-                       if (NULL != descriptor && NULL != descriptor->init_async) {
-                               /* Register async initializer */
-                               struct _zblib_async_init_info *info =
-                                       g_try_new0(struct _zblib_async_init_info, 1);
-                               if (NULL == info) {
-                                       /* LCOV_EXCL_START */
-                                       Z_LOGE("Fatal : Failed to allocate memory");
-                                       return FALSE;
-                                       /* LCOV_EXCL_STOP */
-                               }
-                               info->is_finished = FALSE;
-                               info->is_initialized = FALSE;
-                               info->plugin = plugin;
-                               info->user_data = NULL;
-
-                               list_async = g_slist_append(list_async, info);
-                       } else {
+       /* Initialize plug-in */
+       ZigBeePlugin *plugin = service->plugin;
+       if (FALSE == __zblib_service_init_plugin(plugin)) {
+               /* If there is no initializer, it should have asynchronous one */
+               const ZblibPluginDescriptor_t *descriptor =
+                               zblib_plugin_get_descriptor(plugin);
+               if (NULL != descriptor && NULL != descriptor->init_async) {
+                       /* Register async initializer */
+                       struct _zblib_async_init_info *info =
+                               g_try_new0(struct _zblib_async_init_info, 1);
+                       if (NULL == info) {
                                /* LCOV_EXCL_START */
-                               __zblib_service_remove_async_list(list_async);
-                               Z_LOGE("Fatal : Failed to initialize plugin");
+                               Z_LOGE("Fatal : Failed to allocate memory");
                                return FALSE;
                                /* LCOV_EXCL_STOP */
                        }
+                       info->is_finished = FALSE;
+                       info->is_initialized = FALSE;
+                       info->plugin = plugin;
+                       info->user_data = NULL;
+
+                       service->async_initializer = info;
+               } else {
+                       /* LCOV_EXCL_START */
+                       service->async_initializer = NULL;
+                       Z_LOGE("Fatal : Failed to initialize plugin");
+                       return FALSE;
+                       /* LCOV_EXCL_STOP */
                }
-               list = g_slist_next(list);
        }
 
-       __zblib_service_set_async_initializer(service, list_async);
-
        return TRUE;
 }
 
-gboolean zblib_service_initialize_async_plugins(ZigBeeService *service)
+gboolean zblib_service_initialize_async_plugin(ZigBeeService *service)
 {
-       GSList *list_async;
-
        zblib_check_null_ret_error("service", service, FALSE);
 
-       /* Refer async initializer list */
-       list_async = __zblib_service_ref_async_initializer(service);
-       while (list_async != NULL) {
-               /* Initialize each plug-in */
-               struct _zblib_async_init_info *info =
-                               (struct _zblib_async_init_info *)(list_async->data);
-
-               if (G_UNLIKELY(NULL == info)) {
-                       /* LCOV_EXCL_START */
-                       Z_LOGE("Invalid parameter !");
-                       list_async = g_slist_next(list_async);
-                       continue;
-                       /* LCOV_EXCL_STOP */
-               }
+       /* Initialize each plug-in */
+       struct _zblib_async_init_info *info = service->async_initializer;
+       if (G_UNLIKELY(NULL == info)) {
+               /* LCOV_EXCL_START */
+               Z_LOGE("Invalid parameter !");
+               return FALSE;
+               /* LCOV_EXCL_STOP */
+       }
 
-               if (G_UNLIKELY(FALSE == __zblib_service_init_async_plugin(
-                                       info->plugin, __on_zblib_init_async_finished, info))) {
-                       /* LCOV_EXCL_START */
-                       Z_LOGE("Fatal : Failed to initialize mandatory plugin");
-                       return FALSE;
-                       /* LCOV_EXCL_STOP */
-               }
-               list_async = g_slist_next(list_async);
+       if (G_UNLIKELY(FALSE == __zblib_service_init_async_plugin(
+                               info->plugin, __on_zblib_init_async_finished, info))) {
+               /* LCOV_EXCL_START */
+               Z_LOGE("Fatal : Failed to initialize mandatory plugin");
+               return FALSE;
+               /* LCOV_EXCL_STOP */
        }
 
        return TRUE;
 }
 
-gboolean zblib_service_unload_plugins(ZigBeeService *service)
+gboolean zblib_service_unload_plugin(ZigBeeService *service)
 {
-       GSList *list = NULL;
-       GSList *list_async = NULL;
-
        zblib_check_null_ret_error("service", service, FALSE);
 
-       /* Unload everyy async_plugin */
-       list_async = __zblib_service_ref_async_initializer(service);
-       __zblib_service_remove_async_list(list_async);
-
-       list = zblib_service_ref_plugins(service);
-       while (list != NULL) {
-               ZigBeePlugin *plugin = list->data;
-
-               /* Unload each plug-in */
-               if (G_UNLIKELY(FALSE == __zblib_service_unload_plugin(plugin))) {
-                       /* LCOV_EXCL_START */
-                       list = g_slist_next(list);
-                       continue;
-                       /* LCOV_EXCL_STOP */
-               }
-
-               list = g_slist_next(list);
-               zblib_service_remove_plugin(service, plugin);
+       /* Unload each plug-in */
+       if (G_UNLIKELY(FALSE == __zblib_service_unload_plugin(service->plugin))) {
+               /* LCOV_EXCL_START */
+               return FALSE;
+               /* LCOV_EXCL_STOP */
        }
 
-       return TRUE;
-}
+       service->async_initializer = NULL;
+       service->plugin = NULL;
 
-GSList *zblib_service_ref_plugins(ZigBeeService *service)
-{
-       zblib_check_null_ret_error("service", service, NULL);
+       hal_zigbee_put_backend();
 
-       return service->plugins;
+       return TRUE;
 }
 
 gboolean zblib_service_add_service_interface(ZigBeeService *service,
@@ -700,25 +471,12 @@ gint zblib_service_generate_request_id(ZigBeeService *service)
 gboolean zblib_service_dispatch_request(ZigBeeService *service,
        guint request_id)
 {
-       ZigBeePlugin *plugin = NULL;
-       GSList *plugin_list = NULL;
        gboolean ret = FALSE;
 
        zblib_check_null_ret_error("service", service, FALSE);
 
-       /* Fetch plugin_list */
-       plugin_list = service->plugins;
-       zblib_check_null_ret_error("plugin_list", plugin_list, FALSE);
-
-       while (plugin_list) {
-               plugin = (ZigBeePlugin *)plugin_list->data;
-
-               /* Dispatch request to plugin */
-               ret = zblib_plugin_dispatch_request(plugin, request_id);
-
-               /* Move to next plugin */
-               plugin_list = g_slist_next(plugin_list);
-       }
+       /* Dispatch request to plugin */
+       ret = zblib_plugin_dispatch_request(service->plugin, request_id);
 
        return ret;
 }
index d8aabed..d02720c 100644 (file)
@@ -13,7 +13,7 @@ SET(INCLUDEDIR "\${prefix}/include")
 
 # Set required packages
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 dlog)
+pkg_check_modules(pkgs REQUIRED glib-2.0 dlog hal-api-common hal-api-zigbee)
 
 FOREACH(flag ${pkgs_CFLAGS})
         SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
old mode 100644 (file)
new mode 100755 (executable)
index b53f734..e3e29bc
 
 #include "zigbee_service.h"
 
-#ifndef ZIGBEE_DEFAULT_PLUGINS_PATH
-#define ZIGBEE_DEFAULT_PLUGINS_PATH "/usr/lib/zigbee/plugins/"
-#endif
-
 /* Zigbee service initialization */
 gboolean zigbee_service_init(ZigBeeService *service)
 {
-       const char *zigbee_plugin_path = ZIGBEE_DEFAULT_PLUGINS_PATH;
-
        if (service == NULL) {
                /* LCOV_EXCL_START */
                Z_LOGE("service is NULL");
@@ -44,28 +38,28 @@ gboolean zigbee_service_init(ZigBeeService *service)
                /* LCOV_EXCL_STOP */
        }
 
-       /* Load ZigBee plug-ins */
-       if (G_UNLIKELY(TRUE != zblib_service_load_plugins(service, zigbee_plugin_path))) {
+       /* Load ZigBee plug-in */
+       if (G_UNLIKELY(TRUE != zblib_service_load_plugin(service))) {
                /* LCOV_EXCL_START */
-               Z_LOGE("Load plug-ins failed!");
+               Z_LOGE("Load plug-in failed!");
                return FALSE;
                /* LCOV_EXCL_STOP */
        }
 
        Z_TIME_CHECK("Loading Plugins Complete");
 
-       /* Initialize ZigBee plug-ins */
-       if (G_UNLIKELY(TRUE != zblib_service_initialize_plugins(service))) {
+       /* Initialize ZigBee plug-in */
+       if (G_UNLIKELY(TRUE != zblib_service_initialize_plugin(service))) {
                /* LCOV_EXCL_START */
-               Z_LOGE("Initialize plug-ins failed!");
+               Z_LOGE("Initialize plug-in failed!");
                return FALSE;
                /* LCOV_EXCL_STOP */
        }
 
-       Z_TIME_CHECK("Initializing Plugins Complete.");
+       Z_TIME_CHECK("Initializing Plugin Complete.");
 
-       /* Initialize ZigBee plug-ins */
-       if (G_UNLIKELY(TRUE != zblib_service_initialize_async_plugins(service))) {
+       /* Initialize ZigBee plug-in */
+       if (G_UNLIKELY(TRUE != zblib_service_initialize_async_plugin(service))) {
                /* LCOV_EXCL_START */
                Z_LOGE("Asynchronously initialize plug-ins failed!");
                return FALSE;
@@ -88,7 +82,7 @@ void zigbee_service_deinit(ZigBeeService *service)
        }
 
        /* Unload ZigBee plug-ins */
-       if (G_UNLIKELY(TRUE != zblib_service_unload_plugins(service))) {
+       if (G_UNLIKELY(TRUE != zblib_service_unload_plugin(service))) {
                /* LCOV_EXCL_START */
                Z_LOGE("Unload plug-ins failed!");
                return;