buffet: Add libbuffet library and test daemon

Re-organized code in Buffet a bit. Moved dbus_constants into
libbuffet, so they can be used by both buffet and outside parties.

Added libbuffet shared library and thin helper classes to listen
to command update notifications from buffet daemon and let consumers
handle new commands by providing a simple callback.

Added a very simple test daemon to illustrate how to implement
a daemon that would respond to Buffet commands. test_daemon is
being built but is not installed into the image right now...

BUG=chromium:412583
TEST=Buffet compiles and unit tests run
CQ-DEPEND=CL:217838

Change-Id: Ica025bfdb7fc439c58c662ef3a015abc12426806
Reviewed-on: https://chromium-review.googlesource.com/217890
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/libbuffet/command.h b/buffet/libbuffet/command.h
new file mode 100644
index 0000000..3404898
--- /dev/null
+++ b/buffet/libbuffet/command.h
@@ -0,0 +1,68 @@
+// Copyright 2014 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BUFFET_LIBBUFFET_COMMAND_H_
+#define BUFFET_LIBBUFFET_COMMAND_H_
+
+#include <string>
+
+#include <base/macros.h>
+#include <base/memory/weak_ptr.h>
+#include <chromeos/any.h>
+#include <chromeos/dbus/data_serialization.h>
+
+#include "libbuffet/export.h"
+
+namespace dbus {
+class ObjectProxy;
+}
+
+namespace buffet {
+
+class CommandListener;
+class CommandPropertySet;
+
+// buffet::Command is a proxy class for GCD CommandInstance object delivered to
+// command handling daemon over D-Bus.
+class LIBBUFFET_EXPORT Command {
+ public:
+  Command(const dbus::ObjectPath& object_path,
+          CommandListener* command_listener);
+
+  // Returns the command ID.
+  const std::string& GetID() const;
+  // Returns the full name of the command.
+  const std::string& GetName() const;
+  // Returns the command category.
+  const std::string& GetCategory() const;
+  // Returns the command parameters and their values.
+  const chromeos::dbus_utils::Dictionary& GetParameters() const;
+
+  // Updates the command execution progress. The |progress| must be between
+  // 0 and 100. Returns false if the progress value is incorrect.
+  void SetProgress(int progress);
+  // Aborts command execution.
+  void Abort();
+  // Cancels command execution.
+  void Cancel();
+  // Marks the command as completed successfully.
+  void Done();
+
+  // Command state getters.
+  int GetProgress() const;
+  const std::string& GetStatus() const;
+
+ private:
+  CommandPropertySet* GetProperties() const;
+  dbus::ObjectProxy* GetObjectProxy() const;
+
+  dbus::ObjectPath object_path_;
+  CommandListener* command_listener_;
+
+  DISALLOW_COPY_AND_ASSIGN(Command);
+};
+
+}  // namespace buffet
+
+#endif  // BUFFET_LIBBUFFET_COMMAND_H_