1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
3
* Copyright (C) 2012 Red Hat, Inc.
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2, or (at your option)
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23
#include <glib-object.h>
24
#include <glib/gi18n.h>
26
#include "gsm-system.h"
27
#include "gsm-consolekit.h"
28
#include "gsm-systemd.h"
31
REQUEST_COMPLETED = 0,
35
static guint signals[LAST_SIGNAL] = { 0 };
37
G_DEFINE_INTERFACE (GsmSystem, gsm_system, G_TYPE_OBJECT)
40
gsm_system_default_init (GsmSystemInterface *iface)
42
signals [REQUEST_COMPLETED] =
43
g_signal_new ("request-completed",
46
G_STRUCT_OFFSET (GsmSystemInterface, request_completed),
49
g_cclosure_marshal_VOID__POINTER,
55
gsm_system_error_quark (void)
57
static GQuark error_quark = 0;
59
if (error_quark == 0) {
60
error_quark = g_quark_from_static_string ("gsm-system-error");
67
gsm_system_can_switch_user (GsmSystem *system)
69
return GSM_SYSTEM_GET_IFACE (system)->can_switch_user (system);
73
gsm_system_can_stop (GsmSystem *system)
75
return GSM_SYSTEM_GET_IFACE (system)->can_stop (system);
79
gsm_system_can_restart (GsmSystem *system)
81
return GSM_SYSTEM_GET_IFACE (system)->can_restart (system);
85
gsm_system_attempt_stop (GsmSystem *system)
87
GSM_SYSTEM_GET_IFACE (system)->attempt_stop (system);
91
gsm_system_attempt_restart (GsmSystem *system)
93
GSM_SYSTEM_GET_IFACE (system)->attempt_restart (system);
97
gsm_system_set_session_idle (GsmSystem *system,
100
GSM_SYSTEM_GET_IFACE (system)->set_session_idle (system, is_idle);
104
gsm_system_is_login_session (GsmSystem *system)
106
return GSM_SYSTEM_GET_IFACE (system)->is_login_session (system);
110
gsm_get_system (void)
112
static GsmSystem *system = NULL;
114
if (system == NULL) {
115
system = GSM_SYSTEM (gsm_systemd_new ());
116
if (system != NULL) {
117
g_debug ("Using systemd for session tracking");
120
if (system == NULL) {
121
system = GSM_SYSTEM (gsm_consolekit_new ());
122
if (system != NULL) {
123
g_debug ("Using ConsoleKit for session tracking");
127
return g_object_ref (system);