Modification to store device_icon in database
authorAbhay agarwal <ay.agarwal@samsung.com>
Tue, 20 Aug 2019 05:17:16 +0000 (10:47 +0530)
committersaerome.kim <saerome.kim@samsung.com>
Tue, 20 Aug 2019 09:34:47 +0000 (18:34 +0900)
Change-Id: Ia3a477355b5d6e1de2b9dcc57d95a3bce5b68c5e
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
packaging/ua-manager.spec
ua-daemon/data/ua_db.sql
ua-daemon/src/ua-manager-db.c
ua-daemon/src/ua-manager-device-db.c

index f28114d..b0028aa 100644 (file)
@@ -1,6 +1,6 @@
 Name:       ua-manager
 Summary:    User awareness manager
-Version:    0.6.6
+Version:    0.6.7
 Release:    1
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
index a92a227..70261cd 100644 (file)
@@ -23,6 +23,7 @@ CREATE TABLE IF NOT EXISTS devices (
   service_id TEXT,
   purpose TEXT,
   duid TEXT,
+  device_icon TEXT,
   FOREIGN KEY(user_id) REFERENCES userdata(user_id),
   PRIMARY KEY(device_id, tech_type, address)
 );
index 01235a2..e9bb6a3 100644 (file)
@@ -50,6 +50,7 @@
        "service_id TEXT, " \
        "purpose TEXT, " \
        "duid TEXT, " \
+       "device_icon TEXT, " \
        "FOREIGN KEY(user_id) REFERENCES userdata(user_id), " \
        "PRIMARY KEY(device_id, tech_type, address) " \
        "); "
index 1e09491..a85b0b7 100644 (file)
 
 #define SELECT_ALL_DEVICES "SELECT device_id, tech_type, address, " \
        "ip_address, timestamp, presence_state, os_type, " \
-       "user_id, discriminant, service_id, purpose, duid FROM devices"
+       "user_id, discriminant, service_id, purpose, duid, device_icon FROM devices"
 
 #define SELECT_DEVICE "SELECT device_id, tech_type, address, " \
        "ip_address, timestamp, presence_state, os_type, " \
-       "user_id, discriminant, service_id, purpose, duid FROM devices " \
+       "user_id, discriminant, service_id, purpose, duid, device_icon FROM devices " \
        "WHERE device_id = ? AND tech_type = ? AND address = ?"
 
 #define SELECT_DEVICE_NUMBER "SELECT device_number FROM devices " \
@@ -41,8 +41,8 @@
 #define INSERT_DEVICE "insert into devices " \
        "(device_id, tech_type, address, ip_address, timestamp, " \
        "presence_state, os_type, user_id, discriminant, service_id, " \
-       "purpose, duid, device_number)" \
-       "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
+       "purpose, duid, device_icon, device_number)" \
+       "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
 
 #define UPDATE_TIMESTAMP "UPDATE devices " \
        "SET timestamp = ? WHERE device_id = ? AND tech_type = ? AND address = ?"
@@ -55,7 +55,7 @@
 
 #define UPDATE_DEVICE "UPDATE devices " \
        "SET (os_type, discriminant, ip_address, service_id, " \
-       "purpose, duid) = (?, ?, ?, ?, ?, ?) " \
+       "purpose, duid, device_icon) = (?, ?, ?, ?, ?, ?, ?) " \
        "WHERE device_id = ? AND tech_type = ? AND address = ?"
 
 #define DELETE_ALL_DEVICES "delete from devices "
@@ -440,11 +440,13 @@ int _ua_device_db_update_device_device(char *device_id, int tech_type,
                error_code, handle_error);
        DB_ACTION(sqlite3_bind_text(stmt, 6, payload.duid, UAM_BLE_PAYLOAD_DUID_LEN + 1, SQLITE_TRANSIENT),
                error_code, handle_error);
-       DB_ACTION(sqlite3_bind_text(stmt, 7, device_id, -1, SQLITE_TRANSIENT),
+       DB_ACTION(sqlite3_bind_text(stmt, 7, &(payload.device_icon), 1, SQLITE_TRANSIENT),
                error_code, handle_error);
-       DB_ACTION(sqlite3_bind_int(stmt, 8, tech_type),
+       DB_ACTION(sqlite3_bind_text(stmt, 8, device_id, -1, SQLITE_TRANSIENT),
                error_code, handle_error);
-       DB_ACTION(sqlite3_bind_text(stmt, 9, address, -1, SQLITE_TRANSIENT),
+       DB_ACTION(sqlite3_bind_int(stmt, 9, tech_type),
+               error_code, handle_error);
+       DB_ACTION(sqlite3_bind_text(stmt, 10, address, -1, SQLITE_TRANSIENT),
                error_code, handle_error);
 
        if (sqlite3_step(stmt) != SQLITE_DONE) {
@@ -500,7 +502,9 @@ int _ua_device_db_insert_device_info(int user_id,
                error_code, handle_error);
        DB_ACTION(sqlite3_bind_text(stmt, 12, dev_info->payload.duid, UAM_BLE_PAYLOAD_DUID_LEN + 1, SQLITE_TRANSIENT),
                error_code, handle_error);
-       DB_ACTION(sqlite3_bind_int(stmt, 13, max_device_number + 1),
+       DB_ACTION(sqlite3_bind_text(stmt, 13, &(dev_info->payload.device_icon), 1, SQLITE_TRANSIENT),
+               error_code, handle_error);
+       DB_ACTION(sqlite3_bind_int(stmt, 14, max_device_number + 1),
                error_code, handle_error);
 
        if (sqlite3_step(stmt) != SQLITE_DONE) {
@@ -592,6 +596,7 @@ int _ua_device_db_get_device(char *device_id, int tech_type, char *address,
                if ((char*)sqlite3_column_text(stmt, 11))
                        memcpy(info->dev_info.payload.duid, (char *)sqlite3_column_text(stmt, 11),
                                UAM_BLE_PAYLOAD_DUID_LEN);
+               info->dev_info.payload.device_icon = *(char *)sqlite3_column_text(stmt, 12);
 
                UAM_INFO("%s-%d-%s-%s-%ld-%d-%d-%d-%d-0x%2.2X",
                        info->dev_info.device_id,
@@ -690,6 +695,7 @@ GSList *_ua_device_db_get_all_devices(void)
                        if ((char*)sqlite3_column_text(stmt, 11))
                                memcpy(info->dev_info.payload.duid, (char *)sqlite3_column_text(stmt, 11),
                                        UAM_BLE_PAYLOAD_DUID_LEN);
+                       info->dev_info.payload.device_icon = *(char *)sqlite3_column_text(stmt, 12);
 
                        UAM_INFO("%s-%d-%s-%s-%ld-%d-%d-%d-%d-0x%2.2X",
                                info->dev_info.device_id,