privetd: Implement privet/v3/commands/status
Privetd just forwards IDs to the buffet and buffet returns JSON
representation of the command.
BUG=brillo:430
TEST=unittest
Change-Id: I5698f9fc915ae32dc2b9be3cc35f8efe919ee4e3
Reviewed-on: https://chromium-review.googlesource.com/261641
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/manager.cc b/buffet/manager.cc
index 6097b09..01f73b1 100644
--- a/buffet/manager.cc
+++ b/buffet/manager.cc
@@ -189,6 +189,19 @@
response->Return();
}
+void Manager::GetCommand(DBusMethodResponse<std::string> response,
+ const std::string& id) {
+ const CommandInstance* command = command_manager_->FindCommand(id);
+ if (!command) {
+ response->ReplyWithError(FROM_HERE, kErrorDomainGCD, "unknown_command",
+ "Can't find command with id: " + id);
+ return;
+ }
+ std::string command_str;
+ base::JSONWriter::Write(command->ToJson().get(), &command_str);
+ response->Return(command_str);
+}
+
std::string Manager::TestMethod(const std::string& message) {
LOG(INFO) << "Received call to test method: " << message;
return message;