blob: 1e41403479c00a9a3749bc218e33eea7b26a1832 [file] [log] [blame]
Paul Stewart0756db92012-01-27 08:34:47 -08001// Copyright (c) 2012 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_PROPERTY_EXPORTER_
6#define SHILL_PROFILE_DBUS_PROPERTY_EXPORTER_
7
8#include <map>
9#include <string>
10
11#include <base/basictypes.h>
12#include <dbus-c++/dbus.h>
13
14namespace shill {
15
16class Error;
17class StoreInterface;
18
19// This class is responsible for loading stored profile properties
20// from storage for presentation using the Profile::GetEntry DBus
21// API. Properties are loaded and presented in much the same way
22// as a live service would present them. This is troublesome
23// because it needs to duplicate (and stay in sync with) the way
24// properties are loaded and presented in a real service.
25//
26// TODO(pstew): Get rid of this. It's nasty. crosbug.com/25813
27class ProfileDBusPropertyExporter {
28 public:
29 typedef std::map<std::string, ::DBus::Variant> PropertyList;
30
31 ProfileDBusPropertyExporter(const StoreInterface *storage,
32 const std::string &entry_name);
33 virtual ~ProfileDBusPropertyExporter();
34
35 bool LoadServiceProperties(PropertyList *properties,
36 Error *error);
37
38 private:
39 bool LoadWiFiServiceProperties(PropertyList *properties,
40 Error *error);
41
42 bool LoadBool(PropertyList *properties,
43 const std::string &storage_name,
44 const std::string &dbus_name);
45 bool LoadString(PropertyList *properties,
46 const std::string &storage_name,
47 const std::string &dbus_name);
48 void SetBool(PropertyList *properties,
49 const std::string &dbus_name,
50 bool value);
51 void SetString(PropertyList *properties,
52 const std::string &dbus_name,
53 const std::string &value);
54
55 const StoreInterface *storage_;
56 const std::string entry_name_;
57
58 DISALLOW_COPY_AND_ASSIGN(ProfileDBusPropertyExporter);
59};
60
61} // namespace shill
62
63#endif // SHILL_PROFILE_DBUS_PROPERTY_EXPORTER_