Chris Masone | d7732e4 | 2011-05-20 11:08:56 -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 | |
Paul Stewart | 28fbfdf | 2011-05-31 09:37:38 -0700 | [diff] [blame] | 5 | #include "shill/device.h" |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 6 | #include "shill/device_dbus_adaptor.h" |
| 7 | |
| 8 | #include <map> |
| 9 | #include <string> |
| 10 | |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 11 | #include "shill/device.h" |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 12 | #include "shill/error.h" |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 13 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 14 | using std::map; |
| 15 | using std::string; |
| 16 | |
| 17 | namespace shill { |
| 18 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 19 | // static |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 20 | const char DeviceDBusAdaptor::kInterfaceName[] = SHILL_INTERFACE; |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 21 | // static |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 22 | const char DeviceDBusAdaptor::kPath[] = "/device/"; |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 23 | |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 24 | DeviceDBusAdaptor::DeviceDBusAdaptor(DBus::Connection* conn, Device *device) |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 25 | : DBusAdaptor(conn, kPath + device->UniqueName()), |
Chris Masone | 4e85161 | 2011-07-01 10:46:53 -0700 | [diff] [blame] | 26 | device_(device), |
| 27 | connection_name_(conn->unique_name()) { |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 28 | } |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 29 | |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 30 | DeviceDBusAdaptor::~DeviceDBusAdaptor() { |
| 31 | device_ = NULL; |
| 32 | } |
Chris Masone | 4e85161 | 2011-07-01 10:46:53 -0700 | [diff] [blame] | 33 | const std::string &DeviceDBusAdaptor::GetRpcIdentifier() { |
| 34 | return path(); |
| 35 | } |
| 36 | |
| 37 | const std::string &DeviceDBusAdaptor::GetRpcConnectionIdentifier() { |
| 38 | return connection_name_; |
| 39 | } |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 40 | |
| 41 | void DeviceDBusAdaptor::UpdateEnabled() {} |
| 42 | |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 43 | void DeviceDBusAdaptor::EmitBoolChanged(const std::string& name, bool value) { |
| 44 | PropertyChanged(name, DBusAdaptor::BoolToVariant(value)); |
| 45 | } |
| 46 | |
| 47 | void DeviceDBusAdaptor::EmitUintChanged(const std::string& name, uint32 value) { |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 48 | PropertyChanged(name, DBusAdaptor::Uint32ToVariant(value)); |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | void DeviceDBusAdaptor::EmitIntChanged(const std::string& name, int value) { |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 52 | PropertyChanged(name, DBusAdaptor::Int32ToVariant(value)); |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | void DeviceDBusAdaptor::EmitStringChanged(const std::string& name, |
| 56 | const std::string& value) { |
| 57 | PropertyChanged(name, DBusAdaptor::StringToVariant(value)); |
| 58 | } |
| 59 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 60 | map<string, ::DBus::Variant> DeviceDBusAdaptor::GetProperties( |
| 61 | ::DBus::Error &error) { |
Chris Masone | a8a2c25 | 2011-06-27 22:16:30 -0700 | [diff] [blame] | 62 | map<string, ::DBus::Variant> properties; |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 63 | DBusAdaptor::GetProperties(device_->store(), &properties, &error); |
Chris Masone | a8a2c25 | 2011-06-27 22:16:30 -0700 | [diff] [blame] | 64 | return properties; |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 65 | } |
| 66 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 67 | void DeviceDBusAdaptor::SetProperty(const string& name, |
| 68 | const ::DBus::Variant& value, |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 69 | ::DBus::Error &error) { |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 70 | DBusAdaptor::DispatchOnType(device_->store(), name, value, &error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 71 | } |
| 72 | |
Chris Masone | ccc8881 | 2011-06-08 18:00:10 -0700 | [diff] [blame] | 73 | void DeviceDBusAdaptor::ClearProperty(const std::string& , |
| 74 | ::DBus::Error &error) { |
| 75 | } |
| 76 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 77 | void DeviceDBusAdaptor::ProposeScan(::DBus::Error &error) { |
| 78 | } |
| 79 | |
| 80 | ::DBus::Path DeviceDBusAdaptor::AddIPConfig(const string& , |
| 81 | ::DBus::Error &error) { |
| 82 | return ::DBus::Path(); |
| 83 | } |
| 84 | |
Chris Masone | ccc8881 | 2011-06-08 18:00:10 -0700 | [diff] [blame] | 85 | void DeviceDBusAdaptor::Register(const std::string& , ::DBus::Error &error) { |
| 86 | } |
| 87 | |
| 88 | void DeviceDBusAdaptor::RequirePin(const std::string& , |
| 89 | const bool& , |
| 90 | ::DBus::Error &error) { |
| 91 | } |
| 92 | |
| 93 | void DeviceDBusAdaptor::EnterPin(const std::string& , ::DBus::Error &error) { |
| 94 | } |
| 95 | |
| 96 | void DeviceDBusAdaptor::UnblockPin(const std::string& , |
| 97 | const std::string& , |
| 98 | ::DBus::Error &error) { |
| 99 | } |
| 100 | |
| 101 | void DeviceDBusAdaptor::ChangePin(const std::string& , |
| 102 | const std::string& , |
| 103 | ::DBus::Error &error) { |
| 104 | } |
| 105 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 106 | } // namespace shill |