mukesh agrawal | 6bb9e7c | 2012-01-30 14:57:54 -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/manager_dbus_adaptor.h" |
| 6 | |
| 7 | #include <map> |
| 8 | #include <string> |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 9 | #include <vector> |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 10 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 11 | #include <dbus-c++/dbus.h> |
| 12 | |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 13 | #include "shill/device.h" |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 14 | #include "shill/error.h" |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 15 | #include "shill/key_value_store.h" |
Christopher Wiley | b691efd | 2012-08-09 13:51:51 -0700 | [diff] [blame] | 16 | #include "shill/logging.h" |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 17 | #include "shill/manager.h" |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 18 | #include "shill/wifi_service.h" |
Chris Masone | 7ccc819 | 2011-05-24 14:54:49 -0700 | [diff] [blame] | 19 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 20 | using std::map; |
| 21 | using std::string; |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 22 | using std::vector; |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 23 | |
| 24 | namespace shill { |
| 25 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 26 | // static |
Chris Masone | 19e3040 | 2011-07-19 15:48:47 -0700 | [diff] [blame] | 27 | const char ManagerDBusAdaptor::kPath[] = "/"; |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 28 | |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 29 | ManagerDBusAdaptor::ManagerDBusAdaptor(DBus::Connection* conn, Manager *manager) |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 30 | : DBusAdaptor(conn, kPath), |
| 31 | manager_(manager) { |
| 32 | } |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 33 | |
| 34 | ManagerDBusAdaptor::~ManagerDBusAdaptor() { |
| 35 | manager_ = NULL; |
| 36 | } |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 37 | |
| 38 | void ManagerDBusAdaptor::UpdateRunning() {} |
| 39 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 40 | void ManagerDBusAdaptor::EmitBoolChanged(const string &name, bool value) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 41 | SLOG(DBus, 2) << __func__ << ": " << name; |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 42 | PropertyChanged(name, DBusAdaptor::BoolToVariant(value)); |
| 43 | } |
| 44 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 45 | void ManagerDBusAdaptor::EmitUintChanged(const string &name, |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 46 | uint32 value) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 47 | SLOG(DBus, 2) << __func__ << ": " << name; |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 48 | PropertyChanged(name, DBusAdaptor::Uint32ToVariant(value)); |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 49 | } |
| 50 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 51 | void ManagerDBusAdaptor::EmitIntChanged(const string &name, int value) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 52 | SLOG(DBus, 2) << __func__ << ": " << name; |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 53 | PropertyChanged(name, DBusAdaptor::Int32ToVariant(value)); |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 56 | void ManagerDBusAdaptor::EmitStringChanged(const string &name, |
| 57 | const string &value) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 58 | SLOG(DBus, 2) << __func__ << ": " << name; |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 59 | PropertyChanged(name, DBusAdaptor::StringToVariant(value)); |
| 60 | } |
| 61 | |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 62 | void ManagerDBusAdaptor::EmitStringsChanged(const string &name, |
| 63 | const vector<string> &value) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 64 | SLOG(DBus, 2) << __func__ << ": " << name; |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 65 | PropertyChanged(name, DBusAdaptor::StringsToVariant(value)); |
| 66 | } |
| 67 | |
Paul Stewart | 49739c0 | 2012-08-08 17:24:03 -0700 | [diff] [blame] | 68 | void ManagerDBusAdaptor::EmitRpcIdentifierChanged( |
| 69 | const string &name, |
| 70 | const string &value) { |
| 71 | SLOG(DBus, 2) << __func__ << ": " << name; |
| 72 | PropertyChanged(name, DBusAdaptor::PathToVariant(value)); |
| 73 | } |
| 74 | |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 75 | void ManagerDBusAdaptor::EmitRpcIdentifierArrayChanged( |
| 76 | const string &name, |
| 77 | const vector<string> &value) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 78 | SLOG(DBus, 2) << __func__ << ": " << name; |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 79 | vector< ::DBus::Path> paths; |
| 80 | vector<string>::const_iterator it; |
| 81 | for (it = value.begin(); it != value.end(); ++it) { |
| 82 | paths.push_back(*it); |
| 83 | } |
| 84 | |
mukesh agrawal | 2366eed | 2012-03-20 18:21:50 -0700 | [diff] [blame] | 85 | PropertyChanged(name, DBusAdaptor::PathsToVariant(paths)); |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 88 | void ManagerDBusAdaptor::EmitStateChanged(const string &new_state) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 89 | SLOG(DBus, 2) << __func__; |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 90 | StateChanged(new_state); |
| 91 | } |
| 92 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 93 | map<string, ::DBus::Variant> ManagerDBusAdaptor::GetProperties( |
| 94 | ::DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 95 | SLOG(DBus, 2) << __func__; |
Chris Masone | a8a2c25 | 2011-06-27 22:16:30 -0700 | [diff] [blame] | 96 | map<string, ::DBus::Variant> properties; |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 97 | DBusAdaptor::GetProperties(manager_->store(), &properties, &error); |
Chris Masone | a8a2c25 | 2011-06-27 22:16:30 -0700 | [diff] [blame] | 98 | return properties; |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 99 | } |
| 100 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 101 | void ManagerDBusAdaptor::SetProperty(const string &name, |
| 102 | const ::DBus::Variant &value, |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 103 | ::DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 104 | SLOG(DBus, 2) << __func__ << ": " << name; |
mukesh agrawal | 6bb9e7c | 2012-01-30 14:57:54 -0800 | [diff] [blame] | 105 | if (DBusAdaptor::SetProperty(manager_->mutable_store(), |
| 106 | name, |
| 107 | value, |
| 108 | &error)) { |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 109 | PropertyChanged(name, value); |
| 110 | } |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 111 | } |
| 112 | |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 113 | string ManagerDBusAdaptor::GetState(::DBus::Error &/*error*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 114 | SLOG(DBus, 2) << __func__; |
Paul Stewart | 38fd24c | 2012-04-25 14:06:29 -0700 | [diff] [blame] | 115 | return manager_->CalculateState(NULL); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 116 | } |
| 117 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 118 | ::DBus::Path ManagerDBusAdaptor::CreateProfile(const string &name, |
Paul Stewart | 19c871d | 2011-12-15 16:10:13 -0800 | [diff] [blame] | 119 | ::DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 120 | SLOG(DBus, 2) << __func__ << ": " << name; |
Paul Stewart | 19c871d | 2011-12-15 16:10:13 -0800 | [diff] [blame] | 121 | Error e; |
| 122 | string path; |
| 123 | manager_->CreateProfile(name, &path, &e); |
| 124 | e.ToDBusError(&error); |
| 125 | return ::DBus::Path(path); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 126 | } |
| 127 | |
Paul Stewart | e73d05c | 2012-03-29 16:26:05 -0700 | [diff] [blame] | 128 | void ManagerDBusAdaptor::RemoveProfile(const string &name, |
| 129 | ::DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 130 | SLOG(DBus, 2) << __func__ << ": " << name; |
Paul Stewart | e73d05c | 2012-03-29 16:26:05 -0700 | [diff] [blame] | 131 | Error e; |
| 132 | manager_->RemoveProfile(name, &e); |
| 133 | e.ToDBusError(&error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 134 | } |
| 135 | |
mukesh agrawal | e5929bf | 2011-08-29 13:47:23 -0700 | [diff] [blame] | 136 | ::DBus::Path ManagerDBusAdaptor::PushProfile(const std::string &name, |
Paul Stewart | 19c871d | 2011-12-15 16:10:13 -0800 | [diff] [blame] | 137 | ::DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 138 | SLOG(DBus, 2) << __func__ << ": " << name; |
Paul Stewart | 19c871d | 2011-12-15 16:10:13 -0800 | [diff] [blame] | 139 | Error e; |
| 140 | string path; |
| 141 | manager_->PushProfile(name, &path, &e); |
| 142 | e.ToDBusError(&error); |
| 143 | return ::DBus::Path(path); |
Chris Masone | ccc8881 | 2011-06-08 18:00:10 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Paul Stewart | 19c871d | 2011-12-15 16:10:13 -0800 | [diff] [blame] | 146 | void ManagerDBusAdaptor::PopProfile(const std::string &name, |
| 147 | ::DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 148 | SLOG(DBus, 2) << __func__ << ": " << name; |
Paul Stewart | 19c871d | 2011-12-15 16:10:13 -0800 | [diff] [blame] | 149 | Error e; |
| 150 | manager_->PopProfile(name, &e); |
| 151 | e.ToDBusError(&error); |
Chris Masone | ccc8881 | 2011-06-08 18:00:10 -0700 | [diff] [blame] | 152 | } |
| 153 | |
Paul Stewart | 19c871d | 2011-12-15 16:10:13 -0800 | [diff] [blame] | 154 | void ManagerDBusAdaptor::PopAnyProfile(::DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 155 | SLOG(DBus, 2) << __func__; |
Paul Stewart | 19c871d | 2011-12-15 16:10:13 -0800 | [diff] [blame] | 156 | Error e; |
| 157 | manager_->PopAnyProfile(&e); |
| 158 | e.ToDBusError(&error); |
Chris Masone | ccc8881 | 2011-06-08 18:00:10 -0700 | [diff] [blame] | 159 | } |
| 160 | |
Paul Stewart | c681fa0 | 2012-03-02 19:40:04 -0800 | [diff] [blame] | 161 | void ManagerDBusAdaptor::RecheckPortal(::DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 162 | SLOG(DBus, 2) << __func__; |
Paul Stewart | c681fa0 | 2012-03-02 19:40:04 -0800 | [diff] [blame] | 163 | Error e; |
| 164 | manager_->RecheckPortal(&e); |
| 165 | e.ToDBusError(&error); |
| 166 | } |
| 167 | |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 168 | void ManagerDBusAdaptor::RequestScan(const string &technology, |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 169 | ::DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 170 | SLOG(DBus, 2) << __func__ << ": " << technology; |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 171 | Error e; |
| 172 | manager_->RequestScan(technology, &e); |
| 173 | e.ToDBusError(&error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 174 | } |
| 175 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 176 | void ManagerDBusAdaptor::EnableTechnology(const string &technology_name, |
| 177 | ::DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 178 | SLOG(DBus, 2) << __func__ << ": " << technology_name; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 179 | Error e(Error::kOperationInitiated); |
| 180 | DBus::Tag *tag = new DBus::Tag(); |
| 181 | manager_->EnableTechnology(technology_name, &e, GetMethodReplyCallback(tag)); |
| 182 | ReturnResultOrDefer(tag, e, &error); |
| 183 | // TODO(ers): A reply will be sent to the client as soon as the first |
| 184 | // device of a given technology has finished being enabled. It would |
| 185 | // seem arguably more correct to wait until all the devices were enabled. |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 186 | } |
| 187 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 188 | void ManagerDBusAdaptor::DisableTechnology(const string &technology_name, |
| 189 | ::DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 190 | SLOG(DBus, 2) << __func__ << ": " << technology_name; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 191 | Error e(Error::kOperationInitiated); |
| 192 | DBus::Tag *tag = new DBus::Tag(); |
| 193 | manager_->DisableTechnology(technology_name, &e, GetMethodReplyCallback(tag)); |
| 194 | ReturnResultOrDefer(tag, e, &error); |
| 195 | // TODO(ers): A reply will be sent to the client as soon as the first |
| 196 | // device of a given technology has finished being disabled. It would |
| 197 | // seem arguably more correct to wait until all the devices were enabled. |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 198 | } |
| 199 | |
Darin Petkov | b65c245 | 2012-02-23 15:17:06 +0100 | [diff] [blame] | 200 | // Called, e.g., to get WiFiService handle for a hidden SSID. |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 201 | ::DBus::Path ManagerDBusAdaptor::GetService( |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 202 | const map<string, ::DBus::Variant> &args, |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 203 | ::DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 204 | SLOG(DBus, 2) << __func__; |
Darin Petkov | b65c245 | 2012-02-23 15:17:06 +0100 | [diff] [blame] | 205 | ServiceRefPtr service; |
| 206 | KeyValueStore args_store; |
| 207 | Error e; |
| 208 | DBusAdaptor::ArgsToKeyValueStore(args, &args_store, &e); |
| 209 | if (e.IsSuccess()) { |
| 210 | service = manager_->GetService(args_store, &e); |
| 211 | } |
| 212 | if (e.ToDBusError(&error)) { |
| 213 | return "/"; // ensure return is syntactically valid |
| 214 | } |
| 215 | return service->GetRpcIdentifier(); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Darin Petkov | b65c245 | 2012-02-23 15:17:06 +0100 | [diff] [blame] | 218 | // Obsolete, use GetService instead. |
| 219 | ::DBus::Path ManagerDBusAdaptor::GetVPNService( |
| 220 | const map<string, ::DBus::Variant> &args, |
| 221 | ::DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 222 | SLOG(DBus, 2) << __func__; |
Darin Petkov | b65c245 | 2012-02-23 15:17:06 +0100 | [diff] [blame] | 223 | return GetService(args, error); |
| 224 | } |
| 225 | |
| 226 | // Obsolete, use GetService instead. |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 227 | ::DBus::Path ManagerDBusAdaptor::GetWifiService( |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 228 | const map<string, ::DBus::Variant> &args, |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 229 | ::DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 230 | SLOG(DBus, 2) << __func__; |
Darin Petkov | b65c245 | 2012-02-23 15:17:06 +0100 | [diff] [blame] | 231 | return GetService(args, error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 232 | } |
| 233 | |
Paul Stewart | 7f61e52 | 2012-03-22 11:13:45 -0700 | [diff] [blame] | 234 | |
| 235 | void ManagerDBusAdaptor::ConfigureService( |
| 236 | const map<string, ::DBus::Variant> &args, |
| 237 | ::DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 238 | SLOG(DBus, 2) << __func__; |
Paul Stewart | 7f61e52 | 2012-03-22 11:13:45 -0700 | [diff] [blame] | 239 | KeyValueStore args_store; |
| 240 | Error e; |
| 241 | DBusAdaptor::ArgsToKeyValueStore(args, &args_store, &e); |
| 242 | if (e.IsSuccess()) { |
| 243 | manager_->ConfigureService(args_store, &e); |
| 244 | } |
| 245 | e.ToDBusError(&error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 246 | } |
| 247 | |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 248 | int32_t ManagerDBusAdaptor::GetDebugLevel(::DBus::Error &/*error*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 249 | SLOG(DBus, 2) << __func__; |
Chris Masone | 7ccc819 | 2011-05-24 14:54:49 -0700 | [diff] [blame] | 250 | return logging::GetMinLogLevel(); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 251 | } |
| 252 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 253 | void ManagerDBusAdaptor::SetDebugLevel(const int32_t &level, |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 254 | ::DBus::Error &/*error*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 255 | SLOG(DBus, 2) << __func__ << ": " << level; |
Ben Chan | bc49ac7 | 2012-04-10 19:59:45 -0700 | [diff] [blame] | 256 | if (level < logging::LOG_NUM_SEVERITIES) { |
Chris Masone | 7ccc819 | 2011-05-24 14:54:49 -0700 | [diff] [blame] | 257 | logging::SetMinLogLevel(level); |
Ben Chan | bc49ac7 | 2012-04-10 19:59:45 -0700 | [diff] [blame] | 258 | // Like VLOG, SLOG uses negative verbose level. |
| 259 | ScopeLogger::GetInstance()->set_verbose_level(-level); |
| 260 | } else { |
Chris Masone | 7ccc819 | 2011-05-24 14:54:49 -0700 | [diff] [blame] | 261 | LOG(WARNING) << "Ignoring attempt to set log level to " << level; |
Ben Chan | bc49ac7 | 2012-04-10 19:59:45 -0700 | [diff] [blame] | 262 | } |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 263 | } |
| 264 | |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 265 | string ManagerDBusAdaptor::GetServiceOrder(::DBus::Error &/*error*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 266 | SLOG(DBus, 2) << __func__; |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 267 | return manager_->GetTechnologyOrder(); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 268 | } |
| 269 | |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 270 | void ManagerDBusAdaptor::SetServiceOrder(const string &order, |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 271 | ::DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 272 | SLOG(DBus, 2) << __func__ << ": " << order; |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 273 | Error e; |
| 274 | manager_->SetTechnologyOrder(order, &e); |
| 275 | e.ToDBusError(&error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 276 | } |
| 277 | |
Elly Jones | 16227d3 | 2012-02-09 14:17:25 -0500 | [diff] [blame] | 278 | std::string ManagerDBusAdaptor::GetDebugTags(::DBus::Error &/*error*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 279 | SLOG(DBus, 2) << __func__; |
Ben Chan | bc49ac7 | 2012-04-10 19:59:45 -0700 | [diff] [blame] | 280 | return ScopeLogger::GetInstance()->GetEnabledScopeNames(); |
Elly Jones | 16227d3 | 2012-02-09 14:17:25 -0500 | [diff] [blame] | 281 | } |
| 282 | |
Ben Chan | bc49ac7 | 2012-04-10 19:59:45 -0700 | [diff] [blame] | 283 | void ManagerDBusAdaptor::SetDebugTags(const std::string &tags, |
Elly Jones | 16227d3 | 2012-02-09 14:17:25 -0500 | [diff] [blame] | 284 | ::DBus::Error &/*error*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 285 | SLOG(DBus, 2) << __func__ << ": " << tags; |
Ben Chan | bc49ac7 | 2012-04-10 19:59:45 -0700 | [diff] [blame] | 286 | ScopeLogger::GetInstance()->EnableScopesByName(tags); |
Elly Jones | 16227d3 | 2012-02-09 14:17:25 -0500 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | std::string ManagerDBusAdaptor::ListDebugTags(::DBus::Error &/*error*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 290 | SLOG(DBus, 2) << __func__; |
Ben Chan | bc49ac7 | 2012-04-10 19:59:45 -0700 | [diff] [blame] | 291 | return ScopeLogger::GetInstance()->GetAllScopeNames(); |
Elly Jones | 16227d3 | 2012-02-09 14:17:25 -0500 | [diff] [blame] | 292 | } |
| 293 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 294 | } // namespace shill |