blob: 30f4979cd902ac33635e537337802d25be0fe9cf [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
mukesh agrawal06175d72012-04-23 16:46:01 -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 -050017ModemModemCdmaProxy::ModemModemCdmaProxy(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
22ModemModemCdmaProxy::~ModemModemCdmaProxy() {}
23
24void ModemModemCdmaProxy::Activate(const std::string &carrier,
Eric Shienbrood9a245532012-03-07 14:20:39 -050025 Error *error,
26 const ResultCallback &callback,
27 int timeout) {
28 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
29 try {
mukesh agrawal06175d72012-04-23 16:46:01 -070030 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -050031 proxy_.Activate(carrier, cb.get(), timeout);
32 cb.release();
33 } catch (DBus::Error e) {
34 if (error)
35 CellularError::FromDBusError(e, error);
36 }
Jason Glasgowee1081c2012-03-06 15:14:53 -050037}
38
39void ModemModemCdmaProxy::ActivateManual(
40 const DBusPropertiesMap &properties,
Eric Shienbrood9a245532012-03-07 14:20:39 -050041 Error *error,
42 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050043 int timeout) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050044 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
45 try {
mukesh agrawal06175d72012-04-23 16:46:01 -070046 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -050047 proxy_.ActivateManual(properties, cb.get(), timeout);
48 cb.release();
49 } catch (DBus::Error e) {
50 if (error)
51 CellularError::FromDBusError(e, error);
52 }
53}
54
55void ModemModemCdmaProxy::set_activation_state_callback(
56 const ActivationStateSignalCallback &callback) {
57 proxy_.set_activation_state_callback(callback);
Jason Glasgowee1081c2012-03-06 15:14:53 -050058}
59
60// Inherited properties from ModemModemCdmaProxyInterface.
61std::string ModemModemCdmaProxy::Meid() {
mukesh agrawal06175d72012-04-23 16:46:01 -070062 SLOG(DBus, 2) << __func__;
Jason Glasgowee1081c2012-03-06 15:14:53 -050063 return proxy_.Meid();
64};
65std::string ModemModemCdmaProxy::Esn() {
mukesh agrawal06175d72012-04-23 16:46:01 -070066 SLOG(DBus, 2) << __func__;
Jason Glasgowee1081c2012-03-06 15:14:53 -050067 return proxy_.Esn();
68};
69uint32_t ModemModemCdmaProxy::Sid() {
mukesh agrawal06175d72012-04-23 16:46:01 -070070 SLOG(DBus, 2) << __func__;
Jason Glasgowee1081c2012-03-06 15:14:53 -050071 return proxy_.Sid();
72};
73uint32_t ModemModemCdmaProxy::Nid() {
mukesh agrawal06175d72012-04-23 16:46:01 -070074 SLOG(DBus, 2) << __func__;
Jason Glasgowee1081c2012-03-06 15:14:53 -050075 return proxy_.Nid();
76};
77uint32_t ModemModemCdmaProxy::Cdma1xRegistrationState() {
mukesh agrawal06175d72012-04-23 16:46:01 -070078 SLOG(DBus, 2) << __func__;
Jason Glasgowee1081c2012-03-06 15:14:53 -050079 return proxy_.Cdma1xRegistrationState();
80};
81uint32_t ModemModemCdmaProxy::EvdoRegistrationState() {
mukesh agrawal06175d72012-04-23 16:46:01 -070082 SLOG(DBus, 2) << __func__;
Jason Glasgowee1081c2012-03-06 15:14:53 -050083 return proxy_.EvdoRegistrationState();
84};
85
86// ModemModemCdmaProxy::Proxy
Eric Shienbrood9a245532012-03-07 14:20:39 -050087ModemModemCdmaProxy::Proxy::Proxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -050088 const std::string &path,
89 const std::string &service)
Eric Shienbrood9a245532012-03-07 14:20:39 -050090 : DBus::ObjectProxy(*connection, path, service.c_str()) {}
Jason Glasgowee1081c2012-03-06 15:14:53 -050091
92ModemModemCdmaProxy::Proxy::~Proxy() {}
93
Eric Shienbrood9a245532012-03-07 14:20:39 -050094void ModemModemCdmaProxy::Proxy::set_activation_state_callback(
95 const ActivationStateSignalCallback &callback) {
96 activation_state_callback_ = callback;
97}
98
Jason Glasgowee1081c2012-03-06 15:14:53 -050099// Signal callbacks inherited from Proxy
100void ModemModemCdmaProxy::Proxy::ActivationStateChanged(
101 const uint32_t &activation_state,
102 const uint32_t &activation_error,
103 const DBusPropertiesMap &status_changes) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700104 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500105 activation_state_callback_.Run(activation_state,
106 activation_error,
107 status_changes);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500108}
109
110// Method callbacks inherited from
111// org::freedesktop::ModemManager1::Modem::ModemModemCdmaProxy
112void ModemModemCdmaProxy::Proxy::ActivateCallback(const ::DBus::Error& dberror,
113 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700114 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500115 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500116 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500117 CellularError::FromDBusError(dberror, &error);
118 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500119}
120
121void ModemModemCdmaProxy::Proxy::ActivateManualCallback(
122 const ::DBus::Error& dberror,
123 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700124 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500125 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -0500126 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500127 CellularError::FromDBusError(dberror, &error);
128 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500129}
130
131} // namespace mm1
132} // namespace shill