blob: be05d5fc53cd0f092bbc3975d2ad04ba559201a1 [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 Chanfd1144d2013-09-06 09:10:16 -07007#include <ModemManager/ModemManager.h>
8
Ben Chanfad4a0b2012-04-18 15:49:59 -07009#include "shill/cellular_error.h"
Christopher Wileyb691efd2012-08-09 13:51:51 -070010#include "shill/logging.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(
Ben Chan74924d82013-06-15 17:52:55 -070025 const ModemStateChangedSignalCallback &callback) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050026 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)
Arman Uguray763df862013-07-02 12:49:10 -070041 CellularError::FromMM1DBusError(e, error);
Eric Shienbrood9a245532012-03-07 14:20:39 -050042 }
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)
Arman Uguray763df862013-07-02 12:49:10 -070055 CellularError::FromMM1DBusError(e, error);
Eric Shienbrood9a245532012-03-07 14:20:39 -050056 }
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)
Arman Uguray763df862013-07-02 12:49:10 -070071 CellularError::FromMM1DBusError(e, error);
Eric Shienbrood9a245532012-03-07 14:20:39 -050072 }
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)
Arman Uguray763df862013-07-02 12:49:10 -070086 CellularError::FromMM1DBusError(e, error);
Eric Shienbrood9a245532012-03-07 14:20:39 -050087 }
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)
Arman Uguray763df862013-07-02 12:49:10 -0700100 CellularError::FromMM1DBusError(e, error);
Eric Shienbrood9a245532012-03-07 14:20:39 -0500101 }
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)
Arman Uguray763df862013-07-02 12:49:10 -0700115 CellularError::FromMM1DBusError(e, error);
Eric Shienbrood9a245532012-03-07 14:20:39 -0500116 }
Jason Glasgowee1081c2012-03-06 15:14:53 -0500117}
118
Ben Chan74924d82013-06-15 17:52:55 -0700119void ModemProxy::SetCurrentCapabilities(const uint32_t &capabilities,
120 Error *error,
121 const ResultCallback &callback,
122 int timeout) {
123 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
124 try {
125 SLOG(DBus, 2) << __func__;
126 proxy_.SetCurrentCapabilities(capabilities, cb.get(), timeout);
127 cb.release();
128 } catch (const DBus::Error &e) {
129 if (error)
Arman Uguray763df862013-07-02 12:49:10 -0700130 CellularError::FromMM1DBusError(e, error);
Ben Chan74924d82013-06-15 17:52:55 -0700131 }
132}
133
134void ModemProxy::SetCurrentModes(
135 const ::DBus::Struct<uint32_t, uint32_t> &modes,
136 Error *error,
137 const ResultCallback &callback,
138 int timeout) {
139 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
140 try {
141 SLOG(DBus, 2) << __func__;
142 proxy_.SetCurrentModes(modes, cb.get(), timeout);
143 cb.release();
144 } catch (const DBus::Error &e) {
145 if (error)
Arman Uguray763df862013-07-02 12:49:10 -0700146 CellularError::FromMM1DBusError(e, error);
Ben Chan74924d82013-06-15 17:52:55 -0700147 }
148}
149
150void ModemProxy::SetCurrentBands(const std::vector<uint32_t> &bands,
151 Error *error,
152 const ResultCallback &callback,
153 int timeout) {
154 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
155 try {
156 SLOG(DBus, 2) << __func__;
157 proxy_.SetCurrentBands(bands, cb.get(), timeout);
158 cb.release();
159 } catch (const DBus::Error &e) {
160 if (error)
Arman Uguray763df862013-07-02 12:49:10 -0700161 CellularError::FromMM1DBusError(e, error);
Ben Chan74924d82013-06-15 17:52:55 -0700162 }
163}
164
Jason Glasgowee1081c2012-03-06 15:14:53 -0500165void ModemProxy::Command(const std::string &cmd,
166 const uint32_t &user_timeout,
Eric Shienbrood9a245532012-03-07 14:20:39 -0500167 Error *error,
168 const StringCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500169 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500170 scoped_ptr<StringCallback> cb(new StringCallback(callback));
171 try {
mukesh agrawal06175d72012-04-23 16:46:01 -0700172 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500173 proxy_.Command(cmd, user_timeout, cb.get(), timeout);
174 cb.release();
Ben Chan80326f32012-05-04 17:51:32 -0700175 } catch (const DBus::Error &e) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500176 if (error)
Arman Uguray763df862013-07-02 12:49:10 -0700177 CellularError::FromMM1DBusError(e, error);
Eric Shienbrood9a245532012-03-07 14:20:39 -0500178 }
Jason Glasgowee1081c2012-03-06 15:14:53 -0500179}
180
Arman Ugurayee464d32013-02-13 17:14:36 -0800181void ModemProxy::SetPowerState(const uint32_t &power_state,
182 Error *error,
183 const ResultCallback &callback,
184 int timeout) {
185 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
186 try {
187 SLOG(DBus, 2) << __func__;
188 proxy_.SetPowerState(power_state, cb.get(), timeout);
189 cb.release();
190 } catch (const DBus::Error &e) {
191 if (error)
Arman Uguray763df862013-07-02 12:49:10 -0700192 CellularError::FromMM1DBusError(e, error);
Arman Ugurayee464d32013-02-13 17:14:36 -0800193 }
194}
195
Jason Glasgowee1081c2012-03-06 15:14:53 -0500196// Inherited properties from ModemProxyInterface.
197const ::DBus::Path ModemProxy::Sim() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700198 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700199 try {
200 return proxy_.Sim();
201 } catch (const DBus::Error &e) {
202 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
203 return ::DBus::Path(); // Make the compiler happy.
204 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400205}
Ben Chan74924d82013-06-15 17:52:55 -0700206
207const std::vector<uint32_t> ModemProxy::SupportedCapabilities() {
208 SLOG(DBus, 2) << __func__;
209 try {
210 return proxy_.SupportedCapabilities();
211 } catch (const DBus::Error &e) {
212 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
213 return std::vector<uint32_t>(); // Make the compiler happy.
214 }
215}
216
Jason Glasgowee1081c2012-03-06 15:14:53 -0500217uint32_t ModemProxy::CurrentCapabilities() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700218 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700219 try {
220 return proxy_.CurrentCapabilities();
221 } catch (const DBus::Error &e) {
222 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
223 return 0; // Make the compiler happy.
224 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400225}
Ben Chan74924d82013-06-15 17:52:55 -0700226
Jason Glasgowee1081c2012-03-06 15:14:53 -0500227uint32_t ModemProxy::MaxBearers() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700228 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700229 try {
230 return proxy_.MaxBearers();
231 } catch (const DBus::Error &e) {
232 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
233 return 0; // Make the compiler happy.
234 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400235}
Ben Chan74924d82013-06-15 17:52:55 -0700236
Jason Glasgowee1081c2012-03-06 15:14:53 -0500237uint32_t ModemProxy::MaxActiveBearers() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700238 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700239 try {
240 return proxy_.MaxActiveBearers();
241 } catch (const DBus::Error &e) {
242 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
243 return 0; // Make the compiler happy.
244 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400245}
Ben Chan74924d82013-06-15 17:52:55 -0700246
Jason Glasgowee1081c2012-03-06 15:14:53 -0500247const std::string ModemProxy::Manufacturer() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700248 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700249 try {
250 return proxy_.Manufacturer();
251 } catch (const DBus::Error &e) {
252 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
253 return std::string(); // Make the compiler happy.
254 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400255}
Ben Chan74924d82013-06-15 17:52:55 -0700256
Jason Glasgowee1081c2012-03-06 15:14:53 -0500257const std::string ModemProxy::Model() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700258 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700259 try {
260 return proxy_.Model();
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}
Ben Chan74924d82013-06-15 17:52:55 -0700266
Jason Glasgowee1081c2012-03-06 15:14:53 -0500267const std::string ModemProxy::Revision() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700268 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700269 try {
270 return proxy_.Revision();
271 } catch (const DBus::Error &e) {
272 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
273 return std::string(); // Make the compiler happy.
274 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400275}
Ben Chan74924d82013-06-15 17:52:55 -0700276
Jason Glasgowee1081c2012-03-06 15:14:53 -0500277const std::string ModemProxy::DeviceIdentifier() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700278 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700279 try {
280 return proxy_.DeviceIdentifier();
281 } catch (const DBus::Error &e) {
282 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
283 return std::string(); // Make the compiler happy.
284 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400285}
Ben Chan74924d82013-06-15 17:52:55 -0700286
Jason Glasgowee1081c2012-03-06 15:14:53 -0500287const std::string ModemProxy::Device() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700288 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700289 try {
290 return proxy_.Device();
291 } catch (const DBus::Error &e) {
292 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
293 return std::string(); // Make the compiler happy.
294 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400295}
Ben Chan74924d82013-06-15 17:52:55 -0700296
Ben Chan34e5d682012-08-24 19:10:49 -0700297const std::vector<std::string> ModemProxy::Drivers() {
298 SLOG(DBus, 2) << __func__;
299 try {
300 return proxy_.Drivers();
301 } catch (const DBus::Error &e) {
302 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
303 return std::vector<std::string>(); // Make the compiler happy.
304 }
305}
Ben Chan74924d82013-06-15 17:52:55 -0700306
Jason Glasgowee1081c2012-03-06 15:14:53 -0500307const std::string ModemProxy::Plugin() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700308 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700309 try {
310 return proxy_.Plugin();
311 } catch (const DBus::Error &e) {
312 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
313 return std::string(); // Make the compiler happy.
314 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400315}
Ben Chan74924d82013-06-15 17:52:55 -0700316
Jason Glasgowee1081c2012-03-06 15:14:53 -0500317const std::string ModemProxy::EquipmentIdentifier() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700318 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700319 try {
320 return proxy_.EquipmentIdentifier();
321 } catch (const DBus::Error &e) {
322 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
323 return std::string(); // Make the compiler happy.
324 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400325}
Ben Chan74924d82013-06-15 17:52:55 -0700326
Jason Glasgowee1081c2012-03-06 15:14:53 -0500327uint32_t ModemProxy::UnlockRequired() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700328 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700329 try {
330 return proxy_.UnlockRequired();
331 } catch (const DBus::Error &e) {
332 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
333 return 0; // Make the compiler happy.
334 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400335}
Ben Chan74924d82013-06-15 17:52:55 -0700336
Gary Morain610977f2012-05-04 16:03:52 -0700337const std::map<uint32_t, uint32_t> ModemProxy::UnlockRetries() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700338 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700339 try {
340 return proxy_.UnlockRetries();
341 } catch (const DBus::Error &e) {
342 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
343 return std::map<uint32_t, uint32_t>(); // Make the compiler happy.
344 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400345}
Ben Chan74924d82013-06-15 17:52:55 -0700346
Ben Chanfd1144d2013-09-06 09:10:16 -0700347uint32_t ModemProxy::State(Error *error) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700348 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700349 try {
350 return proxy_.State();
351 } catch (const DBus::Error &e) {
Ben Chanfd1144d2013-09-06 09:10:16 -0700352 if (error)
353 CellularError::FromMM1DBusError(e, error);
354 return MM_MODEM_STATE_UNKNOWN;
Gary Morain610977f2012-05-04 16:03:52 -0700355 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400356}
Ben Chan74924d82013-06-15 17:52:55 -0700357
Jason Glasgowee1081c2012-03-06 15:14:53 -0500358uint32_t ModemProxy::AccessTechnologies() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700359 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700360 try {
361 return proxy_.AccessTechnologies();
362 } catch (const DBus::Error &e) {
363 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
364 return 0; // Make the compiler happy.
365 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400366}
Ben Chan74924d82013-06-15 17:52:55 -0700367
Gary Morain610977f2012-05-04 16:03:52 -0700368const ::DBus::Struct<uint32_t, bool> ModemProxy::SignalQuality() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700369 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700370 try {
371 return proxy_.SignalQuality();
372 } catch (const DBus::Error &e) {
373 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
374 return ::DBus::Struct<uint32_t, bool>(); // Make the compiler happy.
375 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400376}
Ben Chan74924d82013-06-15 17:52:55 -0700377
Jason Glasgow90d216d2012-04-04 15:57:14 -0400378const std::vector<string> ModemProxy::OwnNumbers() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700379 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700380 try {
381 return proxy_.OwnNumbers();
382 } catch (const DBus::Error &e) {
383 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
384 return std::vector<string>(); // Make the compiler happy.
385 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400386}
Ben Chan74924d82013-06-15 17:52:55 -0700387
388const std::vector<::DBus::Struct<uint32_t, uint32_t>>
389ModemProxy::SupportedModes() {
390 SLOG(DBus, 2) << __func__;
391 try {
392 return proxy_.SupportedModes();
393 } catch (const DBus::Error &e) {
394 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
395 // Make the compiler happy.
396 return std::vector<::DBus::Struct<uint32_t, uint32_t>>();
397 }
398}
399
400const ::DBus::Struct<uint32_t, uint32_t> ModemProxy::CurrentModes() {
401 SLOG(DBus, 2) << __func__;
402 try {
403 return proxy_.CurrentModes();
404 } catch (const DBus::Error &e) {
405 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
406 return ::DBus::Struct<uint32_t, uint32_t>(); // Make the compiler happy.
407 }
408}
409
Gary Morain610977f2012-05-04 16:03:52 -0700410const std::vector<uint32_t> ModemProxy::SupportedBands() {
mukesh agrawal06175d72012-04-23 16:46:01 -0700411 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700412 try {
413 return proxy_.SupportedBands();
414 } catch (const DBus::Error &e) {
415 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
416 return std::vector<uint32_t>(); // Make the compiler happy.
417 }
Jason Glasgow90d216d2012-04-04 15:57:14 -0400418}
Ben Chan74924d82013-06-15 17:52:55 -0700419
420const std::vector<uint32_t> ModemProxy::CurrentBands() {
421 SLOG(DBus, 2) << __func__;
422 try {
423 return proxy_.CurrentBands();
424 } catch (const DBus::Error &e) {
425 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
426 return std::vector<uint32_t>(); // Make the compiler happy.
427 }
428}
429
430uint32_t ModemProxy::SupportedIpFamilies() {
431 SLOG(DBus, 2) << __func__;
432 try {
433 return proxy_.SupportedIpFamilies();
434 } catch (const DBus::Error &e) {
435 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
436 return 0; // Make the compiler happy.
437 }
438}
439
Arman Ugurayee464d32013-02-13 17:14:36 -0800440uint32_t ModemProxy::PowerState() {
441 SLOG(DBus, 2) << __func__;
442 try {
443 return proxy_.PowerState();
444 } catch (const DBus::Error &e) {
445 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
446 return 0; // Make the compiler happy.
447 }
448}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500449
Eric Shienbrood9a245532012-03-07 14:20:39 -0500450ModemProxy::Proxy::Proxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500451 const std::string &path,
452 const std::string &service)
Eric Shienbrood9a245532012-03-07 14:20:39 -0500453 : DBus::ObjectProxy(*connection, path, service.c_str()) {}
Jason Glasgowee1081c2012-03-06 15:14:53 -0500454
455ModemProxy::Proxy::~Proxy() {}
456
Eric Shienbrood9a245532012-03-07 14:20:39 -0500457void ModemProxy::Proxy::set_state_changed_callback(
458 const ModemStateChangedSignalCallback &callback) {
459 state_changed_callback_ = callback;
460}
461
Jason Glasgowee1081c2012-03-06 15:14:53 -0500462// Signal callbacks inherited from Proxy
Nathan Williamsa31e79c2012-03-30 15:07:00 -0400463void ModemProxy::Proxy::StateChanged(const int32_t &old,
464 const int32_t &_new,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500465 const uint32_t &reason) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700466 SLOG(DBus, 2) << __func__;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400467 if (!state_changed_callback_.is_null())
468 state_changed_callback_.Run(old, _new, reason);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500469}
470
471// Method callbacks inherited from
472// org::freedesktop::ModemManager1::ModemProxy
Ben Chan74924d82013-06-15 17:52:55 -0700473void ModemProxy::Proxy::EnableCallback(const ::DBus::Error &dberror,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500474 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;
Arman Uguray763df862013-07-02 12:49:10 -0700478 CellularError::FromMM1DBusError(dberror, &error);
Eric Shienbrood9a245532012-03-07 14:20:39 -0500479 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500480}
481
482void ModemProxy::Proxy::ListBearersCallback(
Gary Morain610977f2012-05-04 16:03:52 -0700483 const std::vector< ::DBus::Path> &bearers,
Ben Chan74924d82013-06-15 17:52:55 -0700484 const ::DBus::Error &dberror,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500485 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700486 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500487 scoped_ptr<DBusPathsCallback> callback(
488 reinterpret_cast<DBusPathsCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500489 Error error;
Arman Uguray763df862013-07-02 12:49:10 -0700490 CellularError::FromMM1DBusError(dberror, &error);
Eric Shienbrood9a245532012-03-07 14:20:39 -0500491 callback->Run(bearers, error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500492}
493
494void ModemProxy::Proxy::CreateBearerCallback(const ::DBus::Path &path,
Ben Chan74924d82013-06-15 17:52:55 -0700495 const ::DBus::Error &dberror,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500496 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700497 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500498 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500499 Error error;
Arman Uguray763df862013-07-02 12:49:10 -0700500 CellularError::FromMM1DBusError(dberror, &error);
Eric Shienbrood9a245532012-03-07 14:20:39 -0500501 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500502}
503
Ben Chan74924d82013-06-15 17:52:55 -0700504void ModemProxy::Proxy::DeleteBearerCallback(const ::DBus::Error &dberror,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500505 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700506 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500507 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500508 Error error;
Arman Uguray763df862013-07-02 12:49:10 -0700509 CellularError::FromMM1DBusError(dberror, &error);
Eric Shienbrood9a245532012-03-07 14:20:39 -0500510 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500511}
512
Ben Chan74924d82013-06-15 17:52:55 -0700513void ModemProxy::Proxy::ResetCallback(const ::DBus::Error &dberror,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500514 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700515 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500516 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500517 Error error;
Arman Uguray763df862013-07-02 12:49:10 -0700518 CellularError::FromMM1DBusError(dberror, &error);
Eric Shienbrood9a245532012-03-07 14:20:39 -0500519 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500520}
521
Ben Chan74924d82013-06-15 17:52:55 -0700522void ModemProxy::Proxy::FactoryResetCallback(const ::DBus::Error &dberror,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500523 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700524 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500525 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500526 Error error;
Arman Uguray763df862013-07-02 12:49:10 -0700527 CellularError::FromMM1DBusError(dberror, &error);
Eric Shienbrood9a245532012-03-07 14:20:39 -0500528 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500529}
530
Ben Chan74924d82013-06-15 17:52:55 -0700531void ModemProxy::Proxy::SetCurrentCapabilitesCallback(
532 const ::DBus::Error &dberror,
533 void *data) {
534 SLOG(DBus, 2) << __func__;
535 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
536 Error error;
Arman Uguray763df862013-07-02 12:49:10 -0700537 CellularError::FromMM1DBusError(dberror, &error);
Ben Chan74924d82013-06-15 17:52:55 -0700538 callback->Run(error);
539}
540
541void ModemProxy::Proxy::SetCurrentModesCallback(const ::DBus::Error &dberror,
542 void *data) {
543 SLOG(DBus, 2) << __func__;
544 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
545 Error error;
Arman Uguray763df862013-07-02 12:49:10 -0700546 CellularError::FromMM1DBusError(dberror, &error);
Ben Chan74924d82013-06-15 17:52:55 -0700547 callback->Run(error);
548}
549
550void ModemProxy::Proxy::SetCurrentBandsCallback(const ::DBus::Error &dberror,
551 void *data) {
552 SLOG(DBus, 2) << __func__;
553 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
554 Error error;
Arman Uguray763df862013-07-02 12:49:10 -0700555 CellularError::FromMM1DBusError(dberror, &error);
Ben Chan74924d82013-06-15 17:52:55 -0700556 callback->Run(error);
557}
558
Jason Glasgowee1081c2012-03-06 15:14:53 -0500559void ModemProxy::Proxy::CommandCallback(const std::string &response,
Ben Chan74924d82013-06-15 17:52:55 -0700560 const ::DBus::Error &dberror,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500561 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700562 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500563 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500564 Error error;
Arman Uguray763df862013-07-02 12:49:10 -0700565 CellularError::FromMM1DBusError(dberror, &error);
Eric Shienbrood9a245532012-03-07 14:20:39 -0500566 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500567}
568
Arman Ugurayee464d32013-02-13 17:14:36 -0800569void ModemProxy::Proxy::SetPowerStateCallback(const ::DBus::Error &dberror,
570 void *data) {
571 SLOG(DBus, 2) << __func__;
572 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
573 Error error;
Arman Uguray763df862013-07-02 12:49:10 -0700574 CellularError::FromMM1DBusError(dberror, &error);
Arman Ugurayee464d32013-02-13 17:14:36 -0800575 callback->Run(error);
576}
577
Jason Glasgowee1081c2012-03-06 15:14:53 -0500578} // namespace mm1
579} // namespace shill