blob: 42f7d1cfda277d926c615b6ef432f8d8ba46a380 [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#include "shill/profile_dbus_adaptor.h"
6
7#include <map>
8#include <string>
9#include <vector>
10
11#include <base/logging.h>
12#include <dbus-c++/dbus.h>
13
14#include "shill/error.h"
15#include "shill/profile.h"
16
17using std::map;
18using std::string;
19using std::vector;
20
21namespace shill {
22
23// static
24const char ProfileDBusAdaptor::kInterfaceName[] = SHILL_INTERFACE;
25// static
26const char ProfileDBusAdaptor::kPath[] = "/profile/";
27
28ProfileDBusAdaptor::ProfileDBusAdaptor(DBus::Connection* conn, Profile *profile)
Chris Masone7df0c672011-07-15 10:24:54 -070029 : DBusAdaptor(conn, kPath + profile->GetFriendlyName()),
Chris Masone52cd19b2011-06-29 17:23:04 -070030 profile_(profile) {
31}
32
33ProfileDBusAdaptor::~ProfileDBusAdaptor() {
34 profile_ = NULL;
35}
36
37void ProfileDBusAdaptor::EmitBoolChanged(const string &name, bool value) {
38 PropertyChanged(name, DBusAdaptor::BoolToVariant(value));
39}
40
41void ProfileDBusAdaptor::EmitUintChanged(const string &name,
42 uint32 value) {
43 PropertyChanged(name, DBusAdaptor::Uint32ToVariant(value));
44}
45
46void ProfileDBusAdaptor::EmitIntChanged(const string &name, int value) {
47 PropertyChanged(name, DBusAdaptor::Int32ToVariant(value));
48}
49
50void ProfileDBusAdaptor::EmitStringChanged(const string &name,
51 const string &value) {
52 PropertyChanged(name, DBusAdaptor::StringToVariant(value));
53}
54
55map<string, ::DBus::Variant> ProfileDBusAdaptor::GetProperties(
56 ::DBus::Error &error) {
57 map<string, ::DBus::Variant> properties;
Chris Masone27c4aa52011-07-02 13:10:14 -070058 DBusAdaptor::GetProperties(profile_->store(), &properties, &error);
Chris Masone52cd19b2011-06-29 17:23:04 -070059 return properties;
60}
61
62void ProfileDBusAdaptor::SetProperty(const string &name,
63 const ::DBus::Variant &value,
64 ::DBus::Error &error) {
mukesh agrawalde29fa82011-09-16 16:16:36 -070065 if (DBusAdaptor::DispatchOnType(profile_->mutable_store(),
66 name,
67 value,
68 &error)) {
Chris Masone52cd19b2011-06-29 17:23:04 -070069 PropertyChanged(name, value);
70 }
71}
72
73map<string, ::DBus::Variant> ProfileDBusAdaptor::GetEntry(
mukesh agrawal1830fa12011-09-26 14:31:40 -070074 const std::string& /*name*/,
75 ::DBus::Error &/*error*/) {
Chris Masone52cd19b2011-06-29 17:23:04 -070076 return map<string, ::DBus::Variant>();
77}
78
Paul Stewart75225512012-01-26 22:51:33 -080079void ProfileDBusAdaptor::DeleteEntry(const std::string &name,
80 ::DBus::Error &error) {
81 Error e;
82 profile_->DeleteEntry(name, &e);
83 e.ToDBusError(&error);
Chris Masone52cd19b2011-06-29 17:23:04 -070084}
85
86} // namespace shill