Update weaved to reflect the latest changes in libweave

A number of APIs have changed in libweave and weaved is updated to
work with the latest version of the library. Some public D-Bus APIs
have changed as well to reflect the underlying libweave interfaces:

- Command::Done/SetProgress are replaced with Command::Complete
- Command::Abort now takes error code and error messages
- Command::category is removed
- Command::status is renamed to Command::state
- Manager::GetCommand is removed (since weave::Command::ToJson is
  no longer available)

Change-Id: Iebf0565467756e8a21be37163d750ff22c419672
diff --git a/buffet/dbus_command_proxy.cc b/buffet/dbus_command_proxy.cc
index 71196e8..8c5c99f 100644
--- a/buffet/dbus_command_proxy.cc
+++ b/buffet/dbus_command_proxy.cc
@@ -52,7 +52,7 @@
   // Set the initial property values before registering the DBus object.
   dbus_adaptor_.SetName(command->GetName());
   dbus_adaptor_.SetId(command->GetID());
-  dbus_adaptor_.SetStatus(EnumToString(command->GetStatus()));
+  dbus_adaptor_.SetState(EnumToString(command->GetState()));
   dbus_adaptor_.SetProgress(
       DictionaryToDBusVariantDictionary(*command->GetProgress()));
   dbus_adaptor_.SetOrigin(EnumToString(command->GetOrigin()));
@@ -84,40 +84,49 @@
   }
   dbus_adaptor_.SetProgress(
       DictionaryToDBusVariantDictionary(*command->GetProgress()));
-  dbus_adaptor_.SetStatus(EnumToString(command->GetStatus()));
+  dbus_adaptor_.SetState(EnumToString(command->GetState()));
   return true;
 }
 
-bool DBusCommandProxy::SetResults(chromeos::ErrorPtr* error,
-                                  const chromeos::VariantDictionary& results) {
+bool DBusCommandProxy::Complete(chromeos::ErrorPtr* error,
+                                const chromeos::VariantDictionary& results) {
   auto command = command_.lock();
   if (!command)
     return ReportDestroyedError(error);
 
   LOG(INFO) << "Received call to Command<" << command->GetName()
-            << ">::SetResults()";
+            << ">::Complete()";
   auto dictionary = DictionaryFromDBusVariantDictionary(results, error);
   if (!dictionary)
     return false;
   weave::ErrorPtr weave_error;
-  if (!command->SetResults(*dictionary, &weave_error)) {
+  if (!command->Complete(*dictionary, &weave_error)) {
     ConvertError(*weave_error, error);
     return false;
   }
   dbus_adaptor_.SetProgress(
       DictionaryToDBusVariantDictionary(*command->GetProgress()));
+  dbus_adaptor_.SetState(EnumToString(command->GetState()));
   return true;
 }
 
-bool DBusCommandProxy::Abort(chromeos::ErrorPtr* error) {
+bool DBusCommandProxy::Abort(chromeos::ErrorPtr* error,
+                             const std::string& code,
+                             const std::string& message) {
   auto command = command_.lock();
   if (!command)
     return ReportDestroyedError(error);
 
   LOG(INFO) << "Received call to Command<" << command->GetName()
             << ">::Abort()";
-  command->Abort();
-  dbus_adaptor_.SetStatus(EnumToString(command->GetStatus()));
+  weave::ErrorPtr cmd_error;
+  weave::Error::AddTo(&cmd_error, FROM_HERE, "command_error", code, message);
+  weave::ErrorPtr weave_error;
+  if (!command->Abort(cmd_error.get(), &weave_error)) {
+    ConvertError(*weave_error, error);
+    return false;
+  }
+  dbus_adaptor_.SetState(EnumToString(command->GetState()));
   return true;
 }
 
@@ -128,22 +137,12 @@
 
   LOG(INFO) << "Received call to Command<" << command->GetName()
             << ">::Cancel()";
-  command->Cancel();
-  dbus_adaptor_.SetStatus(EnumToString(command->GetStatus()));
-  return true;
-}
-
-bool DBusCommandProxy::Done(chromeos::ErrorPtr* error) {
-  auto command = command_.lock();
-  if (!command)
-    return ReportDestroyedError(error);
-
-  LOG(INFO) << "Received call to Command<" << command->GetName()
-            << ">::Done()";
-  command->Done();
-  dbus_adaptor_.SetProgress(
-      DictionaryToDBusVariantDictionary(*command->GetProgress()));
-  dbus_adaptor_.SetStatus(EnumToString(command->GetStatus()));
+  weave::ErrorPtr weave_error;
+  if (!command->Cancel(&weave_error)) {
+    ConvertError(*weave_error, error);
+    return false;
+  }
+  dbus_adaptor_.SetState(EnumToString(command->GetState()));
   return true;
 }