mukesh agrawal | b54601c | 2011-06-07 17:39:22 -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 | |
| 5 | #include "shill/wifi_service.h" |
| 6 | |
| 7 | #include <string> |
| 8 | |
| 9 | #include <base/logging.h> |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 10 | #include <chromeos/dbus/service_constants.h> |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 11 | |
| 12 | #include "shill/control_interface.h" |
| 13 | #include "shill/device.h" |
| 14 | #include "shill/shill_event.h" |
| 15 | #include "shill/wifi.h" |
| 16 | |
| 17 | using std::string; |
| 18 | |
| 19 | namespace shill { |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 20 | |
| 21 | WiFiService::WiFiService(ControlInterface *control_interface, |
| 22 | EventDispatcher *dispatcher, |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 23 | Manager *manager, |
Chris Masone | 2b10554 | 2011-06-22 10:58:09 -0700 | [diff] [blame] | 24 | const WiFiRefPtr &device, |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 25 | const std::vector<uint8_t> ssid, |
Chris Masone | 092df3e | 2011-08-22 09:41:39 -0700 | [diff] [blame^] | 26 | const std::string &mode, |
mukesh agrawal | 51a7e93 | 2011-07-27 16:18:26 -0700 | [diff] [blame] | 27 | const std::string &key_management) |
| 28 | : Service(control_interface, dispatcher, manager), |
Chris Masone | 092df3e | 2011-08-22 09:41:39 -0700 | [diff] [blame^] | 29 | mode_(mode), |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 30 | task_factory_(this), |
| 31 | wifi_(device), |
Chris Masone | 092df3e | 2011-08-22 09:41:39 -0700 | [diff] [blame^] | 32 | ssid_(ssid) { |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 33 | eap_.key_management = key_management; |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 34 | |
Chris Masone | 092df3e | 2011-08-22 09:41:39 -0700 | [diff] [blame^] | 35 | store_.RegisterConstString(flimflam::kModeProperty, &mode_); |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 36 | store_.RegisterString(flimflam::kPassphraseProperty, &passphrase_); |
| 37 | store_.RegisterBool(flimflam::kPassphraseRequiredProperty, &need_passphrase_); |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 38 | store_.RegisterConstString(flimflam::kSecurityProperty, &security_); |
Chris Masone | 4d42df8 | 2011-07-02 17:09:39 -0700 | [diff] [blame] | 39 | store_.RegisterConstUint8(flimflam::kSignalStrengthProperty, &strength_); |
| 40 | store_.RegisterConstString(flimflam::kTypeProperty, &type_); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 41 | |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 42 | store_.RegisterConstString(flimflam::kWifiAuthMode, &auth_mode_); |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 43 | store_.RegisterConstBool(flimflam::kWifiHiddenSsid, &hidden_ssid_); |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 44 | store_.RegisterConstUint16(flimflam::kWifiFrequency, &frequency_); |
| 45 | store_.RegisterConstUint16(flimflam::kWifiPhyMode, &physical_mode_); |
| 46 | store_.RegisterConstUint16(flimflam::kWifiHexSsid, &hex_ssid_); |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | WiFiService::~WiFiService() { |
| 50 | LOG(INFO) << __func__; |
| 51 | } |
| 52 | |
| 53 | void WiFiService::Connect() { |
| 54 | LOG(INFO) << __func__; |
| 55 | |
| 56 | // NB(quiche) defer handling, since dbus-c++ does not permit us to |
| 57 | // send an outbound request while processing an inbound one. |
| 58 | dispatcher_->PostTask( |
mukesh agrawal | dc42bb3 | 2011-07-28 10:40:26 -0700 | [diff] [blame] | 59 | task_factory_.NewRunnableMethod(&WiFiService::ConnectTask)); |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 62 | void WiFiService::Disconnect() { |
| 63 | // TODO(quiche) RemoveNetwork from supplicant |
| 64 | // XXX remove from favorite networks list? |
| 65 | } |
| 66 | |
Chris Masone | 092df3e | 2011-08-22 09:41:39 -0700 | [diff] [blame^] | 67 | const string &WiFiService::mode() const { |
mukesh agrawal | 445e72c | 2011-06-22 11:13:50 -0700 | [diff] [blame] | 68 | return mode_; |
| 69 | } |
| 70 | |
Chris Masone | 092df3e | 2011-08-22 09:41:39 -0700 | [diff] [blame^] | 71 | const string &WiFiService::key_management() const { |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 72 | return eap_.key_management; |
mukesh agrawal | 445e72c | 2011-06-22 11:13:50 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | const std::vector<uint8_t> &WiFiService::ssid() const { |
| 76 | return ssid_; |
| 77 | } |
| 78 | |
mukesh agrawal | dc42bb3 | 2011-07-28 10:40:26 -0700 | [diff] [blame] | 79 | void WiFiService::ConnectTask() { |
mukesh agrawal | 445e72c | 2011-06-22 11:13:50 -0700 | [diff] [blame] | 80 | wifi_->ConnectTo(*this); |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Chris Masone | 95207da | 2011-06-29 16:50:49 -0700 | [diff] [blame] | 83 | string WiFiService::GetDeviceRpcId() { |
| 84 | return wifi_->GetRpcIdentifier(); |
| 85 | } |
| 86 | |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 87 | } // namespace shill |