Darin Petkov | 63138a9 | 2012-02-06 14:09:15 +0100 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -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_DEVICE_DBUS_ADAPTOR_H_ |
| 6 | #define SHILL_DEVICE_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 | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 11 | |
Ben Chan | cc67c52 | 2014-09-03 07:19:18 -0700 | [diff] [blame] | 12 | #include <base/macros.h> |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 13 | |
| 14 | #include "shill/adaptor_interfaces.h" |
| 15 | #include "shill/dbus_adaptor.h" |
Liam McLoughlin | ef342b4 | 2013-09-13 21:05:36 +0100 | [diff] [blame] | 16 | #include "shill/dbus_adaptors/org.chromium.flimflam.Device.h" |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 17 | |
| 18 | namespace shill { |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 19 | |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 20 | class Device; |
| 21 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 22 | // Subclass of DBusAdaptor for Device objects |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 23 | // There is a 1:1 mapping between Device and DeviceDBusAdaptor instances. |
| 24 | // Furthermore, the Device owns the DeviceDBusAdaptor and manages its lifetime, |
| 25 | // so we're OK with DeviceDBusAdaptor having a bare pointer to its owner device. |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 26 | class DeviceDBusAdaptor : public org::chromium::flimflam::Device_adaptor, |
| 27 | public DBusAdaptor, |
| 28 | public DeviceAdaptorInterface { |
| 29 | public: |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 30 | static const char kPath[]; |
| 31 | |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 32 | DeviceDBusAdaptor(DBus::Connection* conn, Device* device); |
Ben Chan | 5ea763b | 2014-08-13 11:07:54 -0700 | [diff] [blame] | 33 | ~DeviceDBusAdaptor() override; |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 34 | |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 35 | // Implementation of DeviceAdaptorInterface. |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 36 | const std::string& GetRpcIdentifier() override; |
| 37 | const std::string& GetRpcConnectionIdentifier() override; |
| 38 | void EmitBoolChanged(const std::string& name, bool value) override; |
| 39 | void EmitUintChanged(const std::string& name, uint32_t value) override; |
| 40 | void EmitUint16Changed(const std::string& name, uint16_t value) override; |
| 41 | void EmitIntChanged(const std::string& name, int value) override; |
| 42 | void EmitStringChanged(const std::string& name, |
| 43 | const std::string& value) override; |
| 44 | void EmitStringmapChanged(const std::string& name, |
| 45 | const Stringmap& value) override; |
| 46 | void EmitStringmapsChanged(const std::string& name, |
| 47 | const Stringmaps& value) override; |
| 48 | void EmitStringsChanged(const std::string& name, |
| 49 | const Strings& value) override; |
| 50 | void EmitKeyValueStoreChanged(const std::string& name, |
| 51 | const KeyValueStore& value) override; |
| 52 | void EmitRpcIdentifierChanged(const std::string& name, |
| 53 | const std::string& value) override; |
Yunlian Jiang | 6acd966 | 2015-01-30 08:36:10 -0800 | [diff] [blame] | 54 | void EmitRpcIdentifierArrayChanged( |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 55 | const std::string& name, const std::vector<std::string>& value) override; |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 56 | |
| 57 | // Implementation of Device_adaptor. |
Yunlian Jiang | 6acd966 | 2015-01-30 08:36:10 -0800 | [diff] [blame] | 58 | std::map<std::string, DBus::Variant> GetProperties( |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 59 | DBus::Error& error) override; // NOLINT |
| 60 | void SetProperty(const std::string& name, |
| 61 | const DBus::Variant& value, |
| 62 | DBus::Error& error) override; // NOLINT |
| 63 | void ClearProperty(const std::string& name, |
| 64 | DBus::Error& error) override; // NOLINT |
| 65 | void Enable(DBus::Error& error) override; // NOLINT |
| 66 | void Disable(DBus::Error& error) override; // NOLINT |
| 67 | void ProposeScan(DBus::Error& error) override; // NOLINT |
| 68 | DBus::Path AddIPConfig(const std::string& method, |
| 69 | DBus::Error& error) override; // NOLINT |
| 70 | void Register(const std::string& network_id, |
| 71 | DBus::Error& error) override; // NOLINT |
| 72 | void RequirePin(const std::string& pin, |
| 73 | const bool& require, |
| 74 | DBus::Error& error) override; // NOLINT |
| 75 | void EnterPin(const std::string& pin, DBus::Error& error) override; // NOLINT |
| 76 | void UnblockPin(const std::string& unblock_code, |
| 77 | const std::string& pin, |
| 78 | DBus::Error& error) override; // NOLINT |
| 79 | void ChangePin(const std::string& old_pin, |
| 80 | const std::string& new_pin, |
| 81 | DBus::Error& error) override; // NOLINT |
| 82 | std::string PerformTDLSOperation(const std::string& operation, |
| 83 | const std::string& peer, |
| 84 | DBus::Error& error) override; // NOLINT |
| 85 | void Reset(DBus::Error& error) override; // NOLINT |
| 86 | void ResetByteCounters(DBus::Error& error) override; // NOLINT |
| 87 | void SetCarrier(const std::string& carrier, |
| 88 | DBus::Error& error) override; // NOLINT |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 89 | |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 90 | void AddWakeOnPacketConnection(const std::string& ip_endpoint, |
| 91 | DBus::Error& error) override; // NOLINT |
| 92 | void RemoveWakeOnPacketConnection(const std::string& ip_endpoint, |
| 93 | DBus::Error& error) override; // NOLINT |
| 94 | void RemoveAllWakeOnPacketConnections(DBus::Error& error) override; // NOLINT |
Samuel Tan | 96bdaec | 2014-11-05 18:27:38 -0800 | [diff] [blame] | 95 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 96 | private: |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 97 | Device* device_; |
Chris Masone | 4e85161 | 2011-07-01 10:46:53 -0700 | [diff] [blame] | 98 | const std::string connection_name_; |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 99 | DISALLOW_COPY_AND_ASSIGN(DeviceDBusAdaptor); |
| 100 | }; |
| 101 | |
| 102 | } // namespace shill |
Ben Chan | c45688b | 2014-07-02 23:50:45 -0700 | [diff] [blame] | 103 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 104 | #endif // SHILL_DEVICE_DBUS_ADAPTOR_H_ |