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