blob: 7612d8c839c87e5bc289a32cf69423e03c7d88b7 [file] [log] [blame]
Darin Petkovc37a9c42012-09-06 15:28:22 +02001// 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/modem_gobi_proxy.h"
6
7#include <base/bind.h>
8
9#include "shill/cellular_error.h"
10#include "shill/error.h"
11#include "shill/logging.h"
12
13using base::Bind;
14using base::Callback;
15using std::string;
16
17namespace shill {
18
19ModemGobiProxy::ModemGobiProxy(DBus::Connection *connection,
20 const string &path,
21 const string &service)
22 : proxy_(connection, path, service) {}
23
24ModemGobiProxy::~ModemGobiProxy() {}
25
26void ModemGobiProxy::SetCarrier(const string &carrier,
27 Error *error,
28 const ResultCallback &callback,
29 int timeout) {
30 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
31 try {
32 SLOG(DBus, 2) << __func__;
33 proxy_.SetCarrier(carrier, cb.get(), timeout);
34 cb.release();
35 } catch (const DBus::Error &e) {
36 if (error) {
37 CellularError::FromDBusError(e, error);
38 }
39 }
40}
41
42ModemGobiProxy::Proxy::Proxy(DBus::Connection *connection,
43 const string &path,
44 const string &service)
45 : DBus::ObjectProxy(*connection, path, service.c_str()) {}
46
47ModemGobiProxy::Proxy::~Proxy() {}
48
49void ModemGobiProxy::Proxy::SetCarrierCallback(const DBus::Error &dberror,
50 void *data) {
51 SLOG(DBus, 2) << __func__;
52 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
53 Error error;
54 CellularError::FromDBusError(dberror, &error);
55 callback->Run(error);
56}
57
58} // namespace shill