blob: bbedbe820e39d9dd0ef134dd2e2ef679b8757bda [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
7#include <base/logging.h>
8
Ben Chanfad4a0b2012-04-18 15:49:59 -07009#include "shill/cellular_error.h"
10#include "shill/scope_logger.h"
Jason Glasgowee1081c2012-03-06 15:14:53 -050011
12using std::string;
13
14namespace shill {
15namespace mm1 {
16
Eric Shienbrood9a245532012-03-07 14:20:39 -050017ModemProxy::ModemProxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -050018 const string &path,
19 const string &service)
Eric Shienbrood9a245532012-03-07 14:20:39 -050020 : proxy_(connection, path, service) {}
Jason Glasgowee1081c2012-03-06 15:14:53 -050021
22ModemProxy::~ModemProxy() {}
23
Eric Shienbrood9a245532012-03-07 14:20:39 -050024void ModemProxy::set_state_changed_callback(
25 const ModemStateChangedSignalCallback &callback) {
26 proxy_.set_state_changed_callback(callback);
Jason Glasgowee1081c2012-03-06 15:14:53 -050027}
28
Eric Shienbrood9a245532012-03-07 14:20:39 -050029void ModemProxy::Enable(bool enable,
30 Error *error,
31 const ResultCallback &callback,
32 int timeout) {
Ben Chanfad4a0b2012-04-18 15:49:59 -070033 SLOG(Modem, 2) << __func__ << "(" << enable << ", " << timeout << ")";
Eric Shienbrood9a245532012-03-07 14:20:39 -050034 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
35 try {
mukesh agrawal06175d72012-04-23 16:46:01 -070036 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -050037 proxy_.Enable(enable, cb.get(), timeout);
38 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -070039 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050040 if (error)
41 CellularError::FromDBusError(e, error);
42 }
43}
44
45void ModemProxy::ListBearers(Error *error,
46 const DBusPathsCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050047 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050048 scoped_ptr<DBusPathsCallback> cb(new DBusPathsCallback(callback));
49 try {
mukesh agrawal06175d72012-04-23 16:46:01 -070050 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -050051 proxy_.ListBearers(cb.get(), timeout);
52 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -070053 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050054 if (error)
55 CellularError::FromDBusError(e, error);
56 }
Jason Glasgowee1081c2012-03-06 15:14:53 -050057}
58
59void ModemProxy::CreateBearer(
60 const DBusPropertiesMap &properties,
Eric Shienbrood9a245532012-03-07 14:20:39 -050061 Error *error,
62 const DBusPathCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050063 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050064 scoped_ptr<DBusPathCallback> cb(new DBusPathCallback(callback));
65 try {
mukesh agrawal06175d72012-04-23 16:46:01 -070066 SLOG(DBus, 2) << __func__;
67 proxy_.CreateBearer(properties, cb.get(), timeout);
Eric Shienbrood9a245532012-03-07 14:20:39 -050068 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -070069 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050070 if (error)
71 CellularError::FromDBusError(e, error);
72 }
Jason Glasgowee1081c2012-03-06 15:14:53 -050073}
74
75void ModemProxy::DeleteBearer(const ::DBus::Path &bearer,
Eric Shienbrood9a245532012-03-07 14:20:39 -050076 Error *error,
77 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050078 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050079 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
80 try {
mukesh agrawal06175d72012-04-23 16:46:01 -070081 SLOG(DBus, 2) << __func__;
82 proxy_.DeleteBearer(bearer, cb.get(), timeout);
Eric Shienbrood9a245532012-03-07 14:20:39 -050083 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -070084 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050085 if (error)
86 CellularError::FromDBusError(e, error);
87 }
Jason Glasgowee1081c2012-03-06 15:14:53 -050088}
89
Eric Shienbrood9a245532012-03-07 14:20:39 -050090void ModemProxy::Reset(Error *error,
91 const ResultCallback &callback,
92 int timeout) {
93 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
94 try {
mukesh agrawal06175d72012-04-23 16:46:01 -070095 SLOG(DBus, 2) << __func__;
96 proxy_.Reset(cb.get(), timeout);
Eric Shienbrood9a245532012-03-07 14:20:39 -050097 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -070098 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050099 if (error)
100 CellularError::FromDBusError(e, error);
101 }
Jason Glasgowee1081c2012-03-06 15:14:53 -0500102}
103
104void ModemProxy::FactoryReset(const std::string &code,
Eric Shienbrood9a245532012-03-07 14:20:39 -0500105 Error *error,
106 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500107 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500108 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
109 try {
mukesh agrawal06175d72012-04-23 16:46:01 -0700110 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500111 proxy_.FactoryReset(code, cb.get(), timeout);
112 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -0700113 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500114 if (error)
115 CellularError::FromDBusError(e, error);
116 }
Jason Glasgowee1081c2012-03-06 15:14:53 -0500117}
118
119void ModemProxy::SetAllowedModes(const uint32_t &modes,
120 const uint32_t &preferred,
Eric Shienbrood9a245532012-03-07 14:20:39 -0500121 Error *error,
122 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500123 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500124 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
125 try {
mukesh agrawal06175d72012-04-23 16:46:01 -0700126 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500127 proxy_.SetAllowedModes(modes, preferred, cb.get(), timeout);
128 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -0700129 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500130 if (error)
131 CellularError::FromDBusError(e, error);
132 }
Jason Glasgowee1081c2012-03-06 15:14:53 -0500133}
134
Gary Morain610977f2012-05-04 16:03:52 -0700135void ModemProxy::SetBands(const std::vector<uint32_t> &bands,
Eric Shienbrood9a245532012-03-07 14:20:39 -0500136 Error *error,
137 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500138 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500139 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
140 try {
mukesh agrawal06175d72012-04-23 16:46:01 -0700141 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500142 proxy_.SetBands(bands, cb.get(), timeout);
143 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -0700144 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500145 if (error)
146 CellularError::FromDBusError(e, error);
147 }
Jason Glasgowee1081c2012-03-06 15:14:53 -0500148}
149
150void ModemProxy::Command(const std::string &cmd,
151 const uint32_t &user_timeout,
Eric Shienbrood9a245532012-03-07 14:20:39 -0500152 Error *error,
153 const StringCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500154 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500155 scoped_ptr<StringCallback> cb(new StringCallback(callback));
156 try {
mukesh agrawal06175d72012-04-23 16:46:01 -0700157 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500158 proxy_.Command(cmd, user_timeout, cb.get(), timeout);
159 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -0700160 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500161 if (error)
162 CellularError::FromDBusError(e, error);
163 }
Jason Glasgowee1081c2012-03-06 15:14:53 -0500164}
165
166// Inherited properties from ModemProxyInterface.
167const ::DBus::Path ModemProxy::Sim() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700168 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700169 try {
170 return proxy_.Sim();
171 } catch (const DBus::Error &e) {
172 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
173 return ::DBus::Path(); // Make the compiler happy.
174 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400175}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500176uint32_t ModemProxy::ModemCapabilities() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700177 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700178 try {
179 return proxy_.ModemCapabilities();
180 } catch (const DBus::Error &e) {
181 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
182 return 0; // Make the compiler happy.
183 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400184}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500185uint32_t ModemProxy::CurrentCapabilities() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700186 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700187 try {
188 return proxy_.CurrentCapabilities();
189 } catch (const DBus::Error &e) {
190 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
191 return 0; // Make the compiler happy.
192 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400193}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500194uint32_t ModemProxy::MaxBearers() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700195 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700196 try {
197 return proxy_.MaxBearers();
198 } catch (const DBus::Error &e) {
199 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
200 return 0; // Make the compiler happy.
201 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400202}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500203uint32_t ModemProxy::MaxActiveBearers() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700204 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700205 try {
206 return proxy_.MaxActiveBearers();
207 } catch (const DBus::Error &e) {
208 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
209 return 0; // Make the compiler happy.
210 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400211}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500212const std::string ModemProxy::Manufacturer() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700213 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700214 try {
215 return proxy_.Manufacturer();
216 } catch (const DBus::Error &e) {
217 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
218 return std::string(); // Make the compiler happy.
219 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400220}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500221const std::string ModemProxy::Model() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700222 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700223 try {
224 return proxy_.Model();
225 } catch (const DBus::Error &e) {
226 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
227 return std::string(); // Make the compiler happy.
228 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400229}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500230const std::string ModemProxy::Revision() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700231 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700232 try {
233 return proxy_.Revision();
234 } catch (const DBus::Error &e) {
235 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
236 return std::string(); // Make the compiler happy.
237 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400238}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500239const std::string ModemProxy::DeviceIdentifier() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700240 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700241 try {
242 return proxy_.DeviceIdentifier();
243 } catch (const DBus::Error &e) {
244 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
245 return std::string(); // Make the compiler happy.
246 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400247}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500248const std::string ModemProxy::Device() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700249 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700250 try {
251 return proxy_.Device();
252 } catch (const DBus::Error &e) {
253 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
254 return std::string(); // Make the compiler happy.
255 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400256}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500257const std::string ModemProxy::Driver() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700258 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700259 try {
260 return proxy_.Driver();
261 } catch (const DBus::Error &e) {
262 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
263 return std::string(); // Make the compiler happy.
264 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400265}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500266const std::string ModemProxy::Plugin() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700267 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700268 try {
269 return proxy_.Plugin();
270 } catch (const DBus::Error &e) {
271 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
272 return std::string(); // Make the compiler happy.
273 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400274}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500275const std::string ModemProxy::EquipmentIdentifier() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700276 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700277 try {
278 return proxy_.EquipmentIdentifier();
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}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500284uint32_t ModemProxy::UnlockRequired() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700285 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700286 try {
287 return proxy_.UnlockRequired();
288 } catch (const DBus::Error &e) {
289 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
290 return 0; // Make the compiler happy.
291 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400292}
Gary Morain610977f2012-05-04 16:03:52 -0700293const std::map<uint32_t, uint32_t> ModemProxy::UnlockRetries() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700294 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700295 try {
296 return proxy_.UnlockRetries();
297 } catch (const DBus::Error &e) {
298 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
299 return std::map<uint32_t, uint32_t>(); // Make the compiler happy.
300 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400301}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500302uint32_t ModemProxy::State() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700303 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700304 try {
305 return proxy_.State();
306 } catch (const DBus::Error &e) {
307 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
308 return 0; // Make the compiler happy.
309 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400310}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500311uint32_t ModemProxy::AccessTechnologies() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700312 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700313 try {
314 return proxy_.AccessTechnologies();
315 } catch (const DBus::Error &e) {
316 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
317 return 0; // Make the compiler happy.
318 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400319}
Gary Morain610977f2012-05-04 16:03:52 -0700320const ::DBus::Struct<uint32_t, bool> ModemProxy::SignalQuality() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700321 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700322 try {
323 return proxy_.SignalQuality();
324 } catch (const DBus::Error &e) {
325 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
326 return ::DBus::Struct<uint32_t, bool>(); // Make the compiler happy.
327 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400328}
329const std::vector<string> ModemProxy::OwnNumbers() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700330 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700331 try {
332 return proxy_.OwnNumbers();
333 } catch (const DBus::Error &e) {
334 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
335 return std::vector<string>(); // Make the compiler happy.
336 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400337}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500338uint32_t ModemProxy::SupportedModes() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700339 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700340 try {
341 return proxy_.SupportedModes();
342 } catch (const DBus::Error &e) {
343 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
344 return 0; // Make the compiler happy.
345 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400346}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500347uint32_t ModemProxy::AllowedModes() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700348 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700349 try {
350 return proxy_.AllowedModes();
351 } catch (const DBus::Error &e) {
352 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
353 return 0; // Make the compiler happy.
354 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400355}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500356uint32_t ModemProxy::PreferredMode() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700357 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700358 try {
359 return proxy_.PreferredMode();
360 } catch (const DBus::Error &e) {
361 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
362 return 0; // Make the compiler happy.
363 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400364}
Gary Morain610977f2012-05-04 16:03:52 -0700365const std::vector<uint32_t> ModemProxy::SupportedBands() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700366 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700367 try {
368 return proxy_.SupportedBands();
369 } catch (const DBus::Error &e) {
370 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
371 return std::vector<uint32_t>(); // Make the compiler happy.
372 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400373}
Gary Morain610977f2012-05-04 16:03:52 -0700374const std::vector<uint32_t> ModemProxy::Bands() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700375 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700376 try {
377 return proxy_.Bands();
378 } catch (const DBus::Error &e) {
379 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
380 return std::vector<uint32_t>(); // Make the compiler happy.
381 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400382}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500383
Eric Shienbrood9a245532012-03-07 14:20:39 -0500384ModemProxy::Proxy::Proxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500385 const std::string &path,
386 const std::string &service)
Eric Shienbrood9a245532012-03-07 14:20:39 -0500387 : DBus::ObjectProxy(*connection, path, service.c_str()) {}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500388
389ModemProxy::Proxy::~Proxy() {}
390
Eric Shienbrood9a245532012-03-07 14:20:39 -0500391void ModemProxy::Proxy::set_state_changed_callback(
392 const ModemStateChangedSignalCallback &callback) {
393 state_changed_callback_ = callback;
394}
395
Jason Glasgowee1081c2012-03-06 15:14:53 -0500396// Signal callbacks inherited from Proxy
Nathan Williamsa31e79c2012-03-30 15:07:00 -0400397void ModemProxy::Proxy::StateChanged(const int32_t &old,
398 const int32_t &_new,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500399 const uint32_t &reason) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700400 SLOG(DBus, 2) << __func__;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400401 if (!state_changed_callback_.is_null())
402 state_changed_callback_.Run(old, _new, reason);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500403}
404
405// Method callbacks inherited from
406// org::freedesktop::ModemManager1::ModemProxy
407void ModemProxy::Proxy::EnableCallback(const ::DBus::Error& dberror,
408 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700409 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500410 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500411 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500412 CellularError::FromDBusError(dberror, &error);
413 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500414}
415
416void ModemProxy::Proxy::ListBearersCallback(
Gary Morain610977f2012-05-04 16:03:52 -0700417 const std::vector< ::DBus::Path> &bearers,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500418 const ::DBus::Error& dberror,
419 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700420 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500421 scoped_ptr<DBusPathsCallback> callback(
422 reinterpret_cast<DBusPathsCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500423 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500424 CellularError::FromDBusError(dberror, &error);
425 callback->Run(bearers, error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500426}
427
428void ModemProxy::Proxy::CreateBearerCallback(const ::DBus::Path &path,
429 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::DeleteBearerCallback(const ::DBus::Error& dberror,
439 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700440 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500441 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500442 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500443 CellularError::FromDBusError(dberror, &error);
444 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500445}
446
447void ModemProxy::Proxy::ResetCallback(const ::DBus::Error& dberror,
448 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700449 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500450 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500451 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500452 CellularError::FromDBusError(dberror, &error);
453 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500454}
455
456void ModemProxy::Proxy::FactoryResetCallback(const ::DBus::Error& dberror,
457 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700458 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500459 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500460 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500461 CellularError::FromDBusError(dberror, &error);
462 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500463}
464
465void ModemProxy::Proxy::SetAllowedModesCallback(
466 const ::DBus::Error& dberror,
467 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700468 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500469 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500470 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500471 CellularError::FromDBusError(dberror, &error);
472 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500473}
474
475void ModemProxy::Proxy::SetBandsCallback(const ::DBus::Error& dberror,
476 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700477 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500478 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500479 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500480 CellularError::FromDBusError(dberror, &error);
481 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500482}
483
484void ModemProxy::Proxy::CommandCallback(const std::string &response,
485 const ::DBus::Error& dberror,
486 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700487 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500488 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500489 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500490 CellularError::FromDBusError(dberror, &error);
491 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500492}
493
494} // namespace mm1
495} // namespace shill