blob: c4d627541e3aec6a19333d8b8a501c87c178ff85 [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
10#include <base/logging.h>
11#include <dbus-c++/dbus.h>
12
mukesh agrawal06175d72012-04-23 16:46:01 -070013#include "shill/scope_logger.h"
mukesh agrawalaf571952011-07-14 14:31:12 -070014#include "shill/wifi.h"
15
16using std::map;
17using std::string;
18
19namespace shill {
20
21SupplicantInterfaceProxy::SupplicantInterfaceProxy(
22 const WiFiRefPtr &wifi,
Darin Petkovaceede32011-07-18 15:32:38 -070023 DBus::Connection *bus,
mukesh agrawalaf571952011-07-14 14:31:12 -070024 const ::DBus::Path &object_path,
25 const char *dbus_addr)
Darin Petkovaceede32011-07-18 15:32:38 -070026 : proxy_(wifi, bus, object_path, dbus_addr) {}
mukesh agrawalaf571952011-07-14 14:31:12 -070027
28SupplicantInterfaceProxy::~SupplicantInterfaceProxy() {}
29
30::DBus::Path SupplicantInterfaceProxy::AddNetwork(
31 const std::map<std::string, ::DBus::Variant> &args) {
mukesh agrawal06175d72012-04-23 16:46:01 -070032 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070033 try {
34 return proxy_.AddNetwork(args);
35 } catch (const DBus::Error &e) {
36 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
37 << " args keys are: " << DBusProperties::KeysToString(args);
38 return ::DBus::Path(); // Make the compiler happy.
39 }
mukesh agrawalaf571952011-07-14 14:31:12 -070040}
41
Paul Stewart66c86002012-01-30 18:00:52 -080042void SupplicantInterfaceProxy::ClearCachedCredentials() {
mukesh agrawal06175d72012-04-23 16:46:01 -070043 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070044 try {
45 return proxy_.ClearCachedCredentials();
46 } catch (const DBus::Error &e) {
47 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
48 }
Paul Stewart66c86002012-01-30 18:00:52 -080049}
50
mukesh agrawal0ed0f2e2011-12-05 20:36:17 +000051void SupplicantInterfaceProxy::Disconnect() {
mukesh agrawal06175d72012-04-23 16:46:01 -070052 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070053 try {
54 return proxy_.Disconnect();
55 } catch (const DBus::Error &e) {
56 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
57 }
mukesh agrawal0ed0f2e2011-12-05 20:36:17 +000058}
59
mukesh agrawalaf571952011-07-14 14:31:12 -070060void SupplicantInterfaceProxy::FlushBSS(const uint32_t &age) {
mukesh agrawal06175d72012-04-23 16:46:01 -070061 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070062 try {
63 return proxy_.FlushBSS(age);
64 } catch (const DBus::Error &e) {
65 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
66 << " age: " << age;
67 }
mukesh agrawalaf571952011-07-14 14:31:12 -070068}
69
70void SupplicantInterfaceProxy::RemoveAllNetworks() {
mukesh agrawal06175d72012-04-23 16:46:01 -070071 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070072 try {
73 return proxy_.RemoveAllNetworks();
74 } catch (const DBus::Error &e) {
75 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
76 }
mukesh agrawalaf571952011-07-14 14:31:12 -070077}
78
mukesh agrawal15908392011-11-16 18:29:25 +000079void SupplicantInterfaceProxy::RemoveNetwork(const ::DBus::Path &network) {
mukesh agrawal06175d72012-04-23 16:46:01 -070080 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070081 try {
82 return proxy_.RemoveNetwork(network);
83 } catch (const DBus::Error &e) {
84 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
85 }
mukesh agrawal15908392011-11-16 18:29:25 +000086}
87
mukesh agrawalaf571952011-07-14 14:31:12 -070088void SupplicantInterfaceProxy::Scan(
89 const std::map<std::string, ::DBus::Variant> &args) {
mukesh agrawal06175d72012-04-23 16:46:01 -070090 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070091 try {
92 return proxy_.Scan(args);
93 } catch (const DBus::Error &e) {
94 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
95 << " args keys are: " << DBusProperties::KeysToString(args);
96 }
mukesh agrawalaf571952011-07-14 14:31:12 -070097}
98
99void SupplicantInterfaceProxy::SelectNetwork(const ::DBus::Path &network) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700100 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700101 try {
102 return proxy_.SelectNetwork(network);
103 } catch (const DBus::Error &e) {
104 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
105 }
mukesh agrawalaf571952011-07-14 14:31:12 -0700106}
107
Paul Stewart2987dcf2012-01-30 15:47:42 -0800108void SupplicantInterfaceProxy::SetFastReauth(bool enabled) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700109 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700110 try {
111 return proxy_.FastReauth(enabled);
112 } catch (const DBus::Error &e) {
113 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
114 << "enabled: " << enabled;
115 }
Paul Stewart2987dcf2012-01-30 15:47:42 -0800116}
117
mukesh agrawalf2028172012-03-13 14:20:22 -0700118void SupplicantInterfaceProxy::SetScanInterval(int32 scan_interval) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700119 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700120 try {
121 return proxy_.ScanInterval(scan_interval);
122 } catch (const DBus::Error &e) {
123 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
124 << " scan interval: " << scan_interval;
125 }
mukesh agrawalf2028172012-03-13 14:20:22 -0700126}
127
mukesh agrawalaf571952011-07-14 14:31:12 -0700128// definitions for private class SupplicantInterfaceProxy::Proxy
129
130SupplicantInterfaceProxy::Proxy::Proxy(
131 const WiFiRefPtr &wifi, DBus::Connection *bus,
132 const DBus::Path &dbus_path, const char *dbus_addr)
133 : DBus::ObjectProxy(*bus, dbus_path, dbus_addr),
134 wifi_(wifi) {}
135
136SupplicantInterfaceProxy::Proxy::~Proxy() {}
137
mukesh agrawal1830fa12011-09-26 14:31:40 -0700138void SupplicantInterfaceProxy::Proxy::BlobAdded(const string &/*blobname*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700139 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700140 // XXX
141}
142
mukesh agrawal1830fa12011-09-26 14:31:40 -0700143void SupplicantInterfaceProxy::Proxy::BlobRemoved(const string &/*blobname*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700144 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700145 // XXX
146}
147
148void SupplicantInterfaceProxy::Proxy::BSSAdded(
149 const ::DBus::Path &BSS,
150 const std::map<string, ::DBus::Variant> &properties) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700151 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700152 wifi_->BSSAdded(BSS, properties);
153}
154
mukesh agrawal261daca2011-12-02 18:56:56 +0000155void SupplicantInterfaceProxy::Proxy::BSSRemoved(const ::DBus::Path &BSS) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700156 SLOG(DBus, 2) << __func__;
mukesh agrawal261daca2011-12-02 18:56:56 +0000157 wifi_->BSSRemoved(BSS);
mukesh agrawalaf571952011-07-14 14:31:12 -0700158}
159
160void SupplicantInterfaceProxy::Proxy::NetworkAdded(
mukesh agrawal1830fa12011-09-26 14:31:40 -0700161 const ::DBus::Path &/*network*/,
162 const std::map<string, ::DBus::Variant> &/*properties*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700163 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700164 // XXX
165}
166
167void SupplicantInterfaceProxy::Proxy::NetworkRemoved(
mukesh agrawal1830fa12011-09-26 14:31:40 -0700168 const ::DBus::Path &/*network*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700169 SLOG(DBus, 2) << __func__;
mukesh agrawal8a3188d2011-12-01 20:56:44 +0000170 // TODO(quiche): Pass this up to WiFi, so that it can clean its
171 // rpcid_by_service_ map. crosbug.com/24699
mukesh agrawalaf571952011-07-14 14:31:12 -0700172}
173
174void SupplicantInterfaceProxy::Proxy::NetworkSelected(
mukesh agrawal1830fa12011-09-26 14:31:40 -0700175 const ::DBus::Path &/*network*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700176 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700177 // XXX
178}
179
180void SupplicantInterfaceProxy::Proxy::PropertiesChanged(
mukesh agrawal7ec71312011-11-10 02:08:26 +0000181 const std::map<string, ::DBus::Variant> &properties) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700182 SLOG(DBus, 2) << __func__;
mukesh agrawal7ec71312011-11-10 02:08:26 +0000183 wifi_->PropertiesChanged(properties);
mukesh agrawalaf571952011-07-14 14:31:12 -0700184}
185
186void SupplicantInterfaceProxy::Proxy::ScanDone(const bool& success) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700187 SLOG(DBus, 2) << __func__ << ": " << success;
mukesh agrawalaf571952011-07-14 14:31:12 -0700188 if (success) {
189 wifi_->ScanDone();
190 }
191}
192
193} // namespace shill