summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Vakulenko <avakulenko@google.com>2015-10-09 08:13:34 -0700
committerAlex Vakulenko <avakulenko@google.com>2015-10-09 08:13:34 -0700
commitf497fa2a624ea0351c90745c1d8593b7270c0626 (patch)
treea2713253c917fc8a1398fcfd23086b2010970332
parent83a316758591e349595e408940a1b42bd42c9972 (diff)
downloadexample-ledflasher-f497fa2a624ea0351c90745c1d8593b7270c0626.tar.gz
ledflasher: Update weave command APIs
Weave has changed some of D-Bus APIs and metrics needs to be updated accrdingly. Command::Done is replaced with Complete(), Command::Abort now takes error code and error messages, Command::category is removed and Command::status is renamed to Command::state Change-Id: Ic6717769e88d1ff5f72e1d66d9012ee1ef5e4f1e
-rw-r--r--src/ledflasher/ledflasher.cc29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/ledflasher/ledflasher.cc b/src/ledflasher/ledflasher.cc
index d7f92b9..1d7d58c 100644
--- a/src/ledflasher/ledflasher.cc
+++ b/src/ledflasher/ledflasher.cc
@@ -122,7 +122,7 @@ void Daemon::OnLEDServiceDisconnected(const dbus::ObjectPath& object_path) {
}
void Daemon::OnCommand(CommandProxy* command) {
- if (command->status() != "queued")
+ if (command->state() != "queued")
return;
LOG(INFO) << "Command: " << command->name();
@@ -139,14 +139,19 @@ void Daemon::OnSet(CommandProxy* command) {
int index = GetParameter<int>(command->parameters(), "_led");
CHECK(index > 0);
bool on = GetParameter<bool>(command->parameters(), "_on");
- if (!led_service_ || !led_service_->SetLED(index - 1, on, nullptr)) {
- CHECK(command->Abort(nullptr));
+ if (!led_service_) {
+ CHECK(command->Abort("system_error", "ledservice unavailable", nullptr));
+ return;
+ }
+ chromeos::ErrorPtr error;
+ if (!led_service_->SetLED(index - 1, on, &error)) {
+ CHECK(command->Abort(error->GetCode(), error->GetMessage(), nullptr));
return;
}
animation_.reset();
status_ = "idle";
NotifyDeviceStateChanged();
- CHECK(command->Done(nullptr));
+ CHECK(command->Complete({}, nullptr));
}
void Daemon::OnToggle(CommandProxy* command) {
@@ -154,16 +159,20 @@ void Daemon::OnToggle(CommandProxy* command) {
CHECK(index > 0);
index--;
bool on = false;
- if (!led_service_ ||
- !led_service_->GetLED(index, &on, nullptr) ||
- !led_service_->SetLED(index, !on, nullptr)) {
- CHECK(command->Abort(nullptr));
+ if (!led_service_) {
+ CHECK(command->Abort("system_error", "ledservice unavailable", nullptr));
+ return;
+ }
+ chromeos::ErrorPtr error;
+ if(!led_service_->GetLED(index, &on, &error) ||
+ !led_service_->SetLED(index, !on, &error)) {
+ CHECK(command->Abort(error->GetCode(), error->GetMessage(), nullptr));
return;
}
animation_.reset();
status_ = "idle";
NotifyDeviceStateChanged();
- CHECK(command->Done(nullptr));
+ CHECK(command->Complete({}, nullptr));
}
void Daemon::OnAnimate(CommandProxy* command) {
@@ -181,7 +190,7 @@ void Daemon::OnAnimate(CommandProxy* command) {
status_ = "idle";
}
NotifyDeviceStateChanged();
- CHECK(command->Done(nullptr));
+ CHECK(command->Complete({}, nullptr));
}
void Daemon::UpdateDeviceState(ManagerProxy* manager) {