• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2015 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef SHILL_DBUS_CHROMEOS_PROFILE_DBUS_ADAPTOR_H_
18 #define SHILL_DBUS_CHROMEOS_PROFILE_DBUS_ADAPTOR_H_
19 
20 #include <string>
21 
22 #include <base/macros.h>
23 
24 #include "dbus_bindings/org.chromium.flimflam.Profile.h"
25 #include "shill/adaptor_interfaces.h"
26 #include "shill/dbus/chromeos_dbus_adaptor.h"
27 
28 namespace shill {
29 
30 class Profile;
31 
32 // Subclass of DBusAdaptor for Profile objects
33 // There is a 1:1 mapping between Profile and ChromeosProfileDBusAdaptor
34 // instances.  Furthermore, the Profile owns the ChromeosProfileDBusAdaptor
35 // and manages its lifetime, so we're OK with ChromeosProfileDBusAdaptor
36 // having a bare pointer to its owner profile.
37 //
38 // A Profile is a collection of Entry structures (which we will define later).
39 class ChromeosProfileDBusAdaptor
40     : public org::chromium::flimflam::ProfileAdaptor,
41       public org::chromium::flimflam::ProfileInterface,
42       public ChromeosDBusAdaptor,
43       public ProfileAdaptorInterface {
44  public:
45   static const char kPath[];
46 
47   ChromeosProfileDBusAdaptor(
48       const scoped_refptr<dbus::Bus>& bus,
49       Profile* profile);
50   ~ChromeosProfileDBusAdaptor() override;
51 
52   // Implementation of ProfileAdaptorInterface.
GetRpcIdentifier()53   const std::string& GetRpcIdentifier() override { return dbus_path().value(); }
54   void EmitBoolChanged(const std::string& name, bool value) override;
55   void EmitUintChanged(const std::string& name, uint32_t value) override;
56   void EmitIntChanged(const std::string& name, int value) override;
57   void EmitStringChanged(const std::string& name,
58                          const std::string& value) override;
59 
60   // Implementation of ProfileAdaptor
61   bool GetProperties(brillo::ErrorPtr* error,
62                      brillo::VariantDictionary* properties) override;
63   bool SetProperty(brillo::ErrorPtr* error,
64                    const std::string& name,
65                    const brillo::Any& value) override;
66 
67   // Gets an "Entry", which is apparently a different set of properties than
68   // those returned by GetProperties.
69   bool GetEntry(brillo::ErrorPtr* error,
70                 const std::string& name,
71                 brillo::VariantDictionary* entry_properties) override;
72 
73   // Deletes an Entry.
74   bool DeleteEntry(brillo::ErrorPtr* error, const std::string& name) override;
75 
76  private:
77   Profile* profile_;
78 
79   DISALLOW_COPY_AND_ASSIGN(ChromeosProfileDBusAdaptor);
80 };
81 
82 }  // namespace shill
83 
84 #endif  // SHILL_DBUS_CHROMEOS_PROFILE_DBUS_ADAPTOR_H_
85