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 : :
104 : : #define MCT_TYPE_MANAGER mct_manager_get_type ()
105 [ - + + - : 190 : G_DECLARE_FINAL_TYPE (MctManager, mct_manager, MCT, MANAGER, GObject)
+ - ][ + - ]
106 : :
107 : : MctManager *mct_manager_new (GDBusConnection *connection);
108 : :
109 : : MctAppFilter *mct_manager_get_app_filter (MctManager *self,
110 : : uid_t user_id,
111 : : MctManagerGetValueFlags flags,
112 : : GCancellable *cancellable,
113 : : GError **error);
114 : : void mct_manager_get_app_filter_async (MctManager *self,
115 : : uid_t user_id,
116 : : MctManagerGetValueFlags flags,
117 : : GCancellable *cancellable,
118 : : GAsyncReadyCallback callback,
119 : : gpointer user_data);
120 : : MctAppFilter *mct_manager_get_app_filter_finish (MctManager *self,
121 : : GAsyncResult *result,
122 : : GError **error);
123 : :
124 : : gboolean mct_manager_set_app_filter (MctManager *self,
125 : : uid_t user_id,
126 : : MctAppFilter *app_filter,
127 : : MctManagerSetValueFlags flags,
128 : : GCancellable *cancellable,
129 : : GError **error);
130 : : void mct_manager_set_app_filter_async (MctManager *self,
131 : : uid_t user_id,
132 : : MctAppFilter *app_filter,
133 : : MctManagerSetValueFlags flags,
134 : : GCancellable *cancellable,
135 : : GAsyncReadyCallback callback,
136 : : gpointer user_data);
137 : : gboolean mct_manager_set_app_filter_finish (MctManager *self,
138 : : GAsyncResult *result,
139 : : GError **error);
140 : :
141 : : MctSessionLimits *mct_manager_get_session_limits (MctManager *self,
142 : : uid_t user_id,
143 : : MctManagerGetValueFlags flags,
144 : : GCancellable *cancellable,
145 : : GError **error);
146 : : void mct_manager_get_session_limits_async (MctManager *self,
147 : : uid_t user_id,
148 : : MctManagerGetValueFlags flags,
149 : : GCancellable *cancellable,
150 : : GAsyncReadyCallback callback,
151 : : gpointer user_data);
152 : : MctSessionLimits *mct_manager_get_session_limits_finish (MctManager *self,
153 : : GAsyncResult *result,
154 : : GError **error);
155 : :
156 : : gboolean mct_manager_set_session_limits (MctManager *self,
157 : : uid_t user_id,
158 : : MctSessionLimits *session_limits,
159 : : MctManagerSetValueFlags flags,
160 : : GCancellable *cancellable,
161 : : GError **error);
162 : : void mct_manager_set_session_limits_async (MctManager *self,
163 : : uid_t user_id,
164 : : MctSessionLimits *session_limits,
165 : : MctManagerSetValueFlags flags,
166 : : GCancellable *cancellable,
167 : : GAsyncReadyCallback callback,
168 : : gpointer user_data);
169 : : gboolean mct_manager_set_session_limits_finish (MctManager *self,
170 : : GAsyncResult *result,
171 : : GError **error);
172 : :
173 : : G_END_DECLS
|