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) |
| 29 | : DBusAdaptor(conn, kPath), |
| 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) { |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame^] | 65 | if (DBusAdaptor::DispatchOnType(profile_->store(), name, value, &error)) { |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 66 | PropertyChanged(name, value); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | map<string, ::DBus::Variant> ProfileDBusAdaptor::GetEntry( |
| 71 | const std::string& name, |
| 72 | ::DBus::Error &error) { |
| 73 | return map<string, ::DBus::Variant>(); |
| 74 | } |
| 75 | |
| 76 | void ProfileDBusAdaptor::DeleteEntry(const std::string& name, |
| 77 | ::DBus::Error &error) { |
| 78 | } |
| 79 | |
| 80 | } // namespace shill |