From a2bdd86464a831d56b989b0adb2cb7e40ea9b4ff Mon Sep 17 00:00:00 2001 From: Pierre Wielders Date: Mon, 17 Jul 2023 11:49:15 +0200 Subject: [PATCH 1/3] [JSONRPC] To allow for parameter detection failures, add an error report to the methods. (#739) --- examples/OutOfProcessPlugin/OutOfProcessPlugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/OutOfProcessPlugin/OutOfProcessPlugin.cpp b/examples/OutOfProcessPlugin/OutOfProcessPlugin.cpp index f7d92fe62..447fa9771 100644 --- a/examples/OutOfProcessPlugin/OutOfProcessPlugin.cpp +++ b/examples/OutOfProcessPlugin/OutOfProcessPlugin.cpp @@ -82,7 +82,7 @@ namespace Plugin { _browserresources = _browser->QueryInterface(); if( _browserresources != nullptr) { Exchange::JBrowserResources::Register(*this, _browserresources); - Register("bigupdate", [this](const Core::JSONRPC::Context&, const string& params){ + Register("bigupdate", [this](const Core::JSONRPC::Context&, const string& params, Core::OptionalType&) { uint32_t updates = 5000; string sleep("100"); if(params.empty() == false) { From 8061751fa85648b61439c61afa5646fbe44e8edc Mon Sep 17 00:00:00 2001 From: HaseenaSainul <41037131+HaseenaSainul@users.noreply.github.com> Date: Mon, 31 Jul 2023 12:48:58 +0530 Subject: [PATCH 2/3] ProcessContainers: changes to compile it again (#740) --- ProcessContainers/Containers.h | 2 +- ProcessContainers/ContainersJsonRpc.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ProcessContainers/Containers.h b/ProcessContainers/Containers.h index bbc9a006c..46aadfb8e 100644 --- a/ProcessContainers/Containers.h +++ b/ProcessContainers/Containers.h @@ -63,7 +63,7 @@ namespace Plugin { uint32_t endpoint_start(const JsonData::Containers::StartParamsData& params); uint32_t endpoint_stop(const JsonData::Containers::StopParamsData& params); uint32_t get_containers(Core::JSON::ArrayType& response) const; - uint32_t get_networks(const string& index, Core::JSON::ArrayType& response) const; + uint32_t get_networks(const string& index, Core::JSON::ArrayType& response) const; uint32_t get_memory(const string& index, JsonData::Containers::MemoryData& response) const; uint32_t get_cpu(const string& index, JsonData::Containers::CpuData& response) const; }; diff --git a/ProcessContainers/ContainersJsonRpc.cpp b/ProcessContainers/ContainersJsonRpc.cpp index dbe112321..821db9bd6 100644 --- a/ProcessContainers/ContainersJsonRpc.cpp +++ b/ProcessContainers/ContainersJsonRpc.cpp @@ -36,7 +36,7 @@ namespace Plugin { Register(_T("start"), &Containers::endpoint_start, this); Register(_T("stop"), &Containers::endpoint_stop, this); Property>(_T("containers"), &Containers::get_containers, nullptr, this); - Property>(_T("networks"), &Containers::get_networks, nullptr, this); + Property>(_T("networks"), &Containers::get_networks, nullptr, this); Property(_T("memory"), &Containers::get_memory, nullptr, this); Property(_T("cpu"), &Containers::get_cpu, nullptr, this); } @@ -137,7 +137,7 @@ namespace Plugin { // Return codes: // - ERROR_NONE: Success // - ERROR_UNAVAILABLE: Container not found - uint32_t Containers::get_networks(const string& index, Core::JSON::ArrayType& response) const + uint32_t Containers::get_networks(const string& index, Core::JSON::ArrayType& response) const { uint32_t result = Core::ERROR_NONE; @@ -149,7 +149,7 @@ namespace Plugin { if (iterator != nullptr) { while(iterator->Next() == true) { - NetworksData networkData; + NetworksResultDataElem networkData; networkData.Interface = iterator->Name(); From 54a69748a414c34749ee85935d4361007d3dffd1 Mon Sep 17 00:00:00 2001 From: Pierre Wielders Date: Mon, 31 Jul 2023 10:19:58 +0200 Subject: [PATCH 3/3] [JSONPC] Update the implementation accordingly :-) (#741) --- Dictionary/Dictionary.cpp | 16 ++++++++-------- Dictionary/Dictionary.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Dictionary/Dictionary.cpp b/Dictionary/Dictionary.cpp index 846b88527..75a023ded 100644 --- a/Dictionary/Dictionary.cpp +++ b/Dictionary/Dictionary.cpp @@ -227,9 +227,9 @@ namespace Plugin { return (result); } - /* virtual */ bool Dictionary::Get(const string& nameSpace, const string& key, string& value) const + /* virtual */ Core::hresult Dictionary::Get(const string& nameSpace, const string& key, string& value) const { - bool result = false; + Core::hresult result = Core::ERROR_UNKNOWN_KEY; _adminLock.Lock(); @@ -244,7 +244,7 @@ namespace Plugin { } if (listIndex != container.end()) { - result = true; + result = Core::ERROR_NONE; value = listIndex->Value(); } } @@ -281,10 +281,10 @@ namespace Plugin { // Direct method to Set a value for a key in a certain namespace from the dictionary. // NameSpace and key MUST be filled. - /* virtual */ bool Dictionary::Set(const string& nameSpace, const string& key, const string& value) + /* virtual */ Core::hresult Dictionary::Set(const string& nameSpace, const string& key, const string& value) { // Direct method to Set a value for a key in a certain namespace from the dictionary. - bool result = false; + Core::hresult result = Core::ERROR_UNKNOWN_KEY; _adminLock.Lock(); @@ -296,14 +296,14 @@ namespace Plugin { } if (listIndex == container.end()) { - result = true; + result = Core::ERROR_NONE; container.push_back(RuntimeEntry(key, value, VOLATILE)); } else if (listIndex->Value() != value) { - result = true; + result = Core::ERROR_NONE; listIndex->Value(value); } - if (result == true) { + if (result == Core::ERROR_NONE) { ObserverMap::iterator index(_observers.begin()); // Right, we updated send out the modification !!! diff --git a/Dictionary/Dictionary.h b/Dictionary/Dictionary.h index 056491dbc..f9d394385 100644 --- a/Dictionary/Dictionary.h +++ b/Dictionary/Dictionary.h @@ -391,12 +391,12 @@ namespace Plugin { // ------------------------------------------------------------------------------------------------------- // Direct method to Get a value from a key in a certain namespace from the dictionary. // NameSpace and key MUST be filled. - bool Get(const string& nameSpace, const string& key, string& value) const override; + Core::hresult Get(const string& nameSpace, const string& key, string& value) const override; IDictionary::IIterator* Get(const string& nameSpace) const override; // Direct method to Set a value for a key in a certain namespace from the dictionary. // NameSpace and key MUST be filled. - bool Set(const string& nameSpace, const string& key, const string& value) override; + Core::hresult Set(const string& nameSpace, const string& key, const string& value) override; void Register(const string& nameSpace, struct Exchange::IDictionary::INotification* sink) override; void Unregister(const string& nameSpace, struct Exchange::IDictionary::INotification* sink) override;