blob: 2531e15ef40199757c2e5e9265a9337556b4fe19 [file] [log] [blame]
mukesh agrawal7c1fece2012-01-13 11:31:27 -08001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Darin Petkov394b7d42011-11-03 15:48:02 +01002// 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/power_manager_proxy.h"
6
7#include <base/logging.h>
8#include <chromeos/dbus/service_constants.h>
9
mukesh agrawal7c1fece2012-01-13 11:31:27 -080010using std::string;
11
Darin Petkov394b7d42011-11-03 15:48:02 +010012namespace shill {
13
14PowerManagerProxy::PowerManagerProxy(PowerManagerProxyDelegate *delegate,
15 DBus::Connection *connection)
16 : proxy_(delegate, connection) {}
17
18PowerManagerProxy::~PowerManagerProxy() {}
19
20void PowerManagerProxy::RegisterSuspendDelay(uint32 delay_ms) {
21 proxy_.RegisterSuspendDelay(delay_ms);
22}
23
24PowerManagerProxy::Proxy::Proxy(PowerManagerProxyDelegate *delegate,
25 DBus::Connection *connection)
26 : DBus::ObjectProxy(*connection,
mukesh agrawal5c05b292012-03-07 10:12:52 -080027 power_manager::kPowerManagerServicePath,
Darin Petkov394b7d42011-11-03 15:48:02 +010028 power_manager::kPowerManagerServiceName),
29 delegate_(delegate) {}
30
31PowerManagerProxy::Proxy::~Proxy() {}
32
mukesh agrawal5c05b292012-03-07 10:12:52 -080033// TODO(quiche): make this signal work again. crosbug.com/27475
Darin Petkov394b7d42011-11-03 15:48:02 +010034void PowerManagerProxy::Proxy::SuspendDelay(const uint32_t &sequence_number) {
35 VLOG(2) << __func__ << "(" << sequence_number << ")";
36 delegate_->OnSuspendDelay(sequence_number);
37}
38
mukesh agrawal7c1fece2012-01-13 11:31:27 -080039void PowerManagerProxy::Proxy::PowerStateChanged(
40 const string &new_power_state) {
41 VLOG(2) << __func__ << "(" << new_power_state << ")";
42
43 PowerManagerProxyDelegate::SuspendState suspend_state;
44 if (new_power_state == "on") {
45 suspend_state = PowerManagerProxyDelegate::kOn;
46 } else if (new_power_state == "standby") {
47 suspend_state = PowerManagerProxyDelegate::kStandby;
48 } else if (new_power_state == "mem") {
49 suspend_state = PowerManagerProxyDelegate::kMem;
50 } else if (new_power_state == "disk") {
51 suspend_state = PowerManagerProxyDelegate::kDisk;
52 } else {
53 suspend_state = PowerManagerProxyDelegate::kUnknown;
54 }
55 delegate_->OnPowerStateChanged(suspend_state);
56}
57
Darin Petkov394b7d42011-11-03 15:48:02 +010058} // namespace shill