Debian Codegraph @

src/polkitbackend/polkitbackendauthority.h

raw
1 /*
2 * Copyright (C) 2008 Red Hat, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General
15 * Public License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Zeuthen <[email protected]>
20 */
21
22 #if !defined (_POLKIT_BACKEND_COMPILATION) && !defined(_POLKIT_BACKEND_INSIDE_POLKIT_BACKEND_H)
23 #error "Only <polkitbackend/polkitbackend.h> can be included directly, this file may disappear or change contents."
24 #endif
25
26 #ifndef __POLKIT_BACKEND_AUTHORITY_H
27 #define __POLKIT_BACKEND_AUTHORITY_H
28
29 #include <glib-object.h>
30
31 #include <polkit/polkit.h>
32 #include <polkitbackend/polkitbackendtypes.h>
33
34 G_BEGIN_DECLS
35
36 #define POLKIT_BACKEND_TYPE_AUTHORITY (polkit_backend_authority_get_type ())
37 #define POLKIT_BACKEND_AUTHORITY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_BACKEND_TYPE_AUTHORITY, PolkitBackendAuthority))
38 #define POLKIT_BACKEND_AUTHORITY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), POLKIT_BACKEND_TYPE_AUTHORITY, PolkitBackendAuthorityClass))
39 #define POLKIT_BACKEND_AUTHORITY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_BACKEND_TYPE_AUTHORITY,PolkitBackendAuthorityClass))
40 #define POLKIT_BACKEND_IS_AUTHORITY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_BACKEND_TYPE_AUTHORITY))
41 #define POLKIT_BACKEND_IS_AUTHORITY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_BACKEND_TYPE_AUTHORITY))
42
43 typedef struct _PolkitBackendAuthorityClass PolkitBackendAuthorityClass;
44
45 /**
46 * PolkitBackendAuthority:
47 *
48 * The #PolkitBackendAuthority struct should not be accessed directly.
49 */
50 struct _PolkitBackendAuthority
51 {
52 GObject parent_instance;
53 };
54
55 /**
56 * Log levels aligned with those used in syslog and LogControl
57 */
58 enum
59 {
60 LOG_LEVEL_EMERG,
61 LOG_LEVEL_ALERT,
62 LOG_LEVEL_CRIT,
63 LOG_LEVEL_ERROR,
64 LOG_LEVEL_WARNING,
65 LOG_LEVEL_NOTICE,
66 LOG_LEVEL_INFO,
67 LOG_LEVEL_DEBUG
68 };
69
70 /**
71 * PolkitBackendAuthorityClass:
72 * @parent_class: The parent class.
73 * @get_name: Function pointer for the polkit_backend_authority_get_name() function.
74 * @get_version: Function pointer for the polkit_backend_authority_get_version() function.
75 * @get_features: Function pointer for the polkit_backend_authority_get_features() function.
76 * @changed: Function pointer for #PolkitBackendAuthority::changed signal.
77 * @enumerate_actions: Enumerates registered actions on the
78 * system. See polkit_backend_authority_enumerate_actions() for
79 * details.
80 * @check_authorization: Called to initiate an asynchronous
81 * authorization check. See
82 * polkit_backend_authority_check_authorization() for details.
83 * @check_authorization_finish: Called when finishing an authorization
84 * check. See polkit_backend_authority_check_authorization_finish()
85 * for details.
86 * @register_authentication_agent: Called when an authentication agent
87 * is attempting to register or %NULL if the backend doesn't support
88 * the operation. See
89 * polkit_backend_authority_register_authentication_agent() for
90 * details.
91 * @unregister_authentication_agent: Called when an authentication
92 * agent is attempting to unregister or %NULL if the backend doesn't
93 * support the operation. See
94 * polkit_backend_authority_unregister_authentication_agent() for
95 * details.
96 * @authentication_agent_response: Called by an authentication agent
97 * when the user successfully authenticates or %NULL if the backend
98 * doesn't support the operation. See
99 * polkit_backend_authority_authentication_agent_response() for
100 * details.
101 * @enumerate_temporary_authorizations: Called to enumerate temporary
102 * authorizations or %NULL if the backend doesn't support the operation.
103 * See polkit_backend_authority_enumerate_temporary_authorizations()
104 * for details.
105 * @revoke_temporary_authorizations: Called to revoke temporary
106 * authorizations or %NULL if the backend doesn't support the operation.
107 * See polkit_backend_authority_revoke_temporary_authorizations()
108 * for details.
109 * @revoke_temporary_authorization_by_id: Called to revoke a temporary
110 * authorization identified by id or %NULL if the backend doesn't support
111 * the operation. See polkit_backend_authority_revoke_temporary_authorization_by_id()
112 * for details.
113 *
114 * Class structure for #PolkitBackendAuthority.
115 */
116 struct _PolkitBackendAuthorityClass
117 {
118 /*< public >*/
119 GObjectClass parent_class;
120
121 /* Signals */
122 void (*changed) (PolkitBackendAuthority *authority);
123
124 /* VTable */
125
126 const gchar *(*get_name) (PolkitBackendAuthority *authority);
127 const gchar *(*get_version) (PolkitBackendAuthority *authority);
128 PolkitAuthorityFeatures (*get_features) (PolkitBackendAuthority *authority);
129
130 GList *(*enumerate_actions) (PolkitBackendAuthority *authority,
131 PolkitSubject *caller,
132 const gchar *locale,
133 GError **error);
134
135 void (*check_authorization) (PolkitBackendAuthority *authority,
136 PolkitSubject *caller,
137 PolkitSubject *subject,
138 const gchar *action_id,
139 PolkitDetails *details,
140 PolkitCheckAuthorizationFlags flags,
141 GCancellable *cancellable,
142 GAsyncReadyCallback callback,
143 gpointer user_data);
144
145 PolkitAuthorizationResult * (*check_authorization_finish) (PolkitBackendAuthority *authority,
146 GAsyncResult *res,
147 GError **error);
148
149 gboolean (*register_authentication_agent) (PolkitBackendAuthority *authority,
150 PolkitSubject *caller,
151 PolkitSubject *subject,
152 const gchar *locale,
153 const gchar *object_path,
154 GVariant *options,
155 GError **error);
156
157 gboolean (*unregister_authentication_agent) (PolkitBackendAuthority *authority,
158 PolkitSubject *caller,
159 PolkitSubject *subject,
160 const gchar *object_path,
161 GError **error);
162
163 gboolean (*authentication_agent_response) (PolkitBackendAuthority *authority,
164 PolkitSubject *caller,
165 uid_t uid,
166 const gchar *cookie,
167 PolkitIdentity *identity,
168 GError **error);
169
170 GList *(*enumerate_temporary_authorizations) (PolkitBackendAuthority *authority,
171 PolkitSubject *caller,
172 PolkitSubject *subject,
173 GError **error);
174
175 gboolean (*revoke_temporary_authorizations) (PolkitBackendAuthority *authority,
176 PolkitSubject *caller,
177 PolkitSubject *subject,
178 GError **error);
179
180 gboolean (*revoke_temporary_authorization_by_id) (PolkitBackendAuthority *authority,
181 PolkitSubject *caller,
182 const gchar *id,
183 GError **error);
184
185 /*< private >*/
186 /* Padding for future expansion */
187 void (*_polkit_reserved1) (void);
188 void (*_polkit_reserved2) (void);
189 void (*_polkit_reserved3) (void);
190 void (*_polkit_reserved4) (void);
191 void (*_polkit_reserved5) (void);
192 void (*_polkit_reserved6) (void);
193 void (*_polkit_reserved7) (void);
194 void (*_polkit_reserved8) (void);
195 void (*_polkit_reserved9) (void);
196 void (*_polkit_reserved10) (void);
197 void (*_polkit_reserved11) (void);
198 void (*_polkit_reserved12) (void);
199 void (*_polkit_reserved13) (void);
200 void (*_polkit_reserved14) (void);
201 void (*_polkit_reserved15) (void);
202 void (*_polkit_reserved16) (void);
203 void (*_polkit_reserved17) (void);
204 void (*_polkit_reserved18) (void);
205 void (*_polkit_reserved19) (void);
206 void (*_polkit_reserved20) (void);
207 void (*_polkit_reserved21) (void);
208 void (*_polkit_reserved22) (void);
209 void (*_polkit_reserved23) (void);
210 void (*_polkit_reserved24) (void);
211 void (*_polkit_reserved25) (void);
212 void (*_polkit_reserved26) (void);
213 void (*_polkit_reserved27) (void);
214 void (*_polkit_reserved28) (void);
215 void (*_polkit_reserved29) (void);
216 void (*_polkit_reserved30) (void);
217 void (*_polkit_reserved31) (void);
218 void (*_polkit_reserved32) (void);
219 };
220
221 GType polkit_backend_authority_get_type (void) G_GNUC_CONST;
222
223 /* --- */
224
225 const gchar *polkit_backend_authority_get_name (PolkitBackendAuthority *authority);
226 const gchar *polkit_backend_authority_get_version (PolkitBackendAuthority *authority);
227 PolkitAuthorityFeatures polkit_backend_authority_get_features (PolkitBackendAuthority *authority);
228
229 void polkit_backend_authority_log (PolkitBackendAuthority *authority,
230 const guint message_log_level,
231 const gchar *format,
232 ...);
233
234 void
235 polkit_backend_authority_set_log_level (const gchar *level);
236
237 GList *polkit_backend_authority_enumerate_actions (PolkitBackendAuthority *authority,
238 PolkitSubject *caller,
239 const gchar *locale,
240 GError **error);
241
242 void polkit_backend_authority_check_authorization (PolkitBackendAuthority *authority,
243 PolkitSubject *caller,
244 PolkitSubject *subject,
245 const gchar *action_id,
246 PolkitDetails *details,
247 PolkitCheckAuthorizationFlags flags,
248 GCancellable *cancellable,
249 GAsyncReadyCallback callback,
250 gpointer user_data);
251
252 PolkitAuthorizationResult *polkit_backend_authority_check_authorization_finish (PolkitBackendAuthority *authority,
253 GAsyncResult *res,
254 GError **error);
255
256 gboolean polkit_backend_authority_register_authentication_agent (PolkitBackendAuthority *authority,
257 PolkitSubject *caller,
258 PolkitSubject *subject,
259 const gchar *locale,
260 const gchar *object_path,
261 GVariant *options,
262 GError **error);
263
264 gboolean polkit_backend_authority_unregister_authentication_agent (PolkitBackendAuthority *authority,
265 PolkitSubject *caller,
266 PolkitSubject *subject,
267 const gchar *object_path,
268 GError **error);
269
270 gboolean polkit_backend_authority_authentication_agent_response (PolkitBackendAuthority *authority,
271 PolkitSubject *caller,
272 uid_t uid,
273 const gchar *cookie,
274 PolkitIdentity *identity,
275 GError **error);
276
277 GList *polkit_backend_authority_enumerate_temporary_authorizations (PolkitBackendAuthority *authority,
278 PolkitSubject *caller,
279 PolkitSubject *subject,
280 GError **error);
281
282 gboolean polkit_backend_authority_revoke_temporary_authorizations (PolkitBackendAuthority *authority,
283 PolkitSubject *caller,
284 PolkitSubject *subject,
285 GError **error);
286
287 gboolean polkit_backend_authority_revoke_temporary_authorization_by_id (PolkitBackendAuthority *authority,
288 PolkitSubject *caller,
289 const gchar *id,
290 GError **error);
291
292 /* --- */
293
294 PolkitBackendAuthority *polkit_backend_authority_get (void);
295
296 gpointer polkit_backend_authority_register (PolkitBackendAuthority *authority,
297 GDBusConnection *connection,
298 const gchar *object_path,
299 GError **error);
300
301 void polkit_backend_authority_unregister (gpointer registration_id);
302
303 G_END_DECLS
304
305 #endif /* __POLKIT_BACKEND_AUTHORITY_H */