Identify whether device is already registered and not
authorLokesh <l.kasana@samsung.com>
Fri, 22 Nov 2019 02:04:04 +0000 (07:34 +0530)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 25 Nov 2019 01:09:18 +0000 (10:09 +0900)
Change-Id: Ib4eaaa7864578d7a03679a7f2d1695891fc5068d
Signed-off-by: Lokesh <l.kasana@samsung.com>
include/ua-api.h
ua-daemon/include/ua-manager-core.h
ua-daemon/src/pm/ua-ble-plugin-handler.c
ua-daemon/src/pm/ua-wifi-plugin-handler.c
ua-daemon/src/ua-manager-core.c

index 8d57f07..43b6926 100644 (file)
@@ -480,6 +480,15 @@ typedef enum {
 } uam_tech_type_e;
 
 /**
+ * @brief Enumerations for device is already registered or not.
+ * @since_tizen 5.5
+ */
+typedef enum {
+       UAM_DEVICE_IS_NOT_REGISTERED = 0x00, /**< Device is not registered */
+       UAM_DEVICE_IS_ALREADY_REGISTERED = 0x01, /**< Device already registered */
+} uam_is_new_device_e;
+
+/**
  * @brief BLE Payload info structure.
  * @since_tizen 5.5
  */
index f7f85d9..abaea10 100644 (file)
@@ -180,8 +180,8 @@ void _uam_core_deinit(void);
 
 void _uam_core_handle_sensor_ready(unsigned int sensor, gboolean is_ready);
 
-int _uam_core_handle_device_added(int status,
-               int user_id, const uam_device_info_s *dev_info);
+int _uam_core_handle_device_added(int status, int user_id,
+               const uam_device_info_s *dev_info, int is_new_device);
 
 int _uam_core_handle_presence_detected(unsigned int sensor,
                int user_id, void *sensor_info);
index da39bbe..88b8e7a 100644 (file)
@@ -110,7 +110,8 @@ static void ble_device_added_callback(int status, uas_device_info_t *device)
        else
                status = UAM_ERROR_NONE;
 
-       _uam_core_handle_device_added(status, device->user_id, dev_info);
+       _uam_core_handle_device_added(status, device->user_id, dev_info,
+                                     UAM_DEVICE_IS_NOT_REGISTERED);
        g_free(dev_info);
        FUNC_EXIT;
 }
index b81fa40..d2f2568 100644 (file)
@@ -110,7 +110,8 @@ static void wifi_device_added_callback(int status, uas_device_info_t *device)
                status = UAM_ERROR_NONE;
 
        UAM_INFO("[%d]", device->user_id);
-       _uam_core_handle_device_added(status, device->user_id, dev_info);
+       _uam_core_handle_device_added(status, device->user_id, dev_info,
+                                       UAM_DEVICE_IS_NOT_REGISTERED);
        g_free(dev_info);
        FUNC_EXIT;
 }
index 118dcc1..a98bdcc 100644 (file)
@@ -666,6 +666,11 @@ static void __uam_core_add_dev_to_list(
        l = g_slist_find_custom(devices, dev_info->device_id, __compare_device_id);
        if (NULL != l) {
                device = l->data;
+               /**
+                * TODO: UAM_DEVICE_IS_ALREADY_REGISTERED
+                * 1. Check if user exists or not and accordingly,
+                * 2. Update user->dev, dev->user. dev_user_table and dev_user_list.
+                */
                ret_if(user != device->user);
                ret_if(device->supported_techs & dev_info->type);
 
@@ -892,6 +897,11 @@ int _uam_core_add_device(const char *account, const uam_device_info_s *dev_info)
        l = g_slist_find_custom(devices, dev_info->device_id, __compare_device_id);
        if (NULL != l) {
                device = l->data;
+               /**
+                * TODO: UAM_DEVICE_IS_ALREADY_REGISTERED
+                * 1. Check whether device and user association already exists or not?
+                * 2. If association exists, update device details and send device added callback.
+                */
                retv_if(user != device->user, UAM_ERROR_ALREADY_REGISTERED);
                retv_if((dev_info->type & device->supported_techs),
                                UAM_ERROR_ALREADY_REGISTERED);
@@ -2493,8 +2503,8 @@ void _uam_core_handle_sensor_ready(unsigned int sensor, gboolean is_ready)
        FUNC_EXIT;
 }
 
-int _uam_core_handle_device_added(int status,
-               int user_id, const uam_device_info_s *dev_info)
+int _uam_core_handle_device_added(int status, int user_id,
+               const uam_device_info_s *dev_info, int is_new_device)
 {
        FUNC_ENTRY;