mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -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/supplicant_interface_proxy.h" |
| 6 | |
| 7 | #include <map> |
| 8 | #include <string> |
| 9 | |
| 10 | #include <base/logging.h> |
| 11 | #include <dbus-c++/dbus.h> |
| 12 | |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 13 | #include "shill/scope_logger.h" |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 14 | #include "shill/wifi.h" |
| 15 | |
| 16 | using std::map; |
| 17 | using std::string; |
| 18 | |
| 19 | namespace shill { |
| 20 | |
| 21 | SupplicantInterfaceProxy::SupplicantInterfaceProxy( |
| 22 | const WiFiRefPtr &wifi, |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 23 | DBus::Connection *bus, |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 24 | const ::DBus::Path &object_path, |
| 25 | const char *dbus_addr) |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 26 | : proxy_(wifi, bus, object_path, dbus_addr) {} |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 27 | |
| 28 | SupplicantInterfaceProxy::~SupplicantInterfaceProxy() {} |
| 29 | |
| 30 | ::DBus::Path SupplicantInterfaceProxy::AddNetwork( |
| 31 | const std::map<std::string, ::DBus::Variant> &args) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 32 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 33 | return proxy_.AddNetwork(args); |
| 34 | } |
| 35 | |
Paul Stewart | 66c8600 | 2012-01-30 18:00:52 -0800 | [diff] [blame] | 36 | void SupplicantInterfaceProxy::ClearCachedCredentials() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 37 | SLOG(DBus, 2) << __func__; |
Paul Stewart | 66c8600 | 2012-01-30 18:00:52 -0800 | [diff] [blame] | 38 | return proxy_.ClearCachedCredentials(); |
| 39 | } |
| 40 | |
mukesh agrawal | 0ed0f2e | 2011-12-05 20:36:17 +0000 | [diff] [blame] | 41 | void SupplicantInterfaceProxy::Disconnect() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 42 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | 0ed0f2e | 2011-12-05 20:36:17 +0000 | [diff] [blame] | 43 | return proxy_.Disconnect(); |
| 44 | } |
| 45 | |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 46 | void SupplicantInterfaceProxy::FlushBSS(const uint32_t &age) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 47 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 48 | return proxy_.FlushBSS(age); |
| 49 | } |
| 50 | |
| 51 | void SupplicantInterfaceProxy::RemoveAllNetworks() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 52 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 53 | return proxy_.RemoveAllNetworks(); |
| 54 | } |
| 55 | |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 56 | void SupplicantInterfaceProxy::RemoveNetwork(const ::DBus::Path &network) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 57 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 58 | return proxy_.RemoveNetwork(network); |
| 59 | } |
| 60 | |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 61 | void SupplicantInterfaceProxy::Scan( |
| 62 | const std::map<std::string, ::DBus::Variant> &args) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 63 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 64 | return proxy_.Scan(args); |
| 65 | } |
| 66 | |
| 67 | void SupplicantInterfaceProxy::SelectNetwork(const ::DBus::Path &network) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 68 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 69 | return proxy_.SelectNetwork(network); |
| 70 | } |
| 71 | |
Paul Stewart | 2987dcf | 2012-01-30 15:47:42 -0800 | [diff] [blame] | 72 | void SupplicantInterfaceProxy::SetFastReauth(bool enabled) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 73 | SLOG(DBus, 2) << __func__; |
Paul Stewart | 2987dcf | 2012-01-30 15:47:42 -0800 | [diff] [blame] | 74 | return proxy_.FastReauth(enabled); |
| 75 | } |
| 76 | |
mukesh agrawal | f202817 | 2012-03-13 14:20:22 -0700 | [diff] [blame] | 77 | void SupplicantInterfaceProxy::SetScanInterval(int32 scan_interval) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 78 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | f202817 | 2012-03-13 14:20:22 -0700 | [diff] [blame] | 79 | return proxy_.ScanInterval(scan_interval); |
| 80 | } |
| 81 | |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 82 | // definitions for private class SupplicantInterfaceProxy::Proxy |
| 83 | |
| 84 | SupplicantInterfaceProxy::Proxy::Proxy( |
| 85 | const WiFiRefPtr &wifi, DBus::Connection *bus, |
| 86 | const DBus::Path &dbus_path, const char *dbus_addr) |
| 87 | : DBus::ObjectProxy(*bus, dbus_path, dbus_addr), |
| 88 | wifi_(wifi) {} |
| 89 | |
| 90 | SupplicantInterfaceProxy::Proxy::~Proxy() {} |
| 91 | |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 92 | void SupplicantInterfaceProxy::Proxy::BlobAdded(const string &/*blobname*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 93 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 94 | // XXX |
| 95 | } |
| 96 | |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 97 | void SupplicantInterfaceProxy::Proxy::BlobRemoved(const string &/*blobname*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 98 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 99 | // XXX |
| 100 | } |
| 101 | |
| 102 | void SupplicantInterfaceProxy::Proxy::BSSAdded( |
| 103 | const ::DBus::Path &BSS, |
| 104 | const std::map<string, ::DBus::Variant> &properties) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 105 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 106 | wifi_->BSSAdded(BSS, properties); |
| 107 | } |
| 108 | |
mukesh agrawal | 261daca | 2011-12-02 18:56:56 +0000 | [diff] [blame] | 109 | void SupplicantInterfaceProxy::Proxy::BSSRemoved(const ::DBus::Path &BSS) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 110 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | 261daca | 2011-12-02 18:56:56 +0000 | [diff] [blame] | 111 | wifi_->BSSRemoved(BSS); |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | void SupplicantInterfaceProxy::Proxy::NetworkAdded( |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 115 | const ::DBus::Path &/*network*/, |
| 116 | const std::map<string, ::DBus::Variant> &/*properties*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 117 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 118 | // XXX |
| 119 | } |
| 120 | |
| 121 | void SupplicantInterfaceProxy::Proxy::NetworkRemoved( |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 122 | const ::DBus::Path &/*network*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 123 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 124 | // TODO(quiche): Pass this up to WiFi, so that it can clean its |
| 125 | // rpcid_by_service_ map. crosbug.com/24699 |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | void SupplicantInterfaceProxy::Proxy::NetworkSelected( |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 129 | const ::DBus::Path &/*network*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 130 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 131 | // XXX |
| 132 | } |
| 133 | |
| 134 | void SupplicantInterfaceProxy::Proxy::PropertiesChanged( |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 135 | const std::map<string, ::DBus::Variant> &properties) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 136 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 137 | wifi_->PropertiesChanged(properties); |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | void SupplicantInterfaceProxy::Proxy::ScanDone(const bool& success) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame^] | 141 | SLOG(DBus, 2) << __func__ << ": " << success; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 142 | if (success) { |
| 143 | wifi_->ScanDone(); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | } // namespace shill |