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 | |
Paul Stewart | 5581d07 | 2012-12-17 17:30:20 -0800 | [diff] [blame] | 59 | string SupplicantProcessProxy::GetDebugLevel() { |
| 60 | try { |
| 61 | return proxy_.DebugLevel(); |
| 62 | } catch (const DBus::Error &e) { |
| 63 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 64 | return ""; // Make the compiler happy. |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | void SupplicantProcessProxy::SetDebugLevel(const string &level) { |
| 69 | try { |
| 70 | proxy_.DebugLevel(level); |
| 71 | } catch (const DBus::Error &e) { |
| 72 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 73 | } |
| 74 | } |
| 75 | |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 76 | // definitions for private class SupplicantProcessProxy::Proxy |
| 77 | |
| 78 | SupplicantProcessProxy::Proxy::Proxy( |
| 79 | DBus::Connection *bus, const char *dbus_path, const char *dbus_addr) |
| 80 | : DBus::ObjectProxy(*bus, dbus_path, dbus_addr) {} |
| 81 | |
| 82 | SupplicantProcessProxy::Proxy::~Proxy() {} |
| 83 | |
| 84 | void SupplicantProcessProxy::Proxy::InterfaceAdded( |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 85 | const ::DBus::Path& /*path*/, |
| 86 | const map<string, ::DBus::Variant> &/*properties*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 87 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 88 | // XXX |
| 89 | } |
| 90 | |
| 91 | void SupplicantProcessProxy::Proxy::InterfaceRemoved( |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 92 | const ::DBus::Path& /*path*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 93 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 94 | // XXX |
| 95 | } |
| 96 | |
| 97 | void SupplicantProcessProxy::Proxy::PropertiesChanged( |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 98 | const map<string, ::DBus::Variant>& /*properties*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 99 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 100 | // XXX |
| 101 | } |
| 102 | |
| 103 | } // namespace shill |