blob: 5deb7285e9a4e6222b71094016ba036843ffd50c [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"
mukesh agrawal06175d72012-04-23 16:46:01 -070011#include "shill/scope_logger.h"
Darin Petkova9b1fed2012-02-29 11:49:05 +010012
13using std::map;
14using std::string;
15
16namespace shill {
17
18// static
Darin Petkova9b1fed2012-02-29 11:49:05 +010019const char RPCTaskDBusAdaptor::kPath[] = "/task/";
20
21RPCTaskDBusAdaptor::RPCTaskDBusAdaptor(DBus::Connection *conn, RPCTask *task)
22 : DBusAdaptor(conn, kPath + task->UniqueName()),
23 task_(task),
mukesh agrawald1511fe2012-03-14 17:12:27 -070024 interface_name_(SHILL_INTERFACE ".Task"),
Darin Petkova9b1fed2012-02-29 11:49:05 +010025 connection_name_(conn->unique_name()) {}
26
27RPCTaskDBusAdaptor::~RPCTaskDBusAdaptor() {
28 task_ = NULL;
29}
30
31const string &RPCTaskDBusAdaptor::GetRpcIdentifier() {
32 return DBus::Object::path();
33}
34
35const string &RPCTaskDBusAdaptor::GetRpcInterfaceIdentifier() {
36 // TODO(petkov): We should be able to return DBus::Interface::name() or simply
37 // name() and avoid the need for the |interface_name_| data member. However,
38 // that's non-trivial due to multiple inheritance (crosbug.com/27058).
39 return interface_name_;
40}
41
42const string &RPCTaskDBusAdaptor::GetRpcConnectionIdentifier() {
43 return connection_name_;
44}
45
Darin Petkov209e6292012-04-20 11:33:32 +020046void RPCTaskDBusAdaptor::getsec(
47 string &user, string &password, DBus::Error &error) {
mukesh agrawal06175d72012-04-23 16:46:01 -070048 SLOG(DBus, 2) << __func__ << ": " << user;
Darin Petkov209e6292012-04-20 11:33:32 +020049 task_->GetLogin(&user, &password);
50}
51
Darin Petkova9b1fed2012-02-29 11:49:05 +010052void RPCTaskDBusAdaptor::notify(const string &reason,
53 const map<string, string> &dict,
54 DBus::Error &/*error*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -070055 SLOG(DBus, 2) << __func__ << ": " << reason;
Darin Petkova9b1fed2012-02-29 11:49:05 +010056 task_->Notify(reason, dict);
57}
58
59} // namespace shill