blob: 15fbb7bebc446eec1a56655b98ad03089dccff7f [file] [log] [blame]
Alex Vakulenko89d9d5e2014-09-12 10:27:23 -07001// Copyright 2014 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef BUFFET_LIBBUFFET_COMMAND_H_
6#define BUFFET_LIBBUFFET_COMMAND_H_
7
8#include <string>
9
10#include <base/macros.h>
11#include <base/memory/weak_ptr.h>
Alex Vakulenko576c9792014-09-22 16:49:45 -070012#include <chromeos/variant_dictionary.h>
Alex Vakulenko89d9d5e2014-09-12 10:27:23 -070013
14#include "libbuffet/export.h"
15
16namespace dbus {
17class ObjectProxy;
18}
19
20namespace buffet {
21
22class CommandListener;
23class CommandPropertySet;
24
25// buffet::Command is a proxy class for GCD CommandInstance object delivered to
26// command handling daemon over D-Bus.
27class LIBBUFFET_EXPORT Command {
28 public:
29 Command(const dbus::ObjectPath& object_path,
30 CommandListener* command_listener);
31
32 // Returns the command ID.
33 const std::string& GetID() const;
34 // Returns the full name of the command.
35 const std::string& GetName() const;
36 // Returns the command category.
37 const std::string& GetCategory() const;
38 // Returns the command parameters and their values.
Alex Vakulenko576c9792014-09-22 16:49:45 -070039 const chromeos::VariantDictionary& GetParameters() const;
Alex Vakulenko89d9d5e2014-09-12 10:27:23 -070040
41 // Updates the command execution progress. The |progress| must be between
42 // 0 and 100. Returns false if the progress value is incorrect.
43 void SetProgress(int progress);
44 // Aborts command execution.
45 void Abort();
46 // Cancels command execution.
47 void Cancel();
48 // Marks the command as completed successfully.
49 void Done();
50
51 // Command state getters.
52 int GetProgress() const;
53 const std::string& GetStatus() const;
54
55 private:
56 CommandPropertySet* GetProperties() const;
57 dbus::ObjectProxy* GetObjectProxy() const;
58
59 dbus::ObjectPath object_path_;
60 CommandListener* command_listener_;
61
62 DISALLOW_COPY_AND_ASSIGN(Command);
63};
64
65} // namespace buffet
66
67#endif // BUFFET_LIBBUFFET_COMMAND_H_