diff --git a/.github/workflows/L1-tests.yml b/.github/workflows/L1-tests.yml index df7ea30343..a292106576 100755 --- a/.github/workflows/L1-tests.yml +++ b/.github/workflows/L1-tests.yml @@ -255,6 +255,7 @@ jobs: -DHAS_API_SYSTEM -DHAS_API_POWERSTATE -DHAS_RBUS + -DDISABLE_SECURITY_TOKEN -DENABLE_DEVICE_MANUFACTURER_INFO" -DCOMCAST_CONFIG=OFF -DCMAKE_DISABLE_FIND_PACKAGE_DS=ON diff --git a/.github/workflows/L2-CloudStore.yml b/.github/workflows/L2-CloudStore.yml index 4f76c4b7fd..33ab72540e 100644 --- a/.github/workflows/L2-CloudStore.yml +++ b/.github/workflows/L2-CloudStore.yml @@ -37,4 +37,4 @@ jobs: # Usage: # PATH=${PWD}/install/bin:${PATH} LD_LIBRARY_PATH=${PWD}/install/lib:${LD_LIBRARY_PATH} valgrind --tool=memcheck --log-file=valgrind_log --leak-check=yes --show-reachable=yes --track-fds=yes --fair-sched=try Thunder -f -c ${PWD}/install/etc/Thunder/config.json # (to stop press q & enter) -# curl -d '{"jsonrpc":"2.0","id":0,"method":"org.rdk.CloudStore.setValue","params":{"namespace":"test","key":"key1","value":"1","ttl":100}}' http://localhost:55555/jsonrpc +# curl -d '{"jsonrpc":"2.0","id":0,"method":"org.rdk.CloudStore.setValue","params":{"scope":"account","namespace":"test","key":"key1","value":"1","ttl":100}}' http://localhost:55555/jsonrpc diff --git a/.github/workflows/L2-tests-R4-4-1.yml b/.github/workflows/L2-tests-R4-4-1.yml index 884845c8e1..917e20f705 100755 --- a/.github/workflows/L2-tests-R4-4-1.yml +++ b/.github/workflows/L2-tests-R4-4-1.yml @@ -60,6 +60,11 @@ jobs: ninja -C build sudo ninja -C build install + - name: Checkout rdkservices + uses: actions/checkout@v3 + with: + path: rdkservices + - name: Checkout Thunder uses: actions/checkout@v3 with: @@ -67,13 +72,19 @@ jobs: path: Thunder ref: ${{env.THUNDER_REF}} + - name: Apply patches Thunder + run: | + cd ${{github.workspace}}/Thunder + patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/Use_Legact_Alt_Based_On_ThunderTools_R4.4.3.patch + cd - + - name: Checkout ThunderTools if: steps.cache.outputs.cache-hit != 'true' uses: actions/checkout@v3 with: repository: rdkcentral/ThunderTools path: ThunderTools - ref: ${{env.THUNDER_REF}} + ref: R4.4.3 - name: Build ThunderTools if: steps.cache.outputs.cache-hit != 'true' @@ -90,11 +101,6 @@ jobs: && cmake --install build/ThunderTools - - name: Checkout rdkservices - uses: actions/checkout@v3 - with: - path: rdkservices - - name: Checkout rdkservices run: | cd ${{github.workspace}}/rdkservices @@ -138,6 +144,7 @@ jobs: patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/0007-RDK-IDeviceInfo-Changes.patch patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/0001-RDK-45037-Secure-Storage-Thunder-Plugin.patch patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/RDKV-48604-User-Settings-Thunder-Plugin.patch + patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/Use_Legact_Alt_In_ThunderInterfaces_Based_On_ThunderTools_R4.4.3.patch cd .. - name: Build ThunderInterfaces @@ -247,6 +254,7 @@ jobs: -include ${{github.workspace}}/rdkservices/Tests/mocks/pkg.h -Werror -Wall -Wunused-variable -Wno-deprecated-declarations -Wno-error=format= -DUSE_IARMBUS + -DDISABLE_SECURITY_TOKEN -DENABLE_THERMAL_PROTECTION" -DPLUGIN_PERSISTENTSTORE_PATH="/tmp/secure/persistent/rdkservicestore" -DPLUGIN_PERSISTENTSTORE_LEGACYPATH="/tmp/persistent/rdkservicestore" diff --git a/.github/workflows/L2-tests.yml b/.github/workflows/L2-tests.yml index cfbf0a70e2..1fe3e0227c 100755 --- a/.github/workflows/L2-tests.yml +++ b/.github/workflows/L2-tests.yml @@ -220,6 +220,7 @@ jobs: -include ${{github.workspace}}/rdkservices/Tests/mocks/pkg.h -Wall -Werror -Wno-error=format= -DUSE_IARMBUS + -DDISABLE_SECURITY_TOKEN -DENABLE_THERMAL_PROTECTION" -DCOMCAST_CONFIG=OFF -DCMAKE_DISABLE_FIND_PACKAGE_DS=ON diff --git a/Bluetooth/Bluetooth.cpp b/Bluetooth/Bluetooth.cpp index 37e454bedf..9052dceca1 100644 --- a/Bluetooth/Bluetooth.cpp +++ b/Bluetooth/Bluetooth.cpp @@ -788,15 +788,15 @@ namespace WPEFramework lstBtrMgrEvtRsp.m_deviceHandle = deviceID; - if (eventType.compare(EVT_PAIRING_REQUEST)) { + if (eventType == EVT_PAIRING_REQUEST) { lstBtrMgrEvtRsp.m_eventType = BTRMGR_EVENT_RECEIVED_EXTERNAL_PAIR_REQUEST; lstBtrMgrEvtRsp.m_eventResp = Utils::String::equal(respValue, "ACCEPTED") ? 1 : 0; } - else if (eventType.compare(EVT_CONNECTION_REQUEST)) { + else if (eventType == EVT_CONNECTION_REQUEST) { lstBtrMgrEvtRsp.m_eventType = BTRMGR_EVENT_RECEIVED_EXTERNAL_CONNECT_REQUEST; lstBtrMgrEvtRsp.m_eventResp = Utils::String::equal(respValue, "ACCEPTED") ? 1 : 0; } - else if (eventType.compare(EVT_PLAYBACK_REQUEST)) { + else if (eventType == EVT_PLAYBACK_REQUEST) { lstBtrMgrEvtRsp.m_eventType = BTRMGR_EVENT_RECEIVED_EXTERNAL_PLAYBACK_REQUEST; lstBtrMgrEvtRsp.m_eventResp = Utils::String::equal(respValue, "ACCEPTED") ? 1 : 0; } diff --git a/CloudStore/Module.h b/CloudStore/Module.h index 4901b08640..7892d8a47b 100644 --- a/CloudStore/Module.h +++ b/CloudStore/Module.h @@ -32,6 +32,14 @@ #define URI_ENV "CLOUDSTORE_URI" #define IARM_INIT_NAME "Thunder_Plugins" #define URI_RFC "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.CloudStore.Uri" +#define PARTNER_ID_FILENAME "/opt/www/authService/partnerId3.dat" +#define ACCOUNT_ID_FILENAME "/opt/www/authService/said.dat" +#define DEVICE_ID_FILENAME "/opt/www/authService/xdeviceid.dat" +#define SECURITY_AGENT_FILENAME "/tmp/SecurityAgent/token" +#define IARM_TIMEOUT 1000 +#define COM_RPC_TIMEOUT 1000 +#define JSON_RPC_TIMEOUT 2000 +#define GRPC_TIMEOUT 3000 #undef EXTERNAL #define EXTERNAL diff --git a/CloudStore/grpc/Store2.h b/CloudStore/grpc/Store2.h index bf8d862e23..e007bd9226 100644 --- a/CloudStore/grpc/Store2.h +++ b/CloudStore/grpc/Store2.h @@ -21,6 +21,7 @@ #include "../Module.h" #include "secure_storage.grpc.pb.h" +#include #include #include #ifdef WITH_SYSMGR @@ -33,6 +34,35 @@ namespace Plugin { namespace Grpc { class Store2 : public Exchange::IStore2 { + private: + class Job : public Core::IDispatch { + public: + Job(Store2* parent, const ScopeType scope, const string& ns, const string& key, const string& value) + : _parent(parent) + , _scope(scope) + , _ns(ns) + , _key(key) + , _value(value) + { + _parent->AddRef(); + } + ~Job() override + { + _parent->Release(); + } + void Dispatch() override + { + _parent->OnValueChanged(_scope, _ns, _key, _value); + } + + private: + Store2* _parent; + const ScopeType _scope; + const string _ns; + const string _key; + const string _value; + }; + private: Store2(const Store2&) = delete; Store2& operator=(const Store2&) = delete; @@ -45,6 +75,7 @@ namespace Plugin { Store2(const string& uri) : IStore2() , _uri(uri) + , _authorization((_uri.find("localhost") == string::npos) && (_uri.find("0.0.0.0") == string::npos)) { Open(); } @@ -54,7 +85,7 @@ namespace Plugin { void Open() { std::shared_ptr creds; - if ((_uri.find("localhost") == string::npos) && (_uri.find("0.0.0.0") == string::npos)) { + if (_authorization) { creds = grpc::SslCredentials(grpc::SslCredentialsOptions()); } else { creds = grpc::InsecureChannelCredentials(); @@ -62,61 +93,107 @@ namespace Plugin { _stub = ::distp::gateway::secure_storage::v1::SecureStorageService::NewStub( grpc::CreateChannel(_uri, creds)); } - static bool IsTimeSynced() + + private: + bool IsTimeSynced() const { #ifdef WITH_SYSMGR + // Get actual state, as it may change at any time... IARM_Bus_Init(IARM_INIT_NAME); IARM_Bus_Connect(); IARM_Bus_SYSMgr_GetSystemStates_Param_t param; - if ((IARM_Bus_Call(IARM_BUS_SYSMGR_NAME, IARM_BUS_SYSMGR_API_GetSystemStates, ¶m, sizeof(param)) != IARM_RESULT_SUCCESS) + if ((IARM_Bus_Call_with_IPCTimeout( + IARM_BUS_SYSMGR_NAME, + IARM_BUS_SYSMGR_API_GetSystemStates, + ¶m, + sizeof(param), + IARM_TIMEOUT) // Timeout + != IARM_RESULT_SUCCESS) || !param.time_source.state) { return false; } #endif return true; } - static string ExecuteCmd(const char* cmd) + string GetSecurityToken() const { + // Get actual token, as it may change at any time... string result; - auto pipe = popen(cmd, "r"); - if (pipe != nullptr) { - char buffer[128]; - while (fgets(buffer, sizeof buffer, pipe) != nullptr) { - result += buffer; + + const char* endpoint = ::getenv(_T("SECURITYAGENT_PATH")); + if (endpoint == nullptr) { + endpoint = SECURITY_AGENT_FILENAME; + } + auto engine = Core::ProxyType>::Create(); + auto client = Core::ProxyType::Create( + Core::NodeId(endpoint), + Core::ProxyType(engine)); + + auto interface = client->Open( + _T("SecurityAgent"), + static_cast(~0), + COM_RPC_TIMEOUT); // Timeout + if (interface != nullptr) { + string payload = _T("http://localhost"); + // If main process is out of threads, this can time out, and IPC will mess up... + auto error = interface->CreateToken( + static_cast(payload.length()), + reinterpret_cast(payload.c_str()), + result); + if (error != Core::ERROR_NONE) { + TRACE(Trace::Error, (_T("security token error %d"), error)); } - pclose(pipe); - result.erase(result.find_last_not_of(" \n\r\t") + 1); + interface->Release(); } + return result; } string GetToken() const { - // TODO remove this - return ExecuteCmd("curl -H \"Authorization: Bearer `WPEFrameworkSecurityUtility 2>/dev/null | cut -d '\"' -f 4`\" -s -d '{\"jsonrpc\":\"2.0\",\"id\":0,\"method\":\"org.rdk.AuthService.getServiceAccessToken\"}' http://127.0.0.1:9998/jsonrpc | cut -d '\"' -f 14"); - } - static string ReadFromFile(const char* filename) - { + // Get actual token, as it may change at any time... string result; - Core::File file(filename); - if (file.Open(true)) { - uint8_t buffer[1024]; - auto size = file.Read(buffer, 1024); - result.assign(reinterpret_cast(buffer), size); - result.erase(result.find_last_not_of(" \n\r\t") + 1); + + Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T("127.0.0.1:9998"))); + auto link = Core::ProxyType>::Create( + _T("org.rdk.AuthService"), _T(""), false, "token=" + GetSecurityToken()); + + JsonObject json; + auto status = link->Invoke( + JSON_RPC_TIMEOUT, // Timeout + _T("getServiceAccessToken"), + JsonObject(), + json); + if (status == Core::ERROR_NONE) { + result = json[_T("token")].String(); + } else { + TRACE(Trace::Error, (_T("sat status %d"), status)); } + return result; } string GetPartnerId() const { - return ReadFromFile("/opt/www/authService/partnerId3.dat"); + // Get actual id, as it may change at any time... + std::ifstream input(PARTNER_ID_FILENAME); + string line; + getline(input, line); + return line; } string GetAccountId() const { - return ReadFromFile("/opt/www/authService/said.dat"); + // Get actual id, as it may change at any time... + std::ifstream input(ACCOUNT_ID_FILENAME); + string line; + getline(input, line); + return line; } string GetDeviceId() const { - return ReadFromFile("/opt/www/authService/xdeviceid.dat"); + // Get actual id, as it may change at any time... + std::ifstream input(DEVICE_ID_FILENAME); + string line; + getline(input, line); + return line; } public: @@ -150,14 +227,13 @@ namespace Plugin { uint32_t SetValue(const ScopeType scope, const string& ns, const string& key, const string& value, const uint32_t ttl) override { - ASSERT(scope == ScopeType::ACCOUNT); - uint32_t result; grpc::ClientContext context; - if ((_uri.find("localhost") == string::npos) && (_uri.find("0.0.0.0") == string::npos)) { + if (_authorization) { context.AddMetadata("authorization", "Bearer " + GetToken()); } + context.set_deadline(std::chrono::system_clock::now() + std::chrono::milliseconds(GRPC_TIMEOUT)); // Timeout ::distp::gateway::secure_storage::v1::UpdateValueRequest request; request.set_partner_id(GetPartnerId()); request.set_account_id(GetAccountId()); @@ -172,14 +248,20 @@ namespace Plugin { auto k = new ::distp::gateway::secure_storage::v1::Key(); k->set_app_id(ns); k->set_key(key); - k->set_scope(::distp::gateway::secure_storage::v1::Scope::SCOPE_ACCOUNT); + k->set_scope(scope == ScopeType::ACCOUNT + ? ::distp::gateway::secure_storage::v1::Scope::SCOPE_ACCOUNT + : (scope == ScopeType::DEVICE + ? ::distp::gateway::secure_storage::v1::Scope::SCOPE_DEVICE + : ::distp::gateway::secure_storage::v1::Scope::SCOPE_UNSPECIFIED)); v->set_allocated_key(k); request.set_allocated_value(v); ::distp::gateway::secure_storage::v1::UpdateValueResponse response; auto status = _stub->UpdateValue(&context, request, &response); if (status.ok()) { - OnValueChanged(ns, key, value); + Core::IWorkerPool::Instance().Submit(Core::ProxyType( + Core::ProxyType::Create(this, scope, ns, key, value))); // Decouple notification + result = Core::ERROR_NONE; } else { OnError(__FUNCTION__, status); @@ -194,14 +276,13 @@ namespace Plugin { } uint32_t GetValue(const ScopeType scope, const string& ns, const string& key, string& value, uint32_t& ttl) override { - ASSERT(scope == ScopeType::ACCOUNT); - uint32_t result; grpc::ClientContext context; - if ((_uri.find("localhost") == string::npos) && (_uri.find("0.0.0.0") == string::npos)) { + if (_authorization) { context.AddMetadata("authorization", "Bearer " + GetToken()); } + context.set_deadline(std::chrono::system_clock::now() + std::chrono::milliseconds(GRPC_TIMEOUT)); // Timeout ::distp::gateway::secure_storage::v1::GetValueRequest request; request.set_partner_id(GetPartnerId()); request.set_account_id(GetAccountId()); @@ -209,7 +290,11 @@ namespace Plugin { auto k = new ::distp::gateway::secure_storage::v1::Key(); k->set_app_id(ns); k->set_key(key); - k->set_scope(::distp::gateway::secure_storage::v1::Scope::SCOPE_ACCOUNT); + k->set_scope(scope == ScopeType::ACCOUNT + ? ::distp::gateway::secure_storage::v1::Scope::SCOPE_ACCOUNT + : (scope == ScopeType::DEVICE + ? ::distp::gateway::secure_storage::v1::Scope::SCOPE_DEVICE + : ::distp::gateway::secure_storage::v1::Scope::SCOPE_UNSPECIFIED)); request.set_allocated_key(k); ::distp::gateway::secure_storage::v1::GetValueResponse response; auto status = _stub->GetValue(&context, request, &response); @@ -252,14 +337,13 @@ namespace Plugin { } uint32_t DeleteKey(const ScopeType scope, const string& ns, const string& key) override { - ASSERT(scope == ScopeType::ACCOUNT); - uint32_t result; grpc::ClientContext context; - if ((_uri.find("localhost") == string::npos) && (_uri.find("0.0.0.0") == string::npos)) { + if (_authorization) { context.AddMetadata("authorization", "Bearer " + GetToken()); } + context.set_deadline(std::chrono::system_clock::now() + std::chrono::milliseconds(GRPC_TIMEOUT)); // Timeout ::distp::gateway::secure_storage::v1::DeleteValueRequest request; request.set_partner_id(GetPartnerId()); request.set_account_id(GetAccountId()); @@ -267,7 +351,11 @@ namespace Plugin { auto k = new ::distp::gateway::secure_storage::v1::Key(); k->set_app_id(ns); k->set_key(key); - k->set_scope(::distp::gateway::secure_storage::v1::Scope::SCOPE_ACCOUNT); + k->set_scope(scope == ScopeType::ACCOUNT + ? ::distp::gateway::secure_storage::v1::Scope::SCOPE_ACCOUNT + : (scope == ScopeType::DEVICE + ? ::distp::gateway::secure_storage::v1::Scope::SCOPE_DEVICE + : ::distp::gateway::secure_storage::v1::Scope::SCOPE_UNSPECIFIED)); request.set_allocated_key(k); ::distp::gateway::secure_storage::v1::DeleteValueResponse response; auto status = _stub->DeleteValue(&context, request, &response); @@ -287,20 +375,23 @@ namespace Plugin { } uint32_t DeleteNamespace(const ScopeType scope, const string& ns) override { - ASSERT(scope == ScopeType::ACCOUNT); - uint32_t result; grpc::ClientContext context; - if ((_uri.find("localhost") == string::npos) && (_uri.find("0.0.0.0") == string::npos)) { + if (_authorization) { context.AddMetadata("authorization", "Bearer " + GetToken()); } + context.set_deadline(std::chrono::system_clock::now() + std::chrono::milliseconds(GRPC_TIMEOUT)); // Timeout ::distp::gateway::secure_storage::v1::DeleteAllValuesRequest request; request.set_partner_id(GetPartnerId()); request.set_account_id(GetAccountId()); request.set_device_id(GetDeviceId()); request.set_app_id(ns); - request.set_scope(::distp::gateway::secure_storage::v1::Scope::SCOPE_ACCOUNT); + request.set_scope(scope == ScopeType::ACCOUNT + ? ::distp::gateway::secure_storage::v1::Scope::SCOPE_ACCOUNT + : (scope == ScopeType::DEVICE + ? ::distp::gateway::secure_storage::v1::Scope::SCOPE_DEVICE + : ::distp::gateway::secure_storage::v1::Scope::SCOPE_UNSPECIFIED)); ::distp::gateway::secure_storage::v1::DeleteAllValuesResponse response; auto status = _stub->DeleteAllValues(&context, request, &response); @@ -319,7 +410,7 @@ namespace Plugin { END_INTERFACE_MAP private: - void OnValueChanged(const string& ns, const string& key, const string& value) + void OnValueChanged(const ScopeType scope, const string& ns, const string& key, const string& value) { Core::SafeSyncType lock(_clientLock); @@ -327,7 +418,8 @@ namespace Plugin { index(_clients.begin()); while (index != _clients.end()) { - (*index)->ValueChanged(ScopeType::ACCOUNT, ns, key, value); + // If main process is out of threads, this can time out, and IPC will mess up... + (*index)->ValueChanged(scope, ns, key, value); index++; } } @@ -338,6 +430,7 @@ namespace Plugin { private: const string _uri; + const bool _authorization; std::unique_ptr<::distp::gateway::secure_storage::v1::SecureStorageService::Stub> _stub; std::list _clients; Core::CriticalSection _clientLock; diff --git a/CloudStore/grpc/l0test/Store2Test.cpp b/CloudStore/grpc/l0test/Store2Test.cpp index 7e4a216807..8f23703639 100644 --- a/CloudStore/grpc/l0test/Store2Test.cpp +++ b/CloudStore/grpc/l0test/Store2Test.cpp @@ -4,6 +4,7 @@ #include "../Store2.h" #include "SecureStorageServiceMock.h" #include "Server.h" +#include "WorkerPoolImplementation.h" using ::distp::gateway::secure_storage::v1::DeleteAllValuesRequest; using ::distp::gateway::secure_storage::v1::DeleteAllValuesResponse; @@ -39,13 +40,21 @@ const auto kScope = Scope::SCOPE_ACCOUNT; class AStore2 : public Test { protected: + WPEFramework::Core::ProxyType workerPool; NiceMock service; Server server; WPEFramework::Core::ProxyType store2; AStore2() - : server(kUri, &service) + : workerPool(WPEFramework::Core::ProxyType::Create( + WPEFramework::Core::Thread::DefaultStackSize())) + , server(kUri, &service) , store2(WPEFramework::Core::ProxyType::Create(kUri)) { + WPEFramework::Core::IWorkerPool::Assign(&(*workerPool)); + } + ~AStore2() override + { + WPEFramework::Core::IWorkerPool::Assign(nullptr); } }; diff --git a/CloudStore/grpc/l0test/WorkerPoolImplementation.h b/CloudStore/grpc/l0test/WorkerPoolImplementation.h new file mode 100644 index 0000000000..f782fa5489 --- /dev/null +++ b/CloudStore/grpc/l0test/WorkerPoolImplementation.h @@ -0,0 +1,49 @@ +#pragma once + +#include "../../Module.h" + +class WorkerPoolImplementation + : public WPEFramework::Core::WorkerPool, + public WPEFramework::Core::ThreadPool::ICallback { +private: + class Dispatcher : public WPEFramework::Core::ThreadPool::IDispatcher { + public: + Dispatcher(const Dispatcher&) = delete; + Dispatcher& operator=(const Dispatcher&) = delete; + Dispatcher() = default; + ~Dispatcher() override = default; + + private: + void Initialize() override + { + } + void Deinitialize() override + { + } + void Dispatch(WPEFramework::Core::IDispatch* job) override + { + job->Dispatch(); + } + }; + +public: + WorkerPoolImplementation() = delete; + WorkerPoolImplementation(const WorkerPoolImplementation&) = delete; + WorkerPoolImplementation& operator=(const WorkerPoolImplementation&) = delete; + WorkerPoolImplementation(const uint32_t stackSize) + : WPEFramework::Core::WorkerPool(4 /*threadCount*/, stackSize, 32 /*queueSize*/, &_dispatch, this) + , _dispatch() + { + Run(); + } + ~WorkerPoolImplementation() override + { + Stop(); + } + void Idle() override + { + } + +private: + Dispatcher _dispatch; +}; diff --git a/CloudStore/l0test/ServiceMock.h b/CloudStore/l0test/ServiceMock.h index 63fa33379f..c9efdb8da5 100644 --- a/CloudStore/l0test/ServiceMock.h +++ b/CloudStore/l0test/ServiceMock.h @@ -53,6 +53,7 @@ class ServiceMock : public WPEFramework::PluginHost::IShell, MOCK_METHOD(void, Unregister, (const IShell::ICOMLink::INotification*), (override)); MOCK_METHOD(WPEFramework::RPC::IRemoteConnection*, RemoteConnection, (const uint32_t), (override)); MOCK_METHOD(void*, Instantiate, (const WPEFramework::RPC::Object&, const uint32_t, uint32_t&), (override)); + MOCK_METHOD(WPEFramework::RPC::IStringIterator*, GetLibrarySearchPaths, (const string&), (const, override)); BEGIN_INTERFACE_MAP(ServiceMock) INTERFACE_ENTRY(IShell) INTERFACE_ENTRY(IShell::ICOMLink) diff --git a/PersistentStore/Module.h b/PersistentStore/Module.h index 342536a741..88ac1288c7 100644 --- a/PersistentStore/Module.h +++ b/PersistentStore/Module.h @@ -34,6 +34,8 @@ #define MAXVALUE_ENV "PERSISTENTSTORE_MAXVALUE" #define LIMIT_ENV "PERSISTENTSTORE_LIMIT" #define IARM_INIT_NAME "Thunder_Plugins" +#define IARM_TIMEOUT 1000 +#define SQLITE_TIMEOUT 1000 #undef EXTERNAL #define EXTERNAL diff --git a/PersistentStore/l0test/ServiceMock.h b/PersistentStore/l0test/ServiceMock.h index 63fa33379f..c9efdb8da5 100644 --- a/PersistentStore/l0test/ServiceMock.h +++ b/PersistentStore/l0test/ServiceMock.h @@ -53,6 +53,7 @@ class ServiceMock : public WPEFramework::PluginHost::IShell, MOCK_METHOD(void, Unregister, (const IShell::ICOMLink::INotification*), (override)); MOCK_METHOD(WPEFramework::RPC::IRemoteConnection*, RemoteConnection, (const uint32_t), (override)); MOCK_METHOD(void*, Instantiate, (const WPEFramework::RPC::Object&, const uint32_t, uint32_t&), (override)); + MOCK_METHOD(WPEFramework::RPC::IStringIterator*, GetLibrarySearchPaths, (const string&), (const, override)); BEGIN_INTERFACE_MAP(ServiceMock) INTERFACE_ENTRY(IShell) INTERFACE_ENTRY(IShell::ICOMLink) diff --git a/PersistentStore/l1test/ServiceMock.h b/PersistentStore/l1test/ServiceMock.h index 63fa33379f..c9efdb8da5 100644 --- a/PersistentStore/l1test/ServiceMock.h +++ b/PersistentStore/l1test/ServiceMock.h @@ -53,6 +53,7 @@ class ServiceMock : public WPEFramework::PluginHost::IShell, MOCK_METHOD(void, Unregister, (const IShell::ICOMLink::INotification*), (override)); MOCK_METHOD(WPEFramework::RPC::IRemoteConnection*, RemoteConnection, (const uint32_t), (override)); MOCK_METHOD(void*, Instantiate, (const WPEFramework::RPC::Object&, const uint32_t, uint32_t&), (override)); + MOCK_METHOD(WPEFramework::RPC::IStringIterator*, GetLibrarySearchPaths, (const string&), (const, override)); BEGIN_INTERFACE_MAP(ServiceMock) INTERFACE_ENTRY(IShell) INTERFACE_ENTRY(IShell::ICOMLink) diff --git a/PersistentStore/sqlite/Store2.h b/PersistentStore/sqlite/Store2.h index 1b9b9bbb13..4091f48661 100644 --- a/PersistentStore/sqlite/Store2.h +++ b/PersistentStore/sqlite/Store2.h @@ -36,6 +36,35 @@ namespace Plugin { public Exchange::IStoreCache, public Exchange::IStoreInspector, public Exchange::IStoreLimit { + private: + class Job : public Core::IDispatch { + public: + Job(Store2* parent, const IStore2::ScopeType scope, const string& ns, const string& key, const string& value) + : _parent(parent) + , _scope(scope) + , _ns(ns) + , _key(key) + , _value(value) + { + _parent->AddRef(); + } + ~Job() override + { + _parent->Release(); + } + void Dispatch() override + { + _parent->OnValueChanged(_scope, _ns, _key, _value); + } + + private: + Store2* _parent; + const IStore2::ScopeType _scope; + const string _ns; + const string _key; + const string _value; + }; + private: Store2(const Store2&) = delete; Store2& operator=(const Store2&) = delete; @@ -75,22 +104,59 @@ namespace Plugin { if (rc != SQLITE_OK) { OnError(__FUNCTION__, rc); } + rc = sqlite3_busy_timeout(_data, SQLITE_TIMEOUT); // Timeout + if (rc != SQLITE_OK) { + OnError(__FUNCTION__, rc); + } const std::vector statements = { "pragma foreign_keys = on;", - "pragma busy_timeout = 1000000;", - "create table if not exists namespace (id integer primary key,name text unique);", - "create table if not exists item (ns integer,key text,value text,foreign key(ns) references namespace(id) on delete cascade on update no action,unique(ns,key) on conflict replace);", - "create table if not exists limits (n integer,size integer,foreign key(n) references namespace(id) on delete cascade on update no action,unique(n) on conflict replace);", + "create table if not exists namespace" + " (id integer primary key,name text unique);", + "create table if not exists item" + " (ns integer,key text,value text," + "foreign key(ns) references namespace(id) on delete cascade on update no action," + "unique(ns,key) on conflict replace);", + "create table if not exists limits" + " (n integer,size integer," + "foreign key(n) references namespace(id) on delete cascade on update no action," + "unique(n) on conflict replace);", "alter table item add column ttl integer;", - "create temporary trigger if not exists ns_empty insert on namespace begin select case when length(new.name) = 0 then raise (fail, 'empty') end; end;", - "create temporary trigger if not exists key_empty insert on item begin select case when length(new.key) = 0 then raise (fail, 'empty') end; end;", - "create temporary trigger if not exists ns_maxvalue insert on namespace begin select case when length(new.name) > " + std::to_string(_maxValue) + " then raise (fail, 'max value') end; end;", - "create temporary trigger if not exists key_maxvalue insert on item begin select case when length(new.key) > " + std::to_string(_maxValue) + " then raise (fail, 'max value') end; end;", - "create temporary trigger if not exists value_maxvalue insert on item begin select case when length(new.value) > " + std::to_string(_maxValue) + " then raise (fail, 'max value') end; end;", - "create temporary trigger if not exists ns_maxsize insert on namespace begin select case when (select sum(s) from (select sum(length(key)+length(value)) s from item union all select sum(length(name)) s from namespace union all select length(new.name) s)) > " + std::to_string(_maxSize) + " then raise (fail, 'max size') end; end;", - "create temporary trigger if not exists item_maxsize insert on item begin select case when (select sum(s) from (select sum(length(key)+length(value)) s from item union all select sum(length(name)) s from namespace union all select length(new.key)+length(new.value) s)) > " + std::to_string(_maxSize) + " then raise (fail, 'max size') end; end;", - "create temporary trigger if not exists item_limit_default insert on item begin select case when (select length(new.key)+length(new.value)+sum(length(key)+length(value)) from item where ns = new.ns) > " + std::to_string(_limit) + " then raise (fail, 'limit') end; end;", - "create temporary trigger if not exists item_limit insert on item begin select case when (select size-length(new.key)-length(new.value)-sum(length(key)+length(value)) from limits inner join item on limits.n = item.ns where n = new.ns) < 0 then raise (fail, 'limit') end; end;" + "create temporary trigger if not exists ns_empty insert on namespace" + " begin select case when length(new.name) = 0" + " then raise (fail, 'empty') end; end;", + "create temporary trigger if not exists key_empty insert on item" + " begin select case when length(new.key) = 0" + " then raise (fail, 'empty') end; end;", + "create temporary trigger if not exists ns_maxvalue insert on namespace" + " begin select case when length(new.name) > " + + std::to_string(_maxValue) + " then raise (fail, 'max value') end; end;", + "create temporary trigger if not exists key_maxvalue insert on item" + " begin select case when length(new.key) > " + + std::to_string(_maxValue) + " then raise (fail, 'max value') end; end;", + "create temporary trigger if not exists value_maxvalue insert on item" + " begin select case when length(new.value) > " + + std::to_string(_maxValue) + " then raise (fail, 'max value') end; end;", + "create temporary trigger if not exists ns_maxsize insert on namespace" + " begin select case when" + " (select sum(s) from (select sum(length(key)+length(value)) s from item" + " union all select sum(length(name)) s from namespace" + " union all select length(new.name) s)) > " + + std::to_string(_maxSize) + " then raise (fail, 'max size') end; end;", + "create temporary trigger if not exists item_maxsize insert on item" + " begin select case when" + " (select sum(s) from (select sum(length(key)+length(value)) s from item" + " union all select sum(length(name)) s from namespace" + " union all select length(new.key)+length(new.value) s)) > " + + std::to_string(_maxSize) + " then raise (fail, 'max size') end; end;", + "create temporary trigger if not exists item_limit_default insert on item" + " begin select case when" + " (select length(new.key)+length(new.value)+sum(length(key)+length(value)) from item where ns = new.ns) > " + + std::to_string(_limit) + " then raise (fail, 'limit') end; end;", + "create temporary trigger if not exists item_limit insert on item" + " begin select case when" + " (select size-length(new.key)-length(new.value)-sum(length(key)+length(value)) from limits" + " inner join item on limits.n = item.ns where n = new.ns) < 0" + " then raise (fail, 'limit') end; end;" }; for (auto& sql : statements) { auto rc = sqlite3_exec(_data, sql.c_str(), nullptr, nullptr, nullptr); @@ -106,13 +172,20 @@ namespace Plugin { OnError(__FUNCTION__, rc); } } - static bool IsTimeSynced() + bool IsTimeSynced() const { #ifdef WITH_SYSMGR + // Get actual state, as it may change at any time... IARM_Bus_Init(IARM_INIT_NAME); IARM_Bus_Connect(); IARM_Bus_SYSMgr_GetSystemStates_Param_t param; - if ((IARM_Bus_Call(IARM_BUS_SYSMGR_NAME, IARM_BUS_SYSMGR_API_GetSystemStates, ¶m, sizeof(param)) != IARM_RESULT_SUCCESS) + if ((IARM_Bus_Call_with_IPCTimeout( + IARM_BUS_SYSMGR_NAME, + IARM_BUS_SYSMGR_API_GetSystemStates, + ¶m, + sizeof(param), + IARM_TIMEOUT) // Timeout + != IARM_RESULT_SUCCESS) || !param.time_source.state) { return false; } @@ -185,7 +258,9 @@ namespace Plugin { } if (rc == SQLITE_DONE) { - OnValueChanged(ns, key, value); + Core::IWorkerPool::Instance().Submit(Core::ProxyType( + Core::ProxyType::Create(this, scope, ns, key, value))); // Decouple notification + result = Core::ERROR_NONE; } else { OnError(__FUNCTION__, rc); @@ -489,7 +564,7 @@ namespace Plugin { END_INTERFACE_MAP private: - void OnValueChanged(const string& ns, const string& key, const string& value) + void OnValueChanged(const IStore2::ScopeType scope, const string& ns, const string& key, const string& value) { Core::SafeSyncType lock(_clientLock); @@ -497,7 +572,8 @@ namespace Plugin { index(_clients.begin()); while (index != _clients.end()) { - (*index)->ValueChanged(IStore2::ScopeType::DEVICE, ns, key, value); + // If main process is out of threads, this can time out, and IPC will mess up... + (*index)->ValueChanged(scope, ns, key, value); index++; } } diff --git a/PersistentStore/sqlite/l1test/Store2Test.cpp b/PersistentStore/sqlite/l1test/Store2Test.cpp index 2ee78da6a4..04454ed49e 100644 --- a/PersistentStore/sqlite/l1test/Store2Test.cpp +++ b/PersistentStore/sqlite/l1test/Store2Test.cpp @@ -3,6 +3,7 @@ #include "../Store2.h" #include "Store2NotificationMock.h" +#include "WorkerPoolImplementation.h" using ::testing::_; using ::testing::Eq; @@ -39,10 +40,18 @@ const auto kLimit40 = 40; class AStore2 : public Test { protected: + WPEFramework::Core::ProxyType workerPool; WPEFramework::Core::ProxyType store2; AStore2() - : store2(WPEFramework::Core::ProxyType::Create(kPath, kMaxSize, kMaxValue, kLimit)) + : workerPool(WPEFramework::Core::ProxyType::Create( + WPEFramework::Core::Thread::DefaultStackSize())) + , store2(WPEFramework::Core::ProxyType::Create(kPath, kMaxSize, kMaxValue, kLimit)) { + WPEFramework::Core::IWorkerPool::Assign(&(*workerPool)); + } + ~AStore2() override + { + WPEFramework::Core::IWorkerPool::Assign(nullptr); } }; diff --git a/PersistentStore/sqlite/l1test/WorkerPoolImplementation.h b/PersistentStore/sqlite/l1test/WorkerPoolImplementation.h new file mode 100644 index 0000000000..f782fa5489 --- /dev/null +++ b/PersistentStore/sqlite/l1test/WorkerPoolImplementation.h @@ -0,0 +1,49 @@ +#pragma once + +#include "../../Module.h" + +class WorkerPoolImplementation + : public WPEFramework::Core::WorkerPool, + public WPEFramework::Core::ThreadPool::ICallback { +private: + class Dispatcher : public WPEFramework::Core::ThreadPool::IDispatcher { + public: + Dispatcher(const Dispatcher&) = delete; + Dispatcher& operator=(const Dispatcher&) = delete; + Dispatcher() = default; + ~Dispatcher() override = default; + + private: + void Initialize() override + { + } + void Deinitialize() override + { + } + void Dispatch(WPEFramework::Core::IDispatch* job) override + { + job->Dispatch(); + } + }; + +public: + WorkerPoolImplementation() = delete; + WorkerPoolImplementation(const WorkerPoolImplementation&) = delete; + WorkerPoolImplementation& operator=(const WorkerPoolImplementation&) = delete; + WorkerPoolImplementation(const uint32_t stackSize) + : WPEFramework::Core::WorkerPool(4 /*threadCount*/, stackSize, 32 /*queueSize*/, &_dispatch, this) + , _dispatch() + { + Run(); + } + ~WorkerPoolImplementation() override + { + Stop(); + } + void Idle() override + { + } + +private: + Dispatcher _dispatch; +}; diff --git a/RDKShell/RDKShell.cpp b/RDKShell/RDKShell.cpp index 64743ac705..7460c7984f 100755 --- a/RDKShell/RDKShell.cpp +++ b/RDKShell/RDKShell.cpp @@ -1983,13 +1983,15 @@ namespace WPEFramework { { std::cout << "not launching factory app as conditions not matched\n"; std::cout << "Launch RA not waiting for persistent store\n"; - int32_t status = 0; - std::string callsign("ResidentApp"); + gRdkShellMutex.unlock(); + int32_t status = 0; + std::string callsign("ResidentApp"); JsonObject activateParams; - activateParams.Set("callsign",callsign.c_str()); - JsonObject activateResult; - auto thunderController = getThunderControllerClient(); - status = thunderController->Invoke(RDKSHELL_THUNDER_TIMEOUT, "activate", activateParams, activateResult); + activateParams.Set("callsign",callsign.c_str()); + JsonObject activateResult; + auto thunderController = getThunderControllerClient(); + status = thunderController->Invoke(RDKSHELL_THUNDER_TIMEOUT, "activate", activateParams, activateResult); + gRdkShellMutex.lock(); std::cout << "Bootup Activating ResidentApp from RDKShell without Persistentstore wait with Status:" << status << std::endl; } } @@ -2053,14 +2055,16 @@ namespace WPEFramework { else { std::cout << "Not launching factory app as conditions not matched\n"; - std::cout << "Launch RA after waiting for persistent store\n"; + std::cout << "Launch RA after waiting for persistent store\n"; int32_t status = 0; - std::string callsign("ResidentApp"); + gRdkShellMutex.unlock(); + std::string callsign("ResidentApp"); JsonObject activateParams; - activateParams.Set("callsign",callsign.c_str()); - JsonObject activateResult; - auto thunderController = getThunderControllerClient(); - status = thunderController->Invoke(RDKSHELL_THUNDER_TIMEOUT, "activate", activateParams, activateResult); + activateParams.Set("callsign",callsign.c_str()); + JsonObject activateResult; + auto thunderController = getThunderControllerClient(); + status = thunderController->Invoke(RDKSHELL_THUNDER_TIMEOUT, "activate", activateParams, activateResult); + gRdkShellMutex.lock(); std::cout << "Bootup Activating ResidentApp from RDKShell after Persistentstore wait with Status:" << status << std::endl; } } diff --git a/SystemServices/System.json b/SystemServices/System.json index 4e801f51ef..94e12d7040 100644 --- a/SystemServices/System.json +++ b/SystemServices/System.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "info": { "title": "System API", - "class": "SystemServices", + "class": "org.rdk.System", "description": "The `System` plugin is used to manage various system-level features such as power settings and firmware updates." }, "common": { @@ -1944,6 +1944,35 @@ "success" ] } + }, + "SetPrivacyMode": { + "summary": "Setting Privacy Mode.", + "events": { + "onPrivacyModeChanged" : "Triggered when the Privacy Mode changes." + }, + "params": { + "type": "object", + "properties": { + "privacyMode": { + "summary": "New Privacy Mode", + "type": "string", + "example": "DO_NOT_SHARE" + } + } + }, + "result": { + "summary": "On success null will be returned", + "type": "string", + "example": "null" + } + }, + "getPrivacyMode":{ + "summary": "Getting Privacy Mode", + "result": { + "summary": "Current Privacy Mode", + "type": "string", + "example": "DO_NOT_SHARE" + } } }, "events": { @@ -2275,7 +2304,7 @@ }, "success":{ "summary": "Status information of update whether success or failure", - "type":"bool", + "type":"boolean", "example": "true" } }, @@ -2341,6 +2370,22 @@ ] } }, + "onPrivacyModeChanged": { + "summary": "Triggered after the Privacy Mode changes (see `SetPrivacyMode`)", + "params": { + "type": "object", + "properties": { + "privacyMode":{ + "summary": "Receive Privacy Mode changes", + "type": "string", + "example": "DO_NOT_SHARE" + } + }, + "required": [ + "privacyMode" + ] + } + }, "setFSRFlag":{ "summary": "Set the FSR flag into the emmc raw area.", "result": { diff --git a/SystemServices/SystemServices.cpp b/SystemServices/SystemServices.cpp index 47af4d6357..523dbedfc8 100644 --- a/SystemServices/SystemServices.cpp +++ b/SystemServices/SystemServices.cpp @@ -98,6 +98,8 @@ using namespace std; #define LOG_UPLOAD_STATUS_FAILURE "UPLOAD_FAILURE" #define LOG_UPLOAD_STATUS_ABORTED "UPLOAD_ABORTED" +#define PRIVACY_MODE_FILE "/opt/secure/persistent/System/privacymode.txt" + /** * @struct firmwareUpdate * @brief This structure contains information of firmware update. @@ -493,6 +495,9 @@ namespace WPEFramework { registerMethod("setFSRFlag", &SystemServices::setFSRFlag, this); registerMethod("getFSRFlag", &SystemServices::getFSRFlag, this); + registerMethod("setPrivacyMode", &SystemServices::setPrivacyMode, this); + registerMethod("getPrivacyMode", &SystemServices::getPrivacyMode, this); + } SystemServices::~SystemServices() @@ -3621,8 +3626,10 @@ namespace WPEFramework { if (res == IARM_RESULT_SUCCESS) { if (param.curState == IARM_BUS_PWRMGR_POWERSTATE_ON) currentState = "ON"; - else if ((param.curState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY) || (param.curState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_LIGHT_SLEEP) || (param.curState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP)) + else if ((param.curState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY) || (param.curState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_LIGHT_SLEEP) ) currentState = "STANDBY"; + else if ( param.curState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP) + currentState = "DEEP_SLEEP"; } powerState = currentState; @@ -4721,7 +4728,54 @@ namespace WPEFramework { returnResponse(true); } - + uint32_t SystemServices::setPrivacyMode(const JsonObject& parameters, JsonObject& response) + { + LOGINFOMETHOD(); + + string privacyMode = parameters["privacyMode"].String(); + + if (privacyMode != "SHARE" && privacyMode != "DO_NOT_SHARE") + { + LOGERR("Wrong privacyMode value: '%s'", privacyMode.c_str()); + returnResponse(false); + } + + ofstream optfile; + + optfile.open(PRIVACY_MODE_FILE, ios::out); + if (optfile) + { + optfile << privacyMode; + optfile.close(); + } + + JsonObject params; + params["privacyMode"] = privacyMode; + sendNotify(EVT_ONPRIVACYMODECHANGED, params); + + returnResponse(true); + } + + uint32_t SystemServices::getPrivacyMode(const JsonObject& parameters, JsonObject& response) + { + LOGINFOMETHOD(); + + string privacyMode = ""; + + string optOutStatus; + + getFileContent(PRIVACY_MODE_FILE, privacyMode); + if (privacyMode != "SHARE" && privacyMode != "DO_NOT_SHARE") + { + LOGWARN("Wrong privacyMode value: '%s', returning default", privacyMode.c_str()); + privacyMode = "SHARE"; + } + + response["privacyMode"] = privacyMode; + + returnResponse(true); + } + /*** * @brief : To set the fsr flag into the emmc raw area. * @param1[in] : {"params":{"fsrFlag":} @@ -4776,7 +4830,6 @@ namespace WPEFramework { returnResponse(status); } - } /* namespace Plugin */ } /* namespace WPEFramework */ diff --git a/SystemServices/SystemServices.h b/SystemServices/SystemServices.h index 522ce690df..9bf1c6319b 100644 --- a/SystemServices/SystemServices.h +++ b/SystemServices/SystemServices.h @@ -70,6 +70,7 @@ using std::ofstream; #define EVT_FRIENDLYNAMECHANGED "onFriendlyNameChanged" #define EVT_ONLOGUPLOAD "onLogUpload" #define EVT_ONDEVICEMGTUPDATERECEIVED "onDeviceMgtUpdateReceived" +#define EVT_ONPRIVACYMODECHANGED "onPrivacyModeChanged" #define TERRITORYFILE "/opt/secure/persistent/System/Territory.txt" @@ -301,6 +302,8 @@ namespace WPEFramework { uint32_t getWakeupSrcConfiguration(const JsonObject& parameters, JsonObject& response); uint32_t getPlatformConfiguration(const JsonObject& parameters, PlatformCaps& response); uint32_t getThunderStartReason(const JsonObject& parameters, JsonObject& response); + uint32_t setPrivacyMode(const JsonObject& parameters, JsonObject& response); + uint32_t getPrivacyMode(const JsonObject& parameters, JsonObject& response); uint32_t setFSRFlag(const JsonObject& parameters, JsonObject& response); uint32_t getFSRFlag(const JsonObject& parameters, JsonObject& response); }; /* end of system service class */ diff --git a/Telemetry/Telemetry.cpp b/Telemetry/Telemetry.cpp index db6d3313e1..b3d128d1b2 100644 --- a/Telemetry/Telemetry.cpp +++ b/Telemetry/Telemetry.cpp @@ -21,6 +21,7 @@ #include "UtilsJsonRpc.h" #include "UtilsTelemetry.h" +#include "UtilsController.h" #include "rfcapi.h" @@ -53,13 +54,18 @@ #define T2_PERSISTENT_FOLDER "/opt/.t2reportprofiles/" #define DEFAULT_PROFILES_FILE "/etc/t2profiles/default.json" +#define SYSTEMSERVICES_CALLSIGN "org.rdk.System" + #define API_VERSION_NUMBER_MAJOR 1 #define API_VERSION_NUMBER_MINOR 2 #define API_VERSION_NUMBER_PATCH 2 #ifdef HAS_RBUS +#define RBUS_PRIVACY_MODE_EVENT_NAME "Device.X_RDKCENTRAL-COM_Privacy.PrivacyMode" + static rbusError_t rbusHandleStatus = RBUS_ERROR_NOT_INITIALIZED; static rbusHandle_t rbusHandle; + #endif namespace WPEFramework @@ -108,6 +114,60 @@ namespace WPEFramework const string Telemetry::Initialize(PluginHost::IShell* service ) { + +#ifdef HAS_RBUS + PluginHost::IShell::state state; + if ((Utils::getServiceState(service, SYSTEMSERVICES_CALLSIGN, state) == Core::ERROR_NONE) && (state != PluginHost::IShell::state::ACTIVATED)) + Utils::activatePlugin(service, SYSTEMSERVICES_CALLSIGN); + + if ((Utils::getServiceState(service, SYSTEMSERVICES_CALLSIGN, state) == Core::ERROR_NONE) && (state == PluginHost::IShell::state::ACTIVATED)) + { + m_systemServiceConnection = Utils::getThunderControllerClient(SYSTEMSERVICES_CALLSIGN); + + if (!m_systemServiceConnection) + { + LOGERR("%s plugin initialisation failed", SYSTEMSERVICES_CALLSIGN); + } + else + { + uint32_t err = m_systemServiceConnection->Subscribe(2000, "onPrivacyModeChanged", [this](const JsonObject& parameters) { + + if (parameters.HasLabel("privacyMode")) + { + std::string privacyMode = parameters["privacyMode"].String(); + notifyT2PrivacyMode(privacyMode); + } + else + { + LOGERR("No 'privacyMode' parameter"); + } + }); + + if (err != Core::ERROR_NONE) + { + LOGERR("Failed to subscribe to onPrivacyModeChanged: %d", err); + } + + JsonObject params; + JsonObject res; + m_systemServiceConnection->Invoke(2000, "getPrivacyMode", params, res); + if (res["success"].Boolean()) + { + std::string privacyMode = res["privacyMode"].String(); + notifyT2PrivacyMode(privacyMode); + } + else + { + LOGERR("Failed to get privacy mode"); + } + } + } + else + { + LOGERR("%s plugin is not activated", SYSTEMSERVICES_CALLSIGN); + } +#endif + #if defined(USE_IARMBUS) || defined(USE_IARM_BUS) InitializeIARM(); #endif /* defined(USE_IARMBUS) || defined(USE_IARM_BUS) */ @@ -352,6 +412,37 @@ namespace WPEFramework LOGINFO("Got %s rbus callback", methodName); } + void Telemetry::notifyT2PrivacyMode(std::string privacyMode) + { + LOGINFO("Privacy mode is %s", privacyMode.c_str()); + if (RBUS_ERROR_SUCCESS != rbusHandleStatus) + { + rbusHandleStatus = rbus_open(&rbusHandle, RBUS_COMPONENT_NAME); + } + + if (RBUS_ERROR_SUCCESS == rbusHandleStatus) + { + rbusValue_t value; + rbusSetOptions_t opts = {true, 0}; + + rbusValue_Init(&value); + rbusValue_SetString(value, privacyMode.c_str()); + int rc = rbus_set(rbusHandle, RBUS_PRIVACY_MODE_EVENT_NAME, value, &opts); + if (rc != RBUS_ERROR_SUCCESS) + { + std::stringstream str; + str << "Failed to set property " << RBUS_PRIVACY_MODE_EVENT_NAME << ": " << rc; + LOGERR("%s", str.str().c_str()); + } + rbusValue_Release(value); + } + else + { + LOGERR("rbus_open failed with error code %d", rbusHandleStatus); + } + + } + #endif uint32_t Telemetry::UploadReport() { diff --git a/Telemetry/Telemetry.h b/Telemetry/Telemetry.h index b6ddc2eb91..b5bc1ec23f 100644 --- a/Telemetry/Telemetry.h +++ b/Telemetry/Telemetry.h @@ -74,10 +74,12 @@ namespace WPEFramework { #ifdef HAS_RBUS void onReportUploadStatus(const char* status); + void notifyT2PrivacyMode(std::string privacyMode); #endif public: static Telemetry* _instance; private: + std::shared_ptr> m_systemServiceConnection; }; } // namespace Plugin } // namespace WPEFramework diff --git a/Tests/L2Tests/L2TestsPlugin/tests/Telemetry_L2Test.cpp b/Tests/L2Tests/L2TestsPlugin/tests/Telemetry_L2Test.cpp index a008647497..095556b46f 100644 --- a/Tests/L2Tests/L2TestsPlugin/tests/Telemetry_L2Test.cpp +++ b/Tests/L2Tests/L2TestsPlugin/tests/Telemetry_L2Test.cpp @@ -504,7 +504,7 @@ TEST_F(Telemetry_L2test, TelemetryImplementationMock){ ** 4. Triggered uploadReport Method ** 5. Verify the response of uploadReport Method *******************************************************/ - +#if 0 TEST_F(Telemetry_L2test, TelemetryRbusOpeningErrorCheck){ JSONRPC::LinkType jsonrpc(TELEMETRY_CALLSIGN, TELEMETRYL2TEST_CALLSIGN); @@ -539,6 +539,8 @@ TEST_F(Telemetry_L2test, TelemetryRbusOpeningErrorCheck){ EXPECT_EQ(Core::ERROR_OPENING_FAILED, status); } +#endif + /******************************************************** ************Test case Details ************************** ** 1. ReportUploadStatus ErrorCheck diff --git a/Tests/L2Tests/L2TestsPlugin/tests/UserSettings_L2Test.cpp b/Tests/L2Tests/L2TestsPlugin/tests/UserSettings_L2Test.cpp index e271aa73dc..e045643745 100755 --- a/Tests/L2Tests/L2TestsPlugin/tests/UserSettings_L2Test.cpp +++ b/Tests/L2Tests/L2TestsPlugin/tests/UserSettings_L2Test.cpp @@ -27,14 +27,13 @@ typedef enum : uint32_t { UserSettings_onCaptionsChanged = 0x00000004, UserSettings_onPreferredCaptionsLanguagesChanged = 0x00000005, UserSettings_onPreferredClosedCaptionServiceChanged = 0x00000006, - UserSettings_onPrivacyModeChanged = 0x00000007, - UserSettings_onPinControlChanged = 0x00000008, - UserSettings_onViewingRestrictionsChanged = 0x00000009, - UserSettings_onViewingRestrictionsWindowChanged = 0x0000000a, - UserSettings_onLiveWatershedChanged = 0x0000000b, - UserSettings_onPlaybackWatershedChanged = 0x0000000c, - UserSettings_onBlockNotRatedContentChanged = 0x0000000d, - UserSettings_onPinOnPurchaseChanged = 0x0000000e, + UserSettings_onPinControlChanged = 0x00000007, + UserSettings_onViewingRestrictionsChanged = 0x00000008, + UserSettings_onViewingRestrictionsWindowChanged = 0x00000009, + UserSettings_onLiveWatershedChanged = 0x0000000a, + UserSettings_onPlaybackWatershedChanged = 0x0000000b, + UserSettings_onBlockNotRatedContentChanged = 0x0000000c, + UserSettings_onPinOnPurchaseChanged = 0x0000000d, UserSettings_StateInvalid = 0x00000000 }UserSettingsL2test_async_events_t; @@ -50,7 +49,6 @@ class AsyncHandlerMock_UserSetting MOCK_METHOD(void, onCaptionsChanged, (const bool enabled)); MOCK_METHOD(void, onPreferredCaptionsLanguagesChanged, (const string preferredLanguages)); MOCK_METHOD(void, onPreferredClosedCaptionServiceChanged, (const string service)); - MOCK_METHOD(void, onPrivacyModeChanged, (const string privacyMode)); MOCK_METHOD(void, onPinControlChanged, (const bool enabled)); MOCK_METHOD(void, onViewingRestrictionsChanged, (const string viewingRestrictions)); MOCK_METHOD(void, onViewingRestrictionsWindowChanged, (const string viewingRestrictionsWindow)); @@ -80,7 +78,7 @@ class NotificationHandler : public Exchange::IUserSettings::INotification { NotificationHandler(){} ~NotificationHandler(){} - void onAudioDescriptionChanged(const bool enabled) override + void OnAudioDescriptionChanged(const bool enabled) override { TEST_LOG("OnAudioDescriptionChanged event triggered ***\n"); std::unique_lock lock(m_mutex); @@ -92,7 +90,7 @@ class NotificationHandler : public Exchange::IUserSettings::INotification { m_condition_variable.notify_one(); } - void onPreferredAudioLanguagesChanged(const string& preferredLanguages) override + void OnPreferredAudioLanguagesChanged(const string& preferredLanguages) override { TEST_LOG("OnPreferredAudioLanguagesChanged event triggered ***\n"); std::unique_lock lock(m_mutex); @@ -104,7 +102,7 @@ class NotificationHandler : public Exchange::IUserSettings::INotification { } - void onPresentationLanguageChanged(const string& presentationLanguage) override + void OnPresentationLanguageChanged(const string& presentationLanguage) override { TEST_LOG("OnPresentationLanguageChanged event triggered ***\n"); std::unique_lock lock(m_mutex); @@ -116,7 +114,7 @@ class NotificationHandler : public Exchange::IUserSettings::INotification { } - void onCaptionsChanged(bool enabled) override + void OnCaptionsChanged(bool enabled) override { TEST_LOG("OnCaptionsChanged event triggered ***\n"); std::unique_lock lock(m_mutex); @@ -129,7 +127,7 @@ class NotificationHandler : public Exchange::IUserSettings::INotification { } - void onPreferredCaptionsLanguagesChanged(const string& preferredLanguages) override + void OnPreferredCaptionsLanguagesChanged(const string& preferredLanguages) override { TEST_LOG("OnPreferredCaptionsLanguagesChanged event triggered ***\n"); std::unique_lock lock(m_mutex); @@ -141,7 +139,7 @@ class NotificationHandler : public Exchange::IUserSettings::INotification { } - void onPreferredClosedCaptionServiceChanged(const string& service) override + void OnPreferredClosedCaptionServiceChanged(const string& service) override { TEST_LOG("OnPreferredClosedCaptionServiceChanged event triggered ***\n"); std::unique_lock lock(m_mutex); @@ -152,18 +150,7 @@ class NotificationHandler : public Exchange::IUserSettings::INotification { m_condition_variable.notify_one(); } - void onPrivacyModeChanged(const string& privacyMode) override - { - TEST_LOG("OnPrivacyModeChanged event triggered ***\n"); - std::unique_lock lock(m_mutex); - - TEST_LOG("OnPrivacyModeChanged received: %s\n", privacyMode.c_str()); - /* Notify the requester thread. */ - m_event_signalled |= UserSettings_onPrivacyModeChanged; - m_condition_variable.notify_one(); - } - - void onPinControlChanged(const bool enabled) override + void OnPinControlChanged(const bool enabled) override { TEST_LOG("OnPinControlChanged event triggered ***\n"); std::unique_lock lock(m_mutex); @@ -175,7 +162,7 @@ class NotificationHandler : public Exchange::IUserSettings::INotification { m_condition_variable.notify_one(); } - void onViewingRestrictionsChanged(const string& viewingRestrictions) override + void OnViewingRestrictionsChanged(const string& viewingRestrictions) override { TEST_LOG("OnViewingRestrictionsChanged event triggered ***\n"); std::unique_lock lock(m_mutex); @@ -187,7 +174,7 @@ class NotificationHandler : public Exchange::IUserSettings::INotification { } - void onViewingRestrictionsWindowChanged(const string& viewingRestrictionsWindow) override + void OnViewingRestrictionsWindowChanged(const string& viewingRestrictionsWindow) override { TEST_LOG("OnViewingRestrictionsWindowChanged event triggered ***\n"); std::unique_lock lock(m_mutex); @@ -199,7 +186,7 @@ class NotificationHandler : public Exchange::IUserSettings::INotification { } - void onLiveWatershedChanged(const bool enabled) override + void OnLiveWatershedChanged(const bool enabled) override { TEST_LOG("OnLiveWatershedChanged event triggered ***\n"); std::unique_lock lock(m_mutex); @@ -211,7 +198,7 @@ class NotificationHandler : public Exchange::IUserSettings::INotification { m_condition_variable.notify_one(); } - void onPlaybackWatershedChanged(const bool enabled) override + void OnPlaybackWatershedChanged(const bool enabled) override { TEST_LOG("OnPlaybackWatershedChanged event triggered ***\n"); std::unique_lock lock(m_mutex); @@ -223,7 +210,7 @@ class NotificationHandler : public Exchange::IUserSettings::INotification { m_condition_variable.notify_one(); } - void onBlockNotRatedContentChanged(const bool enabled) override + void OnBlockNotRatedContentChanged(const bool enabled) override { TEST_LOG("OnBlockNotRatedContentChanged event triggered ***\n"); std::unique_lock lock(m_mutex); @@ -235,7 +222,7 @@ class NotificationHandler : public Exchange::IUserSettings::INotification { m_condition_variable.notify_one(); } - void onPinOnPurchaseChanged(const bool enabled) override + void OnPinOnPurchaseChanged(const bool enabled) override { TEST_LOG("OnPinOnPurchaseChanged event triggered ***\n"); std::unique_lock lock(m_mutex); @@ -606,7 +593,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) m_usersettingsplugin->Register(¬ification); /* defaultBooleanValue should get false and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getAudioDescription(defaultBooleanValue); + status = m_usersettingsplugin->GetAudioDescription(defaultBooleanValue); EXPECT_EQ(defaultBooleanValue, false); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -616,7 +603,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) } /* defaultStrValue should get empty string and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getPreferredAudioLanguages(defaultStrValue); + status = m_usersettingsplugin->GetPreferredAudioLanguages(defaultStrValue); EXPECT_EQ(defaultStrValue, ""); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -626,7 +613,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) } /* defaultStrValue should get empty string and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getPresentationLanguage(defaultStrValue); + status = m_usersettingsplugin->GetPresentationLanguage(defaultStrValue); EXPECT_EQ(defaultStrValue, ""); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -636,7 +623,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) } /* defaultBooleanValue should get false and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getCaptions(defaultBooleanValue); + status = m_usersettingsplugin->GetCaptions(defaultBooleanValue); EXPECT_EQ(defaultBooleanValue, false); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -646,7 +633,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) } /* defaultStrValue should get empty string and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getPreferredCaptionsLanguages(defaultStrValue); + status = m_usersettingsplugin->GetPreferredCaptionsLanguages(defaultStrValue); EXPECT_EQ(defaultStrValue, ""); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -656,7 +643,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) } /* defaultStrValue should get "AUTO" and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getPreferredClosedCaptionService(defaultStrValue); + status = m_usersettingsplugin->GetPreferredClosedCaptionService(defaultStrValue); EXPECT_EQ(defaultStrValue, "AUTO"); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -666,7 +653,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) } /* defaultBooleanValue should get false and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getPinControl(defaultBooleanValue); + status = m_usersettingsplugin->GetPinControl(defaultBooleanValue); EXPECT_EQ(defaultBooleanValue, false); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -677,7 +664,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) /* defaultStrValue should get "" and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getViewingRestrictions(defaultStrValue); + status = m_usersettingsplugin->GetViewingRestrictions(defaultStrValue); EXPECT_EQ(defaultStrValue, ""); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -687,7 +674,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) } /* defaultStrValue should get "" and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getViewingRestrictionsWindow(defaultStrValue); + status = m_usersettingsplugin->GetViewingRestrictionsWindow(defaultStrValue); EXPECT_EQ(defaultStrValue, ""); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -697,7 +684,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) } /* defaultBooleanValue should get false and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getLiveWatershed(defaultBooleanValue); + status = m_usersettingsplugin->GetLiveWatershed(defaultBooleanValue); EXPECT_EQ(defaultBooleanValue, false); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -707,7 +694,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) } /* defaultBooleanValue should get false and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getPlaybackWatershed(defaultBooleanValue); + status = m_usersettingsplugin->GetPlaybackWatershed(defaultBooleanValue); EXPECT_EQ(defaultBooleanValue, false); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -718,7 +705,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) /* defaultBooleanValue should get false and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getBlockNotRatedContent(defaultBooleanValue); + status = m_usersettingsplugin->GetBlockNotRatedContent(defaultBooleanValue); EXPECT_EQ(defaultBooleanValue, false); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -729,7 +716,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) /* defaultBooleanValue should get false and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getPinOnPurchase(defaultBooleanValue); + status = m_usersettingsplugin->GetPinOnPurchase(defaultBooleanValue); EXPECT_EQ(defaultBooleanValue, false); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -742,7 +729,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) But we are trying to get PreferredAudioLanguages, which has no entry in db. So GetPreferredAudioLanguages should return the empty string and the return status from Persistant store is Core::ERROR_UNKNOWN_KEY and return status from usersettings is Core::ERROR_NONE */ - status = m_usersettingsplugin->setAudioDescription(defaultBooleanValue); + status = m_usersettingsplugin->SetAudioDescription(defaultBooleanValue); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) { @@ -756,7 +743,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) /* We are trying to get PreferredAudioLanguages, which has no entry in db. Persistant store returns status as Core::ERROR_UNKNOWN_KEY to UserSettings GetPreferredAudioLanguages should get the empty string.*/ - status = m_usersettingsplugin->getPreferredAudioLanguages(defaultStrValue); + status = m_usersettingsplugin->GetPreferredAudioLanguages(defaultStrValue); EXPECT_EQ(defaultStrValue, ""); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -768,7 +755,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) /* We are trying to get PresentationLanguage, which has no entry in db. Persistant store returns status as Core::ERROR_UNKNOWN_KEY to UserSettings GetPreferredAudioLanguages should get the empty string.*/ - status = m_usersettingsplugin->getPresentationLanguage(defaultStrValue); + status = m_usersettingsplugin->GetPresentationLanguage(defaultStrValue); EXPECT_EQ(defaultStrValue, ""); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -780,7 +767,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) /* We are trying to get Captions, which has no entry in db. Persistant store returns status as Core::ERROR_UNKNOWN_KEY to UserSettings GetPreferredAudioLanguages should get the empty string.*/ - status = m_usersettingsplugin->getCaptions(defaultBooleanValue); + status = m_usersettingsplugin->GetCaptions(defaultBooleanValue); EXPECT_EQ(defaultBooleanValue, false); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -792,7 +779,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) /* We are trying to get PreferredCaptionsLanguages, which has no entry in db. Persistant store returns status as Core::ERROR_UNKNOWN_KEY to UserSettings GetPreferredAudioLanguages should get the empty string.*/ - status = m_usersettingsplugin->getPreferredCaptionsLanguages(defaultStrValue); + status = m_usersettingsplugin->GetPreferredCaptionsLanguages(defaultStrValue); EXPECT_EQ(defaultStrValue, ""); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -804,7 +791,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) /* We are trying to get PreferredClosedCaptionService, which has no entry in db. Persistant store returns status as Core::ERROR_UNKNOWN_KEY to UserSettings GetPreferredAudioLanguages should get the empty string.*/ - status = m_usersettingsplugin->getPreferredClosedCaptionService(defaultStrValue); + status = m_usersettingsplugin->GetPreferredClosedCaptionService(defaultStrValue); EXPECT_EQ(defaultStrValue, "AUTO"); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -814,7 +801,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) } /* defaultBooleanValue should get false and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getPinControl(defaultBooleanValue); + status = m_usersettingsplugin->GetPinControl(defaultBooleanValue); EXPECT_EQ(defaultBooleanValue, false); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -824,7 +811,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) } /* defaultStrValue should get "" and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getViewingRestrictions(defaultStrValue); + status = m_usersettingsplugin->GetViewingRestrictions(defaultStrValue); EXPECT_EQ(defaultStrValue, ""); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -834,7 +821,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) } /* defaultStrValue should get "" and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getViewingRestrictionsWindow(defaultStrValue); + status = m_usersettingsplugin->GetViewingRestrictionsWindow(defaultStrValue); EXPECT_EQ(defaultStrValue, ""); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -844,7 +831,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) } /* defaultBooleanValue should get false and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getLiveWatershed(defaultBooleanValue); + status = m_usersettingsplugin->GetLiveWatershed(defaultBooleanValue); EXPECT_EQ(defaultBooleanValue, false); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -854,7 +841,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) } /* defaultBooleanValue should get false and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getPlaybackWatershed(defaultBooleanValue); + status = m_usersettingsplugin->GetPlaybackWatershed(defaultBooleanValue); EXPECT_EQ(defaultBooleanValue, false); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -864,7 +851,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) } /* defaultBooleanValue should get false and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getBlockNotRatedContent(defaultBooleanValue); + status = m_usersettingsplugin->GetBlockNotRatedContent(defaultBooleanValue); EXPECT_EQ(defaultBooleanValue, false); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -874,7 +861,7 @@ TEST_F(UserSettingTest, VerifyDefaultValues) } /* defaultBooleanValue should get false and the return status is Core::ERROR_NONE */ - status = m_usersettingsplugin->getPinOnPurchase(defaultBooleanValue); + status = m_usersettingsplugin->GetPinOnPurchase(defaultBooleanValue); EXPECT_EQ(defaultBooleanValue, false); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -1287,7 +1274,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) m_usersettingsplugin->Register(¬ification); TEST_LOG("Setting and Getting AudioDescription Values"); - status = m_usersettingsplugin->setAudioDescription(true); + status = m_usersettingsplugin->SetAudioDescription(true); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) { @@ -1297,7 +1284,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, UserSettings_onAudioDescriptionChanged); EXPECT_TRUE(signalled & UserSettings_onAudioDescriptionChanged); - status = m_usersettingsplugin->getAudioDescription(getBoolValue); + status = m_usersettingsplugin->GetAudioDescription(getBoolValue); EXPECT_EQ(getBoolValue, true); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -1307,7 +1294,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) } TEST_LOG("Setting and Getting PreferredAudioLanguages Values"); - status = m_usersettingsplugin->setPreferredAudioLanguages("eng"); + status = m_usersettingsplugin->SetPreferredAudioLanguages("eng"); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) { @@ -1317,7 +1304,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) signalled = notification.WaitForRequestStatus(JSON_TIMEOUT,UserSettings_onPreferredAudioLanguagesChanged); EXPECT_TRUE(signalled & UserSettings_onPreferredAudioLanguagesChanged); - status = m_usersettingsplugin->getPreferredAudioLanguages(getStringValue); + status = m_usersettingsplugin->GetPreferredAudioLanguages(getStringValue); EXPECT_EQ(getStringValue, "eng"); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -1327,7 +1314,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) } TEST_LOG("Setting and Getting PresentationLanguage Values"); - status = m_usersettingsplugin->setPresentationLanguage("fra"); + status = m_usersettingsplugin->SetPresentationLanguage("fra"); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) { @@ -1337,7 +1324,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) signalled = notification.WaitForRequestStatus(JSON_TIMEOUT,UserSettings_onPresentationLanguageChanged); EXPECT_TRUE(signalled & UserSettings_onPresentationLanguageChanged); - status = m_usersettingsplugin->getPresentationLanguage(getStringValue); + status = m_usersettingsplugin->GetPresentationLanguage(getStringValue); EXPECT_EQ(getStringValue, "fra"); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -1348,7 +1335,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) TEST_LOG("Setting and Getting Captions Values"); getBoolValue = false; - status = m_usersettingsplugin->setCaptions(true); + status = m_usersettingsplugin->SetCaptions(true); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) { @@ -1358,7 +1345,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) signalled = notification.WaitForRequestStatus(JSON_TIMEOUT,UserSettings_onCaptionsChanged); EXPECT_TRUE(signalled & UserSettings_onCaptionsChanged); - status = m_usersettingsplugin->getCaptions(getBoolValue); + status = m_usersettingsplugin->GetCaptions(getBoolValue); EXPECT_EQ(getBoolValue, true); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -1368,7 +1355,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) } TEST_LOG("Setting and Getting Captions Values"); - status = m_usersettingsplugin->setPreferredCaptionsLanguages("en,es"); + status = m_usersettingsplugin->SetPreferredCaptionsLanguages("en,es"); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) { @@ -1378,7 +1365,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) signalled = notification.WaitForRequestStatus(JSON_TIMEOUT,UserSettings_onPreferredCaptionsLanguagesChanged); EXPECT_TRUE(signalled & UserSettings_onPreferredCaptionsLanguagesChanged); - status = m_usersettingsplugin->getPreferredCaptionsLanguages(getStringValue); + status = m_usersettingsplugin->GetPreferredCaptionsLanguages(getStringValue); EXPECT_EQ(getStringValue, "en,es"); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -1388,7 +1375,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) } TEST_LOG("Setting and Getting PreferredClosedCaptionService Values"); - status = m_usersettingsplugin->setPreferredClosedCaptionService("CC3"); + status = m_usersettingsplugin->SetPreferredClosedCaptionService("CC3"); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) { @@ -1398,7 +1385,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) signalled = notification.WaitForRequestStatus(JSON_TIMEOUT,UserSettings_onPreferredClosedCaptionServiceChanged); EXPECT_TRUE(signalled & UserSettings_onPreferredClosedCaptionServiceChanged); - status = m_usersettingsplugin->getPreferredClosedCaptionService(getStringValue); + status = m_usersettingsplugin->GetPreferredClosedCaptionService(getStringValue); EXPECT_EQ(getStringValue, "CC3"); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -1408,7 +1395,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) } TEST_LOG("Setting and Getting PinControl Values"); - status = m_usersettingsplugin->setPinControl(true); + status = m_usersettingsplugin->SetPinControl(true); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) { @@ -1418,7 +1405,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, UserSettings_onPinControlChanged); EXPECT_TRUE(signalled & UserSettings_onPinControlChanged); - status = m_usersettingsplugin->getPinControl(getBoolValue); + status = m_usersettingsplugin->GetPinControl(getBoolValue); EXPECT_EQ(getBoolValue, true); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -1428,7 +1415,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) } string viewRes = "{\"restrictions\": [{\"scheme\": \"US_TV\", \"restrict\": [\"TV-Y7/FV\"]}, {\"scheme\": \"MPAA\", \"restrict\": []}]}"; TEST_LOG("Setting and Getting ViewingRestrictions Values"); - status = m_usersettingsplugin->setViewingRestrictions(viewRes); + status = m_usersettingsplugin->SetViewingRestrictions(viewRes); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) { @@ -1438,7 +1425,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) signalled = notification.WaitForRequestStatus(JSON_TIMEOUT,UserSettings_onViewingRestrictionsChanged); EXPECT_TRUE(signalled & UserSettings_onViewingRestrictionsChanged); - status = m_usersettingsplugin->getViewingRestrictions(getStringValue); + status = m_usersettingsplugin->GetViewingRestrictions(getStringValue); EXPECT_EQ(getStringValue, viewRes); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -1448,7 +1435,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) } TEST_LOG("Setting and Getting ViewingRestrictionsWindow Values"); - status = m_usersettingsplugin->setViewingRestrictionsWindow("ALWAYS"); + status = m_usersettingsplugin->SetViewingRestrictionsWindow("ALWAYS"); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) { @@ -1458,7 +1445,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) signalled = notification.WaitForRequestStatus(JSON_TIMEOUT,UserSettings_onViewingRestrictionsWindowChanged); EXPECT_TRUE(signalled & UserSettings_onViewingRestrictionsWindowChanged); - status = m_usersettingsplugin->getViewingRestrictionsWindow(getStringValue); + status = m_usersettingsplugin->GetViewingRestrictionsWindow(getStringValue); EXPECT_EQ(getStringValue, "ALWAYS"); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -1468,7 +1455,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) } TEST_LOG("Setting and Getting LiveWatershed Values"); - status = m_usersettingsplugin->setLiveWatershed(true); + status = m_usersettingsplugin->SetLiveWatershed(true); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) { @@ -1478,7 +1465,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, UserSettings_onLiveWatershedChanged); EXPECT_TRUE(signalled & UserSettings_onLiveWatershedChanged); - status = m_usersettingsplugin->getLiveWatershed(getBoolValue); + status = m_usersettingsplugin->GetLiveWatershed(getBoolValue); EXPECT_EQ(getBoolValue, true); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -1488,7 +1475,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) } TEST_LOG("Setting and Getting PlaybackWatershed Values"); - status = m_usersettingsplugin->setPlaybackWatershed(true); + status = m_usersettingsplugin->SetPlaybackWatershed(true); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) { @@ -1498,7 +1485,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, UserSettings_onPlaybackWatershedChanged); EXPECT_TRUE(signalled & UserSettings_onPlaybackWatershedChanged); - status = m_usersettingsplugin->getPlaybackWatershed(getBoolValue); + status = m_usersettingsplugin->GetPlaybackWatershed(getBoolValue); EXPECT_EQ(getBoolValue, true); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -1508,7 +1495,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) } TEST_LOG("Setting and Getting BlockNotRatedContent Values"); - status = m_usersettingsplugin->setBlockNotRatedContent(true); + status = m_usersettingsplugin->SetBlockNotRatedContent(true); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) { @@ -1518,7 +1505,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, UserSettings_onBlockNotRatedContentChanged); EXPECT_TRUE(signalled & UserSettings_onBlockNotRatedContentChanged); - status = m_usersettingsplugin->getBlockNotRatedContent(getBoolValue); + status = m_usersettingsplugin->GetBlockNotRatedContent(getBoolValue); EXPECT_EQ(getBoolValue, true); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -1528,7 +1515,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) } TEST_LOG("Setting and Getting PinOnPurchase Values"); - status = m_usersettingsplugin->setPinOnPurchase(true); + status = m_usersettingsplugin->SetPinOnPurchase(true); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) { @@ -1538,7 +1525,7 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase) signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, UserSettings_onPinOnPurchaseChanged); EXPECT_TRUE(signalled & UserSettings_onPinOnPurchaseChanged); - status = m_usersettingsplugin->getPinOnPurchase(getBoolValue); + status = m_usersettingsplugin->GetPinOnPurchase(getBoolValue); EXPECT_EQ(getBoolValue, true); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) @@ -1587,7 +1574,7 @@ TEST_F(UserSettingTest, NoDBFileInPersistentstoreErrorCase) m_usersettingsplugin->Register(¬ification); TEST_LOG("Setting and Getting AudioDescription Values"); - status = m_usersettingsplugin->setAudioDescription(true); + status = m_usersettingsplugin->SetAudioDescription(true); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) { @@ -1597,12 +1584,12 @@ TEST_F(UserSettingTest, NoDBFileInPersistentstoreErrorCase) signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, UserSettings_onAudioDescriptionChanged); EXPECT_TRUE(signalled & UserSettings_onAudioDescriptionChanged); - status = m_usersettingsplugin->getAudioDescription(getBoolValue); + status = m_usersettingsplugin->GetAudioDescription(getBoolValue); EXPECT_EQ(getBoolValue, true); EXPECT_EQ(status, Core::ERROR_NONE); TEST_LOG("Setting and Getting PinControl Values"); - status = m_usersettingsplugin->setPinControl(true); + status = m_usersettingsplugin->SetPinControl(true); EXPECT_EQ(status,Core::ERROR_NONE); if (status != Core::ERROR_NONE) { @@ -1612,7 +1599,7 @@ TEST_F(UserSettingTest, NoDBFileInPersistentstoreErrorCase) signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, UserSettings_onPinControlChanged); EXPECT_TRUE(signalled & UserSettings_onPinControlChanged); - status = m_usersettingsplugin->getPinControl(getBoolValue); + status = m_usersettingsplugin->GetPinControl(getBoolValue); EXPECT_EQ(getBoolValue, true); EXPECT_EQ(status, Core::ERROR_NONE); @@ -1633,24 +1620,24 @@ TEST_F(UserSettingTest, NoDBFileInPersistentstoreErrorCase) } TEST_LOG("Setting and Getting AudioDescription Values after DB file deletion"); - status = m_usersettingsplugin->setAudioDescription(false); + status = m_usersettingsplugin->SetAudioDescription(false); EXPECT_EQ(status, Core::ERROR_GENERAL); signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, UserSettings_onAudioDescriptionChanged); EXPECT_TRUE(signalled & UserSettings_onAudioDescriptionChanged); - status = m_usersettingsplugin->getAudioDescription(getBoolValue); + status = m_usersettingsplugin->GetAudioDescription(getBoolValue); EXPECT_EQ(getBoolValue, true); EXPECT_EQ(status, Core::ERROR_NONE); TEST_LOG("Setting and Getting setPinControl Values after DB file deletion"); - status = m_usersettingsplugin->setPinControl(false); + status = m_usersettingsplugin->SetPinControl(false); EXPECT_EQ(status, Core::ERROR_GENERAL); signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, UserSettings_onPinControlChanged); EXPECT_TRUE(signalled & UserSettings_onPinControlChanged); - status = m_usersettingsplugin->getPinControl(getBoolValue); + status = m_usersettingsplugin->GetPinControl(getBoolValue); EXPECT_EQ(getBoolValue, true); EXPECT_EQ(status, Core::ERROR_NONE); @@ -1798,24 +1785,24 @@ TEST_F(UserSettingTest, PersistentstoreIsNotActivatedWhileUserSettingsActivating m_usersettingsplugin->Register(¬ification); TEST_LOG("Setting and Getting AudioDescription Values"); - status = m_usersettingsplugin->setAudioDescription(true); + status = m_usersettingsplugin->SetAudioDescription(true); EXPECT_EQ(status,Core::ERROR_GENERAL); signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, UserSettings_onAudioDescriptionChanged); EXPECT_FALSE(signalled & UserSettings_onAudioDescriptionChanged); - status = m_usersettingsplugin->getAudioDescription(getBoolValue); + status = m_usersettingsplugin->GetAudioDescription(getBoolValue); EXPECT_EQ(getBoolValue, false); EXPECT_EQ(status, Core::ERROR_GENERAL); TEST_LOG("Setting and Getting PinControl Values"); - status = m_usersettingsplugin->setPinControl(true); + status = m_usersettingsplugin->SetPinControl(true); EXPECT_EQ(status,Core::ERROR_GENERAL); signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, UserSettings_onPinControlChanged); EXPECT_FALSE(signalled & UserSettings_onPinControlChanged); - status = m_usersettingsplugin->getPinControl(getBoolValue); + status = m_usersettingsplugin->GetPinControl(getBoolValue); EXPECT_EQ(getBoolValue, false); EXPECT_EQ(status, Core::ERROR_GENERAL); diff --git a/Tests/L2Tests/patches/RDKV-48604-User-Settings-Thunder-Plugin.patch b/Tests/L2Tests/patches/RDKV-48604-User-Settings-Thunder-Plugin.patch index 5812a88b77..9ea2c7a14b 100755 --- a/Tests/L2Tests/patches/RDKV-48604-User-Settings-Thunder-Plugin.patch +++ b/Tests/L2Tests/patches/RDKV-48604-User-Settings-Thunder-Plugin.patch @@ -1,15 +1,13 @@ -commit e60f095f4fdcbd083ad3f6295beca33b6dcd0877 +commit 8afc4a92b878252780fae90496b9782600a41bd0 Author: Nagalakshmi Dosakayala -Date: Wed Aug 28 12:16:07 2024 +0530 +Date: Fri Sep 6 12:49:05 2024 +0530 RDK-48604: New UserSettings Thunder Plugin -diff --git a/interfaces/IUserSettings.h b/interfaces/IUserSettings.h -new file mode 100755 -index 0000000..460d793 ---- /dev/null -+++ b/interfaces/IUserSettings.h -@@ -0,0 +1,351 @@ +diff -uprN a/interfaces/IUserSettings.h b/interfaces/IUserSettings.h +--- a/interfaces/IUserSettings.h 1970-01-01 03:00:00.000000000 +0300 ++++ b/interfaces/IUserSettings.h 2024-09-10 00:56:19.923464729 +0300 +@@ -0,0 +1,264 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: @@ -35,7 +33,7 @@ index 0000000..460d793 + +namespace WPEFramework { +namespace Exchange { -+ // @json ++ // @json @text:keep + struct EXTERNAL IUserSettings : virtual public Core::IUnknown { + enum { ID = ID_USER_SETTINGS }; + @@ -43,116 +41,111 @@ index 0000000..460d793 + struct EXTERNAL INotification : virtual public Core::IUnknown { + enum { ID = ID_USER_SETTINGS_NOTIFICATION }; + -+ // @alt onAudioDescriptionChanged ++ // @text onAudioDescriptionChanged + // @brief The AudioDescription setting has changed. + // @param enabled: Enabled/Disabled. -+ virtual void onAudioDescriptionChanged(const bool enabled) = 0; ++ virtual void OnAudioDescriptionChanged(const bool enabled) = 0; + -+ // @alt onPreferredAudioLanguagesChanged ++ // @text onPreferredAudioLanguagesChanged + // @brief The preferredLanguages setting has changed. + // @param preferredLanguages: PreferredLanguages. -+ virtual void onPreferredAudioLanguagesChanged(const string& preferredLanguages /* @text preferredLanguages */) = 0; ++ virtual void OnPreferredAudioLanguagesChanged(const string& preferredLanguages /* @text preferredLanguages */) = 0; + -+ // @alt onPresentationLanguageChanged ++ // @text onPresentationLanguageChanged + // @brief The PresentationLanguages setting has changed. + // @param presentationLanguage: PresentationLanguage. -+ virtual void onPresentationLanguageChanged(const string& presentationLanguage /* @text presentationLanguage */) = 0; ++ virtual void OnPresentationLanguageChanged(const string& presentationLanguage /* @text presentationLanguage */) = 0; + -+ // @alt onCaptionsChanged ++ // @text onCaptionsChanged + // @brief The Captions setting has changed. + // @param enabled: Enabled/Disabled. -+ virtual void onCaptionsChanged(const bool enabled) = 0; ++ virtual void OnCaptionsChanged(const bool enabled) = 0; + -+ // @alt onPreferredCaptionsLanguagesChanged ++ // @text onPreferredCaptionsLanguagesChanged + // @brief The PreferredCaptionsLanguages setting has changed. + // @param preferredLanguages: PreferredLanguages. -+ virtual void onPreferredCaptionsLanguagesChanged(const string& preferredLanguages /* @text preferredLanguages */) = 0; ++ virtual void OnPreferredCaptionsLanguagesChanged(const string& preferredLanguages /* @text preferredLanguages */) = 0; + -+ // @alt onPreferredClosedCaptionServiceChanged ++ // @text onPreferredClosedCaptionServiceChanged + // @brief The PreferredClosedCaptionService setting has changed. + // @param service: "CC[1-4]", "TEXT[1-4]", "SERVICE[1-64]". -+ virtual void onPreferredClosedCaptionServiceChanged(const string& service) = 0; ++ virtual void OnPreferredClosedCaptionServiceChanged(const string& service) = 0; + -+ // @alt onPrivacyModeChanged -+ // @brief The PrivacyMode setting has changed. -+ // @param privacyMode: "SHARE", "DO_NOT_SHARE". -+ virtual void onPrivacyModeChanged(const string& privacyMode /* @text privacyMode */) = 0; -+ -+ // @alt onPinControlChanged ++ // @text onPinControlChanged + // @brief The PinControl setting has changed. + // @param enabled: Enabled/Disabled. -+ virtual void onPinControlChanged(const bool enabled) = 0; ++ virtual void OnPinControlChanged(const bool enabled) = 0; + -+ // @alt onViewingRestrictionsChanged ++ // @text onViewingRestrictionsChanged + // @brief The ViewingRestrictions setting has changed. + // @param viewingRestrictions: Empty string -+ virtual void onViewingRestrictionsChanged(const string& viewingRestrictions /* @text viewingRestrictions */) = 0; ++ virtual void OnViewingRestrictionsChanged(const string& viewingRestrictions /* @text viewingRestrictions */) = 0; + -+ // @alt onViewingRestrictionsWindowChanged ++ // @text onViewingRestrictionsWindowChanged + // @brief The ViewingRestrictionsWindow setting has changed. + // @param viewingRestrictionsWindow: "ALWAYS" -+ virtual void onViewingRestrictionsWindowChanged(const string& viewingRestrictionsWindow /* @text viewingRestrictionsWindow */) = 0; ++ virtual void OnViewingRestrictionsWindowChanged(const string& viewingRestrictionsWindow /* @text viewingRestrictionsWindow */) = 0; + -+ // @alt onLiveWatershedChanged ++ // @text onLiveWatershedChanged + // @brief The LiveWatershed setting has changed. + // @param enabled: Enabled/Disabled. -+ virtual void onLiveWatershedChanged(const bool enabled) = 0; ++ virtual void OnLiveWatershedChanged(const bool enabled) = 0; + -+ // @alt onPlaybackWatershedChanged ++ // @text onPlaybackWatershedChanged + // @brief The PlaybackWatershed setting has changed. + // @param enabled: Enabled/Disabled. -+ virtual void onPlaybackWatershedChanged(const bool enabled) = 0; ++ virtual void OnPlaybackWatershedChanged(const bool enabled) = 0; + -+ // @alt onBlockNotRatedContentChanged ++ // @text onBlockNotRatedContentChanged + // @brief The BlockNotRatedContent setting has changed. + // @param enabled: Enabled/Disabled. -+ virtual void onBlockNotRatedContentChanged(const bool enabled) = 0; ++ virtual void OnBlockNotRatedContentChanged(const bool enabled) = 0; + -+ // @alt onPinOnPurchaseChanged ++ // @text onPinOnPurchaseChanged + // @brief The PinOnPurchase setting has changed. + // @param enabled: Enabled/Disabled. -+ virtual void onPinOnPurchaseChanged(const bool enabled) = 0; ++ virtual void OnPinOnPurchaseChanged(const bool enabled) = 0; + + }; + + virtual uint32_t Register(Exchange::IUserSettings::INotification* notification /* @in */) = 0; + virtual uint32_t Unregister(Exchange::IUserSettings::INotification* notification /* @in */) = 0; + -+ // @alt setAudioDescription ++ // @text setAudioDescription + // @brief Sets AudioDescription ON/OFF. Players should preferred Audio Descriptive tracks over normal audio track when enabled + // @param enabled: Enabled/Disabled -+ virtual uint32_t setAudioDescription(const bool enabled /* @in */) = 0; ++ virtual uint32_t SetAudioDescription(const bool enabled /* @in */) = 0; + -+ // @alt getAudioDescription ++ // @text getAudioDescription + // @brief Gets the current AudioDescription setting + // @param enabled: Enabled/Disabled -+ virtual uint32_t getAudioDescription(bool &enabled /* @out */) const = 0; ++ virtual uint32_t GetAudioDescription(bool &enabled /* @out */) const = 0; + -+ // @alt setPreferredAudioLanguages ++ // @text setPreferredAudioLanguages + // @brief A prioritized list of ISO 639-2/B codes for the preferred audio languages, + // expressed as a comma separated lists of languages of zero of more elements. + // The players will pick the audio track that has the best match compared with + // this list. In the absence of a matching track, the player should by best + // effort select the preferred audio track.*/ + // @param preferredLanguages: PreferredLanguages -+ virtual uint32_t setPreferredAudioLanguages(const string& preferredLanguages /* @in @text preferredLanguages */) = 0; ++ virtual uint32_t SetPreferredAudioLanguages(const string& preferredLanguages /* @in @text preferredLanguages */) = 0; + -+ // @alt getPreferredAudioLanguages ++ // @text getPreferredAudioLanguages + // @brief Gets the current PreferredAudioLanguages setting + // @param preferredLanguages: PreferredLanguages -+ virtual uint32_t getPreferredAudioLanguages(string &preferredLanguages /* @out @text preferredLanguages */) const = 0; ++ virtual uint32_t GetPreferredAudioLanguages(string &preferredLanguages /* @out @text preferredLanguages */) const = 0; + -+ // @alt setPresentationLanguage ++ // @text setPresentationLanguage + // @brief Sets the presentationLanguage in a full BCP 47 value, including script, region, variant + // @param presentationLanguage: "en-US", "es-US", "en-CA", "fr-CA" -+ virtual uint32_t setPresentationLanguage(const string& presentationLanguage /* @in @text presentationLanguage */) = 0; ++ virtual uint32_t SetPresentationLanguage(const string& presentationLanguage /* @in @text presentationLanguage */) = 0; + -+ // @alt getPresentationLanguage ++ // @text getPresentationLanguage + // @brief Gets the presentationLanguage + // @param presentationLanguage: "en-US", "es-US", "en-CA", "fr-CA" -+ virtual uint32_t getPresentationLanguage(string &presentationLanguage /* @out @text presentationLanguage */) const = 0; ++ virtual uint32_t GetPresentationLanguage(string &presentationLanguage /* @out @text presentationLanguage */) const = 0; + -+ // @alt setCaptions ++ // @text setCaptions + // @brief brief Sets Captions ON/OFF. + // @details A setting of ON indicates that Players should select a subtitle track for presentation + // The Setting does not influence any running sessions. It is up to the player to enforce the setting. @@ -164,14 +157,14 @@ index 0000000..460d793 + // This holds true for media players that utilize TextTrack render sessions for text track decode-display and also for media + // players or apps that decode-display internally + // @param enabled: Sets the state -+ virtual uint32_t setCaptions(const bool enabled /* @in */) = 0; ++ virtual uint32_t SetCaptions(const bool enabled /* @in */) = 0; + -+ // @alt getCaptions ++ // @text getCaptions + // @brief Gets the Captions setting. + // @param enabled: Receives the state -+ virtual uint32_t getCaptions(bool &enabled /* @out */) const = 0; ++ virtual uint32_t GetCaptions(bool &enabled /* @out */) const = 0; + -+ // @alt setPreferredCaptionsLanguages ++ // @text setPreferredCaptionsLanguages + // @brief Set preferred languages for captions. + // @details A prioritized list of ISO 639-2/B codes for the preferred Captions languages, + // expressed as a comma separated lists of languages of zero of more elements. @@ -179,188 +172,106 @@ index 0000000..460d793 + // this list. In the absence of a matching track, the player should by best + // effort select the preferred subtitle track. + // @param preferredLanguages: Is the list to set (e.g. "eng,fra") -+ virtual uint32_t setPreferredCaptionsLanguages(const string& preferredLanguages /* @in @text preferredLanguages */) = 0; ++ virtual uint32_t SetPreferredCaptionsLanguages(const string& preferredLanguages /* @in @text preferredLanguages */) = 0; + -+ // @alt getPreferredCaptionsLanguages ++ // @text getPreferredCaptionsLanguages + // @brief Gets the current PreferredCaptionsLanguages setting. + // @param preferredLanguages: "eng,fra" -+ virtual uint32_t getPreferredCaptionsLanguages(string &preferredLanguages /* @out @text preferredLanguages */) const = 0; ++ virtual uint32_t GetPreferredCaptionsLanguages(string &preferredLanguages /* @out @text preferredLanguages */) const = 0; + -+ // @alt setPreferredClosedCaptionService ++ // @text setPreferredClosedCaptionService + // @brief Sets the PreferredClosedCaptionService. + // @details The setting should be honored by the player. The behaviour of AUTO may be player specific. + // Valid input for service is "CC[1-4]", "TEXT[1-4]", "SERVICE[1-64]" + // @param service: Identifies the service to display e.g. "CC3". -+ virtual uint32_t setPreferredClosedCaptionService(const string& service /* @in */) = 0; ++ virtual uint32_t SetPreferredClosedCaptionService(const string& service /* @in */) = 0; + -+ // @alt getPreferredClosedCaptionService ++ // @text getPreferredClosedCaptionService + // @brief Gets the current PreferredClosedCaptionService setting. + // @param service: Identifies the service to display e.g. "CC3". -+ virtual uint32_t getPreferredClosedCaptionService(string &service /* @out */) const = 0; -+ -+ // @alt setPrivacyMode -+ // @brief Sets the PrivacyMode. -+ // @details The setting should be honored by the Telemetry. -+ // If privacyMode is "DO_NOT_SHARE", logs and crash report should not be uploaded. -+ // @param privacyMode: "SHARE", "DO_NOT_SHARE" -+ virtual uint32_t setPrivacyMode(const string& privacyMode /* @in @text privacyMode*/) = 0; -+ -+ // @alt getPrivacyMode -+ // @brief Gets the current PrivacyMode setting. -+ // @param privacyMode: "SHARE" -+ virtual uint32_t getPrivacyMode(string &privacyMode /* @out @text privacyMode */) const = 0; ++ virtual uint32_t GetPreferredClosedCaptionService(string &service /* @out */) const = 0; + -+ // @alt setPinControl ++ // @text setPinControl + // @brief Sets PinControl ON/OFF. Parental Control as a whole is enabled or disabled. + // @param enabled: Enabled/Disabled -+ virtual uint32_t setPinControl(const bool enabled /* @in */) = 0; ++ virtual uint32_t SetPinControl(const bool enabled /* @in */) = 0; + -+ // @alt getPinControl ++ // @text getPinControl + // @brief Gets the PinControl setting + // @param enabled: Enabled/Disabled -+ virtual uint32_t getPinControl(bool &enabled /* @out */) const = 0; ++ virtual uint32_t GetPinControl(bool &enabled /* @out */) const = 0; + -+ // @alt setViewingRestrictions ++ // @text setViewingRestrictions + // @brief Sets the ViewingRestrictions. + // @details A JSON document that escribes the rating scheme(s) and ratings that are blocked. + // @param viewingRestrictions: A JSON document that describes the rating scheme(s) and ratings that are blocked. -+ virtual uint32_t setViewingRestrictions(const string& viewingRestrictions /* @in @text viewingRestrictions */) = 0; ++ virtual uint32_t SetViewingRestrictions(const string& viewingRestrictions /* @in @text viewingRestrictions */) = 0; + -+ // @alt getViewingRestrictions ++ // @text getViewingRestrictions + // @brief Gets the current ViewingRestrictions. + // @param viewingRestrictions: A JSON document that escribes the rating scheme(s) and ratings that are blocked. -+ virtual uint32_t getViewingRestrictions(string &viewingRestrictions /* @out @text viewingRestrictions */) const = 0; ++ virtual uint32_t GetViewingRestrictions(string &viewingRestrictions /* @out @text viewingRestrictions */) const = 0; + -+ // @alt setViewingRestrictionsWindow ++ // @text setViewingRestrictionsWindow + // @brief Sets the ViewingRestrictionsWindow. + // @details A project-specific representation of the time interval when viewing + // restrictions are to be applied, if applicable for the project + // @param viewingRestrictionsWindow: A project-specific representation of the time interval.Eg: "ALWAYS" -+ virtual uint32_t setViewingRestrictionsWindow(const string &viewingRestrictionsWindow /* @in @text viewingRestrictionsWindow */) = 0; ++ virtual uint32_t SetViewingRestrictionsWindow(const string &viewingRestrictionsWindow /* @in @text viewingRestrictionsWindow */) = 0; + -+ // @alt getViewingRestrictionsWindow ++ // @text getViewingRestrictionsWindow + // @brief Gets the current ViewingRestrictionsWindow. + // @param viewingRestrictionsWindow: A project-specific representation of the time interval.Eg: "ALWAYS" -+ virtual uint32_t getViewingRestrictionsWindow(string &viewingRestrictionsWindow /* @out @text viewingRestrictionsWindow */) const = 0; ++ virtual uint32_t GetViewingRestrictionsWindow(string &viewingRestrictionsWindow /* @out @text viewingRestrictionsWindow */) const = 0; + -+ // @alt setLiveWatershed ++ // @text setLiveWatershed + // @brief Sets LiveWatershed ON/OFF.Whether project-specific watershed rules + // should be applied for live content, if applicable for the project. + // @param enabled: Enabled/Disabled -+ virtual uint32_t setLiveWatershed(const bool enabled /* @in */) = 0; ++ virtual uint32_t SetLiveWatershed(const bool enabled /* @in */) = 0; + -+ // @alt getLiveWatershed ++ // @text getLiveWatershed + // @brief Gets the LiveWatershed setting + // @param enabled: Enabled/Disabled -+ virtual uint32_t getLiveWatershed(bool &enabled /* @out */) const = 0; ++ virtual uint32_t GetLiveWatershed(bool &enabled /* @out */) const = 0; + -+ // @alt setPlaybackWatershed ++ // @text setPlaybackWatershed + // @brief Sets PlaybackWatershed ON/OFF. Whether project-specific watershed rules + // should be applied for non-live content, if applicable for the project. + // @param enabled: Enabled/Disabled -+ virtual uint32_t setPlaybackWatershed(const bool enabled /* @in */) = 0; ++ virtual uint32_t SetPlaybackWatershed(const bool enabled /* @in */) = 0; + -+ // @alt getPlaybackWatershed ++ // @text getPlaybackWatershed + // @brief Gets the PlaybackWatershed setting + // @param enabled: Enabled/Disabled -+ virtual uint32_t getPlaybackWatershed(bool &enabled /* @out */) const = 0; ++ virtual uint32_t GetPlaybackWatershed(bool &enabled /* @out */) const = 0; + -+ // @alt setBlockNotRatedContent ++ // @text setBlockNotRatedContent + // @brief Sets BlockNotRatedContent ON/OFF. Whether content that is not rated should be + // blocked, if applicable for the project. + // @param enabled: Enabled/Disabled -+ virtual uint32_t setBlockNotRatedContent(const bool enabled /* @in */) = 0; ++ virtual uint32_t SetBlockNotRatedContent(const bool enabled /* @in */) = 0; + -+ // @alt getBlockNotRatedContent ++ // @text getBlockNotRatedContent + // @brief Gets the BlockNotRatedContent setting + // @param enabled: Enabled/Disabled -+ virtual uint32_t getBlockNotRatedContent(bool &enabled /* @out */) const = 0; ++ virtual uint32_t GetBlockNotRatedContent(bool &enabled /* @out */) const = 0; + -+ // @alt setPinOnPurchase ++ // @text setPinOnPurchase + // @brief Sets PinOnPurchase ON/OFF.Whether a PIN challenge should be made + // when a purchase is attempted. + // @param enabled: Enabled/Disabled -+ virtual uint32_t setPinOnPurchase(const bool enabled /* @in */) = 0; ++ virtual uint32_t SetPinOnPurchase(const bool enabled /* @in */) = 0; + -+ // @alt getPinOnPurchase ++ // @text getPinOnPurchase + // @brief Gets the PinOnPurchase setting + // @param enabled: Enabled/Disabled -+ virtual uint32_t getPinOnPurchase(bool &enabled /* @out */) const = 0; ++ virtual uint32_t GetPinOnPurchase(bool &enabled /* @out */) const = 0; + +}; +} // namespace Exchange +} // namespace WPEFramework + -+ -+#ifndef SUPPORT_CAMEL_CASE_JSON_APIS -+ -+/* JUserSettings.h will be generated with auto generated tool and it is calling _impl_(object of IUserSettings.h) methods -+ starting with Capital letters,which will cause compilation error as IUserSettings interface method names are starting with -+ small letters. -+ To avoid the compilation error we have added below macros, which will replace method names as below in JUserSettings.h -+ Eg: Setxxxx replaced with setxxxx */ -+ -+/* Set and Get methods macros */ -+#define SetAudioDescription setAudioDescription -+#define GetAudioDescription getAudioDescription -+ -+#define SetPreferredAudioLanguages setPreferredAudioLanguages -+#define GetPreferredAudioLanguages getPreferredAudioLanguages -+ -+#define SetPresentationLanguage setPresentationLanguage -+#define GetPresentationLanguage getPresentationLanguage -+ -+#define SetCaptions setCaptions -+#define GetCaptions getCaptions -+ -+#define SetPreferredCaptionsLanguages setPreferredCaptionsLanguages -+#define GetPreferredCaptionsLanguages getPreferredCaptionsLanguages -+ -+#define SetPreferredClosedCaptionService setPreferredClosedCaptionService -+#define GetPreferredClosedCaptionService getPreferredClosedCaptionService -+ -+#define SetPrivacyMode setPrivacyMode -+#define GetPrivacyMode getPrivacyMode -+ -+#define SetPinControl setPinControl -+#define GetPinControl getPinControl -+ -+#define SetViewingRestrictions setViewingRestrictions -+#define GetViewingRestrictions getViewingRestrictions -+ -+#define SetViewingRestrictionsWindow setViewingRestrictionsWindow -+#define GetViewingRestrictionsWindow getViewingRestrictionsWindow -+ -+#define SetLiveWatershed setLiveWatershed -+#define GetLiveWatershed getLiveWatershed -+ -+#define SetPlaybackWatershed setPlaybackWatershed -+#define GetPlaybackWatershed getPlaybackWatershed -+ -+#define SetBlockNotRatedContent setBlockNotRatedContent -+#define GetBlockNotRatedContent getBlockNotRatedContent -+ -+#define SetPinOnPurchase setPinOnPurchase -+#define GetPinOnPurchase getPinOnPurchase -+ -+/* Event names macros*/ -+#define OnAudioDescriptionChanged onAudioDescriptionChanged -+#define OnPreferredAudioLanguagesChanged onPreferredAudioLanguagesChanged -+#define OnPresentationLanguageChanged onPresentationLanguageChanged -+#define OnCaptionsChanged onCaptionsChanged -+#define OnPreferredCaptionsLanguagesChanged onPreferredCaptionsLanguagesChanged -+#define OnPreferredClosedCaptionServiceChanged onPreferredClosedCaptionServiceChanged -+#define OnPrivacyModeChanged onPrivacyModeChanged -+#define OnPinControlChanged onPinControlChanged -+#define OnViewingRestrictionsChanged onViewingRestrictionsChanged -+#define OnViewingRestrictionsWindowChanged onViewingRestrictionsWindowChanged -+#define OnLiveWatershedChanged onLiveWatershedChanged -+#define OnPlaybackWatershedChanged onPlaybackWatershedChanged -+#define OnBlockNotRatedContentChanged onBlockNotRatedContentChanged -+#define OnPinOnPurchaseChanged onPinOnPurchaseChanged -+ -+#endif -+ diff --git a/interfaces/Ids.h b/interfaces/Ids.h index a37db24..293dd73 100644 --- a/interfaces/Ids.h diff --git a/Tests/L2Tests/patches/Use_Legact_Alt_Based_On_ThunderTools_R4.4.3.patch b/Tests/L2Tests/patches/Use_Legact_Alt_Based_On_ThunderTools_R4.4.3.patch new file mode 100755 index 0000000000..c5b4a36f6a --- /dev/null +++ b/Tests/L2Tests/patches/Use_Legact_Alt_Based_On_ThunderTools_R4.4.3.patch @@ -0,0 +1,20 @@ +commit 810aae64cb31c907698e468b615797750094b847 +Author: Pesala Lakshmi Jwala Priya +Date: Thu Aug 29 12:31:30 2024 +0530 + + Alt change + +diff --git a/Source/plugins/CMakeLists.txt b/Source/plugins/CMakeLists.txt +index 4d362d54..cdb53cdc 100644 +--- a/Source/plugins/CMakeLists.txt ++++ b/Source/plugins/CMakeLists.txt +@@ -29,7 +29,7 @@ ProxyStubGenerator(NAMESPACE "WPEFramework::PluginHost" INPUT "${CMAKE_CURRENT_S + ProxyStubGenerator(NAMESPACE "WPEFramework::PluginHost" INPUT "${CMAKE_CURRENT_SOURCE_DIR}/ISubSystem.h" OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/generated") + ProxyStubGenerator(NAMESPACE "WPEFramework::PluginHost" INPUT "${CMAKE_CURRENT_SOURCE_DIR}/IDispatcher.h" OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/generated") + +-JsonGenerator(CODE NAMESPACE WPEFramework::Exchange::Controller INPUT ${CMAKE_CURRENT_SOURCE_DIR}/IController.h OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/generated/jsonrpc" INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/.." NO_INCLUDES) ++JsonGenerator(CODE NAMESPACE WPEFramework::Exchange::Controller INPUT ${CMAKE_CURRENT_SOURCE_DIR}/IController.h OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/generated/jsonrpc" INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/.." NO_INCLUDES LEGACY_ALT) + + add_library(${TARGET} SHARED + Channel.cpp + diff --git a/Tests/L2Tests/patches/Use_Legact_Alt_In_ThunderInterfaces_Based_On_ThunderTools_R4.4.3.patch b/Tests/L2Tests/patches/Use_Legact_Alt_In_ThunderInterfaces_Based_On_ThunderTools_R4.4.3.patch new file mode 100755 index 0000000000..3078552785 --- /dev/null +++ b/Tests/L2Tests/patches/Use_Legact_Alt_In_ThunderInterfaces_Based_On_ThunderTools_R4.4.3.patch @@ -0,0 +1,22 @@ +commit f6fd38dcb9f2f1eaf5617119580957228231191c +Author: Pesala Lakshmi Jwala Priya +Date: Thu Aug 29 12:17:41 2024 +0530 + + R4.4.3_change + +diff --git a/definitions/CMakeLists.txt b/definitions/CMakeLists.txt +index adacc7b..53c5327 100644 +--- a/definitions/CMakeLists.txt ++++ b/definitions/CMakeLists.txt +@@ -49,8 +49,8 @@ if(NOT GENERATOR_SEARCH_PATH) + set(GENERATOR_SEARCH_PATH ${CMAKE_SYSROOT}${CMAKE_INSTALL_PREFIX}/include/${NAMESPACE}) + endif() + +-JsonGenerator(CODE INPUT ${JSON_FILE} OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/generated" INCLUDE_PATH ${GENERATOR_SEARCH_PATH} CPPIFDIR "${CMAKE_CURRENT_SOURCE_DIR}/../interfaces/") +-JsonGenerator(CODE INPUT ${INTERFACE_FILE} OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/generated" INCLUDE_PATH ${GENERATOR_SEARCH_PATH}) ++JsonGenerator(CODE INPUT ${JSON_FILE} OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/generated" INCLUDE_PATH ${GENERATOR_SEARCH_PATH} CPPIFDIR "${CMAKE_CURRENT_SOURCE_DIR}/../interfaces/" LEGACY_ALT) ++JsonGenerator(CODE INPUT ${INTERFACE_FILE} OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/generated" INCLUDE_PATH ${GENERATOR_SEARCH_PATH} LEGACY_ALT) + + file(GLOB JSON_ENUM_SOURCES "${CMAKE_CURRENT_BINARY_DIR}/generated/JsonEnum*.cpp") + file(GLOB JSON_LINK_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/generated/J*.h") + diff --git a/UserSettings/CMakeLists.txt b/UserSettings/CMakeLists.txt index 684b858580..0f38bb97e2 100755 --- a/UserSettings/CMakeLists.txt +++ b/UserSettings/CMakeLists.txt @@ -49,24 +49,7 @@ add_library(${PLUGIN_IMPLEMENTATION} SHARED UserSettingsImplementation.cpp Module.cpp) - -find_path(RBUS_API_HEADER NAMES rbus.h PATH_SUFFIXES rbus) - -if (NOT ${RBUS_API_HEADER} STREQUAL "RBUS_API_HEADER-NOTFOUND") - message("Found rbus.h ${RBUS_API_HEADER}") - add_definitions (-DHAS_RBUS) - set(RBUS_API_HEADERS ${RBUS_API_HEADER}) -find_library(RBUS_LIBRARY NAMES rbus) -endif() - -set(RBUS_LIBRARIES "") -if (NOT ${RBUS_LIBRARY} STREQUAL "RBUS_LIBRARY-NOTFOUND") - set(RBUS_LIBRARIES ${RBUS_LIBRARY}) -endif() - - include_directories( - ${RBUS_API_HEADERS} ../helpers) set_target_properties(${PLUGIN_IMPLEMENTATION} PROPERTIES @@ -86,8 +69,7 @@ endif (RDK_SERVICES_L2_TEST) target_link_libraries(${PLUGIN_IMPLEMENTATION} PRIVATE CompileSettingsDebug::CompileSettingsDebug - ${NAMESPACE}Plugins::${NAMESPACE}Plugins - ${RBUS_LIBRARIES}) + ${NAMESPACE}Plugins::${NAMESPACE}Plugins) install(TARGETS ${PLUGIN_IMPLEMENTATION} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/${STORAGE_DIRECTORY}/plugins) diff --git a/UserSettings/UserSettings.h b/UserSettings/UserSettings.h index af909930a6..c79c2a0952 100755 --- a/UserSettings/UserSettings.h +++ b/UserSettings/UserSettings.h @@ -68,85 +68,79 @@ namespace Plugin { _parent.Deactivated(connection); } - void onAudioDescriptionChanged(const bool enabled) override + void OnAudioDescriptionChanged(const bool enabled) override { LOGINFO("AudioDescriptionChanged: %d\n", enabled); Exchange::JUserSettings::Event::OnAudioDescriptionChanged(_parent, enabled); } - void onPreferredAudioLanguagesChanged(const string& preferredLanguages) override + void OnPreferredAudioLanguagesChanged(const string& preferredLanguages) override { LOGINFO("PreferredAudioLanguagesChanged: %s\n", preferredLanguages.c_str()); Exchange::JUserSettings::Event::OnPreferredAudioLanguagesChanged(_parent, preferredLanguages); } - void onPresentationLanguageChanged(const string& presentationLanguage) override + void OnPresentationLanguageChanged(const string& presentationLanguage) override { LOGINFO("PresentationLanguageChanged: %s\n", presentationLanguage.c_str()); Exchange::JUserSettings::Event::OnPresentationLanguageChanged(_parent, presentationLanguage); } - void onCaptionsChanged(bool enabled) override + void OnCaptionsChanged(bool enabled) override { LOGINFO("CaptionsChanged: %d\n", enabled); Exchange::JUserSettings::Event::OnCaptionsChanged(_parent, enabled); } - void onPreferredCaptionsLanguagesChanged(const string& preferredLanguages) override + void OnPreferredCaptionsLanguagesChanged(const string& preferredLanguages) override { LOGINFO("PreferredCaptionsLanguagesChanged: %s\n", preferredLanguages.c_str()); Exchange::JUserSettings::Event::OnPreferredCaptionsLanguagesChanged(_parent, preferredLanguages); } - void onPreferredClosedCaptionServiceChanged(const string& service) override + void OnPreferredClosedCaptionServiceChanged(const string& service) override { LOGINFO("PreferredClosedCaptionServiceChanged: %s\n", service.c_str()); Exchange::JUserSettings::Event::OnPreferredClosedCaptionServiceChanged(_parent, service); } - void onPrivacyModeChanged(const string &privacyMode) override - { - LOGINFO("PrivacyModeChanged: %s\n", privacyMode.c_str()); - Exchange::JUserSettings::Event::OnPrivacyModeChanged(_parent, privacyMode); - } - - void onPinControlChanged(const bool enabled) override + void OnPinControlChanged(const bool enabled) override { LOGINFO("PinControlChanged: %d\n", enabled); - Exchange::JUserSettings::Event::onPinControlChanged(_parent, enabled); + Exchange::JUserSettings::Event::OnPinControlChanged(_parent, enabled); } - void onViewingRestrictionsChanged(const string& viewingRestrictions) override + void OnViewingRestrictionsChanged(const string& viewingRestrictions) override { LOGINFO("ViewingRestrictionsChanged: %s\n", viewingRestrictions.c_str()); Exchange::JUserSettings::Event::OnViewingRestrictionsChanged(_parent, viewingRestrictions); } - void onViewingRestrictionsWindowChanged(const string& viewingRestrictionsWindow) override + void OnViewingRestrictionsWindowChanged(const string& viewingRestrictionsWindow) override { LOGINFO("ViewingRestrictionsWindowChanged: %s\n", viewingRestrictionsWindow.c_str()); Exchange::JUserSettings::Event::OnViewingRestrictionsWindowChanged(_parent, viewingRestrictionsWindow); } - void onLiveWatershedChanged(const bool enabled) override + void OnLiveWatershedChanged(const bool enabled) override { LOGINFO("LiveWatershedChanged: %d\n", enabled); Exchange::JUserSettings::Event::OnLiveWatershedChanged(_parent, enabled); } - void onPlaybackWatershedChanged(const bool enabled) override + void OnPlaybackWatershedChanged(const bool enabled) override { LOGINFO("PlaybackWatershedChanged: %d\n", enabled); Exchange::JUserSettings::Event::OnPlaybackWatershedChanged(_parent, enabled); } - void onBlockNotRatedContentChanged(const bool enabled) override + void OnBlockNotRatedContentChanged(const bool enabled) override { LOGINFO("BlockNotRatedContentChanged: %d\n", enabled); Exchange::JUserSettings::Event::OnBlockNotRatedContentChanged(_parent, enabled); } - void onPinOnPurchaseChanged(const bool enabled) override + void OnPinOnPurchaseChanged(const bool enabled) override { LOGINFO("PinOnPurchaseChanged: %d\n", enabled); Exchange::JUserSettings::Event::OnPinOnPurchaseChanged(_parent, enabled); diff --git a/UserSettings/UserSettings.json b/UserSettings/UserSettings.json index 4e462e8b4d..100e2e076d 100755 --- a/UserSettings/UserSettings.json +++ b/UserSettings/UserSettings.json @@ -160,27 +160,6 @@ "example": "null" } }, - "SetPrivacyMode": { - "summary": "Setting Privacy Mode.", - "events": { - "onPrivacyModeChanged" : "Triggered when the Privacy Mode changes." - }, - "params": { - "type": "object", - "properties": { - "privacyMode": { - "summary": "New Privacy Mode", - "type": "string", - "example": "DO_NOT_SHARE" - } - } - }, - "result": { - "summary": "On success null will be returned", - "type": "string", - "example": "null" - } - }, "setPinControl": { "summary": "Setting PinControl.", "events": { @@ -364,14 +343,6 @@ "$ref": "#/definitions/preferredClosedCaptionService" } }, - "getPrivacyMode":{ - "summary": "Getting Privacy Mode", - "result": { - "summary": "Current Privacy Mode", - "type": "string", - "example": "DO_NOT_SHARE" - } - }, "getPinControl":{ "summary": "Returns Pin Control.", "result": { @@ -522,22 +493,6 @@ ] } }, - "onPrivacyModeChanged": { - "summary": "Triggered after the Privacy Mode changes (see `SetPrivacyMode`)", - "params": { - "type": "object", - "properties": { - "privacyMode":{ - "summary": "Receive Privacy Mode changes", - "type": "string", - "example": "DO_NOT_SHARE" - } - }, - "required": [ - "privacyMode" - ] - } - }, "onPinControlChanged": { "summary": "Triggered after the pin control changes (see `setPinControl`)", "params": { diff --git a/UserSettings/UserSettingsImplementation.cpp b/UserSettings/UserSettingsImplementation.cpp index eb47d1d9d6..66a0182d43 100755 --- a/UserSettings/UserSettingsImplementation.cpp +++ b/UserSettings/UserSettingsImplementation.cpp @@ -23,10 +23,6 @@ #include #include "tracing/Logging.h" -#ifdef HAS_RBUS -#define RBUS_COMPONENT_NAME "UserSettingsThunderPlugin" -#define RBUS_PRIVACY_MODE_EVENT_NAME "Device.X_RDKCENTRAL-COM_UserSettings.PrivacyModeChanged" -#endif namespace WPEFramework { namespace Plugin { @@ -55,9 +51,6 @@ UserSettingsImplementation::UserSettingsImplementation() , _remotStoreObject(nullptr) , _storeNotification(*this) , _registeredEventHandlers(false) -#ifdef HAS_RBUS -, _rbusHandleStatus(RBUS_ERROR_NOT_INITIALIZED) -#endif { LOGINFO("Create UserSettingsImplementation Instance"); @@ -135,15 +128,6 @@ UserSettingsImplementation::~UserSettingsImplementation() _remotStoreObject->Release(); } _registeredEventHandlers = false; - -#ifdef HAS_RBUS - if (RBUS_ERROR_SUCCESS == _rbusHandleStatus) - { - rbus_close(_rbusHandle); - _rbusHandleStatus = RBUS_ERROR_NOT_INITIALIZED; - } - -#endif } void UserSettingsImplementation::registerEventHandlers() @@ -223,7 +207,7 @@ void UserSettingsImplementation::Dispatch(Event event, const JsonValue params) case AUDIO_DESCRIPTION_CHANGED: while (index != _userSettingNotification.end()) { - (*index)->onAudioDescriptionChanged(params.Boolean()); + (*index)->OnAudioDescriptionChanged(params.Boolean()); ++index; } break; @@ -231,7 +215,7 @@ void UserSettingsImplementation::Dispatch(Event event, const JsonValue params) case PREFERRED_AUDIO_CHANGED: while (index != _userSettingNotification.end()) { - (*index)->onPreferredAudioLanguagesChanged(params.String()); + (*index)->OnPreferredAudioLanguagesChanged(params.String()); ++index; } break; @@ -239,7 +223,7 @@ void UserSettingsImplementation::Dispatch(Event event, const JsonValue params) case PRESENTATION_LANGUAGE_CHANGED: while (index != _userSettingNotification.end()) { - (*index)->onPresentationLanguageChanged(params.String()); + (*index)->OnPresentationLanguageChanged(params.String()); ++index; } break; @@ -247,7 +231,7 @@ void UserSettingsImplementation::Dispatch(Event event, const JsonValue params) case CAPTIONS_CHANGED: while (index != _userSettingNotification.end()) { - (*index)->onCaptionsChanged(params.Boolean()); + (*index)->OnCaptionsChanged(params.Boolean()); ++index; } break; @@ -255,7 +239,7 @@ void UserSettingsImplementation::Dispatch(Event event, const JsonValue params) case PREFERRED_CAPTIONS_LANGUAGE_CHANGED: while (index != _userSettingNotification.end()) { - (*index)->onPreferredCaptionsLanguagesChanged(params.String()); + (*index)->OnPreferredCaptionsLanguagesChanged(params.String()); ++index; } break; @@ -263,15 +247,7 @@ void UserSettingsImplementation::Dispatch(Event event, const JsonValue params) case PREFERRED_CLOSED_CAPTIONS_SERVICE_CHANGED: while (index != _userSettingNotification.end()) { - (*index)->onPreferredClosedCaptionServiceChanged(params.String()); - ++index; - } - break; - - case PRIVACY_MODE_CHANGED: - while (index != _userSettingNotification.end()) - { - (*index)->onPrivacyModeChanged(params.String()); + (*index)->OnPreferredClosedCaptionServiceChanged(params.String()); ++index; } break; @@ -279,7 +255,7 @@ void UserSettingsImplementation::Dispatch(Event event, const JsonValue params) case PIN_CONTROL_CHANGED: while (index != _userSettingNotification.end()) { - (*index)->onPinControlChanged(params.Boolean()); + (*index)->OnPinControlChanged(params.Boolean()); ++index; } break; @@ -287,7 +263,7 @@ void UserSettingsImplementation::Dispatch(Event event, const JsonValue params) case VIEWING_RESTRICTIONS_CHANGED: while (index != _userSettingNotification.end()) { - (*index)->onViewingRestrictionsChanged(params.String()); + (*index)->OnViewingRestrictionsChanged(params.String()); ++index; } break; @@ -295,7 +271,7 @@ void UserSettingsImplementation::Dispatch(Event event, const JsonValue params) case VIEWING_RESTRICTIONS_WINDOW_CHANGED: while (index != _userSettingNotification.end()) { - (*index)->onViewingRestrictionsWindowChanged(params.String()); + (*index)->OnViewingRestrictionsWindowChanged(params.String()); ++index; } break; @@ -303,7 +279,7 @@ void UserSettingsImplementation::Dispatch(Event event, const JsonValue params) case LIVE_WATERSHED_CHANGED: while (index != _userSettingNotification.end()) { - (*index)->onLiveWatershedChanged(params.Boolean()); + (*index)->OnLiveWatershedChanged(params.Boolean()); ++index; } break; @@ -311,7 +287,7 @@ void UserSettingsImplementation::Dispatch(Event event, const JsonValue params) case PLAYBACK_WATERSHED_CHANGED: while (index != _userSettingNotification.end()) { - (*index)->onPlaybackWatershedChanged(params.Boolean()); + (*index)->OnPlaybackWatershedChanged(params.Boolean()); ++index; } break; @@ -319,7 +295,7 @@ void UserSettingsImplementation::Dispatch(Event event, const JsonValue params) case BLOCK_NOT_RATED_CONTENT_CHANGED: while (index != _userSettingNotification.end()) { - (*index)->onBlockNotRatedContentChanged(params.Boolean()); + (*index)->OnBlockNotRatedContentChanged(params.Boolean()); ++index; } break; @@ -327,7 +303,7 @@ void UserSettingsImplementation::Dispatch(Event event, const JsonValue params) case PIN_ON_PURCHASE_CHANGED: while (index != _userSettingNotification.end()) { - (*index)->onPinOnPurchaseChanged(params.Boolean()); + (*index)->OnPinOnPurchaseChanged(params.Boolean()); ++index; } break; @@ -367,10 +343,6 @@ void UserSettingsImplementation::ValueChanged(const Exchange::IStore2::ScopeType { dispatchEvent(PREFERRED_CLOSED_CAPTIONS_SERVICE_CHANGED, JsonValue((string)value)); } - else if((ns.compare(USERSETTINGS_NAMESPACE) == 0) && (key.compare(USERSETTINGS_PRIVACY_MODE_KEY) == 0)) - { - dispatchEvent(PRIVACY_MODE_CHANGED, JsonValue((string)value)); - } else if((ns.compare(USERSETTINGS_NAMESPACE) == 0) && (key.compare(USERSETTINGS_PIN_CONTROL_KEY) == 0)) { dispatchEvent(PIN_CONTROL_CHANGED, JsonValue((bool)(value.compare("true")==0)?true:false)); @@ -450,7 +422,7 @@ uint32_t UserSettingsImplementation::GetUserSettingsValue(const string& key, str return status; } -uint32_t UserSettingsImplementation::setAudioDescription(const bool enabled) +uint32_t UserSettingsImplementation::SetAudioDescription(const bool enabled) { uint32_t status = Core::ERROR_GENERAL; @@ -459,7 +431,7 @@ uint32_t UserSettingsImplementation::setAudioDescription(const bool enabled) return status; } -uint32_t UserSettingsImplementation::getAudioDescription(bool &enabled) const +uint32_t UserSettingsImplementation::GetAudioDescription(bool &enabled) const { uint32_t status = Core::ERROR_GENERAL; std::string value = ""; @@ -480,7 +452,7 @@ uint32_t UserSettingsImplementation::getAudioDescription(bool &enabled) const return status; } -uint32_t UserSettingsImplementation::setPreferredAudioLanguages(const string& preferredLanguages) +uint32_t UserSettingsImplementation::SetPreferredAudioLanguages(const string& preferredLanguages) { uint32_t status = Core::ERROR_GENERAL; @@ -489,7 +461,7 @@ uint32_t UserSettingsImplementation::setPreferredAudioLanguages(const string& pr return status; } -uint32_t UserSettingsImplementation::getPreferredAudioLanguages(string &preferredLanguages) const +uint32_t UserSettingsImplementation::GetPreferredAudioLanguages(string &preferredLanguages) const { uint32_t status = Core::ERROR_GENERAL; std::string value = ""; @@ -498,7 +470,7 @@ uint32_t UserSettingsImplementation::getPreferredAudioLanguages(string &preferre return status; } -uint32_t UserSettingsImplementation::setPresentationLanguage(const string& presentationLanguage) +uint32_t UserSettingsImplementation::SetPresentationLanguage(const string& presentationLanguage) { uint32_t status = Core::ERROR_GENERAL; @@ -507,7 +479,7 @@ uint32_t UserSettingsImplementation::setPresentationLanguage(const string& prese return status; } -uint32_t UserSettingsImplementation::getPresentationLanguage(string &presentationLanguage) const +uint32_t UserSettingsImplementation::GetPresentationLanguage(string &presentationLanguage) const { uint32_t status = Core::ERROR_GENERAL; std::string value = ""; @@ -516,7 +488,7 @@ uint32_t UserSettingsImplementation::getPresentationLanguage(string &presentatio return status; } -uint32_t UserSettingsImplementation::setCaptions(const bool enabled) +uint32_t UserSettingsImplementation::SetCaptions(const bool enabled) { uint32_t status = Core::ERROR_GENERAL; @@ -525,7 +497,7 @@ uint32_t UserSettingsImplementation::setCaptions(const bool enabled) return status; } -uint32_t UserSettingsImplementation::getCaptions(bool &enabled) const +uint32_t UserSettingsImplementation::GetCaptions(bool &enabled) const { uint32_t status = Core::ERROR_GENERAL; std::string value = ""; @@ -546,7 +518,7 @@ uint32_t UserSettingsImplementation::getCaptions(bool &enabled) const return status; } -uint32_t UserSettingsImplementation::setPreferredCaptionsLanguages(const string& preferredLanguages) +uint32_t UserSettingsImplementation::SetPreferredCaptionsLanguages(const string& preferredLanguages) { uint32_t status = Core::ERROR_GENERAL; @@ -555,7 +527,7 @@ uint32_t UserSettingsImplementation::setPreferredCaptionsLanguages(const string& return status; } -uint32_t UserSettingsImplementation::getPreferredCaptionsLanguages(string &preferredLanguages) const +uint32_t UserSettingsImplementation::GetPreferredCaptionsLanguages(string &preferredLanguages) const { uint32_t status = Core::ERROR_GENERAL; std::string value = ""; @@ -564,7 +536,7 @@ uint32_t UserSettingsImplementation::getPreferredCaptionsLanguages(string &prefe return status; } -uint32_t UserSettingsImplementation::setPreferredClosedCaptionService(const string& service) +uint32_t UserSettingsImplementation::SetPreferredClosedCaptionService(const string& service) { uint32_t status = Core::ERROR_GENERAL; @@ -573,7 +545,7 @@ uint32_t UserSettingsImplementation::setPreferredClosedCaptionService(const stri return status; } -uint32_t UserSettingsImplementation::getPreferredClosedCaptionService(string &service) const +uint32_t UserSettingsImplementation::GetPreferredClosedCaptionService(string &service) const { uint32_t status = Core::ERROR_GENERAL; std::string value = ""; @@ -582,100 +554,7 @@ uint32_t UserSettingsImplementation::getPreferredClosedCaptionService(string &se return status; } -uint32_t UserSettingsImplementation::setPrivacyMode(const string& privacyMode) -{ - uint32_t status = Core::ERROR_GENERAL; - - LOGINFO("privacyMode: %s", privacyMode.c_str()); - - if (privacyMode != "SHARE" && privacyMode != "DO_NOT_SHARE") - { - LOGERR("Wrong privacyMode value: '%s', returning default", privacyMode.c_str()); - return status; - } - - _adminLock.Lock(); - - ASSERT (nullptr != _remotStoreObject); - - if (nullptr != _remotStoreObject) - { - uint32_t ttl = 0; - string oldPrivacyMode; - status = _remotStoreObject->GetValue(Exchange::IStore2::ScopeType::DEVICE, USERSETTINGS_NAMESPACE, USERSETTINGS_PRIVACY_MODE_KEY, oldPrivacyMode, ttl); - LOGINFO("oldPrivacyMode: %s", oldPrivacyMode.c_str()); - - if (privacyMode != oldPrivacyMode) - { -#ifdef HAS_RBUS - if (Core::ERROR_NONE == status) - { - if (RBUS_ERROR_SUCCESS != _rbusHandleStatus) - { - _rbusHandleStatus = rbus_open(&_rbusHandle, RBUS_COMPONENT_NAME); - } - - if (RBUS_ERROR_SUCCESS == _rbusHandleStatus) - { - rbusValue_t value; - rbusSetOptions_t opts = {true, 0}; - - rbusValue_Init(&value); - rbusValue_SetString(value, privacyMode.c_str()); - int rc = rbus_set(_rbusHandle, RBUS_PRIVACY_MODE_EVENT_NAME, value, &opts); - if (rc != RBUS_ERROR_SUCCESS) - { - std::stringstream str; - str << "Failed to set property " << RBUS_PRIVACY_MODE_EVENT_NAME << ": " << rc; - LOGERR("%s", str.str().c_str()); - } - rbusValue_Release(value); - } - else - { - std::stringstream str; - str << "rbus_open failed with error code " << _rbusHandleStatus; - LOGERR("%s", str.str().c_str()); - } - } -#endif - status = _remotStoreObject->SetValue(Exchange::IStore2::ScopeType::DEVICE, USERSETTINGS_NAMESPACE, USERSETTINGS_PRIVACY_MODE_KEY, privacyMode, 0); - } - } - - _adminLock.Unlock(); - - return status; -} - -uint32_t UserSettingsImplementation::getPrivacyMode(string &privacyMode) const -{ - uint32_t status = Core::ERROR_NONE; - std::string value = ""; - uint32_t ttl = 0; - privacyMode = ""; - - _adminLock.Lock(); - - ASSERT (nullptr != _remotStoreObject); - - if (nullptr != _remotStoreObject) - { - _remotStoreObject->GetValue(Exchange::IStore2::ScopeType::DEVICE, USERSETTINGS_NAMESPACE, USERSETTINGS_PRIVACY_MODE_KEY, privacyMode, ttl); - } - - _adminLock.Unlock(); - - if (privacyMode != "SHARE" && privacyMode != "DO_NOT_SHARE") - { - LOGWARN("Wrong privacyMode value: '%s', returning default", privacyMode.c_str()); - privacyMode = "SHARE"; - } - - return status; -} - -uint32_t UserSettingsImplementation::setPinControl(const bool enabled) +uint32_t UserSettingsImplementation::SetPinControl(const bool enabled) { uint32_t status = Core::ERROR_GENERAL; @@ -684,7 +563,7 @@ uint32_t UserSettingsImplementation::setPinControl(const bool enabled) return status; } -uint32_t UserSettingsImplementation::getPinControl(bool &enabled) const +uint32_t UserSettingsImplementation::GetPinControl(bool &enabled) const { uint32_t status = Core::ERROR_GENERAL; std::string value = ""; @@ -706,7 +585,7 @@ uint32_t UserSettingsImplementation::getPinControl(bool &enabled) const } -uint32_t UserSettingsImplementation::setViewingRestrictions(const string& viewingRestrictions) +uint32_t UserSettingsImplementation::SetViewingRestrictions(const string& viewingRestrictions) { uint32_t status = Core::ERROR_GENERAL; @@ -716,7 +595,7 @@ uint32_t UserSettingsImplementation::setViewingRestrictions(const string& viewin } -uint32_t UserSettingsImplementation::getViewingRestrictions(string &viewingRestrictions) const +uint32_t UserSettingsImplementation::GetViewingRestrictions(string &viewingRestrictions) const { uint32_t status = Core::ERROR_GENERAL; @@ -725,7 +604,7 @@ uint32_t UserSettingsImplementation::getViewingRestrictions(string &viewingRestr } -uint32_t UserSettingsImplementation::setViewingRestrictionsWindow(const string& viewingRestrictionsWindow) +uint32_t UserSettingsImplementation::SetViewingRestrictionsWindow(const string& viewingRestrictionsWindow) { uint32_t status = Core::ERROR_GENERAL; @@ -735,7 +614,7 @@ uint32_t UserSettingsImplementation::setViewingRestrictionsWindow(const string& } -uint32_t UserSettingsImplementation::getViewingRestrictionsWindow(string &viewingRestrictionsWindow) const +uint32_t UserSettingsImplementation::GetViewingRestrictionsWindow(string &viewingRestrictionsWindow) const { uint32_t status = Core::ERROR_GENERAL; @@ -743,7 +622,7 @@ uint32_t UserSettingsImplementation::getViewingRestrictionsWindow(string &viewin return status; } -uint32_t UserSettingsImplementation::setLiveWatershed(const bool enabled) +uint32_t UserSettingsImplementation::SetLiveWatershed(const bool enabled) { uint32_t status = Core::ERROR_GENERAL; @@ -753,7 +632,7 @@ uint32_t UserSettingsImplementation::setLiveWatershed(const bool enabled) } -uint32_t UserSettingsImplementation::getLiveWatershed(bool &enabled) const +uint32_t UserSettingsImplementation::GetLiveWatershed(bool &enabled) const { uint32_t status = Core::ERROR_GENERAL; std::string value = ""; @@ -774,7 +653,7 @@ uint32_t UserSettingsImplementation::getLiveWatershed(bool &enabled) const return status; } -uint32_t UserSettingsImplementation::setPlaybackWatershed(const bool enabled) +uint32_t UserSettingsImplementation::SetPlaybackWatershed(const bool enabled) { uint32_t status = Core::ERROR_GENERAL; @@ -783,7 +662,7 @@ uint32_t UserSettingsImplementation::setPlaybackWatershed(const bool enabled) return status; } -uint32_t UserSettingsImplementation::getPlaybackWatershed(bool &enabled) const +uint32_t UserSettingsImplementation::GetPlaybackWatershed(bool &enabled) const { uint32_t status = Core::ERROR_GENERAL; std::string value = ""; @@ -804,7 +683,7 @@ uint32_t UserSettingsImplementation::getPlaybackWatershed(bool &enabled) const return status; } -uint32_t UserSettingsImplementation::setBlockNotRatedContent(const bool enabled) +uint32_t UserSettingsImplementation::SetBlockNotRatedContent(const bool enabled) { uint32_t status = Core::ERROR_GENERAL; @@ -813,7 +692,7 @@ uint32_t UserSettingsImplementation::setBlockNotRatedContent(const bool enabled) return status; } -uint32_t UserSettingsImplementation::getBlockNotRatedContent(bool &enabled) const +uint32_t UserSettingsImplementation::GetBlockNotRatedContent(bool &enabled) const { uint32_t status = Core::ERROR_GENERAL; std::string value = ""; @@ -834,7 +713,7 @@ uint32_t UserSettingsImplementation::getBlockNotRatedContent(bool &enabled) cons return status; } -uint32_t UserSettingsImplementation::setPinOnPurchase(const bool enabled) +uint32_t UserSettingsImplementation::SetPinOnPurchase(const bool enabled) { uint32_t status = Core::ERROR_GENERAL; @@ -843,7 +722,7 @@ uint32_t UserSettingsImplementation::setPinOnPurchase(const bool enabled) return status; } -uint32_t UserSettingsImplementation::getPinOnPurchase(bool &enabled) const +uint32_t UserSettingsImplementation::GetPinOnPurchase(bool &enabled) const { uint32_t status = Core::ERROR_GENERAL; std::string value = ""; diff --git a/UserSettings/UserSettingsImplementation.h b/UserSettings/UserSettingsImplementation.h index b71678e544..70412a5104 100755 --- a/UserSettings/UserSettingsImplementation.h +++ b/UserSettings/UserSettingsImplementation.h @@ -30,10 +30,6 @@ #include #include -#ifdef HAS_RBUS -#include "rbus.h" -#endif - #define USERSETTINGS_NAMESPACE "UserSettings" #define USERSETTINGS_AUDIO_DESCRIPTION_KEY "audioDescription" @@ -42,7 +38,6 @@ #define USERSETTINGS_CAPTIONS_KEY "captions" #define USERSETTINGS_PREFERRED_CAPTIONS_LANGUAGES_KEY "preferredCaptionsLanguages" #define USERSETTINGS_PREFERRED_CLOSED_CAPTIONS_SERVICE_KEY "preferredClosedCaptionsService" -#define USERSETTINGS_PRIVACY_MODE_KEY "privacyMode" #define USERSETTINGS_PIN_CONTROL_KEY "pinControl" #define USERSETTINGS_VIEWING_RESTRICTIONS_KEY "viewingRestrictions" #define USERSETTINGS_VIEWING_RESTRICTIONS_WINDOW_KEY "viewingRestrictionsWindow" @@ -108,7 +103,6 @@ namespace Plugin { CAPTIONS_CHANGED, PREFERRED_CAPTIONS_LANGUAGE_CHANGED, PREFERRED_CLOSED_CAPTIONS_SERVICE_CHANGED, - PRIVACY_MODE_CHANGED, PIN_CONTROL_CHANGED, VIEWING_RESTRICTIONS_CHANGED, VIEWING_RESTRICTIONS_WINDOW_CHANGED, @@ -160,34 +154,32 @@ namespace Plugin { public: virtual uint32_t Register(Exchange::IUserSettings::INotification *notification ) override ; virtual uint32_t Unregister(Exchange::IUserSettings::INotification *notification ) override ; - uint32_t setAudioDescription(const bool enabled) override; - uint32_t getAudioDescription(bool &enabled) const override; - uint32_t setPreferredAudioLanguages(const string& preferredLanguages) override; - uint32_t getPreferredAudioLanguages(string &preferredLanguages) const override; - uint32_t setPresentationLanguage(const string& presentationLanguage) override; - uint32_t getPresentationLanguage(string &presentationLanguage) const override; - uint32_t setCaptions(const bool enabled) override; - uint32_t getCaptions(bool &enabled) const override; - uint32_t setPreferredCaptionsLanguages(const string& preferredLanguages) override; - uint32_t getPreferredCaptionsLanguages(string &preferredLanguages) const override; - uint32_t setPreferredClosedCaptionService(const string& service) override; - uint32_t getPreferredClosedCaptionService(string &service) const override; - uint32_t setPrivacyMode(const string& privacyMode) override; - uint32_t getPrivacyMode(string &privacyMode) const override; - uint32_t setPinControl(const bool enabled) override; - uint32_t getPinControl(bool &enabled) const override; - uint32_t setViewingRestrictions(const string& viewingRestrictions) override; - uint32_t getViewingRestrictions(string &viewingRestrictions) const override; - uint32_t setViewingRestrictionsWindow(const string& viewingRestrictionsWindow) override; - uint32_t getViewingRestrictionsWindow(string &viewingRestrictionsWindow) const override; - uint32_t setLiveWatershed(const bool enabled) override; - uint32_t getLiveWatershed(bool &enabled) const override; - uint32_t setPlaybackWatershed(const bool enabled) override; - uint32_t getPlaybackWatershed(bool &enabled) const override; - uint32_t setBlockNotRatedContent(const bool enabled) override; - uint32_t getBlockNotRatedContent(bool &enabled) const override; - uint32_t setPinOnPurchase(const bool enabled) override; - uint32_t getPinOnPurchase(bool &enabled) const override; + uint32_t SetAudioDescription(const bool enabled) override; + uint32_t GetAudioDescription(bool &enabled) const override; + uint32_t SetPreferredAudioLanguages(const string& preferredLanguages) override; + uint32_t GetPreferredAudioLanguages(string &preferredLanguages) const override; + uint32_t SetPresentationLanguage(const string& presentationLanguage) override; + uint32_t GetPresentationLanguage(string &presentationLanguage) const override; + uint32_t SetCaptions(const bool enabled) override; + uint32_t GetCaptions(bool &enabled) const override; + uint32_t SetPreferredCaptionsLanguages(const string& preferredLanguages) override; + uint32_t GetPreferredCaptionsLanguages(string &preferredLanguages) const override; + uint32_t SetPreferredClosedCaptionService(const string& service) override; + uint32_t GetPreferredClosedCaptionService(string &service) const override; + uint32_t SetPinControl(const bool enabled) override; + uint32_t GetPinControl(bool &enabled) const override; + uint32_t SetViewingRestrictions(const string& viewingRestrictions) override; + uint32_t GetViewingRestrictions(string &viewingRestrictions) const override; + uint32_t SetViewingRestrictionsWindow(const string& viewingRestrictionsWindow) override; + uint32_t GetViewingRestrictionsWindow(string &viewingRestrictionsWindow) const override; + uint32_t SetLiveWatershed(const bool enabled) override; + uint32_t GetLiveWatershed(bool &enabled) const override; + uint32_t SetPlaybackWatershed(const bool enabled) override; + uint32_t GetPlaybackWatershed(bool &enabled) const override; + uint32_t SetBlockNotRatedContent(const bool enabled) override; + uint32_t GetBlockNotRatedContent(bool &enabled) const override; + uint32_t SetPinOnPurchase(const bool enabled) override; + uint32_t GetPinOnPurchase(bool &enabled) const override; void registerEventHandlers(); void ValueChanged(const Exchange::IStore2::ScopeType scope, const string& ns, const string& key, const string& value); @@ -206,10 +198,6 @@ namespace Plugin { Core::Sink _storeNotification; bool _registeredEventHandlers; -#ifdef HAS_RBUS - rbusError_t _rbusHandleStatus; - rbusHandle_t _rbusHandle; -#endif void dispatchEvent(Event, const JsonValue ¶ms); void Dispatch(Event event, const JsonValue params); diff --git a/WebKitBrowser/Extension/main.cpp b/WebKitBrowser/Extension/main.cpp index 8f9ccd6531..ca13c9b46c 100644 --- a/WebKitBrowser/Extension/main.cpp +++ b/WebKitBrowser/Extension/main.cpp @@ -148,6 +148,12 @@ static class PluginHost { #if defined(UPDATE_TZ_FROM_FILE) _tzSupport.Deinitialize(); #endif + +#ifdef __CORE_MESSAGING__ + // Messaging has to be destroyed before Singletons are disposed. + // We are not inside WPEProcess so need to do it manually. + Messaging::MessageUnit::Instance().Close(); +#endif if (_comClient.IsValid() == true) { _comClient.Release(); } diff --git a/WebKitBrowser/WebKitImplementation.cpp b/WebKitBrowser/WebKitImplementation.cpp index 2f4b0b0b96..924a92c221 100644 --- a/WebKitBrowser/WebKitImplementation.cpp +++ b/WebKitBrowser/WebKitImplementation.cpp @@ -364,6 +364,13 @@ static GSourceFuncs _handlerIntervention = if (implementation != nullptr) { delete implementation; implementation = nullptr; +#ifdef __CORE_MESSAGING__ + // Messaging has to be destroyed before Singletons are disposed. + // WPEProcess will usually take care of this at the end of its main() func, + // but beeing here suggests that something went wrong and possibly + // we are closing with exit() func (from postExitJob()) + Messaging::MessageUnit::Instance().Close(); +#endif } } diff --git a/docs/api/SystemPlugin.md b/docs/api/SystemPlugin.md index b2a040ce97..51e1851a9e 100644 --- a/docs/api/SystemPlugin.md +++ b/docs/api/SystemPlugin.md @@ -2,7 +2,7 @@ # System API -**Version: [2.3.2](https://github.com/rdkcentral/rdkservices/blob/main/SystemServices/CHANGELOG.md)** +**Version: [1.0.0]()** A org.rdk.System plugin for Thunder framework. @@ -114,6 +114,8 @@ org.rdk.System interface methods: | [uploadLogsAsync](#method.uploadLogsAsync) | Starts background process to upload logs | | [abortLogUpload](#method.abortLogUpload) | Stops background process to upload logs | | [getThunderStartReason](#method.getThunderStartReason) | Returns the Thunder start reason | +| [SetPrivacyMode](#method.SetPrivacyMode) | Setting Privacy Mode | +| [getPrivacyMode](#method.getPrivacyMode) | Getting Privacy Mode | @@ -3633,6 +3635,95 @@ This method takes no parameters. } ``` + +## *SetPrivacyMode [method](#head.Methods)* + +Setting Privacy Mode. + +### Events + +| Event | Description | +| :-------- | :-------- | +| [onPrivacyModeChanged](#event.onPrivacyModeChanged) | Triggered when the Privacy Mode changes. | +### Parameters + +| Name | Type | Description | +| :-------- | :-------- | :-------- | +| params | object | | +| params.privacyMode | string | New Privacy Mode | + +### Result + +| Name | Type | Description | +| :-------- | :-------- | :-------- | +| result | string | On success null will be returned | + +### Example + +#### Request + +```json +{ + "jsonrpc": "2.0", + "id": 42, + "method": "org.rdk.System.SetPrivacyMode", + "params": { + "privacyMode": "DO_NOT_SHARE" + } +} +``` + +#### Response + +```json +{ + "jsonrpc": "2.0", + "id": 42, + "result": "null" +} +``` + + +## *getPrivacyMode [method](#head.Methods)* + +Getting Privacy Mode. + +### Events + +No Events + +### Parameters + +This method takes no parameters. + +### Result + +| Name | Type | Description | +| :-------- | :-------- | :-------- | +| result | string | Current Privacy Mode | + +### Example + +#### Request + +```json +{ + "jsonrpc": "2.0", + "id": 42, + "method": "org.rdk.System.getPrivacyMode" +} +``` + +#### Response + +```json +{ + "jsonrpc": "2.0", + "id": 42, + "result": "DO_NOT_SHARE" +} +``` + # Notifications @@ -3662,8 +3753,12 @@ State details are: | [onFriendlyNameChanged](#event.onFriendlyNameChanged) | Triggered when the device friendly name change | | [onTemperatureThresholdChanged](#event.onTemperatureThresholdChanged) | Triggered when the device temperature changes beyond the `WARN` or `MAX` limits (see `setTemperatureThresholds`) | | [onTerritoryChanged](#event.onTerritoryChanged) | Triggered when the device territory changed | +| [onDeviceMgtUpdateReceived](#event.onDeviceMgtUpdateReceived) | Triggered when the device management update completes | | [onTimeZoneDSTChanged](#event.onTimeZoneDSTChanged) | Triggered when device time zone changed | | [onLogUpload](#event.onLogUpload) | Triggered when logs upload process is done or stopped | +| [onPrivacyModeChanged](#event.onPrivacyModeChanged) | Triggered after the Privacy Mode changes (see `SetPrivacyMode`) | +| [setFSRFlag](#event.setFSRFlag) | Set the FSR flag into the emmc raw area | +| [getFSRFlag](#event.getFSRFlag) | Get the FSR flag from the emmc raw area | @@ -4034,6 +4129,34 @@ Triggered when the device territory changed. } ``` + +## *onDeviceMgtUpdateReceived [event](#head.Notifications)* + +Triggered when the device management update completes. + +### Parameters + +| Name | Type | Description | +| :-------- | :-------- | :-------- | +| params | object | | +| params.source | string | Source information from where the event on update is posted | +| params.type | string | Type of Update received currently it will be used as initial | +| params.success | boolean | Status information of update whether success or failure | + +### Example + +```json +{ + "jsonrpc": "2.0", + "method": "client.events.onDeviceMgtUpdateReceived", + "params": { + "source": "rfc", + "type": "initial", + "success": true + } +} +``` + ## *onTimeZoneDSTChanged [event](#head.Notifications)* @@ -4088,3 +4211,79 @@ Triggered when logs upload process is done or stopped. } ``` + +## *onPrivacyModeChanged [event](#head.Notifications)* + +Triggered after the Privacy Mode changes (see `SetPrivacyMode`). + +### Parameters + +| Name | Type | Description | +| :-------- | :-------- | :-------- | +| params | object | | +| params.privacyMode | string | Receive Privacy Mode changes | + +### Example + +```json +{ + "jsonrpc": "2.0", + "method": "client.events.onPrivacyModeChanged", + "params": { + "privacyMode": "DO_NOT_SHARE" + } +} +``` + + +## *setFSRFlag [event](#head.Notifications)* + +Set the FSR flag into the emmc raw area. + +### Parameters + +This event carries no parameters. + +### Result + +| Name | Type | Description | +| :-------- | :-------- | :-------- | +| result | object | | +| result.fsrFlag | boolean | FSR flag | +| result.success | boolean | Whether the request succeeded | + +### Example + +```json +{ + "jsonrpc": "2.0", + "method": "client.events.setFSRFlag" +} +``` + + +## *getFSRFlag [event](#head.Notifications)* + +Get the FSR flag from the emmc raw area. + +### Parameters + +This event carries no parameters. + +### Result + +| Name | Type | Description | +| :-------- | :-------- | :-------- | +| result | object | | +| result.fsrFlag | boolean | FSR flag | +| result.success | boolean | Whether the request succeeded | + +### Example + +```json +{ + "jsonrpc": "2.0", + "method": "client.events.getFSRFlag" +} +``` + diff --git a/docs/api/UserSettingsPlugin.md b/docs/api/UserSettingsPlugin.md index 8c2be2914a..4d76f6748d 100644 --- a/docs/api/UserSettingsPlugin.md +++ b/docs/api/UserSettingsPlugin.md @@ -1,8 +1,8 @@ - -# UserSettings Plugin + +# UserSettings API -**Version: [1.0.0](https://github.com/rdkcentral/rdkservices/blob/main/UserSettings/CHANGELOG.md)** +**Version: [1.0.0]()** A org.rdk.UserSettings plugin for Thunder framework. @@ -22,7 +22,7 @@ A org.rdk.UserSettings plugin for Thunder framework. # Description -The `UserSettings` that is responsible for persisting and notifying listeners of any change of these settings. +The `UserSettings`, that is responsible for persisting and notifying listeners of any change of these settings.. The plugin is designed to be loaded and executed within the Thunder framework. For more information about the framework refer to [[Thunder](#ref.Thunder)]. @@ -33,9 +33,7 @@ The table below lists configuration options of the plugin. | Name | Type | Description | | :-------- | :-------- | :-------- | -| callsign | string | Plugin instance name (default: *org.rdk.UserSettings*) | | classname | string | Class name: *org.rdk.UserSettings* | -| locator | string | Library name: *libWPEFrameworkUserSettings.so* | | autostart | boolean | Determines if the plugin shall be started automatically along with the framework | @@ -53,7 +51,6 @@ org.rdk.UserSettings interface methods: | [setCaptions](#method.setCaptions) | Setting Captions | | [setPreferredCaptionsLanguages](#method.setPreferredCaptionsLanguages) | Setting PreferredCaption Languages | | [setPreferredClosedCaptionService](#method.setPreferredClosedCaptionService) | Setting Preferred Closed Caption Service | -| [SetPrivacyMode](#method.SetPrivacyMode) | Setting Privacy Mode | | [setPinControl](#method.setPinControl) | Setting PinControl | | [setViewingRestrictions](#method.setViewingRestrictions) | Setting ViewingRestrictions | | [setViewingRestrictionsWindow](#method.setViewingRestrictionsWindow) | Setting viewingRestrictionsWindow | @@ -67,7 +64,6 @@ org.rdk.UserSettings interface methods: | [getCaptions](#method.getCaptions) | Getting Captions Enabled | | [getPreferredCaptionsLanguages](#method.getPreferredCaptionsLanguages) | Getting Preferred Caption Languages | | [getPreferredClosedCaptionService](#method.getPreferredClosedCaptionService) | Getting Preferred ClosedCaption Service | -| [getPrivacyMode](#method.getPrivacyMode) | Getting Privacy Mode | | [getPinControl](#method.getPinControl) | Returns Pin Control | | [getViewingRestrictions](#method.getViewingRestrictions) | Returns Get Viewing Restrictions | | [getViewingRestrictionsWindow](#method.getViewingRestrictionsWindow) | Returns Get Viewing Restrictions Window | @@ -365,54 +361,6 @@ Setting Preferred Closed Caption Service. } ``` - -## *SetPrivacyMode [method](#head.Methods)* - -Setting Privacy Mode. - -### Events - -| Event | Description | -| :-------- | :-------- | -| [onPrivacyModeChanged](#event.onPrivacyModeChanged) | Triggered when the Privacy Mode changes. | -### Parameters - -| Name | Type | Description | -| :-------- | :-------- | :-------- | -| params | object | | -| params.privacyMode | string | New Privacy Mode | - -### Result - -| Name | Type | Description | -| :-------- | :-------- | :-------- | -| result | string | On success null will be returned | - -### Example - -#### Request - -```json -{ - "jsonrpc": "2.0", - "id": 42, - "method": "org.rdk.UserSettings.SetPrivacyMode", - "params": { - "privacyMode": "DO_NOT_SHARE" - } -} -``` - -#### Response - -```json -{ - "jsonrpc": "2.0", - "id": 42, - "result": "null" -} -``` - ## *setPinControl [method](#head.Methods)* @@ -995,47 +943,6 @@ This method takes no parameters. } ``` - -## *getPrivacyMode [method](#head.Methods)* - -Getting Privacy Mode. - -### Events - -No Events - -### Parameters - -This method takes no parameters. - -### Result - -| Name | Type | Description | -| :-------- | :-------- | :-------- | -| result | string | Current Privacy Mode | - -### Example - -#### Request - -```json -{ - "jsonrpc": "2.0", - "id": 42, - "method": "org.rdk.UserSettings.getPrivacyMode" -} -``` - -#### Response - -```json -{ - "jsonrpc": "2.0", - "id": 42, - "result": "DO_NOT_SHARE" -} -``` - ## *getPinControl [method](#head.Methods)* @@ -1340,7 +1247,6 @@ org.rdk.UserSettings interface events: | [onCaptionsChanged](#event.onCaptionsChanged) | Triggered after the captions changes (see `SetCaptions`) | | [onPreferredCaptionsLanguagesChanged](#event.onPreferredCaptionsLanguagesChanged) | Triggered after the PreferredCaption Languages changes (see `SetPreferredCaptionsLanguages`) | | [onPreferredClosedCaptionServiceChanged](#event.onPreferredClosedCaptionServiceChanged) | Triggered after the Preferred Closed Caption changes (see `SetPreferredClosedCaptionService`) | -| [onPrivacyModeChanged](#event.onPrivacyModeChanged) | Triggered after the Privacy Mode changes (see `SetPrivacyMode`) | | [onPinControlChanged](#event.onPinControlChanged) | Triggered after the pin control changes (see `setPinControl`) | | [onViewingRestrictionsChanged](#event.onViewingRestrictionsChanged) | Triggered after the viewingRestrictions changes (see `setViewingRestrictions`) | | [onViewingRestrictionsWindowChanged](#event.onViewingRestrictionsWindowChanged) | Triggered after the viewingRestrictionsWindow changes (see `setViewingRestrictionsWindow`) | @@ -1494,30 +1400,6 @@ Triggered after the Preferred Closed Caption changes (see `SetPreferredClosedCap } ``` - -## *onPrivacyModeChanged [event](#head.Notifications)* - -Triggered after the Privacy Mode changes (see `SetPrivacyMode`). - -### Parameters - -| Name | Type | Description | -| :-------- | :-------- | :-------- | -| params | object | | -| params.privacyMode | string | Receive Privacy Mode changes | - -### Example - -```json -{ - "jsonrpc": "2.0", - "method": "client.events.onPrivacyModeChanged", - "params": { - "privacyMode": "DO_NOT_SHARE" - } -} -``` - ## *onPinControlChanged [event](#head.Notifications)* diff --git a/helpers/UtilsController.h b/helpers/UtilsController.h new file mode 100644 index 0000000000..405e0c24fc --- /dev/null +++ b/helpers/UtilsController.h @@ -0,0 +1,208 @@ +#pragma once + +#include +#include + +#ifndef DISABLE_SECURITY_TOKEN +#include +#endif + +// std +#include + +#define MAX_STRING_LENGTH 2048 + +#define SERVER_DETAILS "127.0.0.1:9998" + +using namespace WPEFramework; +using namespace std; + +namespace Utils +{ + struct SecurityToken + { + static void getSecurityToken(std::string &token) + { + static std::string sToken = ""; + static bool sThunderSecurityChecked = false; + + static std::mutex mtx; + std::unique_lock lock(mtx); + + if (sThunderSecurityChecked) + { + token = sToken; + return; + } + + sThunderSecurityChecked = true; + +#ifdef DISABLE_SECURITY_TOKEN + token = sToken; +#else + if (!isThunderSecurityConfigured()) + { + LOGINFO("Thunder Security is not enabled. Not getting token"); + token = sToken; + return; + } + + unsigned char buffer[MAX_STRING_LENGTH] = {0}; + int ret = GetSecurityToken(MAX_STRING_LENGTH, buffer); + if (ret < 0) + { + LOGERR("Error in getting token"); + } + else + { + LOGINFO("Retrieved token successfully"); + token = (char *)buffer; + sToken = token; + } +#endif + } + +#ifndef DISABLE_SECURITY_TOKEN + static size_t writeCurlResponse(void *ptr, size_t size, size_t nmemb, string stream) + { + size_t realsize = size * nmemb; + string temp(static_cast(ptr), realsize); + stream.append(temp); + return realsize; + } + + static bool isThunderSecurityConfigured() + { + bool configured = false; + long http_code = 0; + std::string jsonResp; + CURL *curl_handle = NULL; + CURLcode res = CURLE_OK; + curl_handle = curl_easy_init(); + string serialNumber = ""; + string url = "http://127.0.0.1:9998/Service/Controller/Configuration/Controller"; + if (curl_handle && + !curl_easy_setopt(curl_handle, CURLOPT_URL, url.c_str()) && + !curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1) && + !curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1) && // when redirected, follow the redirections + !curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, writeCurlResponse) && + !curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, &jsonResp)) + { + + res = curl_easy_perform(curl_handle); + if (curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &http_code) != CURLE_OK) + { + std::cout << "curl_easy_getinfo failed\n"; + } + std::cout << "Thunder Controller Configuration ret: " << res << " http response code: " << http_code << std::endl; + curl_easy_cleanup(curl_handle); + } + else + { + std::cout << "Could not perform curl to read Thunder Controller Configuration\n"; + } + if ((res == CURLE_OK) && (http_code == 200)) + { + // check for "Security" in response + JsonObject responseJson = JsonObject(jsonResp); + if (responseJson.HasLabel("subsystems")) + { + const JsonArray subsystemList = responseJson["subsystems"].Array(); + for (int i = 0; i < subsystemList.Length(); i++) + { + string subsystem = subsystemList[i].String(); + if (subsystem == "Security") + { + configured = true; + break; + } + } + } + } + return configured; + } +#endif + + }; + + // Thunder Plugin Communication + std::shared_ptr> getThunderControllerClient(std::string callsign="") + { + + string token; + Utils::SecurityToken::getSecurityToken(token); + string query = "token=" + token; + + Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T(SERVER_DETAILS))); + std::shared_ptr> thunderClient = make_shared>(callsign.c_str(), "", false, query); + + return thunderClient; + } + +#ifndef USE_THUNDER_R4 + class Job : public Core::IDispatchType +#else + class Job : public Core::IDispatch +#endif /* USE_THUNDER_R4 */ + { + public: + Job(std::function work) + : _work(work) + { + } + void Dispatch() override + { + _work(); + } + + private: + std::function _work; + }; + + uint32_t getServiceState(PluginHost::IShell *shell, const string &callsign, PluginHost::IShell::state &state) + { + uint32_t result; + auto interface = shell->QueryInterfaceByCallsign(callsign); + if (interface == nullptr) + { + result = Core::ERROR_UNAVAILABLE; + std::cout << "no IShell for " << callsign << std::endl; + } + else + { + result = Core::ERROR_NONE; + state = interface->State(); + std::cout << "IShell state " << state << " for " << callsign << std::endl; + interface->Release(); + } + return result; + } + + uint32_t activatePlugin(PluginHost::IShell *shell, const string &callsign) + { + uint32_t result = Core::ERROR_ASYNC_FAILED; + Core::Event event(false, true); + +#ifndef USE_THUNDER_R4 + Core::IWorkerPool::Instance().Submit(Core::ProxyType>(Core::ProxyType::Create([&]() + { +#else + Core::IWorkerPool::Instance().Submit(Core::ProxyType(Core::ProxyType::Create([&]() + { +#endif /* USE_THUNDER_R4 */ + auto interface = shell->QueryInterfaceByCallsign(callsign); + if (interface == nullptr) { + result = Core::ERROR_UNAVAILABLE; + std::cout << "no IShell for " << callsign << std::endl; + } else { + result = interface->Activate(PluginHost::IShell::reason::REQUESTED); + std::cout << "IShell activate status " << result << " for " << callsign << std::endl; + interface->Release(); + } + event.SetEvent(); }))); + + event.Lock(); + return result; + } + +}