Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 1 | // Copyright (c) 2012 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/rpc_task_dbus_adaptor.h" |
| 6 | |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 7 | #include "shill/error.h" |
Christopher Wiley | b691efd | 2012-08-09 13:51:51 -0700 | [diff] [blame] | 8 | #include "shill/logging.h" |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 9 | #include "shill/rpc_task.h" |
| 10 | |
| 11 | using std::map; |
| 12 | using std::string; |
| 13 | |
| 14 | namespace shill { |
| 15 | |
| 16 | // static |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 17 | const char RPCTaskDBusAdaptor::kPath[] = "/task/"; |
| 18 | |
| 19 | RPCTaskDBusAdaptor::RPCTaskDBusAdaptor(DBus::Connection *conn, RPCTask *task) |
| 20 | : DBusAdaptor(conn, kPath + task->UniqueName()), |
| 21 | task_(task), |
mukesh agrawal | d1511fe | 2012-03-14 17:12:27 -0700 | [diff] [blame] | 22 | interface_name_(SHILL_INTERFACE ".Task"), |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 23 | connection_name_(conn->unique_name()) {} |
| 24 | |
| 25 | RPCTaskDBusAdaptor::~RPCTaskDBusAdaptor() { |
| 26 | task_ = NULL; |
| 27 | } |
| 28 | |
| 29 | const string &RPCTaskDBusAdaptor::GetRpcIdentifier() { |
| 30 | return DBus::Object::path(); |
| 31 | } |
| 32 | |
| 33 | const string &RPCTaskDBusAdaptor::GetRpcInterfaceIdentifier() { |
| 34 | // TODO(petkov): We should be able to return DBus::Interface::name() or simply |
| 35 | // name() and avoid the need for the |interface_name_| data member. However, |
| 36 | // that's non-trivial due to multiple inheritance (crosbug.com/27058). |
| 37 | return interface_name_; |
| 38 | } |
| 39 | |
| 40 | const string &RPCTaskDBusAdaptor::GetRpcConnectionIdentifier() { |
| 41 | return connection_name_; |
| 42 | } |
| 43 | |
Darin Petkov | 209e629 | 2012-04-20 11:33:32 +0200 | [diff] [blame] | 44 | void RPCTaskDBusAdaptor::getsec( |
| 45 | string &user, string &password, DBus::Error &error) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 46 | SLOG(DBus, 2) << __func__ << ": " << user; |
Darin Petkov | 209e629 | 2012-04-20 11:33:32 +0200 | [diff] [blame] | 47 | task_->GetLogin(&user, &password); |
| 48 | } |
| 49 | |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 50 | void RPCTaskDBusAdaptor::notify(const string &reason, |
| 51 | const map<string, string> &dict, |
| 52 | DBus::Error &/*error*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 53 | SLOG(DBus, 2) << __func__ << ": " << reason; |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 54 | task_->Notify(reason, dict); |
| 55 | } |
| 56 | |
| 57 | } // namespace shill |