blob: edd7649115a26bcba52f3e59f4371fa53fe876cc [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
Alex Vakulenko8a532292014-06-16 17:18:44 -07005#include "shill/mm1_modem_location_proxy.h"
Arman Uguray2c39fab2012-12-12 16:56:34 -08006
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) {
mukesh agrawal0e9e9d12014-04-18 16:09:58 -070028 BeginAsyncDBusCall(__func__, proxy_, &Proxy::SetupAsync, callback,
29 error, &CellularError::FromMM1DBusError, timeout,
30 sources, signal_location);
Arman Uguray2c39fab2012-12-12 16:56:34 -080031}
32
33void ModemLocationProxy::GetLocation(Error *error,
34 const DBusEnumValueMapCallback &callback,
35 int timeout) {
mukesh agrawal0e9e9d12014-04-18 16:09:58 -070036 BeginAsyncDBusCall(__func__, proxy_, &Proxy::GetLocationAsync, callback,
37 error, &CellularError::FromMM1DBusError, timeout);
Arman Uguray2c39fab2012-12-12 16:56:34 -080038}
39
Arman Uguray2c39fab2012-12-12 16:56:34 -080040ModemLocationProxy::Proxy::Proxy(DBus::Connection *connection,
41 const string &path,
42 const string &service)
43 : DBus::ObjectProxy(*connection, path, service.c_str()) {}
44
45ModemLocationProxy::Proxy::~Proxy() {}
46
47// Method callbacks inherited from
48// org::freedesktop::ModemManager1::Modem:LocationProxy
49void ModemLocationProxy::Proxy::SetupCallback(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 Uguray2c39fab2012-12-12 16:56:34 -080055 callback->Run(error);
56}
57
58void ModemLocationProxy::Proxy::GetLocationCallback(
59 const DBusEnumValueMap &location,
60 const ::DBus::Error &dberror,
61 void *data) {
62 SLOG(DBus, 2) << __func__;
63 scoped_ptr<DBusEnumValueMapCallback> callback(
64 reinterpret_cast<DBusEnumValueMapCallback *>(data));
65 Error error;
Arman Uguray763df862013-07-02 12:49:10 -070066 CellularError::FromMM1DBusError(dberror, &error);
Arman Uguray2c39fab2012-12-12 16:56:34 -080067 callback->Run(location, error);
68}
69
70} // namespace mm1
71} // namespace shill