Add more device info (#23)
author연정현/Tizen Platform Lab(SR)/Staff Engineer/삼성전자 <jungh.yeon@samsung.com>
Wed, 4 Jul 2018 05:47:46 +0000 (14:47 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Wed, 4 Jul 2018 05:47:46 +0000 (14:47 +0900)
* Add more device info APIs

Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
* Fix to clone additional device info

Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
* Fix db schema for unit test

Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/client/client.cc
src/client/include/capmgr.h
src/unit_tests/sql_test/testdb.sql

index 2fff39053ad77fd2474cc414b89d3b65af71a140..b51bf278f5cc9b1b13da97725146978b3b5ef3f5 100644 (file)
@@ -26,6 +26,8 @@ struct capmgr_device_s {
   std::string profile;
   std::string address;
   std::string uuid;
+  std::string sw_version;
+  std::string platform_version;
 };
 
 struct capmgr_app_control_s {
@@ -46,7 +48,8 @@ API int capmgr_device_foreach_devices(capmgr_device_foreach_cb cb,
       new capmgr::SQLiteConnection(kDBPath));
 
   const char kQueryForeachDevices[] =
-      "SELECT name, profile, address, uuid FROM devices";
+      "SELECT name, profile, address, uuid, sw_version, platform_version " \
+      "FROM devices";
   std::shared_ptr<capmgr::SQLStatement> stmt = sql_conn->PrepareStatement(
       kQueryForeachDevices);
   while (stmt->Step() == capmgr::SQLStatement::StepResult::ROW) {
@@ -55,6 +58,8 @@ API int capmgr_device_foreach_devices(capmgr_device_foreach_cb cb,
     dev.profile = stmt->GetColumnString(1);
     dev.address = stmt->GetColumnString(2);
     dev.uuid = stmt->GetColumnString(3);
+    dev.sw_version = stmt->GetColumnString(4);
+    dev.platform_version = stmt->GetColumnString(5);
     if (cb(&dev, user_data))
       break;
   }
@@ -74,6 +79,8 @@ API int capmgr_device_clone(const capmgr_device_h device,
     clone->profile = device->profile;
     clone->address = device->address;
     clone->uuid = device->uuid;
+    clone->sw_version = device->sw_version;
+    clone->platform_version = device->platform_version;
 
     *device_clone = clone;
   } catch (const std::bad_alloc& e) {
@@ -137,6 +144,30 @@ API int capmgr_device_get_uuid(capmgr_device_h device, char** uuid) {
   return CAPMGR_ERROR_NONE;
 }
 
+API int capmgr_device_get_sw_version(capmgr_device_h device,
+    char** sw_version) {
+  if (!device || !sw_version)
+    return CAPMGR_ERROR_INVALID_PARAMETER;
+
+  *sw_version = strdup(device->sw_version.c_str());
+  if (*sw_version == nullptr)
+    return CAPMGR_ERROR_OUT_OF_MEMORY;
+
+  return CAPMGR_ERROR_NONE;
+}
+
+API int capmgr_device_get_platform_version(capmgr_device_h device,
+    char** platform_version) {
+  if (!device || !platform_version)
+    return CAPMGR_ERROR_INVALID_PARAMETER;
+
+  *platform_version = strdup(device->platform_version.c_str());
+  if (*platform_version == nullptr)
+    return CAPMGR_ERROR_OUT_OF_MEMORY;
+
+  return CAPMGR_ERROR_NONE;
+}
+
 API int capmgr_app_control_create(capmgr_app_control_h* app_control) {
   if (!app_control)
     return CAPMGR_ERROR_INVALID_PARAMETER;
index 92dc8bfe15607847ca2db07689614d50789d8982..01643e8fb3cadff27ccd9d6e0fd960a8de90e027 100644 (file)
@@ -72,6 +72,17 @@ int capmgr_device_get_address(capmgr_device_h device, char** address);
  */
 int capmgr_device_get_uuid(capmgr_device_h device, char** uuid);
 
+/**
+ * @brief
+ */
+int capmgr_device_get_sw_version(capmgr_device_h device, char** sw_version);
+
+/**
+ * @brief
+ */
+int capmgr_device_get_platform_version(capmgr_device_h device,
+    char** platform_version);
+
 /**
  * @brief
  */
index 5fc2b3c06b9bcc3b2538380d54f644720b8dc239..32312d8bed8879a6db0861860158a1bc5cd5ee7a 100644 (file)
@@ -5,11 +5,13 @@ CREATE TABLE IF NOT EXISTS capability (
   PRIMARY KEY (name, appid)
 );
 
-CREATE TABLE IF NOT EXISTS device (
+CREATE TABLE IF NOT EXISTS devices (
   name TEXT NOT NULL,
   profile TEXT,
   address TEXT,
   uuid TEXT,
+  sw_version TEXT,
+  platform_version TEXT,
   PRIMARY KEY (uuid)
 );