mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "shill/device_dbus_adaptor.h" |
| 6 | |
| 7 | #include <map> |
| 8 | #include <string> |
| 9 | |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 10 | #include "shill/device.h" |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 11 | #include "shill/error.h" |
Christopher Wiley | b691efd | 2012-08-09 13:51:51 -0700 | [diff] [blame] | 12 | #include "shill/logging.h" |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 13 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 14 | using std::map; |
| 15 | using std::string; |
Paul Stewart | d4f2648 | 2014-04-25 19:12:03 -0700 | [diff] [blame] | 16 | using std::vector; |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 17 | |
| 18 | namespace shill { |
| 19 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 20 | // static |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 21 | const char DeviceDBusAdaptor::kPath[] = "/device/"; |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 22 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 23 | DeviceDBusAdaptor::DeviceDBusAdaptor(DBus::Connection *conn, Device *device) |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 24 | : DBusAdaptor(conn, kPath + device->UniqueName()), |
Chris Masone | 4e85161 | 2011-07-01 10:46:53 -0700 | [diff] [blame] | 25 | device_(device), |
| 26 | connection_name_(conn->unique_name()) { |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 27 | } |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 28 | |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 29 | DeviceDBusAdaptor::~DeviceDBusAdaptor() { |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 30 | device_ = nullptr; |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 31 | } |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 32 | |
| 33 | const string &DeviceDBusAdaptor::GetRpcIdentifier() { |
Chris Masone | 4e85161 | 2011-07-01 10:46:53 -0700 | [diff] [blame] | 34 | return path(); |
| 35 | } |
| 36 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 37 | const string &DeviceDBusAdaptor::GetRpcConnectionIdentifier() { |
Chris Masone | 4e85161 | 2011-07-01 10:46:53 -0700 | [diff] [blame] | 38 | return connection_name_; |
| 39 | } |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 40 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 41 | void DeviceDBusAdaptor::EmitBoolChanged(const string &name, bool value) { |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 42 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName() |
| 43 | << " " << name; |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 44 | PropertyChanged(name, DBusAdaptor::BoolToVariant(value)); |
| 45 | } |
| 46 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 47 | void DeviceDBusAdaptor::EmitUintChanged(const string &name, |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 48 | uint32_t value) { |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 49 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName() |
| 50 | << " " << name; |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 51 | PropertyChanged(name, DBusAdaptor::Uint32ToVariant(value)); |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 52 | } |
| 53 | |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 54 | void DeviceDBusAdaptor::EmitUint16Changed(const string &name, uint16_t value) { |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 55 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName() |
| 56 | << " " << name; |
Prathmesh Prabhu | 700ff4d | 2014-01-16 15:59:33 -0800 | [diff] [blame] | 57 | PropertyChanged(name, DBusAdaptor::Uint16ToVariant(value)); |
| 58 | } |
| 59 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 60 | void DeviceDBusAdaptor::EmitIntChanged(const string &name, int value) { |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 61 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName() |
| 62 | << " " << name; |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 63 | PropertyChanged(name, DBusAdaptor::Int32ToVariant(value)); |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 66 | void DeviceDBusAdaptor::EmitStringChanged(const string &name, |
| 67 | const string &value) { |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 68 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName() |
| 69 | << " " << name; |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 70 | PropertyChanged(name, DBusAdaptor::StringToVariant(value)); |
| 71 | } |
| 72 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 73 | void DeviceDBusAdaptor::EmitStringmapChanged(const string &name, |
Prathmesh Prabhu | 9f06c87 | 2013-11-21 14:08:23 -0800 | [diff] [blame] | 74 | const Stringmap &value) { |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 75 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName() |
| 76 | << " " << name; |
Prathmesh Prabhu | 9f06c87 | 2013-11-21 14:08:23 -0800 | [diff] [blame] | 77 | PropertyChanged(name, DBusAdaptor::StringmapToVariant(value)); |
| 78 | } |
| 79 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 80 | void DeviceDBusAdaptor::EmitStringmapsChanged(const string &name, |
Darin Petkov | 3cfbf21 | 2011-11-21 16:02:09 +0100 | [diff] [blame] | 81 | const Stringmaps &value) { |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 82 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName() |
| 83 | << " " << name; |
Darin Petkov | 3cfbf21 | 2011-11-21 16:02:09 +0100 | [diff] [blame] | 84 | PropertyChanged(name, DBusAdaptor::StringmapsToVariant(value)); |
| 85 | } |
| 86 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 87 | void DeviceDBusAdaptor::EmitStringsChanged(const string &name, |
Prathmesh Prabhu | 700ff4d | 2014-01-16 15:59:33 -0800 | [diff] [blame] | 88 | const Strings &value) { |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 89 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName() |
| 90 | << " " << name; |
Prathmesh Prabhu | 700ff4d | 2014-01-16 15:59:33 -0800 | [diff] [blame] | 91 | PropertyChanged(name, DBusAdaptor::StringsToVariant(value)); |
| 92 | } |
| 93 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 94 | void DeviceDBusAdaptor::EmitKeyValueStoreChanged(const string &name, |
Darin Petkov | 63138a9 | 2012-02-06 14:09:15 +0100 | [diff] [blame] | 95 | const KeyValueStore &value) { |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 96 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName() |
| 97 | << " " << name; |
Darin Petkov | 63138a9 | 2012-02-06 14:09:15 +0100 | [diff] [blame] | 98 | PropertyChanged(name, DBusAdaptor::KeyValueStoreToVariant(value)); |
| 99 | } |
| 100 | |
Paul Stewart | d4f2648 | 2014-04-25 19:12:03 -0700 | [diff] [blame] | 101 | void DeviceDBusAdaptor::EmitRpcIdentifierArrayChanged( |
| 102 | const string &name, |
| 103 | const vector<string> &value) { |
| 104 | SLOG(DBus, 2) << __func__ << ": " << name; |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 105 | vector<DBus::Path> paths; |
Paul Stewart | 6db7b24 | 2014-05-02 15:34:21 -0700 | [diff] [blame] | 106 | for (const auto &element : value) { |
| 107 | paths.push_back(element); |
Paul Stewart | d4f2648 | 2014-04-25 19:12:03 -0700 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | PropertyChanged(name, DBusAdaptor::PathsToVariant(paths)); |
| 111 | } |
| 112 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 113 | map<string, DBus::Variant> DeviceDBusAdaptor::GetProperties( |
| 114 | DBus::Error &error) { // NOLINT |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 115 | SLOG(DBus, 2) << __func__ << " " << device_->UniqueName(); |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 116 | map<string, DBus::Variant> properties; |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 117 | DBusAdaptor::GetProperties(device_->store(), &properties, &error); |
Chris Masone | a8a2c25 | 2011-06-27 22:16:30 -0700 | [diff] [blame] | 118 | return properties; |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 119 | } |
| 120 | |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 121 | void DeviceDBusAdaptor::SetProperty(const string &name, |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 122 | const DBus::Variant &value, |
| 123 | DBus::Error &error) { // NOLINT |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 124 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName() |
| 125 | << " " << name; |
mukesh agrawal | 6bb9e7c | 2012-01-30 14:57:54 -0800 | [diff] [blame] | 126 | DBusAdaptor::SetProperty(device_->mutable_store(), name, value, &error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 127 | } |
| 128 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 129 | void DeviceDBusAdaptor::ClearProperty(const string &name, |
| 130 | DBus::Error &error) { // NOLINT |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 131 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName() |
| 132 | << " " << name; |
mukesh agrawal | 8abd2f6 | 2012-01-30 14:56:14 -0800 | [diff] [blame] | 133 | DBusAdaptor::ClearProperty(device_->mutable_store(), name, &error); |
Chris Masone | ccc8881 | 2011-06-08 18:00:10 -0700 | [diff] [blame] | 134 | } |
| 135 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 136 | void DeviceDBusAdaptor::Enable(DBus::Error &error) { // NOLINT |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 137 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 138 | Error e(Error::kOperationInitiated); |
| 139 | DBus::Tag *tag = new DBus::Tag(); |
| 140 | device_->SetEnabledPersistent(true, &e, GetMethodReplyCallback(tag)); |
| 141 | ReturnResultOrDefer(tag, e, &error); |
| 142 | } |
| 143 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 144 | void DeviceDBusAdaptor::Disable(DBus::Error &error) { // NOLINT |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 145 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 146 | Error e(Error::kOperationInitiated); |
| 147 | DBus::Tag *tag = new DBus::Tag(); |
| 148 | device_->SetEnabledPersistent(false, &e, GetMethodReplyCallback(tag)); |
| 149 | ReturnResultOrDefer(tag, e, &error); |
| 150 | } |
| 151 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 152 | void DeviceDBusAdaptor::ProposeScan(DBus::Error &error) { // NOLINT |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 153 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName(); |
Darin Petkov | c086531 | 2011-09-16 15:31:20 -0700 | [diff] [blame] | 154 | Error e; |
Wade Guthrie | 68d4109 | 2013-04-02 12:56:02 -0700 | [diff] [blame] | 155 | // User scan requests, which are the likely source of DBus requests, probably |
| 156 | // aren't time-critical so we might as well perform a complete scan. It |
| 157 | // also provides a failsafe for progressive scan. |
Wade Guthrie | 4823f4f | 2013-07-25 10:03:03 -0700 | [diff] [blame] | 158 | device_->Scan(Device::kFullScan, &e, __func__); |
Darin Petkov | c086531 | 2011-09-16 15:31:20 -0700 | [diff] [blame] | 159 | e.ToDBusError(&error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 160 | } |
| 161 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 162 | DBus::Path DeviceDBusAdaptor::AddIPConfig(const string &/*method*/, |
| 163 | DBus::Error &error) { // NOLINT |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 164 | SLOG(DBus, 2) << __func__; |
Paul Stewart | 624b9a2 | 2012-05-21 14:17:35 -0700 | [diff] [blame] | 165 | Error e(Error::kNotSupported, "This function is deprecated in shill"); |
| 166 | e.ToDBusError(&error); |
Darin Petkov | fd164b8 | 2012-02-10 14:11:52 +0100 | [diff] [blame] | 167 | return "/"; |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 168 | } |
| 169 | |
Darin Petkov | 9ae310f | 2011-08-30 15:41:13 -0700 | [diff] [blame] | 170 | void DeviceDBusAdaptor::Register(const string &network_id, |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 171 | DBus::Error &error) { // NOLINT |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 172 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName() |
| 173 | << " (" << network_id << ")"; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 174 | Error e(Error::kOperationInitiated); |
| 175 | DBus::Tag *tag = new DBus::Tag(); |
| 176 | device_->RegisterOnNetwork(network_id, &e, GetMethodReplyCallback(tag)); |
| 177 | ReturnResultOrDefer(tag, e, &error); |
Chris Masone | ccc8881 | 2011-06-08 18:00:10 -0700 | [diff] [blame] | 178 | } |
| 179 | |
Darin Petkov | c64fe5e | 2012-01-11 12:46:13 +0100 | [diff] [blame] | 180 | void DeviceDBusAdaptor::RequirePin( |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 181 | const string &pin, const bool &require, DBus::Error &error) { // NOLINT |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 182 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 183 | Error e(Error::kOperationInitiated); |
| 184 | DBus::Tag *tag = new DBus::Tag(); |
| 185 | device_->RequirePIN(pin, require, &e, GetMethodReplyCallback(tag)); |
| 186 | ReturnResultOrDefer(tag, e, &error); |
Chris Masone | ccc8881 | 2011-06-08 18:00:10 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 189 | void DeviceDBusAdaptor::EnterPin(const string &pin, |
| 190 | DBus::Error &error) { // NOLINT |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 191 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 192 | Error e(Error::kOperationInitiated); |
| 193 | DBus::Tag *tag = new DBus::Tag(); |
| 194 | device_->EnterPIN(pin, &e, GetMethodReplyCallback(tag)); |
| 195 | ReturnResultOrDefer(tag, e, &error); |
Chris Masone | ccc8881 | 2011-06-08 18:00:10 -0700 | [diff] [blame] | 196 | } |
| 197 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 198 | void DeviceDBusAdaptor::UnblockPin(const string &unblock_code, |
| 199 | const string &pin, |
| 200 | DBus::Error &error) { // NOLINT |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 201 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 202 | Error e(Error::kOperationInitiated); |
| 203 | DBus::Tag *tag = new DBus::Tag(); |
| 204 | device_->UnblockPIN(unblock_code, pin, &e, GetMethodReplyCallback(tag)); |
| 205 | ReturnResultOrDefer(tag, e, &error); |
Chris Masone | ccc8881 | 2011-06-08 18:00:10 -0700 | [diff] [blame] | 206 | } |
| 207 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 208 | void DeviceDBusAdaptor::ChangePin(const string &old_pin, |
| 209 | const string &new_pin, |
| 210 | DBus::Error &error) { // NOLINT |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 211 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName(); |
Darin Petkov | c37a9c4 | 2012-09-06 15:28:22 +0200 | [diff] [blame] | 212 | Error e(Error::kOperationInitiated); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 213 | DBus::Tag *tag = new DBus::Tag(); |
| 214 | device_->ChangePIN(old_pin, new_pin, &e, GetMethodReplyCallback(tag)); |
| 215 | ReturnResultOrDefer(tag, e, &error); |
Chris Masone | ccc8881 | 2011-06-08 18:00:10 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 218 | void DeviceDBusAdaptor::Reset(DBus::Error &error) { // NOLINT |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 219 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName(); |
Ben Chan | ad663e1 | 2013-01-08 01:58:47 -0800 | [diff] [blame] | 220 | Error e(Error::kOperationInitiated); |
| 221 | DBus::Tag *tag = new DBus::Tag(); |
| 222 | device_->Reset(&e, GetMethodReplyCallback(tag)); |
| 223 | ReturnResultOrDefer(tag, e, &error); |
| 224 | } |
| 225 | |
Paul Stewart | c6fbad9 | 2013-11-13 14:50:52 -0800 | [diff] [blame] | 226 | string DeviceDBusAdaptor::PerformTDLSOperation(const string &operation, |
| 227 | const string &peer, |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 228 | DBus::Error &error) { // NOLINT |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 229 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName(); |
Paul Stewart | c6fbad9 | 2013-11-13 14:50:52 -0800 | [diff] [blame] | 230 | Error e; |
| 231 | string return_value = device_->PerformTDLSOperation(operation, peer, &e); |
| 232 | e.ToDBusError(&error); |
| 233 | return return_value; |
| 234 | } |
| 235 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 236 | void DeviceDBusAdaptor::ResetByteCounters(DBus::Error &error) { // NOLINT |
Paul Stewart | 6ff27f5 | 2012-07-11 06:51:41 -0700 | [diff] [blame] | 237 | device_->ResetByteCounters(); |
| 238 | } |
| 239 | |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 240 | void DeviceDBusAdaptor::SetCarrier(const string &carrier, |
| 241 | DBus::Error &error) { // NOLINT |
Peter Qiu | 047a21c | 2014-04-01 11:48:50 -0700 | [diff] [blame] | 242 | SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName() |
| 243 | << "(" << carrier << ")"; |
Darin Petkov | c37a9c4 | 2012-09-06 15:28:22 +0200 | [diff] [blame] | 244 | Error e(Error::kOperationInitiated); |
| 245 | DBus::Tag *tag = new DBus::Tag(); |
| 246 | device_->SetCarrier(carrier, &e, GetMethodReplyCallback(tag)); |
| 247 | ReturnResultOrDefer(tag, e, &error); |
| 248 | } |
| 249 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 250 | } // namespace shill |