blob: 7f392956e721962a90c786724aa4702fb799aa9d [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
Darin Petkova9b1fed2012-02-29 11:49:05 +01007#include "shill/error.h"
Christopher Wileyb691efd2012-08-09 13:51:51 -07008#include "shill/logging.h"
Darin Petkova9b1fed2012-02-29 11:49:05 +01009#include "shill/rpc_task.h"
10
11using std::map;
12using std::string;
13
14namespace shill {
15
16// static
Darin Petkova9b1fed2012-02-29 11:49:05 +010017const char RPCTaskDBusAdaptor::kPath[] = "/task/";
18
19RPCTaskDBusAdaptor::RPCTaskDBusAdaptor(DBus::Connection *conn, RPCTask *task)
20 : DBusAdaptor(conn, kPath + task->UniqueName()),
21 task_(task),
mukesh agrawald1511fe2012-03-14 17:12:27 -070022 interface_name_(SHILL_INTERFACE ".Task"),
Darin Petkova9b1fed2012-02-29 11:49:05 +010023 connection_name_(conn->unique_name()) {}
24
25RPCTaskDBusAdaptor::~RPCTaskDBusAdaptor() {
26 task_ = NULL;
27}
28
29const string &RPCTaskDBusAdaptor::GetRpcIdentifier() {
30 return DBus::Object::path();
31}
32
33const 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
40const string &RPCTaskDBusAdaptor::GetRpcConnectionIdentifier() {
41 return connection_name_;
42}
43
Darin Petkov209e6292012-04-20 11:33:32 +020044void RPCTaskDBusAdaptor::getsec(
45 string &user, string &password, DBus::Error &error) {
mukesh agrawal06175d72012-04-23 16:46:01 -070046 SLOG(DBus, 2) << __func__ << ": " << user;
Darin Petkov209e6292012-04-20 11:33:32 +020047 task_->GetLogin(&user, &password);
48}
49
Darin Petkova9b1fed2012-02-29 11:49:05 +010050void RPCTaskDBusAdaptor::notify(const string &reason,
51 const map<string, string> &dict,
52 DBus::Error &/*error*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -070053 SLOG(DBus, 2) << __func__ << ": " << reason;
Darin Petkova9b1fed2012-02-29 11:49:05 +010054 task_->Notify(reason, dict);
55}
56
57} // namespace shill