|
@@ -29,22 +29,54 @@ namespace Exchange {
|
|
|
29
29
|
|
|
30
30
|
_module__.PluginHost::JSONRPC::RegisterVersion(_T("JConfiguration"), Version::Major, Version::Minor, Version::Patch);
|
|
31
31
|
|
|
32
32
|
// Register methods and properties...
|
|
33
33
|
|
|
34
|
-
// Method: 'persist' - Stores
|
|
35
|
-
_module__.PluginHost::JSONRPC::template Register<
|
|
36
|
-
[_implementation__]() -> uint32_t {
|
|
34
|
+
// Method: 'persist' - Stores configuration to the persistent memory
|
|
35
|
+
_module__.PluginHost::JSONRPC::template Register<JsonData::Configuration::PersistParamsInfo, void>(_T("persist"),
|
|
36
|
+
[_implementation__](const JsonData::Configuration::PersistParamsInfo& params) -> uint32_t {
|
|
37
37
|
uint32_t _errorCode__ = Core::ERROR_NONE;
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
if ((params.IsSet() == true) && (params.IsDataValid() == false)) {
|
|
40
|
+
_errorCode__ = Core::ERROR_BAD_REQUEST;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
Core::OptionalType<string> _callsign_{};
|
|
44
|
+
if (params.Callsign.IsSet() == true) {
|
|
45
|
+
_callsign_ = params.Callsign;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
_errorCode__ = _implementation__->Persist(_callsign_);
|
|
49
|
+
|
|
50
|
+
}
|
|
40
51
|
|
|
41
52
|
return (_errorCode__);
|
|
42
53
|
});
|
|
43
54
|
|
|
44
55
|
_module__.PluginHost::JSONRPC::Register(_T("storeconfig"), _T("persist"));
|
|
45
56
|
|
|
57
|
+
// Method: 'restore' - Restores configuration back to default
|
|
58
|
+
_module__.PluginHost::JSONRPC::template Register<JsonData::Configuration::PersistParamsInfo, void>(_T("restore"),
|
|
59
|
+
[_implementation__](const JsonData::Configuration::PersistParamsInfo& params) -> uint32_t {
|
|
60
|
+
uint32_t _errorCode__ = Core::ERROR_NONE;
|
|
61
|
+
|
|
62
|
+
if ((params.IsSet() == true) && (params.IsDataValid() == false)) {
|
|
63
|
+
_errorCode__ = Core::ERROR_BAD_REQUEST;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
Core::OptionalType<string> _callsign_{};
|
|
67
|
+
if (params.Callsign.IsSet() == true) {
|
|
68
|
+
_callsign_ = params.Callsign;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_errorCode__ = _implementation__->Restore(_callsign_);
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return (_errorCode__);
|
|
76
|
+
});
|
|
77
|
+
|
|
46
78
|
// Indexed Property: 'configuration' - Service configuration
|
|
47
79
|
_module__.PluginHost::JSONRPC::template Register<Core::JSON::String, Core::JSON::String, std::function<uint32_t(const string&, const Core::JSON::String&, Core::JSON::String&)>>(_T("configuration"),
|
|
48
80
|
[_implementation__](const string& callsign, const Core::JSON::String& params, Core::JSON::String& result) -> uint32_t {
|
|
49
81
|
uint32_t _errorCode__ = Core::ERROR_NONE;
|
|
50
82
|
|
|
@@ -95,10 +127,11 @@ namespace Exchange {
|
|
|
95
127
|
static void Unregister(MODULE& _module__)
|
|
96
128
|
{
|
|
97
129
|
// Unregister methods and properties...
|
|
98
130
|
_module__.PluginHost::JSONRPC::Unregister(_T("persist"));
|
|
99
131
|
_module__.PluginHost::JSONRPC::Unregister(_T("storeconfig"));
|
|
132
|
+
_module__.PluginHost::JSONRPC::Unregister(_T("restore"));
|
|
100
133
|
_module__.PluginHost::JSONRPC::Unregister(_T("configuration"));
|
|
101
134
|
}
|
|
102
135
|
|
|
103
136
|
POP_WARNING()
|
|
104
137
|
POP_WARNING()
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// C++ types for Configuration API.
|
|
2
|
+
// Generated automatically from 'IController.h'. DO NOT EDIT.
|
|
3
|
+
|
|
4
|
+
// Note: This code is inherently not thread safe. If required, proper synchronisation must be added.
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include <core/JSON.h>
|
|
9
|
+
|
|
10
|
+
namespace Thunder {
|
|
11
|
+
|
|
12
|
+
namespace JsonData {
|
|
13
|
+
|
|
14
|
+
PUSH_WARNING(DISABLE_WARNING_TYPE_LIMITS)
|
|
15
|
+
|
|
16
|
+
namespace Configuration {
|
|
17
|
+
|
|
18
|
+
// Common classes
|
|
19
|
+
//
|
|
20
|
+
|
|
21
|
+
class PersistParamsInfo : public Core::JSON::Container {
|
|
22
|
+
public:
|
|
23
|
+
PersistParamsInfo()
|
|
24
|
+
: Core::JSON::Container()
|
|
25
|
+
{
|
|
26
|
+
Add(_T("callsign"), &Callsign);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
PersistParamsInfo(const PersistParamsInfo&) = delete;
|
|
30
|
+
PersistParamsInfo(PersistParamsInfo&&) noexcept = delete;
|
|
31
|
+
|
|
32
|
+
PersistParamsInfo& operator=(const PersistParamsInfo&) = delete;
|
|
33
|
+
PersistParamsInfo& operator=(PersistParamsInfo&&) noexcept = delete;
|
|
34
|
+
|
|
35
|
+
~PersistParamsInfo() = default;
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
bool IsDataValid() const
|
|
39
|
+
{
|
|
40
|
+
return (true);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public:
|
|
44
|
+
Core::JSON::String Callsign; // Plugin callsign to persist (omit for all plugins, empty string for Controller only)
|
|
45
|
+
}; // class PersistParamsInfo
|
|
46
|
+
|
|
47
|
+
// Method params/result classes
|
|
48
|
+
//
|
|
49
|
+
|
|
50
|
+
} // namespace Configuration
|
|
51
|
+
|
|
52
|
+
POP_WARNING()
|
|
53
|
+
|
|
54
|
+
} // namespace JsonData
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
#pragma once
|
|
5
5
|
|
|
6
6
|
#include "JsonData_System.h"
|
|
7
7
|
#include "JsonData_Discovery.h"
|
|
8
|
+
#include "JsonData_Configuration.h"
|
|
8
9
|
#include "JsonData_LifeTime.h"
|
|
9
10
|
#include "JsonData_Subsystems.h"
|
|
10
11
|
#include "JsonData_Events.h"
|
|
11
12
|
#include "JsonData_Metadata.h"
|
|
12
13
|
#include "JSystem.h"
|