mukesh agrawal | 7c1fece | 2012-01-13 11:31:27 -0800 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Darin Petkov | 394b7d4 | 2011-11-03 15:48:02 +0100 | [diff] [blame] | 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/power_manager_proxy.h" |
| 6 | |
| 7 | #include <base/logging.h> |
| 8 | #include <chromeos/dbus/service_constants.h> |
| 9 | |
mukesh agrawal | 7c1fece | 2012-01-13 11:31:27 -0800 | [diff] [blame] | 10 | using std::string; |
| 11 | |
Darin Petkov | 394b7d4 | 2011-11-03 15:48:02 +0100 | [diff] [blame] | 12 | namespace shill { |
| 13 | |
| 14 | PowerManagerProxy::PowerManagerProxy(PowerManagerProxyDelegate *delegate, |
| 15 | DBus::Connection *connection) |
| 16 | : proxy_(delegate, connection) {} |
| 17 | |
| 18 | PowerManagerProxy::~PowerManagerProxy() {} |
| 19 | |
| 20 | void PowerManagerProxy::RegisterSuspendDelay(uint32 delay_ms) { |
| 21 | proxy_.RegisterSuspendDelay(delay_ms); |
| 22 | } |
| 23 | |
| 24 | PowerManagerProxy::Proxy::Proxy(PowerManagerProxyDelegate *delegate, |
| 25 | DBus::Connection *connection) |
| 26 | : DBus::ObjectProxy(*connection, |
mukesh agrawal | 5c05b29 | 2012-03-07 10:12:52 -0800 | [diff] [blame] | 27 | power_manager::kPowerManagerServicePath, |
Darin Petkov | 394b7d4 | 2011-11-03 15:48:02 +0100 | [diff] [blame] | 28 | power_manager::kPowerManagerServiceName), |
| 29 | delegate_(delegate) {} |
| 30 | |
| 31 | PowerManagerProxy::Proxy::~Proxy() {} |
| 32 | |
mukesh agrawal | 5c05b29 | 2012-03-07 10:12:52 -0800 | [diff] [blame] | 33 | // TODO(quiche): make this signal work again. crosbug.com/27475 |
Darin Petkov | 394b7d4 | 2011-11-03 15:48:02 +0100 | [diff] [blame] | 34 | void PowerManagerProxy::Proxy::SuspendDelay(const uint32_t &sequence_number) { |
| 35 | VLOG(2) << __func__ << "(" << sequence_number << ")"; |
| 36 | delegate_->OnSuspendDelay(sequence_number); |
| 37 | } |
| 38 | |
mukesh agrawal | 7c1fece | 2012-01-13 11:31:27 -0800 | [diff] [blame] | 39 | void 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 Petkov | 394b7d4 | 2011-11-03 15:48:02 +0100 | [diff] [blame] | 58 | } // namespace shill |