OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdlib.h> | 5 #include <stdlib.h> |
6 #include <unistd.h> | 6 #include <unistd.h> |
7 #include <sys/wait.h> | 7 #include <sys/wait.h> |
8 #include <dbus/dbus-glib-lowlevel.h> | 8 #include <dbus/dbus-glib-lowlevel.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "chromeos/dbus/dbus.h" | 11 #include "chromeos/dbus/dbus.h" |
12 #include "chromeos/dbus/service_constants.h" | 12 #include "chromeos/dbus/service_constants.h" |
13 | 13 |
14 namespace power_manager { | 14 namespace power_manager { |
15 | 15 |
16 namespace util { | 16 namespace util { |
17 | 17 |
18 // interface names | 18 // interface names |
19 const char* kPowerManagerInterface = "org.chromium.PowerManager"; | |
20 const char* kLowerPowerManagerInterface = "org.chromium.LowerPowerManager"; | 19 const char* kLowerPowerManagerInterface = "org.chromium.LowerPowerManager"; |
21 | 20 |
22 // powerd -> powerm signals | 21 // powerd -> powerm signals |
23 const char* kRequestCleanShutdown = "RequestCleanShutdown"; | 22 const char* kRequestCleanShutdown = "RequestCleanShutdown"; |
24 const char* kSuspendSignal = "SuspendSignal"; | 23 const char* kSuspendSignal = "SuspendSignal"; |
25 const char* kShutdownSignal = "ShutdownSignal"; | 24 const char* kShutdownSignal = "ShutdownSignal"; |
26 | 25 |
27 // powerm -> powerd signals | 26 // powerm -> powerd signals |
28 const char* kLidClosed = "LidClosed"; | 27 const char* kLidClosed = "LidClosed"; |
29 const char* kLidOpened = "LidOpened"; | 28 const char* kLidOpened = "LidOpened"; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 CHECK(signal); | 80 CHECK(signal); |
82 ::dbus_g_proxy_send(proxy.gproxy(), signal, NULL); | 81 ::dbus_g_proxy_send(proxy.gproxy(), signal, NULL); |
83 ::dbus_message_unref(signal); | 82 ::dbus_message_unref(signal); |
84 } | 83 } |
85 | 84 |
86 // A utility function to send a signal to upper power daemon (powerd). | 85 // A utility function to send a signal to upper power daemon (powerd). |
87 void SendSignalToPowerD(const char* signal_name) { | 86 void SendSignalToPowerD(const char* signal_name) { |
88 LOG(INFO) << "Sending signal '" << signal_name << "' to PowerManager:"; | 87 LOG(INFO) << "Sending signal '" << signal_name << "' to PowerManager:"; |
89 chromeos::dbus::Proxy proxy(chromeos::dbus::GetSystemBusConnection(), | 88 chromeos::dbus::Proxy proxy(chromeos::dbus::GetSystemBusConnection(), |
90 "/", | 89 "/", |
91 power_manager::kPowerManagerInterface); | 90 kPowerManagerInterface); |
92 DBusMessage* signal = ::dbus_message_new_signal( | 91 DBusMessage* signal = ::dbus_message_new_signal( |
93 "/", | 92 "/", |
94 power_manager::kPowerManagerInterface, | 93 kPowerManagerInterface, |
95 signal_name); | 94 signal_name); |
96 CHECK(signal); | 95 CHECK(signal); |
97 ::dbus_g_proxy_send(proxy.gproxy(), signal, NULL); | 96 ::dbus_g_proxy_send(proxy.gproxy(), signal, NULL); |
98 ::dbus_message_unref(signal); | 97 ::dbus_message_unref(signal); |
99 } | 98 } |
100 | 99 |
101 } // namespace util | 100 } // namespace util |
102 | 101 |
103 } // namespace power_manager | 102 } // namespace power_manager |
OLD | NEW |