Bug Summary

File:cafe-settings-daemon/main.c
Warning:line 555, column 17
This statement is never executed

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 main.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 -pic-is-pie -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 -fdebug-compilation-dir=/rootdir/cafe-settings-daemon -fcoverage-compilation-dir=/rootdir/cafe-settings-daemon -resource-dir /usr/lib/llvm-19/lib/clang/19 -D HAVE_CONFIG_H -I . -I .. -D DATADIR="/usr/share" -D CAFE_SETTINGS_LOCALEDIR="/usr/share/locale" -D LIBEXECDIR="/usr/libexec" -D CAFE_SETTINGS_PLUGINDIR="/usr/lib/cafe-settings-daemon" -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/ctk-3.0 -I /usr/include/pango-1.0 -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/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -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/gdk-pixbuf-2.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/libpng16 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/cafe-desktop-2.0 -I /usr/include/ctk-3.0 -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/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -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/startup-notification-1.0 -I /usr/include/dconf -internal-isystem /usr/lib/llvm-19/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -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.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/2025-09-14-114457-64160-1 -x c main.c
1/*
2 * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program 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
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "config.h"
20
21#include <stdlib.h>
22#include <unistd.h>
23#include <libintl.h>
24#include <errno(*__errno_location ()).h>
25#include <locale.h>
26#include <signal.h>
27#include <fcntl.h>
28#include <sys/wait.h>
29
30#include <glib/gi18n.h>
31#include <glib/gstdio.h>
32#include <ctk/ctk.h>
33
34#include <dbus/dbus-glib.h>
35#include <dbus/dbus-glib-lowlevel.h>
36
37#ifdef HAVE_LIBNOTIFY1
38#include <libnotify/notify.h>
39#endif /* HAVE_LIBNOTIFY */
40
41#include "cafe-settings-manager.h"
42#include "cafe-settings-profile.h"
43
44#include <libcafe-desktop/cafe-gsettings.h>
45
46#define CSD_DBUS_NAME"org.cafe.SettingsDaemon" "org.cafe.SettingsDaemon"
47
48#define DEBUG_KEY"cafe-settings-daemon" "cafe-settings-daemon"
49#define DEBUG_SCHEMA"org.cafe.debug" "org.cafe.debug"
50
51#define CAFE_SESSION_DBUS_NAME"org.gnome.SessionManager" "org.gnome.SessionManager"
52#define CAFE_SESSION_DBUS_OBJECT"/org/gnome/SessionManager" "/org/gnome/SessionManager"
53#define CAFE_SESSION_DBUS_INTERFACE"org.gnome.SessionManager" "org.gnome.SessionManager"
54#define CAFE_SESSION_PRIVATE_DBUS_INTERFACE"org.gnome.SessionManager.ClientPrivate" "org.gnome.SessionManager.ClientPrivate"
55
56/* this is kept only for compatibility with custom .desktop files */
57static gboolean no_daemon = TRUE(!(0));
58static gboolean replace = FALSE(0);
59static gboolean debug = FALSE(0);
60static gboolean do_timed_exit = FALSE(0);
61static int term_signal_pipe_fds[2];
62
63static GOptionEntry entries[] = {
64 { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code")("Enable debugging code"), NULL((void*)0) },
65 { "replace", 0, 0, G_OPTION_ARG_NONE, &replace, N_("Replace the current daemon")("Replace the current daemon"), NULL((void*)0) },
66 { "no-daemon", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &no_daemon, N_("Don't become a daemon")("Don't become a daemon"), NULL((void*)0) },
67 { "timed-exit", 0, 0, G_OPTION_ARG_NONE, &do_timed_exit, N_("Exit after a time (for debugging)")("Exit after a time (for debugging)"), NULL((void*)0) },
68 { NULL((void*)0) }
69};
70
71static gboolean
72timed_exit_cb (void)
73{
74 ctk_main_quit ();
75 return FALSE(0);
76}
77
78static DBusGProxy *
79get_bus_proxy (DBusGConnection *connection)
80{
81 DBusGProxy *bus_proxy;
82
83 bus_proxy = dbus_g_proxy_new_for_name (connection,
84 DBUS_SERVICE_DBUS"org.freedesktop.DBus",
85 DBUS_PATH_DBUS"/org/freedesktop/DBus",
86 DBUS_INTERFACE_DBUS"org.freedesktop.DBus");
87
88 return bus_proxy;
89}
90
91static gboolean
92acquire_name_on_proxy (DBusGProxy *bus_proxy)
93{
94 GError *error;
95 guint result;
96 gboolean res;
97 gboolean ret;
98 guint32 flags;
99
100 ret = FALSE(0);
101
102 flags = DBUS_NAME_FLAG_DO_NOT_QUEUE0x4|DBUS_NAME_FLAG_ALLOW_REPLACEMENT0x1;
103 if (replace)
104 flags |= DBUS_NAME_FLAG_REPLACE_EXISTING0x2;
105
106 error = NULL((void*)0);
107 res = dbus_g_proxy_call (bus_proxy,
108 "RequestName",
109 &error,
110 G_TYPE_STRING((GType) ((16) << (2))), CSD_DBUS_NAME"org.cafe.SettingsDaemon",
111 G_TYPE_UINT((GType) ((7) << (2))), flags,
112 G_TYPE_INVALID((GType) ((0) << (2))),
113 G_TYPE_UINT((GType) ((7) << (2))), &result,
114 G_TYPE_INVALID((GType) ((0) << (2))));
115 if (! res) {
116 if (error != NULL((void*)0)) {
117 g_warning ("Failed to acquire %s: %s", CSD_DBUS_NAME"org.cafe.SettingsDaemon", error->message);
118 g_error_free (error);
119 } else {
120 g_warning ("Failed to acquire %s", CSD_DBUS_NAME"org.cafe.SettingsDaemon");
121 }
122 goto out;
123 }
124
125 if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER1) {
126 if (error != NULL((void*)0)) {
127 g_warning ("Failed to acquire %s: %s", CSD_DBUS_NAME"org.cafe.SettingsDaemon", error->message);
128 g_error_free (error);
129 } else {
130 g_warning ("Failed to acquire %s", CSD_DBUS_NAME"org.cafe.SettingsDaemon");
131 }
132 goto out;
133 }
134
135 ret = TRUE(!(0));
136
137 out:
138 return ret;
139}
140
141static DBusHandlerResult
142bus_message_handler (DBusConnection *connection G_GNUC_UNUSED__attribute__ ((__unused__)),
143 DBusMessage *message,
144 void *user_data G_GNUC_UNUSED__attribute__ ((__unused__)))
145{
146 if (dbus_message_is_signal (message,
147 DBUS_INTERFACE_LOCAL"org.freedesktop.DBus.Local",
148 "Disconnected")) {
149 ctk_main_quit ();
150 return DBUS_HANDLER_RESULT_HANDLED;
151 }
152 else if (dbus_message_is_signal (message,
153 DBUS_INTERFACE_DBUS"org.freedesktop.DBus",
154 "NameLost")) {
155 g_warning ("D-Bus name lost, quitting");
156 ctk_main_quit ();
157 return DBUS_HANDLER_RESULT_HANDLED;
158 }
159
160 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
161}
162
163static DBusGConnection *
164get_session_bus (void)
165{
166 GError *error;
167 DBusGConnection *bus;
168 DBusConnection *connection;
169
170 error = NULL((void*)0);
171 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
172 if (bus == NULL((void*)0)) {
173 g_warning ("Couldn't connect to session bus: %s",
174 error->message);
175 g_error_free (error);
176 goto out;
177 }
178
179 connection = dbus_g_connection_get_connection (bus);
180 dbus_connection_add_filter (connection,
181 (DBusHandleMessageFunction)
182 bus_message_handler,
183 NULL((void*)0), NULL((void*)0));
184
185 dbus_connection_set_exit_on_disconnect (connection, FALSE(0));
186
187 out:
188 return bus;
189}
190
191static gboolean
192bus_register (DBusGConnection *bus)
193{
194 DBusGProxy *bus_proxy;
195 gboolean ret;
196
197 cafe_settings_profile_start (NULL);
198
199 ret = FALSE(0);
200
201 bus_proxy = get_bus_proxy (bus);
202
203 if (bus_proxy == NULL((void*)0)) {
204 g_warning ("Could not construct bus_proxy object");
205 goto out;
206 }
207
208 ret = acquire_name_on_proxy (bus_proxy);
209 g_object_unref (bus_proxy);
210
211 if (!ret) {
212 g_warning ("Could not acquire name");
213 goto out;
214 }
215
216 g_debug ("Successfully connected to D-Bus");
217
218 out:
219 cafe_settings_profile_end (NULL);
220
221 return ret;
222}
223
224static void
225on_session_over (DBusGProxy *proxy G_GNUC_UNUSED__attribute__ ((__unused__)),
226 CafeSettingsManager *manager G_GNUC_UNUSED__attribute__ ((__unused__)))
227{
228 /* not used, see on_session_end instead */
229}
230
231static void
232on_session_query_end (DBusGProxy *proxy,
233 guint flags G_GNUC_UNUSED__attribute__ ((__unused__)),
234 CafeSettingsManager *manager G_GNUC_UNUSED__attribute__ ((__unused__)))
235{
236 GError *error = NULL((void*)0);
237 gboolean ret = FALSE(0);
238
239 /* send response */
240 ret = dbus_g_proxy_call (proxy, "EndSessionResponse", &error,
241 G_TYPE_BOOLEAN((GType) ((5) << (2))), TRUE(!(0)) /* ok */,
242 G_TYPE_STRING((GType) ((16) << (2))), NULL((void*)0) /* reason */,
243 G_TYPE_INVALID((GType) ((0) << (2))),
244 G_TYPE_INVALID((GType) ((0) << (2))));
245 if (!ret) {
246 g_warning ("failed to send session response: %s", error->message);
247 g_error_free (error);
248 }
249}
250
251static void
252on_session_end (DBusGProxy *proxy,
253 guint flags G_GNUC_UNUSED__attribute__ ((__unused__)),
254 CafeSettingsManager *manager)
255{
256 GError *error = NULL((void*)0);
257 gboolean ret = FALSE(0);
258
259 /* send response */
260 ret = dbus_g_proxy_call (proxy, "EndSessionResponse", &error,
261 G_TYPE_BOOLEAN((GType) ((5) << (2))), TRUE(!(0)) /* ok */,
262 G_TYPE_STRING((GType) ((16) << (2))), NULL((void*)0) /* reason */,
263 G_TYPE_INVALID((GType) ((0) << (2))),
264 G_TYPE_INVALID((GType) ((0) << (2))));
265 if (!ret) {
266 g_warning ("failed to send session response: %s", error->message);
267 g_error_free (error);
268 }
269
270 cafe_settings_manager_stop (manager);
271 ctk_main_quit ();
272}
273
274static void
275on_term_signal (int signal G_GNUC_UNUSED__attribute__ ((__unused__)))
276{
277 /* Wake up main loop to tell it to shutdown */
278 close (term_signal_pipe_fds[1]);
279 term_signal_pipe_fds[1] = -1;
280}
281
282static gboolean
283on_term_signal_pipe_closed (GIOChannel *source G_GNUC_UNUSED__attribute__ ((__unused__)),
284 GIOCondition condition G_GNUC_UNUSED__attribute__ ((__unused__)),
285 gpointer data G_GNUC_UNUSED__attribute__ ((__unused__)))
286{
287 term_signal_pipe_fds[0] = -1;
288
289 /* Got SIGTERM, time to clean up and get out
290 */
291 ctk_main_quit ();
292
293 return FALSE(0);
294}
295
296static void
297watch_for_term_signal (CafeSettingsManager *manager)
298{
299 GIOChannel *channel;
300
301 if (-1 == pipe (term_signal_pipe_fds) ||
302 -1 == fcntl (term_signal_pipe_fds[0], F_SETFD2, FD_CLOEXEC1) ||
303 -1 == fcntl (term_signal_pipe_fds[1], F_SETFD2, FD_CLOEXEC1)) {
304 g_error ("Could not create pipe: %s", g_strerror (errno(*__errno_location ())));
305 exit (EXIT_FAILURE1);
306 }
307
308 channel = g_io_channel_unix_new (term_signal_pipe_fds[0]);
309 g_io_channel_set_encoding (channel, NULL((void*)0), NULL((void*)0));
310 g_io_channel_set_buffered (channel, FALSE(0));
311 g_io_add_watch (channel, G_IO_HUP, on_term_signal_pipe_closed, manager);
312 g_io_channel_unref (channel);
313
314 signal (SIGTERM15, on_term_signal);
315
316}
317
318static void
319set_session_over_handler (DBusGConnection *bus, CafeSettingsManager *manager)
320{
321 DBusGProxy *session_proxy;
322 gchar *client_id = NULL((void*)0);
323 const char *startup_id;
324 GError *error = NULL((void*)0);
325 gboolean res;
326
327 g_assert (bus != NULL)do { if (bus != ((void*)0)) ; else g_assertion_message_expr (
((gchar*) 0), "main.c", 327, ((const char*) (__func__)), "bus != NULL"
); } while (0)
;
328
329 cafe_settings_profile_start (NULL);
330
331 session_proxy =
332 dbus_g_proxy_new_for_name (bus,
333 CAFE_SESSION_DBUS_NAME"org.gnome.SessionManager",
334 CAFE_SESSION_DBUS_OBJECT"/org/gnome/SessionManager",
335 CAFE_SESSION_DBUS_INTERFACE"org.gnome.SessionManager");
336
337 dbus_g_object_register_marshaller (
338 g_cclosure_marshal_VOID__VOID,
339 G_TYPE_NONE((GType) ((1) << (2))),
340 G_TYPE_INVALID((GType) ((0) << (2))));
341
342 dbus_g_proxy_add_signal (session_proxy,
343 "SessionOver",
344 G_TYPE_INVALID((GType) ((0) << (2))));
345
346 dbus_g_proxy_connect_signal (session_proxy,
347 "SessionOver",
348 G_CALLBACK (on_session_over)((GCallback) (on_session_over)),
349 manager,
350 NULL((void*)0));
351
352 /* Register with cafe-session */
353 startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
354 if (startup_id != NULL((void*)0) && *startup_id != '\0') {
355 res = dbus_g_proxy_call (session_proxy,
356 "RegisterClient",
357 &error,
358 G_TYPE_STRING((GType) ((16) << (2))), "cafe-settings-daemon",
359 G_TYPE_STRING((GType) ((16) << (2))), startup_id,
360 G_TYPE_INVALID((GType) ((0) << (2))),
361 DBUS_TYPE_G_OBJECT_PATH(dbus_g_object_path_get_g_type ()), &client_id,
362 G_TYPE_INVALID((GType) ((0) << (2))));
363 if (!res) {
364 g_warning ("failed to register client '%s': %s", startup_id, error->message);
365 g_error_free (error);
366 }
367 else {
368 DBusGProxy *private_proxy;
369
370 /* get org.gnome.SessionManager.ClientPrivate interface */
371 private_proxy = dbus_g_proxy_new_for_name_owner (bus, CAFE_SESSION_DBUS_NAME"org.gnome.SessionManager",
372 client_id, CAFE_SESSION_PRIVATE_DBUS_INTERFACE"org.gnome.SessionManager.ClientPrivate",
373 &error);
374 if (private_proxy == NULL((void*)0)) {
375 g_warning ("DBUS error: %s", error->message);
376 g_error_free (error);
377 }
378 else {
379
380 /* get QueryEndSession */
381 dbus_g_proxy_add_signal (private_proxy, "QueryEndSession", G_TYPE_UINT((GType) ((7) << (2))), G_TYPE_INVALID((GType) ((0) << (2))));
382 dbus_g_proxy_connect_signal (private_proxy, "QueryEndSession",
383 G_CALLBACK (on_session_query_end)((GCallback) (on_session_query_end)),
384 manager, NULL((void*)0));
385
386 /* get EndSession */
387 dbus_g_proxy_add_signal (private_proxy, "EndSession", G_TYPE_UINT((GType) ((7) << (2))), G_TYPE_INVALID((GType) ((0) << (2))));
388 dbus_g_proxy_connect_signal (private_proxy, "EndSession",
389 G_CALLBACK (on_session_end)((GCallback) (on_session_end)), manager, NULL((void*)0));
390
391 }
392
393 g_free (client_id);
394 }
395 }
396
397 watch_for_term_signal (manager);
398 cafe_settings_profile_end (NULL);
399}
400
401static void
402csd_log_default_handler (const gchar *log_domain,
403 GLogLevelFlags log_level,
404 const gchar *message,
405 gpointer unused_data)
406{
407 /* filter out DEBUG messages if debug isn't set */
408 if ((log_level & G_LOG_LEVEL_MASK) == G_LOG_LEVEL_DEBUG
409 && ! debug) {
410 return;
411 }
412
413 g_log_default_handler (log_domain,
414 log_level,
415 message,
416 unused_data);
417}
418
419static void
420parse_args (int *argc, char ***argv)
421{
422 GError *error;
423 GOptionContext *context;
424
425 cafe_settings_profile_start (NULL);
426
427
428 context = g_option_context_new (NULL((void*)0));
429
430 g_option_context_add_main_entries (context, entries, NULL((void*)0));
431 g_option_context_add_group (context, ctk_get_option_group (FALSE(0)));
432
433 error = NULL((void*)0);
434 if (!g_option_context_parse (context, argc, argv, &error)) {
435 if (error != NULL((void*)0)) {
436 g_warning ("%s", error->message);
437 g_error_free (error);
438 } else {
439 g_warning ("Unable to initialize CTK+");
440 }
441 exit (EXIT_FAILURE1);
442 }
443
444 g_option_context_free (context);
445
446 cafe_settings_profile_end (NULL);
447
448 if (debug)
449 g_setenv ("G_MESSAGES_DEBUG", "all", FALSE(0));
450}
451
452static void debug_changed (GSettings *settings,
453 gchar *key G_GNUC_UNUSED__attribute__ ((__unused__)),
454 gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__)))
455{
456 debug = g_settings_get_boolean (settings, DEBUG_KEY"cafe-settings-daemon");
457 if (debug) {
458 g_warning ("Enable DEBUG");
459 g_setenv ("G_MESSAGES_DEBUG", "all", FALSE(0));
460 } else {
461 g_warning ("Disable DEBUG");
462 g_unsetenv ("G_MESSAGES_DEBUG");
463 }
464}
465
466int
467main (int argc, char *argv[])
468{
469 CafeSettingsManager *manager;
470 DBusGConnection *bus;
471 gboolean res;
472 GError *error;
473 GSettings *debug_settings = NULL((void*)0);
474
475 manager = NULL((void*)0);
476
477 cafe_settings_profile_start (NULL);
478
479 bindtextdomain (GETTEXT_PACKAGE"cafe-settings-daemon", CAFE_SETTINGS_LOCALEDIR"/usr/share/locale");
480 bind_textdomain_codeset (GETTEXT_PACKAGE"cafe-settings-daemon", "UTF-8");
481 textdomain (GETTEXT_PACKAGE"cafe-settings-daemon");
482 setlocale (LC_ALL6, "");
483
484 parse_args (&argc, &argv);
485
486 /* Allows to enable/disable debug from GSettings only if it is not set from argument */
487 if (cafe_gsettings_schema_exists (DEBUG_SCHEMA"org.cafe.debug"))
488 {
489 debug_settings = g_settings_new (DEBUG_SCHEMA"org.cafe.debug");
490 debug = g_settings_get_boolean (debug_settings, DEBUG_KEY"cafe-settings-daemon");
491 g_signal_connect (debug_settings, "changed::" DEBUG_KEY, G_CALLBACK (debug_changed), NULL)g_signal_connect_data ((debug_settings), ("changed::" "cafe-settings-daemon"
), (((GCallback) (debug_changed))), (((void*)0)), ((void*)0),
(GConnectFlags) 0)
;
492
493 if (debug) {
494 g_setenv ("G_MESSAGES_DEBUG", "all", FALSE(0));
495 }
496 }
497
498 cafe_settings_profile_start ("opening ctk display");
499 if (! ctk_init_check (NULL((void*)0), NULL((void*)0))) {
500 g_warning ("Unable to initialize CTK+");
501 exit (EXIT_FAILURE1);
502 }
503 cafe_settings_profile_end ("opening ctk display");
504
505 g_log_set_default_handler (csd_log_default_handler, NULL((void*)0));
506
507 bus = get_session_bus ();
508 if (bus == NULL((void*)0)) {
509 g_warning ("Could not get a connection to the bus");
510 goto out;
511 }
512
513 if (! bus_register (bus)) {
514 goto out;
515 }
516
517#ifdef HAVE_LIBNOTIFY1
518 notify_init ("cafe-settings-daemon");
519#endif /* HAVE_LIBNOTIFY */
520
521 cafe_settings_profile_start ("cafe_settings_manager_new");
522 manager = cafe_settings_manager_new ();
523 cafe_settings_profile_end ("cafe_settings_manager_new");
524 if (manager == NULL((void*)0)) {
525 g_warning ("Unable to register object");
526 goto out;
527 }
528
529 /* If we aren't started by dbus then load the plugins automatically during the
530 * Initialization phase. Otherwise, wait for an Awake etc. */
531 if (g_getenv ("DBUS_STARTER_BUS_TYPE") == NULL((void*)0)) {
532 error = NULL((void*)0);
533 res = cafe_settings_manager_start (manager, PLUGIN_LOAD_INIT, &error);
534 if (! res) {
535 g_warning ("Unable to start: %s", error->message);
536 g_error_free (error);
537 }
538 }
539
540 set_session_over_handler (bus, manager);
541
542 /* If we aren't started by dbus then load the plugins automatically after
543 * cafe-settings-daemon has registered itself. Otherwise, wait for an Awake etc. */
544 if (g_getenv ("DBUS_STARTER_BUS_TYPE") == NULL((void*)0)) {
545 error = NULL((void*)0);
546 res = cafe_settings_manager_start (manager, PLUGIN_LOAD_DEFER, &error);
547 if (! res) {
548 g_warning ("Unable to start: %s", error->message);
549 g_error_free (error);
550 goto out;
551 }
552 }
553
554 if (do_timed_exit) {
555 g_timeout_add_seconds (30, (GSourceFunc) timed_exit_cb, NULL((void*)0));
This statement is never executed
556 }
557
558 ctk_main ();
559
560 out:
561
562 if (bus != NULL((void*)0)) {
563 dbus_g_connection_unref (bus);
564 }
565
566 if (manager != NULL((void*)0)) {
567 g_object_unref (manager);
568 }
569
570 if (debug_settings != NULL((void*)0)) {
571 g_object_unref (debug_settings);
572 }
573
574#ifdef HAVE_LIBNOTIFY1
575 if (notify_is_initted ())
576 notify_uninit ();
577#endif /* HAVE_LIBNOTIFY */
578
579 g_debug ("SettingsDaemon finished");
580 cafe_settings_profile_end (NULL);
581
582 return 0;
583}