Chris Masone | 52cd19b | 2011-06-29 17:23:04 -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/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 | |
| 17 | using std::map; |
| 18 | using std::string; |
| 19 | using std::vector; |
| 20 | |
| 21 | namespace shill { |
| 22 | |
| 23 | // static |
| 24 | const char ProfileDBusAdaptor::kInterfaceName[] = SHILL_INTERFACE; |
| 25 | // static |
| 26 | const char ProfileDBusAdaptor::kPath[] = "/profile/"; |
| 27 | |
| 28 | ProfileDBusAdaptor::ProfileDBusAdaptor(DBus::Connection* conn, Profile *profile) |
Chris Masone | 7df0c67 | 2011-07-15 10:24:54 -0700 | [diff] [blame] | 29 | : DBusAdaptor(conn, kPath + profile->GetFriendlyName()), |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 30 | profile_(profile) { |
| 31 | } |
| 32 | |
| 33 | ProfileDBusAdaptor::~ProfileDBusAdaptor() { |
| 34 | profile_ = NULL; |
| 35 | } |
| 36 | |
| 37 | void ProfileDBusAdaptor::EmitBoolChanged(const string &name, bool value) { |
| 38 | PropertyChanged(name, DBusAdaptor::BoolToVariant(value)); |
| 39 | } |
| 40 | |
| 41 | void ProfileDBusAdaptor::EmitUintChanged(const string &name, |
| 42 | uint32 value) { |
| 43 | PropertyChanged(name, DBusAdaptor::Uint32ToVariant(value)); |
| 44 | } |
| 45 | |
| 46 | void ProfileDBusAdaptor::EmitIntChanged(const string &name, int value) { |
| 47 | PropertyChanged(name, DBusAdaptor::Int32ToVariant(value)); |
| 48 | } |
| 49 | |
| 50 | void ProfileDBusAdaptor::EmitStringChanged(const string &name, |
| 51 | const string &value) { |
| 52 | PropertyChanged(name, DBusAdaptor::StringToVariant(value)); |
| 53 | } |
| 54 | |
| 55 | map<string, ::DBus::Variant> ProfileDBusAdaptor::GetProperties( |
| 56 | ::DBus::Error &error) { |
| 57 | map<string, ::DBus::Variant> properties; |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 58 | DBusAdaptor::GetProperties(profile_->store(), &properties, &error); |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 59 | return properties; |
| 60 | } |
| 61 | |
| 62 | void ProfileDBusAdaptor::SetProperty(const string &name, |
| 63 | const ::DBus::Variant &value, |
| 64 | ::DBus::Error &error) { |
mukesh agrawal | de29fa8 | 2011-09-16 16:16:36 -0700 | [diff] [blame] | 65 | if (DBusAdaptor::DispatchOnType(profile_->mutable_store(), |
| 66 | name, |
| 67 | value, |
| 68 | &error)) { |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 69 | PropertyChanged(name, value); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | map<string, ::DBus::Variant> ProfileDBusAdaptor::GetEntry( |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 74 | const std::string& /*name*/, |
| 75 | ::DBus::Error &/*error*/) { |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 76 | return map<string, ::DBus::Variant>(); |
| 77 | } |
| 78 | |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 79 | void ProfileDBusAdaptor::DeleteEntry(const std::string& /*name*/, |
| 80 | ::DBus::Error &/*error*/) { |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | } // namespace shill |