Debian Codegraph @

src/inhibit.c

raw symbols SCIP
1 /*
2 * Copyright © 2016 Red Hat, Inc
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Authors:
20 * Matthias Clasen <[email protected]>
21 */
22
23 #include "config.h"cxx . . $ `<file>/build/config.h`/
24
25 #include <string.h>
26 #include <gio/gio.h>
27
28 #include "inhibit.h"cxx . . $ `<file>/src/inhibit.h`/
29 #include "xdp-request.h"cxx . . $ `<file>/src/xdp-request.h`/
30 #include "xdp-session.h"cxx . . $ `<file>/src/xdp-session.h`/
31 #include "xdp-permissions.h"cxx . . $ `<file>/src/xdp-permissions.h`/
32 #include "xdp-dbus.h"cxx . . $ `<file>/build/src/xdp-dbus.h`/
33 #include "xdp-impl-dbus.h"cxx . . $ `<file>/build/src/xdp-impl-dbus.h`/
34 #include "xdp-utils.h"cxx . . $ `<file>/src/xdp-utils.h`/
35
36 #define PERMISSION_TABLEcxx . . $ `src/inhibit.c:36:9`! "inhibit"
37 #define PERMISSION_IDcxx . . $ `src/inhibit.c:37:9`! "inhibit"
38
39 enumcxx . . $ $anonymous_type_307c449876d076ce_0# {
40 INHIBIT_LOGOUTcxx . . $ INHIBIT_LOGOUT. = 1,
41 INHIBIT_USER_SWITCHcxx . . $ INHIBIT_USER_SWITCH. = 2,
42 INHIBIT_SUSPENDcxx . . $ INHIBIT_SUSPEND. = 4,
43 INHIBIT_IDLEcxx . . $ INHIBIT_IDLE. = 8
44 };
45
46 #define INHIBIT_ALLcxx . . $ `src/inhibit.c:46:9`! (INHIBIT_LOGOUT|INHIBIT_USER_SWITCH|INHIBIT_SUSPEND|INHIBIT_IDLE)
47
48 typedef struct _Inhibitcxx . . $ _Inhibit# Inhibitcxx . . $ Inhibit#;
49 typedef struct _InhibitClasscxx . . $ _InhibitClass# InhibitClasscxx . . $ InhibitClass#;
50
51 struct _Inhibitcxx . . $ _Inhibit#
52 {
53 XdpDbusInhibitSkeletoncxx . . $ XdpDbusInhibitSkeleton# parent_instancecxx . . $ _Inhibit#parent_instance.;
54 };
55
56 struct _InhibitClasscxx . . $ _InhibitClass#
57 {
58 XdpDbusInhibitSkeletonClasscxx . . $ XdpDbusInhibitSkeletonClass# parent_classcxx . . $ _InhibitClass#parent_class.;
59 };
60
61 static XdpDbusImplInhibitcxx . . $ XdpDbusImplInhibit# *implcxx . . $ impl.;
62 static Inhibitcxx . . $ Inhibit# *inhibitcxx . . $ inhibit.;
63
64 GTypecxx . . $ GType# inhibit_get_typecxx . . $ inhibit_get_type(f708dce9a8856c70). (void) G_GNUC_CONSTcxx . . $ `<external>/12741050725406041920/gmacros.h:640:9`!;
65 static void inhibit_iface_initcxx . . $ inhibit_iface_init(d1add2dbf976090). (XdpDbusInhibitIfacecxx . . $ XdpDbusInhibitIface# *iface);
66
67 G_DEFINE_TYPE_WITH_CODEcxx . . $ `<external>/9567554376676449156/gtype.h:1850:9`! (Inhibit, inhibit, XDP_DBUS_TYPE_INHIBIT_SKELETONcxx . . $ `build/src/xdp-dbus.h:3622:9`!,
68 G_IMPLEMENT_INTERFACEcxx . . $ `<external>/9567554376676449156/gtype.h:2115:9`! (XDP_DBUS_TYPE_INHIBITcxx . . $ `build/src/xdp-dbus.h:3401:9`!,
69 inhibit_iface_init));
70
71 static void
72 inhibit_donecxx . . $ inhibit_done(aa1d200d824d915d). (GObjectcxx . . $ GObject# *source,
73 GAsyncResultcxx . . $ GAsyncResult# *result,
74 gpointercxx . . $ gpointer# data)
75 {
76 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GError) error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
77 XdpRequestcxx . . $ XdpRequest# *request = data;
78 int response = 0;
79
80 REQUEST_AUTOLOCKcxx . . $ `src/xdp-request.h:103:9`! (request);
81
82 if (!xdp_dbus_impl_inhibit_call_inhibit_finishcxx . . $ xdp_dbus_impl_inhibit_call_inhibit_finish(38f99c3daa0aaa41). (implcxx . . $ impl., result, &error))
83 {
84 g_dbus_error_strip_remote_errorcxx . . $ g_dbus_error_strip_remote_error(425e103a815b829). (error);
85 g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("A backend call failed: %s", error->message);
86 response = 2;
87 }
88
89 if (request->exportedcxx . . $ _XdpRequest#exported.)
90 {
91 g_autocxx . . $ `<external>/12741050725406041920/gmacros.h:1428:9`!(GVariantBuilder) new_results =
92 G_VARIANT_BUILDER_INITcxx . . $ `<external>/10279604295420929244/gvariant.h:369:9`! (G_VARIANT_TYPE_VARDICTcxx . . $ `<external>/14064154155447831270/gvarianttype.h:279:9`!);
93
94 xdp_dbus_request_emit_responsecxx . . $ xdp_dbus_request_emit_response(6deab25eec490adc). (XDP_DBUS_REQUESTcxx . . $ `build/src/xdp-dbus.h:6732:9`! (request),
95 response,
96 g_variant_builder_endcxx . . $ g_variant_builder_end(6d60952e65fc2b86). (&new_results));
97 }
98 }
99
100 static guint32cxx . . $ guint32#
101 get_allowed_inhibitcxx . . $ get_allowed_inhibit(c61c63047ce273de). (const char *app_id)
102 {
103 g_autocxx . . $ `<external>/12741050725406041920/gmacros.h:1428:9`!(GStrv) perms = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
104 guint32cxx . . $ guint32# ret = 0;
105
106 perms = xdp_get_permissions_synccxx . . $ xdp_get_permissions_sync(e30301b8df2bfcd). (app_id, PERMISSION_TABLEcxx . . $ `src/inhibit.c:36:9`!, PERMISSION_IDcxx . . $ `src/inhibit.c:37:9`!);
107
108 if (perms != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
109 {
110 int i;
111
112 for (i = 0; perms[i]; i++)
113 {
114 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88). (perms[i], "logout") == 0)
115 ret |= INHIBIT_LOGOUTcxx . . $ INHIBIT_LOGOUT.;
116 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88). (perms[i], "switch") == 0)
117 ret |= INHIBIT_USER_SWITCHcxx . . $ INHIBIT_USER_SWITCH.;
118 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88). (perms[i], "suspend") == 0)
119 ret |= INHIBIT_SUSPENDcxx . . $ INHIBIT_SUSPEND.;
120 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88). (perms[i], "idle") == 0)
121 ret |= INHIBIT_IDLEcxx . . $ INHIBIT_IDLE.;
122 else
123 g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("Unknown inhibit flag in permission store: %s", perms[i]);
124 }
125 }
126 else
127 ret = INHIBIT_ALLcxx . . $ `src/inhibit.c:46:9`!; /* all allowed */
128
129 g_debugcxx . . $ `<external>/5169755362661750954/gmessages.h:371:9`! ("Inhibit permissions for %s: %d", app_id, ret);
130
131 return ret;
132 }
133
134 static void
135 handle_inhibit_in_thread_funccxx . . $ handle_inhibit_in_thread_func(4704ff26353eb8ae). (GTaskcxx . . $ GTask# *task,
136 gpointercxx . . $ gpointer# source_object,
137 gpointercxx . . $ gpointer# task_data,
138 GCancellablecxx . . $ GCancellable# *cancellable)
139 {
140 XdpRequestcxx . . $ XdpRequest# *request = XDP_REQUESTcxx . . $ XDP_REQUEST(e3ad50a9247c4f2e). (task_data);
141 const char *window;
142 guint32cxx . . $ guint32# flags;
143 GVariantcxx . . $ GVariant# *options;
144 const char *app_id;
145
146 REQUEST_AUTOLOCKcxx . . $ `src/xdp-request.h:103:9`! (request);
147
148 window = (const char *)g_object_get_datacxx . . $ g_object_get_data(973400aee2f864c2). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (request), "window");
149 flags = GPOINTER_TO_UINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:104:9`! (g_object_get_data (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (request), "flags"));
150 options = (GVariantcxx . . $ GVariant# *)g_object_get_datacxx . . $ g_object_get_data(973400aee2f864c2). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (request), "options");
151
152 app_id = xdp_app_info_get_idcxx . . $ xdp_app_info_get_id(b9a768ac644c9329). (request->app_infocxx . . $ _XdpRequest#app_info.);
153 flags = flags & get_allowed_inhibitcxx . . $ get_allowed_inhibit(c61c63047ce273de). (app_id);
154
155 if (flags == 0)
156 return;
157
158 g_debugcxx . . $ `<external>/5169755362661750954/gmessages.h:371:9`! ("Calling inhibit backend for %s: %d", app_id, flags);
159 xdp_dbus_impl_inhibit_call_inhibitcxx . . $ xdp_dbus_impl_inhibit_call_inhibit(e705f31f1efa71be). (implcxx . . $ impl.,
160 request->idcxx . . $ _XdpRequest#id.,
161 app_id,
162 window,
163 flags,
164 options,
165 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
166 inhibit_donecxx . . $ inhibit_done(aa1d200d824d915d).,
167 g_object_refcxx . . $ `<external>/1341695927569185362/gobject.h:533:9`! (request));
168 }
169
170 static gbooleancxx . . $ gboolean#
171 validate_reasoncxx . . $ validate_reason(a4f81f97d7ea3409). (const char *key,
172 GVariantcxx . . $ GVariant# *value,
173 GVariantcxx . . $ GVariant# *options,
174 GErrorcxx . . $ GError# **error)
175 {
176 const char *string = g_variant_get_stringcxx . . $ g_variant_get_string(5d5cac9792ea78b8). (value, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
177
178 if (g_utf8_strlencxx . . $ g_utf8_strlen(730d9b36f6411b7f). (string, -1) > 256)
179 {
180 g_set_errorcxx . . $ g_set_error(ca0c191bc68fc328). (error, XDG_DESKTOP_PORTAL_ERRORcxx . . $ `src/xdp-utils.h:98:9`!, XDG_DESKTOP_PORTAL_ERROR_INVALID_ARGUMENTcxx . . $ XDG_DESKTOP_PORTAL_ERROR_INVALID_ARGUMENT.,
181 "Not accepting overly long reasons");
182 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
183 }
184
185 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
186 }
187
188 static XdpOptionKeycxx . . $ XdpOptionKey# inhibit_optionscxx . . $ inhibit_options.[] = {
189 { "reason", G_VARIANT_TYPE_STRINGcxx . . $ `<external>/14064154155447831270/gvarianttype.h:122:9`!, validate_reasoncxx . . $ validate_reason(a4f81f97d7ea3409). }
190 };
191
192 static gbooleancxx . . $ gboolean#
193 handle_inhibitcxx . . $ handle_inhibit(91e027c802f0ef96). (XdpDbusInhibitcxx . . $ XdpDbusInhibit# *object,
194 GDBusMethodInvocationcxx . . $ GDBusMethodInvocation# *invocation,
195 const char *arg_window,
196 guint32cxx . . $ guint32# arg_flags,
197 GVariantcxx . . $ GVariant# *arg_options)
198 {
199 XdpRequestcxx . . $ XdpRequest# *request = xdp_request_from_invocationcxx . . $ xdp_request_from_invocation(9583a51810815010). (invocation);
200 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GError) error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
201 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(XdpDbusImplRequest) impl_request = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
202 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GTask) task = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
203 g_autocxx . . $ `<external>/12741050725406041920/gmacros.h:1428:9`!(GVariantBuilder) opt_builder =
204 G_VARIANT_BUILDER_INITcxx . . $ `<external>/10279604295420929244/gvariant.h:369:9`! (G_VARIANT_TYPE_VARDICTcxx . . $ `<external>/14064154155447831270/gvarianttype.h:279:9`!);
205 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GVariant) options = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
206
207 REQUEST_AUTOLOCKcxx . . $ `src/xdp-request.h:103:9`! (request);
208
209 if ((arg_flags & ~INHIBIT_ALLcxx . . $ `src/inhibit.c:46:9`!) != 0)
210 {
211 g_dbus_method_invocation_return_errorcxx . . $ g_dbus_method_invocation_return_error(2860f9a06c72d77e). (invocation,
212 XDG_DESKTOP_PORTAL_ERRORcxx . . $ `src/xdp-utils.h:98:9`!,
213 XDG_DESKTOP_PORTAL_ERROR_INVALID_ARGUMENTcxx . . $ XDG_DESKTOP_PORTAL_ERROR_INVALID_ARGUMENT.,
214 "Invalid flags");
215 return G_DBUS_METHOD_INVOCATION_HANDLEDcxx . . $ `<external>/7877694576918326146/gdbusmethodinvocation.h:56:9`!;
216 }
217
218 xdp_filter_optionscxx . . $ xdp_filter_options(d63f67045969ba55). (arg_options, &opt_builder,
219 inhibit_optionscxx . . $ inhibit_options., G_N_ELEMENTScxx . . $ `<external>/12741050725406041920/gmacros.h:993:9`! (inhibit_options),
220 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
221
222 options = g_variant_ref_sinkcxx . . $ g_variant_ref_sink(3606eab35379b54a). (g_variant_builder_endcxx . . $ g_variant_builder_end(6d60952e65fc2b86). (&opt_builder));
223
224 g_object_set_data_fullcxx . . $ g_object_set_data_full(218df00be1d2a06c). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (request), "window", g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (arg_window), g_freecxx . . $ g_free(5d22bdacc48458e8).);
225 g_object_set_datacxx . . $ g_object_set_data(c3d5001d890c27fc). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (request), "flags", GUINT_TO_POINTERcxx . . $ `<external>/10505296616216143549/glibconfig.h:107:9`! (arg_flags));
226 g_object_set_data_fullcxx . . $ g_object_set_data_full(218df00be1d2a06c). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (request), "options", g_variant_refcxx . . $ g_variant_ref(3606eab35379b54a). (options), (GDestroyNotifycxx . . $ GDestroyNotify#)g_variant_unrefcxx . . $ g_variant_unref(86dbca581f53fd84).);
227
228 impl_request = xdp_dbus_impl_request_proxy_new_synccxx . . $ xdp_dbus_impl_request_proxy_new_sync(b36c38a372f8f089). (g_dbus_proxy_get_connectioncxx . . $ g_dbus_proxy_get_connection(fd0690ce15ac5ecf). (G_DBUS_PROXYcxx . . $ `<external>/4635717660623816082/gdbusproxy.h:36:9`! (impl)),
229 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIEScxx . . $ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES.,
230 g_dbus_proxy_get_namecxx . . $ g_dbus_proxy_get_name(c2c3b8a4da378b0d). (G_DBUS_PROXYcxx . . $ `<external>/4635717660623816082/gdbusproxy.h:36:9`! (impl)),
231 request->idcxx . . $ _XdpRequest#id.,
232 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &error);
233 if (!impl_request)
234 {
235 g_dbus_method_invocation_return_gerrorcxx . . $ g_dbus_method_invocation_return_gerror(f84b6a1e02aa551). (invocation, error);
236 return G_DBUS_METHOD_INVOCATION_HANDLEDcxx . . $ `<external>/7877694576918326146/gdbusmethodinvocation.h:56:9`!;
237 }
238
239 xdp_request_set_impl_requestcxx . . $ xdp_request_set_impl_request(18bd0ab3b325ada4). (request, impl_request);
240 xdp_request_exportcxx . . $ xdp_request_export(49d11f351a243e17). (request, g_dbus_method_invocation_get_connectioncxx . . $ g_dbus_method_invocation_get_connection(8c6afd006dd99032). (invocation));
241
242 task = g_task_newcxx . . $ g_task_new(292d224db8478659). (object, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
243 g_task_set_task_datacxx . . $ g_task_set_task_data(2e97a86ccb74176a). (task, g_object_refcxx . . $ `<external>/1341695927569185362/gobject.h:533:9`! (request), g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8).);
244 g_task_run_in_threadcxx . . $ g_task_run_in_thread(9210d4c97157796e). (task, handle_inhibit_in_thread_funccxx . . $ handle_inhibit_in_thread_func(4704ff26353eb8ae).);
245
246 xdp_dbus_inhibit_complete_inhibitcxx . . $ xdp_dbus_inhibit_complete_inhibit(132c4488b08310ec). (object, invocation, request->idcxx . . $ _XdpRequest#id.);
247
248 return G_DBUS_METHOD_INVOCATION_HANDLEDcxx . . $ `<external>/7877694576918326146/gdbusmethodinvocation.h:56:9`!;
249 }
250
251 typedef struct _InhibitSessioncxx . . $ _InhibitSession#
252 {
253 XdpSessioncxx . . $ XdpSession# parentcxx . . $ _InhibitSession#parent.;
254
255 gbooleancxx . . $ gboolean# closedcxx . . $ _InhibitSession#closed.;
256 } InhibitSessioncxx . . $ InhibitSession#;
257
258 typedef struct _InhibitSessionClasscxx . . $ _InhibitSessionClass#
259 {
260 XdpSessionClasscxx . . $ XdpSessionClass# parent_classcxx . . $ _InhibitSessionClass#parent_class.;
261 } InhibitSessionClasscxx . . $ InhibitSessionClass#;
262
263 GTypecxx . . $ GType# inhibit_session_get_typecxx . . $ inhibit_session_get_type(f708dce9a8856c70). (void);
264
265 G_DEFINE_TYPEcxx . . $ `<external>/9567554376676449156/gtype.h:1834:9`! (InhibitSession, inhibit_session, xdp_session_get_type ())
266
267 G_GNUC_UNUSEDcxx . . $ `<external>/12741050725406041920/gmacros.h:647:9`! static inline InhibitSessioncxx . . $ InhibitSession# *
268 INHIBIT_SESSIONcxx . . $ INHIBIT_SESSION(80b9dbcbee079200). (gpointercxx . . $ gpointer# ptr)
269 {
270 return G_TYPE_CHECK_INSTANCE_CASTcxx . . $ `<external>/9567554376676449156/gtype.h:528:9`! (ptr, inhibit_session_get_type (), InhibitSession);
271 }
272
273 G_GNUC_UNUSEDcxx . . $ `<external>/12741050725406041920/gmacros.h:647:9`! static inline gbooleancxx . . $ gboolean#
274 IS_INHIBIT_SESSIONcxx . . $ IS_INHIBIT_SESSION(dedf1e9b1c614a07). (gpointercxx . . $ gpointer# ptr)
275 {
276 return G_TYPE_CHECK_INSTANCE_TYPEcxx . . $ `<external>/9567554376676449156/gtype.h:541:9`! (ptr, inhibit_session_get_type ());
277 }
278
279 static void
280 inhibit_session_closecxx . . $ inhibit_session_close(ac695378ab375fe8). (XdpSessioncxx . . $ XdpSession# *session)
281 {
282 InhibitSessioncxx . . $ InhibitSession# *inhibit_session = INHIBIT_SESSIONcxx . . $ INHIBIT_SESSION(80b9dbcbee079200). (session);
283
284 inhibit_session->closedcxx . . $ _InhibitSession#closed. = TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
285
286 g_debugcxx . . $ `<external>/5169755362661750954/gmessages.h:371:9`! ("inhibit session owned by '%s' closed", session->sender);
287 }
288
289 static void
290 inhibit_session_finalizecxx . . $ inhibit_session_finalize(6087475fa43034d3). (GObjectcxx . . $ GObject# *object)
291 {
292 G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (inhibit_session_parent_class)->finalizecxx . . $ _GObjectClass#finalize. (object);
293 }
294
295 static void
296 inhibit_session_initcxx . . $ inhibit_session_init(9b5dc6554117c017). (InhibitSessioncxx . . $ InhibitSession# *inhibit_session)
297 {
298 }
299
300 static void
301 inhibit_session_class_initcxx . . $ inhibit_session_class_init(1d362984e6981af2). (InhibitSessionClasscxx . . $ InhibitSessionClass# *klass)
302 {
303 GObjectClasscxx . . $ GObjectClass# *object_class;
304 XdpSessionClasscxx . . $ XdpSessionClass# *session_class;
305
306 object_class = G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (klass);
307 object_class->finalizecxx . . $ _GObjectClass#finalize. = inhibit_session_finalizecxx . . $ inhibit_session_finalize(6087475fa43034d3).;
308
309 session_class = (XdpSessionClasscxx . . $ XdpSessionClass# *)klass;
310 session_class->closecxx . . $ _XdpSessionClass#close. = inhibit_session_closecxx . . $ inhibit_session_close(ac695378ab375fe8).;
311 }
312
313 static InhibitSessioncxx . . $ InhibitSession# *
314 inhibit_session_newcxx . . $ inhibit_session_new(19dda4a7375a80da). (GVariantcxx . . $ GVariant# *options,
315 XdpRequestcxx . . $ XdpRequest# *request,
316 GErrorcxx . . $ GError# **error)
317 {
318 XdpSessioncxx . . $ XdpSession# *session;
319 const char *session_token;
320 GDBusInterfaceSkeletoncxx . . $ GDBusInterfaceSkeleton# *interface_skeleton = G_DBUS_INTERFACE_SKELETONcxx . . $ `<external>/1991948168568871819/gdbusinterfaceskeleton.h:32:9`! (request);
321 GDBusConnectioncxx . . $ GDBusConnection# *connection = g_dbus_interface_skeleton_get_connectioncxx . . $ g_dbus_interface_skeleton_get_connection(b3e1a9aea5de7a42). (interface_skeleton);
322 GDBusConnectioncxx . . $ GDBusConnection# *impl_connection = g_dbus_proxy_get_connectioncxx . . $ g_dbus_proxy_get_connection(fd0690ce15ac5ecf). (G_DBUS_PROXYcxx . . $ `<external>/4635717660623816082/gdbusproxy.h:36:9`! (impl));
323 const char *impl_dbus_name = g_dbus_proxy_get_namecxx . . $ g_dbus_proxy_get_name(c2c3b8a4da378b0d). (G_DBUS_PROXYcxx . . $ `<external>/4635717660623816082/gdbusproxy.h:36:9`! (impl));
324
325 session_token = lookup_session_tokencxx . . $ lookup_session_token(d2704f6d4d26effc). (options);
326 session = g_initable_newcxx . . $ g_initable_new(a8cb3f520296c554). (inhibit_session_get_typecxx . . $ inhibit_session_get_type(f708dce9a8856c70). (), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, error,
327 "sender", request->sendercxx . . $ _XdpRequest#sender.,
328 "app-id", xdp_app_info_get_idcxx . . $ xdp_app_info_get_id(b9a768ac644c9329). (request->app_infocxx . . $ _XdpRequest#app_info.),
329 "token", session_token,
330 "connection", connection,
331 "impl-connection", impl_connection,
332 "impl-dbus-name", impl_dbus_name,
333 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
334
335 if (session)
336 g_debugcxx . . $ `<external>/5169755362661750954/gmessages.h:371:9`! ("inhibit session owned by '%s' created", session->sender);
337
338 return (InhibitSessioncxx . . $ InhibitSession#*)session;
339 }
340
341 static void
342 create_monitor_donecxx . . $ create_monitor_done(aa1d200d824d915d). (GObjectcxx . . $ GObject# *source_object,
343 GAsyncResultcxx . . $ GAsyncResult# *res,
344 gpointercxx . . $ gpointer# data)
345 {
346 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(XdpRequest) request = data;
347 XdpSessioncxx . . $ XdpSession# *session;
348 guintcxx . . $ guint# response = 2;
349 gbooleancxx . . $ gboolean# should_close_session;
350 g_autocxx . . $ `<external>/12741050725406041920/gmacros.h:1428:9`!(GVariantBuilder) results_builder =
351 G_VARIANT_BUILDER_INITcxx . . $ `<external>/10279604295420929244/gvariant.h:369:9`! (G_VARIANT_TYPE_VARDICTcxx . . $ `<external>/14064154155447831270/gvarianttype.h:279:9`!);
352 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GError) error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
353
354 REQUEST_AUTOLOCKcxx . . $ `src/xdp-request.h:103:9`! (request);
355
356 session = g_object_get_datacxx . . $ g_object_get_data(973400aee2f864c2). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (request), "session");
357 SESSION_AUTOLOCK_UNREFcxx . . $ `src/xdp-session.h:115:9`! (g_object_refcxx . . $ `<external>/1341695927569185362/gobject.h:533:9`! (session));
358 g_object_set_datacxx . . $ g_object_set_data(c3d5001d890c27fc). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (request), "session", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
359
360 if (!xdp_dbus_impl_inhibit_call_create_monitor_finishcxx . . $ xdp_dbus_impl_inhibit_call_create_monitor_finish(e88bd6ee1cdf771f). (implcxx . . $ impl., &response, res, &error))
361 {
362 g_dbus_error_strip_remote_errorcxx . . $ g_dbus_error_strip_remote_error(425e103a815b829). (error);
363 g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("A backend call failed: %s", error->message);
364 should_close_session = TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
365 goto out;
366 }
367
368 if (request->exportedcxx . . $ _XdpRequest#exported. && response == 0)
369 {
370 if (!xdp_session_exportcxx . . $ xdp_session_export(3c2cf3f1073dc4c7). (session, &error))
371 {
372 g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("Failed to export session: %s", error->message);
373 response = 2;
374 should_close_session = TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
375 goto out;
376 }
377
378 should_close_session = FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
379 xdp_session_registercxx . . $ xdp_session_register(ac695378ab375fe8). (session);
380 }
381 else
382 {
383 should_close_session = TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
384 }
385
386 g_variant_builder_addcxx . . $ g_variant_builder_add(a422658e2ec2035a). (&results_builder, "{sv}",
387 "session_handle", g_variant_newcxx . . $ g_variant_new(59b7d1999758b6d9). ("s", session->idcxx . . $ _XdpSession#id.));
388
389 out:
390 if (request->exportedcxx . . $ _XdpRequest#exported.)
391 {
392 xdp_dbus_request_emit_responsecxx . . $ xdp_dbus_request_emit_response(6deab25eec490adc). (XDP_DBUS_REQUESTcxx . . $ `build/src/xdp-dbus.h:6732:9`! (request),
393 response,
394 g_variant_builder_endcxx . . $ g_variant_builder_end(6d60952e65fc2b86). (&results_builder));
395 xdp_request_unexportcxx . . $ xdp_request_unexport(8bf1d2bcdc4be36d). (request);
396 }
397
398 if (should_close_session)
399 xdp_session_closecxx . . $ xdp_session_close(e4dd02f38fc14a2). (session, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
400 }
401
402 static gbooleancxx . . $ gboolean#
403 handle_create_monitorcxx . . $ handle_create_monitor(75409f50a2835171). (XdpDbusInhibitcxx . . $ XdpDbusInhibit# *object,
404 GDBusMethodInvocationcxx . . $ GDBusMethodInvocation# *invocation,
405 const char *arg_window,
406 GVariantcxx . . $ GVariant# *arg_options)
407 {
408 XdpRequestcxx . . $ XdpRequest# *request = xdp_request_from_invocationcxx . . $ xdp_request_from_invocation(9583a51810815010). (invocation);
409 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GError) error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
410 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(XdpDbusImplRequest) impl_request = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
411 XdpSessioncxx . . $ XdpSession# *session;
412
413 REQUEST_AUTOLOCKcxx . . $ `src/xdp-request.h:103:9`! (request);
414
415 impl_request =
416 xdp_dbus_impl_request_proxy_new_synccxx . . $ xdp_dbus_impl_request_proxy_new_sync(b36c38a372f8f089). (g_dbus_proxy_get_connectioncxx . . $ g_dbus_proxy_get_connection(fd0690ce15ac5ecf). (G_DBUS_PROXYcxx . . $ `<external>/4635717660623816082/gdbusproxy.h:36:9`! (impl)),
417 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIEScxx . . $ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES.,
418 g_dbus_proxy_get_namecxx . . $ g_dbus_proxy_get_name(c2c3b8a4da378b0d). (G_DBUS_PROXYcxx . . $ `<external>/4635717660623816082/gdbusproxy.h:36:9`! (impl)),
419 request->idcxx . . $ _XdpRequest#id.,
420 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &error);
421 if (!impl_request)
422 {
423 g_dbus_method_invocation_return_gerrorcxx . . $ g_dbus_method_invocation_return_gerror(f84b6a1e02aa551). (invocation, error);
424 return G_DBUS_METHOD_INVOCATION_HANDLEDcxx . . $ `<external>/7877694576918326146/gdbusmethodinvocation.h:56:9`!;
425 }
426
427 xdp_request_set_impl_requestcxx . . $ xdp_request_set_impl_request(18bd0ab3b325ada4). (request, impl_request);
428 xdp_request_exportcxx . . $ xdp_request_export(49d11f351a243e17). (request, g_dbus_method_invocation_get_connectioncxx . . $ g_dbus_method_invocation_get_connection(8c6afd006dd99032). (invocation));
429
430 session = XDP_SESSIONcxx . . $ XDP_SESSION(a424cc90118498e6). (inhibit_session_newcxx . . $ inhibit_session_new(19dda4a7375a80da). (arg_options, request, &error));
431 if (!session)
432 {
433 g_dbus_method_invocation_return_gerrorcxx . . $ g_dbus_method_invocation_return_gerror(f84b6a1e02aa551). (invocation, error);
434 return G_DBUS_METHOD_INVOCATION_HANDLEDcxx . . $ `<external>/7877694576918326146/gdbusmethodinvocation.h:56:9`!;
435 }
436
437 g_object_set_data_fullcxx . . $ g_object_set_data_full(218df00be1d2a06c). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (request), "session", g_object_refcxx . . $ `<external>/1341695927569185362/gobject.h:533:9`! (session), g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8).);
438
439 xdp_dbus_impl_inhibit_call_create_monitorcxx . . $ xdp_dbus_impl_inhibit_call_create_monitor(e94dcef4e64a61d4). (implcxx . . $ impl.,
440 request->idcxx . . $ _XdpRequest#id.,
441 session->idcxx . . $ _XdpSession#id.,
442 xdp_app_info_get_idcxx . . $ xdp_app_info_get_id(b9a768ac644c9329). (request->app_infocxx . . $ _XdpRequest#app_info.),
443 arg_window,
444 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
445 create_monitor_donecxx . . $ create_monitor_done(aa1d200d824d915d).,
446 g_object_refcxx . . $ `<external>/1341695927569185362/gobject.h:533:9`! (request));
447
448 xdp_dbus_inhibit_complete_create_monitorcxx . . $ xdp_dbus_inhibit_complete_create_monitor(132c4488b08310ec). (object, invocation, request->idcxx . . $ _XdpRequest#id.);
449
450 return G_DBUS_METHOD_INVOCATION_HANDLEDcxx . . $ `<external>/7877694576918326146/gdbusmethodinvocation.h:56:9`!;
451 }
452
453 static gbooleancxx . . $ gboolean#
454 handle_query_end_responsecxx . . $ handle_query_end_response(3f7b9c8830f787c5). (XdpDbusInhibitcxx . . $ XdpDbusInhibit# *object,
455 GDBusMethodInvocationcxx . . $ GDBusMethodInvocation# *invocation,
456 const char *session_id)
457 {
458 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(XdpSession) session = xdp_session_lookupcxx . . $ xdp_session_lookup(7cb6de4f3c42cd2). (session_id);
459
460 if (!session)
461 {
462 g_dbus_method_invocation_return_errorcxx . . $ g_dbus_method_invocation_return_error(2860f9a06c72d77e). (invocation,
463 G_DBUS_ERRORcxx . . $ `<external>/517763016858796244/gdbuserror.h:49:9`!,
464 G_DBUS_ERROR_ACCESS_DENIEDcxx . . $ G_DBUS_ERROR_ACCESS_DENIED.,
465 "Invalid session");
466 return G_DBUS_METHOD_INVOCATION_HANDLEDcxx . . $ `<external>/7877694576918326146/gdbusmethodinvocation.h:56:9`!;
467 }
468
469 xdp_dbus_impl_inhibit_call_query_end_responsecxx . . $ xdp_dbus_impl_inhibit_call_query_end_response(b0510354d5f6c7f2). (implcxx . . $ impl., session->idcxx . . $ _XdpSession#id.,
470 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
471 xdp_dbus_inhibit_complete_query_end_responsecxx . . $ xdp_dbus_inhibit_complete_query_end_response(3d1cf80a024c6bfc). (object, invocation);
472
473 return G_DBUS_METHOD_INVOCATION_HANDLEDcxx . . $ `<external>/7877694576918326146/gdbusmethodinvocation.h:56:9`!;
474 }
475
476
477 static void
478 inhibit_iface_initcxx . . $ inhibit_iface_init(d1add2dbf976090). (XdpDbusInhibitIfacecxx . . $ XdpDbusInhibitIface# *iface)
479 {
480 iface->handle_inhibitcxx . . $ _XdpDbusInhibitIface#handle_inhibit. = handle_inhibitcxx . . $ handle_inhibit(91e027c802f0ef96).;
481 iface->handle_create_monitorcxx . . $ _XdpDbusInhibitIface#handle_create_monitor. = handle_create_monitorcxx . . $ handle_create_monitor(75409f50a2835171).;
482 iface->handle_query_end_responsecxx . . $ _XdpDbusInhibitIface#handle_query_end_response. = handle_query_end_responsecxx . . $ handle_query_end_response(3f7b9c8830f787c5).;
483 }
484
485 static void
486 inhibit_initcxx . . $ inhibit_init(c6f9460fea394520). (Inhibitcxx . . $ Inhibit# *inhibit)
487 {
488 xdp_dbus_inhibit_set_versioncxx . . $ xdp_dbus_inhibit_set_version(8824b2c24a23e76d). (XDP_DBUS_INHIBITcxx . . $ `build/src/xdp-dbus.h:3402:9`! (inhibit), 3);
489 }
490
491 static void
492 inhibit_class_initcxx . . $ inhibit_class_init(e33b71e5a9110914). (InhibitClasscxx . . $ InhibitClass# *klass)
493 {
494 }
495
496 static void
497 state_changed_cbcxx . . $ state_changed_cb(936d22a23c51ded5). (XdpDbusImplInhibitcxx . . $ XdpDbusImplInhibit# *impl,
498 const char *session_id,
499 GVariantcxx . . $ GVariant# *state,
500 gpointercxx . . $ gpointer# data)
501 {
502 GDBusConnectioncxx . . $ GDBusConnection# *connection = g_dbus_proxy_get_connectioncxx . . $ g_dbus_proxy_get_connection(fd0690ce15ac5ecf). (G_DBUS_PROXYcxx . . $ `<external>/4635717660623816082/gdbusproxy.h:36:9`! (impl));
503 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(XdpSession) session = xdp_session_lookupcxx . . $ xdp_session_lookup(7cb6de4f3c42cd2). (session_id);
504 InhibitSessioncxx . . $ InhibitSession# *inhibit_session = INHIBIT_SESSIONcxx . . $ INHIBIT_SESSION(80b9dbcbee079200). (session);
505 gbooleancxx . . $ gboolean# active = FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
506 guint32cxx . . $ guint32# session_state = 0;
507
508 g_variant_lookupcxx . . $ g_variant_lookup(7f27c6838ade8909). (state, "screensaver-active", "b", &active);
509 g_variant_lookupcxx . . $ g_variant_lookup(7f27c6838ade8909). (state, "session-state", "u", &session_state);
510 g_debugcxx . . $ `<external>/5169755362661750954/gmessages.h:371:9`! ("Received state-changed %s: screensaver-active: %d, session-state: %u",
511 session_id, active, session_state);
512
513 if (inhibit_session && !inhibit_session->closedcxx . . $ _InhibitSession#closed.)
514 g_dbus_connection_emit_signalcxx . . $ g_dbus_connection_emit_signal(e1c7067f953d4fcb). (connection,
515 session->sendercxx . . $ _XdpSession#sender.,
516 "/org/freedesktop/portal/desktop",
517 "org.freedesktop.portal.Inhibit",
518 "StateChanged",
519 g_variant_newcxx . . $ g_variant_new(59b7d1999758b6d9). ("(o@a{sv})", session_id, state),
520 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
521 }
522
523 GDBusInterfaceSkeletoncxx . . $ GDBusInterfaceSkeleton# *
524 inhibit_createcxx . . $ inhibit_create(e35f8a0759ac8f9a). (GDBusConnectioncxx . . $ GDBusConnection# *connection,
525 const char *dbus_name)
526 {
527 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GError) error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
528
529 implcxx . . $ impl. = xdp_dbus_impl_inhibit_proxy_new_synccxx . . $ xdp_dbus_impl_inhibit_proxy_new_sync(10b35150a2a80f3c). (connection,
530 G_DBUS_PROXY_FLAGS_NONEcxx . . $ G_DBUS_PROXY_FLAGS_NONE.,
531 dbus_name,
532 "/org/freedesktop/portal/desktop",
533 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &error);
534 if (implcxx . . $ impl. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
535 {
536 g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("Failed to create inhibit proxy: %s", error->message);
537 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
538 }
539
540 g_dbus_proxy_set_default_timeoutcxx . . $ g_dbus_proxy_set_default_timeout(c68bf28eca88e1d4). (G_DBUS_PROXYcxx . . $ `<external>/4635717660623816082/gdbusproxy.h:36:9`! (impl), G_MAXINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:39:9`!);
541
542 inhibitcxx . . $ inhibit. = g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (inhibit_get_typecxx . . $ inhibit_get_type(f708dce9a8856c70). (), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
543
544 g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (impl, "state-changed", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (state_changed_cb), inhibit);
545
546 return G_DBUS_INTERFACE_SKELETONcxx . . $ `<external>/1991948168568871819/gdbusinterfaceskeleton.h:32:9`! (inhibit);
547 }