blob: d3046cd9ad48e013fa64544835312f00c635db2a [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_modemcdma_proxy.h"
6
7#include <base/logging.h>
8
9#include "cellular_error.h"
10
11using std::string;
12
13namespace shill {
14namespace mm1 {
15
Eric Shienbrood9a245532012-03-07 14:20:39 -050016ModemModemCdmaProxy::ModemModemCdmaProxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -050017 const string &path,
18 const string &service)
Eric Shienbrood9a245532012-03-07 14:20:39 -050019 : proxy_(connection, path, service) {}
Jason Glasgowee1081c2012-03-06 15:14:53 -050020
21ModemModemCdmaProxy::~ModemModemCdmaProxy() {}
22
23void ModemModemCdmaProxy::Activate(const std::string &carrier,
Eric Shienbrood9a245532012-03-07 14:20:39 -050024 Error *error,
25 const ResultCallback &callback,
26 int timeout) {
27 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
28 try {
29 proxy_.Activate(carrier, cb.get(), timeout);
30 cb.release();
31 } catch (DBus::Error e) {
32 if (error)
33 CellularError::FromDBusError(e, error);
34 }
Jason Glasgowee1081c2012-03-06 15:14:53 -050035}
36
37void ModemModemCdmaProxy::ActivateManual(
38 const DBusPropertiesMap &properties,
Eric Shienbrood9a245532012-03-07 14:20:39 -050039 Error *error,
40 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050041 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050042 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
43 try {
44 proxy_.ActivateManual(properties, cb.get(), timeout);
45 cb.release();
46 } catch (DBus::Error e) {
47 if (error)
48 CellularError::FromDBusError(e, error);
49 }
50}
51
52void ModemModemCdmaProxy::set_activation_state_callback(
53 const ActivationStateSignalCallback &callback) {
54 proxy_.set_activation_state_callback(callback);
Jason Glasgowee1081c2012-03-06 15:14:53 -050055}
56
57// Inherited properties from ModemModemCdmaProxyInterface.
58std::string ModemModemCdmaProxy::Meid() {
59 return proxy_.Meid();
60};
61std::string ModemModemCdmaProxy::Esn() {
62 return proxy_.Esn();
63};
64uint32_t ModemModemCdmaProxy::Sid() {
65 return proxy_.Sid();
66};
67uint32_t ModemModemCdmaProxy::Nid() {
68 return proxy_.Nid();
69};
70uint32_t ModemModemCdmaProxy::Cdma1xRegistrationState() {
71 return proxy_.Cdma1xRegistrationState();
72};
73uint32_t ModemModemCdmaProxy::EvdoRegistrationState() {
74 return proxy_.EvdoRegistrationState();
75};
76
77// ModemModemCdmaProxy::Proxy
Eric Shienbrood9a245532012-03-07 14:20:39 -050078ModemModemCdmaProxy::Proxy::Proxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -050079 const std::string &path,
80 const std::string &service)
Eric Shienbrood9a245532012-03-07 14:20:39 -050081 : DBus::ObjectProxy(*connection, path, service.c_str()) {}
Jason Glasgowee1081c2012-03-06 15:14:53 -050082
83ModemModemCdmaProxy::Proxy::~Proxy() {}
84
Eric Shienbrood9a245532012-03-07 14:20:39 -050085void ModemModemCdmaProxy::Proxy::set_activation_state_callback(
86 const ActivationStateSignalCallback &callback) {
87 activation_state_callback_ = callback;
88}
89
Jason Glasgowee1081c2012-03-06 15:14:53 -050090// Signal callbacks inherited from Proxy
91void ModemModemCdmaProxy::Proxy::ActivationStateChanged(
92 const uint32_t &activation_state,
93 const uint32_t &activation_error,
94 const DBusPropertiesMap &status_changes) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050095 activation_state_callback_.Run(activation_state,
96 activation_error,
97 status_changes);
Jason Glasgowee1081c2012-03-06 15:14:53 -050098}
99
100// Method callbacks inherited from
101// org::freedesktop::ModemManager1::Modem::ModemModemCdmaProxy
102void ModemModemCdmaProxy::Proxy::ActivateCallback(const ::DBus::Error& dberror,
103 void *data) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500104 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500105 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500106 CellularError::FromDBusError(dberror, &error);
107 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500108}
109
110void ModemModemCdmaProxy::Proxy::ActivateManualCallback(
111 const ::DBus::Error& dberror,
112 void *data) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500113 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500114 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500115 CellularError::FromDBusError(dberror, &error);
116 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500117}
118
119} // namespace mm1
120} // namespace shill