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 | |
| 5 | #include "shill/service_dbus_adaptor.h" |
| 6 | |
| 7 | #include <map> |
| 8 | #include <string> |
| 9 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 10 | #include <base/logging.h> |
| 11 | |
| 12 | #include "shill/error.h" |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 13 | #include "shill/service.h" |
| 14 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 15 | using std::map; |
| 16 | using std::string; |
| 17 | |
| 18 | namespace shill { |
| 19 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 20 | // static |
| 21 | const char ServiceDBusAdaptor::kInterfaceName[] = SHILL_INTERFACE; |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 22 | // static |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 23 | const char ServiceDBusAdaptor::kPath[] = "/service/"; |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 24 | |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 25 | ServiceDBusAdaptor::ServiceDBusAdaptor(DBus::Connection* conn, Service *service) |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 26 | : DBusAdaptor(conn, kPath + service->UniqueName()), |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 27 | service_(service) {} |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 28 | |
| 29 | ServiceDBusAdaptor::~ServiceDBusAdaptor() { |
| 30 | service_ = NULL; |
| 31 | } |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 32 | |
| 33 | void ServiceDBusAdaptor::UpdateConnected() {} |
| 34 | |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 35 | void ServiceDBusAdaptor::EmitBoolChanged(const std::string& name, bool value) { |
| 36 | PropertyChanged(name, DBusAdaptor::BoolToVariant(value)); |
| 37 | } |
| 38 | |
| 39 | void ServiceDBusAdaptor::EmitUintChanged(const std::string& name, |
| 40 | uint32 value) { |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 41 | PropertyChanged(name, DBusAdaptor::Uint32ToVariant(value)); |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | void ServiceDBusAdaptor::EmitIntChanged(const std::string& name, int value) { |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 45 | PropertyChanged(name, DBusAdaptor::Int32ToVariant(value)); |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | void ServiceDBusAdaptor::EmitStringChanged(const std::string& name, |
| 49 | const std::string& value) { |
| 50 | PropertyChanged(name, DBusAdaptor::StringToVariant(value)); |
| 51 | |
| 52 | } |
| 53 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 54 | map<string, ::DBus::Variant> ServiceDBusAdaptor::GetProperties( |
| 55 | ::DBus::Error &error) { |
Chris Masone | a8a2c25 | 2011-06-27 22:16:30 -0700 | [diff] [blame] | 56 | map<string, ::DBus::Variant> properties; |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 57 | DBusAdaptor::GetProperties(service_->store(), &properties, &error); |
Chris Masone | a8a2c25 | 2011-06-27 22:16:30 -0700 | [diff] [blame] | 58 | return properties; |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 59 | } |
| 60 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 61 | void ServiceDBusAdaptor::SetProperty(const string& name, |
| 62 | const ::DBus::Variant& value, |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 63 | ::DBus::Error &error) { |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 64 | DBusAdaptor::DispatchOnType(service_->store(), name, value, &error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | void ServiceDBusAdaptor::ClearProperty(const string& , ::DBus::Error &error) { |
| 68 | } |
| 69 | |
| 70 | void ServiceDBusAdaptor::Connect(::DBus::Error &error) { |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 71 | service_->Connect(); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | void ServiceDBusAdaptor::Disconnect(::DBus::Error &error) { |
| 75 | } |
| 76 | |
| 77 | void ServiceDBusAdaptor::Remove(::DBus::Error &error) { |
| 78 | } |
| 79 | |
| 80 | void ServiceDBusAdaptor::MoveBefore(const ::DBus::Path& , |
| 81 | ::DBus::Error &error) { |
| 82 | } |
| 83 | |
| 84 | void ServiceDBusAdaptor::MoveAfter(const ::DBus::Path& , |
| 85 | ::DBus::Error &error) { |
| 86 | } |
| 87 | |
| 88 | void ServiceDBusAdaptor::ActivateCellularModem(const string& , |
| 89 | ::DBus::Error &error) { |
| 90 | } |
| 91 | |
| 92 | } // namespace shill |