blob: 6f241474798d7be7b7a5e5619c04dcb593cc32ce [file] [log] [blame]
Chris Masoned7732e42011-05-20 11:08:56 -07001// Copyright (c) 2011 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_DEVICE_DBUS_ADAPTOR_H_
6#define SHILL_DEVICE_DBUS_ADAPTOR_H_
7
8#include <map>
9#include <string>
10
11#include <base/basictypes.h>
12
13#include "shill/adaptor_interfaces.h"
14#include "shill/dbus_adaptor.h"
Darin Petkov4a09b6b2011-07-19 12:52:06 -070015#include "shill/dbus_bindings/flimflam-device.h"
Chris Masoned7732e42011-05-20 11:08:56 -070016
17namespace shill {
Chris Masoned7732e42011-05-20 11:08:56 -070018
Chris Masoneec6b18b2011-06-08 14:09:10 -070019class Device;
20
Chris Masoned7732e42011-05-20 11:08:56 -070021// Subclass of DBusAdaptor for Device objects
Chris Masoneec6b18b2011-06-08 14:09:10 -070022// There is a 1:1 mapping between Device and DeviceDBusAdaptor instances.
23// Furthermore, the Device owns the DeviceDBusAdaptor and manages its lifetime,
24// so we're OK with DeviceDBusAdaptor having a bare pointer to its owner device.
Chris Masoned7732e42011-05-20 11:08:56 -070025class DeviceDBusAdaptor : public org::chromium::flimflam::Device_adaptor,
26 public DBusAdaptor,
27 public DeviceAdaptorInterface {
28 public:
29 static const char kInterfaceName[];
30 static const char kPath[];
31
Chris Masoneec6b18b2011-06-08 14:09:10 -070032 DeviceDBusAdaptor(DBus::Connection* conn, Device *device);
Chris Masoned7732e42011-05-20 11:08:56 -070033 virtual ~DeviceDBusAdaptor();
Chris Masoned7732e42011-05-20 11:08:56 -070034
Chris Masoned0ceb8c2011-06-02 10:05:39 -070035 // Implementation of DeviceAdaptorInterface.
Chris Masone4e851612011-07-01 10:46:53 -070036 virtual const std::string &GetRpcIdentifier();
37 virtual const std::string &GetRpcConnectionIdentifier();
38 virtual void UpdateEnabled();
39 virtual void EmitBoolChanged(const std::string& name, bool value);
40 virtual void EmitUintChanged(const std::string& name, uint32 value);
41 virtual void EmitIntChanged(const std::string& name, int value);
42 virtual void EmitStringChanged(const std::string& name,
43 const std::string& value);
Chris Masoned0ceb8c2011-06-02 10:05:39 -070044
45 // Implementation of Device_adaptor.
Chris Masoned7732e42011-05-20 11:08:56 -070046 std::map<std::string, ::DBus::Variant> GetProperties(::DBus::Error &error);
Chris Masone8fe2c7e2011-06-09 15:51:19 -070047 void SetProperty(const std::string& name,
48 const ::DBus::Variant& value,
Chris Masoned7732e42011-05-20 11:08:56 -070049 ::DBus::Error &error);
Chris Masoneccc88812011-06-08 18:00:10 -070050 void ClearProperty(const std::string& , ::DBus::Error &error);
Chris Masoned7732e42011-05-20 11:08:56 -070051 void ProposeScan(::DBus::Error &error);
52 ::DBus::Path AddIPConfig(const std::string& , ::DBus::Error &error);
Chris Masoneccc88812011-06-08 18:00:10 -070053 void Register(const std::string& , ::DBus::Error &error);
54 void RequirePin(const std::string& , const bool& , ::DBus::Error &error);
55 void EnterPin(const std::string& , ::DBus::Error &error);
56 void UnblockPin(const std::string& ,
57 const std::string& ,
58 ::DBus::Error &error);
59 void ChangePin(const std::string& ,
60 const std::string& ,
61 ::DBus::Error &error);
Chris Masoned7732e42011-05-20 11:08:56 -070062
63 private:
Chris Masoneec6b18b2011-06-08 14:09:10 -070064 Device *device_;
Chris Masone4e851612011-07-01 10:46:53 -070065 const std::string connection_name_;
Chris Masoned7732e42011-05-20 11:08:56 -070066 DISALLOW_COPY_AND_ASSIGN(DeviceDBusAdaptor);
67};
68
69} // namespace shill
70#endif // SHILL_DEVICE_DBUS_ADAPTOR_H_