Darin Petkov | 18fb2f7 | 2012-06-14 09:09:34 +0200 | [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 | |
| 5 | #ifndef SHILL_DBUS_SERVICE_PROXY_H_ |
| 6 | #define SHILL_DBUS_SERVICE_PROXY_H_ |
| 7 | |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 8 | #include <string> |
| 9 | |
Liam McLoughlin | ef342b4 | 2013-09-13 21:05:36 +0100 | [diff] [blame] | 10 | #include "shill/dbus_proxies/dbus-service.h" |
Darin Petkov | 18fb2f7 | 2012-06-14 09:09:34 +0200 | [diff] [blame] | 11 | #include "shill/dbus_service_proxy_interface.h" |
| 12 | |
| 13 | namespace shill { |
| 14 | |
| 15 | class DBusServiceProxy : public DBusServiceProxyInterface { |
| 16 | public: |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 17 | explicit DBusServiceProxy(DBus::Connection* connection); |
Ben Chan | 5ea763b | 2014-08-13 11:07:54 -0700 | [diff] [blame] | 18 | ~DBusServiceProxy() override; |
Darin Petkov | 18fb2f7 | 2012-06-14 09:09:34 +0200 | [diff] [blame] | 19 | |
| 20 | // Inherited from DBusServiceProxyInterface. |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 21 | void GetNameOwner(const std::string& name, |
| 22 | Error* error, |
| 23 | const StringCallback& callback, |
Yunlian Jiang | 6acd966 | 2015-01-30 08:36:10 -0800 | [diff] [blame] | 24 | int timeout) override; |
| 25 | void set_name_owner_changed_callback( |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 26 | const NameOwnerChangedCallback& callback) override; |
Darin Petkov | 18fb2f7 | 2012-06-14 09:09:34 +0200 | [diff] [blame] | 27 | |
| 28 | private: |
| 29 | class Proxy : public org::freedesktop::DBus_proxy, |
| 30 | public DBus::ObjectProxy { |
| 31 | public: |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 32 | explicit Proxy(DBus::Connection* connection); |
Ben Chan | 5ea763b | 2014-08-13 11:07:54 -0700 | [diff] [blame] | 33 | ~Proxy() override; |
Darin Petkov | 18fb2f7 | 2012-06-14 09:09:34 +0200 | [diff] [blame] | 34 | |
| 35 | void set_name_owner_changed_callback( |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 36 | const NameOwnerChangedCallback& callback); |
Darin Petkov | 18fb2f7 | 2012-06-14 09:09:34 +0200 | [diff] [blame] | 37 | |
| 38 | private: |
| 39 | // Signal callbacks inherited from DBus_proxy. |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 40 | void NameOwnerChanged(const std::string& name, |
| 41 | const std::string& old_owner, |
| 42 | const std::string& new_owner) override; |
Darin Petkov | 18fb2f7 | 2012-06-14 09:09:34 +0200 | [diff] [blame] | 43 | |
| 44 | // Method callbacks inherited from Device_proxy. |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 45 | void GetNameOwnerCallback(const std::string& unique_name, |
| 46 | const DBus::Error& error, void* data) override; |
Darin Petkov | 18fb2f7 | 2012-06-14 09:09:34 +0200 | [diff] [blame] | 47 | |
| 48 | NameOwnerChangedCallback name_owner_changed_callback_; |
| 49 | |
| 50 | DISALLOW_COPY_AND_ASSIGN(Proxy); |
| 51 | }; |
| 52 | |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 53 | static void FromDBusError(const DBus::Error& dbus_error, Error* error); |
Darin Petkov | 18fb2f7 | 2012-06-14 09:09:34 +0200 | [diff] [blame] | 54 | |
| 55 | Proxy proxy_; |
| 56 | |
| 57 | DISALLOW_COPY_AND_ASSIGN(DBusServiceProxy); |
| 58 | }; |
| 59 | |
| 60 | } // namespace shill |
| 61 | |
| 62 | #endif // SHILL_DBUS_SERVICE_PROXY_H_ |