mukesh agrawal | 8abd2f6 | 2012-01-30 14:56:14 -0800 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 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_IPCONFIG_DBUS_ADAPTOR_H_ |
| 6 | #define SHILL_IPCONFIG_DBUS_ADAPTOR_H_ |
| 7 | |
| 8 | #include <map> |
| 9 | #include <string> |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 10 | #include <vector> |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 11 | |
Ben Chan | cc67c52 | 2014-09-03 07:19:18 -0700 | [diff] [blame] | 12 | #include <base/macros.h> |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 13 | #include <dbus-c++/dbus.h> |
| 14 | |
| 15 | #include "shill/adaptor_interfaces.h" |
| 16 | #include "shill/dbus_adaptor.h" |
Liam McLoughlin | ef342b4 | 2013-09-13 21:05:36 +0100 | [diff] [blame] | 17 | #include "shill/dbus_adaptors/org.chromium.flimflam.IPConfig.h" |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 18 | |
| 19 | namespace shill { |
| 20 | |
| 21 | class IPConfig; |
| 22 | |
| 23 | // Subclass of DBusAdaptor for IPConfig objects |
| 24 | // There is a 1:1 mapping between IPConfig and IPConfigDBusAdaptor |
| 25 | // instances. Furthermore, the IPConfig owns the IPConfigDBusAdaptor |
| 26 | // and manages its lifetime, so we're OK with IPConfigDBusAdaptor |
| 27 | // having a bare pointer to its owner ipconfig. |
| 28 | class IPConfigDBusAdaptor : public org::chromium::flimflam::IPConfig_adaptor, |
| 29 | public DBusAdaptor, |
| 30 | public IPConfigAdaptorInterface { |
| 31 | public: |
| 32 | static const char kInterfaceName[]; |
| 33 | static const char kPath[]; |
| 34 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 35 | IPConfigDBusAdaptor(DBus::Connection* conn, IPConfig* ipconfig); |
Ben Chan | 5ea763b | 2014-08-13 11:07:54 -0700 | [diff] [blame] | 36 | ~IPConfigDBusAdaptor() override; |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 37 | |
| 38 | // Implementation of IPConfigAdaptorInterface. |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 39 | const std::string& GetRpcIdentifier() override { return path(); } |
| 40 | void EmitBoolChanged(const std::string& name, bool value) override; |
| 41 | void EmitUintChanged(const std::string& name, uint32_t value) override; |
| 42 | void EmitIntChanged(const std::string& name, int value) override; |
| 43 | void EmitStringChanged(const std::string& name, |
| 44 | const std::string& value) override; |
| 45 | void EmitStringsChanged(const std::string& name, |
| 46 | const std::vector<std::string>& value) override; |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 47 | |
| 48 | // Implementation of IPConfig_adaptor |
Yunlian Jiang | 6acd966 | 2015-01-30 08:36:10 -0800 | [diff] [blame] | 49 | std::map<std::string, DBus::Variant> GetProperties( |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 50 | DBus::Error& error) override; // NOLINT |
| 51 | void SetProperty(const std::string& name, |
| 52 | const DBus::Variant& value, |
| 53 | DBus::Error& error) override; // NOLINT |
| 54 | void ClearProperty(const std::string& name, |
| 55 | DBus::Error& error) override; // NOLINT |
| 56 | void Remove(DBus::Error& error) override; // NOLINT |
| 57 | void Refresh(DBus::Error& error) override; // NOLINT |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 58 | |
| 59 | private: |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 60 | IPConfig* ipconfig_; |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 61 | DISALLOW_COPY_AND_ASSIGN(IPConfigDBusAdaptor); |
| 62 | }; |
| 63 | |
| 64 | } // namespace shill |
Ben Chan | c45688b | 2014-07-02 23:50:45 -0700 | [diff] [blame] | 65 | |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 66 | #endif // SHILL_IPCONFIG_DBUS_ADAPTOR_H_ |