blob: 58736d57b8ebe4b60481ccbab307e1d3aac3c0ba [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
Arman Ugurayee464d32013-02-13 17:14:36 -0800164void ModemProxy::SetPowerState(const uint32_t &power_state,
165 Error *error,
166 const ResultCallback &callback,
167 int timeout) {
168 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
169 try {
170 SLOG(DBus, 2) << __func__;
171 proxy_.SetPowerState(power_state, cb.get(), timeout);
172 cb.release();
173 } catch (const DBus::Error &e) {
174 if (error)
175 CellularError::FromDBusError(e, error);
176 }
177}
178
Jason Glasgowee1081c2012-03-06 15:14:53 -0500179// Inherited properties from ModemProxyInterface.
180const ::DBus::Path ModemProxy::Sim() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700181 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700182 try {
183 return proxy_.Sim();
184 } catch (const DBus::Error &e) {
185 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
186 return ::DBus::Path(); // Make the compiler happy.
187 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400188}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500189uint32_t ModemProxy::ModemCapabilities() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700190 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700191 try {
192 return proxy_.ModemCapabilities();
193 } catch (const DBus::Error &e) {
194 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
195 return 0; // Make the compiler happy.
196 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400197}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500198uint32_t ModemProxy::CurrentCapabilities() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700199 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700200 try {
201 return proxy_.CurrentCapabilities();
202 } catch (const DBus::Error &e) {
203 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
204 return 0; // Make the compiler happy.
205 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400206}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500207uint32_t ModemProxy::MaxBearers() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700208 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700209 try {
210 return proxy_.MaxBearers();
211 } catch (const DBus::Error &e) {
212 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
213 return 0; // Make the compiler happy.
214 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400215}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500216uint32_t ModemProxy::MaxActiveBearers() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700217 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700218 try {
219 return proxy_.MaxActiveBearers();
220 } catch (const DBus::Error &e) {
221 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
222 return 0; // Make the compiler happy.
223 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400224}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500225const std::string ModemProxy::Manufacturer() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700226 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700227 try {
228 return proxy_.Manufacturer();
229 } catch (const DBus::Error &e) {
230 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
231 return std::string(); // Make the compiler happy.
232 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400233}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500234const std::string ModemProxy::Model() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700235 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700236 try {
237 return proxy_.Model();
238 } catch (const DBus::Error &e) {
239 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
240 return std::string(); // Make the compiler happy.
241 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400242}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500243const std::string ModemProxy::Revision() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700244 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700245 try {
246 return proxy_.Revision();
247 } catch (const DBus::Error &e) {
248 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
249 return std::string(); // Make the compiler happy.
250 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400251}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500252const std::string ModemProxy::DeviceIdentifier() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700253 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700254 try {
255 return proxy_.DeviceIdentifier();
256 } catch (const DBus::Error &e) {
257 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
258 return std::string(); // Make the compiler happy.
259 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400260}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500261const std::string ModemProxy::Device() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700262 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700263 try {
264 return proxy_.Device();
265 } catch (const DBus::Error &e) {
266 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
267 return std::string(); // Make the compiler happy.
268 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400269}
Ben Chan34e5d682012-08-24 19:10:49 -0700270const std::vector<std::string> ModemProxy::Drivers() {
271 SLOG(DBus, 2) << __func__;
272 try {
273 return proxy_.Drivers();
274 } catch (const DBus::Error &e) {
275 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
276 return std::vector<std::string>(); // Make the compiler happy.
277 }
278}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500279const std::string ModemProxy::Plugin() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700280 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700281 try {
282 return proxy_.Plugin();
283 } catch (const DBus::Error &e) {
284 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
285 return std::string(); // Make the compiler happy.
286 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400287}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500288const std::string ModemProxy::EquipmentIdentifier() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700289 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700290 try {
291 return proxy_.EquipmentIdentifier();
292 } catch (const DBus::Error &e) {
293 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
294 return std::string(); // Make the compiler happy.
295 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400296}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500297uint32_t ModemProxy::UnlockRequired() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700298 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700299 try {
300 return proxy_.UnlockRequired();
301 } catch (const DBus::Error &e) {
302 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
303 return 0; // Make the compiler happy.
304 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400305}
Gary Morain610977f2012-05-04 16:03:52 -0700306const std::map<uint32_t, uint32_t> ModemProxy::UnlockRetries() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700307 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700308 try {
309 return proxy_.UnlockRetries();
310 } catch (const DBus::Error &e) {
311 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
312 return std::map<uint32_t, uint32_t>(); // Make the compiler happy.
313 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400314}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500315uint32_t ModemProxy::State() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700316 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700317 try {
318 return proxy_.State();
319 } catch (const DBus::Error &e) {
320 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
321 return 0; // Make the compiler happy.
322 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400323}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500324uint32_t ModemProxy::AccessTechnologies() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700325 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700326 try {
327 return proxy_.AccessTechnologies();
328 } catch (const DBus::Error &e) {
329 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
330 return 0; // Make the compiler happy.
331 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400332}
Gary Morain610977f2012-05-04 16:03:52 -0700333const ::DBus::Struct<uint32_t, bool> ModemProxy::SignalQuality() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700334 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700335 try {
336 return proxy_.SignalQuality();
337 } catch (const DBus::Error &e) {
338 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
339 return ::DBus::Struct<uint32_t, bool>(); // Make the compiler happy.
340 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400341}
342const std::vector<string> ModemProxy::OwnNumbers() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700343 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700344 try {
345 return proxy_.OwnNumbers();
346 } catch (const DBus::Error &e) {
347 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
348 return std::vector<string>(); // Make the compiler happy.
349 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400350}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500351uint32_t ModemProxy::SupportedModes() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700352 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700353 try {
354 return proxy_.SupportedModes();
355 } catch (const DBus::Error &e) {
356 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
357 return 0; // Make the compiler happy.
358 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400359}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500360uint32_t ModemProxy::AllowedModes() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700361 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700362 try {
363 return proxy_.AllowedModes();
364 } catch (const DBus::Error &e) {
365 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
366 return 0; // Make the compiler happy.
367 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400368}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500369uint32_t ModemProxy::PreferredMode() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700370 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700371 try {
372 return proxy_.PreferredMode();
373 } catch (const DBus::Error &e) {
374 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
375 return 0; // Make the compiler happy.
376 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400377}
Gary Morain610977f2012-05-04 16:03:52 -0700378const std::vector<uint32_t> ModemProxy::SupportedBands() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700379 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700380 try {
381 return proxy_.SupportedBands();
382 } catch (const DBus::Error &e) {
383 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
384 return std::vector<uint32_t>(); // Make the compiler happy.
385 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400386}
Gary Morain610977f2012-05-04 16:03:52 -0700387const std::vector<uint32_t> ModemProxy::Bands() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700388 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700389 try {
390 return proxy_.Bands();
391 } catch (const DBus::Error &e) {
392 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
393 return std::vector<uint32_t>(); // Make the compiler happy.
394 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400395}
Arman Ugurayee464d32013-02-13 17:14:36 -0800396uint32_t ModemProxy::PowerState() {
397 SLOG(DBus, 2) << __func__;
398 try {
399 return proxy_.PowerState();
400 } catch (const DBus::Error &e) {
401 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
402 return 0; // Make the compiler happy.
403 }
404}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500405
Eric Shienbrood9a245532012-03-07 14:20:39 -0500406ModemProxy::Proxy::Proxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500407 const std::string &path,
408 const std::string &service)
Eric Shienbrood9a245532012-03-07 14:20:39 -0500409 : DBus::ObjectProxy(*connection, path, service.c_str()) {}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500410
411ModemProxy::Proxy::~Proxy() {}
412
Eric Shienbrood9a245532012-03-07 14:20:39 -0500413void ModemProxy::Proxy::set_state_changed_callback(
414 const ModemStateChangedSignalCallback &callback) {
415 state_changed_callback_ = callback;
416}
417
Jason Glasgowee1081c2012-03-06 15:14:53 -0500418// Signal callbacks inherited from Proxy
Nathan Williamsa31e79c2012-03-30 15:07:00 -0400419void ModemProxy::Proxy::StateChanged(const int32_t &old,
420 const int32_t &_new,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500421 const uint32_t &reason) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700422 SLOG(DBus, 2) << __func__;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400423 if (!state_changed_callback_.is_null())
424 state_changed_callback_.Run(old, _new, reason);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500425}
426
427// Method callbacks inherited from
428// org::freedesktop::ModemManager1::ModemProxy
429void ModemProxy::Proxy::EnableCallback(const ::DBus::Error& dberror,
430 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700431 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500432 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500433 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500434 CellularError::FromDBusError(dberror, &error);
435 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500436}
437
438void ModemProxy::Proxy::ListBearersCallback(
Gary Morain610977f2012-05-04 16:03:52 -0700439 const std::vector< ::DBus::Path> &bearers,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500440 const ::DBus::Error& dberror,
441 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700442 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500443 scoped_ptr<DBusPathsCallback> callback(
444 reinterpret_cast<DBusPathsCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500445 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500446 CellularError::FromDBusError(dberror, &error);
447 callback->Run(bearers, error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500448}
449
450void ModemProxy::Proxy::CreateBearerCallback(const ::DBus::Path &path,
451 const ::DBus::Error& dberror,
452 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700453 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500454 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500455 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500456 CellularError::FromDBusError(dberror, &error);
457 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500458}
459
460void ModemProxy::Proxy::DeleteBearerCallback(const ::DBus::Error& dberror,
461 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700462 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500463 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500464 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500465 CellularError::FromDBusError(dberror, &error);
466 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500467}
468
469void ModemProxy::Proxy::ResetCallback(const ::DBus::Error& dberror,
470 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700471 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500472 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500473 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500474 CellularError::FromDBusError(dberror, &error);
475 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500476}
477
478void ModemProxy::Proxy::FactoryResetCallback(const ::DBus::Error& dberror,
479 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700480 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500481 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500482 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500483 CellularError::FromDBusError(dberror, &error);
484 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500485}
486
487void ModemProxy::Proxy::SetAllowedModesCallback(
488 const ::DBus::Error& dberror,
489 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700490 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500491 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500492 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500493 CellularError::FromDBusError(dberror, &error);
494 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500495}
496
497void ModemProxy::Proxy::SetBandsCallback(const ::DBus::Error& dberror,
498 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700499 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500500 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500501 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500502 CellularError::FromDBusError(dberror, &error);
503 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500504}
505
506void ModemProxy::Proxy::CommandCallback(const std::string &response,
507 const ::DBus::Error& dberror,
508 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700509 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500510 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500511 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500512 CellularError::FromDBusError(dberror, &error);
513 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500514}
515
Arman Ugurayee464d32013-02-13 17:14:36 -0800516void ModemProxy::Proxy::SetPowerStateCallback(const ::DBus::Error &dberror,
517 void *data) {
518 SLOG(DBus, 2) << __func__;
519 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
520 Error error;
521 CellularError::FromDBusError(dberror, &error);
522 callback->Run(error);
523}
524
Jason Glasgowee1081c2012-03-06 15:14:53 -0500525} // namespace mm1
526} // namespace shill