Modify ua-manager to support the vendor-plugin
authorsaerome.kim <saerome.kim@samsung.com>
Wed, 23 Oct 2019 12:31:58 +0000 (21:31 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Fri, 1 Nov 2019 03:54:15 +0000 (12:54 +0900)
- Problem: we decided to remove the power-plugin.
- Cause: Recently, we decided to remove the power plugin and use the
  power-plugin.
- Solution: Modify ua-manager to support the vendor-plugin instead of
  the power plugin.

Change-Id: I3b726d46282fd6dfd437f7121a6209020ea4251d
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
packaging/ua-manager.spec
ua-daemon/CMakeLists.txt
ua-daemon/include/ua-manager-common.h
ua-daemon/include/ua-vendor-plugin-manager.h [moved from ua-daemon/include/ua-power-plugin-manager.h with 78% similarity]
ua-daemon/src/pm/ua-cloud-plugin-handler.c
ua-daemon/src/pm/ua-vendor-plugin-handler.c [moved from ua-daemon/src/pm/ua-power-plugin-handler.c with 95% similarity]
ua-daemon/src/pm/ua-vendor-plugin-manager.c [moved from ua-daemon/src/pm/ua-power-plugin-manager.c with 61% similarity]
ua-daemon/src/ua-manager-core.c
ua-plugins/CMakeLists.txt
ua-plugins/include/ua-vendor-plugin.h [moved from ua-plugins/include/ua-power-plugin.h with 67% similarity]

index 07f8952..2acb0e3 100644 (file)
@@ -1,6 +1,6 @@
 Name:       ua-manager
 Summary:    User awareness manager
-Version:    0.12.2
+Version:    0.12.3
 Release:    1
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
@@ -109,6 +109,6 @@ cp ua-manager.service %{buildroot}%{_unitdir}/ua-manager.service
 %defattr(-, root, root)
 %{_includedir}/ua-manager/plugins/ua-plugin-type.h
 %{_includedir}/ua-manager/plugins/ua-plugin.h
-%{_includedir}/ua-manager/plugins/ua-power-plugin.h
+%{_includedir}/ua-manager/plugins/ua-vendor-plugin.h
 %{_includedir}/ua-manager/plugins/ua-cloud-plugin.h
 %{_libdir}/pkgconfig/ua-plugins.pc
index 7d3eec0..687b780 100644 (file)
@@ -23,8 +23,8 @@ SET(SRCS
        src/pm/ua-light-plugin-handler.c
        src/pm/ua-motion-plugin-handler.c
        src/pm/ua-cloud-plugin-handler.c
-       src/pm/ua-power-plugin-manager.c
-       src/pm/ua-power-plugin-handler.c
+       src/pm/ua-vendor-plugin-manager.c
+       src/pm/ua-vendor-plugin-handler.c
 )
 
 IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
index 4bf67b4..5e577a2 100644 (file)
@@ -55,7 +55,7 @@ extern "C" {
 #define FUNC_EXIT UAM_DBG("-")
 
 #define SENSOR_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/sensor")
-#define POWER_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/power")
+#define VENDOR_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/vendor")
 #define CLOUD_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/cloud")
 
 #define UAM_VERSION "0.1"
similarity index 78%
rename from ua-daemon/include/ua-power-plugin-manager.h
rename to ua-daemon/include/ua-vendor-plugin-manager.h
index 1e3586c..a37dd3a 100644 (file)
  *
  */
 
-#ifndef __UAM_POWER_PLUGIN_MANAGER_H__
-#define __UAM_POWER_PLUGIN_MANAGER_H__
+#ifndef __UAM_VENDOR_PLUGIN_MANAGER_H__
+#define __UAM_VENDOR_PLUGIN_MANAGER_H__
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-void _uam_ppm_send_presence_detection_event(unsigned int sensor);
+void _uam_vpm_send_presence_detection_event(unsigned int sensor);
 
 #ifdef __cplusplus
 }
 #endif
-#endif /* __UAM_POWER_PLUGIN_MANAGER_H__ */
+#endif /* __UAM_VENDOR_PLUGIN_MANAGER_H__ */
index de14463..4ee1128 100644 (file)
@@ -353,7 +353,7 @@ static int __init_cloud_plugin(void)
        FUNC_ENTRY;
        int status;
 
-       /* Initialize loaded power plugins */
+       /* Initialize loaded cloud plugins */
        retv_if(UAM_ERROR_NONE != __load_cloud_plugin(), UAM_ERROR_INTERNAL);
 
        if (!cloud_plugin || !cloud_plugin->api) {
similarity index 95%
rename from ua-daemon/src/pm/ua-power-plugin-handler.c
rename to ua-daemon/src/pm/ua-vendor-plugin-handler.c
index 5fcccbe..a8d3865 100644 (file)
@@ -18,7 +18,7 @@
 #include <string.h>
 
 #include <ua-plugin.h>
-#include <ua-power-plugin.h>
+#include <ua-vendor-plugin.h>
 #include <ua-plugin-manager.h>
 #include <ua-manager-core.h>
 
@@ -40,26 +40,26 @@ static int do_presence_check_callback(unsigned int sensors)
        if (UAM_ERROR_NONE != ret) {
                UAM_ERR("Failed with error: %s (0x%4.4X)",
                                _uam_manager_error_to_str(ret), ret);
-               return UAP_STATUS_FAIL;
+               return UAV_STATUS_FAIL;
        }
 
        ret = _uam_pm_set_low_power_mode(UAM_SENSOR_ALL, FALSE);
        if (UAM_ERROR_NONE != ret) {
                UAM_ERR("Failed with error: %s (0x%4.4X)",
                                _uam_manager_error_to_str(ret), ret);
-               return UAP_STATUS_FAIL;
+               return UAV_STATUS_FAIL;
        }
 
        ret = _uam_pm_start_detection(UAM_DETECT_PRESENCE, sensors);
        if (UAM_ERROR_NONE != ret) {
                UAM_ERR("Failed with error: %s (0x%4.4X)",
                                _uam_manager_error_to_str(ret), ret);
-               return UAP_STATUS_FAIL;
+               return UAV_STATUS_FAIL;
        }
 
        presence_check_started = TRUE;
        FUNC_EXIT;
-       return UAP_STATUS_SUCCESS;
+       return UAV_STATUS_SUCCESS;
 }
 
 static void stop_presence_check_callback(unsigned int sensors)
@@ -126,7 +126,7 @@ static void reset(void)
        FUNC_EXIT;
 }
 
-uap_callbacks_t power_cbs = {
+uav_callbacks_t vendor_cbs = {
        .check_presence_cb = do_presence_check_callback,
        .stop_presence_cb = stop_presence_check_callback,
        .get_active_sensors_cb = get_active_sensors_callback,
similarity index 61%
rename from ua-daemon/src/pm/ua-power-plugin-manager.c
rename to ua-daemon/src/pm/ua-vendor-plugin-manager.c
index 3490061..f60a560 100644 (file)
 #include <string.h>
 #include <dlfcn.h>
 #include <ua-plugin.h>
-#include <ua-power-plugin.h>
+#include <ua-vendor-plugin.h>
 #include <ua-plugin-manager.h>
-#include <ua-power-plugin-manager.h>
+#include <ua-vendor-plugin-manager.h>
 #include <tzplatform_config.h>
 
-extern const uap_callbacks_t power_cbs;
+extern const uav_callbacks_t vendor_cbs;
 
 typedef struct {
        void *handle;
-       uap_module_t *module;
+       uav_module_t *module;
        uap_api_t *api;
-} uam_power_plugin_info_t;
+} uam_vendor_plugin_info_t;
 
-static uam_power_plugin_info_t* pwr_plugin = NULL;
+static uam_vendor_plugin_info_t* vendor_plugin = NULL;
 
-static void __deinit_power_plugin(void)
+static void __deinit_vendor_plugin(void)
 {
        FUNC_ENTRY;
 
        /* Deinitialize and unload power plugins */
-       if (!pwr_plugin) {
+       if (!vendor_plugin) {
                UAM_WARN("Power plugin is NULL");
                return;
        }
-       if (pwr_plugin->api && pwr_plugin->api->deinit)
-               pwr_plugin->api->deinit();
-       if (pwr_plugin->module && pwr_plugin->module->deinit)
-               pwr_plugin->module->deinit();
-       if (pwr_plugin->handle)
-               dlclose(pwr_plugin->handle);
+       if (vendor_plugin->api && vendor_plugin->api->deinit)
+               vendor_plugin->api->deinit();
+       if (vendor_plugin->module && vendor_plugin->module->deinit)
+               vendor_plugin->module->deinit();
+       if (vendor_plugin->handle)
+               dlclose(vendor_plugin->handle);
 
-       g_free(pwr_plugin);
-       pwr_plugin = NULL;
+       g_free(vendor_plugin);
+       vendor_plugin = NULL;
 
        FUNC_EXIT;
 }
 
-static gboolean __add_power_plugin(void *handle, uap_module_t *module)
+static gboolean __add_vendor_plugin(void *handle, uav_module_t *module)
 {
        FUNC_ENTRY;
 
        uap_api_t *api = NULL;
-       uam_power_plugin_info_t *plugin = pwr_plugin;
+       uam_vendor_plugin_info_t *plugin = vendor_plugin;
        UAM_DBG("Plugin [id: %d, name: %s, version: %s]",
                        module->id, module->name, module->version);
 
-       if (NULL != pwr_plugin) {
+       if (NULL != vendor_plugin) {
                UAM_ERR("Plugin already added");
                return FALSE;
        }
@@ -73,7 +73,7 @@ static gboolean __add_power_plugin(void *handle, uap_module_t *module)
                return FALSE;
        }
 
-       plugin = g_try_new0(uam_power_plugin_info_t, 1);
+       plugin = g_try_new0(uam_vendor_plugin_info_t, 1);
        if (NULL == plugin) {
                UAM_ERR("Memory allocation failed");
                return FALSE;
@@ -96,19 +96,19 @@ static gboolean __add_power_plugin(void *handle, uap_module_t *module)
        plugin->module = module;
        plugin->api = api;
 
-       pwr_plugin = plugin;
+       vendor_plugin = plugin;
 
        FUNC_EXIT;
        return TRUE;
 }
 
-static int __load_power_plugin(const char *path, const char *name, const char *symbol)
+static int __load_vendor_plugin(const char *path, const char *name, const char *symbol)
 {
        FUNC_ENTRY;
 
        char *filename = NULL;
        void *handle = NULL;
-       uap_module_t *module = NULL;
+       uav_module_t *module = NULL;
 
        retv_if(NULL == path, UAM_ERROR_INVALID_PARAMETER);
        retv_if(NULL == name, UAM_ERROR_INVALID_PARAMETER);
@@ -124,26 +124,26 @@ static int __load_power_plugin(const char *path, const char *name, const char *s
                return UAM_ERROR_INTERNAL;
        }
 
-       module = (uap_module_t *)dlsym(handle, symbol);
+       module = (uav_module_t *)dlsym(handle, symbol);
        if (module == NULL) {
                UAM_ERR("Can't load power plugin module: %s", dlerror());
                dlclose(handle);
                return UAM_ERROR_INTERNAL;
        }
 
-       if (UAP_PLUGIN_ID_POWER != module->id) {
+       if (UAV_PLUGIN_ID_VENDOR != module->id) {
                dlclose(handle);
                handle = NULL;
                return UAM_ERROR_INVALID_PARAMETER;
        }
 
-       retv_if(FALSE == __add_power_plugin(handle, module), UAM_ERROR_INTERNAL);
+       retv_if(FALSE == __add_vendor_plugin(handle, module), UAM_ERROR_INTERNAL);
 
        FUNC_EXIT;
        return UAM_ERROR_NONE;
 }
 
-static int __load_power_plugins(void)
+static int __load_vendor_plugins(void)
 {
        FUNC_ENTRY;
 
@@ -151,10 +151,10 @@ static int __load_power_plugins(void)
        const char *filename;
        int ret = UAM_ERROR_INTERNAL;
 
-       retv_if(0 == strlen(POWER_PLUGIN_DIR), UAM_ERROR_INVALID_PARAMETER);
-       UAM_DBG("Loading power plugin from %s", POWER_PLUGIN_DIR);
+       retv_if(0 == strlen(VENDOR_PLUGIN_DIR), UAM_ERROR_INVALID_PARAMETER);
+       UAM_DBG("Loading vendor plugin from %s", VENDOR_PLUGIN_DIR);
 
-       dir = g_dir_open(POWER_PLUGIN_DIR, 0, NULL);
+       dir = g_dir_open(VENDOR_PLUGIN_DIR, 0, NULL);
        if (!dir) {
                UAM_ERR("Unable to open directory");
                return UAM_ERROR_INTERNAL;
@@ -164,7 +164,7 @@ static int __load_power_plugins(void)
                if (g_str_has_suffix(filename, ".so") == FALSE)
                        continue;
                /* If atleast one plugin is loaded, return value is UAM_ERROR_NONE */
-               if (UAM_ERROR_NONE == __load_power_plugin(POWER_PLUGIN_DIR, filename, "uap_module"))
+               if (UAM_ERROR_NONE == __load_vendor_plugin(VENDOR_PLUGIN_DIR, filename, "uap_module"))
                        ret = UAM_ERROR_NONE;
        }
        g_dir_close(dir);
@@ -173,25 +173,25 @@ static int __load_power_plugins(void)
        return ret;
 }
 
-static int __init_power_plugin(void)
+static int __init_vendor_plugin(void)
 {
        FUNC_ENTRY;
 
        int ret;
        int status;
        /* Initialize loaded power plugins */
-       retv_if(UAM_ERROR_NONE != __load_power_plugins(), UAM_ERROR_INTERNAL);
+       retv_if(UAM_ERROR_NONE != __load_vendor_plugins(), UAM_ERROR_INTERNAL);
 
-       uam_power_plugin_info_t *plugin = pwr_plugin;
+       uam_vendor_plugin_info_t *plugin = vendor_plugin;
        if (!plugin || !plugin->api) {
                UAM_WARN("Plugin is NULL");
                return UAM_ERROR_INVALID_PARAMETER;
        }
 
-       status = plugin->api->init(&power_cbs);
+       status = plugin->api->init(&vendor_cbs);
        if (UAS_STATUS_SUCCESS != status) {
                /* Deinit plugin */
-               __deinit_power_plugin();
+               __deinit_vendor_plugin();
                return UAM_ERROR_NOT_IN_OPERATION;
        }
 
@@ -202,32 +202,32 @@ static int __init_power_plugin(void)
        return ret;
 }
 
-static void __attribute__((constructor)) _uam_ppm_init(void)
+static void __attribute__((constructor)) _uam_vpm_init(void)
 {
        FUNC_ENTRY;
        int ret;
 
-       ret = __init_power_plugin();
+       ret = __init_vendor_plugin();
        ret_if(UAM_ERROR_NONE != ret);
-       UAM_INFO_C("__init_power_plugin done");
+       UAM_INFO_C("__init_vendor_plugin done");
 
        FUNC_EXIT;
 }
 
-static void __attribute__((destructor)) _uam_ppm_deinit(void)
+static void __attribute__((destructor)) _uam_vpm_deinit(void)
 {
        FUNC_ENTRY;
-       __deinit_power_plugin();
+       __deinit_vendor_plugin();
        FUNC_EXIT;
 }
 
-void _uam_ppm_send_presence_detection_event(unsigned int sensor)
+void _uam_vpm_send_presence_detection_event(unsigned int sensor)
 {
        FUNC_ENTRY;
-       ret_if(NULL == pwr_plugin);
-       ret_if(NULL == pwr_plugin->api);
-       ret_if(NULL == pwr_plugin->api->presence_detected_cb);
+       ret_if(NULL == vendor_plugin);
+       ret_if(NULL == vendor_plugin->api);
+       ret_if(NULL == vendor_plugin->api->presence_detected_cb);
 
-       pwr_plugin->api->presence_detected_cb(sensor);
+       vendor_plugin->api->presence_detected_cb(sensor);
        FUNC_EXIT;
 }
index 6314bc0..e61386c 100644 (file)
@@ -26,7 +26,7 @@
 #include "ua-manager-database.h"
 #include "ua-cloud-plugin-handler.h"
 
-#include "ua-power-plugin-manager.h"
+#include "ua-vendor-plugin-manager.h"
 
 #define UAM_MAX_USERS 255
 #define USER_ACCOUNT_DEFAULT "default@default.com"
@@ -2737,7 +2737,7 @@ void _uam_core_handle_presence_detected(unsigned int sensor,
        if (info && (UAM_SENSOR_BITMASK_BLE == sensor || UAM_SENSOR_BITMASK_WIFI == sensor))
                dev_info = info;
 
-       _uam_ppm_send_presence_detection_event(sensor);
+       _uam_vpm_send_presence_detection_event(sensor);
 
        if (NULL == dev_info) {
                __send_sensor_presence_event(sensor_info, sensor);
index 5b08666..c0bd170 100644 (file)
@@ -6,7 +6,7 @@ SET(LIB_PKGCONFIG_DIR "${LIB_PATH}/pkgconfig")
 SET(HEADERS
        ua-plugin-type.h
        ua-plugin.h
-       ua-power-plugin.h
+       ua-vendor-plugin.h
        ua-cloud-plugin.h
        )
 
similarity index 67%
rename from ua-plugins/include/ua-power-plugin.h
rename to ua-plugins/include/ua-vendor-plugin.h
index 1fcd537..87b5ebf 100644 (file)
  * limitations under the License.
  *
  */
-#ifndef __UAM_POWER_PLUGIN_H__
-#define __UAM_POWER_PLUGIN_H__
+#ifndef __UAM_VENDOR_PLUGIN_H__
+#define __UAM_VENDOR_PLUGIN_H__
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/* UA power plugin states */
+/* UA vendor plugin states */
 typedef enum {
-       UAP_STATE_NOT_READY = 0x00,
-       UAP_STATE_READY
-} uap_state_e;
+       UAV_STATE_NOT_READY = 0x00,
+       UAV_STATE_READY
+} uav_state_e;
 
 /* UA power plugin return status */
 typedef enum {
-       UAP_STATUS_SUCCESS = 0x00,
-       UAP_STATUS_FAIL = 0x01,
-       UAP_STATUS_NOT_READY = 0x02,
-       UAP_STATUS_NOMEM = 0x03,
-       UAP_STATUS_BUSY = 0x04,
-       UAP_STATUS_ALREADY_DONE = 0x05,
-       UAP_STATUS_UNSUPPORTED = 0x06,
-       UAP_STATUS_TIMEOUT = 0x07,
-       UAP_STATUS_INVALID_PARAMS = 0x08,
-} uap_status_e;
+       UAV_STATUS_SUCCESS = 0x00,
+       UAV_STATUS_FAIL = 0x01,
+       UAV_STATUS_NOT_READY = 0x02,
+       UAV_STATUS_NOMEM = 0x03,
+       UAV_STATUS_BUSY = 0x04,
+       UAV_STATUS_ALREADY_DONE = 0x05,
+       UAV_STATUS_UNSUPPORTED = 0x06,
+       UAV_STATUS_TIMEOUT = 0x07,
+       UAV_STATUS_INVALID_PARAMS = 0x08,
+} uav_status_e;
 
 /*
- * DIRECTION: ua-manager --> power-plugin
+ * DIRECTION: ua-manager --> vendor-plugin
  * ua-manager calls this to nofity PRESENCE detected or timeout occurs
  * [Param] status - Operation status Success/Fail/Timeout
  * [Param] ids - Which sensor detect(s)
  */
-typedef int (*presence_cb)(uap_status_e status, uas_plugin_id_e ids);
+typedef int (*presence_cb)(uav_status_e status, uas_plugin_id_e ids);
 
 /*
- * DIRECTION: power-plugin --> ua-manager
+ * DIRECTION: vendor-plugin --> ua-manager
  * Power plugin invokes this to detect one-time PRESENCE (after TV resume).
  * [Param] sensors - Which sensors will detect PRESENCE
  */
 typedef int (*start_presence_check)(unsigned int sensors);
 
 /*
- * DIRECTION: power-plugin --> ua-manager
+ * DIRECTION: vendor-plugin --> ua-manager
  * Power plugin invokes this to stop one-time PRESENCE detection
  */
 typedef void (*stop_presence_check)(unsigned int sensors);
 
 /*
- * DIRECTION: power-plugin --> ua-manager
+ * DIRECTION: vendor-plugin --> ua-manager
  * Get available sensor list (bitmask)
  */
 typedef unsigned int (*get_active_sensors)(void);
 
 /*
- * DIRECTION: power-plugin --> ua-manager
+ * DIRECTION: vendor-plugin --> ua-manager
  * Power plugin invokes this to set low power mode in detection sensors.
  * If mode == 0 - Disable LPM, else Enable LPM
  */
 typedef void (*set_low_power_mode)(int mode);
 
 /*
- * DIRECTION: power-plugin --> ua-manager
+ * DIRECTION: vendor-plugin --> ua-manager
  * Power plugin invokes this to reset ua-manager database.
  */
 typedef void (*reset_ua_db)(void);
@@ -87,30 +87,30 @@ typedef struct {
        get_active_sensors get_active_sensors_cb;
        set_low_power_mode set_lpm_mode_cb;
        reset_ua_db reset_cb;
-} uap_callbacks_t;
+} uav_callbacks_t;
 
 typedef struct {
        /* [Sync API] To initialize power plug-in */
-       int (*init)(const uap_callbacks_t* callbacks);
+       int (*init)(const uav_callbacks_t* callbacks);
 
        /* [Sync API] To deinitialize senspor plug-in */
        int (*deinit)(void);
 
        /* [Sync API] To get plug-in's current state (READY/NOT_READY) */
-       int (*get_state)(uap_state_e *state);
+       int (*get_state)(uav_state_e *state);
 
        /*
-        * [Sync API] This function notify power-plugin of presence detection.
+        * [Sync API] This function notify vendor-plugin of presence detection.
         * [Param] sensor - Which sensor detect event.
         */
        void (*presence_detected_cb)(unsigned int sensor);
 } uap_api_t;
 
 typedef enum {
-       UAP_PLUGIN_ID_NONE = 0, /**< None */
-       UAP_PLUGIN_ID_POWER = 0xAAAA, /**< 0b101010.. pattern */
-       UAP_PLUGIN_ID_MAX
-} uap_plugin_id_e;
+       UAV_PLUGIN_ID_NONE = 0, /**< None */
+       UAV_PLUGIN_ID_VENDOR = 0xAAAA, /**< 0b101010.. pattern */
+       UAV_PLUGIN_ID_MAX
+} uav_plugin_id_e;
 
 typedef struct {
        /** Identifier of module */
@@ -125,12 +125,12 @@ typedef struct {
        int (*init)(uap_api_t **api);
        /** Modules de-init */
        int (*deinit)(void);
-} uap_module_t;
+} uav_module_t;
 
-#define UAP_MODULE_ADD(id, name, author, version, init, deinit) \
-       uap_module_t uap_module = { id, name, author, version, init, deinit };
+#define UAV_MODULE_ADD(id, name, author, version, init, deinit) \
+       uav_module_t uap_module = { id, name, author, version, init, deinit };
 
 #ifdef __cplusplus
 }
 #endif
-#endif /* __UAM_POWER_PLUGIN_H__ */
+#endif /* __UAM_VENDOR_PLUGIN_H__ */