blob: a902b16f267b87e1e5eb87a30c873a189c145f3b [file] [log] [blame]
Eric Shienbrood5de44ab2011-12-05 10:46:27 -05001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Darin Petkove604f702011-07-28 15:51:17 -07002// 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/modem_simple_proxy.h"
6
Eric Shienbrood5de44ab2011-12-05 10:46:27 -05007#include "shill/cellular_error.h"
8#include "shill/error.h"
9
Darin Petkove604f702011-07-28 15:51:17 -070010using std::string;
11
12namespace shill {
13
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050014ModemSimpleProxy::ModemSimpleProxy(ModemSimpleProxyDelegate *delegate,
15 DBus::Connection *connection,
Darin Petkove604f702011-07-28 15:51:17 -070016 const string &path,
17 const string &service)
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050018 : proxy_(delegate, connection, path, service) {}
Darin Petkove604f702011-07-28 15:51:17 -070019
20ModemSimpleProxy::~ModemSimpleProxy() {}
21
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050022void ModemSimpleProxy::GetModemStatus(AsyncCallHandler *call_handler,
23 int timeout) {
24 proxy_.GetStatus(call_handler, timeout);
Darin Petkove604f702011-07-28 15:51:17 -070025}
26
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050027void ModemSimpleProxy::Connect(const DBusPropertiesMap &properties,
28 AsyncCallHandler *call_handler, int timeout) {
29 proxy_.Connect(properties, call_handler, timeout);
Darin Petkovc5f56562011-08-06 16:40:05 -070030}
31
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050032ModemSimpleProxy::Proxy::Proxy(ModemSimpleProxyDelegate *delegate,
33 DBus::Connection *connection,
Darin Petkove604f702011-07-28 15:51:17 -070034 const string &path,
35 const string &service)
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050036 : DBus::ObjectProxy(*connection, path, service.c_str()),
37 delegate_(delegate) {}
Darin Petkove604f702011-07-28 15:51:17 -070038
39ModemSimpleProxy::Proxy::~Proxy() {}
40
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050041void ModemSimpleProxy::Proxy::GetStatusCallback(const DBusPropertiesMap &props,
42 const DBus::Error &dberror,
43 void *data) {
44 AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
45 Error error;
46 CellularError::FromDBusError(dberror, &error);
47 delegate_->OnGetModemStatusCallback(props, error, call_handler);
48}
49
50void ModemSimpleProxy::Proxy::ConnectCallback(const DBus::Error &dberror,
51 void *data) {
52 AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
53 Error error;
54 CellularError::FromDBusError(dberror, &error);
55 delegate_->OnConnectCallback(error, call_handler);
56}
57
Darin Petkove604f702011-07-28 15:51:17 -070058} // namespace shill