Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 1 | // 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_SERVICE_DBUS_ADAPTOR_H_ |
| 6 | #define SHILL_SERVICE_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 Petkov | 4a09b6b | 2011-07-19 12:52:06 -0700 | [diff] [blame] | 15 | #include "shill/dbus_bindings/flimflam-service.h" |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 16 | |
| 17 | namespace shill { |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 18 | |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 19 | class Service; |
| 20 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 21 | // Subclass of DBusAdaptor for Service objects |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 22 | // There is a 1:1 mapping between Service and ServiceDBusAdaptor |
| 23 | // instances. Furthermore, the Service owns the ServiceDBusAdaptor |
| 24 | // and manages its lifetime, so we're OK with ServiceDBusAdaptor |
| 25 | // having a bare pointer to its owner service. |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 26 | class ServiceDBusAdaptor : public org::chromium::flimflam::Service_adaptor, |
| 27 | public DBusAdaptor, |
| 28 | public ServiceAdaptorInterface { |
| 29 | public: |
| 30 | static const char kInterfaceName[]; |
| 31 | static const char kPath[]; |
| 32 | |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 33 | ServiceDBusAdaptor(DBus::Connection* conn, Service *service); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 34 | virtual ~ServiceDBusAdaptor(); |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 35 | |
| 36 | // Implementation of ServiceAdaptorInterface. |
Chris Masone | 95207da | 2011-06-29 16:50:49 -0700 | [diff] [blame] | 37 | virtual const std::string &GetRpcIdentifier() { return path(); } |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 38 | void UpdateConnected(); |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 39 | void EmitBoolChanged(const std::string& name, bool value); |
| 40 | void EmitUintChanged(const std::string& name, uint32 value); |
| 41 | void EmitIntChanged(const std::string& name, int value); |
| 42 | void EmitStringChanged(const std::string& name, const std::string& value); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 43 | |
| 44 | // Implementation of Service_adaptor |
| 45 | std::map<std::string, ::DBus::Variant> GetProperties(::DBus::Error &error); |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 46 | void SetProperty(const std::string& name, |
| 47 | const ::DBus::Variant& value, |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 48 | ::DBus::Error &error); |
| 49 | void ClearProperty(const std::string& , ::DBus::Error &error); |
| 50 | void Connect(::DBus::Error &error); |
| 51 | void Disconnect(::DBus::Error &error); |
| 52 | void Remove(::DBus::Error &error); |
| 53 | void MoveBefore(const ::DBus::Path& , ::DBus::Error &error); |
| 54 | void MoveAfter(const ::DBus::Path& , ::DBus::Error &error); |
Darin Petkov | c408e69 | 2011-08-17 13:47:15 -0700 | [diff] [blame] | 55 | void ActivateCellularModem(const std::string &carrier, ::DBus::Error &error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 56 | |
| 57 | private: |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 58 | Service *service_; |
Darin Petkov | c408e69 | 2011-08-17 13:47:15 -0700 | [diff] [blame] | 59 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 60 | DISALLOW_COPY_AND_ASSIGN(ServiceDBusAdaptor); |
| 61 | }; |
| 62 | |
| 63 | } // namespace shill |
| 64 | #endif // SHILL_SERVICE_DBUS_ADAPTOR_H_ |