Back to index

lightdm  1.3.2
Functions | Variables
power.c File Reference
#include <config.h>
#include <string.h>
#include <gio/gio.h>
#include "lightdm/power.h"

Go to the source code of this file.

Functions

static gboolean upower_call_function (const gchar *function, gboolean default_result, GError **error)
gboolean lightdm_get_can_suspend (void)
 lightdm_get_can_suspend:
gboolean lightdm_suspend (GError **error)
 lightdm_suspend: : return location for a #GError, or NULL
gboolean lightdm_get_can_hibernate (void)
 lightdm_get_can_hibernate:
gboolean lightdm_hibernate (GError **error)
 lightdm_hibernate: : return location for a #GError, or NULL
static gboolean ck_call_function (const gchar *function, gboolean default_result, GError **error)
gboolean lightdm_get_can_restart (void)
 lightdm_get_can_restart:
gboolean lightdm_restart (GError **error)
 lightdm_restart: : return location for a #GError, or NULL
gboolean lightdm_get_can_shutdown (void)
 lightdm_get_can_shutdown:
gboolean lightdm_shutdown (GError **error)
 lightdm_shutdown: : return location for a #GError, or NULL

Variables

static GDBusProxy * upower_proxy = NULL
static GDBusProxy * ck_proxy = NULL

Function Documentation

static gboolean ck_call_function ( const gchar *  function,
gboolean  default_result,
GError **  error 
) [static]

Definition at line 114 of file power.c.

{
    GVariant *result;
    gboolean function_result = FALSE;

    if (!ck_proxy)
    {
        ck_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
                                                  G_DBUS_PROXY_FLAGS_NONE,
                                                  NULL,
                                                  "org.freedesktop.ConsoleKit",
                                                  "/org/freedesktop/ConsoleKit/Manager",
                                                  "org.freedesktop.ConsoleKit.Manager",
                                                  NULL,
                                                  error);
        if (!ck_proxy)
            return FALSE;
    }

    result = g_dbus_proxy_call_sync (ck_proxy,
                                     function,
                                     NULL,
                                     G_DBUS_CALL_FLAGS_NONE,
                                     -1,
                                     NULL,
                                     error);

    if (!result)
        return default_result;

    if (g_variant_is_of_type (result, G_VARIANT_TYPE ("(b)")))
        g_variant_get (result, "(b)", &function_result);

    g_variant_unref (result);
    return function_result;
}

Here is the caller graph for this function:

gboolean lightdm_get_can_hibernate ( void  )

lightdm_get_can_hibernate:

Checks if is authorized to do a system hibernate.

Return value: #TRUE if can hibernate the system

Definition at line 94 of file power.c.

{
    return upower_call_function ("HibernateAllowed", FALSE, NULL);
}

Here is the call graph for this function:

gboolean lightdm_get_can_restart ( void  )

lightdm_get_can_restart:

Checks if is authorized to do a system restart.

Return value: #TRUE if can restart the system

Definition at line 159 of file power.c.

{
    return ck_call_function ("CanRestart", FALSE, NULL);
}

Here is the call graph for this function:

gboolean lightdm_get_can_shutdown ( void  )

lightdm_get_can_shutdown:

Checks if is authorized to do a system shutdown.

Return value: #TRUE if can shutdown the system

Definition at line 186 of file power.c.

{
    return ck_call_function ("CanStop", FALSE, NULL);
}

Here is the call graph for this function:

gboolean lightdm_get_can_suspend ( void  )

lightdm_get_can_suspend:

Checks if authorized to do a system suspend.

Return value: #TRUE if can suspend the system

Definition at line 67 of file power.c.

{
    return upower_call_function ("SuspendAllowed", FALSE, NULL);
}

Here is the call graph for this function:

gboolean lightdm_hibernate ( GError **  error)

lightdm_hibernate: : return location for a #GError, or NULL

Triggers a system hibernate.

Return value: #TRUE if hibernate initiated.

Definition at line 108 of file power.c.

{
    return upower_call_function ("Hibernate", TRUE, error);
}

Here is the call graph for this function:

gboolean lightdm_restart ( GError **  error)

lightdm_restart: : return location for a #GError, or NULL

Triggers a system restart.

Return value: #TRUE if restart initiated.

Definition at line 173 of file power.c.

{
    return ck_call_function ("Restart", TRUE, error);
}

Here is the call graph for this function:

gboolean lightdm_shutdown ( GError **  error)

lightdm_shutdown: : return location for a #GError, or NULL

Triggers a system shutdown.

Return value: #TRUE if shutdown initiated.

Definition at line 200 of file power.c.

{
    return ck_call_function ("Stop", TRUE, error);
}

Here is the call graph for this function:

gboolean lightdm_suspend ( GError **  error)

lightdm_suspend: : return location for a #GError, or NULL

Triggers a system suspend.

Return value: #TRUE if suspend initiated.

Definition at line 81 of file power.c.

{
    return upower_call_function ("Suspend", TRUE, error);
}

Here is the call graph for this function:

static gboolean upower_call_function ( const gchar *  function,
gboolean  default_result,
GError **  error 
) [static]

Definition at line 23 of file power.c.

{
    GVariant *result;
    gboolean function_result = FALSE;

    if (!upower_proxy)
    {
        upower_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
                                                      G_DBUS_PROXY_FLAGS_NONE,
                                                      NULL,
                                                      "org.freedesktop.UPower",
                                                      "/org/freedesktop/UPower",
                                                      "org.freedesktop.UPower",
                                                      NULL,
                                                      error);
        if (!upower_proxy)
            return FALSE;
    }

    result = g_dbus_proxy_call_sync (upower_proxy,
                                     function,
                                     NULL,
                                     G_DBUS_CALL_FLAGS_NONE,
                                     -1,
                                     NULL,
                                     error);
    if (!result)
        return default_result;

    if (g_variant_is_of_type (result, G_VARIANT_TYPE ("(b)")))
        g_variant_get (result, "(b)", &function_result);

    g_variant_unref (result);
    return function_result;
}

Here is the caller graph for this function:


Variable Documentation

GDBusProxy* ck_proxy = NULL [static]

Definition at line 20 of file power.c.

GDBusProxy* upower_proxy = NULL [static]

Definition at line 19 of file power.c.