1 /* eggsmclient.h
2  * Copyright (C) 2007 Novell, Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef __EGG_SM_CLIENT_H__
21 #define __EGG_SM_CLIENT_H__
22 
23 #include <glib-object.h>
24 
25 G_BEGIN_DECLS
26 
27 #define EGG_TYPE_SM_CLIENT            (egg_sm_client_get_type ())
28 G_DECLARE_DERIVABLE_TYPE (EggSMClient, egg_sm_client, EGG, SM_CLIENT, GObject)
29 
30 typedef enum
31 {
32     EGG_SM_CLIENT_END_SESSION_DEFAULT,
33     EGG_SM_CLIENT_LOGOUT,
34     EGG_SM_CLIENT_REBOOT,
35     EGG_SM_CLIENT_SHUTDOWN
36 } EggSMClientEndStyle;
37 
38 typedef enum
39 {
40     EGG_SM_CLIENT_MODE_DISABLED,
41     EGG_SM_CLIENT_MODE_NO_RESTART,
42     EGG_SM_CLIENT_MODE_NORMAL
43 } EggSMClientMode;
44 
45 struct _EggSMClientClass
46 {
47     GObjectClass parent_class;
48 
49     /* signals */
50     void (*save_state)       (EggSMClient *client,
51                               GKeyFile    *state_file);
52 
53     void (*quit_requested)   (EggSMClient *client);
54     void (*quit_cancelled)   (EggSMClient *client);
55     void (*quit)             (EggSMClient *client);
56 
57     /* virtual methods */
58     void (*startup)             (EggSMClient          *client,
59                                  const char           *client_id);
60     void (*set_restart_command) (EggSMClient          *client,
61                                  int                   argc,
62                                  const char          **argv);
63 	void (*set_discard_command) (EggSMClient          *client,
64                                  int                   argc,
65                                  const char          **argv);
66     void (*will_quit)           (EggSMClient          *client,
67                                  gboolean              will_quit);
68     gboolean (*end_session)     (EggSMClient          *client,
69                                  EggSMClientEndStyle   style,
70                                  gboolean              request_confirmation);
71 
72     /* Padding for future expansion */
73     void (*_egg_reserved1) (void);
74     void (*_egg_reserved2) (void);
75     void (*_egg_reserved3) (void);
76     void (*_egg_reserved4) (void);
77 };
78 
79 GOptionGroup    *egg_sm_client_get_option_group    (void);
80 
81 /* Initialization */
82 void             egg_sm_client_set_mode            (EggSMClientMode mode);
83 EggSMClientMode  egg_sm_client_get_mode            (void);
84 EggSMClient     *egg_sm_client_get                 (void);
85 
86 /* Resuming a saved session */
87 gboolean         egg_sm_client_is_resumed          (EggSMClient *client);
88 GKeyFile        *egg_sm_client_get_state_file      (EggSMClient *client);
89 
90 /* Alternate means of saving state */
91 void             egg_sm_client_set_restart_command (EggSMClient  *client,
92                                                     int           argc,
93                                                     const char  **argv);
94 void             egg_sm_client_set_discard_command (EggSMClient  *client,
95                                                     int           argc,
96                                                     const char  **argv);
97 
98 /* Handling "quit_requested" signal */
99 void             egg_sm_client_will_quit           (EggSMClient *client,
100                                                     gboolean     will_quit);
101 
102 /* Initiate a logout/reboot/shutdown */
103 gboolean         egg_sm_client_end_session         (EggSMClientEndStyle  style,
104                                                     gboolean             request_confirmation);
105 
106 G_END_DECLS
107 
108 #endif /* __EGG_SM_CLIENT_H__ */
109