blob: 3404898107917ff3827255b24a5fb8b8710cbac5 [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>
12#include <chromeos/any.h>
13#include <chromeos/dbus/data_serialization.h>
14
15#include "libbuffet/export.h"
16
17namespace dbus {
18class ObjectProxy;
19}
20
21namespace buffet {
22
23class CommandListener;
24class CommandPropertySet;
25
26// buffet::Command is a proxy class for GCD CommandInstance object delivered to
27// command handling daemon over D-Bus.
28class LIBBUFFET_EXPORT Command {
29 public:
30 Command(const dbus::ObjectPath& object_path,
31 CommandListener* command_listener);
32
33 // Returns the command ID.
34 const std::string& GetID() const;
35 // Returns the full name of the command.
36 const std::string& GetName() const;
37 // Returns the command category.
38 const std::string& GetCategory() const;
39 // Returns the command parameters and their values.
40 const chromeos::dbus_utils::Dictionary& GetParameters() const;
41
42 // Updates the command execution progress. The |progress| must be between
43 // 0 and 100. Returns false if the progress value is incorrect.
44 void SetProgress(int progress);
45 // Aborts command execution.
46 void Abort();
47 // Cancels command execution.
48 void Cancel();
49 // Marks the command as completed successfully.
50 void Done();
51
52 // Command state getters.
53 int GetProgress() const;
54 const std::string& GetStatus() const;
55
56 private:
57 CommandPropertySet* GetProperties() const;
58 dbus::ObjectProxy* GetObjectProxy() const;
59
60 dbus::ObjectPath object_path_;
61 CommandListener* command_listener_;
62
63 DISALLOW_COPY_AND_ASSIGN(Command);
64};
65
66} // namespace buffet
67
68#endif // BUFFET_LIBBUFFET_COMMAND_H_