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