blob: 721d8d56433b9b73fd2cb4f42d31e6752257111e [file] [log] [blame]
Peter Qiuf9335402015-11-16 12:09:16 -08001//
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
24using brillo::dbus_utils::ExportedObjectManager;
25using brillo::dbus_utils::DBusObject;
26using org::chromium::apmanager::ManagerAdaptor;
27using std::string;
28
29namespace apmanager {
30
31DeviceDBusAdaptor::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 Qiu2ea547f2015-11-20 14:18:11 -080042 adaptor_.RegisterWithDBusObject(&dbus_object_);
Peter Qiuf9335402015-11-16 12:09:16 -080043 dbus_object_.RegisterAndBlock();
44}
45
46DeviceDBusAdaptor::~DeviceDBusAdaptor() {}
47
48void DeviceDBusAdaptor::SetDeviceName(const string& device_name) {
49 adaptor_.SetDeviceName(device_name);
50}
51
52string DeviceDBusAdaptor::GetDeviceName() {
53 return adaptor_.GetDeviceName();
54}
55
56void DeviceDBusAdaptor::SetPreferredApInterface(const string& interface_name) {
57 adaptor_.SetPreferredApInterface(interface_name);
58}
59
60string DeviceDBusAdaptor::GetPreferredApInterface() {
61 return adaptor_.GetPreferredApInterface();
62}
63
64void DeviceDBusAdaptor::SetInUse(bool in_use) {
65 adaptor_.SetInUse(in_use);
66}
67
68bool DeviceDBusAdaptor::GetInUse() {
69 return adaptor_.GetInUse();
70}
71
72} // namespace apmanager