blob: f9127fd693991e93c2cebefb3ebdf88bc062ba26 [file] [log] [blame]
Darin Petkov18fb2f72012-06-14 09:09:34 +02001// 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 Vakulenko8a532292014-06-16 17:18:44 -07008#include <string>
9
Liam McLoughlinef342b42013-09-13 21:05:36 +010010#include "shill/dbus_proxies/dbus-service.h"
Darin Petkov18fb2f72012-06-14 09:09:34 +020011#include "shill/dbus_service_proxy_interface.h"
12
13namespace shill {
14
15class DBusServiceProxy : public DBusServiceProxyInterface {
16 public:
Paul Stewarta794cd62015-06-16 13:13:10 -070017 explicit DBusServiceProxy(DBus::Connection* connection);
Ben Chan5ea763b2014-08-13 11:07:54 -070018 ~DBusServiceProxy() override;
Darin Petkov18fb2f72012-06-14 09:09:34 +020019
20 // Inherited from DBusServiceProxyInterface.
Paul Stewarta794cd62015-06-16 13:13:10 -070021 void GetNameOwner(const std::string& name,
22 Error* error,
23 const StringCallback& callback,
Yunlian Jiang6acd9662015-01-30 08:36:10 -080024 int timeout) override;
25 void set_name_owner_changed_callback(
Paul Stewarta794cd62015-06-16 13:13:10 -070026 const NameOwnerChangedCallback& callback) override;
Darin Petkov18fb2f72012-06-14 09:09:34 +020027
28 private:
29 class Proxy : public org::freedesktop::DBus_proxy,
30 public DBus::ObjectProxy {
31 public:
Paul Stewarta794cd62015-06-16 13:13:10 -070032 explicit Proxy(DBus::Connection* connection);
Ben Chan5ea763b2014-08-13 11:07:54 -070033 ~Proxy() override;
Darin Petkov18fb2f72012-06-14 09:09:34 +020034
35 void set_name_owner_changed_callback(
Paul Stewarta794cd62015-06-16 13:13:10 -070036 const NameOwnerChangedCallback& callback);
Darin Petkov18fb2f72012-06-14 09:09:34 +020037
38 private:
39 // Signal callbacks inherited from DBus_proxy.
Paul Stewarta794cd62015-06-16 13:13:10 -070040 void NameOwnerChanged(const std::string& name,
41 const std::string& old_owner,
42 const std::string& new_owner) override;
Darin Petkov18fb2f72012-06-14 09:09:34 +020043
44 // Method callbacks inherited from Device_proxy.
Paul Stewarta794cd62015-06-16 13:13:10 -070045 void GetNameOwnerCallback(const std::string& unique_name,
46 const DBus::Error& error, void* data) override;
Darin Petkov18fb2f72012-06-14 09:09:34 +020047
48 NameOwnerChangedCallback name_owner_changed_callback_;
49
50 DISALLOW_COPY_AND_ASSIGN(Proxy);
51 };
52
Paul Stewarta794cd62015-06-16 13:13:10 -070053 static void FromDBusError(const DBus::Error& dbus_error, Error* error);
Darin Petkov18fb2f72012-06-14 09:09:34 +020054
55 Proxy proxy_;
56
57 DISALLOW_COPY_AND_ASSIGN(DBusServiceProxy);
58};
59
60} // namespace shill
61
62#endif // SHILL_DBUS_SERVICE_PROXY_H_