-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from Stivius/feat/notify_status
Implement NotifyStatus request
- Loading branch information
Showing
29 changed files
with
313 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "NotifyStatusInfo.hpp" | ||
|
||
#include "common/parsing/Parsing.hpp" | ||
|
||
std::string NotifyStatusInfo::string() const | ||
{ | ||
JsonNode tree; | ||
tree.put("currentLayoutId", currentLayoutId); | ||
tree.put("availableSpace", spaceUsageInfo.available); | ||
tree.put("totalSpace", spaceUsageInfo.total); | ||
// tree.put("lastCommandSuccess", ""); TODO: implement when commands will be available | ||
tree.put("deviceName", static_cast<std::string>(deviceName)); | ||
tree.put("timeZone", timezone); | ||
return Parsing::jsonToString(tree); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include "common/fs/StorageUsageInfo.hpp" | ||
#include "common/system/Hostname.hpp" | ||
#include "schedule/ScheduleItem.hpp" | ||
|
||
struct NotifyStatusInfo | ||
{ | ||
std::string string() const; | ||
|
||
LayoutId currentLayoutId; | ||
StorageUsageInfo spaceUsageInfo; | ||
Hostname deviceName; | ||
std::string timezone; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "NotifyStatus.hpp" | ||
|
||
#include "cms/xmds/Resources.hpp" | ||
|
||
namespace Resources = XmdsResources::NotifyStatus; | ||
|
||
Soap::RequestSerializer<NotifyStatus::Request>::RequestSerializer(const NotifyStatus::Request& request) : | ||
BaseRequestSerializer(request) | ||
{ | ||
} | ||
|
||
std::string Soap::RequestSerializer<NotifyStatus::Request>::string() | ||
{ | ||
return createRequest(Resources::Name, request().serverKey, request().hardwareKey, request().status); | ||
} | ||
|
||
Soap::ResponseParser<NotifyStatus::Result>::ResponseParser(const std::string& soapResponse) : | ||
BaseResponseParser(soapResponse) | ||
{ | ||
} | ||
|
||
NotifyStatus::Result Soap::ResponseParser<NotifyStatus::Result>::parseBody(const XmlNode& node) | ||
{ | ||
NotifyStatus::Result result; | ||
result.success = node.get<bool>(Resources::Success); | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
|
||
#include "cms/xmds/BaseRequestSerializer.hpp" | ||
#include "cms/xmds/BaseResponseParser.hpp" | ||
#include "cms/xmds/Soap.hpp" | ||
|
||
#include "common/SoapField.hpp" | ||
|
||
namespace NotifyStatus | ||
{ | ||
struct Result | ||
{ | ||
bool success; | ||
}; | ||
|
||
struct Request | ||
{ | ||
SoapField<std::string> serverKey{"serverKey"}; | ||
SoapField<std::string> hardwareKey{"hardwareKey"}; | ||
SoapField<std::string> status{"status"}; | ||
}; | ||
} | ||
|
||
template <> | ||
class Soap::RequestSerializer<NotifyStatus::Request> : public BaseRequestSerializer<NotifyStatus::Request> | ||
{ | ||
public: | ||
RequestSerializer(const NotifyStatus::Request& request); | ||
std::string string(); | ||
}; | ||
|
||
template <> | ||
class Soap::ResponseParser<NotifyStatus::Result> : public BaseResponseParser<NotifyStatus::Result> | ||
{ | ||
public: | ||
ResponseParser(const std::string& soapResponse); | ||
|
||
protected: | ||
NotifyStatus::Result parseBody(const XmlNode& node) override; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.