Arman Uguray | 2c39fab | 2012-12-12 16:56:34 -0800 | [diff] [blame] | 1 | // 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 Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 5 | #include "shill/mm1_modem_location_proxy.h" |
Arman Uguray | 2c39fab | 2012-12-12 16:56:34 -0800 | [diff] [blame] | 6 | |
| 7 | #include "shill/cellular_error.h" |
mukesh agrawal | 0e9e9d1 | 2014-04-18 16:09:58 -0700 | [diff] [blame] | 8 | #include "shill/dbus_async_call_helper.h" |
Arman Uguray | 2c39fab | 2012-12-12 16:56:34 -0800 | [diff] [blame] | 9 | #include "shill/logging.h" |
| 10 | |
| 11 | using std::string; |
| 12 | |
| 13 | namespace shill { |
| 14 | namespace mm1 { |
| 15 | |
| 16 | ModemLocationProxy::ModemLocationProxy(DBus::Connection *connection, |
| 17 | const string &path, |
| 18 | const string &service) |
| 19 | : proxy_(connection, path, service) {} |
| 20 | |
| 21 | ModemLocationProxy::~ModemLocationProxy() {} |
| 22 | |
| 23 | void ModemLocationProxy::Setup(uint32_t sources, |
| 24 | bool signal_location, |
| 25 | Error *error, |
| 26 | const ResultCallback &callback, |
| 27 | int timeout) { |
mukesh agrawal | 0e9e9d1 | 2014-04-18 16:09:58 -0700 | [diff] [blame] | 28 | BeginAsyncDBusCall(__func__, proxy_, &Proxy::SetupAsync, callback, |
| 29 | error, &CellularError::FromMM1DBusError, timeout, |
| 30 | sources, signal_location); |
Arman Uguray | 2c39fab | 2012-12-12 16:56:34 -0800 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | void ModemLocationProxy::GetLocation(Error *error, |
| 34 | const DBusEnumValueMapCallback &callback, |
| 35 | int timeout) { |
mukesh agrawal | 0e9e9d1 | 2014-04-18 16:09:58 -0700 | [diff] [blame] | 36 | BeginAsyncDBusCall(__func__, proxy_, &Proxy::GetLocationAsync, callback, |
| 37 | error, &CellularError::FromMM1DBusError, timeout); |
Arman Uguray | 2c39fab | 2012-12-12 16:56:34 -0800 | [diff] [blame] | 38 | } |
| 39 | |
Arman Uguray | 2c39fab | 2012-12-12 16:56:34 -0800 | [diff] [blame] | 40 | ModemLocationProxy::Proxy::Proxy(DBus::Connection *connection, |
| 41 | const string &path, |
| 42 | const string &service) |
| 43 | : DBus::ObjectProxy(*connection, path, service.c_str()) {} |
| 44 | |
| 45 | ModemLocationProxy::Proxy::~Proxy() {} |
| 46 | |
| 47 | // Method callbacks inherited from |
| 48 | // org::freedesktop::ModemManager1::Modem:LocationProxy |
| 49 | void 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 Uguray | 763df86 | 2013-07-02 12:49:10 -0700 | [diff] [blame] | 54 | CellularError::FromMM1DBusError(dberror, &error); |
Arman Uguray | 2c39fab | 2012-12-12 16:56:34 -0800 | [diff] [blame] | 55 | callback->Run(error); |
| 56 | } |
| 57 | |
| 58 | void 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 Uguray | 763df86 | 2013-07-02 12:49:10 -0700 | [diff] [blame] | 66 | CellularError::FromMM1DBusError(dberror, &error); |
Arman Uguray | 2c39fab | 2012-12-12 16:56:34 -0800 | [diff] [blame] | 67 | callback->Run(location, error); |
| 68 | } |
| 69 | |
| 70 | } // namespace mm1 |
| 71 | } // namespace shill |