Branch data Line data Source code
1 : : /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2 : : *
3 : : * Copyright 2024 GNOME Foundation, Inc.
4 : : *
5 : : * SPDX-License-Identifier: GPL-2.0-or-later
6 : : *
7 : : * This program is free software; you can redistribute it and/or modify
8 : : * it under the terms of the GNU General Public License as published by
9 : : * the Free Software Foundation; either version 2 of the License, or
10 : : * (at your option) any later version.
11 : : *
12 : : * This program is distributed in the hope that it will be useful,
13 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 : : * GNU General Public License for more details.
16 : : *
17 : : * You should have received a copy of the GNU General Public License
18 : : * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 : : *
20 : : * Authors:
21 : : * - Philip Withnall <pwithnall@gnome.org>
22 : : */
23 : :
24 : : #include "config.h"
25 : :
26 : : #include <glib.h>
27 : : #include <glib/gi18n.h>
28 : : #include <libgsystemservice/service.h>
29 : : #include <libmalcontent-timer/timer-service.h>
30 : : #include <signal.h>
31 : :
32 : :
33 : : int
34 : 1 : main (int argc,
35 : : char *argv[])
36 : : {
37 : 1 : g_autoptr(GError) error = NULL;
38 : 1 : g_autoptr(MctTimerService) service = NULL;
39 : :
40 : : /* Set up a D-Bus service and run until we are killed. */
41 : 1 : service = mct_timer_service_new ();
42 : 1 : gss_service_run (GSS_SERVICE (service), argc, argv, &error);
43 : :
44 [ + - ]: 1 : if (error != NULL)
45 : : {
46 [ - + ]: 1 : if (g_error_matches (error,
47 : : GSS_SERVICE_ERROR, GSS_SERVICE_ERROR_SIGNALLED))
48 : 0 : raise (gss_service_get_exit_signal (GSS_SERVICE (service)));
49 [ + - ]: 1 : else if (g_error_matches (error,
50 : : GSS_SERVICE_ERROR, GSS_SERVICE_ERROR_TIMEOUT))
51 : : {
52 : 1 : g_message (_("Exiting due to reaching inactivity timeout"));
53 : 1 : return 0;
54 : : }
55 : :
56 : 0 : g_printerr ("%s: %s\n", argv[0], error->message);
57 : :
58 : 0 : return gss_service_error_to_exit_status (error->code);
59 : : }
60 : :
61 : 0 : return 0;
62 : : }
63 : :
|