blob: 56deb7e84729bd28966b0e3d5559f086ff17c5c5 [file] [log] [blame]
mukesh agrawal8a3188d2011-12-01 20:56:44 +00001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
mukesh agrawalaf571952011-07-14 14:31:12 -07002// 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
mukesh agrawalaf571952011-07-14 14:31:12 -070010#include <dbus-c++/dbus.h>
11
Christopher Wileyb691efd2012-08-09 13:51:51 -070012#include "shill/logging.h"
Paul Stewart196f50f2013-03-27 18:02:11 -070013#include "shill/supplicant_event_delegate_interface.h"
mukesh agrawalaf571952011-07-14 14:31:12 -070014
15using std::map;
16using std::string;
17
18namespace shill {
19
20SupplicantInterfaceProxy::SupplicantInterfaceProxy(
Paul Stewart196f50f2013-03-27 18:02:11 -070021 SupplicantEventDelegateInterface *delegate,
Darin Petkovaceede32011-07-18 15:32:38 -070022 DBus::Connection *bus,
mukesh agrawalaf571952011-07-14 14:31:12 -070023 const ::DBus::Path &object_path,
24 const char *dbus_addr)
Paul Stewart196f50f2013-03-27 18:02:11 -070025 : proxy_(delegate, bus, object_path, dbus_addr) {}
mukesh agrawalaf571952011-07-14 14:31:12 -070026
27SupplicantInterfaceProxy::~SupplicantInterfaceProxy() {}
28
29::DBus::Path SupplicantInterfaceProxy::AddNetwork(
30 const std::map<std::string, ::DBus::Variant> &args) {
mukesh agrawal06175d72012-04-23 16:46:01 -070031 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070032 try {
33 return proxy_.AddNetwork(args);
34 } catch (const DBus::Error &e) {
Gary Morainba919ac2012-05-08 11:30:20 -070035 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what()
Gary Morain610977f2012-05-04 16:03:52 -070036 << " args keys are: " << DBusProperties::KeysToString(args);
Gary Morainba919ac2012-05-08 11:30:20 -070037 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -070038 }
mukesh agrawalaf571952011-07-14 14:31:12 -070039}
40
Christopher Wiley5519e9e2013-01-08 16:55:56 -080041void SupplicantInterfaceProxy::EnableHighBitrates() {
42 SLOG(DBus, 2) << __func__;
43 try {
44 return proxy_.EnableHighBitrates();
45 } catch (const DBus::Error &e) {
46 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what();
47 throw; // Re-throw the exception.
48 }
49}
50
Paul Stewartbe9abfd2013-04-22 12:18:48 -070051void SupplicantInterfaceProxy::EAPLogoff() {
52 SLOG(DBus, 2) << __func__;
53 try {
54 return proxy_.EAPLogoff();
55 } catch (const DBus::Error &e) {
56 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what();
57 throw; // Re-throw the exception.
58 }
59}
60
61void SupplicantInterfaceProxy::EAPLogon() {
62 SLOG(DBus, 2) << __func__;
63 try {
64 return proxy_.EAPLogon();
65 } catch (const DBus::Error &e) {
66 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what();
67 throw; // Re-throw the exception.
68 }
69}
70
mukesh agrawal0ed0f2e2011-12-05 20:36:17 +000071void SupplicantInterfaceProxy::Disconnect() {
mukesh agrawal06175d72012-04-23 16:46:01 -070072 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070073 try {
74 return proxy_.Disconnect();
75 } catch (const DBus::Error &e) {
Gary Morainba919ac2012-05-08 11:30:20 -070076 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what();
77 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -070078 }
mukesh agrawal0ed0f2e2011-12-05 20:36:17 +000079}
80
mukesh agrawalaf571952011-07-14 14:31:12 -070081void SupplicantInterfaceProxy::FlushBSS(const uint32_t &age) {
mukesh agrawal06175d72012-04-23 16:46:01 -070082 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070083 try {
84 return proxy_.FlushBSS(age);
85 } catch (const DBus::Error &e) {
86 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
87 << " age: " << age;
88 }
mukesh agrawalaf571952011-07-14 14:31:12 -070089}
90
Paul Stewart3c508e12012-08-09 11:40:06 -070091void SupplicantInterfaceProxy::Reassociate() {
92 SLOG(DBus, 2) << __func__;
93 try {
94 return proxy_.Reassociate();
95 } catch (const DBus::Error &e) {
96 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what();
97 throw; // Re-throw the exception.
98 }
99}
100
mukesh agrawalaf571952011-07-14 14:31:12 -0700101void SupplicantInterfaceProxy::RemoveAllNetworks() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700102 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700103 try {
104 return proxy_.RemoveAllNetworks();
105 } catch (const DBus::Error &e) {
106 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
107 }
mukesh agrawalaf571952011-07-14 14:31:12 -0700108}
109
mukesh agrawal15908392011-11-16 18:29:25 +0000110void SupplicantInterfaceProxy::RemoveNetwork(const ::DBus::Path &network) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700111 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700112 try {
113 return proxy_.RemoveNetwork(network);
114 } catch (const DBus::Error &e) {
Paul Stewart71f6ecd2012-09-13 14:52:18 -0700115 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what();
116 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -0700117 }
mukesh agrawal15908392011-11-16 18:29:25 +0000118}
119
mukesh agrawalaf571952011-07-14 14:31:12 -0700120void SupplicantInterfaceProxy::Scan(
121 const std::map<std::string, ::DBus::Variant> &args) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700122 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700123 try {
124 return proxy_.Scan(args);
125 } catch (const DBus::Error &e) {
Gary Morainba919ac2012-05-08 11:30:20 -0700126 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what()
Gary Morain610977f2012-05-04 16:03:52 -0700127 << " args keys are: " << DBusProperties::KeysToString(args);
Gary Morainba919ac2012-05-08 11:30:20 -0700128 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -0700129 }
mukesh agrawalaf571952011-07-14 14:31:12 -0700130}
131
132void SupplicantInterfaceProxy::SelectNetwork(const ::DBus::Path &network) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700133 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700134 try {
135 return proxy_.SelectNetwork(network);
136 } catch (const DBus::Error &e) {
137 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
138 }
mukesh agrawalaf571952011-07-14 14:31:12 -0700139}
140
Paul Stewart2987dcf2012-01-30 15:47:42 -0800141void SupplicantInterfaceProxy::SetFastReauth(bool enabled) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700142 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700143 try {
144 return proxy_.FastReauth(enabled);
145 } catch (const DBus::Error &e) {
Gary Morainba919ac2012-05-08 11:30:20 -0700146 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what()
Gary Morain610977f2012-05-04 16:03:52 -0700147 << "enabled: " << enabled;
Gary Morainba919ac2012-05-08 11:30:20 -0700148 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -0700149 }
Paul Stewart2987dcf2012-01-30 15:47:42 -0800150}
151
mukesh agrawalf2028172012-03-13 14:20:22 -0700152void SupplicantInterfaceProxy::SetScanInterval(int32 scan_interval) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700153 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700154 try {
155 return proxy_.ScanInterval(scan_interval);
156 } catch (const DBus::Error &e) {
Gary Morainba919ac2012-05-08 11:30:20 -0700157 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what()
Gary Morain610977f2012-05-04 16:03:52 -0700158 << " scan interval: " << scan_interval;
Gary Morainba919ac2012-05-08 11:30:20 -0700159 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -0700160 }
mukesh agrawalf2028172012-03-13 14:20:22 -0700161}
162
Christopher Wiley5519e9e2013-01-08 16:55:56 -0800163void SupplicantInterfaceProxy::SetDisableHighBitrates(
164 bool disable_high_bitrates) {
165 SLOG(DBus, 2) << __func__;
166 try {
167 return proxy_.DisableHighBitrates(disable_high_bitrates);
168 } catch (const DBus::Error &e) {
169 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what()
170 << "disable_high_bitrates: " << disable_high_bitrates;
171 throw; // Re-throw the exception.
172 }
173}
174
mukesh agrawalaf571952011-07-14 14:31:12 -0700175// definitions for private class SupplicantInterfaceProxy::Proxy
176
177SupplicantInterfaceProxy::Proxy::Proxy(
Paul Stewart196f50f2013-03-27 18:02:11 -0700178 SupplicantEventDelegateInterface *delegate, DBus::Connection *bus,
mukesh agrawalaf571952011-07-14 14:31:12 -0700179 const DBus::Path &dbus_path, const char *dbus_addr)
180 : DBus::ObjectProxy(*bus, dbus_path, dbus_addr),
Paul Stewart196f50f2013-03-27 18:02:11 -0700181 delegate_(delegate) {}
mukesh agrawalaf571952011-07-14 14:31:12 -0700182
183SupplicantInterfaceProxy::Proxy::~Proxy() {}
184
mukesh agrawal1830fa12011-09-26 14:31:40 -0700185void SupplicantInterfaceProxy::Proxy::BlobAdded(const string &/*blobname*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700186 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700187 // XXX
188}
189
mukesh agrawal1830fa12011-09-26 14:31:40 -0700190void SupplicantInterfaceProxy::Proxy::BlobRemoved(const string &/*blobname*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700191 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700192 // XXX
193}
194
195void SupplicantInterfaceProxy::Proxy::BSSAdded(
196 const ::DBus::Path &BSS,
197 const std::map<string, ::DBus::Variant> &properties) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700198 SLOG(DBus, 2) << __func__;
Paul Stewart196f50f2013-03-27 18:02:11 -0700199 delegate_->BSSAdded(BSS, properties);
mukesh agrawalaf571952011-07-14 14:31:12 -0700200}
201
Paul Stewartbc6e7392012-05-24 07:07:48 -0700202void SupplicantInterfaceProxy::Proxy::Certification(
203 const std::map<string, ::DBus::Variant> &properties) {
204 SLOG(DBus, 2) << __func__;
Paul Stewart196f50f2013-03-27 18:02:11 -0700205 delegate_->Certification(properties);
Paul Stewartbc6e7392012-05-24 07:07:48 -0700206}
207
Paul Stewartdb0f9172012-11-30 16:48:09 -0800208void SupplicantInterfaceProxy::Proxy::EAP(
209 const string &status, const string &parameter) {
210 SLOG(DBus, 2) << __func__ << ": status " << status
211 << ", parameter " << parameter;
Paul Stewart196f50f2013-03-27 18:02:11 -0700212 delegate_->EAPEvent(status, parameter);
Paul Stewartdb0f9172012-11-30 16:48:09 -0800213}
214
mukesh agrawal261daca2011-12-02 18:56:56 +0000215void SupplicantInterfaceProxy::Proxy::BSSRemoved(const ::DBus::Path &BSS) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700216 SLOG(DBus, 2) << __func__;
Paul Stewart196f50f2013-03-27 18:02:11 -0700217 delegate_->BSSRemoved(BSS);
mukesh agrawalaf571952011-07-14 14:31:12 -0700218}
219
220void SupplicantInterfaceProxy::Proxy::NetworkAdded(
mukesh agrawal1830fa12011-09-26 14:31:40 -0700221 const ::DBus::Path &/*network*/,
222 const std::map<string, ::DBus::Variant> &/*properties*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700223 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700224 // XXX
225}
226
227void SupplicantInterfaceProxy::Proxy::NetworkRemoved(
mukesh agrawal1830fa12011-09-26 14:31:40 -0700228 const ::DBus::Path &/*network*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700229 SLOG(DBus, 2) << __func__;
Paul Stewart196f50f2013-03-27 18:02:11 -0700230 // TODO(quiche): Pass this up to the delegate, so that it can clean its
mukesh agrawal8a3188d2011-12-01 20:56:44 +0000231 // rpcid_by_service_ map. crosbug.com/24699
mukesh agrawalaf571952011-07-14 14:31:12 -0700232}
233
234void SupplicantInterfaceProxy::Proxy::NetworkSelected(
mukesh agrawal1830fa12011-09-26 14:31:40 -0700235 const ::DBus::Path &/*network*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700236 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700237 // XXX
238}
239
240void SupplicantInterfaceProxy::Proxy::PropertiesChanged(
mukesh agrawal7ec71312011-11-10 02:08:26 +0000241 const std::map<string, ::DBus::Variant> &properties) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700242 SLOG(DBus, 2) << __func__;
Paul Stewart196f50f2013-03-27 18:02:11 -0700243 delegate_->PropertiesChanged(properties);
mukesh agrawalaf571952011-07-14 14:31:12 -0700244}
245
246void SupplicantInterfaceProxy::Proxy::ScanDone(const bool& success) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700247 SLOG(DBus, 2) << __func__ << ": " << success;
mukesh agrawalaf571952011-07-14 14:31:12 -0700248 if (success) {
Paul Stewart196f50f2013-03-27 18:02:11 -0700249 delegate_->ScanDone();
mukesh agrawalaf571952011-07-14 14:31:12 -0700250 }
251}
252
253} // namespace shill