blob: ddfa3d3a007b7e0f364a59df6c2c1f8ae2b7c1e4 [file] [log] [blame]
Arman Uguray2c39fab2012-12-12 16:56:34 -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 "mm1_modem_location_proxy.h"
6
7#include "shill/cellular_error.h"
8#include "shill/logging.h"
9
10using std::string;
11
12namespace shill {
13namespace mm1 {
14
15ModemLocationProxy::ModemLocationProxy(DBus::Connection *connection,
16 const string &path,
17 const string &service)
18 : proxy_(connection, path, service) {}
19
20ModemLocationProxy::~ModemLocationProxy() {}
21
22void ModemLocationProxy::Setup(uint32_t sources,
23 bool signal_location,
24 Error *error,
25 const ResultCallback &callback,
26 int timeout) {
27 SLOG(Modem, 2) << __func__;
28 scoped_ptr<ResultCallback> cb(new ResultCallback(callback));
29 try {
30 SLOG(DBus, 2) << __func__;
31 proxy_.Setup(sources, signal_location, cb.get(), timeout);
32 cb.release();
33 } catch (const DBus::Error &e) {
34 if (error)
Arman Uguray763df862013-07-02 12:49:10 -070035 CellularError::FromMM1DBusError(e, error);
Arman Uguray2c39fab2012-12-12 16:56:34 -080036 }
37}
38
39void ModemLocationProxy::GetLocation(Error *error,
40 const DBusEnumValueMapCallback &callback,
41 int timeout) {
42 SLOG(Modem, 2) << __func__;
43 scoped_ptr<DBusEnumValueMapCallback> cb(
44 new DBusEnumValueMapCallback(callback));
45 try {
46 SLOG(DBus, 2) << __func__;
47 proxy_.GetLocation(cb.get(), timeout);
48 cb.release();
49 } catch (const DBus::Error &e) {
50 if (error)
Arman Uguray763df862013-07-02 12:49:10 -070051 CellularError::FromMM1DBusError(e, error);
Arman Uguray2c39fab2012-12-12 16:56:34 -080052 }
53}
54
Arman Uguray2c39fab2012-12-12 16:56:34 -080055ModemLocationProxy::Proxy::Proxy(DBus::Connection *connection,
56 const string &path,
57 const string &service)
58 : DBus::ObjectProxy(*connection, path, service.c_str()) {}
59
60ModemLocationProxy::Proxy::~Proxy() {}
61
62// Method callbacks inherited from
63// org::freedesktop::ModemManager1::Modem:LocationProxy
64void ModemLocationProxy::Proxy::SetupCallback(const ::DBus::Error &dberror,
65 void *data) {
66 SLOG(DBus, 2) << __func__;
67 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
68 Error error;
Arman Uguray763df862013-07-02 12:49:10 -070069 CellularError::FromMM1DBusError(dberror, &error);
Arman Uguray2c39fab2012-12-12 16:56:34 -080070 callback->Run(error);
71}
72
73void ModemLocationProxy::Proxy::GetLocationCallback(
74 const DBusEnumValueMap &location,
75 const ::DBus::Error &dberror,
76 void *data) {
77 SLOG(DBus, 2) << __func__;
78 scoped_ptr<DBusEnumValueMapCallback> callback(
79 reinterpret_cast<DBusEnumValueMapCallback *>(data));
80 Error error;
Arman Uguray763df862013-07-02 12:49:10 -070081 CellularError::FromMM1DBusError(dberror, &error);
Arman Uguray2c39fab2012-12-12 16:56:34 -080082 callback->Run(location, error);
83}
84
85} // namespace mm1
86} // namespace shill