Bug Summary

File:ctk/ctkapplication-dbus.c
Warning:line 698, column 41
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name ctkapplication-dbus.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/ctk -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Ctk" -D G_LOG_USE_STRUCTURED=1 -D CTK_VERSION="3.25.5" -D CTK_BINARY_VERSION="3.0.0" -D CTK_COMPILATION -D CTK_PRINT_BACKEND_ENABLE_UNSUPPORTED -D CTK_LIBDIR="/usr/lib" -D CTK_LOCALEDIR="/usr/share/locale" -D CTK_DATADIR="/usr/share" -D CTK_DATA_PREFIX="/usr" -D CTK_SYSCONFDIR="/usr/etc" -D CTK_HOST="x86_64-pc-linux-gnu" -D CTK_PRINT_BACKENDS="file,cups" -D X11_DATA_PREFIX="/usr" -D ISO_CODES_PREFIX="" -I .. -I ../ctk -I .. -I ../cdk -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -D G_ENABLE_DEBUG -D G_ENABLE_CONSISTENCY_CHECKS -D GLIB_MIN_REQUIRED_VERSION=GLIB_VERSION_2_66 -D GLIB_MAX_ALLOWED_VERSION=GLIB_VERSION_2_66 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/atk-1.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/gio-unix-2.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/pango-1.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -D PIC -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/ctk -ferror-limit 19 -fvisibility=hidden -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-09-19-172241-43638-1 -x c ctkapplication-dbus.c
1/*
2 * Copyright © 2010 Codethink Limited
3 * Copyright © 2012 Red Hat, Inc.
4 * Copyright © 2013 Canonical Limited
5 *
6 * This library 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 of the licence, 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 * Author: Ryan Lortie <desrt@desrt.ca>
20 * Matthias Clasen <mclasen@redhat.com>
21 */
22
23#include "config.h"
24
25#include "ctkapplicationprivate.h"
26#include "ctksettings.h"
27#include "ctkprivate.h"
28
29#include "cdk/cdk-private.h"
30
31G_DEFINE_TYPE (CtkApplicationImplDBus, ctk_application_impl_dbus, CTK_TYPE_APPLICATION_IMPL)static void ctk_application_impl_dbus_init (CtkApplicationImplDBus
*self); static void ctk_application_impl_dbus_class_init (CtkApplicationImplDBusClass
*klass); static GType ctk_application_impl_dbus_get_type_once
(void); static gpointer ctk_application_impl_dbus_parent_class
= ((void*)0); static gint CtkApplicationImplDBus_private_offset
; static void ctk_application_impl_dbus_class_intern_init (gpointer
klass) { ctk_application_impl_dbus_parent_class = g_type_class_peek_parent
(klass); if (CtkApplicationImplDBus_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CtkApplicationImplDBus_private_offset); ctk_application_impl_dbus_class_init
((CtkApplicationImplDBusClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer ctk_application_impl_dbus_get_instance_private
(CtkApplicationImplDBus *self) { return (((gpointer) ((guint8
*) (self) + (glong) (CtkApplicationImplDBus_private_offset)))
); } GType ctk_application_impl_dbus_get_type (void) { static
GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); (void) (0 ? (gpointer) * (
&static_g_define_type_id) : ((void*)0)); (!(__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= ctk_application_impl_dbus_get_type_once (); (__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); 0 ? (void
) (*(&static_g_define_type_id) = (g_define_type_id)) : (void
) 0; g_once_init_leave_pointer ((&static_g_define_type_id
), (gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ctk_application_impl_dbus_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ctk_application_impl_get_type ()), g_intern_static_string (
"CtkApplicationImplDBus"), sizeof (CtkApplicationImplDBusClass
), (GClassInitFunc)(void (*)(void)) ctk_application_impl_dbus_class_intern_init
, sizeof (CtkApplicationImplDBus), (GInstanceInitFunc)(void (
*)(void)) ctk_application_impl_dbus_init, (GTypeFlags) 0); { {
{};} } return g_define_type_id; }
32
33#define GNOME_DBUS_NAME"org.gnome.SessionManager" "org.gnome.SessionManager"
34#define GNOME_DBUS_OBJECT_PATH"/org/gnome/SessionManager" "/org/gnome/SessionManager"
35#define GNOME_DBUS_INTERFACE"org.gnome.SessionManager" "org.gnome.SessionManager"
36#define GNOME_DBUS_CLIENT_INTERFACE"org.gnome.SessionManager.ClientPrivate" "org.gnome.SessionManager.ClientPrivate"
37#define XFCE_DBUS_NAME"org.xfce.SessionManager" "org.xfce.SessionManager"
38#define XFCE_DBUS_OBJECT_PATH"/org/xfce/SessionManager" "/org/xfce/SessionManager"
39#define XFCE_DBUS_INTERFACE"org.xfce.Session.Manager" "org.xfce.Session.Manager"
40#define XFCE_DBUS_CLIENT_INTERFACE"org.xfce.Session.Client" "org.xfce.Session.Client"
41#define GNOME_SCREENSAVER_DBUS_NAME"org.gnome.ScreenSaver" "org.gnome.ScreenSaver"
42#define GNOME_SCREENSAVER_DBUS_OBJECT_PATH"/org/gnome/ScreenSaver" "/org/gnome/ScreenSaver"
43#define GNOME_SCREENSAVER_DBUS_INTERFACE"org.gnome.ScreenSaver" "org.gnome.ScreenSaver"
44
45static void
46unregister_client (CtkApplicationImplDBus *dbus)
47{
48 GError *error = NULL((void*)0);
49
50 g_debug ("Unregistering client");
51
52 g_dbus_proxy_call_sync (dbus->sm_proxy,
53 "UnregisterClient",
54 g_variant_new ("(o)", dbus->client_path),
55 G_DBUS_CALL_FLAGS_NONE,
56 G_MAXINT2147483647,
57 NULL((void*)0),
58 &error);
59
60 if (error)
61 {
62 g_warning ("Failed to unregister client: %s", error->message);
63 g_error_free (error);
64 }
65
66 g_clear_object (&dbus->client_proxy)do { _Static_assert (sizeof *((&dbus->client_proxy)) ==
sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&dbus->client_proxy))) _pp = ((&dbus->client_proxy
)); __typeof__ (*((&dbus->client_proxy))) _ptr = *_pp;
*_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while
(0)
;
67
68 g_free (dbus->client_path);
69 dbus->client_path = NULL((void*)0);
70}
71
72static void
73send_quit_response (CtkApplicationImplDBus *dbus,
74 gboolean will_quit,
75 const gchar *reason)
76{
77 g_debug ("Calling EndSessionResponse %d '%s'", will_quit, reason);
78
79 g_dbus_proxy_call (dbus->client_proxy,
80 "EndSessionResponse",
81 g_variant_new ("(bs)", will_quit, reason ? reason : ""),
82 G_DBUS_CALL_FLAGS_NONE,
83 G_MAXINT2147483647,
84 NULL((void*)0), NULL((void*)0), NULL((void*)0));
85}
86
87static void
88client_proxy_signal (GDBusProxy *proxy G_GNUC_UNUSED__attribute__ ((__unused__)),
89 const gchar *sender_name G_GNUC_UNUSED__attribute__ ((__unused__)),
90 const gchar *signal_name,
91 GVariant *parameters G_GNUC_UNUSED__attribute__ ((__unused__)),
92 gpointer user_data)
93{
94 CtkApplicationImplDBus *dbus = user_data;
95
96 if (g_str_equal (signal_name, "QueryEndSession")(strcmp ((const char *) (signal_name), (const char *) ("QueryEndSession"
)) == 0)
)
97 {
98 g_debug ("Received QueryEndSession");
99 g_signal_emit_by_name (dbus->impl.application, "query-end");
100 send_quit_response (dbus, TRUE(!(0)), NULL((void*)0));
101 }
102 else if (g_str_equal (signal_name, "CancelEndSession")(strcmp ((const char *) (signal_name), (const char *) ("CancelEndSession"
)) == 0)
)
103 {
104 g_debug ("Received CancelEndSession");
105 }
106 else if (g_str_equal (signal_name, "EndSession")(strcmp ((const char *) (signal_name), (const char *) ("EndSession"
)) == 0)
)
107 {
108 g_debug ("Received EndSession");
109 send_quit_response (dbus, TRUE(!(0)), NULL((void*)0));
110 unregister_client (dbus);
111 g_application_quit (G_APPLICATION (dbus->impl.application)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dbus->impl.application)), ((g_application_get_type ()
))))))
);
112 }
113 else if (g_str_equal (signal_name, "Stop")(strcmp ((const char *) (signal_name), (const char *) ("Stop"
)) == 0)
)
114 {
115 g_debug ("Received Stop");
116 unregister_client (dbus);
117 g_application_quit (G_APPLICATION (dbus->impl.application)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dbus->impl.application)), ((g_application_get_type ()
))))))
);
118 }
119}
120
121static GDBusProxy*
122ctk_application_get_proxy_if_service_present (GDBusConnection *connection,
123 GDBusProxyFlags flags,
124 const gchar *bus_name,
125 const gchar *object_path,
126 const gchar *interface,
127 GError **error)
128{
129 GDBusProxy *proxy;
130 gchar *owner;
131
132 proxy = g_dbus_proxy_new_sync (connection,
133 flags,
134 NULL((void*)0),
135 bus_name,
136 object_path,
137 interface,
138 NULL((void*)0),
139 error);
140
141 if (!proxy)
142 return NULL((void*)0);
143
144 /* is there anyone actually providing the service? */
145 owner = g_dbus_proxy_get_name_owner (proxy);
146 if (owner == NULL((void*)0))
147 {
148 g_clear_object (&proxy)do { _Static_assert (sizeof *((&proxy)) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ (((&proxy
))) _pp = ((&proxy)); __typeof__ (*((&proxy))) _ptr =
*_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); }
while (0)
;
149 g_set_error (error, G_DBUS_ERRORg_dbus_error_quark(), G_DBUS_ERROR_NAME_HAS_NO_OWNER,
150 "The name %s is not owned", bus_name);
151 }
152 else
153 g_free (owner);
154
155 return proxy;
156}
157
158static void
159screensaver_signal_session (GDBusProxy *proxy G_GNUC_UNUSED__attribute__ ((__unused__)),
160 const char *sender_name G_GNUC_UNUSED__attribute__ ((__unused__)),
161 const char *signal_name,
162 GVariant *parameters,
163 CtkApplication *application)
164{
165 gboolean active;
166
167 if (!g_str_equal (signal_name, "ActiveChanged")(strcmp ((const char *) (signal_name), (const char *) ("ActiveChanged"
)) == 0)
)
168 return;
169
170 g_variant_get (parameters, "(b)", &active);
171 ctk_application_set_screensaver_active (application, active);
172}
173
174enum {
175 UNKNOWN = 0,
176 RUNNING = 1,
177 QUERY_END = 2,
178 ENDING = 3
179};
180
181static void
182screensaver_signal_portal (GDBusConnection *connection G_GNUC_UNUSED__attribute__ ((__unused__)),
183 const char *sender_name G_GNUC_UNUSED__attribute__ ((__unused__)),
184 const char *object_path G_GNUC_UNUSED__attribute__ ((__unused__)),
185 const char *interface_name G_GNUC_UNUSED__attribute__ ((__unused__)),
186 const char *signal_name,
187 GVariant *parameters,
188 gpointer data)
189{
190 CtkApplicationImplDBus *dbus = (CtkApplicationImplDBus *)data;
191 CtkApplication *application = data;
192 gboolean active;
193 GVariant *state;
194 guint32 session_state = UNKNOWN;
195
196 if (!g_str_equal (signal_name, "StateChanged")(strcmp ((const char *) (signal_name), (const char *) ("StateChanged"
)) == 0)
)
197 return;
198
199 g_variant_get (parameters, "(o@a{sv})", NULL((void*)0), &state);
200 g_variant_lookup (state, "screensaver-active", "b", &active);
201 ctk_application_set_screensaver_active (dbus->impl.application, active);
202
203 g_variant_lookup (state, "session-state", "u", &session_state);
204 if (session_state != dbus->session_state)
205 {
206 dbus->session_state = session_state;
207
208 /* Note that we'll only ever get here if we get a session-state,
209 * in which case, the interface is new enough to have QueryEndResponse.
210 */
211 if (session_state == ENDING)
212 {
213 g_application_quit (G_APPLICATION (application)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((application)), ((g_application_get_type ()))))))
);
214 }
215 else if (session_state == QUERY_END)
216 {
217 g_signal_emit_by_name (dbus->impl.application, "query-end");
218
219 g_dbus_proxy_call (dbus->inhibit_proxy,
220 "QueryEndResponse",
221 g_variant_new ("(o)", dbus->session_id),
222 G_DBUS_CALL_FLAGS_NONE,
223 G_MAXINT2147483647,
224 NULL((void*)0),
225 NULL((void*)0), NULL((void*)0));
226 }
227 }
228}
229
230static void
231create_monitor_cb (GObject *source,
232 GAsyncResult *result,
233 gpointer data G_GNUC_UNUSED__attribute__ ((__unused__)))
234{
235 GDBusProxy *proxy = G_DBUS_PROXY (source)((((GDBusProxy*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((source)), ((g_dbus_proxy_get_type ()))))))
;
236 GError *error = NULL((void*)0);
237 GVariant *ret = NULL((void*)0);
238
239 ret = g_dbus_proxy_call_finish (proxy, result, &error);
240 if (ret == NULL((void*)0))
241 {
242 g_warning ("Creating a portal monitor failed: %s", error->message);
243 g_error_free (error);
244 return;
245 }
246
247 g_variant_unref (ret);
248}
249
250static void
251ctk_application_impl_dbus_startup (CtkApplicationImpl *impl,
252 gboolean register_session)
253{
254 CtkApplicationImplDBus *dbus = (CtkApplicationImplDBus *) impl;
255 GError *error = NULL((void*)0);
256 GVariant *res;
257 gboolean same_bus;
258 const char *bus_name;
259 const char *client_interface;
260 const char *client_id = CDK_PRIVATE_CALL (cdk_get_desktop_autostart_id)(cdk__private__ ()->cdk_get_desktop_autostart_id) ();
261
262 dbus->session = g_application_get_dbus_connection (G_APPLICATION (impl->application)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((impl->application)), ((g_application_get_type ())))))
)
);
263
264 if (!dbus->session)
265 goto out;
266
267 dbus->application_id = g_application_get_application_id (G_APPLICATION (impl->application)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((impl->application)), ((g_application_get_type ())))))
)
);
268 dbus->object_path = g_application_get_dbus_object_path (G_APPLICATION (impl->application)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((impl->application)), ((g_application_get_type ())))))
)
);
269 dbus->unique_name = g_dbus_connection_get_unique_name (dbus->session);
270
271 if (ctk_should_use_portal ())
272 goto out;
273
274 g_debug ("Connecting to session manager");
275
276 /* Try the GNOME session manager first */
277 dbus->sm_proxy = ctk_application_get_proxy_if_service_present (dbus->session,
278 G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
279 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
280 G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
281 GNOME_DBUS_NAME"org.gnome.SessionManager",
282 GNOME_DBUS_OBJECT_PATH"/org/gnome/SessionManager",
283 GNOME_DBUS_INTERFACE"org.gnome.SessionManager",
284 &error);
285
286 if (error)
287 {
288 g_debug ("Failed to get the GNOME session proxy: %s", error->message);
289 g_clear_error (&error);
290 }
291
292 if (!dbus->sm_proxy)
293 {
294 /* Fallback to trying the Xfce session manager */
295 dbus->sm_proxy = ctk_application_get_proxy_if_service_present (dbus->session,
296 G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
297 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
298 G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
299 XFCE_DBUS_NAME"org.xfce.SessionManager",
300 XFCE_DBUS_OBJECT_PATH"/org/xfce/SessionManager",
301 XFCE_DBUS_INTERFACE"org.xfce.Session.Manager",
302 &error);
303
304 if (error)
305 {
306 g_debug ("Failed to get the Xfce session proxy: %s", error->message);
307 g_clear_error (&error);
308 goto out;
309 }
310 }
311
312 if (!register_session)
313 goto out;
314
315 dbus->ss_proxy = ctk_application_get_proxy_if_service_present (dbus->session,
316 G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
317 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
318 G_DBUS_PROXY_FLAGS_NONE,
319 GNOME_SCREENSAVER_DBUS_NAME"org.gnome.ScreenSaver",
320 GNOME_SCREENSAVER_DBUS_OBJECT_PATH"/org/gnome/ScreenSaver",
321 GNOME_SCREENSAVER_DBUS_INTERFACE"org.gnome.ScreenSaver",
322 &error);
323 if (error)
324 {
325 g_debug ("Failed to get the GNOME screensaver proxy: %s", error->message);
326 g_clear_error (&error);
327 g_clear_object (&dbus->ss_proxy)do { _Static_assert (sizeof *((&dbus->ss_proxy)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&dbus->ss_proxy))) _pp = ((&dbus->ss_proxy)); __typeof__
(*((&dbus->ss_proxy))) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_object_unref) (_ptr); } while (0)
;
328 }
329
330 if (dbus->ss_proxy)
331 {
332 GVariant *active_var;
333 gboolean active;
334
335 g_signal_connect (dbus->ss_proxy, "g-signal",g_signal_connect_data ((dbus->ss_proxy), ("g-signal"), (((
GCallback) (screensaver_signal_session))), (impl->application
), ((void*)0), (GConnectFlags) 0)
336 G_CALLBACK (screensaver_signal_session), impl->application)g_signal_connect_data ((dbus->ss_proxy), ("g-signal"), (((
GCallback) (screensaver_signal_session))), (impl->application
), ((void*)0), (GConnectFlags) 0)
;
337
338 active_var = g_dbus_proxy_call_sync (dbus->ss_proxy,
339 "GetActive",
340 NULL((void*)0),
341 G_DBUS_CALL_FLAGS_NONE,
342 G_MAXINT2147483647,
343 NULL((void*)0),
344 &error);
345 if (!active_var)
346 {
347 g_debug ("Error calling GetActive on GNOME screensaver: %s",
348 error->message);
349 g_clear_error (&error);
350 }
351 else
352 {
353 g_variant_get (active_var, "(b)", &active);
354 g_variant_unref (active_var);
355 ctk_application_set_screensaver_active (dbus->impl.application, active);
356 }
357 }
358
359 g_debug ("Registering client '%s' '%s'", dbus->application_id, client_id);
360
361 res = g_dbus_proxy_call_sync (dbus->sm_proxy,
362 "RegisterClient",
363 g_variant_new ("(ss)", dbus->application_id, client_id),
364 G_DBUS_CALL_FLAGS_NONE,
365 G_MAXINT2147483647,
366 NULL((void*)0),
367 &error);
368
369 if (error)
370 {
371 g_warning ("Failed to register client: %s", error->message);
372 g_clear_error (&error);
373 g_clear_object (&dbus->sm_proxy)do { _Static_assert (sizeof *((&dbus->sm_proxy)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&dbus->sm_proxy))) _pp = ((&dbus->sm_proxy)); __typeof__
(*((&dbus->sm_proxy))) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_object_unref) (_ptr); } while (0)
;
374 goto out;
375 }
376
377 g_variant_get (res, "(o)", &dbus->client_path);
378 g_variant_unref (res);
379
380 g_debug ("Registered client at '%s'", dbus->client_path);
381
382 if (g_str_equal (g_dbus_proxy_get_name (dbus->sm_proxy), GNOME_DBUS_NAME)(strcmp ((const char *) (g_dbus_proxy_get_name (dbus->sm_proxy
)), (const char *) ("org.gnome.SessionManager")) == 0)
)
383 {
384 bus_name = GNOME_DBUS_NAME"org.gnome.SessionManager";
385 client_interface = GNOME_DBUS_CLIENT_INTERFACE"org.gnome.SessionManager.ClientPrivate";
386 }
387 else
388 {
389 bus_name = XFCE_DBUS_NAME"org.xfce.SessionManager";
390 client_interface = XFCE_DBUS_CLIENT_INTERFACE"org.xfce.Session.Client";
391 }
392
393 dbus->client_proxy = g_dbus_proxy_new_sync (dbus->session, 0,
394 NULL((void*)0),
395 bus_name,
396 dbus->client_path,
397 client_interface,
398 NULL((void*)0),
399 &error);
400 if (error)
401 {
402 g_warning ("Failed to get client proxy: %s", error->message);
403 g_clear_error (&error);
404 g_free (dbus->client_path);
405 dbus->client_path = NULL((void*)0);
406 goto out;
407 }
408
409 g_signal_connect (dbus->client_proxy, "g-signal", G_CALLBACK (client_proxy_signal), dbus)g_signal_connect_data ((dbus->client_proxy), ("g-signal"),
(((GCallback) (client_proxy_signal))), (dbus), ((void*)0), (
GConnectFlags) 0)
;
410
411 out:
412 same_bus = FALSE(0);
413
414 if (dbus->session)
415 {
416 const gchar *id;
417 const gchar *id2;
418 GValue value = G_VALUE_INIT{ 0, { { 0 } } };
419
420 g_value_init (&value, G_TYPE_STRING((GType) ((16) << (2))));
421 cdk_screen_get_setting (cdk_screen_get_default (), "ctk-session-bus-id", &value);
422 id = g_value_get_string (&value);
423
424 if (id && id[0])
425 {
426 res = g_dbus_connection_call_sync (dbus->session,
427 "org.freedesktop.DBus",
428 "/org/freedesktop/DBus",
429 "org.freedesktop.DBus",
430 "GetId",
431 NULL((void*)0),
432 NULL((void*)0),
433 G_DBUS_CALL_FLAGS_NONE,
434 -1,
435 NULL((void*)0),
436 NULL((void*)0));
437 if (res)
438 {
439 g_variant_get (res, "(&s)", &id2);
440
441 if (g_strcmp0 (id, id2) == 0)
442 same_bus = TRUE(!(0));
443
444 g_variant_unref (res);
445 }
446 }
447 else
448 same_bus = TRUE(!(0));
449
450 g_value_unset (&value);
451 }
452
453 if (!same_bus)
454 g_object_set (ctk_settings_get_default (),
455 "ctk-shell-shows-app-menu", FALSE(0),
456 "ctk-shell-shows-menubar", FALSE(0),
457 NULL((void*)0));
458
459 if (dbus->sm_proxy == NULL((void*)0) && dbus->session)
460 {
461 dbus->inhibit_proxy = ctk_application_get_proxy_if_service_present (dbus->session,
462 G_DBUS_PROXY_FLAGS_NONE,
463 "org.freedesktop.portal.Desktop",
464 "/org/freedesktop/portal/desktop",
465 "org.freedesktop.portal.Inhibit",
466 &error);
467 if (error)
468 {
469 g_debug ("Failed to get an inhibit portal proxy: %s", error->message);
470 g_clear_error (&error);
471 goto end;
472 }
473
474 if (register_session)
475 {
476 char *token;
477 GVariantBuilder opt_builder;
478
479 /* Monitor screensaver state */
480
481 dbus->session_id = ctk_get_portal_session_path (dbus->session, &token);
482 dbus->state_changed_handler =
483 g_dbus_connection_signal_subscribe (dbus->session,
484 "org.freedesktop.portal.Desktop",
485 "org.freedesktop.portal.Inhibit",
486 "StateChanged",
487 "/org/freedesktop/portal/desktop",
488 NULL((void*)0),
489 G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE,
490 screensaver_signal_portal,
491 dbus,
492 NULL((void*)0));
493 g_variant_builder_init (&opt_builder, G_VARIANT_TYPE_VARDICT((const GVariantType *) "a{sv}"));
494 g_variant_builder_add (&opt_builder, "{sv}",
495 "session_handle_token", g_variant_new_string (token));
496 g_dbus_proxy_call (dbus->inhibit_proxy,
497 "CreateMonitor",
498 g_variant_new ("(sa{sv})", "", &opt_builder),
499 G_DBUS_CALL_FLAGS_NONE,
500 G_MAXINT2147483647,
501 NULL((void*)0),
502 create_monitor_cb, dbus);
503 g_free (token);
504 }
505 }
506
507end:;
508}
509
510static void
511ctk_application_impl_dbus_shutdown (CtkApplicationImpl *impl G_GNUC_UNUSED__attribute__ ((__unused__)))
512{
513}
514
515GQuark ctk_application_impl_dbus_export_id_quark (void);
516
517G_DEFINE_QUARK (CtkApplicationImplDBus export id, ctk_application_impl_dbus_export_id)GQuark ctk_application_impl_dbus_export_id_quark (void) { static
GQuark q; if (q == 0) q = g_quark_from_static_string ("CtkApplicationImplDBus export id"
); return q; }
518
519static void
520ctk_application_impl_dbus_window_added (CtkApplicationImpl *impl,
521 CtkWindow *window)
522{
523 CtkApplicationImplDBus *dbus = (CtkApplicationImplDBus *) impl;
524 GActionGroup *actions;
525 gchar *path;
526 guint id;
527
528 if (!dbus->session || !CTK_IS_APPLICATION_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); GType __t = ((ctk_application_window_get_type ()))
; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class
&& __inst->g_class->g_type == __t) __r = (!(0)
); else __r = g_type_check_instance_is_a (__inst, __t); __r; }
))))
)
529 return;
530
531 /* Export the action group of this window, based on its id */
532 actions = ctk_application_window_get_action_group (CTK_APPLICATION_WINDOW (window)((((CtkApplicationWindow*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), ((ctk_application_window_get_type
()))))))
);
533
534 path = ctk_application_impl_dbus_get_window_path (dbus, window);
535 id = g_dbus_connection_export_action_group (dbus->session, path, actions, NULL((void*)0));
536 g_free (path);
537
538 g_object_set_qdata (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, ctk_application_impl_dbus_export_id_quark (), GUINT_TO_POINTER (id)((gpointer) (gulong) (id)));
539}
540
541static void
542ctk_application_impl_dbus_window_removed (CtkApplicationImpl *impl,
543 CtkWindow *window)
544{
545 CtkApplicationImplDBus *dbus = (CtkApplicationImplDBus *) impl;
546 guint id;
547
548 id = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (window), ctk_application_impl_dbus_export_id_quark ()))((guint) (gulong) (g_object_get_qdata (((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((window)), (((
GType) ((20) << (2)))))))), ctk_application_impl_dbus_export_id_quark
())))
;
549 if (id)
550 {
551 g_dbus_connection_unexport_action_group (dbus->session, id);
552 g_object_set_qdata (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, ctk_application_impl_dbus_export_id_quark (), NULL((void*)0));
553 }
554}
555
556static void
557ctk_application_impl_dbus_active_window_changed (CtkApplicationImpl *impl G_GNUC_UNUSED__attribute__ ((__unused__)),
558 CtkWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)))
559{
560}
561
562static void
563ctk_application_impl_dbus_publish_menu (CtkApplicationImplDBus *dbus,
564 const gchar *type,
565 GMenuModel *model,
566 guint *id,
567 gchar **path)
568{
569 gint i;
570
571 if (dbus->session == NULL((void*)0))
572 return;
573
574 /* unexport any existing menu */
575 if (*id)
576 {
577 g_dbus_connection_unexport_menu_model (dbus->session, *id);
578 g_free (*path);
579 *path = NULL((void*)0);
580 *id = 0;
581 }
582
583 /* export the new menu, if there is one */
584 if (model != NULL((void*)0))
585 {
586 /* try getting the preferred name */
587 *path = g_strconcat (dbus->object_path, "/menus/", type, NULL((void*)0));
588 *id = g_dbus_connection_export_menu_model (dbus->session, *path, model, NULL((void*)0));
589
590 /* keep trying until we get a working name... */
591 for (i = 0; *id == 0; i++)
592 {
593 g_free (*path);
594 *path = g_strdup_printf ("%s/menus/%s%d", dbus->object_path, type, i);
595 *id = g_dbus_connection_export_menu_model (dbus->session, *path, model, NULL((void*)0));
596 }
597 }
598}
599
600static void
601ctk_application_impl_dbus_set_app_menu (CtkApplicationImpl *impl,
602 GMenuModel *app_menu)
603{
604 CtkApplicationImplDBus *dbus = (CtkApplicationImplDBus *) impl;
605
606 ctk_application_impl_dbus_publish_menu (dbus, "appmenu", app_menu, &dbus->app_menu_id, &dbus->app_menu_path);
607}
608
609static void
610ctk_application_impl_dbus_set_menubar (CtkApplicationImpl *impl,
611 GMenuModel *menubar)
612{
613 CtkApplicationImplDBus *dbus = (CtkApplicationImplDBus *) impl;
614
615 ctk_application_impl_dbus_publish_menu (dbus, "menubar", menubar, &dbus->menubar_id, &dbus->menubar_path);
616}
617
618static GVariant *
619ctk_application_impl_dbus_real_get_window_system_id (CtkApplicationImplDBus *dbus G_GNUC_UNUSED__attribute__ ((__unused__)),
620 CtkWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)))
621{
622 return g_variant_new_uint32 (0);
623}
624
625/* returns floating */
626static GVariant *
627ctk_application_impl_dbus_get_window_system_id (CtkApplicationImplDBus *dbus,
628 CtkWindow *window)
629{
630 return CTK_APPLICATION_IMPL_DBUS_GET_CLASS (dbus)((((CtkApplicationImplDBusClass*) (((GTypeInstance*) ((dbus))
)->g_class))))
->get_window_system_id (dbus, window);
631}
632
633static int next_cookie;
634
635typedef struct {
636 char *handle;
637 int cookie;
638} InhibitHandle;
639
640static void
641inhibit_handle_free (gpointer data)
642{
643 InhibitHandle *handle = data;
644
645 g_free (handle->handle);
646 g_free (handle);
647}
648
649static guint
650ctk_application_impl_dbus_inhibit (CtkApplicationImpl *impl,
651 CtkWindow *window,
652 CtkApplicationInhibitFlags flags,
653 const gchar *reason)
654{
655 CtkApplicationImplDBus *dbus = (CtkApplicationImplDBus *) impl;
656 GVariant *res;
657 GError *error = NULL((void*)0);
658 guint cookie;
659 static gboolean warned = FALSE(0);
660
661 if (dbus->sm_proxy)
662 {
663 res = g_dbus_proxy_call_sync (dbus->sm_proxy,
664 "Inhibit",
665 g_variant_new ("(s@usu)",
666 dbus->application_id,
667 window ? ctk_application_impl_dbus_get_window_system_id (dbus, window) : g_variant_new_uint32 (0),
668 reason ? reason : "",
669 flags),
670 G_DBUS_CALL_FLAGS_NONE,
671 G_MAXINT2147483647,
672 NULL((void*)0),
673 &error);
674
675 if (res)
676 {
677 g_variant_get (res, "(u)", &cookie);
678 g_variant_unref (res);
679 return cookie;
680 }
681
682 if (error)
683 {
684 if (!warned)
685 {
686 g_warning ("Calling %s.Inhibit failed: %s",
687 g_dbus_proxy_get_interface_name (dbus->sm_proxy),
688 error->message);
689 warned = TRUE(!(0));
690 }
691 g_clear_error (&error);
692 }
693 }
694 else if (dbus->inhibit_proxy)
695 {
696 GVariantBuilder options;
697
698 g_variant_builder_init (&options, G_VARIANT_TYPE_VARDICT((const GVariantType *) "a{sv}"));
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
699 g_variant_builder_add (&options, "{sv}", "reason", g_variant_new_string (reason));
700 res = g_dbus_proxy_call_sync (dbus->inhibit_proxy,
701 "Inhibit",
702 g_variant_new ("(su@a{sv})",
703 "", /* window */
704 flags,
705 g_variant_builder_end (&options)),
706 G_DBUS_CALL_FLAGS_NONE,
707 G_MAXINT2147483647,
708 NULL((void*)0),
709 &error);
710 if (res)
711 {
712 InhibitHandle *handle;
713
714 handle = g_new (InhibitHandle, 1)((InhibitHandle *) g_malloc_n ((1), sizeof (InhibitHandle)));
715 handle->cookie = ++next_cookie;
716
717 g_variant_get (res, "(o)", &handle->handle);
718 g_variant_unref (res);
719
720 dbus->inhibit_handles = g_slist_prepend (dbus->inhibit_handles, handle);
721
722 return handle->cookie;
723 }
724
725 if (error)
726 {
727 if (!warned)
728 {
729 g_warning ("Calling %s.Inhibit failed: %s",
730 g_dbus_proxy_get_interface_name (dbus->inhibit_proxy),
731 error->message);
732 warned = TRUE(!(0));
733 }
734 g_clear_error (&error);
735 }
736 }
737
738 return 0;
739}
740
741static void
742ctk_application_impl_dbus_uninhibit (CtkApplicationImpl *impl,
743 guint cookie)
744{
745 CtkApplicationImplDBus *dbus = (CtkApplicationImplDBus *) impl;
746
747 if (dbus->sm_proxy)
748 {
749 g_dbus_proxy_call (dbus->sm_proxy,
750 "Uninhibit",
751 g_variant_new ("(u)", cookie),
752 G_DBUS_CALL_FLAGS_NONE,
753 G_MAXINT2147483647,
754 NULL((void*)0), NULL((void*)0), NULL((void*)0));
755 }
756 else if (dbus->inhibit_proxy)
757 {
758 GSList *l;
759
760 for (l = dbus->inhibit_handles; l; l = l->next)
761 {
762 InhibitHandle *handle = l->data;
763 if (handle->cookie == cookie)
764 {
765 g_dbus_connection_call (dbus->session,
766 "org.freedesktop.portal.Desktop",
767 handle->handle,
768 "org.freedesktop.portal.Request",
769 "Close",
770 g_variant_new ("()"),
771 G_VARIANT_TYPE_UNIT((const GVariantType *) "()"),
772 G_DBUS_CALL_FLAGS_NONE,
773 G_MAXINT2147483647,
774 NULL((void*)0), NULL((void*)0), NULL((void*)0));
775 dbus->inhibit_handles = g_slist_remove (dbus->inhibit_handles, handle);
776 inhibit_handle_free (handle);
777 break;
778 }
779 }
780 }
781}
782
783static gboolean
784ctk_application_impl_dbus_is_inhibited (CtkApplicationImpl *impl,
785 CtkApplicationInhibitFlags flags)
786{
787 CtkApplicationImplDBus *dbus = (CtkApplicationImplDBus *) impl;
788 GVariant *res;
789 GError *error = NULL((void*)0);
790 gboolean inhibited;
791 static gboolean warned = FALSE(0);
792
793 if (dbus->sm_proxy == NULL((void*)0))
794 return FALSE(0);
795
796 res = g_dbus_proxy_call_sync (dbus->sm_proxy,
797 "IsInhibited",
798 g_variant_new ("(u)", flags),
799 G_DBUS_CALL_FLAGS_NONE,
800 G_MAXINT2147483647,
801 NULL((void*)0),
802 &error);
803 if (error)
804 {
805 if (!warned)
806 {
807 g_warning ("Calling %s.IsInhibited failed: %s",
808 g_dbus_proxy_get_interface_name (dbus->sm_proxy),
809 error->message);
810 warned = TRUE(!(0));
811 }
812 g_error_free (error);
813 return FALSE(0);
814 }
815
816 g_variant_get (res, "(b)", &inhibited);
817 g_variant_unref (res);
818
819 return inhibited;
820}
821
822static gboolean
823ctk_application_impl_dbus_prefers_app_menu (CtkApplicationImpl *impl G_GNUC_UNUSED__attribute__ ((__unused__)))
824{
825 static gboolean decided;
826 static gboolean result;
827
828 /* We do not support notifying if/when the result changes, so make
829 * sure that once we give an answer, we will always give the same one.
830 */
831 if (!decided)
832 {
833 CtkSettings *ctk_settings;
834 gboolean show_app_menu;
835 gboolean show_menubar;
836
837 ctk_settings = ctk_settings_get_default ();
838 g_object_get (G_OBJECT (ctk_settings)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_settings)), (((GType) ((20) << (2))))))))
,
839 "ctk-shell-shows-app-menu", &show_app_menu,
840 "ctk-shell-shows-menubar", &show_menubar,
841 NULL((void*)0));
842
843 /* We prefer traditional menus when we have a shell that doesn't
844 * show the appmenu or we have a shell that shows menubars
845 * (ie: Unity)
846 */
847 result = show_app_menu && !show_menubar;
848 decided = TRUE(!(0));
849 }
850
851 return result;
852}
853
854static void
855ctk_application_impl_dbus_init (CtkApplicationImplDBus *dbus G_GNUC_UNUSED__attribute__ ((__unused__)))
856{
857}
858
859static void
860ctk_application_impl_dbus_finalize (GObject *object)
861{
862 CtkApplicationImplDBus *dbus = (CtkApplicationImplDBus *) object;
863
864 if (dbus->session_id)
865 {
866 g_dbus_connection_call (dbus->session,
867 "org.freedesktop.portal.Desktop",
868 dbus->session_id,
869 "org.freedesktop.portal.Session",
870 "Close",
871 NULL((void*)0), NULL((void*)0), 0, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0));
872
873 g_free (dbus->session_id);
874 }
875
876 if (dbus->state_changed_handler)
877 g_dbus_connection_signal_unsubscribe (dbus->session,
878 dbus->state_changed_handler);
879
880 g_clear_object (&dbus->inhibit_proxy)do { _Static_assert (sizeof *((&dbus->inhibit_proxy)) ==
sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&dbus->inhibit_proxy))) _pp = ((&dbus->inhibit_proxy
)); __typeof__ (*((&dbus->inhibit_proxy))) _ptr = *_pp
; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while
(0)
;
881 g_slist_free_full (dbus->inhibit_handles, inhibit_handle_free);
882 g_free (dbus->app_menu_path);
883 g_free (dbus->menubar_path);
884 g_clear_object (&dbus->sm_proxy)do { _Static_assert (sizeof *((&dbus->sm_proxy)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&dbus->sm_proxy))) _pp = ((&dbus->sm_proxy)); __typeof__
(*((&dbus->sm_proxy))) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_object_unref) (_ptr); } while (0)
;
885 g_clear_object (&dbus->ss_proxy)do { _Static_assert (sizeof *((&dbus->ss_proxy)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&dbus->ss_proxy))) _pp = ((&dbus->ss_proxy)); __typeof__
(*((&dbus->ss_proxy))) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_object_unref) (_ptr); } while (0)
;
886
887 G_OBJECT_CLASS (ctk_application_impl_dbus_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ctk_application_impl_dbus_parent_class)), (((GType) ((20
) << (2))))))))
->finalize (object);
888}
889
890static void
891ctk_application_impl_dbus_class_init (CtkApplicationImplDBusClass *class)
892{
893 CtkApplicationImplClass *impl_class = CTK_APPLICATION_IMPL_CLASS (class)((((CtkApplicationImplClass*) (void *) g_type_check_class_cast
((GTypeClass*) ((class)), ((ctk_application_impl_get_type ()
))))))
;
894 GObjectClass *gobject_class = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), (((GType) ((20) << (2))))))))
;
895
896 class->get_window_system_id = ctk_application_impl_dbus_real_get_window_system_id;
897
898 impl_class->startup = ctk_application_impl_dbus_startup;
899 impl_class->shutdown = ctk_application_impl_dbus_shutdown;
900 impl_class->window_added = ctk_application_impl_dbus_window_added;
901 impl_class->window_removed = ctk_application_impl_dbus_window_removed;
902 impl_class->active_window_changed = ctk_application_impl_dbus_active_window_changed;
903 impl_class->set_app_menu = ctk_application_impl_dbus_set_app_menu;
904 impl_class->set_menubar = ctk_application_impl_dbus_set_menubar;
905 impl_class->inhibit = ctk_application_impl_dbus_inhibit;
906 impl_class->uninhibit = ctk_application_impl_dbus_uninhibit;
907 impl_class->is_inhibited = ctk_application_impl_dbus_is_inhibited;
908 impl_class->prefers_app_menu = ctk_application_impl_dbus_prefers_app_menu;
909
910 gobject_class->finalize = ctk_application_impl_dbus_finalize;
911}
912
913gchar *
914ctk_application_impl_dbus_get_window_path (CtkApplicationImplDBus *dbus,
915 CtkWindow *window)
916{
917 if (dbus->session && CTK_IS_APPLICATION_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); GType __t = ((ctk_application_window_get_type ()))
; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class
&& __inst->g_class->g_type == __t) __r = (!(0)
); else __r = g_type_check_instance_is_a (__inst, __t); __r; }
))))
)
918 return g_strdup_printf ("%s/window/%d",
919 dbus->object_path,
920 ctk_application_window_get_id (CTK_APPLICATION_WINDOW (window)((((CtkApplicationWindow*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), ((ctk_application_window_get_type
()))))))
));
921 else
922 return NULL((void*)0);
923}