[Xfce4-commits] <xfce4-session:console-kit> WIP
Brian J. Tarricone
noreply at xfce.org
Fri Jan 29 07:08:03 CET 2010
Updating branch refs/heads/console-kit
to 9bde2ef1cc7004bbbad8721ebc85bd6dde4136a4 (commit)
from e6993a82aac7a11e5fd997ac35f1cd374ba5c80f (commit)
commit 9bde2ef1cc7004bbbad8721ebc85bd6dde4136a4
Author: Brian J. Tarricone <brian at tarricone.org>
Date: Thu Jul 30 17:06:33 2009 -0700
WIP
xfce4-session/xfsm-shutdown-helper.c | 179 +++++++++++++++++----------------
1 files changed, 92 insertions(+), 87 deletions(-)
diff --git a/xfce4-session/xfsm-shutdown-helper.c b/xfce4-session/xfsm-shutdown-helper.c
index e018c67..6b345d7 100644
--- a/xfce4-session/xfsm-shutdown-helper.c
+++ b/xfce4-session/xfsm-shutdown-helper.c
@@ -800,102 +800,103 @@ xfsm_shutdown_helper_send_command (XfsmShutdownHelper *helper,
g_return_val_if_fail (command != XFSM_SHUTDOWN_ASK
&& command != XFSM_SHUTDOWN_LOGOUT, FALSE);
- switch (command) {
- case XFSM_SHUTDOWN_HALT:
- case XFSM_SHUTDOWN_REBOOT:
- if (helper->shut_backend == XFSM_SHUTDOWN_POWER_MANAGER)
- {
- return xfsm_shutdown_helper_pm_send (helper, command, error);
- }
- else if (helper->shut_backend == XFSM_SHUTDOWN_CONSOLEKIT)
- {
- return xfsm_shutdown_helper_ck_send (helper, command, error);
- }
- else if (helper->shut_backend == XFSM_SHUTDOWN_HAL)
- {
- return xfsm_shutdown_helper_hal_send (helper, command, error);
- }
- else if (helper->shut_backend == XFSM_SHUTDOWN_SUDO)
- {
- /* we don't support hibernate or suspend without HAL */
- switch (command)
- {
- case XFSM_SHUTDOWN_HALT:
- command_str = "POWEROFF";
- break;
+ switch (command)
+ {
+ case XFSM_SHUTDOWN_HALT:
+ case XFSM_SHUTDOWN_REBOOT:
+ if (helper->shut_backend == XFSM_SHUTDOWN_POWER_MANAGER)
+ {
+ return xfsm_shutdown_helper_pm_send (helper, command, error);
+ }
+ else if (helper->shut_backend == XFSM_SHUTDOWN_CONSOLEKIT)
+ {
+ return xfsm_shutdown_helper_ck_send (helper, command, error);
+ }
+ else if (helper->shut_backend == XFSM_SHUTDOWN_HAL)
+ {
+ return xfsm_shutdown_helper_hal_send (helper, command, error);
+ }
+ else if (helper->shut_backend == XFSM_SHUTDOWN_SUDO)
+ {
+ /* we don't support hibernate or suspend without HAL */
+ switch (command)
+ {
+ case XFSM_SHUTDOWN_HALT:
+ command_str = "POWEROFF";
+ break;
+
+ case XFSM_SHUTDOWN_REBOOT:
+ command_str = "REBOOT";
+ break;
+
+ case XFSM_SHUTDOWN_SUSPEND:
+ case XFSM_SHUTDOWN_HIBERNATE:
+ if (error)
+ {
+ g_set_error (error, DBUS_GERROR, DBUS_GERROR_SERVICE_UNKNOWN,
+ _("Suspend and Hibernate are only supported through HAL, which is unavailable"));
+ }
+ /* fall through */
+ default:
+ return FALSE;
+ }
- case XFSM_SHUTDOWN_REBOOT:
- command_str = "REBOOT";
- break;
+ /* send it to our associated sudo'ed process */
+ fprintf (helper->outfile, "%s\n", command_str);
+ fflush (helper->outfile);
- case XFSM_SHUTDOWN_SUSPEND:
- case XFSM_SHUTDOWN_HIBERNATE:
- if (error)
+ if (ferror (helper->outfile))
+ {
+ if (error && errno != EINTR)
{
- g_set_error (error, DBUS_GERROR, DBUS_GERROR_SERVICE_UNKNOWN,
- _("Suspend and Hibernate are only supported through HAL, which is unavailable"));
+ g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
+ _("Error sending command to shutdown helper: %s"),
+ strerror (errno));
}
- /* fall through */
- default:
return FALSE;
- }
-
- /* send it to our associated sudo'ed process */
- fprintf (helper->outfile, "%s\n", command_str);
- fflush (helper->outfile);
-
- if (ferror (helper->outfile))
- {
- if (error && errno != EINTR)
- {
- g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
- _("Error sending command to shutdown helper: %s"),
- strerror (errno));
- }
- return FALSE;
- }
+ }
- if (fgets (response, 256, helper->infile) == NULL)
- {
- if (error && errno != EINTR)
- {
- g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
- _("Error receiving response from shutdown helper: %s"),
- strerror (errno));
- }
- return FALSE;
- }
+ if (fgets (response, 256, helper->infile) == NULL)
+ {
+ if (error && errno != EINTR)
+ {
+ g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
+ _("Error receiving response from shutdown helper: %s"),
+ strerror (errno));
+ }
+ return FALSE;
+ }
- if (strncmp (response, "SUCCEED", 7) != 0)
- {
- if (error)
- {
- g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
- _("Shutdown command failed"));
- }
- return FALSE;
- }
- }
- else
- return FALSE;
+ if (strncmp (response, "SUCCEED", 7) != 0)
+ {
+ if (error)
+ {
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Shutdown command failed"));
+ }
+ return FALSE;
+ }
+ }
+ else
+ return FALSE;
- break;
+ break;
- case XFSM_SHUTDOWN_SUSPEND:
- case XFSM_SHUTDOWN_HIBERNATE:
- if (helper->susp_backend == XFSM_SHUTDOWN_POWER_MANAGER)
- {
- return xfsm_shutdown_helper_pm_send (helper, command, error);
- }
- else if (helper->shusp_backend == XFSM_SHUTDOWN_CONSOLEKIT)
- {
- return xfsm_shutdown_helper_ck_send (helper, command, error);
- }
- else
- return FALSE;
-
- break;
- }
+ case XFSM_SHUTDOWN_SUSPEND:
+ case XFSM_SHUTDOWN_HIBERNATE:
+ if (helper->susp_backend == XFSM_SHUTDOWN_POWER_MANAGER)
+ {
+ return xfsm_shutdown_helper_pm_send (helper, command, error);
+ }
+ else if (helper->shusp_backend == XFSM_SHUTDOWN_CONSOLEKIT)
+ {
+ return xfsm_shutdown_helper_ck_send (helper, command, error);
+ }
+ else
+ return FALSE;
+
+ break;
+ }
return TRUE;
}
@@ -912,6 +913,10 @@ xfsm_shutdown_helper_supports (XfsmShutdownHelper *helper,
if (!helper)
return FALSE;
+ switch (shutdown_type)
+ {
+ case XFSM_SHUTDOWN_HALT:
+ case XFSM_SHUTDOWN_REBOOT:
switch (helper->backend)
{
case XFSM_SHUTDOWN_POWER_MANAGER:
More information about the Xfce4-commits
mailing list