blob: d8c41ae2575b820dbdaaeca9c61b013fefa197fc [file] [log] [blame]
Darin Petkovd78ee7e2012-01-12 11:21:10 +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_SERVICE_DBUS_ADAPTOR_H_
6#define SHILL_SERVICE_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.Service.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 Service;
21
Chris Masoned7732e42011-05-20 11:08:56 -070022// Subclass of DBusAdaptor for Service objects
Chris Masoneec6b18b2011-06-08 14:09:10 -070023// 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 Masoned7732e42011-05-20 11:08:56 -070027class ServiceDBusAdaptor : public org::chromium::flimflam::Service_adaptor,
28 public DBusAdaptor,
29 public ServiceAdaptorInterface {
30 public:
Chris Masoned7732e42011-05-20 11:08:56 -070031 static const char kPath[];
32
mukesh agrawalbebf1b82013-04-23 15:06:33 -070033 ServiceDBusAdaptor(DBus::Connection *conn, Service *service);
Ben Chan5ea763b2014-08-13 11:07:54 -070034 ~ServiceDBusAdaptor() override;
Chris Masoned0ceb8c2011-06-02 10:05:39 -070035
36 // Implementation of ServiceAdaptorInterface.
Yunlian Jiang6acd9662015-01-30 08:36:10 -080037 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 Masoned7732e42011-05-20 11:08:56 -070052
53 // Implementation of Service_adaptor
Ben Chan3f4d4ee2014-09-09 07:41:33 -070054 std::map<std::string, DBus::Variant> GetProperties(
Yunlian Jiang6acd9662015-01-30 08:36:10 -080055 DBus::Error &error) override; // NOLINT
Ben Chan3f4d4ee2014-09-09 07:41:33 -070056 void SetProperty(const std::string &name,
57 const DBus::Variant &value,
Yunlian Jiang6acd9662015-01-30 08:36:10 -080058 DBus::Error &error) override; // NOLINT
Ben Chan3f4d4ee2014-09-09 07:41:33 -070059 void SetProperties(const std::map<std::string, DBus::Variant> &args,
Yunlian Jiang6acd9662015-01-30 08:36:10 -080060 DBus::Error &error) override; // NOLINT
61 void ClearProperty(const std::string &name,
62 DBus::Error &error) override; // NOLINT
Ben Chan3f4d4ee2014-09-09 07:41:33 -070063 std::vector<bool> ClearProperties(const std::vector<std::string> &names,
Yunlian Jiang6acd9662015-01-30 08:36:10 -080064 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 Chan3f4d4ee2014-09-09 07:41:33 -070068 void ActivateCellularModem(const std::string &carrier,
Yunlian Jiang6acd9662015-01-30 08:36:10 -080069 DBus::Error &error) override; // NOLINT
70 void CompleteCellularActivation(DBus::Error &error) override; // NOLINT
Ben Chan3f4d4ee2014-09-09 07:41:33 -070071 std::map<DBus::Path, std::string> GetLoadableProfileEntries(
Yunlian Jiang6acd9662015-01-30 08:36:10 -080072 DBus::Error &error) override; // NOLINT
Chris Masoned7732e42011-05-20 11:08:56 -070073
74 private:
Chris Masoneec6b18b2011-06-08 14:09:10 -070075 Service *service_;
Darin Petkovc408e692011-08-17 13:47:15 -070076
Chris Masoned7732e42011-05-20 11:08:56 -070077 DISALLOW_COPY_AND_ASSIGN(ServiceDBusAdaptor);
78};
79
80} // namespace shill
Ben Chanc45688b2014-07-02 23:50:45 -070081
Chris Masoned7732e42011-05-20 11:08:56 -070082#endif // SHILL_SERVICE_DBUS_ADAPTOR_H_