Branch data Line data Source code
1 : : /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2 : : *
3 : : * Copyright © 2019 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 : : * MctManagerGetValueFlags:
35 : : * @MCT_MANAGER_GET_VALUE_FLAGS_NONE: No flags set.
36 : : * @MCT_MANAGER_GET_VALUE_FLAGS_INTERACTIVE: Allow interactive polkit dialogs
37 : : * when requesting authorization.
38 : : *
39 : : * Flags to control the behaviour of getter functions like
40 : : * [method@Malcontent.Manager.get_app_filter] and
41 : : * [method@Malcontent.Manager.get_app_filter_async].
42 : : *
43 : : * Since: 0.5.0
44 : : */
45 : : typedef enum
46 : : {
47 : : MCT_MANAGER_GET_VALUE_FLAGS_NONE = 0,
48 : : MCT_MANAGER_GET_VALUE_FLAGS_INTERACTIVE = (1 << 0),
49 : : } MctManagerGetValueFlags;
50 : :
51 : : /* FIXME: Eventually deprecate these compatibility fallbacks. */
52 : : typedef MctManagerGetValueFlags MctGetAppFilterFlags;
53 : : #define MCT_GET_APP_FILTER_FLAGS_NONE MCT_MANAGER_GET_VALUE_FLAGS_NONE
54 : : #define MCT_GET_APP_FILTER_FLAGS_INTERACTIVE MCT_MANAGER_GET_VALUE_FLAGS_INTERACTIVE
55 : :
56 : : /**
57 : : * MctManagerSetValueFlags:
58 : : * @MCT_MANAGER_SET_VALUE_FLAGS_NONE: No flags set.
59 : : * @MCT_MANAGER_SET_VALUE_FLAGS_INTERACTIVE: Allow interactive polkit dialogs
60 : : * when requesting authorization.
61 : : *
62 : : * Flags to control the behaviour of setter functions like
63 : : * [method@Malcontent.Manager.set_app_filter] and
64 : : * [method@Malcontent.Manager.set_app_filter_async].
65 : : *
66 : : * Since: 0.5.0
67 : : */
68 : : typedef enum
69 : : {
70 : : MCT_MANAGER_SET_VALUE_FLAGS_NONE = 0,
71 : : MCT_MANAGER_SET_VALUE_FLAGS_INTERACTIVE = (1 << 0),
72 : : } MctManagerSetValueFlags;
73 : :
74 : : /* FIXME: Eventually deprecate these compatibility fallbacks. */
75 : : typedef MctManagerSetValueFlags MctSetAppFilterFlags;
76 : : #define MCT_SET_APP_FILTER_FLAGS_NONE MCT_MANAGER_SET_VALUE_FLAGS_NONE
77 : : #define MCT_SET_APP_FILTER_FLAGS_INTERACTIVE MCT_MANAGER_SET_VALUE_FLAGS_INTERACTIVE
78 : :
79 : : /**
80 : : * MctManagerError:
81 : : * @MCT_MANAGER_ERROR_INVALID_USER: Given user ID doesn’t exist
82 : : * @MCT_MANAGER_ERROR_PERMISSION_DENIED: Not authorized to query properties of
83 : : * the given user
84 : : * @MCT_MANAGER_ERROR_INVALID_DATA: The data stored in a property of the given
85 : : * user is inconsistent or invalid
86 : : * @MCT_MANAGER_ERROR_DISABLED: Parental controls are disabled for all users
87 : : *
88 : : * Errors relating to get/set operations on a [class@Malcontent.Manager]
89 : : * instance.
90 : : *
91 : : * Since: 0.5.0
92 : : */
93 : : typedef enum
94 : : {
95 : : MCT_MANAGER_ERROR_INVALID_USER,
96 : : MCT_MANAGER_ERROR_PERMISSION_DENIED,
97 : : MCT_MANAGER_ERROR_INVALID_DATA,
98 : : MCT_MANAGER_ERROR_DISABLED,
99 : : } MctManagerError;
100 : :
101 : : GQuark mct_manager_error_quark (void);
102 : : #define MCT_MANAGER_ERROR mct_manager_error_quark ()
103 : :
104 : : #include <libmalcontent/app-filter.h>
105 : : #include <libmalcontent/session-limits.h>
106 : : #include <libmalcontent/web-filter.h>
107 : :
108 : : #define MCT_TYPE_MANAGER mct_manager_get_type ()
109 [ - + + - : 235 : G_DECLARE_FINAL_TYPE (MctManager, mct_manager, MCT, MANAGER, GObject)
+ - ][ + - ]
110 : :
111 : : MctManager *mct_manager_new (GDBusConnection *connection);
112 : :
113 : : MctAppFilter *mct_manager_get_app_filter (MctManager *self,
114 : : uid_t user_id,
115 : : MctManagerGetValueFlags flags,
116 : : GCancellable *cancellable,
117 : : GError **error);
118 : : void mct_manager_get_app_filter_async (MctManager *self,
119 : : uid_t user_id,
120 : : MctManagerGetValueFlags flags,
121 : : GCancellable *cancellable,
122 : : GAsyncReadyCallback callback,
123 : : gpointer user_data);
124 : : MctAppFilter *mct_manager_get_app_filter_finish (MctManager *self,
125 : : GAsyncResult *result,
126 : : GError **error);
127 : :
128 : : gboolean mct_manager_set_app_filter (MctManager *self,
129 : : uid_t user_id,
130 : : MctAppFilter *app_filter,
131 : : MctManagerSetValueFlags flags,
132 : : GCancellable *cancellable,
133 : : GError **error);
134 : : void mct_manager_set_app_filter_async (MctManager *self,
135 : : uid_t user_id,
136 : : MctAppFilter *app_filter,
137 : : MctManagerSetValueFlags flags,
138 : : GCancellable *cancellable,
139 : : GAsyncReadyCallback callback,
140 : : gpointer user_data);
141 : : gboolean mct_manager_set_app_filter_finish (MctManager *self,
142 : : GAsyncResult *result,
143 : : GError **error);
144 : :
145 : : MctSessionLimits *mct_manager_get_session_limits (MctManager *self,
146 : : uid_t user_id,
147 : : MctManagerGetValueFlags flags,
148 : : GCancellable *cancellable,
149 : : GError **error);
150 : : void mct_manager_get_session_limits_async (MctManager *self,
151 : : uid_t user_id,
152 : : MctManagerGetValueFlags flags,
153 : : GCancellable *cancellable,
154 : : GAsyncReadyCallback callback,
155 : : gpointer user_data);
156 : : MctSessionLimits *mct_manager_get_session_limits_finish (MctManager *self,
157 : : GAsyncResult *result,
158 : : GError **error);
159 : :
160 : : gboolean mct_manager_set_session_limits (MctManager *self,
161 : : uid_t user_id,
162 : : MctSessionLimits *session_limits,
163 : : MctManagerSetValueFlags flags,
164 : : GCancellable *cancellable,
165 : : GError **error);
166 : : void mct_manager_set_session_limits_async (MctManager *self,
167 : : uid_t user_id,
168 : : MctSessionLimits *session_limits,
169 : : MctManagerSetValueFlags flags,
170 : : GCancellable *cancellable,
171 : : GAsyncReadyCallback callback,
172 : : gpointer user_data);
173 : : gboolean mct_manager_set_session_limits_finish (MctManager *self,
174 : : GAsyncResult *result,
175 : : GError **error);
176 : :
177 : :
178 : :
179 : : MctWebFilter *mct_manager_get_web_filter (MctManager *self,
180 : : uid_t user_id,
181 : : MctManagerGetValueFlags flags,
182 : : GCancellable *cancellable,
183 : : GError **error);
184 : : void mct_manager_get_web_filter_async (MctManager *self,
185 : : uid_t user_id,
186 : : MctManagerGetValueFlags flags,
187 : : GCancellable *cancellable,
188 : : GAsyncReadyCallback callback,
189 : : void *user_data);
190 : : MctWebFilter *mct_manager_get_web_filter_finish (MctManager *self,
191 : : GAsyncResult *result,
192 : : GError **error);
193 : :
194 : : gboolean mct_manager_set_web_filter (MctManager *self,
195 : : uid_t user_id,
196 : : MctWebFilter *web_filter,
197 : : MctManagerSetValueFlags flags,
198 : : GCancellable *cancellable,
199 : : GError **error);
200 : : void mct_manager_set_web_filter_async (MctManager *self,
201 : : uid_t user_id,
202 : : MctWebFilter *web_filter,
203 : : MctManagerSetValueFlags flags,
204 : : GCancellable *cancellable,
205 : : GAsyncReadyCallback callback,
206 : : void *user_data);
207 : : gboolean mct_manager_set_web_filter_finish (MctManager *self,
208 : : GAsyncResult *result,
209 : : GError **error);
210 : :
211 : : G_END_DECLS
|