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