Christopher Wiley | 4b5f04c | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 1 | // 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_MANAGER_H_ |
| 6 | #define BUFFET_MANAGER_H_ |
| 7 | |
| 8 | #include <base/basictypes.h> |
| 9 | #include <base/memory/scoped_ptr.h> |
Alex Vakulenko | f3d77e5 | 2014-04-15 11:36:32 -0700 | [diff] [blame^] | 10 | #include <base/values.h> |
Christopher Wiley | 4b5f04c | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 11 | #include <dbus/message.h> |
Christopher Wiley | 54028f9 | 2014-04-01 17:33:29 -0700 | [diff] [blame] | 12 | #include <dbus/object_path.h> |
Alex Vakulenko | f3d77e5 | 2014-04-15 11:36:32 -0700 | [diff] [blame^] | 13 | #include <memory> |
Christopher Wiley | 4b5f04c | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 14 | |
Christopher Wiley | 106686a | 2014-03-27 14:51:26 -0700 | [diff] [blame] | 15 | #include "buffet/dbus_constants.h" |
| 16 | #include "buffet/exported_property_set.h" |
Alex Vakulenko | f3d77e5 | 2014-04-15 11:36:32 -0700 | [diff] [blame^] | 17 | #include "buffet/device_registration_info.h" |
Christopher Wiley | 106686a | 2014-03-27 14:51:26 -0700 | [diff] [blame] | 18 | |
Christopher Wiley | 4b5f04c | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 19 | namespace buffet { |
| 20 | |
| 21 | class DBusManager; |
| 22 | |
| 23 | // The Manager is responsible for global state of Buffet. It exposes |
| 24 | // interfaces which affect the entire device such as device registration and |
| 25 | // device state. |
| 26 | class Manager { |
| 27 | public: |
Christopher Wiley | 54028f9 | 2014-04-01 17:33:29 -0700 | [diff] [blame] | 28 | typedef base::Callback<void(bool success)> OnInitFinish; |
| 29 | |
| 30 | Manager(dbus::Bus* bus); |
Christopher Wiley | 4b5f04c | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 31 | ~Manager(); |
Christopher Wiley | 54028f9 | 2014-04-01 17:33:29 -0700 | [diff] [blame] | 32 | void Init(const OnInitFinish& cb); |
Christopher Wiley | 4b5f04c | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 33 | |
| 34 | private: |
Christopher Wiley | 106686a | 2014-03-27 14:51:26 -0700 | [diff] [blame] | 35 | struct Properties: public dbus_utils::ExportedPropertySet { |
| 36 | public: |
| 37 | dbus_utils::ExportedProperty<std::string> state_; |
Christopher Wiley | 54028f9 | 2014-04-01 17:33:29 -0700 | [diff] [blame] | 38 | Properties(dbus::Bus* bus) |
| 39 | : dbus_utils::ExportedPropertySet( |
| 40 | bus, dbus::ObjectPath(dbus_constants::kManagerServicePath)) { |
Christopher Wiley | 106686a | 2014-03-27 14:51:26 -0700 | [diff] [blame] | 41 | RegisterProperty(dbus_constants::kManagerInterface, "State", &state_); |
| 42 | } |
| 43 | virtual ~Properties() {} |
| 44 | }; |
| 45 | |
Alex Vakulenko | f3d77e5 | 2014-04-15 11:36:32 -0700 | [diff] [blame^] | 46 | // Handles calls to org.chromium.Buffet.Manager.CheckDeviceRegistered(). |
| 47 | scoped_ptr<dbus::Response> HandleCheckDeviceRegistered( |
| 48 | dbus::MethodCall* method_call); |
| 49 | // Handles calls to org.chromium.Buffet.Manager.GetDeviceInfo(). |
| 50 | scoped_ptr<dbus::Response> HandleGetDeviceInfo( |
| 51 | dbus::MethodCall* method_call); |
| 52 | // Handles calls to org.chromium.Buffet.Manager.StartRegisterDevice(). |
| 53 | scoped_ptr<dbus::Response> HandleStartRegisterDevice( |
| 54 | dbus::MethodCall* method_call); |
| 55 | // Handles calls to org.chromium.Buffet.Manager.FinishRegisterDevice(). |
| 56 | scoped_ptr<dbus::Response> HandleFinishRegisterDevice( |
Christopher Wiley | 4b5f04c | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 57 | dbus::MethodCall* method_call); |
| 58 | // Handles calls to org.chromium.Buffet.Manager.UpdateState(). |
| 59 | scoped_ptr<dbus::Response> HandleUpdateState( |
| 60 | dbus::MethodCall* method_call); |
| 61 | |
Christopher Wiley | 54028f9 | 2014-04-01 17:33:29 -0700 | [diff] [blame] | 62 | dbus::Bus* bus_; |
| 63 | dbus::ExportedObject* exported_object_; // weak; owned by the Bus object. |
Christopher Wiley | 106686a | 2014-03-27 14:51:26 -0700 | [diff] [blame] | 64 | scoped_ptr<Properties> properties_; |
Christopher Wiley | 4b5f04c | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 65 | |
Alex Vakulenko | f3d77e5 | 2014-04-15 11:36:32 -0700 | [diff] [blame^] | 66 | DeviceRegistrationInfo device_info_; |
| 67 | |
Christopher Wiley | 4b5f04c | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 68 | DISALLOW_COPY_AND_ASSIGN(Manager); |
| 69 | }; |
| 70 | |
| 71 | } // namespace buffet |
| 72 | |
| 73 | #endif // BUFFET_MANAGER_H_ |