blob: 17551473bc487a18b22b7956eed8fba270205a9f [file] [log] [blame]
Arman Uguray6e5639f2012-11-15 20:30:19 -08001// 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_bearer_proxy.h"
6
7#include "shill/cellular_error.h"
mukesh agrawal0e9e9d12014-04-18 16:09:58 -07008#include "shill/dbus_async_call_helper.h"
Arman Uguray6e5639f2012-11-15 20:30:19 -08009#include "shill/logging.h"
10
11using std::string;
12
13namespace shill {
14namespace mm1 {
15
16BearerProxy::BearerProxy(DBus::Connection *connection,
17 const std::string &path,
18 const std::string &service)
19 : proxy_(connection, path, service) {}
20
21BearerProxy::~BearerProxy() {}
22
23
24// Inherited methods from BearerProxyInterface
25void BearerProxy::Connect(Error *error,
26 const ResultCallback &callback,
27 int timeout) {
mukesh agrawal0e9e9d12014-04-18 16:09:58 -070028 BeginAsyncDBusCall(__func__, proxy_, &Proxy::ConnectAsync, callback,
29 error, &CellularError::FromMM1DBusError, timeout);
Arman Uguray6e5639f2012-11-15 20:30:19 -080030}
31
32void BearerProxy::Disconnect(Error *error,
33 const ResultCallback &callback,
34 int timeout) {
mukesh agrawal0e9e9d12014-04-18 16:09:58 -070035 BeginAsyncDBusCall(__func__, proxy_, &Proxy::DisconnectAsync, callback,
36 error, &CellularError::FromMM1DBusError, timeout);
Arman Uguray6e5639f2012-11-15 20:30:19 -080037}
38
Arman Uguray6e5639f2012-11-15 20:30:19 -080039BearerProxy::Proxy::Proxy(DBus::Connection *connection,
40 const std::string &path,
41 const std::string &service)
42 : DBus::ObjectProxy(*connection, path, service.c_str()) {}
43
44BearerProxy::Proxy::~Proxy() {}
45
46
47// Method callbacks inherited from
48// org::freedesktop::ModemManager1::BearerProxy
49void BearerProxy::Proxy::ConnectCallback(const ::DBus::Error &dberror,
50 void *data) {
51 SLOG(DBus, 2) << __func__;
52 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
53 Error error;
Arman Uguray763df862013-07-02 12:49:10 -070054 CellularError::FromMM1DBusError(dberror, &error);
Arman Uguray6e5639f2012-11-15 20:30:19 -080055 callback->Run(error);
56}
57
58void BearerProxy::Proxy::DisconnectCallback(const ::DBus::Error &dberror,
59 void *data) {
60 SLOG(DBus, 2) << __func__;
61 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
62 Error error;
Arman Uguray763df862013-07-02 12:49:10 -070063 CellularError::FromMM1DBusError(dberror, &error);
Arman Uguray6e5639f2012-11-15 20:30:19 -080064 callback->Run(error);
65}
66
67} // namespace mm1
68} // namespace shill