1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2  *
3  * Copyright (C) 2008 Jon McCann <jmccann@redhat.com>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, see <http://www.gnu.org/licenses/>.
17  *
18  * Authors:
19  *	Jon McCann <jmccann@redhat.com>
20  */
21 
22 #ifndef __GSM_SYSTEM_H__
23 #define __GSM_SYSTEM_H__
24 
25 #include <glib.h>
26 #include <glib-object.h>
27 
28 #include "gsm-inhibitor.h"
29 
30 G_BEGIN_DECLS
31 
32 #define GSM_TYPE_SYSTEM             (gsm_system_get_type ())
33 #define GSM_SYSTEM(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSM_TYPE_SYSTEM, GsmSystem))
34 #define GSM_SYSTEM_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GSM_TYPE_SYSTEM, GsmSystemInterface))
35 #define GSM_IS_SYSTEM(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSM_TYPE_SYSTEM))
36 #define GSM_SYSTEM_GET_IFACE(obj)   (G_TYPE_INSTANCE_GET_INTERFACE((obj), GSM_TYPE_SYSTEM, GsmSystemInterface))
37 #define GSM_SYSTEM_ERROR            (gsm_system_error_quark ())
38 
39 typedef struct _GsmSystem          GsmSystem;
40 typedef struct _GsmSystemInterface GsmSystemInterface;
41 typedef enum   _GsmSystemError     GsmSystemError;
42 
43 struct _GsmSystemInterface
44 {
45         GTypeInterface base_interface;
46 
47         void (* request_completed)    (GsmSystem *system,
48                                        GError    *error);
49 
50         void (* shutdown_prepared)    (GsmSystem *system,
51                                        gboolean   success);
52 
53         gboolean (* can_switch_user)  (GsmSystem *system);
54         gboolean (* can_stop)         (GsmSystem *system);
55         gboolean (* can_restart)      (GsmSystem *system);
56         gboolean (* can_restart_to_firmware_setup) (GsmSystem *system);
57         void     (* set_restart_to_firmware_setup) (GsmSystem *system,
58                                               gboolean   enable);
59         gboolean (* can_suspend)      (GsmSystem *system);
60         gboolean (* can_hibernate)    (GsmSystem *system);
61         void     (* attempt_stop)     (GsmSystem *system);
62         void     (* attempt_restart)  (GsmSystem *system);
63         void     (* suspend)          (GsmSystem *system);
64         void     (* hibernate)        (GsmSystem *system);
65         void     (* set_session_idle) (GsmSystem *system,
66                                        gboolean   is_idle);
67         gboolean (* is_login_session) (GsmSystem *system);
68         void     (* set_inhibitors)   (GsmSystem        *system,
69                                        GsmInhibitorFlag  flags);
70         void     (* prepare_shutdown) (GsmSystem   *system,
71                                        gboolean     restart);
72         void     (* complete_shutdown)(GsmSystem   *system);
73         gboolean (* is_last_session_for_user) (GsmSystem *system);
74 };
75 
76 enum _GsmSystemError {
77         GSM_SYSTEM_ERROR_RESTARTING = 0,
78         GSM_SYSTEM_ERROR_STOPPING
79 };
80 
81 GType      gsm_system_get_type         (void);
82 
83 GQuark     gsm_system_error_quark      (void);
84 
85 GsmSystem *gsm_get_system              (void);
86 
87 gboolean   gsm_system_can_switch_user  (GsmSystem *system);
88 
89 gboolean   gsm_system_can_stop         (GsmSystem *system);
90 
91 gboolean   gsm_system_can_restart      (GsmSystem *system);
92 
93 gboolean   gsm_system_can_restart_to_firmware_setup (GsmSystem *system);
94 
95 void       gsm_system_set_restart_to_firmware_setup (GsmSystem *system,
96                                                      gboolean   enable);
97 
98 gboolean   gsm_system_can_suspend      (GsmSystem *system);
99 
100 gboolean   gsm_system_can_hibernate    (GsmSystem *system);
101 
102 void       gsm_system_attempt_stop     (GsmSystem *system);
103 
104 void       gsm_system_attempt_restart  (GsmSystem *system);
105 
106 void       gsm_system_suspend          (GsmSystem *system);
107 
108 void       gsm_system_hibernate        (GsmSystem *system);
109 
110 void       gsm_system_set_session_idle (GsmSystem *system,
111                                         gboolean   is_idle);
112 
113 gboolean   gsm_system_is_login_session (GsmSystem *system);
114 
115 gboolean   gsm_system_is_last_session_for_user (GsmSystem *system);
116 
117 gboolean   gsm_system_is_active        (GsmSystem *system);
118 
119 void       gsm_system_set_inhibitors   (GsmSystem        *system,
120                                         GsmInhibitorFlag  flags);
121 
122 void       gsm_system_prepare_shutdown  (GsmSystem  *system,
123                                          gboolean    restart);
124 void       gsm_system_complete_shutdown (GsmSystem  *system);
125 
126 
127 
128 G_END_DECLS
129 
130 #endif /* __GSM_SYSTEM_H__ */
131