blob: 9b43d65a5db4e0e5d32f57b24230be138eaa3a67 [file] [log] [blame]
Darin Petkov63138a92012-02-06 14:09:15 +01001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Chris Masoned7732e42011-05-20 11:08:56 -07002// 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 Vakulenko8a532292014-06-16 17:18:44 -070010#include <vector>
Chris Masoned7732e42011-05-20 11:08:56 -070011
Ben Chancc67c522014-09-03 07:19:18 -070012#include <base/macros.h>
Chris Masoned7732e42011-05-20 11:08:56 -070013
14#include "shill/adaptor_interfaces.h"
15#include "shill/dbus_adaptor.h"
Liam McLoughlinef342b42013-09-13 21:05:36 +010016#include "shill/dbus_adaptors/org.chromium.flimflam.Device.h"
Chris Masoned7732e42011-05-20 11:08:56 -070017
18namespace shill {
Chris Masoned7732e42011-05-20 11:08:56 -070019
Chris Masoneec6b18b2011-06-08 14:09:10 -070020class Device;
21
Chris Masoned7732e42011-05-20 11:08:56 -070022// Subclass of DBusAdaptor for Device objects
Chris Masoneec6b18b2011-06-08 14:09:10 -070023// 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 Masoned7732e42011-05-20 11:08:56 -070026class DeviceDBusAdaptor : public org::chromium::flimflam::Device_adaptor,
27 public DBusAdaptor,
28 public DeviceAdaptorInterface {
29 public:
Chris Masoned7732e42011-05-20 11:08:56 -070030 static const char kPath[];
31
Paul Stewarta794cd62015-06-16 13:13:10 -070032 DeviceDBusAdaptor(DBus::Connection* conn, Device* device);
Ben Chan5ea763b2014-08-13 11:07:54 -070033 ~DeviceDBusAdaptor() override;
Chris Masoned7732e42011-05-20 11:08:56 -070034
Chris Masoned0ceb8c2011-06-02 10:05:39 -070035 // Implementation of DeviceAdaptorInterface.
Paul Stewarta794cd62015-06-16 13:13:10 -070036 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 Jiang6acd9662015-01-30 08:36:10 -080054 void EmitRpcIdentifierArrayChanged(
Paul Stewarta794cd62015-06-16 13:13:10 -070055 const std::string& name, const std::vector<std::string>& value) override;
Chris Masoned0ceb8c2011-06-02 10:05:39 -070056
57 // Implementation of Device_adaptor.
Yunlian Jiang6acd9662015-01-30 08:36:10 -080058 std::map<std::string, DBus::Variant> GetProperties(
Paul Stewarta794cd62015-06-16 13:13:10 -070059 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 Masoned7732e42011-05-20 11:08:56 -070089
Paul Stewarta794cd62015-06-16 13:13:10 -070090 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 Tan96bdaec2014-11-05 18:27:38 -080095
Chris Masoned7732e42011-05-20 11:08:56 -070096 private:
Paul Stewarta794cd62015-06-16 13:13:10 -070097 Device* device_;
Chris Masone4e851612011-07-01 10:46:53 -070098 const std::string connection_name_;
Chris Masoned7732e42011-05-20 11:08:56 -070099 DISALLOW_COPY_AND_ASSIGN(DeviceDBusAdaptor);
100};
101
102} // namespace shill
Ben Chanc45688b2014-07-02 23:50:45 -0700103
Chris Masoned7732e42011-05-20 11:08:56 -0700104#endif // SHILL_DEVICE_DBUS_ADAPTOR_H_