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