blob: d600746966d178471c9366e86f0e41e774a3fe96 [file] [log] [blame]
Jason Glasgowee1081c2012-03-06 15:14:53 -05001// Copyright (c) 2012 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/mm1_modem_proxy.h"
6
Ben Chanfad4a0b2012-04-18 15:49:59 -07007#include "shill/cellular_error.h"
Christopher Wileyb691efd2012-08-09 13:51:51 -07008#include "shill/logging.h"
Jason Glasgowee1081c2012-03-06 15:14:53 -05009
10using std::string;
11
12namespace shill {
13namespace mm1 {
14
Eric Shienbrood9a245532012-03-07 14:20:39 -050015ModemProxy::ModemProxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -050016 const string &path,
17 const string &service)
Eric Shienbrood9a245532012-03-07 14:20:39 -050018 : proxy_(connection, path, service) {}
Jason Glasgowee1081c2012-03-06 15:14:53 -050019
20ModemProxy::~ModemProxy() {}
21
Eric Shienbrood9a245532012-03-07 14:20:39 -050022void ModemProxy::set_state_changed_callback(
23 const ModemStateChangedSignalCallback &callback) {
24 proxy_.set_state_changed_callback(callback);
Jason Glasgowee1081c2012-03-06 15:14:53 -050025}
26
Eric Shienbrood9a245532012-03-07 14:20:39 -050027void ModemProxy::Enable(bool enable,
28 Error *error,
29 const ResultCallback &callback,
30 int timeout) {
Ben Chanfad4a0b2012-04-18 15:49:59 -070031 SLOG(Modem, 2) << __func__ << "(" << enable << ", " << timeout << ")";
Eric Shienbrood9a245532012-03-07 14:20:39 -050032 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
33 try {
mukesh agrawal06175d72012-04-23 16:46:01 -070034 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -050035 proxy_.Enable(enable, cb.get(), timeout);
36 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -070037 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050038 if (error)
39 CellularError::FromDBusError(e, error);
40 }
41}
42
43void ModemProxy::ListBearers(Error *error,
44 const DBusPathsCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050045 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050046 scoped_ptr<DBusPathsCallback> cb(new DBusPathsCallback(callback));
47 try {
mukesh agrawal06175d72012-04-23 16:46:01 -070048 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -050049 proxy_.ListBearers(cb.get(), timeout);
50 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -070051 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050052 if (error)
53 CellularError::FromDBusError(e, error);
54 }
Jason Glasgowee1081c2012-03-06 15:14:53 -050055}
56
57void ModemProxy::CreateBearer(
58 const DBusPropertiesMap &properties,
Eric Shienbrood9a245532012-03-07 14:20:39 -050059 Error *error,
60 const DBusPathCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050061 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050062 scoped_ptr<DBusPathCallback> cb(new DBusPathCallback(callback));
63 try {
mukesh agrawal06175d72012-04-23 16:46:01 -070064 SLOG(DBus, 2) << __func__;
65 proxy_.CreateBearer(properties, cb.get(), timeout);
Eric Shienbrood9a245532012-03-07 14:20:39 -050066 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -070067 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050068 if (error)
69 CellularError::FromDBusError(e, error);
70 }
Jason Glasgowee1081c2012-03-06 15:14:53 -050071}
72
73void ModemProxy::DeleteBearer(const ::DBus::Path &bearer,
Eric Shienbrood9a245532012-03-07 14:20:39 -050074 Error *error,
75 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050076 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050077 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
78 try {
mukesh agrawal06175d72012-04-23 16:46:01 -070079 SLOG(DBus, 2) << __func__;
80 proxy_.DeleteBearer(bearer, cb.get(), timeout);
Eric Shienbrood9a245532012-03-07 14:20:39 -050081 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -070082 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050083 if (error)
84 CellularError::FromDBusError(e, error);
85 }
Jason Glasgowee1081c2012-03-06 15:14:53 -050086}
87
Eric Shienbrood9a245532012-03-07 14:20:39 -050088void ModemProxy::Reset(Error *error,
89 const ResultCallback &callback,
90 int timeout) {
91 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
92 try {
mukesh agrawal06175d72012-04-23 16:46:01 -070093 SLOG(DBus, 2) << __func__;
94 proxy_.Reset(cb.get(), timeout);
Eric Shienbrood9a245532012-03-07 14:20:39 -050095 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -070096 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050097 if (error)
98 CellularError::FromDBusError(e, error);
99 }
Jason Glasgowee1081c2012-03-06 15:14:53 -0500100}
101
102void ModemProxy::FactoryReset(const std::string &code,
Eric Shienbrood9a245532012-03-07 14:20:39 -0500103 Error *error,
104 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500105 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500106 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
107 try {
mukesh agrawal06175d72012-04-23 16:46:01 -0700108 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500109 proxy_.FactoryReset(code, cb.get(), timeout);
110 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -0700111 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500112 if (error)
113 CellularError::FromDBusError(e, error);
114 }
Jason Glasgowee1081c2012-03-06 15:14:53 -0500115}
116
117void ModemProxy::SetAllowedModes(const uint32_t &modes,
118 const uint32_t &preferred,
Eric Shienbrood9a245532012-03-07 14:20:39 -0500119 Error *error,
120 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500121 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500122 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
123 try {
mukesh agrawal06175d72012-04-23 16:46:01 -0700124 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500125 proxy_.SetAllowedModes(modes, preferred, cb.get(), timeout);
126 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -0700127 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500128 if (error)
129 CellularError::FromDBusError(e, error);
130 }
Jason Glasgowee1081c2012-03-06 15:14:53 -0500131}
132
Gary Morain610977f2012-05-04 16:03:52 -0700133void ModemProxy::SetBands(const std::vector<uint32_t> &bands,
Eric Shienbrood9a245532012-03-07 14:20:39 -0500134 Error *error,
135 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500136 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500137 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
138 try {
mukesh agrawal06175d72012-04-23 16:46:01 -0700139 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500140 proxy_.SetBands(bands, cb.get(), timeout);
141 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -0700142 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500143 if (error)
144 CellularError::FromDBusError(e, error);
145 }
Jason Glasgowee1081c2012-03-06 15:14:53 -0500146}
147
148void ModemProxy::Command(const std::string &cmd,
149 const uint32_t &user_timeout,
Eric Shienbrood9a245532012-03-07 14:20:39 -0500150 Error *error,
151 const StringCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500152 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500153 scoped_ptr<StringCallback> cb(new StringCallback(callback));
154 try {
mukesh agrawal06175d72012-04-23 16:46:01 -0700155 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500156 proxy_.Command(cmd, user_timeout, cb.get(), timeout);
157 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -0700158 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500159 if (error)
160 CellularError::FromDBusError(e, error);
161 }
Jason Glasgowee1081c2012-03-06 15:14:53 -0500162}
163
164// Inherited properties from ModemProxyInterface.
165const ::DBus::Path ModemProxy::Sim() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700166 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700167 try {
168 return proxy_.Sim();
169 } catch (const DBus::Error &e) {
170 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
171 return ::DBus::Path(); // Make the compiler happy.
172 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400173}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500174uint32_t ModemProxy::ModemCapabilities() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700175 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700176 try {
177 return proxy_.ModemCapabilities();
178 } catch (const DBus::Error &e) {
179 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
180 return 0; // Make the compiler happy.
181 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400182}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500183uint32_t ModemProxy::CurrentCapabilities() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700184 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700185 try {
186 return proxy_.CurrentCapabilities();
187 } catch (const DBus::Error &e) {
188 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
189 return 0; // Make the compiler happy.
190 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400191}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500192uint32_t ModemProxy::MaxBearers() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700193 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700194 try {
195 return proxy_.MaxBearers();
196 } catch (const DBus::Error &e) {
197 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
198 return 0; // Make the compiler happy.
199 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400200}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500201uint32_t ModemProxy::MaxActiveBearers() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700202 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700203 try {
204 return proxy_.MaxActiveBearers();
205 } catch (const DBus::Error &e) {
206 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
207 return 0; // Make the compiler happy.
208 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400209}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500210const std::string ModemProxy::Manufacturer() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700211 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700212 try {
213 return proxy_.Manufacturer();
214 } catch (const DBus::Error &e) {
215 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
216 return std::string(); // Make the compiler happy.
217 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400218}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500219const std::string ModemProxy::Model() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700220 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700221 try {
222 return proxy_.Model();
223 } catch (const DBus::Error &e) {
224 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
225 return std::string(); // Make the compiler happy.
226 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400227}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500228const std::string ModemProxy::Revision() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700229 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700230 try {
231 return proxy_.Revision();
232 } catch (const DBus::Error &e) {
233 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
234 return std::string(); // Make the compiler happy.
235 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400236}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500237const std::string ModemProxy::DeviceIdentifier() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700238 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700239 try {
240 return proxy_.DeviceIdentifier();
241 } catch (const DBus::Error &e) {
242 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
243 return std::string(); // Make the compiler happy.
244 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400245}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500246const std::string ModemProxy::Device() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700247 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700248 try {
249 return proxy_.Device();
250 } catch (const DBus::Error &e) {
251 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
252 return std::string(); // Make the compiler happy.
253 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400254}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500255const std::string ModemProxy::Driver() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700256 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700257 try {
258 return proxy_.Driver();
259 } catch (const DBus::Error &e) {
260 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
261 return std::string(); // Make the compiler happy.
262 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400263}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500264const std::string ModemProxy::Plugin() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700265 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700266 try {
267 return proxy_.Plugin();
268 } catch (const DBus::Error &e) {
269 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
270 return std::string(); // Make the compiler happy.
271 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400272}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500273const std::string ModemProxy::EquipmentIdentifier() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700274 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700275 try {
276 return proxy_.EquipmentIdentifier();
277 } catch (const DBus::Error &e) {
278 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
279 return std::string(); // Make the compiler happy.
280 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400281}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500282uint32_t ModemProxy::UnlockRequired() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700283 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700284 try {
285 return proxy_.UnlockRequired();
286 } catch (const DBus::Error &e) {
287 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
288 return 0; // Make the compiler happy.
289 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400290}
Gary Morain610977f2012-05-04 16:03:52 -0700291const std::map<uint32_t, uint32_t> ModemProxy::UnlockRetries() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700292 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700293 try {
294 return proxy_.UnlockRetries();
295 } catch (const DBus::Error &e) {
296 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
297 return std::map<uint32_t, uint32_t>(); // Make the compiler happy.
298 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400299}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500300uint32_t ModemProxy::State() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700301 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700302 try {
303 return proxy_.State();
304 } catch (const DBus::Error &e) {
305 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
306 return 0; // Make the compiler happy.
307 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400308}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500309uint32_t ModemProxy::AccessTechnologies() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700310 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700311 try {
312 return proxy_.AccessTechnologies();
313 } catch (const DBus::Error &e) {
314 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
315 return 0; // Make the compiler happy.
316 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400317}
Gary Morain610977f2012-05-04 16:03:52 -0700318const ::DBus::Struct<uint32_t, bool> ModemProxy::SignalQuality() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700319 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700320 try {
321 return proxy_.SignalQuality();
322 } catch (const DBus::Error &e) {
323 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
324 return ::DBus::Struct<uint32_t, bool>(); // Make the compiler happy.
325 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400326}
327const std::vector<string> ModemProxy::OwnNumbers() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700328 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700329 try {
330 return proxy_.OwnNumbers();
331 } catch (const DBus::Error &e) {
332 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
333 return std::vector<string>(); // Make the compiler happy.
334 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400335}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500336uint32_t ModemProxy::SupportedModes() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700337 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700338 try {
339 return proxy_.SupportedModes();
340 } catch (const DBus::Error &e) {
341 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
342 return 0; // Make the compiler happy.
343 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400344}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500345uint32_t ModemProxy::AllowedModes() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700346 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700347 try {
348 return proxy_.AllowedModes();
349 } catch (const DBus::Error &e) {
350 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
351 return 0; // Make the compiler happy.
352 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400353}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500354uint32_t ModemProxy::PreferredMode() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700355 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700356 try {
357 return proxy_.PreferredMode();
358 } catch (const DBus::Error &e) {
359 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
360 return 0; // Make the compiler happy.
361 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400362}
Gary Morain610977f2012-05-04 16:03:52 -0700363const std::vector<uint32_t> ModemProxy::SupportedBands() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700364 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700365 try {
366 return proxy_.SupportedBands();
367 } catch (const DBus::Error &e) {
368 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
369 return std::vector<uint32_t>(); // Make the compiler happy.
370 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400371}
Gary Morain610977f2012-05-04 16:03:52 -0700372const std::vector<uint32_t> ModemProxy::Bands() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700373 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700374 try {
375 return proxy_.Bands();
376 } catch (const DBus::Error &e) {
377 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
378 return std::vector<uint32_t>(); // Make the compiler happy.
379 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400380}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500381
Eric Shienbrood9a245532012-03-07 14:20:39 -0500382ModemProxy::Proxy::Proxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500383 const std::string &path,
384 const std::string &service)
Eric Shienbrood9a245532012-03-07 14:20:39 -0500385 : DBus::ObjectProxy(*connection, path, service.c_str()) {}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500386
387ModemProxy::Proxy::~Proxy() {}
388
Eric Shienbrood9a245532012-03-07 14:20:39 -0500389void ModemProxy::Proxy::set_state_changed_callback(
390 const ModemStateChangedSignalCallback &callback) {
391 state_changed_callback_ = callback;
392}
393
Jason Glasgowee1081c2012-03-06 15:14:53 -0500394// Signal callbacks inherited from Proxy
Nathan Williamsa31e79c2012-03-30 15:07:00 -0400395void ModemProxy::Proxy::StateChanged(const int32_t &old,
396 const int32_t &_new,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500397 const uint32_t &reason) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700398 SLOG(DBus, 2) << __func__;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400399 if (!state_changed_callback_.is_null())
400 state_changed_callback_.Run(old, _new, reason);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500401}
402
403// Method callbacks inherited from
404// org::freedesktop::ModemManager1::ModemProxy
405void ModemProxy::Proxy::EnableCallback(const ::DBus::Error& dberror,
406 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700407 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500408 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500409 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500410 CellularError::FromDBusError(dberror, &error);
411 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500412}
413
414void ModemProxy::Proxy::ListBearersCallback(
Gary Morain610977f2012-05-04 16:03:52 -0700415 const std::vector< ::DBus::Path> &bearers,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500416 const ::DBus::Error& dberror,
417 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700418 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500419 scoped_ptr<DBusPathsCallback> callback(
420 reinterpret_cast<DBusPathsCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500421 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500422 CellularError::FromDBusError(dberror, &error);
423 callback->Run(bearers, error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500424}
425
426void ModemProxy::Proxy::CreateBearerCallback(const ::DBus::Path &path,
427 const ::DBus::Error& dberror,
428 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700429 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500430 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500431 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500432 CellularError::FromDBusError(dberror, &error);
433 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500434}
435
436void ModemProxy::Proxy::DeleteBearerCallback(const ::DBus::Error& dberror,
437 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700438 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500439 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500440 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500441 CellularError::FromDBusError(dberror, &error);
442 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500443}
444
445void ModemProxy::Proxy::ResetCallback(const ::DBus::Error& dberror,
446 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700447 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500448 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500449 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500450 CellularError::FromDBusError(dberror, &error);
451 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500452}
453
454void ModemProxy::Proxy::FactoryResetCallback(const ::DBus::Error& dberror,
455 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700456 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500457 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500458 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500459 CellularError::FromDBusError(dberror, &error);
460 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500461}
462
463void ModemProxy::Proxy::SetAllowedModesCallback(
464 const ::DBus::Error& dberror,
465 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700466 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500467 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500468 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500469 CellularError::FromDBusError(dberror, &error);
470 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500471}
472
473void ModemProxy::Proxy::SetBandsCallback(const ::DBus::Error& dberror,
474 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700475 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500476 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500477 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500478 CellularError::FromDBusError(dberror, &error);
479 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500480}
481
482void ModemProxy::Proxy::CommandCallback(const std::string &response,
483 const ::DBus::Error& dberror,
484 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700485 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500486 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500487 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500488 CellularError::FromDBusError(dberror, &error);
489 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500490}
491
492} // namespace mm1
493} // namespace shill