Darin Petkov | d78ee7e | 2012-01-12 11:21:10 +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_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: |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 30 | static const char kPath[]; |
| 31 | |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 32 | ServiceDBusAdaptor(DBus::Connection *conn, Service *service); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 33 | virtual ~ServiceDBusAdaptor(); |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 34 | |
| 35 | // Implementation of ServiceAdaptorInterface. |
Chris Masone | 95207da | 2011-06-29 16:50:49 -0700 | [diff] [blame] | 36 | virtual const std::string &GetRpcIdentifier() { return path(); } |
Darin Petkov | d78ee7e | 2012-01-12 11:21:10 +0100 | [diff] [blame] | 37 | virtual void UpdateConnected(); |
| 38 | virtual void EmitBoolChanged(const std::string &name, bool value); |
| 39 | virtual void EmitUint8Changed(const std::string &name, uint8 value); |
mukesh agrawal | e1d90e9 | 2012-02-15 17:36:08 -0800 | [diff] [blame] | 40 | virtual void EmitUint16Changed(const std::string &name, uint16 value); |
mukesh agrawal | e7c7e65 | 2013-06-18 17:19:39 -0700 | [diff] [blame] | 41 | virtual void EmitUint16sChanged(const std::string &name, |
| 42 | const Uint16s &value); |
Darin Petkov | d78ee7e | 2012-01-12 11:21:10 +0100 | [diff] [blame] | 43 | virtual void EmitUintChanged(const std::string &name, uint32 value); |
| 44 | virtual void EmitIntChanged(const std::string &name, int value); |
Paul Stewart | 1e3bc496 | 2012-09-14 12:20:22 -0700 | [diff] [blame] | 45 | virtual void EmitRpcIdentifierChanged( |
| 46 | const std::string &name, const std::string &value); |
Darin Petkov | d78ee7e | 2012-01-12 11:21:10 +0100 | [diff] [blame] | 47 | virtual void EmitStringChanged( |
mukesh agrawal | e1d90e9 | 2012-02-15 17:36:08 -0800 | [diff] [blame] | 48 | const std::string &name, const std::string &value); |
Darin Petkov | 9cb0268 | 2012-01-28 00:17:38 +0100 | [diff] [blame] | 49 | virtual void EmitStringmapChanged(const std::string &name, |
| 50 | const Stringmap &value); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 51 | |
| 52 | // Implementation of Service_adaptor |
| 53 | std::map<std::string, ::DBus::Variant> GetProperties(::DBus::Error &error); |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 54 | void SetProperty(const std::string& name, |
| 55 | const ::DBus::Variant& value, |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 56 | ::DBus::Error &error); |
Paul Stewart | ad0e598 | 2013-07-02 08:47:47 -0700 | [diff] [blame] | 57 | void SetProperties(const std::map<std::string, ::DBus::Variant> &args, |
| 58 | ::DBus::Error &error); |
Paul Stewart | bcb2c96 | 2012-10-31 10:52:10 -0700 | [diff] [blame] | 59 | void ClearProperty(const std::string&, ::DBus::Error &error); |
| 60 | std::vector<bool> ClearProperties(const std::vector<std::string>&, |
| 61 | ::DBus::Error &error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 62 | void Connect(::DBus::Error &error); |
| 63 | void Disconnect(::DBus::Error &error); |
| 64 | void Remove(::DBus::Error &error); |
| 65 | void MoveBefore(const ::DBus::Path& , ::DBus::Error &error); |
| 66 | void MoveAfter(const ::DBus::Path& , ::DBus::Error &error); |
Darin Petkov | c408e69 | 2011-08-17 13:47:15 -0700 | [diff] [blame] | 67 | void ActivateCellularModem(const std::string &carrier, ::DBus::Error &error); |
Ben Chan | 5d92454 | 2013-02-14 17:49:08 -0800 | [diff] [blame] | 68 | void CompleteCellularActivation(::DBus::Error &error); |
Paul Stewart | 967eaeb | 2013-04-25 19:53:07 -0700 | [diff] [blame] | 69 | std::map<::DBus::Path, std::string> GetLoadableProfileEntries( |
| 70 | ::DBus::Error &error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 71 | |
| 72 | private: |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 73 | Service *service_; |
Darin Petkov | c408e69 | 2011-08-17 13:47:15 -0700 | [diff] [blame] | 74 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 75 | DISALLOW_COPY_AND_ASSIGN(ServiceDBusAdaptor); |
| 76 | }; |
| 77 | |
| 78 | } // namespace shill |
| 79 | #endif // SHILL_SERVICE_DBUS_ADAPTOR_H_ |