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> |
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.Service.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 Service; |
| 21 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 22 | // Subclass of DBusAdaptor for Service objects |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 23 | // There is a 1:1 mapping between Service and ServiceDBusAdaptor |
| 24 | // instances. Furthermore, the Service owns the ServiceDBusAdaptor |
| 25 | // and manages its lifetime, so we're OK with ServiceDBusAdaptor |
| 26 | // having a bare pointer to its owner service. |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 27 | class ServiceDBusAdaptor : public org::chromium::flimflam::Service_adaptor, |
| 28 | public DBusAdaptor, |
| 29 | public ServiceAdaptorInterface { |
| 30 | public: |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 31 | static const char kPath[]; |
| 32 | |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 33 | ServiceDBusAdaptor(DBus::Connection *conn, Service *service); |
Ben Chan | 5ea763b | 2014-08-13 11:07:54 -0700 | [diff] [blame] | 34 | ~ServiceDBusAdaptor() override; |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 35 | |
| 36 | // Implementation of ServiceAdaptorInterface. |
Yunlian Jiang | 6acd966 | 2015-01-30 08:36:10 -0800 | [diff] [blame] | 37 | const std::string &GetRpcIdentifier() override { return path(); } |
| 38 | void UpdateConnected() override; |
| 39 | void EmitBoolChanged(const std::string &name, bool value) override; |
| 40 | void EmitUint8Changed(const std::string &name, uint8_t value) override; |
| 41 | void EmitUint16Changed(const std::string &name, uint16_t value) override; |
| 42 | void EmitUint16sChanged(const std::string &name, |
| 43 | const Uint16s &value) override; |
| 44 | void EmitUintChanged(const std::string &name, uint32_t value) override; |
| 45 | void EmitIntChanged(const std::string &name, int value) override; |
| 46 | void EmitRpcIdentifierChanged( |
| 47 | const std::string &name, const std::string &value) override; |
| 48 | void EmitStringChanged( |
| 49 | const std::string &name, const std::string &value) override; |
| 50 | void EmitStringmapChanged(const std::string &name, |
| 51 | const Stringmap &value) override; |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 52 | |
| 53 | // Implementation of Service_adaptor |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 54 | std::map<std::string, DBus::Variant> GetProperties( |
Yunlian Jiang | 6acd966 | 2015-01-30 08:36:10 -0800 | [diff] [blame] | 55 | DBus::Error &error) override; // NOLINT |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 56 | void SetProperty(const std::string &name, |
| 57 | const DBus::Variant &value, |
Yunlian Jiang | 6acd966 | 2015-01-30 08:36:10 -0800 | [diff] [blame] | 58 | DBus::Error &error) override; // NOLINT |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 59 | void SetProperties(const std::map<std::string, DBus::Variant> &args, |
Yunlian Jiang | 6acd966 | 2015-01-30 08:36:10 -0800 | [diff] [blame] | 60 | DBus::Error &error) override; // NOLINT |
| 61 | void ClearProperty(const std::string &name, |
| 62 | DBus::Error &error) override; // NOLINT |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 63 | std::vector<bool> ClearProperties(const std::vector<std::string> &names, |
Yunlian Jiang | 6acd966 | 2015-01-30 08:36:10 -0800 | [diff] [blame] | 64 | DBus::Error &error) override; // NOLINT |
| 65 | void Connect(DBus::Error &error) override; // NOLINT |
| 66 | void Disconnect(DBus::Error &error) override; // NOLINT |
| 67 | void Remove(DBus::Error &error) override; // NOLINT |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 68 | void ActivateCellularModem(const std::string &carrier, |
Yunlian Jiang | 6acd966 | 2015-01-30 08:36:10 -0800 | [diff] [blame] | 69 | DBus::Error &error) override; // NOLINT |
| 70 | void CompleteCellularActivation(DBus::Error &error) override; // NOLINT |
Ben Chan | 3f4d4ee | 2014-09-09 07:41:33 -0700 | [diff] [blame] | 71 | std::map<DBus::Path, std::string> GetLoadableProfileEntries( |
Yunlian Jiang | 6acd966 | 2015-01-30 08:36:10 -0800 | [diff] [blame] | 72 | DBus::Error &error) override; // NOLINT |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 73 | |
| 74 | private: |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 75 | Service *service_; |
Darin Petkov | c408e69 | 2011-08-17 13:47:15 -0700 | [diff] [blame] | 76 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 77 | DISALLOW_COPY_AND_ASSIGN(ServiceDBusAdaptor); |
| 78 | }; |
| 79 | |
| 80 | } // namespace shill |
Ben Chan | c45688b | 2014-07-02 23:50:45 -0700 | [diff] [blame] | 81 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 82 | #endif // SHILL_SERVICE_DBUS_ADAPTOR_H_ |