blob: 1d309651865793d14fa6cff1e18ee9a8922a3c02 [file] [log] [blame]
Chris Masone52cd19b2011-06-29 17:23:04 -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_PROFILE_DBUS_ADAPTOR_H_
6#define SHILL_PROFILE_DBUS_ADAPTOR_H_
7
8#include <map>
9#include <string>
10
Ben Chancc67c522014-09-03 07:19:18 -070011#include <base/macros.h>
Chris Masone52cd19b2011-06-29 17:23:04 -070012#include <dbus-c++/dbus.h>
13
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.Profile.h"
Chris Masone52cd19b2011-06-29 17:23:04 -070017
18namespace shill {
19
20class Profile;
21
22// Subclass of DBusAdaptor for Profile objects
23// There is a 1:1 mapping between Profile and ProfileDBusAdaptor
24// instances. Furthermore, the Profile owns the ProfileDBusAdaptor
25// and manages its lifetime, so we're OK with ProfileDBusAdaptor
26// having a bare pointer to its owner profile.
27//
28// A Profile is a collection of Entry structures (which we will define later).
29class ProfileDBusAdaptor : public org::chromium::flimflam::Profile_adaptor,
30 public DBusAdaptor,
31 public ProfileAdaptorInterface {
32 public:
Chris Masone52cd19b2011-06-29 17:23:04 -070033 static const char kPath[];
34
Paul Stewart1a212a62015-06-16 13:13:10 -070035 ProfileDBusAdaptor(DBus::Connection* conn, Profile* profile);
Ben Chan5ea763b2014-08-13 11:07:54 -070036 ~ProfileDBusAdaptor() override;
Chris Masone52cd19b2011-06-29 17:23:04 -070037
38 // Implementation of ProfileAdaptorInterface.
Paul Stewart1a212a62015-06-16 13:13:10 -070039 const std::string& GetRpcIdentifier() override { return path(); }
40 void EmitBoolChanged(const std::string& name, bool value) override;
41 void EmitUintChanged(const std::string& name, uint32_t value) override;
42 void EmitIntChanged(const std::string& name, int value) override;
43 void EmitStringChanged(const std::string& name,
44 const std::string& value) override;
Chris Masone52cd19b2011-06-29 17:23:04 -070045
46 // Implementation of Profile_adaptor
Yunlian Jiang6acd9662015-01-30 08:36:10 -080047 std::map<std::string, DBus::Variant> GetProperties(
Paul Stewart1a212a62015-06-16 13:13:10 -070048 DBus::Error& error) override; // NOLINT
49 void SetProperty(const std::string& name,
50 const DBus::Variant& value,
51 DBus::Error& error) override; // NOLINT
Chris Masone52cd19b2011-06-29 17:23:04 -070052
53 // Gets an "Entry", which is apparently a different set of properties than
54 // those returned by GetProperties.
Yunlian Jiang6acd9662015-01-30 08:36:10 -080055 std::map<std::string, DBus::Variant> GetEntry(
Paul Stewart1a212a62015-06-16 13:13:10 -070056 const std::string&,
57 DBus::Error& error) override; // NOLINT
Chris Masone52cd19b2011-06-29 17:23:04 -070058
59 // Deletes an Entry.
Paul Stewart1a212a62015-06-16 13:13:10 -070060 void DeleteEntry(const std::string& , DBus::Error& error) override; // NOLINT
Chris Masone52cd19b2011-06-29 17:23:04 -070061
62 private:
Paul Stewart1a212a62015-06-16 13:13:10 -070063 Profile* profile_;
Ben Chan3f4d4ee2014-09-09 07:41:33 -070064
Chris Masone52cd19b2011-06-29 17:23:04 -070065 DISALLOW_COPY_AND_ASSIGN(ProfileDBusAdaptor);
66};
67
68} // namespace shill
Ben Chanc45688b2014-07-02 23:50:45 -070069
Chris Masone52cd19b2011-06-29 17:23:04 -070070#endif // SHILL_PROFILE_DBUS_ADAPTOR_H_