blob: 771f47b2715e59f4f8b258c229e6cc6d2f444398 [file] [log] [blame]
mukesh agrawalaf571952011-07-14 14:31:12 -07001// 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 Petkovef34f182011-08-26 14:14:40 -07005#include "shill/supplicant_process_proxy.h"
mukesh agrawalaf571952011-07-14 14:31:12 -07006
7#include <map>
8#include <string>
9
mukesh agrawalaf571952011-07-14 14:31:12 -070010#include <dbus-c++/dbus.h>
11
Gary Morain610977f2012-05-04 16:03:52 -070012#include "shill/dbus_properties.h"
Christopher Wileyb691efd2012-08-09 13:51:51 -070013#include "shill/logging.h"
mukesh agrawal06175d72012-04-23 16:46:01 -070014
mukesh agrawalaf571952011-07-14 14:31:12 -070015using std::map;
16using std::string;
17
18namespace shill {
19
Darin Petkovaceede32011-07-18 15:32:38 -070020SupplicantProcessProxy::SupplicantProcessProxy(DBus::Connection *bus,
21 const char *dbus_path,
22 const char *dbus_addr)
23 : proxy_(bus, dbus_path, dbus_addr) {}
mukesh agrawalaf571952011-07-14 14:31:12 -070024
25SupplicantProcessProxy::~SupplicantProcessProxy() {}
26
27::DBus::Path SupplicantProcessProxy::CreateInterface(
28 const map<string, ::DBus::Variant> &args) {
mukesh agrawal06175d72012-04-23 16:46:01 -070029 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070030 try {
31 return proxy_.CreateInterface(args);
32 } catch (const DBus::Error &e) {
Gary Morainba919ac2012-05-08 11:30:20 -070033 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what()
Gary Morain610977f2012-05-04 16:03:52 -070034 << " args keys are: " << DBusProperties::KeysToString(args);
Gary Morainba919ac2012-05-08 11:30:20 -070035 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -070036 }
mukesh agrawalaf571952011-07-14 14:31:12 -070037}
38
39void SupplicantProcessProxy::RemoveInterface(const ::DBus::Path &path) {
mukesh agrawal06175d72012-04-23 16:46:01 -070040 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070041 try {
42 return proxy_.RemoveInterface(path);
43 } catch (const DBus::Error &e) {
44 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
45 }
mukesh agrawalaf571952011-07-14 14:31:12 -070046}
47
48::DBus::Path SupplicantProcessProxy::GetInterface(const string &ifname) {
mukesh agrawal06175d72012-04-23 16:46:01 -070049 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070050 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 agrawalaf571952011-07-14 14:31:12 -070057}
58
Paul Stewart5581d072012-12-17 17:30:20 -080059string 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
68void 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 agrawalaf571952011-07-14 14:31:12 -070076// definitions for private class SupplicantProcessProxy::Proxy
77
78SupplicantProcessProxy::Proxy::Proxy(
79 DBus::Connection *bus, const char *dbus_path, const char *dbus_addr)
80 : DBus::ObjectProxy(*bus, dbus_path, dbus_addr) {}
81
82SupplicantProcessProxy::Proxy::~Proxy() {}
83
84void SupplicantProcessProxy::Proxy::InterfaceAdded(
mukesh agrawal1830fa12011-09-26 14:31:40 -070085 const ::DBus::Path& /*path*/,
86 const map<string, ::DBus::Variant> &/*properties*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -070087 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -070088 // XXX
89}
90
91void SupplicantProcessProxy::Proxy::InterfaceRemoved(
mukesh agrawal1830fa12011-09-26 14:31:40 -070092 const ::DBus::Path& /*path*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -070093 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -070094 // XXX
95}
96
97void SupplicantProcessProxy::Proxy::PropertiesChanged(
mukesh agrawal1830fa12011-09-26 14:31:40 -070098 const map<string, ::DBus::Variant>& /*properties*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -070099 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700100 // XXX
101}
102
103} // namespace shill