blob: 564323712cf83923eb2dc8cf23d2e399edabc659 [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_simple_proxy.h"
6
mukesh agrawal06175d72012-04-23 16:46:01 -07007#include "shill/cellular_error.h"
mukesh agrawal0e9e9d12014-04-18 16:09:58 -07008#include "shill/dbus_async_call_helper.h"
Christopher Wileyb691efd2012-08-09 13:51:51 -07009#include "shill/logging.h"
Jason Glasgowee1081c2012-03-06 15:14:53 -050010
11using std::string;
12
13namespace shill {
14namespace mm1 {
15
Eric Shienbrood9a245532012-03-07 14:20:39 -050016ModemSimpleProxy::ModemSimpleProxy(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
21ModemSimpleProxy::~ModemSimpleProxy() {}
22
23void ModemSimpleProxy::Connect(
24 const DBusPropertiesMap &properties,
Eric Shienbrood9a245532012-03-07 14:20:39 -050025 Error *error,
26 const DBusPathCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050027 int timeout) {
mukesh agrawal0e9e9d12014-04-18 16:09:58 -070028 BeginAsyncDBusCall(__func__, proxy_, &Proxy::ConnectAsync, callback,
29 error, &CellularError::FromMM1DBusError, timeout,
30 properties);
Jason Glasgowee1081c2012-03-06 15:14:53 -050031}
32
33void ModemSimpleProxy::Disconnect(const ::DBus::Path &bearer,
Eric Shienbrood9a245532012-03-07 14:20:39 -050034 Error *error,
35 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050036 int timeout) {
mukesh agrawal0e9e9d12014-04-18 16:09:58 -070037 BeginAsyncDBusCall(__func__, proxy_, &Proxy::DisconnectAsync, callback,
38 error, &CellularError::FromMM1DBusError, timeout,
39 bearer);
Jason Glasgowee1081c2012-03-06 15:14:53 -050040}
41
Eric Shienbrood9a245532012-03-07 14:20:39 -050042void ModemSimpleProxy::GetStatus(Error *error,
43 const DBusPropertyMapCallback &callback,
44 int timeout) {
mukesh agrawal0e9e9d12014-04-18 16:09:58 -070045 BeginAsyncDBusCall(__func__, proxy_, &Proxy::GetStatusAsync, callback,
46 error, &CellularError::FromMM1DBusError, timeout);
Jason Glasgowee1081c2012-03-06 15:14:53 -050047}
48
49
50// ModemSimpleProxy::Proxy
Eric Shienbrood9a245532012-03-07 14:20:39 -050051ModemSimpleProxy::Proxy::Proxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -050052 const std::string &path,
53 const std::string &service)
Eric Shienbrood9a245532012-03-07 14:20:39 -050054 : DBus::ObjectProxy(*connection, path, service.c_str()) {}
Jason Glasgowee1081c2012-03-06 15:14:53 -050055
56ModemSimpleProxy::Proxy::~Proxy() {}
57
58// Method callbacks inherited from
59// org::freedesktop::ModemManager1::Modem::ModemSimpleProxy
60void ModemSimpleProxy::Proxy::ConnectCallback(const ::DBus::Path &bearer,
61 const ::DBus::Error &dberror,
62 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -070063 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -050064 scoped_ptr<DBusPathCallback> callback(
65 reinterpret_cast<DBusPathCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -050066 Error error;
Arman Uguray763df862013-07-02 12:49:10 -070067 CellularError::FromMM1DBusError(dberror, &error);
Eric Shienbrood9a245532012-03-07 14:20:39 -050068 callback->Run(bearer, error);
Jason Glasgowee1081c2012-03-06 15:14:53 -050069}
70
71void ModemSimpleProxy::Proxy::DisconnectCallback(const ::DBus::Error &dberror,
72 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -070073 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -050074 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -050075 Error error;
Arman Uguray763df862013-07-02 12:49:10 -070076 CellularError::FromMM1DBusError(dberror, &error);
Eric Shienbrood9a245532012-03-07 14:20:39 -050077 callback->Run(error);
Jason Glasgowee1081c2012-03-06 15:14:53 -050078}
79
80void ModemSimpleProxy::Proxy::GetStatusCallback(
81 const DBusPropertiesMap &properties,
82 const ::DBus::Error &dberror,
83 void *data) {
mukesh agrawal06175d72012-04-23 16:46:01 -070084 SLOG(DBus, 2) << __func__;
Eric Shienbrood9a245532012-03-07 14:20:39 -050085 scoped_ptr<DBusPropertyMapCallback> callback(
86 reinterpret_cast<DBusPropertyMapCallback *>(data));
Jason Glasgowee1081c2012-03-06 15:14:53 -050087 Error error;
Arman Uguray763df862013-07-02 12:49:10 -070088 CellularError::FromMM1DBusError(dberror, &error);
Eric Shienbrood9a245532012-03-07 14:20:39 -050089 callback->Run(properties, error);
Jason Glasgowee1081c2012-03-06 15:14:53 -050090}
91
92} // namespace mm1
93} // namespace shill