blob: b3ca0c1d08bc57effa37ba18f61c336975e6a528 [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"
mukesh agrawal0e9e9d12014-04-18 16:09:58 -07008#include "shill/dbus_async_call_helper.h"
Arman Uguray2c39fab2012-12-12 16:56:34 -08009#include "shill/logging.h"
10
11using std::string;
12
13namespace shill {
14namespace mm1 {
15
16ModemLocationProxy::ModemLocationProxy(DBus::Connection *connection,
17 const string &path,
18 const string &service)
19 : proxy_(connection, path, service) {}
20
21ModemLocationProxy::~ModemLocationProxy() {}
22
23void ModemLocationProxy::Setup(uint32_t sources,
24 bool signal_location,
25 Error *error,
26 const ResultCallback &callback,
27 int timeout) {
28 SLOG(Modem, 2) << __func__;
mukesh agrawal0e9e9d12014-04-18 16:09:58 -070029 BeginAsyncDBusCall(__func__, proxy_, &Proxy::SetupAsync, callback,
30 error, &CellularError::FromMM1DBusError, timeout,
31 sources, signal_location);
Arman Uguray2c39fab2012-12-12 16:56:34 -080032}
33
34void ModemLocationProxy::GetLocation(Error *error,
35 const DBusEnumValueMapCallback &callback,
36 int timeout) {
37 SLOG(Modem, 2) << __func__;
mukesh agrawal0e9e9d12014-04-18 16:09:58 -070038 BeginAsyncDBusCall(__func__, proxy_, &Proxy::GetLocationAsync, callback,
39 error, &CellularError::FromMM1DBusError, timeout);
Arman Uguray2c39fab2012-12-12 16:56:34 -080040}
41
Arman Uguray2c39fab2012-12-12 16:56:34 -080042ModemLocationProxy::Proxy::Proxy(DBus::Connection *connection,
43 const string &path,
44 const string &service)
45 : DBus::ObjectProxy(*connection, path, service.c_str()) {}
46
47ModemLocationProxy::Proxy::~Proxy() {}
48
49// Method callbacks inherited from
50// org::freedesktop::ModemManager1::Modem:LocationProxy
51void ModemLocationProxy::Proxy::SetupCallback(const ::DBus::Error &dberror,
52 void *data) {
53 SLOG(DBus, 2) << __func__;
54 scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
55 Error error;
Arman Uguray763df862013-07-02 12:49:10 -070056 CellularError::FromMM1DBusError(dberror, &error);
Arman Uguray2c39fab2012-12-12 16:56:34 -080057 callback->Run(error);
58}
59
60void ModemLocationProxy::Proxy::GetLocationCallback(
61 const DBusEnumValueMap &location,
62 const ::DBus::Error &dberror,
63 void *data) {
64 SLOG(DBus, 2) << __func__;
65 scoped_ptr<DBusEnumValueMapCallback> callback(
66 reinterpret_cast<DBusEnumValueMapCallback *>(data));
67 Error error;
Arman Uguray763df862013-07-02 12:49:10 -070068 CellularError::FromMM1DBusError(dberror, &error);
Arman Uguray2c39fab2012-12-12 16:56:34 -080069 callback->Run(location, error);
70}
71
72} // namespace mm1
73} // namespace shill