19
19
20
20
#include " Monitor.h"
21
21
22
- #define API_VERSION_NUMBER_MAJOR 1
22
+ #define API_VERSION_NUMBER_MAJOR 2
23
23
#define API_VERSION_NUMBER_MINOR 0
24
- #define API_VERSION_NUMBER_PATCH 9
24
+ #define API_VERSION_NUMBER_PATCH 0
25
25
26
26
namespace WPEFramework {
27
-
28
- namespace {
29
-
30
- static Plugin::Metadata<Plugin::Monitor> metadata (
31
- // Version (Major, Minor, Patch)
32
- API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH,
33
- // Preconditions
34
- {},
35
- // Terminations
36
- {},
37
- // Controls
38
- {}
39
- );
40
- }
41
-
42
27
namespace Plugin {
43
28
44
- SERVICE_REGISTRATION (Monitor, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH);
29
+ namespace {
30
+
31
+ static Plugin::Metadata<Plugin::Monitor> metadata (
32
+ // Version (Major, Minor, Patch)
33
+ API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH,
34
+ // Preconditions
35
+ {},
36
+ // Terminations
37
+ {},
38
+ // Controls
39
+ {}
40
+ );
41
+ }
45
42
46
43
static Core::ProxyPoolType<Web::JSONBodyType<Core::JSON::ArrayType<Monitor::Data>>> jsonBodyDataFactory (2 );
47
44
static Core::ProxyPoolType<Web::JSONBodyType<Monitor::Data>> jsonBodyParamFactory (2 );
@@ -57,21 +54,24 @@ namespace Plugin {
57
54
Core::JSON::ArrayType<Config::Entry>::Iterator index (_config.Observables .Elements ());
58
55
59
56
// Create a list of plugins to monitor..
60
- _monitor-> Open (service, index);
57
+ _monitor. Open (service, index);
61
58
62
59
// During the registartion, all Plugins, currently active are reported to the sink.
63
- service->Register (_monitor);
60
+ service->Register (&_monitor);
61
+
62
+ RegisterAll ();
64
63
65
64
// On succes return a name as a Callsign to be used in the URL, after the "service"prefix
66
65
return (_T (" " ));
67
66
}
68
67
69
68
/* virtual */ void Monitor::Deinitialize (PluginHost::IShell* service)
70
69
{
70
+ UnregisterAll ();
71
71
72
- _monitor-> Close ( );
72
+ service-> Unregister (&_monitor );
73
73
74
- service-> Unregister ( _monitor);
74
+ _monitor. Close ( );
75
75
}
76
76
77
77
/* virtual */ string Monitor::Information () const
@@ -106,46 +106,39 @@ namespace Plugin {
106
106
if (request.Verb == Web::Request::HTTP_GET) {
107
107
// Let's list them all....
108
108
if (index.Next () == false ) {
109
- if (_monitor-> Length () > 0 ) {
109
+ if (_monitor. Length () > 0 ) {
110
110
Core::ProxyType<Web::JSONBodyType<Core::JSON::ArrayType<Monitor::Data>>> response (jsonBodyDataFactory.Element ());
111
111
112
- _monitor->Snapshot (*response);
113
- #ifndef USE_THUNDER_R4
114
- result->Body (Core::proxy_cast<Web::IBody>(response));
115
- #else
112
+ _monitor.Snapshot (*response);
113
+
116
114
result->Body (Core::ProxyType<Web::IBody>(response));
117
- #endif /* USE_THUNDER_R4 */
118
115
}
119
116
} else {
120
117
MetaData memoryInfo;
118
+ bool operational = false ;
121
119
122
120
// Seems we only want 1 name
123
- if (_monitor-> Snapshot (index.Current ().Text (), memoryInfo) == true ) {
121
+ if (_monitor. Snapshot (index.Current ().Text (), memoryInfo, operational ) == true ) {
124
122
Core::ProxyType<Web::JSONBodyType<Monitor::Data::MetaData>> response (jsonMemoryBodyDataFactory.Element ());
125
123
126
- *response = memoryInfo;
127
- #ifndef USE_THUNDER_R4
128
- result->Body (Core::proxy_cast<Web::IBody>(response));
129
- #else
124
+ *response = Monitor::Data::MetaData (memoryInfo, operational);
125
+
130
126
result->Body (Core::ProxyType<Web::IBody>(response));
131
- #endif /* USE_THUNDER_R4 */
132
127
}
133
128
}
134
129
135
130
result->ContentType = Web::MIME_JSON;
136
131
} else if ((request.Verb == Web::Request::HTTP_PUT) && (index.Next () == true )) {
137
132
MetaData memoryInfo;
133
+ bool operational = false ;
138
134
139
135
// Seems we only want 1 name
140
- if (_monitor-> Reset (index.Current ().Text (), memoryInfo) == true ) {
136
+ if (_monitor. Reset (index.Current ().Text (), memoryInfo, operational ) == true ) {
141
137
Core::ProxyType<Web::JSONBodyType<Monitor::Data::MetaData>> response (jsonMemoryBodyDataFactory.Element ());
142
138
143
- *response = memoryInfo;
144
- #ifndef USE_THUNDER_R4
145
- result->Body (Core::proxy_cast<Web::IBody>(response));
146
- #else
139
+ *response = Monitor::Data::MetaData (memoryInfo, operational);
140
+
147
141
result->Body (Core::ProxyType<Web::IBody>(response));
148
- #endif /* USE_THUNDER_R4 */
149
142
}
150
143
151
144
result->ContentType = Web::MIME_JSON;
@@ -161,7 +154,7 @@ namespace Plugin {
161
154
restartLimit = body->Restart .Limit ;
162
155
}
163
156
TRACE (Trace::Information, (_T (" Sets Restart Limits:[LIMIT:%d, WINDOW:%d]" ), restartLimit, restartWindow));
164
- _monitor-> Update (observable, restartWindow, restartLimit);
157
+ _monitor. Update (observable, restartWindow, restartLimit);
165
158
} else {
166
159
result->ErrorCode = Web::STATUS_BAD_REQUEST;
167
160
result->Message = _T (" could not handle your request." );
@@ -170,4 +163,4 @@ namespace Plugin {
170
163
return (result);
171
164
}
172
165
}
173
- }
166
+ }
0 commit comments