Peter Qiu | f933540 | 2015-11-16 12:09:16 -0800 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2014 The Android Open Source Project |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | // |
| 16 | |
| 17 | #include "apmanager/dbus/device_dbus_adaptor.h" |
| 18 | |
| 19 | #include <base/strings/stringprintf.h> |
| 20 | #include <dbus_bindings/org.chromium.apmanager.Manager.h> |
| 21 | |
| 22 | #include "apmanager/device.h" |
| 23 | |
| 24 | using brillo::dbus_utils::ExportedObjectManager; |
| 25 | using brillo::dbus_utils::DBusObject; |
| 26 | using org::chromium::apmanager::ManagerAdaptor; |
| 27 | using std::string; |
| 28 | |
| 29 | namespace apmanager { |
| 30 | |
| 31 | DeviceDBusAdaptor::DeviceDBusAdaptor( |
| 32 | const scoped_refptr<dbus::Bus>& bus, |
| 33 | ExportedObjectManager* object_manager, |
| 34 | Device* device) |
| 35 | : adaptor_(this), |
| 36 | object_path_( |
| 37 | base::StringPrintf("%s/devices/%d", |
| 38 | ManagerAdaptor::GetObjectPath().value().c_str(), |
| 39 | device->identifier())), |
| 40 | dbus_object_(object_manager, bus, object_path_) { |
| 41 | // Register D-Bus object. |
Peter Qiu | 2ea547f | 2015-11-20 14:18:11 -0800 | [diff] [blame] | 42 | adaptor_.RegisterWithDBusObject(&dbus_object_); |
Peter Qiu | f933540 | 2015-11-16 12:09:16 -0800 | [diff] [blame] | 43 | dbus_object_.RegisterAndBlock(); |
| 44 | } |
| 45 | |
| 46 | DeviceDBusAdaptor::~DeviceDBusAdaptor() {} |
| 47 | |
| 48 | void DeviceDBusAdaptor::SetDeviceName(const string& device_name) { |
| 49 | adaptor_.SetDeviceName(device_name); |
| 50 | } |
| 51 | |
| 52 | string DeviceDBusAdaptor::GetDeviceName() { |
| 53 | return adaptor_.GetDeviceName(); |
| 54 | } |
| 55 | |
| 56 | void DeviceDBusAdaptor::SetPreferredApInterface(const string& interface_name) { |
| 57 | adaptor_.SetPreferredApInterface(interface_name); |
| 58 | } |
| 59 | |
| 60 | string DeviceDBusAdaptor::GetPreferredApInterface() { |
| 61 | return adaptor_.GetPreferredApInterface(); |
| 62 | } |
| 63 | |
| 64 | void DeviceDBusAdaptor::SetInUse(bool in_use) { |
| 65 | adaptor_.SetInUse(in_use); |
| 66 | } |
| 67 | |
| 68 | bool DeviceDBusAdaptor::GetInUse() { |
| 69 | return adaptor_.GetInUse(); |
| 70 | } |
| 71 | |
| 72 | } // namespace apmanager |