Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 1 | // 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 Masone | 0756f23 | 2011-07-21 17:24:00 -0700 | [diff] [blame^] | 12 | #include <base/stringprintf.h> |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 13 | #include <dbus-c++/dbus.h> |
| 14 | |
| 15 | #include "shill/error.h" |
| 16 | #include "shill/ipconfig.h" |
| 17 | |
Chris Masone | 0756f23 | 2011-07-21 17:24:00 -0700 | [diff] [blame^] | 18 | using base::StringPrintf; |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 19 | using std::map; |
| 20 | using std::string; |
| 21 | using std::vector; |
| 22 | |
| 23 | namespace shill { |
| 24 | |
| 25 | // static |
| 26 | const char IPConfigDBusAdaptor::kInterfaceName[] = SHILL_INTERFACE; |
| 27 | // static |
Chris Masone | 0756f23 | 2011-07-21 17:24:00 -0700 | [diff] [blame^] | 28 | const char IPConfigDBusAdaptor::kPath[] = "/ipconfig/"; |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 29 | |
| 30 | IPConfigDBusAdaptor::IPConfigDBusAdaptor(DBus::Connection* conn, |
| 31 | IPConfig *config) |
Chris Masone | 0756f23 | 2011-07-21 17:24:00 -0700 | [diff] [blame^] | 32 | : DBusAdaptor(conn, StringPrintf("%s%s_%u_%s", |
| 33 | kPath, |
| 34 | config->device_name().c_str(), |
| 35 | config->serial(), |
| 36 | config->type().c_str())), |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 37 | ipconfig_(config) { |
| 38 | } |
| 39 | |
| 40 | IPConfigDBusAdaptor::~IPConfigDBusAdaptor() { |
| 41 | ipconfig_ = NULL; |
| 42 | } |
| 43 | |
| 44 | void IPConfigDBusAdaptor::EmitBoolChanged(const string &name, bool value) { |
| 45 | PropertyChanged(name, DBusAdaptor::BoolToVariant(value)); |
| 46 | } |
| 47 | |
| 48 | void IPConfigDBusAdaptor::EmitUintChanged(const string &name, |
| 49 | uint32 value) { |
| 50 | PropertyChanged(name, DBusAdaptor::Uint32ToVariant(value)); |
| 51 | } |
| 52 | |
| 53 | void IPConfigDBusAdaptor::EmitIntChanged(const string &name, int value) { |
| 54 | PropertyChanged(name, DBusAdaptor::Int32ToVariant(value)); |
| 55 | } |
| 56 | |
| 57 | void IPConfigDBusAdaptor::EmitStringChanged(const string &name, |
| 58 | const string &value) { |
| 59 | PropertyChanged(name, DBusAdaptor::StringToVariant(value)); |
| 60 | } |
| 61 | |
| 62 | map<string, ::DBus::Variant> IPConfigDBusAdaptor::GetProperties( |
| 63 | ::DBus::Error &error) { |
| 64 | map<string, ::DBus::Variant> properties; |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 65 | DBusAdaptor::GetProperties(ipconfig_->store(), &properties, &error); |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 66 | return properties; |
| 67 | } |
| 68 | |
| 69 | void IPConfigDBusAdaptor::SetProperty(const string &name, |
| 70 | const ::DBus::Variant &value, |
| 71 | ::DBus::Error &error) { |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 72 | if (DBusAdaptor::DispatchOnType(ipconfig_->store(), name, value, &error)) { |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 73 | PropertyChanged(name, value); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | void IPConfigDBusAdaptor::ClearProperty(const std::string& name, |
| 78 | ::DBus::Error &error) { |
| 79 | } |
| 80 | |
| 81 | void IPConfigDBusAdaptor::Remove(::DBus::Error &error) { |
| 82 | } |
| 83 | |
| 84 | void IPConfigDBusAdaptor::MoveBefore(const ::DBus::Path& path, |
| 85 | ::DBus::Error &error) { |
| 86 | } |
| 87 | |
| 88 | void IPConfigDBusAdaptor::MoveAfter(const ::DBus::Path& path, |
| 89 | ::DBus::Error &error) { |
| 90 | } |
| 91 | |
| 92 | } // namespace shill |