blob: 0ab4819ab2835f1b2f728032bd016ede509e7359 [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) {
Gary Morainba919ac2012-05-08 11:30:20 -070036 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what()
Gary Morain610977f2012-05-04 16:03:52 -070037 << " args keys are: " << DBusProperties::KeysToString(args);
Gary Morainba919ac2012-05-08 11:30:20 -070038 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -070039 }
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) {
Gary Morainba919ac2012-05-08 11:30:20 -070047 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what();
48 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -070049 }
Paul Stewart66c86002012-01-30 18:00:52 -080050}
51
mukesh agrawal0ed0f2e2011-12-05 20:36:17 +000052void SupplicantInterfaceProxy::Disconnect() {
mukesh agrawal06175d72012-04-23 16:46:01 -070053 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070054 try {
55 return proxy_.Disconnect();
56 } catch (const DBus::Error &e) {
Gary Morainba919ac2012-05-08 11:30:20 -070057 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what();
58 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -070059 }
mukesh agrawal0ed0f2e2011-12-05 20:36:17 +000060}
61
mukesh agrawalaf571952011-07-14 14:31:12 -070062void SupplicantInterfaceProxy::FlushBSS(const uint32_t &age) {
mukesh agrawal06175d72012-04-23 16:46:01 -070063 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070064 try {
65 return proxy_.FlushBSS(age);
66 } catch (const DBus::Error &e) {
67 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
68 << " age: " << age;
69 }
mukesh agrawalaf571952011-07-14 14:31:12 -070070}
71
72void SupplicantInterfaceProxy::RemoveAllNetworks() {
mukesh agrawal06175d72012-04-23 16:46:01 -070073 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070074 try {
75 return proxy_.RemoveAllNetworks();
76 } catch (const DBus::Error &e) {
77 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
78 }
mukesh agrawalaf571952011-07-14 14:31:12 -070079}
80
mukesh agrawal15908392011-11-16 18:29:25 +000081void SupplicantInterfaceProxy::RemoveNetwork(const ::DBus::Path &network) {
mukesh agrawal06175d72012-04-23 16:46:01 -070082 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070083 try {
84 return proxy_.RemoveNetwork(network);
85 } catch (const DBus::Error &e) {
86 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
87 }
mukesh agrawal15908392011-11-16 18:29:25 +000088}
89
mukesh agrawalaf571952011-07-14 14:31:12 -070090void SupplicantInterfaceProxy::Scan(
91 const std::map<std::string, ::DBus::Variant> &args) {
mukesh agrawal06175d72012-04-23 16:46:01 -070092 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070093 try {
94 return proxy_.Scan(args);
95 } catch (const DBus::Error &e) {
Gary Morainba919ac2012-05-08 11:30:20 -070096 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what()
Gary Morain610977f2012-05-04 16:03:52 -070097 << " args keys are: " << DBusProperties::KeysToString(args);
Gary Morainba919ac2012-05-08 11:30:20 -070098 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -070099 }
mukesh agrawalaf571952011-07-14 14:31:12 -0700100}
101
102void SupplicantInterfaceProxy::SelectNetwork(const ::DBus::Path &network) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700103 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700104 try {
105 return proxy_.SelectNetwork(network);
106 } catch (const DBus::Error &e) {
107 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
108 }
mukesh agrawalaf571952011-07-14 14:31:12 -0700109}
110
Paul Stewart2987dcf2012-01-30 15:47:42 -0800111void SupplicantInterfaceProxy::SetFastReauth(bool enabled) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700112 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700113 try {
114 return proxy_.FastReauth(enabled);
115 } catch (const DBus::Error &e) {
Gary Morainba919ac2012-05-08 11:30:20 -0700116 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what()
Gary Morain610977f2012-05-04 16:03:52 -0700117 << "enabled: " << enabled;
Gary Morainba919ac2012-05-08 11:30:20 -0700118 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -0700119 }
Paul Stewart2987dcf2012-01-30 15:47:42 -0800120}
121
mukesh agrawalf2028172012-03-13 14:20:22 -0700122void SupplicantInterfaceProxy::SetScanInterval(int32 scan_interval) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700123 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700124 try {
125 return proxy_.ScanInterval(scan_interval);
126 } catch (const DBus::Error &e) {
Gary Morainba919ac2012-05-08 11:30:20 -0700127 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what()
Gary Morain610977f2012-05-04 16:03:52 -0700128 << " scan interval: " << scan_interval;
Gary Morainba919ac2012-05-08 11:30:20 -0700129 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -0700130 }
mukesh agrawalf2028172012-03-13 14:20:22 -0700131}
132
mukesh agrawalaf571952011-07-14 14:31:12 -0700133// definitions for private class SupplicantInterfaceProxy::Proxy
134
135SupplicantInterfaceProxy::Proxy::Proxy(
136 const WiFiRefPtr &wifi, DBus::Connection *bus,
137 const DBus::Path &dbus_path, const char *dbus_addr)
138 : DBus::ObjectProxy(*bus, dbus_path, dbus_addr),
139 wifi_(wifi) {}
140
141SupplicantInterfaceProxy::Proxy::~Proxy() {}
142
mukesh agrawal1830fa12011-09-26 14:31:40 -0700143void SupplicantInterfaceProxy::Proxy::BlobAdded(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
mukesh agrawal1830fa12011-09-26 14:31:40 -0700148void SupplicantInterfaceProxy::Proxy::BlobRemoved(const string &/*blobname*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700149 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700150 // XXX
151}
152
153void SupplicantInterfaceProxy::Proxy::BSSAdded(
154 const ::DBus::Path &BSS,
155 const std::map<string, ::DBus::Variant> &properties) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700156 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700157 wifi_->BSSAdded(BSS, properties);
158}
159
mukesh agrawal261daca2011-12-02 18:56:56 +0000160void SupplicantInterfaceProxy::Proxy::BSSRemoved(const ::DBus::Path &BSS) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700161 SLOG(DBus, 2) << __func__;
mukesh agrawal261daca2011-12-02 18:56:56 +0000162 wifi_->BSSRemoved(BSS);
mukesh agrawalaf571952011-07-14 14:31:12 -0700163}
164
165void SupplicantInterfaceProxy::Proxy::NetworkAdded(
mukesh agrawal1830fa12011-09-26 14:31:40 -0700166 const ::DBus::Path &/*network*/,
167 const std::map<string, ::DBus::Variant> &/*properties*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700168 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700169 // XXX
170}
171
172void SupplicantInterfaceProxy::Proxy::NetworkRemoved(
mukesh agrawal1830fa12011-09-26 14:31:40 -0700173 const ::DBus::Path &/*network*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700174 SLOG(DBus, 2) << __func__;
mukesh agrawal8a3188d2011-12-01 20:56:44 +0000175 // TODO(quiche): Pass this up to WiFi, so that it can clean its
176 // rpcid_by_service_ map. crosbug.com/24699
mukesh agrawalaf571952011-07-14 14:31:12 -0700177}
178
179void SupplicantInterfaceProxy::Proxy::NetworkSelected(
mukesh agrawal1830fa12011-09-26 14:31:40 -0700180 const ::DBus::Path &/*network*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700181 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700182 // XXX
183}
184
185void SupplicantInterfaceProxy::Proxy::PropertiesChanged(
mukesh agrawal7ec71312011-11-10 02:08:26 +0000186 const std::map<string, ::DBus::Variant> &properties) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700187 SLOG(DBus, 2) << __func__;
mukesh agrawal7ec71312011-11-10 02:08:26 +0000188 wifi_->PropertiesChanged(properties);
mukesh agrawalaf571952011-07-14 14:31:12 -0700189}
190
191void SupplicantInterfaceProxy::Proxy::ScanDone(const bool& success) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700192 SLOG(DBus, 2) << __func__ << ": " << success;
mukesh agrawalaf571952011-07-14 14:31:12 -0700193 if (success) {
194 wifi_->ScanDone();
195 }
196}
197
198} // namespace shill