Line | Branch | Exec | Source |
---|---|---|---|
1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- | ||
2 | * | ||
3 | * Copyright © 2017 Endless Mobile, Inc. | ||
4 | * | ||
5 | * SPDX-License-Identifier: LGPL-2.1-or-later | ||
6 | * | ||
7 | * This library is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU Lesser General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2.1 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * This library 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 GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with this library; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | * | ||
21 | * Authors: | ||
22 | * - Philip Withnall <withnall@endlessm.com> | ||
23 | */ | ||
24 | |||
25 | #pragma once | ||
26 | |||
27 | #include <gio/gio.h> | ||
28 | #include <glib.h> | ||
29 | #include <glib-object.h> | ||
30 | |||
31 | G_BEGIN_DECLS | ||
32 | |||
33 | /** | ||
34 | * GSS_SERVICE_ERROR: | ||
35 | * | ||
36 | * Error domain for #GssServiceError. | ||
37 | * | ||
38 | * Since: 0.1.0 | ||
39 | */ | ||
40 | #define GSS_SERVICE_ERROR gss_service_error_quark () | ||
41 | GQuark gss_service_error_quark (void); | ||
42 | |||
43 | /** | ||
44 | * GssServiceError: | ||
45 | * @GSS_SERVICE_ERROR_SIGNALLED: Process was signalled with `SIGINT` or | ||
46 | * `SIGTERM`. | ||
47 | * @GSS_SERVICE_ERROR_INVALID_OPTIONS: Invalid command line options. | ||
48 | * @GSS_SERVICE_ERROR_NAME_UNAVAILABLE: Bus or well-known name unavailable. | ||
49 | * @GSS_SERVICE_ERROR_INVALID_ENVIRONMENT: Runtime environment is insecure or | ||
50 | * otherwise invalid for running the daemon. | ||
51 | * @GSS_SERVICE_ERROR_TIMEOUT: Inactivity timeout reached. | ||
52 | * | ||
53 | * Errors from running a service. | ||
54 | * | ||
55 | * Since: 0.1.0 | ||
56 | */ | ||
57 | typedef enum | ||
58 | { | ||
59 | GSS_SERVICE_ERROR_SIGNALLED, | ||
60 | GSS_SERVICE_ERROR_INVALID_OPTIONS, | ||
61 | GSS_SERVICE_ERROR_NAME_UNAVAILABLE, | ||
62 | GSS_SERVICE_ERROR_INVALID_ENVIRONMENT, | ||
63 | GSS_SERVICE_ERROR_TIMEOUT, | ||
64 | } GssServiceError; | ||
65 | |||
66 | #define GSS_TYPE_SERVICE gss_service_get_type () | ||
67 |
1/7✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
20 | G_DECLARE_DERIVABLE_TYPE (GssService, gss_service, GSS, SERVICE, GObject) |
68 | |||
69 | /** | ||
70 | * GssServiceClass: | ||
71 | * @get_main_option_entries: (nullable): Get a %NULL-terminated array of | ||
72 | * #GOptionEntrys to add to the main option group for the service. If | ||
73 | * implemented, this must return a non-%NULL value. | ||
74 | * @startup_async: (not nullable): Asynchronous service startup implementation. | ||
75 | * This should start performing the startup for the service, when called by | ||
76 | * gss_service_run(). @startup_finish will be called to complete the startup, | ||
77 | * and a #GMainContext will be iterated between the two. This method must be | ||
78 | * implemented. If gss_service_exit() is called during startup_async(), the | ||
79 | * exit return value (success or error) will be returned from | ||
80 | * gss_service_run(). | ||
81 | * @startup_finish: (not nullable): Finish asynchronous startup started with | ||
82 | * @startup_async. This method must be implemented. | ||
83 | * @shutdown: (not nullable): Synchronous service shutdown implementation. This | ||
84 | * should perform all shutdown for the service, and is called from | ||
85 | * gss_service_run() once the service shutdown is triggered. This method must | ||
86 | * be implemented. | ||
87 | * | ||
88 | * Class structure for a #GssService implementation. | ||
89 | * | ||
90 | * All services must implement @startup_async, @startup_finish and @shutdown, | ||
91 | * which are called by gss_service_run() to start up and shut down the service. | ||
92 | * | ||
93 | * If your service needs to support additional command line options in the main | ||
94 | * group, implement @get_main_option_entries; otherwise leave it unimplemented. | ||
95 | * | ||
96 | * Since: 0.1.0 | ||
97 | */ | ||
98 | struct _GssServiceClass | ||
99 | { | ||
100 | GObjectClass parent_class; | ||
101 | |||
102 | GOptionEntry *(*get_main_option_entries) (GssService *service); | ||
103 | |||
104 | void (*startup_async) (GssService *service, | ||
105 | GCancellable *cancellable, | ||
106 | GAsyncReadyCallback callback, | ||
107 | gpointer user_data); | ||
108 | void (*startup_finish) (GssService *service, | ||
109 | GAsyncResult *result, | ||
110 | GError **error); | ||
111 | void (*shutdown) (GssService *service); | ||
112 | |||
113 | /*< private >*/ | ||
114 | gpointer padding[12]; | ||
115 | }; | ||
116 | |||
117 | void gss_service_add_option_group (GssService *self, | ||
118 | GOptionGroup *group); | ||
119 | |||
120 | void gss_service_run (GssService *self, | ||
121 | int argc, | ||
122 | char **argv, | ||
123 | GError **error); | ||
124 | void gss_service_exit (GssService *self, | ||
125 | const GError *error, | ||
126 | int signum); | ||
127 | |||
128 | GDBusConnection *gss_service_get_dbus_connection (GssService *self); | ||
129 | int gss_service_get_exit_signal (GssService *self); | ||
130 | |||
131 | guint gss_service_get_inactivity_timeout (GssService *self); | ||
132 | void gss_service_set_inactivity_timeout (GssService *self, | ||
133 | guint timeout_ms); | ||
134 | |||
135 | GDebugController *gss_service_get_debug_controller (GssService *self); | ||
136 | |||
137 | void gss_service_hold (GssService *self); | ||
138 | void gss_service_release (GssService *self); | ||
139 | |||
140 | G_END_DECLS | ||
141 |