From 566e8802a0015a696e75d9c828ea94823f138c7c Mon Sep 17 00:00:00 2001 From: Lomtev Dmytro Date: Thu, 31 Aug 2017 13:48:24 +0300 Subject: [PATCH] parentUuid field added to the device info structure. --- tv-widget/proxy/inc/device.h | 19 +++++++++++++++++-- tv-widget/proxy/inc/network/nm_types.h | 1 + tv-widget/proxy/src/network/network_manager.cpp | 7 ++++++- tv-widget/proxy/src/utils/json_utils.cpp | 1 + .../proxy/ut/src/web_view_test/web_view_tests.cpp | 10 +++++----- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/tv-widget/proxy/inc/device.h b/tv-widget/proxy/inc/device.h index f07f3c1..710fde9 100644 --- a/tv-widget/proxy/inc/device.h +++ b/tv-widget/proxy/inc/device.h @@ -21,13 +21,17 @@ namespace iotswsec class Device { public: - Device(const std::string& id = std::string(), const std::string& name = std::string(), + Device(const std::string& id = std::string(), + const std::string& name = std::string(), const std::string& type = std::string(), - const std::string& description = std::string(), int status = 0): + const std::string& description = std::string(), + const std::string& parentUuid = std::string(), + int status = 0): m_id(id), m_name(name), m_type(type), m_description(description), + m_parentUuid(parentUuid), m_status(status) {} @@ -66,6 +70,16 @@ public: return m_type; } + void SetParentUuid(const std::string& parentUuid) + { + m_parentUuid = parentUuid; + } + + const std::string& GetParentUuid() const + { + return m_parentUuid; + } + void SetType(const std::string& type) { m_type = type; @@ -86,6 +100,7 @@ private: std::string m_name; std::string m_type; std::string m_description; + std::string m_parentUuid; int m_status; }; diff --git a/tv-widget/proxy/inc/network/nm_types.h b/tv-widget/proxy/inc/network/nm_types.h index 2ced064..af0dafd 100644 --- a/tv-widget/proxy/inc/network/nm_types.h +++ b/tv-widget/proxy/inc/network/nm_types.h @@ -76,6 +76,7 @@ typedef struct char* model; char* type; DeviceState state; + char* parent; } NM_DeviceInfo; typedef enum { diff --git a/tv-widget/proxy/src/network/network_manager.cpp b/tv-widget/proxy/src/network/network_manager.cpp index 9a81e4c..965fd2a 100644 --- a/tv-widget/proxy/src/network/network_manager.cpp +++ b/tv-widget/proxy/src/network/network_manager.cpp @@ -415,7 +415,12 @@ DevicePtr NetworkManager::ToDevice(const NM_DeviceInfo* device) target->SetType(device->type); } - target->SetStatus(std::stoi(std::to_string(device->state))); + if (device->parent) + { + target->SetParentUuid(device->parent); + } + + target->SetStatus(static_cast(device->state)); LOG_DBG("END"); diff --git a/tv-widget/proxy/src/utils/json_utils.cpp b/tv-widget/proxy/src/utils/json_utils.cpp index d263683..b1ecd46 100644 --- a/tv-widget/proxy/src/utils/json_utils.cpp +++ b/tv-widget/proxy/src/utils/json_utils.cpp @@ -23,6 +23,7 @@ JSONNode ToJson(const DevicePtr& device) json.push_back(JSONNode("type", device->GetType())); json.push_back(JSONNode("status", device->GetStatus())); json.push_back(JSONNode("description", device->GetDescription())); + json.push_back(JSONNode("parentUuid", device->GetParentUuid())); return json; } diff --git a/tv-widget/proxy/ut/src/web_view_test/web_view_tests.cpp b/tv-widget/proxy/ut/src/web_view_test/web_view_tests.cpp index 95da401..e8a2d06 100644 --- a/tv-widget/proxy/ut/src/web_view_test/web_view_tests.cpp +++ b/tv-widget/proxy/ut/src/web_view_test/web_view_tests.cpp @@ -53,16 +53,16 @@ public: ErrorCode GetOwnedDeviceList(DeviceList& deviceList) override { - deviceList = {std::make_shared("123456789", "My TV", "smart-tv", "TV device", 0), - std::make_shared("1234567890", "My Smartphone", "smartphone", "Smartphone device", 1)}; + deviceList = {std::make_shared("123456789", "My TV", "smart-tv", "TV device", "", 0), + std::make_shared("1234567890", "My Smartphone", "smartphone", "Smartphone device", "", 1)}; return ErrorCode::Success; } ErrorCode GetUnownedDeviceList(DeviceList& deviceList) override { - deviceList = {std::make_shared("123456789", "My TV", "smart-tv", "TV device", 0), - std::make_shared("1234567890", "My Smartphone", "smartphone", "Smartphone device", 1)}; + deviceList = {std::make_shared("123456789", "My TV", "smart-tv", "TV device", "", 0), + std::make_shared("1234567890", "My Smartphone", "smartphone", "Smartphone device", "", 1)}; return ErrorCode::Success; } @@ -175,7 +175,7 @@ public: ErrorCode GetDeviceInfo(const std::string& deviceId, DevicePtr& deviceInfo) override { - deviceInfo = std::make_shared(deviceId, "My TV", "smart-tv", "TV device", 0); + deviceInfo = std::make_shared(deviceId, "My TV", "smart-tv", "TV device", "", 0); return ErrorCode::Success; } -- 2.7.4