1 /*
2  * Copyright (C) 2018, Matthias Clasen
3  *
4  * This file is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License as
6  * published by the Free Software Foundation, version 3.0 of the
7  * License.
8  *
9  * This file is distributed in the hope that it will be useful, but
10  * 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 program.  If not, see <http://www.gnu.org/licenses/>.
16  *
17  * SPDX-License-Identifier: LGPL-3.0-only
18  */
19 
20 #pragma once
21 
22 #include <libportal/types.h>
23 
24 G_BEGIN_DECLS
25 
26 /**
27  * XdpInhibitFlags:
28  * @XDP_INHIBIT_FLAG_LOGOUT: Inhibit logout
29  * @XDP_INHIBIT_FLAG_USER_SWITCH: Inhibit user switching
30  * @XDP_INHIBIT_FLAG_SUSPEND: Inhibit suspend
31  * @XDP_INHIBIT_FLAG_IDLE: Inhibit the session going idle
32  *
33  * Flags that determine what session status changes are inhibited.
34  */
35 typedef enum {
36   XDP_INHIBIT_FLAG_LOGOUT      = 1 << 0,
37   XDP_INHIBIT_FLAG_USER_SWITCH = 1 << 1,
38   XDP_INHIBIT_FLAG_SUSPEND     = 1 << 2,
39   XDP_INHIBIT_FLAG_IDLE        = 1 << 3
40 } XdpInhibitFlags;
41 
42 XDP_PUBLIC
43 void       xdp_portal_session_inhibit             (XdpPortal            *portal,
44                                                    XdpParent            *parent,
45                                                    const char           *reason,
46                                                    XdpInhibitFlags       flags,
47                                                    GCancellable         *cancellable,
48                                                    GAsyncReadyCallback   callback,
49                                                    gpointer              data);
50 
51 XDP_PUBLIC
52 int        xdp_portal_session_inhibit_finish      (XdpPortal            *portal,
53                                                    GAsyncResult         *result,
54                                                    GError              **error);
55 
56 XDP_PUBLIC
57 void       xdp_portal_session_uninhibit           (XdpPortal            *portal,
58                                                    int                   id);
59 
60 /**
61  * XdpLoginSessionState:
62  * @XDP_LOGIN_SESSION_RUNNING: the session is running
63  * @XDP_LOGIN_SESSION_QUERY_END: the session is in the query end phase,
64  *     during which applications can save their state or inhibit the
65  *     session from ending
66  * @XDP_LOGIN_SESSION_ENDING: the session is about to end
67  *
68  * The values of this enum are returned in the [signal@Portal::session-state-changed] signal
69  * to indicate the current state of the user session.
70  */
71 typedef enum {
72   XDP_LOGIN_SESSION_RUNNING =   1,
73   XDP_LOGIN_SESSION_QUERY_END = 2,
74   XDP_LOGIN_SESSION_ENDING =    3,
75 } XdpLoginSessionState;
76 
77 typedef enum {
78   XDP_SESSION_MONITOR_FLAG_NONE = 0
79 } XdpSessionMonitorFlags;
80 
81 XDP_PUBLIC
82 void       xdp_portal_session_monitor_start              (XdpPortal               *portal,
83                                                           XdpParent               *parent,
84                                                           XdpSessionMonitorFlags   flags,
85                                                           GCancellable            *cancellable,
86                                                           GAsyncReadyCallback      callback,
87                                                           gpointer                 data);
88 
89 XDP_PUBLIC
90 gboolean   xdp_portal_session_monitor_start_finish       (XdpPortal               *portal,
91                                                           GAsyncResult            *result,
92                                                           GError                 **error);
93 
94 XDP_PUBLIC
95 void       xdp_portal_session_monitor_stop               (XdpPortal               *portal);
96 
97 XDP_PUBLIC
98 void       xdp_portal_session_monitor_query_end_response (XdpPortal               *portal);
99 
100 G_END_DECLS
101