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 | |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 16 | namespace Logging { |
| 17 | static auto kModuleLogScope = ScopeLogger::kDBus; |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 18 | static string ObjectID(RPCTaskDBusAdaptor* r) { return r->GetRpcIdentifier(); } |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 19 | } |
| 20 | |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 21 | // static |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 22 | const char RPCTaskDBusAdaptor::kPath[] = "/task/"; |
| 23 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 24 | RPCTaskDBusAdaptor::RPCTaskDBusAdaptor(DBus::Connection* conn, RPCTask* task) |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 25 | : DBusAdaptor(conn, kPath + task->UniqueName()), |
| 26 | task_(task), |
mukesh agrawal | d1511fe | 2012-03-14 17:12:27 -0700 | [diff] [blame] | 27 | interface_name_(SHILL_INTERFACE ".Task"), |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 28 | connection_name_(conn->unique_name()) {} |
| 29 | |
| 30 | RPCTaskDBusAdaptor::~RPCTaskDBusAdaptor() { |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 31 | task_ = nullptr; |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 32 | } |
| 33 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 34 | const string& RPCTaskDBusAdaptor::GetRpcIdentifier() { |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 35 | return DBus::Object::path(); |
| 36 | } |
| 37 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 38 | const string& RPCTaskDBusAdaptor::GetRpcInterfaceIdentifier() { |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 39 | // TODO(petkov): We should be able to return DBus::Interface::name() or simply |
| 40 | // name() and avoid the need for the |interface_name_| data member. However, |
Paul Stewart | ee6b3d7 | 2013-07-12 16:07:51 -0700 | [diff] [blame] | 41 | // that's non-trivial due to multiple inheritance (crbug.com/209869). |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 42 | return interface_name_; |
| 43 | } |
| 44 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 45 | const string& RPCTaskDBusAdaptor::GetRpcConnectionIdentifier() { |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 46 | return connection_name_; |
| 47 | } |
| 48 | |
Darin Petkov | 209e629 | 2012-04-20 11:33:32 +0200 | [diff] [blame] | 49 | void RPCTaskDBusAdaptor::getsec( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 50 | string& user, string& password, DBus::Error& error) { // NOLINT |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 51 | SLOG(this, 2) << __func__ << ": " << user; |
Darin Petkov | 209e629 | 2012-04-20 11:33:32 +0200 | [diff] [blame] | 52 | task_->GetLogin(&user, &password); |
| 53 | } |
| 54 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 55 | void RPCTaskDBusAdaptor::notify(const string& reason, |
| 56 | const map<string, string>& dict, |
| 57 | DBus::Error& /*error*/) { // NOLINT |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 58 | SLOG(this, 2) << __func__ << ": " << reason; |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 59 | task_->Notify(reason, dict); |
| 60 | } |
| 61 | |
| 62 | } // namespace shill |