blob: 2e29a45715e59706101dcea53fceaf848a61efd3 [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(
Ben Chan74924d82013-06-15 17:52:55 -070023 const ModemStateChangedSignalCallback &callback) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050024 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
Ben Chan74924d82013-06-15 17:52:55 -0700117void ModemProxy::SetCurrentCapabilities(const uint32_t &capabilities,
118 Error *error,
119 const ResultCallback &callback,
120 int timeout) {
121 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
122 try {
123 SLOG(DBus, 2) << __func__;
124 proxy_.SetCurrentCapabilities(capabilities, cb.get(), timeout);
125 cb.release();
126 } catch (const DBus::Error &e) {
127 if (error)
128 CellularError::FromDBusError(e, error);
129 }
130}
131
132void ModemProxy::SetCurrentModes(
133 const ::DBus::Struct<uint32_t, uint32_t> &modes,
134 Error *error,
135 const ResultCallback &callback,
136 int timeout) {
137 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
138 try {
139 SLOG(DBus, 2) << __func__;
140 proxy_.SetCurrentModes(modes, cb.get(), timeout);
141 cb.release();
142 } catch (const DBus::Error &e) {
143 if (error)
144 CellularError::FromDBusError(e, error);
145 }
146}
147
148void ModemProxy::SetCurrentBands(const std::vector<uint32_t> &bands,
149 Error *error,
150 const ResultCallback &callback,
151 int timeout) {
152 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
153 try {
154 SLOG(DBus, 2) << __func__;
155 proxy_.SetCurrentBands(bands, cb.get(), timeout);
156 cb.release();
157 } catch (const DBus::Error &e) {
158 if (error)
159 CellularError::FromDBusError(e, error);
160 }
161}
162
Jason Glasgowee1081c2012-03-06 15:14:53 -0500163void ModemProxy::Command(const std::string &cmd,
164 const uint32_t &user_timeout,
Eric Shienbrood9a245532012-03-07 14:20:39 -0500165 Error *error,
166 const StringCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500167 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500168 scoped_ptr<StringCallback> cb(new StringCallback(callback));
169 try {
mukesh agrawal06175d72012-04-23 16:46:01 -0700170 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500171 proxy_.Command(cmd, user_timeout, cb.get(), timeout);
172 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -0700173 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500174 if (error)
175 CellularError::FromDBusError(e, error);
176 }
Jason Glasgowee1081c2012-03-06 15:14:53 -0500177}
178
Arman Ugurayee464d32013-02-13 17:14:36 -0800179void ModemProxy::SetPowerState(const uint32_t &power_state,
180 Error *error,
181 const ResultCallback &callback,
182 int timeout) {
183 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
184 try {
185 SLOG(DBus, 2) << __func__;
186 proxy_.SetPowerState(power_state, cb.get(), timeout);
187 cb.release();
188 } catch (const DBus::Error &e) {
189 if (error)
190 CellularError::FromDBusError(e, error);
191 }
192}
193
Jason Glasgowee1081c2012-03-06 15:14:53 -0500194// Inherited properties from ModemProxyInterface.
195const ::DBus::Path ModemProxy::Sim() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700196 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700197 try {
198 return proxy_.Sim();
199 } catch (const DBus::Error &e) {
200 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
201 return ::DBus::Path(); // Make the compiler happy.
202 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400203}
Ben Chan74924d82013-06-15 17:52:55 -0700204
205const std::vector<uint32_t> ModemProxy::SupportedCapabilities() {
206 SLOG(DBus, 2) << __func__;
207 try {
208 return proxy_.SupportedCapabilities();
209 } catch (const DBus::Error &e) {
210 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
211 return std::vector<uint32_t>(); // Make the compiler happy.
212 }
213}
214
Jason Glasgowee1081c2012-03-06 15:14:53 -0500215uint32_t ModemProxy::CurrentCapabilities() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700216 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700217 try {
218 return proxy_.CurrentCapabilities();
219 } catch (const DBus::Error &e) {
220 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
221 return 0; // Make the compiler happy.
222 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400223}
Ben Chan74924d82013-06-15 17:52:55 -0700224
Jason Glasgowee1081c2012-03-06 15:14:53 -0500225uint32_t ModemProxy::MaxBearers() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700226 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700227 try {
228 return proxy_.MaxBearers();
229 } catch (const DBus::Error &e) {
230 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
231 return 0; // Make the compiler happy.
232 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400233}
Ben Chan74924d82013-06-15 17:52:55 -0700234
Jason Glasgowee1081c2012-03-06 15:14:53 -0500235uint32_t ModemProxy::MaxActiveBearers() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700236 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700237 try {
238 return proxy_.MaxActiveBearers();
239 } catch (const DBus::Error &e) {
240 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
241 return 0; // Make the compiler happy.
242 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400243}
Ben Chan74924d82013-06-15 17:52:55 -0700244
Jason Glasgowee1081c2012-03-06 15:14:53 -0500245const std::string ModemProxy::Manufacturer() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700246 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700247 try {
248 return proxy_.Manufacturer();
249 } catch (const DBus::Error &e) {
250 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
251 return std::string(); // Make the compiler happy.
252 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400253}
Ben Chan74924d82013-06-15 17:52:55 -0700254
Jason Glasgowee1081c2012-03-06 15:14:53 -0500255const std::string ModemProxy::Model() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700256 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700257 try {
258 return proxy_.Model();
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}
Ben Chan74924d82013-06-15 17:52:55 -0700264
Jason Glasgowee1081c2012-03-06 15:14:53 -0500265const std::string ModemProxy::Revision() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700266 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700267 try {
268 return proxy_.Revision();
269 } catch (const DBus::Error &e) {
270 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
271 return std::string(); // Make the compiler happy.
272 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400273}
Ben Chan74924d82013-06-15 17:52:55 -0700274
Jason Glasgowee1081c2012-03-06 15:14:53 -0500275const std::string ModemProxy::DeviceIdentifier() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700276 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700277 try {
278 return proxy_.DeviceIdentifier();
279 } catch (const DBus::Error &e) {
280 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
281 return std::string(); // Make the compiler happy.
282 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400283}
Ben Chan74924d82013-06-15 17:52:55 -0700284
Jason Glasgowee1081c2012-03-06 15:14:53 -0500285const std::string ModemProxy::Device() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700286 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700287 try {
288 return proxy_.Device();
289 } catch (const DBus::Error &e) {
290 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
291 return std::string(); // Make the compiler happy.
292 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400293}
Ben Chan74924d82013-06-15 17:52:55 -0700294
Ben Chan34e5d682012-08-24 19:10:49 -0700295const std::vector<std::string> ModemProxy::Drivers() {
296 SLOG(DBus, 2) << __func__;
297 try {
298 return proxy_.Drivers();
299 } catch (const DBus::Error &e) {
300 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
301 return std::vector<std::string>(); // Make the compiler happy.
302 }
303}
Ben Chan74924d82013-06-15 17:52:55 -0700304
Jason Glasgowee1081c2012-03-06 15:14:53 -0500305const std::string ModemProxy::Plugin() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700306 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700307 try {
308 return proxy_.Plugin();
309 } catch (const DBus::Error &e) {
310 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
311 return std::string(); // Make the compiler happy.
312 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400313}
Ben Chan74924d82013-06-15 17:52:55 -0700314
Jason Glasgowee1081c2012-03-06 15:14:53 -0500315const std::string ModemProxy::EquipmentIdentifier() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700316 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700317 try {
318 return proxy_.EquipmentIdentifier();
319 } catch (const DBus::Error &e) {
320 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
321 return std::string(); // Make the compiler happy.
322 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400323}
Ben Chan74924d82013-06-15 17:52:55 -0700324
Jason Glasgowee1081c2012-03-06 15:14:53 -0500325uint32_t ModemProxy::UnlockRequired() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700326 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700327 try {
328 return proxy_.UnlockRequired();
329 } catch (const DBus::Error &e) {
330 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
331 return 0; // Make the compiler happy.
332 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400333}
Ben Chan74924d82013-06-15 17:52:55 -0700334
Gary Morain610977f2012-05-04 16:03:52 -0700335const std::map<uint32_t, uint32_t> ModemProxy::UnlockRetries() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700336 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700337 try {
338 return proxy_.UnlockRetries();
339 } catch (const DBus::Error &e) {
340 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
341 return std::map<uint32_t, uint32_t>(); // Make the compiler happy.
342 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400343}
Ben Chan74924d82013-06-15 17:52:55 -0700344
Jason Glasgowee1081c2012-03-06 15:14:53 -0500345uint32_t ModemProxy::State() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700346 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700347 try {
348 return proxy_.State();
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}
Ben Chan74924d82013-06-15 17:52:55 -0700354
Jason Glasgowee1081c2012-03-06 15:14:53 -0500355uint32_t ModemProxy::AccessTechnologies() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700356 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700357 try {
358 return proxy_.AccessTechnologies();
359 } catch (const DBus::Error &e) {
360 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
361 return 0; // Make the compiler happy.
362 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400363}
Ben Chan74924d82013-06-15 17:52:55 -0700364
Gary Morain610977f2012-05-04 16:03:52 -0700365const ::DBus::Struct<uint32_t, bool> ModemProxy::SignalQuality() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700366 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700367 try {
368 return proxy_.SignalQuality();
369 } catch (const DBus::Error &e) {
370 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
371 return ::DBus::Struct<uint32_t, bool>(); // Make the compiler happy.
372 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400373}
Ben Chan74924d82013-06-15 17:52:55 -0700374
Jason Glasgow90d216d2012-04-04 15:57:14 -0400375const std::vector<string> ModemProxy::OwnNumbers() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700376 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700377 try {
378 return proxy_.OwnNumbers();
379 } catch (const DBus::Error &e) {
380 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
381 return std::vector<string>(); // Make the compiler happy.
382 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400383}
Ben Chan74924d82013-06-15 17:52:55 -0700384
385const std::vector<::DBus::Struct<uint32_t, uint32_t>>
386ModemProxy::SupportedModes() {
387 SLOG(DBus, 2) << __func__;
388 try {
389 return proxy_.SupportedModes();
390 } catch (const DBus::Error &e) {
391 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
392 // Make the compiler happy.
393 return std::vector<::DBus::Struct<uint32_t, uint32_t>>();
394 }
395}
396
397const ::DBus::Struct<uint32_t, uint32_t> ModemProxy::CurrentModes() {
398 SLOG(DBus, 2) << __func__;
399 try {
400 return proxy_.CurrentModes();
401 } catch (const DBus::Error &e) {
402 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
403 return ::DBus::Struct<uint32_t, uint32_t>(); // Make the compiler happy.
404 }
405}
406
Gary Morain610977f2012-05-04 16:03:52 -0700407const std::vector<uint32_t> ModemProxy::SupportedBands() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700408 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700409 try {
410 return proxy_.SupportedBands();
411 } catch (const DBus::Error &e) {
412 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
413 return std::vector<uint32_t>(); // Make the compiler happy.
414 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400415}
Ben Chan74924d82013-06-15 17:52:55 -0700416
417const std::vector<uint32_t> ModemProxy::CurrentBands() {
418 SLOG(DBus, 2) << __func__;
419 try {
420 return proxy_.CurrentBands();
421 } catch (const DBus::Error &e) {
422 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
423 return std::vector<uint32_t>(); // Make the compiler happy.
424 }
425}
426
427uint32_t ModemProxy::SupportedIpFamilies() {
428 SLOG(DBus, 2) << __func__;
429 try {
430 return proxy_.SupportedIpFamilies();
431 } catch (const DBus::Error &e) {
432 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
433 return 0; // Make the compiler happy.
434 }
435}
436
Arman Ugurayee464d32013-02-13 17:14:36 -0800437uint32_t ModemProxy::PowerState() {
438 SLOG(DBus, 2) << __func__;
439 try {
440 return proxy_.PowerState();
441 } catch (const DBus::Error &e) {
442 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
443 return 0; // Make the compiler happy.
444 }
445}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500446
Eric Shienbrood9a245532012-03-07 14:20:39 -0500447ModemProxy::Proxy::Proxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500448 const std::string &path,
449 const std::string &service)
Eric Shienbrood9a245532012-03-07 14:20:39 -0500450 : DBus::ObjectProxy(*connection, path, service.c_str()) {}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500451
452ModemProxy::Proxy::~Proxy() {}
453
Eric Shienbrood9a245532012-03-07 14:20:39 -0500454void ModemProxy::Proxy::set_state_changed_callback(
455 const ModemStateChangedSignalCallback &callback) {
456 state_changed_callback_ = callback;
457}
458
Jason Glasgowee1081c2012-03-06 15:14:53 -0500459// Signal callbacks inherited from Proxy
Nathan Williamsa31e79c2012-03-30 15:07:00 -0400460void ModemProxy::Proxy::StateChanged(const int32_t &old,
461 const int32_t &_new,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500462 const uint32_t &reason) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700463 SLOG(DBus, 2) << __func__;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400464 if (!state_changed_callback_.is_null())
465 state_changed_callback_.Run(old, _new, reason);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500466}
467
468// Method callbacks inherited from
469// org::freedesktop::ModemManager1::ModemProxy
Ben Chan74924d82013-06-15 17:52:55 -0700470void ModemProxy::Proxy::EnableCallback(const ::DBus::Error &dberror,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500471 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700472 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500473 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500474 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500475 CellularError::FromDBusError(dberror, &error);
476 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500477}
478
479void ModemProxy::Proxy::ListBearersCallback(
Gary Morain610977f2012-05-04 16:03:52 -0700480 const std::vector< ::DBus::Path> &bearers,
Ben Chan74924d82013-06-15 17:52:55 -0700481 const ::DBus::Error &dberror,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500482 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700483 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500484 scoped_ptr<DBusPathsCallback> callback(
485 reinterpret_cast<DBusPathsCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500486 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500487 CellularError::FromDBusError(dberror, &error);
488 callback->Run(bearers, error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500489}
490
491void ModemProxy::Proxy::CreateBearerCallback(const ::DBus::Path &path,
Ben Chan74924d82013-06-15 17:52:55 -0700492 const ::DBus::Error &dberror,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500493 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700494 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500495 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500496 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500497 CellularError::FromDBusError(dberror, &error);
498 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500499}
500
Ben Chan74924d82013-06-15 17:52:55 -0700501void ModemProxy::Proxy::DeleteBearerCallback(const ::DBus::Error &dberror,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500502 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700503 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500504 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500505 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500506 CellularError::FromDBusError(dberror, &error);
507 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500508}
509
Ben Chan74924d82013-06-15 17:52:55 -0700510void ModemProxy::Proxy::ResetCallback(const ::DBus::Error &dberror,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500511 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700512 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500513 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500514 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500515 CellularError::FromDBusError(dberror, &error);
516 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500517}
518
Ben Chan74924d82013-06-15 17:52:55 -0700519void ModemProxy::Proxy::FactoryResetCallback(const ::DBus::Error &dberror,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500520 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700521 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500522 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500523 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500524 CellularError::FromDBusError(dberror, &error);
525 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500526}
527
Ben Chan74924d82013-06-15 17:52:55 -0700528void ModemProxy::Proxy::SetCurrentCapabilitesCallback(
529 const ::DBus::Error &dberror,
530 void *data) {
531 SLOG(DBus, 2) << __func__;
532 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
533 Error error;
534 CellularError::FromDBusError(dberror, &error);
535 callback->Run(error);
536}
537
538void ModemProxy::Proxy::SetCurrentModesCallback(const ::DBus::Error &dberror,
539 void *data) {
540 SLOG(DBus, 2) << __func__;
541 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
542 Error error;
543 CellularError::FromDBusError(dberror, &error);
544 callback->Run(error);
545}
546
547void ModemProxy::Proxy::SetCurrentBandsCallback(const ::DBus::Error &dberror,
548 void *data) {
549 SLOG(DBus, 2) << __func__;
550 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
551 Error error;
552 CellularError::FromDBusError(dberror, &error);
553 callback->Run(error);
554}
555
Jason Glasgowee1081c2012-03-06 15:14:53 -0500556void ModemProxy::Proxy::CommandCallback(const std::string &response,
Ben Chan74924d82013-06-15 17:52:55 -0700557 const ::DBus::Error &dberror,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500558 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700559 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500560 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500561 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500562 CellularError::FromDBusError(dberror, &error);
563 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500564}
565
Arman Ugurayee464d32013-02-13 17:14:36 -0800566void ModemProxy::Proxy::SetPowerStateCallback(const ::DBus::Error &dberror,
567 void *data) {
568 SLOG(DBus, 2) << __func__;
569 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
570 Error error;
571 CellularError::FromDBusError(dberror, &error);
572 callback->Run(error);
573}
574
Jason Glasgowee1081c2012-03-06 15:14:53 -0500575} // namespace mm1
576} // namespace shill