mukesh agrawal | af57195 | 2011-07-14 14:31:12 -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 | |
Darin Petkov | ef34f18 | 2011-08-26 14:14:40 -0700 | [diff] [blame] | 5 | #include "shill/supplicant_process_proxy.h" |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 6 | |
| 7 | #include <map> |
| 8 | #include <string> |
| 9 | |
| 10 | #include <base/logging.h> |
| 11 | #include <dbus-c++/dbus.h> |
| 12 | |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 13 | #include "shill/dbus_properties.h" |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 14 | #include "shill/scope_logger.h" |
| 15 | |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 16 | using std::map; |
| 17 | using std::string; |
| 18 | |
| 19 | namespace shill { |
| 20 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 21 | SupplicantProcessProxy::SupplicantProcessProxy(DBus::Connection *bus, |
| 22 | const char *dbus_path, |
| 23 | const char *dbus_addr) |
| 24 | : proxy_(bus, dbus_path, dbus_addr) {} |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 25 | |
| 26 | SupplicantProcessProxy::~SupplicantProcessProxy() {} |
| 27 | |
| 28 | ::DBus::Path SupplicantProcessProxy::CreateInterface( |
| 29 | const map<string, ::DBus::Variant> &args) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 30 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 31 | try { |
| 32 | return proxy_.CreateInterface(args); |
| 33 | } catch (const DBus::Error &e) { |
Gary Morain | ba919ac | 2012-05-08 11:30:20 -0700 | [diff] [blame] | 34 | LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what() |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 35 | << " args keys are: " << DBusProperties::KeysToString(args); |
Gary Morain | ba919ac | 2012-05-08 11:30:20 -0700 | [diff] [blame] | 36 | throw; // Re-throw the exception. |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 37 | } |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | void SupplicantProcessProxy::RemoveInterface(const ::DBus::Path &path) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 41 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 42 | try { |
| 43 | return proxy_.RemoveInterface(path); |
| 44 | } catch (const DBus::Error &e) { |
| 45 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 46 | } |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | ::DBus::Path SupplicantProcessProxy::GetInterface(const string &ifname) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 50 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 51 | try { |
| 52 | return proxy_.GetInterface(ifname); |
| 53 | } catch (const DBus::Error &e) { |
| 54 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what() |
| 55 | << " ifname: " << ifname; |
| 56 | return ::DBus::Path(); // Make the compiler happy. |
| 57 | } |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | // definitions for private class SupplicantProcessProxy::Proxy |
| 61 | |
| 62 | SupplicantProcessProxy::Proxy::Proxy( |
| 63 | DBus::Connection *bus, const char *dbus_path, const char *dbus_addr) |
| 64 | : DBus::ObjectProxy(*bus, dbus_path, dbus_addr) {} |
| 65 | |
| 66 | SupplicantProcessProxy::Proxy::~Proxy() {} |
| 67 | |
| 68 | void SupplicantProcessProxy::Proxy::InterfaceAdded( |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 69 | const ::DBus::Path& /*path*/, |
| 70 | const map<string, ::DBus::Variant> &/*properties*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 71 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 72 | // XXX |
| 73 | } |
| 74 | |
| 75 | void SupplicantProcessProxy::Proxy::InterfaceRemoved( |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 76 | const ::DBus::Path& /*path*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 77 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 78 | // XXX |
| 79 | } |
| 80 | |
| 81 | void SupplicantProcessProxy::Proxy::PropertiesChanged( |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 82 | const map<string, ::DBus::Variant>& /*properties*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 83 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 84 | // XXX |
| 85 | } |
| 86 | |
| 87 | } // namespace shill |