Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: powerman.cc

Issue 3771002: power_manager: Send BrightnessChanged signal. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/power_manager.git
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « powerd.cc ('k') | util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdio.h> 6 #include <stdio.h>
7 #include <dbus/dbus-shared.h> 7 #include <dbus/dbus-shared.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <sys/wait.h> 9 #include <sys/wait.h>
10 #include <gdk/gdkx.h> 10 #include <gdk/gdkx.h>
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 util::kShutdownSignal)) { 165 util::kShutdownSignal)) {
166 LOG(INFO) << "Shutdown event"; 166 LOG(INFO) << "Shutdown event";
167 LOG(INFO) << "power button is " 167 LOG(INFO) << "power button is "
168 << (daemon->power_button_state_ == kPowerButtonDown? 168 << (daemon->power_button_state_ == kPowerButtonDown?
169 "down.":"up."); 169 "down.":"up.");
170 daemon->Shutdown(); 170 daemon->Shutdown();
171 } else if (dbus_message_is_signal(message, util::kLowerPowerManagerInterface, 171 } else if (dbus_message_is_signal(message, util::kLowerPowerManagerInterface,
172 util::kRequestCleanShutdown)) { 172 util::kRequestCleanShutdown)) {
173 LOG(INFO) << "Request Clean Shutdown"; 173 LOG(INFO) << "Request Clean Shutdown";
174 util::Launch("initctl emit power-manager-clean-shutdown"); 174 util::Launch("initctl emit power-manager-clean-shutdown");
175 } else if (dbus_message_is_signal(message, util::kPowerManagerInterface, 175 } else if (dbus_message_is_signal(message, kPowerManagerInterface,
176 util::kPowerStateChanged)) { 176 util::kPowerStateChanged)) {
177 LOG(INFO) << "Power state change event"; 177 LOG(INFO) << "Power state change event";
178 const char *state = '\0'; 178 const char *state = '\0';
179 DBusError error; 179 DBusError error;
180 dbus_error_init(&error); 180 dbus_error_init(&error);
181 181
182 if (dbus_message_get_args(message, &error, DBUS_TYPE_STRING, &state, 182 if (dbus_message_get_args(message, &error, DBUS_TYPE_STRING, &state,
183 DBUS_TYPE_INVALID) == FALSE) { 183 DBUS_TYPE_INVALID) == FALSE) {
184 LOG(WARNING) << "Trouble reading args of PowerStateChange event " 184 LOG(WARNING) << "Trouble reading args of PowerStateChange event "
185 << state; 185 << state;
(...skipping 14 matching lines...) Expand all
200 } else { 200 } else {
201 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 201 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
202 } 202 }
203 return DBUS_HANDLER_RESULT_HANDLED; 203 return DBUS_HANDLER_RESULT_HANDLED;
204 } 204 }
205 205
206 void PowerManDaemon::DBusNameOwnerChangedHandler( 206 void PowerManDaemon::DBusNameOwnerChangedHandler(
207 DBusGProxy*, const gchar* name, const gchar* old_owner, 207 DBusGProxy*, const gchar* name, const gchar* old_owner,
208 const gchar* new_owner, void *data) { 208 const gchar* new_owner, void *data) {
209 PowerManDaemon* daemon = static_cast<PowerManDaemon*>(data); 209 PowerManDaemon* daemon = static_cast<PowerManDaemon*>(data);
210 if (strcmp(name, util::kPowerManagerInterface) == 0) { 210 if (strcmp(name, kPowerManagerInterface) == 0) {
211 DLOG(INFO) << "name:" << name << " old_owner:" << old_owner 211 DLOG(INFO) << "name:" << name << " old_owner:" << old_owner
212 << " new_owner:" << new_owner; 212 << " new_owner:" << new_owner;
213 daemon->powerd_id_++; 213 daemon->powerd_id_++;
214 if (strlen(new_owner) == 0) { 214 if (strlen(new_owner) == 0) {
215 daemon->powerd_state_ = kPowerManagerDead; 215 daemon->powerd_state_ = kPowerManagerDead;
216 LOG(WARNING) << "Powerd has stopped"; 216 LOG(WARNING) << "Powerd has stopped";
217 } else if (strlen(old_owner) == 0) { 217 } else if (strlen(old_owner) == 0) {
218 daemon->powerd_state_ = kPowerManagerAlive; 218 daemon->powerd_state_ = kPowerManagerAlive;
219 LOG(INFO) << "Powerd has started"; 219 LOG(INFO) << "Powerd has started";
220 } else { 220 } else {
(...skipping 14 matching lines...) Expand all
235 LOG(ERROR) << "Failed to add a match:" << error.name << ", message=" 235 LOG(ERROR) << "Failed to add a match:" << error.name << ", message="
236 << error.message; 236 << error.message;
237 NOTREACHED(); 237 NOTREACHED();
238 } 238 }
239 } 239 }
240 240
241 void PowerManDaemon::RegisterDBusMessageHandler() { 241 void PowerManDaemon::RegisterDBusMessageHandler() {
242 DBusConnection* connection = dbus_g_connection_get_connection( 242 DBusConnection* connection = dbus_g_connection_get_connection(
243 chromeos::dbus::GetSystemBusConnection().g_connection()); 243 chromeos::dbus::GetSystemBusConnection().g_connection());
244 AddDBusMatch(connection, util::kLowerPowerManagerInterface); 244 AddDBusMatch(connection, util::kLowerPowerManagerInterface);
245 AddDBusMatch(connection, util::kPowerManagerInterface); 245 AddDBusMatch(connection, kPowerManagerInterface);
246 CHECK(dbus_connection_add_filter( 246 CHECK(dbus_connection_add_filter(
247 connection, &DBusMessageHandler, this, NULL)); 247 connection, &DBusMessageHandler, this, NULL));
248 248
249 DBusGProxy* proxy = dbus_g_proxy_new_for_name( 249 DBusGProxy* proxy = dbus_g_proxy_new_for_name(
250 chromeos::dbus::GetSystemBusConnection().g_connection(), 250 chromeos::dbus::GetSystemBusConnection().g_connection(),
251 DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); 251 DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
252 252
253 if (NULL == proxy) { 253 if (NULL == proxy) {
254 LOG(ERROR) << "Failed to connect to freedesktop dbus server."; 254 LOG(ERROR) << "Failed to connect to freedesktop dbus server.";
255 NOTREACHED(); 255 NOTREACHED();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 exit(fork() == 0 ? wait(NULL), system("powerd_suspend") : 0); 303 exit(fork() == 0 ? wait(NULL), system("powerd_suspend") : 0);
304 } else if (pid > 0) { 304 } else if (pid > 0) {
305 suspend_pid_ = pid; 305 suspend_pid_ = pid;
306 waitpid(pid, NULL, 0); 306 waitpid(pid, NULL, 0);
307 } else { 307 } else {
308 LOG(ERROR) << "Fork for suspend failed"; 308 LOG(ERROR) << "Fork for suspend failed";
309 } 309 }
310 } 310 }
311 311
312 } // namespace power_manager 312 } // namespace power_manager
OLDNEW
« no previous file with comments | « powerd.cc ('k') | util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698