blob: 912c42d34ddad1efa48c121ae15f562f3e242ef6 [file] [log] [blame]
mukesh agrawal4d0401c2012-01-06 16:05:31 -08001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Chris Masonec6c6c132011-06-30 11:29:52 -07002// 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) {
mukesh agrawalde29fa82011-09-16 16:16:36 -070072 if (DBusAdaptor::DispatchOnType(ipconfig_->mutable_store(),
73 name,
74 value,
75 &error)) {
Chris Masonec6c6c132011-06-30 11:29:52 -070076 PropertyChanged(name, value);
77 }
78}
79
mukesh agrawal4d0401c2012-01-06 16:05:31 -080080void IPConfigDBusAdaptor::ClearProperty(const std::string &name,
mukesh agrawal1830fa12011-09-26 14:31:40 -070081 ::DBus::Error &/*error*/) {
mukesh agrawal4d0401c2012-01-06 16:05:31 -080082 NOTIMPLEMENTED() << " Ignoring request to clear " << name
83 << " property of IPConfig " << ipconfig_->serial()
84 << " (associated with Device " << ipconfig_->device_name()
85 << ")";
Chris Masonec6c6c132011-06-30 11:29:52 -070086}
87
mukesh agrawal1830fa12011-09-26 14:31:40 -070088void IPConfigDBusAdaptor::Remove(::DBus::Error &/*error*/) {
Chris Masonec6c6c132011-06-30 11:29:52 -070089}
90
mukesh agrawal1830fa12011-09-26 14:31:40 -070091void IPConfigDBusAdaptor::MoveBefore(const ::DBus::Path& /*path*/,
92 ::DBus::Error &/*error*/) {
Chris Masonec6c6c132011-06-30 11:29:52 -070093}
94
mukesh agrawal1830fa12011-09-26 14:31:40 -070095void IPConfigDBusAdaptor::MoveAfter(const ::DBus::Path& /*path*/,
96 ::DBus::Error &/*error*/) {
Chris Masonec6c6c132011-06-30 11:29:52 -070097}
98
99} // namespace shill