blob: 26858e60d7618dd26365b42295d266903741a716 [file] [log] [blame]
Chris Masonec6c6c132011-06-30 11:29:52 -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/ipconfig_dbus_adaptor.h"
6
7#include <map>
8#include <string>
9#include <vector>
10
11#include <base/logging.h>
Chris Masone0756f232011-07-21 17:24:00 -070012#include <base/stringprintf.h>
Chris Masonec6c6c132011-06-30 11:29:52 -070013#include <dbus-c++/dbus.h>
14
15#include "shill/error.h"
16#include "shill/ipconfig.h"
17
Chris Masone0756f232011-07-21 17:24:00 -070018using base::StringPrintf;
Chris Masonec6c6c132011-06-30 11:29:52 -070019using std::map;
20using std::string;
21using std::vector;
22
23namespace shill {
24
25// static
26const char IPConfigDBusAdaptor::kInterfaceName[] = SHILL_INTERFACE;
27// static
Chris Masone0756f232011-07-21 17:24:00 -070028const char IPConfigDBusAdaptor::kPath[] = "/ipconfig/";
Chris Masonec6c6c132011-06-30 11:29:52 -070029
30IPConfigDBusAdaptor::IPConfigDBusAdaptor(DBus::Connection* conn,
31 IPConfig *config)
Chris Masone0756f232011-07-21 17:24:00 -070032 : DBusAdaptor(conn, StringPrintf("%s%s_%u_%s",
33 kPath,
34 config->device_name().c_str(),
35 config->serial(),
36 config->type().c_str())),
Chris Masonec6c6c132011-06-30 11:29:52 -070037 ipconfig_(config) {
38}
39
40IPConfigDBusAdaptor::~IPConfigDBusAdaptor() {
41 ipconfig_ = NULL;
42}
43
44void IPConfigDBusAdaptor::EmitBoolChanged(const string &name, bool value) {
45 PropertyChanged(name, DBusAdaptor::BoolToVariant(value));
46}
47
48void IPConfigDBusAdaptor::EmitUintChanged(const string &name,
49 uint32 value) {
50 PropertyChanged(name, DBusAdaptor::Uint32ToVariant(value));
51}
52
53void IPConfigDBusAdaptor::EmitIntChanged(const string &name, int value) {
54 PropertyChanged(name, DBusAdaptor::Int32ToVariant(value));
55}
56
57void IPConfigDBusAdaptor::EmitStringChanged(const string &name,
58 const string &value) {
59 PropertyChanged(name, DBusAdaptor::StringToVariant(value));
60}
61
62map<string, ::DBus::Variant> IPConfigDBusAdaptor::GetProperties(
63 ::DBus::Error &error) {
64 map<string, ::DBus::Variant> properties;
Chris Masone27c4aa52011-07-02 13:10:14 -070065 DBusAdaptor::GetProperties(ipconfig_->store(), &properties, &error);
Chris Masonec6c6c132011-06-30 11:29:52 -070066 return properties;
67}
68
69void IPConfigDBusAdaptor::SetProperty(const string &name,
70 const ::DBus::Variant &value,
71 ::DBus::Error &error) {
Chris Masone27c4aa52011-07-02 13:10:14 -070072 if (DBusAdaptor::DispatchOnType(ipconfig_->store(), name, value, &error)) {
Chris Masonec6c6c132011-06-30 11:29:52 -070073 PropertyChanged(name, value);
74 }
75}
76
77void IPConfigDBusAdaptor::ClearProperty(const std::string& name,
78 ::DBus::Error &error) {
79}
80
81void IPConfigDBusAdaptor::Remove(::DBus::Error &error) {
82}
83
84void IPConfigDBusAdaptor::MoveBefore(const ::DBus::Path& path,
85 ::DBus::Error &error) {
86}
87
88void IPConfigDBusAdaptor::MoveAfter(const ::DBus::Path& path,
89 ::DBus::Error &error) {
90}
91
92} // namespace shill