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