Remove payload from device
authorAbhay agarwal <ay.agarwal@samsung.com>
Thu, 28 Nov 2019 11:35:41 +0000 (17:05 +0530)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 30 Dec 2019 07:29:55 +0000 (16:29 +0900)
payload would be added to device-service instead of only being device specific

Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
include/ua-api.h
ua-daemon/include/ua-manager-core.h
ua-daemon/include/ua-manager-database.h
ua-daemon/src/pm/ua-plugin-manager.c
ua-daemon/src/pm/ua-pm-util.c
ua-daemon/src/ua-manager-core.c
ua-daemon/src/ua-manager-device-db.c
ua-daemon/src/ua-manager-request-handler.c

index 0c74194..808a36c 100644 (file)
@@ -501,7 +501,6 @@ typedef struct {
        char mac[UAM_MAC_ADDRESS_STRING_LEN]; /**< Device's MAC ADDRESS */
        char ipv4_addr[UAM_IP_ADDRESS_MAX_STRING_LEN];/**< Device's IPv4 address optional */
        char device_id[UAM_DEVICE_ID_MAX_STRING_LEN]; /**< Device's uniquie ID */
-       uam_ble_payload_s payload; /**< BLE Payload to parse BLE devices*/
        gboolean discriminant; /**< Determines whether to judge PRESENCE/ABSENCE */
        unsigned long long last_seen; /**< Latest seen time when device was discoverd */
 } uam_device_info_s;
index 3ee75ac..57d7a6a 100644 (file)
@@ -83,7 +83,6 @@ typedef struct {
        gboolean discriminant; /**< Decide whether to detect device or not */
        struct uam_db_device_info *device; /**< Device info which stored in the DB */
        GSList *svc_list; /**< Service list */
-       uam_db_ble_payload_t *payload; /**< Filtering info when detecting the BLE payload */
 } uam_db_tech_info_t;
 
 typedef struct uam_db_device_info {
index 7c08057..9571516 100644 (file)
@@ -142,8 +142,8 @@ int _uam_device_db_update_device_ip_address(
        char *device_id, int tech_type, char *ip_address);
 int _uam_device_db_update_device_mac_address(
        char *device_id, int tech_type, char *address);
-int _uam_device_db_update_device_device(char *device_id, int tech_type,
-       char *address, char *ip, char os_type, char discriminant, uam_ble_payload_s payload);
+int _uam_device_db_update_device(char *device_id, int tech_type,
+       char *address, char *ip, char os_type, char discriminant);
 
 /* SERVICE QUERIES */
 
index 78c722c..f378551 100644 (file)
@@ -292,12 +292,6 @@ static void __uas_device_list_free(int count, uas_device_info_t *devices)
                        g_free(device->addr_list[j].address);
 
                g_free(device->addr_list);
-
-               if(device->payload) {
-                       g_free(device->payload->device_uid);
-                       g_free(device->payload->bt_mac);
-                       g_free(device->payload);
-               }
        }
 
        g_free(devices);
index 240b8d5..6fbe543 100644 (file)
@@ -142,13 +142,6 @@ void _pm_util_uas_device_info_free(uas_device_info_t *device)
                g_free(device->addr_list[i].address);
 
        g_free(device->addr_list);
-
-       if (device->payload) {
-               g_free(device->payload->device_uid);
-               g_free(device->payload->bt_mac);
-               g_free(device->payload);
-       }
-
        g_free(device);
 
        FUNC_EXIT;
@@ -197,12 +190,6 @@ void _pm_util_uam_db_dev_to_uas_dev(unsigned int tech_type,
                        (*device)->addr_list[i].type = _pm_util_uam_addr_type_to_uas_addr_type(addr->addr_type);
                        (*device)->addr_list[i++].address = g_strdup(addr->address);
                }
-               (*device)->payload = g_new0(uas_ble_payload_t, 1);
-               (*device)->payload->primary_key = tech->payload->primary_key;
-               (*device)->payload->secondary_key = tech->payload->secondary_key;
-               (*device)->payload->device_icon = tech->payload->device_icon;
-               (*device)->payload->device_uid = g_memdup(tech->payload->device_uid, UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
-               (*device)->payload->bt_mac = g_memdup(tech->payload->bt_mac, UAM_BT_MAC_ADDRESS_STRING_LEN);
        }
 
        FUNC_EXIT;
@@ -259,13 +246,6 @@ uas_device_info_t *_pm_util_uam_dev_info_to_uas_dev_info(const uam_device_info_s
 
        device->device_id = g_strdup(dev->device_id);
 
-       device->payload = g_new0(uas_ble_payload_t, 1);
-       device->payload->primary_key = dev->payload.primary_key;
-       device->payload->secondary_key = dev->payload.secondary_key;
-       device->payload->device_icon = dev->payload.device_icon;
-       device->payload->device_uid = g_memdup(&(dev->payload.device_uid), UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
-       device->payload->bt_mac = g_memdup(&(dev->payload.bt_mac), UAM_BT_MAC_ADDRESS_STRING_LEN);
-
        device->addr_list = g_new0(uas_address_info_t, device->num_addr);
        if (mac) {
                device->addr_list[i].type = type;
@@ -297,19 +277,6 @@ uam_device_info_s *_pm_util_uas_dev_info_to_uam_dev_info(const uas_device_info_t
        device->last_seen = dev->last_seen;
        g_strlcpy(device->device_id, dev->device_id, UAM_DEVICE_ID_MAX_STRING_LEN);
 
-       memset(device->payload.device_uid, 0, UAM_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
-       memset(device->payload.bt_mac, 0, UAM_BT_MAC_ADDRESS_STRING_LEN);
-       if (dev->payload) {
-               device->payload.primary_key = dev->payload->primary_key;
-               device->payload.device_icon = dev->payload->device_icon;
-               device->payload.secondary_key = dev->payload->secondary_key;
-               if (dev->payload->device_uid)
-                       memcpy(device->payload.device_uid, dev->payload->device_uid, UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
-               if (dev->payload->bt_mac)
-                       g_strlcpy(device->payload.bt_mac,
-                       dev->payload->bt_mac, UAM_BT_MAC_ADDRESS_STRING_LEN);
-       }
-
        for (i = 0; i < dev->num_addr; i++) {
                UAM_DBG("Address[%d]: %s", i, dev->addr_list[i].address);
                switch (dev->addr_list[i].type) {
index d2eb599..d01c111 100644 (file)
@@ -133,12 +133,6 @@ static void __free_dev_tech_info(gpointer data)
        g_slist_free_full(tech_info->addresses, __free_address_info);
        tech_info->addresses = NULL;
 
-       if (tech_info->payload) {
-               g_free(tech_info->payload->device_uid);
-               g_free(tech_info->payload->bt_mac);
-               g_free(tech_info->payload);
-       }
-
        g_free(tech_info);
 
        FUNC_EXIT;
@@ -272,6 +266,7 @@ static void __uam_core_copy_addr(uam_device_info_s *device, uam_db_address_info_
        }
 }
 
+/*
 static void __uam_copy_payload_info(uam_ble_payload_s *dev_payload, uam_db_ble_payload_t *payload)
 {
        if (payload) {
@@ -286,6 +281,7 @@ static void __uam_copy_payload_info(uam_ble_payload_s *dev_payload, uam_db_ble_p
                        payload->bt_mac, UAM_BT_MAC_ADDRESS_STRING_LEN);
        }
 }
+*/
 
 static int __copy_tech_info_to_device_info(uam_db_tech_info_t *tech, uam_device_info_s *device)
 {
@@ -309,10 +305,7 @@ static int __copy_tech_info_to_device_info(uam_db_tech_info_t *tech, uam_device_
                        UAM_DEVICE_ID_MAX_STRING_LEN);
        device->type = tech->tech_type;
        device->discriminant = tech->discriminant;
-       memset(device->payload.device_uid, 0, UAM_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
-       memset(device->payload.bt_mac, 0, UAM_BT_MAC_ADDRESS_STRING_LEN);
        device->last_seen = tech->last_seen;
-       __uam_copy_payload_info(&(device->payload), tech->payload);
 
        FUNC_EXIT;
        return UAM_ERROR_NONE;
@@ -699,13 +692,6 @@ static void __uam_core_add_dev_to_list(
        tech->device = device;
        tech->discriminant = dev_info->discriminant;
 
-       tech->payload = g_new0(uam_db_ble_payload_t, 1);
-       tech->payload->primary_key = dev_info->payload.primary_key;
-       tech->payload->secondary_key = dev_info->payload.secondary_key;
-       tech->payload->device_icon = dev_info->payload.device_icon;
-       tech->payload->device_uid = g_memdup(&(dev_info->payload.device_uid), UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
-       tech->payload->bt_mac = g_memdup(&(dev_info->payload.bt_mac), UAM_BT_MAC_ADDRESS_STRING_LEN);
-
        tech->svc_list = svc_list;
        g_slist_foreach(tech->svc_list, __print_service, tech);
        for (l = svc_list; NULL != l; l = g_slist_next(l)) {
@@ -1194,13 +1180,6 @@ int _uam_core_update_device(const uam_device_info_s *a_device)
                /* Update discriminant for device-tech */
                tech->discriminant = a_device->discriminant;
 
-               /* Update Payload for device-tech */
-               tech->payload->primary_key = a_device->payload.primary_key;
-               tech->payload->secondary_key = a_device->payload.secondary_key;
-               tech->payload->device_icon = a_device->payload.device_icon;
-               tech->payload->device_uid = g_memdup(&(a_device->payload.device_uid), UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
-               tech->payload->bt_mac = g_memdup(&(a_device->payload.bt_mac), UAM_BT_MAC_ADDRESS_STRING_LEN);
-
                /* Update device's updated information to database */
                ret = __copy_tech_info_to_device_info(tech, &temp);
                if (UAM_ERROR_NONE != ret) {
@@ -1208,11 +1187,10 @@ int _uam_core_update_device(const uam_device_info_s *a_device)
                        return ret;
                }
 
-               ret = _uam_device_db_update_device_device(temp.device_id, temp.type,
-                               temp.mac, temp.ipv4_addr, temp.operating_system, temp.discriminant,
-                               temp.payload);
+               ret = _uam_device_db_update_device(temp.device_id, temp.type,
+                               temp.mac, temp.ipv4_addr, temp.operating_system, temp.discriminant);
                if (UAM_ERROR_NONE != ret) {
-                       UAM_ERR("_uam_device_db_update_device_device failed [%d]", ret);
+                       UAM_ERR("_uam_device_db_update_device failed [%d]", ret);
                        return ret;
                }
        }
index fbce295..8615a96 100644 (file)
 
 #define SELECT_ALL_DEVICES "SELECT device_id, tech_type, address, " \
        "ip_address, last_seen, presence_state, os_type, " \
-       "user_id, discriminant, primary_key, secondary_key, device_uid, device_icon FROM devices"
+       "user_id, discriminant FROM devices"
 
 #define SELECT_DEVICE "SELECT device_id, tech_type, address, " \
        "ip_address, last_seen, presence_state, os_type, " \
-       "user_id, discriminant, primary_key, secondary_key, device_uid, device_icon FROM devices " \
+       "user_id, discriminant FROM devices " \
        "WHERE device_id = ? AND tech_type = ? AND address = ?"
 
 #define SELECT_DEVICE_NUMBER "SELECT device_number FROM devices " \
@@ -38,9 +38,8 @@
 
 #define INSERT_DEVICE "insert into devices " \
        "(device_id, tech_type, address, ip_address, last_seen, " \
-       "presence_state, os_type, user_id, discriminant, primary_key, " \
-       "secondary_key, device_uid, device_icon)" \
-       "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
+       "presence_state, os_type, user_id, discriminant)" \
+       "values (?, ?, ?, ?, ?, ?, ?, ?, ?)"
 
 #define UPDATE_LAST_SEEN "UPDATE devices " \
        "SET last_seen = ? WHERE device_id = ? AND tech_type = ? AND address = ?"
@@ -55,8 +54,7 @@
        "SET address = ? WHERE device_id = ? AND tech_type = ?"
 
 #define UPDATE_DEVICE "UPDATE devices " \
-       "SET (os_type, discriminant, ip_address, primary_key, " \
-       "secondary_key, device_uid, device_icon) = (?, ?, ?, ?, ?, ?, ?) " \
+       "SET (os_type, discriminant, ip_address) = (?, ?, ?) " \
        "WHERE device_id = ? AND tech_type = ? AND address = ?"
 
 #define DELETE_ALL_DEVICES "delete from devices "
@@ -415,8 +413,8 @@ handle_error:
        return error_code;
 }
 
-int _uam_device_db_update_device_device(char *device_id, int tech_type,
-       char *address, char *ip, char os_type, char discriminant, uam_ble_payload_s payload)
+int _uam_device_db_update_device(char *device_id, int tech_type,
+       char *address, char *ip, char os_type, char discriminant)
 {
        int error_code = UAM_ERROR_NONE;
        sqlite3_stmt *stmt = update_device;
@@ -431,19 +429,11 @@ int _uam_device_db_update_device_device(char *device_id, int tech_type,
                error_code, handle_error);
        DB_ACTION(sqlite3_bind_text(stmt, 3, ip, -1, SQLITE_TRANSIENT),
                error_code, handle_error);
-       DB_ACTION(sqlite3_bind_text(stmt, 4, &(payload.primary_key), 1, SQLITE_TRANSIENT),
+       DB_ACTION(sqlite3_bind_text(stmt, 4, device_id, -1, SQLITE_TRANSIENT),
                error_code, handle_error);
-       DB_ACTION(sqlite3_bind_text(stmt, 5, &(payload.secondary_key), 1, SQLITE_TRANSIENT),
+       DB_ACTION(sqlite3_bind_int(stmt, 5, tech_type),
                error_code, handle_error);
-       DB_ACTION(sqlite3_bind_text(stmt, 6, payload.device_uid, UAM_BLE_PAYLOAD_DEVICE_UID_LEN + 1, SQLITE_TRANSIENT),
-               error_code, handle_error);
-       DB_ACTION(sqlite3_bind_text(stmt, 7, &(payload.device_icon), 1, SQLITE_TRANSIENT),
-               error_code, handle_error);
-       DB_ACTION(sqlite3_bind_text(stmt, 8, device_id, -1, SQLITE_TRANSIENT),
-               error_code, handle_error);
-       DB_ACTION(sqlite3_bind_int(stmt, 9, tech_type),
-               error_code, handle_error);
-       DB_ACTION(sqlite3_bind_text(stmt, 10, address, -1, SQLITE_TRANSIENT),
+       DB_ACTION(sqlite3_bind_text(stmt, 6, address, -1, SQLITE_TRANSIENT),
                error_code, handle_error);
 
        sql_ret = sqlite3_step(stmt);
@@ -472,10 +462,10 @@ int _uam_device_db_insert_device_info(int user_id,
 
        retv_if(NULL == dev_info, UAM_ERROR_INVALID_PARAMETER);
 
-       UAM_INFO("%s-%d-%s-%s-%llu-%d-%d-%d-%d-0x%2.2X", dev_info->device_id,
+       UAM_INFO("%s-%d-%s-%s-%llu-%d-%d-%d-%d", dev_info->device_id,
                        dev_info->type, dev_info->mac, dev_info->ipv4_addr,
                        last_seen, presence_state, dev_info->operating_system, dev_info->discriminant,
-                       user_id, dev_info->payload.primary_key);
+                       user_id);
 
        DB_ACTION(sqlite3_bind_text(stmt, 1, dev_info->device_id, -1, SQLITE_TRANSIENT),
                error_code, handle_error);
@@ -495,14 +485,6 @@ int _uam_device_db_insert_device_info(int user_id,
                error_code, handle_error);
        DB_ACTION(sqlite3_bind_int(stmt, 9, dev_info->discriminant),
                error_code, handle_error);
-       DB_ACTION(sqlite3_bind_text(stmt, 10, &(dev_info->payload.primary_key), 1, SQLITE_TRANSIENT),
-               error_code, handle_error);
-       DB_ACTION(sqlite3_bind_text(stmt, 11, &(dev_info->payload.secondary_key), 1, SQLITE_TRANSIENT),
-               error_code, handle_error);
-       DB_ACTION(sqlite3_bind_text(stmt, 12, dev_info->payload.device_uid, UAM_BLE_PAYLOAD_DEVICE_UID_LEN + 1, SQLITE_TRANSIENT),
-               error_code, handle_error);
-       DB_ACTION(sqlite3_bind_text(stmt, 13, &(dev_info->payload.device_icon), 1, SQLITE_TRANSIENT),
-               error_code, handle_error);
 
        sql_ret = sqlite3_step(stmt);
        if (sql_ret != SQLITE_DONE) {
@@ -570,7 +552,6 @@ int _uam_device_db_get_device(char *device_id, int tech_type, char *address,
        int error_code = UAM_ERROR_NONE;
        sqlite3_stmt *stmt = select_device;
        int sql_ret = SQLITE_OK;
-       char *buf = NULL;
 
        retv_if(NULL == info, UAM_ERROR_INVALID_PARAMETER);
 
@@ -603,18 +584,8 @@ int _uam_device_db_get_device(char *device_id, int tech_type, char *address,
                info->dev_info.operating_system = sqlite3_column_int(stmt, 6);
                info->user_id = sqlite3_column_int(stmt, 7);
                info->dev_info.discriminant = sqlite3_column_int(stmt, 8);
-               memset(info->dev_info.payload.device_uid, 0, UAM_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
-               buf = (char *)sqlite3_column_text(stmt, 9);
-               info->dev_info.payload.primary_key = buf ? *buf : 13;
-               buf = (char *)sqlite3_column_text(stmt, 10);
-               info->dev_info.payload.secondary_key = buf ? *buf : 1;
-               if ((char*)sqlite3_column_text(stmt, 11))
-                       memcpy(info->dev_info.payload.device_uid, (char *)sqlite3_column_text(stmt, 11),
-                               UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
-               buf = (char *)sqlite3_column_text(stmt, 12);
-               info->dev_info.payload.device_icon = buf ? *buf : 1;
-
-               UAM_INFO("%s-%d-%s-%s-%llu-%d-%d-%d-%d-0x%2.2X",
+
+               UAM_INFO("%s-%d-%s-%s-%llu-%d-%d-%d-%d",
                        info->dev_info.device_id,
                        info->dev_info.type,
                        info->dev_info.mac,
@@ -623,8 +594,7 @@ int _uam_device_db_get_device(char *device_id, int tech_type, char *address,
                        info->presence_state,
                        info->dev_info.operating_system,
                        info->user_id,
-                       info->dev_info.discriminant,
-                       info->dev_info.payload.primary_key);
+                       info->dev_info.discriminant);
        }
 
 handle_error:
@@ -684,7 +654,6 @@ GSList *_uam_device_db_get_all_devices(void)
        GSList *device_list = NULL;
        db_device_info_t *info = NULL;
        int sql_ret = SQLITE_OK;
-       char *buf = NULL;
 
        do {
                sql_ret = sqlite3_step(stmt);
@@ -706,18 +675,8 @@ GSList *_uam_device_db_get_all_devices(void)
                        info->dev_info.operating_system = sqlite3_column_int(stmt, 6);
                        info->user_id = sqlite3_column_int(stmt, 7);
                        info->dev_info.discriminant = sqlite3_column_int(stmt, 8);
-                       memset(info->dev_info.payload.device_uid, 0, UAM_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
-                       buf = (char *)sqlite3_column_text(stmt, 9);
-                       info->dev_info.payload.primary_key = buf ? *buf : 13;
-                       buf = (char *)sqlite3_column_text(stmt, 10);
-                       info->dev_info.payload.secondary_key = buf ? *buf : 1;
-                       if ((char*)sqlite3_column_text(stmt, 11))
-                               memcpy(info->dev_info.payload.device_uid, (char *)sqlite3_column_text(stmt, 11),
-                                       UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
-                       buf = (char *)sqlite3_column_text(stmt, 12);
-                       info->dev_info.payload.device_icon = buf ? *buf : 1;
-
-                       UAM_INFO("%s-%d-%s-%s-%llu-%d-%d-%d-%d-0x%2.2X",
+
+                       UAM_INFO("%s-%d-%s-%s-%llu-%d-%d-%d-%d",
                                info->dev_info.device_id,
                                info->dev_info.type,
                                info->dev_info.mac,
@@ -726,8 +685,7 @@ GSList *_uam_device_db_get_all_devices(void)
                                info->presence_state,
                                info->dev_info.operating_system,
                                info->user_id,
-                               info->dev_info.discriminant,
-                               info->dev_info.payload.primary_key);
+                               info->dev_info.discriminant);
 
                        device_list = g_slist_append(device_list, info);
                        break;
index f641bf2..55ffb2a 100644 (file)
@@ -805,15 +805,10 @@ static int __uam_manager_async_request_handler(
                account = (char *)g_variant_get_data(in_param1);
                __uam_manager_copy_params(in_param2,
                                &dev_info, sizeof(uam_device_info_s));
-               UAM_DBG("Account: [%s], Type: %d, MAC: [%s] IP: [%s], ID: [%s], Discriminant: [%s]," \
-                       " Payload ServiceId: [0x%2.2X], Purpose: [0x%2.2X], DEVICE_UID: [%s]," \
-                       " Device Icon: [0x%2.2X], BT MAC Address: [%s]",
+               UAM_DBG("Account: [%s], Type: %d, MAC: [%s] IP: [%s], ID: [%s], Discriminant: [%s]",
                                account, dev_info.type, dev_info.mac,
                                dev_info.ipv4_addr, dev_info.device_id,
-                               dev_info.discriminant ? "true" : "false",
-                               dev_info.payload.primary_key, dev_info.payload.secondary_key,
-                               dev_info.payload.device_uid, dev_info.payload.device_icon,
-                               dev_info.payload.bt_mac);
+                               dev_info.discriminant ? "true" : "false");
 
                if (__uam_manager_is_request_pending(UAM_REQUEST_ADD_DEVICE,
                                                     dev_info.device_id)) {