Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 5 | #include "shill/manager.h" |
| 6 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 7 | #include <time.h> |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 8 | #include <stdio.h> |
Chris Masone | ee929b7 | 2011-05-10 10:02:18 -0700 | [diff] [blame] | 9 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 10 | #include <string> |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 11 | #include <vector> |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 12 | |
Paul Stewart | e613202 | 2011-08-16 09:11:02 -0700 | [diff] [blame] | 13 | #include <base/file_util.h> |
Chris Masone | ee929b7 | 2011-05-10 10:02:18 -0700 | [diff] [blame] | 14 | #include <base/logging.h> |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 15 | #include <base/memory/ref_counted.h> |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 16 | #include <chromeos/dbus/service_constants.h> |
Chris Masone | ee929b7 | 2011-05-10 10:02:18 -0700 | [diff] [blame] | 17 | |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 18 | #include "shill/adaptor_interfaces.h" |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 19 | #include "shill/control_interface.h" |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 20 | #include "shill/dbus_adaptor.h" |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 21 | #include "shill/default_profile.h" |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 22 | #include "shill/device.h" |
| 23 | #include "shill/device_info.h" |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 24 | #include "shill/ephemeral_profile.h" |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 25 | #include "shill/error.h" |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 26 | #include "shill/profile.h" |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 27 | #include "shill/property_accessor.h" |
Paul Stewart | e613202 | 2011-08-16 09:11:02 -0700 | [diff] [blame] | 28 | #include "shill/resolver.h" |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 29 | #include "shill/shill_event.h" |
| 30 | #include "shill/service.h" |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 31 | |
| 32 | using std::string; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 33 | using std::vector; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 34 | |
| 35 | namespace shill { |
Paul Stewart | e613202 | 2011-08-16 09:11:02 -0700 | [diff] [blame] | 36 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 37 | Manager::Manager(ControlInterface *control_interface, |
Darin Petkov | 887f298 | 2011-07-14 16:10:17 -0700 | [diff] [blame] | 38 | EventDispatcher *dispatcher, |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 39 | GLib *glib, |
| 40 | const string &run_directory, |
| 41 | const string &storage_directory, |
| 42 | const string &user_storage_format) |
| 43 | : run_path_(FilePath(run_directory)), |
| 44 | storage_path_(FilePath(storage_directory)), |
| 45 | user_storage_format_(user_storage_format), |
Paul Stewart | e613202 | 2011-08-16 09:11:02 -0700 | [diff] [blame] | 46 | adaptor_(control_interface->CreateManagerAdaptor(this)), |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 47 | device_info_(control_interface, dispatcher, this), |
Darin Petkov | 887f298 | 2011-07-14 16:10:17 -0700 | [diff] [blame] | 48 | modem_info_(control_interface, dispatcher, this, glib), |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 49 | running_(false), |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 50 | ephemeral_profile_(new EphemeralProfile(control_interface, glib, this)), |
| 51 | control_interface_(control_interface), |
| 52 | glib_(glib) { |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 53 | HelpRegisterDerivedString(flimflam::kActiveProfileProperty, |
| 54 | &Manager::GetActiveProfileName, |
| 55 | NULL); |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 56 | HelpRegisterDerivedStrings(flimflam::kAvailableTechnologiesProperty, |
| 57 | &Manager::AvailableTechnologies, |
| 58 | NULL); |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 59 | store_.RegisterString(flimflam::kCheckPortalListProperty, |
| 60 | &props_.check_portal_list); |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 61 | HelpRegisterDerivedStrings(flimflam::kConnectedTechnologiesProperty, |
| 62 | &Manager::ConnectedTechnologies, |
| 63 | NULL); |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 64 | store_.RegisterString(flimflam::kCountryProperty, &props_.country); |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 65 | HelpRegisterDerivedString(flimflam::kDefaultTechnologyProperty, |
| 66 | &Manager::DefaultTechnology, |
| 67 | NULL); |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 68 | HelpRegisterDerivedStrings(flimflam::kDevicesProperty, |
| 69 | &Manager::EnumerateDevices, |
| 70 | NULL); |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 71 | HelpRegisterDerivedStrings(flimflam::kEnabledTechnologiesProperty, |
| 72 | &Manager::EnabledTechnologies, |
| 73 | NULL); |
| 74 | store_.RegisterBool(flimflam::kOfflineModeProperty, &props_.offline_mode); |
| 75 | store_.RegisterString(flimflam::kPortalURLProperty, &props_.portal_url); |
| 76 | HelpRegisterDerivedString(flimflam::kStateProperty, |
| 77 | &Manager::CalculateState, |
| 78 | NULL); |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 79 | HelpRegisterDerivedStrings(flimflam::kServicesProperty, |
| 80 | &Manager::EnumerateAvailableServices, |
| 81 | NULL); |
| 82 | HelpRegisterDerivedStrings(flimflam::kServiceWatchListProperty, |
| 83 | &Manager::EnumerateWatchedServices, |
| 84 | NULL); |
Chris Masone | 3c3f6a1 | 2011-07-01 10:01:41 -0700 | [diff] [blame] | 85 | |
Chris Masone | 4d42df8 | 2011-07-02 17:09:39 -0700 | [diff] [blame] | 86 | // TODO(cmasone): Wire these up once we actually put in profile support. |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 87 | // known_properties_.push_back(flimflam::kProfilesProperty); |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 88 | profiles_.push_back(new DefaultProfile(control_interface_, |
| 89 | glib_, |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 90 | this, |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 91 | storage_path_, |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 92 | props_)); |
Chris Masone | b07006b | 2011-05-14 16:10:04 -0700 | [diff] [blame] | 93 | VLOG(2) << "Manager initialized."; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 94 | } |
| 95 | |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 96 | Manager::~Manager() { |
| 97 | vector<ProfileRefPtr>::iterator it; |
| 98 | for (it = profiles_.begin(); it != profiles_.end(); ++it) { |
| 99 | (*it)->Finalize(); |
| 100 | } |
| 101 | ephemeral_profile_->Finalize(); |
| 102 | } |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 103 | |
mukesh agrawal | 8f317b6 | 2011-07-15 11:53:23 -0700 | [diff] [blame] | 104 | void Manager::AddDeviceToBlackList(const string &device_name) { |
| 105 | device_info_.AddDeviceToBlackList(device_name); |
| 106 | } |
| 107 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 108 | void Manager::Start() { |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 109 | LOG(INFO) << "Manager started."; |
Paul Stewart | e613202 | 2011-08-16 09:11:02 -0700 | [diff] [blame] | 110 | |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 111 | CHECK(file_util::CreateDirectory(run_path_)) << run_path_.value(); |
Paul Stewart | e613202 | 2011-08-16 09:11:02 -0700 | [diff] [blame] | 112 | Resolver::GetInstance()->set_path(run_path_.Append("resolv.conf")); |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 113 | |
| 114 | CHECK(file_util::CreateDirectory(storage_path_)) << storage_path_.value(); |
| 115 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 116 | running_ = true; |
Chris Masone | 413a319 | 2011-05-09 17:10:05 -0700 | [diff] [blame] | 117 | adaptor_->UpdateRunning(); |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 118 | device_info_.Start(); |
Darin Petkov | 887f298 | 2011-07-14 16:10:17 -0700 | [diff] [blame] | 119 | modem_info_.Start(); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | void Manager::Stop() { |
| 123 | running_ = false; |
Chris Masone | 413a319 | 2011-05-09 17:10:05 -0700 | [diff] [blame] | 124 | adaptor_->UpdateRunning(); |
Darin Petkov | 887f298 | 2011-07-14 16:10:17 -0700 | [diff] [blame] | 125 | modem_info_.Stop(); |
| 126 | device_info_.Stop(); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 127 | } |
| 128 | |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 129 | const ProfileRefPtr &Manager::ActiveProfile() { |
| 130 | return profiles_.back(); |
| 131 | } |
| 132 | |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 133 | bool Manager::MoveToActiveProfile(const ProfileRefPtr &from, |
| 134 | const ServiceRefPtr &to_move) { |
| 135 | return ActiveProfile()->AdoptService(to_move) && |
| 136 | from->AbandonService(to_move->UniqueName()); |
| 137 | } |
| 138 | |
Chris Masone | 2b10554 | 2011-06-22 10:58:09 -0700 | [diff] [blame] | 139 | void Manager::RegisterDevice(const DeviceRefPtr &to_manage) { |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 140 | vector<DeviceRefPtr>::iterator it; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 141 | for (it = devices_.begin(); it != devices_.end(); ++it) { |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 142 | if (to_manage.get() == it->get()) |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 143 | return; |
| 144 | } |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 145 | devices_.push_back(to_manage); |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 146 | |
| 147 | // TODO(pstew): Should check configuration |
| 148 | if (running_) |
| 149 | to_manage->Start(); |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 150 | } |
| 151 | |
mukesh agrawal | 5029c6c | 2011-08-25 11:12:40 -0700 | [diff] [blame] | 152 | void Manager::DeregisterDevice(const DeviceRefPtr &to_forget) { |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 153 | vector<DeviceRefPtr>::iterator it; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 154 | for (it = devices_.begin(); it != devices_.end(); ++it) { |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 155 | if (to_forget.get() == it->get()) { |
mukesh agrawal | 5029c6c | 2011-08-25 11:12:40 -0700 | [diff] [blame] | 156 | VLOG(2) << "Deregistered device: " << to_forget->UniqueName(); |
| 157 | to_forget->Stop(); |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 158 | devices_.erase(it); |
| 159 | return; |
| 160 | } |
| 161 | } |
mukesh agrawal | 5029c6c | 2011-08-25 11:12:40 -0700 | [diff] [blame] | 162 | VLOG(2) << __func__ << " unknown device: " << to_forget->UniqueName(); |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 163 | } |
| 164 | |
Chris Masone | 2b10554 | 2011-06-22 10:58:09 -0700 | [diff] [blame] | 165 | void Manager::RegisterService(const ServiceRefPtr &to_manage) { |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 166 | // This should look for |to_manage| in the real profiles and, if found, |
| 167 | // do...something...to merge the meaningful state, I guess. |
| 168 | |
| 169 | // If not found, add it to the ephemeral profile |
| 170 | ephemeral_profile_->AdoptService(to_manage); |
| 171 | |
| 172 | // Now add to OUR list. |
| 173 | // TODO(cmasone): Keep this list sorted. |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 174 | vector<ServiceRefPtr>::iterator it; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 175 | for (it = services_.begin(); it != services_.end(); ++it) { |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 176 | if (to_manage->UniqueName() == (*it)->UniqueName()) |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 177 | return; |
| 178 | } |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 179 | services_.push_back(to_manage); |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame^] | 180 | |
| 181 | vector<string> service_paths; |
| 182 | for (it = services_.begin(); it != services_.end(); ++it) { |
| 183 | service_paths.push_back((*it)->GetRpcIdentifier()); |
| 184 | } |
| 185 | adaptor_->EmitRpcIdentifierArrayChanged(flimflam::kServicesProperty, |
| 186 | service_paths); |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Chris Masone | 2b10554 | 2011-06-22 10:58:09 -0700 | [diff] [blame] | 189 | void Manager::DeregisterService(const ServiceConstRefPtr &to_forget) { |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 190 | // If the service is in the ephemeral profile, destroy it. |
| 191 | if (!ephemeral_profile_->AbandonService(to_forget->UniqueName())) { |
| 192 | // if it's in one of the real profiles...um...I guess mark it unconnectable? |
| 193 | } |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 194 | vector<ServiceRefPtr>::iterator it; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 195 | for (it = services_.begin(); it != services_.end(); ++it) { |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 196 | if (to_forget->UniqueName() == (*it)->UniqueName()) { |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 197 | services_.erase(it); |
| 198 | return; |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 203 | void Manager::UpdateService(const ServiceConstRefPtr &to_update) { |
| 204 | LOG(INFO) << "Service " << to_update->UniqueName() << " updated;" |
| 205 | << " state: " << to_update->state() << " failure: " |
| 206 | << to_update->failure(); |
| 207 | // TODO(pstew): This should trigger re-sorting of services, autoconnect, etc. |
| 208 | } |
| 209 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 210 | void Manager::FilterByTechnology(Device::Technology tech, |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 211 | vector<DeviceRefPtr> *found) { |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 212 | CHECK(found); |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 213 | vector<DeviceRefPtr>::iterator it; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 214 | for (it = devices_.begin(); it != devices_.end(); ++it) { |
| 215 | if ((*it)->TechnologyIs(tech)) |
| 216 | found->push_back(*it); |
| 217 | } |
| 218 | } |
| 219 | |
Chris Masone | e0dea76 | 2011-06-09 09:06:03 -0700 | [diff] [blame] | 220 | ServiceRefPtr Manager::FindService(const std::string& name) { |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 221 | vector<ServiceRefPtr>::iterator it; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 222 | for (it = services_.begin(); it != services_.end(); ++it) { |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 223 | if (name == (*it)->UniqueName()) |
Chris Masone | e0dea76 | 2011-06-09 09:06:03 -0700 | [diff] [blame] | 224 | return *it; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 225 | } |
Chris Masone | e0dea76 | 2011-06-09 09:06:03 -0700 | [diff] [blame] | 226 | return NULL; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 227 | } |
| 228 | |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 229 | void Manager::HelpRegisterDerivedString(const string &name, |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 230 | string(Manager::*get)(void), |
| 231 | bool(Manager::*set)(const string&)) { |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 232 | store_.RegisterDerivedString( |
| 233 | name, |
| 234 | StringAccessor(new CustomAccessor<Manager, string>(this, get, set))); |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 237 | void Manager::HelpRegisterDerivedStrings(const string &name, |
Chris Masone | a8a2c25 | 2011-06-27 22:16:30 -0700 | [diff] [blame] | 238 | Strings(Manager::*get)(void), |
| 239 | bool(Manager::*set)(const Strings&)) { |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 240 | store_.RegisterDerivedStrings( |
| 241 | name, |
| 242 | StringsAccessor(new CustomAccessor<Manager, Strings>(this, get, set))); |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | string Manager::CalculateState() { |
| 246 | return flimflam::kStateOffline; |
| 247 | } |
| 248 | |
| 249 | vector<string> Manager::AvailableTechnologies() { |
| 250 | return vector<string>(); |
| 251 | } |
| 252 | |
| 253 | vector<string> Manager::ConnectedTechnologies() { |
| 254 | return vector<string>(); |
| 255 | } |
| 256 | |
| 257 | string Manager::DefaultTechnology() { |
| 258 | return ""; |
| 259 | } |
| 260 | |
| 261 | vector<string> Manager::EnabledTechnologies() { |
| 262 | return vector<string>(); |
| 263 | } |
| 264 | |
Chris Masone | 3c3f6a1 | 2011-07-01 10:01:41 -0700 | [diff] [blame] | 265 | vector<string> Manager::EnumerateDevices() { |
| 266 | vector<string> device_rpc_ids; |
| 267 | for (vector<DeviceRefPtr>::const_iterator it = devices_.begin(); |
| 268 | it != devices_.end(); |
| 269 | ++it) { |
| 270 | device_rpc_ids.push_back((*it)->GetRpcIdentifier()); |
| 271 | } |
| 272 | return device_rpc_ids; |
| 273 | } |
| 274 | |
| 275 | vector<string> Manager::EnumerateAvailableServices() { |
Chris Masone | 3c3f6a1 | 2011-07-01 10:01:41 -0700 | [diff] [blame] | 276 | vector<string> service_rpc_ids; |
| 277 | for (vector<ServiceRefPtr>::const_iterator it = services_.begin(); |
| 278 | it != services_.end(); |
| 279 | ++it) { |
| 280 | service_rpc_ids.push_back((*it)->GetRpcIdentifier()); |
| 281 | } |
| 282 | return service_rpc_ids; |
| 283 | } |
| 284 | |
| 285 | vector<string> Manager::EnumerateWatchedServices() { |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 286 | // TODO(cmasone): Filter this list for services in appropriate states. |
Chris Masone | 3c3f6a1 | 2011-07-01 10:01:41 -0700 | [diff] [blame] | 287 | return EnumerateAvailableServices(); |
| 288 | } |
| 289 | |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 290 | string Manager::GetActiveProfileName() { |
Chris Masone | 7df0c67 | 2011-07-15 10:24:54 -0700 | [diff] [blame] | 291 | return ActiveProfile()->GetFriendlyName(); |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 292 | } |
| 293 | |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame^] | 294 | // called via RPC (e.g., from ManagerDBusAdaptor) |
| 295 | void Manager::RequestScan(const std::string &technology, Error *error) { |
| 296 | if (technology == flimflam::kTypeWifi || technology == "") { |
| 297 | vector<DeviceRefPtr> wifi_devices; |
| 298 | FilterByTechnology(Device::kWifi, &wifi_devices); |
| 299 | |
| 300 | for (vector<DeviceRefPtr>::iterator it = wifi_devices.begin(); |
| 301 | it != wifi_devices.end(); |
| 302 | ++it) { |
| 303 | (*it)->Scan(); |
| 304 | } |
| 305 | } else { |
| 306 | // TODO(quiche): support scanning for other technologies? |
| 307 | const string kMessage = "Unrecognized technology " + technology; |
| 308 | LOG(ERROR) << kMessage; |
| 309 | CHECK(error); |
| 310 | error->Populate(Error::kInvalidArguments, kMessage); |
| 311 | } |
| 312 | } |
| 313 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 314 | } // namespace shill |