blob: 196ccd2e7c89d3d6f08ccf6763ab65624d98c1d9 [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
Chris Masone0756f232011-07-21 17:24:00 -070026const char IPConfigDBusAdaptor::kPath[] = "/ipconfig/";
Chris Masonec6c6c132011-06-30 11:29:52 -070027
28IPConfigDBusAdaptor::IPConfigDBusAdaptor(DBus::Connection* conn,
29 IPConfig *config)
Chris Masone0756f232011-07-21 17:24:00 -070030 : DBusAdaptor(conn, StringPrintf("%s%s_%u_%s",
31 kPath,
32 config->device_name().c_str(),
33 config->serial(),
34 config->type().c_str())),
Chris Masonec6c6c132011-06-30 11:29:52 -070035 ipconfig_(config) {
36}
37
38IPConfigDBusAdaptor::~IPConfigDBusAdaptor() {
39 ipconfig_ = NULL;
40}
41
42void IPConfigDBusAdaptor::EmitBoolChanged(const string &name, bool value) {
43 PropertyChanged(name, DBusAdaptor::BoolToVariant(value));
44}
45
46void IPConfigDBusAdaptor::EmitUintChanged(const string &name,
47 uint32 value) {
48 PropertyChanged(name, DBusAdaptor::Uint32ToVariant(value));
49}
50
51void IPConfigDBusAdaptor::EmitIntChanged(const string &name, int value) {
52 PropertyChanged(name, DBusAdaptor::Int32ToVariant(value));
53}
54
55void IPConfigDBusAdaptor::EmitStringChanged(const string &name,
56 const string &value) {
57 PropertyChanged(name, DBusAdaptor::StringToVariant(value));
58}
59
60map<string, ::DBus::Variant> IPConfigDBusAdaptor::GetProperties(
61 ::DBus::Error &error) {
62 map<string, ::DBus::Variant> properties;
Chris Masone27c4aa52011-07-02 13:10:14 -070063 DBusAdaptor::GetProperties(ipconfig_->store(), &properties, &error);
Chris Masonec6c6c132011-06-30 11:29:52 -070064 return properties;
65}
66
67void IPConfigDBusAdaptor::SetProperty(const string &name,
68 const ::DBus::Variant &value,
69 ::DBus::Error &error) {
mukesh agrawal6bb9e7c2012-01-30 14:57:54 -080070 if (DBusAdaptor::SetProperty(ipconfig_->mutable_store(),
71 name,
72 value,
73 &error)) {
Chris Masonec6c6c132011-06-30 11:29:52 -070074 PropertyChanged(name, value);
75 }
76}
77
mukesh agrawal4d0401c2012-01-06 16:05:31 -080078void IPConfigDBusAdaptor::ClearProperty(const std::string &name,
mukesh agrawal8abd2f62012-01-30 14:56:14 -080079 ::DBus::Error &error) {
80 DBusAdaptor::ClearProperty(ipconfig_->mutable_store(), name, &error);
Chris Masonec6c6c132011-06-30 11:29:52 -070081}
82
mukesh agrawal1830fa12011-09-26 14:31:40 -070083void IPConfigDBusAdaptor::Remove(::DBus::Error &/*error*/) {
Chris Masonec6c6c132011-06-30 11:29:52 -070084}
85
mukesh agrawal1830fa12011-09-26 14:31:40 -070086void IPConfigDBusAdaptor::MoveBefore(const ::DBus::Path& /*path*/,
87 ::DBus::Error &/*error*/) {
Chris Masonec6c6c132011-06-30 11:29:52 -070088}
89
mukesh agrawal1830fa12011-09-26 14:31:40 -070090void IPConfigDBusAdaptor::MoveAfter(const ::DBus::Path& /*path*/,
91 ::DBus::Error &/*error*/) {
Chris Masonec6c6c132011-06-30 11:29:52 -070092}
93
94} // namespace shill