polkitbackendauthority.h 19.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/*
 * Copyright (C) 2008 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General
 * Public License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Author: David Zeuthen <davidz@redhat.com>
 */

#if !defined (_POLKIT_BACKEND_COMPILATION) && !defined(_POLKIT_BACKEND_INSIDE_POLKIT_BACKEND_H)
#error "Only <polkitbackend/polkitbackend.h> can be included directly, this file may disappear or change contents."
#endif

#ifndef __POLKIT_BACKEND_AUTHORITY_H
#define __POLKIT_BACKEND_AUTHORITY_H

#include <glib-object.h>
30

31 32 33 34 35 36 37 38 39 40 41 42 43
#include "polkitbackendtypes.h"

G_BEGIN_DECLS

#define POLKIT_BACKEND_TYPE_AUTHORITY         (polkit_backend_authority_get_type ())
#define POLKIT_BACKEND_AUTHORITY(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_BACKEND_TYPE_AUTHORITY, PolkitBackendAuthority))
#define POLKIT_BACKEND_AUTHORITY_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), POLKIT_BACKEND_TYPE_AUTHORITY, PolkitBackendAuthorityClass))
#define POLKIT_BACKEND_AUTHORITY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_BACKEND_TYPE_AUTHORITY,PolkitBackendAuthorityClass))
#define POLKIT_BACKEND_IS_AUTHORITY(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_BACKEND_TYPE_AUTHORITY))
#define POLKIT_BACKEND_IS_AUTHORITY_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_BACKEND_TYPE_AUTHORITY))

typedef struct _PolkitBackendAuthorityClass    PolkitBackendAuthorityClass;

44 45 46 47 48 49 50
/**
 * POLKIT_BACKEND_AUTHORITY_EXTENSION_POINT_NAME:
 *
 * Extension point name for authority backend implementations.
 */
#define POLKIT_BACKEND_AUTHORITY_EXTENSION_POINT_NAME "polkit-backend-authority-1"

51 52 53 54 55
/**
 * PolkitBackendAuthority:
 *
 * The #PolkitBackendAuthority struct should not be accessed directly.
 */
56 57 58 59 60
struct _PolkitBackendAuthority
{
  GObject parent_instance;
};

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
/**
 * PolkitBackendAuthorityClass:
 * @parent_class: The parent class.
 * @changed: Function pointer for #PolkitBackendAuthorityClass::changed signal.
 * @enumerate_actions: Enumerates registered actions on the
 * system. See polkit_backend_authority_enumerate_actions() for
 * details.
 * @check_authorization: Called to initiate an asynchronous
 * authorization check. See
 * polkit_backend_authority_check_authorization() for details.
 * @check_authorization_finish: Called when finishing an authorization
 * check. See polkit_backend_authority_check_authorization_finish()
 * for details.
 * @register_authentication_agent: Called when an authentication agent
 * is attempting to register or %NULL if the backend doesn't support
 * the operation. See
 * polkit_backend_authority_register_authentication_agent() for
 * details.
 * @unregister_authentication_agent: Called when an authentication
 * agent is attempting to unregister or %NULL if the backend doesn't
 * support the operation. See
 * polkit_backend_authority_unregister_authentication_agent() for
 * details.
 * @authentication_agent_response: Called by an authentication agent
 * when the user successfully authenticates or %NULL if the backend
 * doesn't support the operation. See
 * polkit_backend_authority_authentication_agent_response() for
 * details.
89 90 91 92 93 94 95 96
 * @enumerate_temporary_authorizations: Called to enumerate temporary
 * authorizations or %NULL if the backend doesn't support the operation.
 * See polkit_backend_authority_enumerate_temporary_authorizations()
 * for details.
 * @revoke_temporary_authorizations: Called to revoke temporary
 * authorizations or %NULL if the backend doesn't support the operation.
 * See polkit_backend_authority_revoke_temporary_authorizations()
 * for details.
97 98 99 100
 * @revoke_temporary_authorization_by_id: Called to revoke a temporary
 * authorization identified by id or %NULL if the backend doesn't support
 * the operation. See polkit_backend_authority_revoke_temporary_authorization_by_id()
 * for details.
101 102 103 104 105
 * @add_lockdown_for_action: Called to add lock down for an action. See polkit_backend_authority_add_lockdown_for_action() for details. Can be %NULL if not supported by the backend.
 * @add_lockdown_for_action_finish: Called to finish adding lock down for an an action. See polkit_backend_authority_add_lockdown_for_action_finish() for details. Can be %NULL if not supported by the backend.
 * @remove_lockdown_for_action: Called when removing lock down for an action. See polkit_backend_authority_remove_lockdown_for_action() for details. Can be %NULL if not supported by the backend.
 * @remove_lockdown_for_action_finish: Called to finish removing lock down for an action. See polkit_backend_authority_remove_lockdown_for_action_finish() for details. Can be %NULL if not supported by the backend.
 * @system_bus_name_owner_changed: temporary VFunc, to be removed before API is declared stable.
106 107 108
 *
 * VFuncs that authority backends need to implement.
 */
109 110 111
struct _PolkitBackendAuthorityClass
{
  /*< public >*/
112
  GObjectClass parent_class;
113

114 115 116 117 118
  /* Signals */
  void (*changed)  (PolkitBackendAuthority   *authority);

  /* VTable */

119 120 121 122
  const gchar             *(*get_name)     (PolkitBackendAuthority *authority);
  const gchar             *(*get_version)  (PolkitBackendAuthority *authority);
  PolkitAuthorityFeatures  (*get_features) (PolkitBackendAuthority *authority);

David Zeuthen's avatar
David Zeuthen committed
123 124 125 126
  GList *(*enumerate_actions)  (PolkitBackendAuthority   *authority,
                                PolkitSubject            *caller,
                                const gchar              *locale,
                                GError                  **error);
127

128
  void (*check_authorization) (PolkitBackendAuthority        *authority,
David Zeuthen's avatar
David Zeuthen committed
129
                               PolkitSubject                 *caller,
130 131
                               PolkitSubject                 *subject,
                               const gchar                   *action_id,
132
                               PolkitDetails                 *details,
133
                               PolkitCheckAuthorizationFlags  flags,
David Zeuthen's avatar
David Zeuthen committed
134 135 136 137
                               GCancellable                  *cancellable,
                               GAsyncReadyCallback            callback,
                               gpointer                       user_data);

138 139 140
  PolkitAuthorizationResult * (*check_authorization_finish) (PolkitBackendAuthority  *authority,
                                                             GAsyncResult            *res,
                                                             GError                 **error);
David Zeuthen's avatar
David Zeuthen committed
141

142 143
  gboolean (*register_authentication_agent) (PolkitBackendAuthority   *authority,
                                             PolkitSubject            *caller,
144
                                             PolkitSubject            *subject,
145
                                             const gchar              *locale,
146 147 148 149 150
                                             const gchar              *object_path,
                                             GError                  **error);

  gboolean (*unregister_authentication_agent) (PolkitBackendAuthority   *authority,
                                               PolkitSubject            *caller,
151
                                               PolkitSubject            *subject,
152 153 154 155 156 157 158 159 160
                                               const gchar              *object_path,
                                               GError                  **error);

  gboolean (*authentication_agent_response) (PolkitBackendAuthority   *authority,
                                             PolkitSubject            *caller,
                                             const gchar              *cookie,
                                             PolkitIdentity           *identity,
                                             GError                  **error);

161 162 163 164 165 166 167 168 169 170
  GList *(*enumerate_temporary_authorizations) (PolkitBackendAuthority   *authority,
                                                PolkitSubject            *caller,
                                                PolkitSubject            *subject,
                                                GError                  **error);

  gboolean (*revoke_temporary_authorizations) (PolkitBackendAuthority   *authority,
                                               PolkitSubject            *caller,
                                               PolkitSubject            *subject,
                                               GError                  **error);

171 172 173 174 175
  gboolean (*revoke_temporary_authorization_by_id) (PolkitBackendAuthority   *authority,
                                                    PolkitSubject            *caller,
                                                    const gchar              *id,
                                                    GError                  **error);

176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
  void (*add_lockdown_for_action) (PolkitBackendAuthority  *authority,
                                   PolkitSubject           *caller,
                                   const gchar             *action_id,
                                   GAsyncReadyCallback      callback,
                                   gpointer                 user_data);

  gboolean (*add_lockdown_for_action_finish) (PolkitBackendAuthority  *authority,
                                              GAsyncResult            *res,
                                              GError                 **error);

  void (*remove_lockdown_for_action) (PolkitBackendAuthority  *authority,
                                      PolkitSubject           *caller,
                                      const gchar             *action_id,
                                      GAsyncReadyCallback      callback,
                                      gpointer                 user_data);

  gboolean (*remove_lockdown_for_action_finish) (PolkitBackendAuthority  *authority,
                                                 GAsyncResult            *res,
                                                 GError                 **error);

196 197 198 199 200
  /* TODO: need something more efficient such that we don't watch all name changes */
  void (*system_bus_name_owner_changed)  (PolkitBackendAuthority   *authority,
                                          const gchar              *name,
                                          const gchar              *old_owner,
                                          const gchar              *new_owner);
201

202 203 204 205 206 207 208 209 210 211
  /*< private >*/
  /* Padding for future expansion */
  void (*_polkit_reserved1) (void);
  void (*_polkit_reserved2) (void);
  void (*_polkit_reserved3) (void);
  void (*_polkit_reserved4) (void);
  void (*_polkit_reserved5) (void);
  void (*_polkit_reserved6) (void);
  void (*_polkit_reserved7) (void);
  void (*_polkit_reserved8) (void);
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
  void (*_polkit_reserved9) (void);
  void (*_polkit_reserved10) (void);
  void (*_polkit_reserved11) (void);
  void (*_polkit_reserved12) (void);
  void (*_polkit_reserved13) (void);
  void (*_polkit_reserved14) (void);
  void (*_polkit_reserved15) (void);
  void (*_polkit_reserved16) (void);
  void (*_polkit_reserved17) (void);
  void (*_polkit_reserved18) (void);
  void (*_polkit_reserved19) (void);
  void (*_polkit_reserved20) (void);
  void (*_polkit_reserved21) (void);
  void (*_polkit_reserved22) (void);
  void (*_polkit_reserved23) (void);
  void (*_polkit_reserved24) (void);
  void (*_polkit_reserved25) (void);
  void (*_polkit_reserved26) (void);
  void (*_polkit_reserved27) (void);
  void (*_polkit_reserved28) (void);
  void (*_polkit_reserved29) (void);
  void (*_polkit_reserved30) (void);
  void (*_polkit_reserved31) (void);
  void (*_polkit_reserved32) (void);
236 237
};

238
GType    polkit_backend_authority_get_type (void) G_GNUC_CONST;
239

240 241
/* --- */

242 243 244 245
const gchar             *polkit_backend_authority_get_name     (PolkitBackendAuthority *authority);
const gchar             *polkit_backend_authority_get_version  (PolkitBackendAuthority *authority);
PolkitAuthorityFeatures  polkit_backend_authority_get_features (PolkitBackendAuthority *authority);

David Zeuthen's avatar
David Zeuthen committed
246 247 248 249
void     polkit_backend_authority_log (PolkitBackendAuthority *authority,
                                       const gchar *format,
                                       ...);

250 251 252 253 254
void     polkit_backend_authority_system_bus_name_owner_changed (PolkitBackendAuthority   *authority,
                                                                 const gchar              *name,
                                                                 const gchar              *old_owner,
                                                                 const gchar              *new_owner);

David Zeuthen's avatar
David Zeuthen committed
255 256
GList   *polkit_backend_authority_enumerate_actions         (PolkitBackendAuthority    *authority,
                                                             PolkitSubject             *caller,
257
                                                             const gchar               *locale,
David Zeuthen's avatar
David Zeuthen committed
258
                                                             GError                   **error);
259

260
void     polkit_backend_authority_check_authorization       (PolkitBackendAuthority        *authority,
David Zeuthen's avatar
David Zeuthen committed
261
                                                             PolkitSubject                 *caller,
262 263
                                                             PolkitSubject                 *subject,
                                                             const gchar                   *action_id,
264
                                                             PolkitDetails                 *details,
265
                                                             PolkitCheckAuthorizationFlags  flags,
David Zeuthen's avatar
David Zeuthen committed
266 267 268
                                                             GCancellable                  *cancellable,
                                                             GAsyncReadyCallback            callback,
                                                             gpointer                       user_data);
269

270 271 272
PolkitAuthorizationResult *polkit_backend_authority_check_authorization_finish (PolkitBackendAuthority  *authority,
                                                                                GAsyncResult            *res,
                                                                                GError                 **error);
David Zeuthen's avatar
David Zeuthen committed
273 274 275

gboolean polkit_backend_authority_register_authentication_agent (PolkitBackendAuthority    *authority,
                                                                 PolkitSubject             *caller,
276
                                                                 PolkitSubject             *subject,
277
                                                                 const gchar               *locale,
278
                                                                 const gchar               *object_path,
David Zeuthen's avatar
David Zeuthen committed
279
                                                                 GError                   **error);
280

David Zeuthen's avatar
David Zeuthen committed
281 282
gboolean polkit_backend_authority_unregister_authentication_agent (PolkitBackendAuthority    *authority,
                                                                   PolkitSubject             *caller,
283
                                                                   PolkitSubject             *subject,
284
                                                                   const gchar               *object_path,
David Zeuthen's avatar
David Zeuthen committed
285
                                                                   GError                   **error);
286

David Zeuthen's avatar
David Zeuthen committed
287 288
gboolean polkit_backend_authority_authentication_agent_response (PolkitBackendAuthority    *authority,
                                                                 PolkitSubject             *caller,
289 290
                                                                 const gchar               *cookie,
                                                                 PolkitIdentity            *identity,
David Zeuthen's avatar
David Zeuthen committed
291
                                                                 GError                   **error);
292

293 294 295 296 297 298 299 300 301 302
GList *polkit_backend_authority_enumerate_temporary_authorizations (PolkitBackendAuthority   *authority,
                                                                    PolkitSubject            *caller,
                                                                    PolkitSubject            *subject,
                                                                    GError                  **error);

gboolean polkit_backend_authority_revoke_temporary_authorizations (PolkitBackendAuthority   *authority,
                                                                   PolkitSubject            *caller,
                                                                   PolkitSubject            *subject,
                                                                   GError                  **error);

303 304 305 306 307
gboolean polkit_backend_authority_revoke_temporary_authorization_by_id (PolkitBackendAuthority   *authority,
                                                                        PolkitSubject            *caller,
                                                                        const gchar              *id,
                                                                        GError                  **error);

308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
void polkit_backend_authority_add_lockdown_for_action (PolkitBackendAuthority  *authority,
                                                       PolkitSubject           *caller,
                                                       const gchar             *action_id,
                                                       GAsyncReadyCallback      callback,
                                                       gpointer                 user_data);

gboolean polkit_backend_authority_add_lockdown_for_action_finish (PolkitBackendAuthority  *authority,
                                                                  GAsyncResult            *res,
                                                                  GError                 **error);

void polkit_backend_authority_remove_lockdown_for_action (PolkitBackendAuthority  *authority,
                                                          PolkitSubject           *caller,
                                                          const gchar             *action_id,
                                                          GAsyncReadyCallback      callback,
                                                          gpointer                 user_data);

gboolean polkit_backend_authority_remove_lockdown_for_action_finish (PolkitBackendAuthority  *authority,
                                                                     GAsyncResult            *res,
                                                                     GError                 **error);

328
/* --- */
329

330 331
PolkitBackendAuthority *polkit_backend_authority_get (void);

332 333 334 335 336
gboolean polkit_backend_register_authority (PolkitBackendAuthority   *authority,
                                            const gchar              *well_known_name,
                                            const gchar              *object_path,
                                            GError                  **error);

337 338 339
G_END_DECLS

#endif /* __POLKIT_BACKEND_AUTHORITY_H */