polkitagentlistener.h 7.51 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * 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>
 */

22
#if !defined(_POLKIT_AGENT_INSIDE_POLKIT_AGENT_H) && !defined (_POLKIT_AGENT_COMPILATION)
23 24 25
#error "Only <polkitagent/polkitagent.h> can be included directly, this file may disappear or change contents"
#endif

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
#ifndef __POLKIT_AGENT_LISTENER_H
#define __POLKIT_AGENT_LISTENER_H

#include <polkit/polkit.h>
#include <polkitagent/polkitagenttypes.h>

G_BEGIN_DECLS

#define POLKIT_AGENT_TYPE_LISTENER         (polkit_agent_listener_get_type ())
#define POLKIT_AGENT_LISTENER(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_AGENT_TYPE_LISTENER, PolkitAgentListener))
#define POLKIT_AGENT_LISTENER_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), POLKIT_AGENT_TYPE_LISTENER, PolkitAgentListenerClass))
#define POLKIT_AGENT_LISTENER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_AGENT_TYPE_LISTENER,PolkitAgentListenerClass))
#define POLKIT_AGENT_IS_LISTENER(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_AGENT_TYPE_LISTENER))
#define POLKIT_AGENT_IS_LISTENER_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_AGENT_TYPE_LISTENER))

David Zeuthen's avatar
David Zeuthen committed
41
struct _PolkitAgentListenerClass;
42
typedef struct _PolkitAgentListenerClass PolkitAgentListenerClass;
43

44 45 46 47 48
/**
 * PolkitAgentListener:
 *
 * The #PolkitAgentListener struct should not be accessed directly.
 */
49 50 51 52 53
struct _PolkitAgentListener
{
  GObject parent_instance;
};

54 55 56 57 58 59 60 61
/**
 * PolkitAgentListenerClass:
 * @parent_class: The parent class.
 * @initiate_authentication: Handle an authentication request, see polkit_agent_listener_initiate_authentication().
 * @initiate_authentication_finish: Finishes handling an authentication request, see polkit_agent_listener_initiate_authentication_finish().
 *
 * VFuncs that authentication agents needs to implement.
 */
62 63
struct _PolkitAgentListenerClass
{
64
  /*< public >*/
65 66
  GObjectClass parent_class;

67
  /* Vtable */
David Zeuthen's avatar
David Zeuthen committed
68 69
  void     (*initiate_authentication)        (PolkitAgentListener  *listener,
                                              const gchar          *action_id,
70 71
                                              const gchar          *message,
                                              const gchar          *icon_name,
72
                                              PolkitDetails        *details,
David Zeuthen's avatar
David Zeuthen committed
73 74 75 76 77
                                              const gchar          *cookie,
                                              GList                *identities,
                                              GCancellable         *cancellable,
                                              GAsyncReadyCallback   callback,
                                              gpointer              user_data);
78

David Zeuthen's avatar
David Zeuthen committed
79 80 81
  gboolean (*initiate_authentication_finish) (PolkitAgentListener  *listener,
                                              GAsyncResult         *res,
                                              GError              **error);
82 83 84 85 86 87 88 89 90 91 92 93 94 95

  /*< private >*/
  /* Padding for future expansion */
  void (*_polkit_reserved0) (void);
  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);
};

GType     polkit_agent_listener_get_type                        (void) G_GNUC_CONST;
96

97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
void      polkit_agent_listener_initiate_authentication         (PolkitAgentListener      *listener,
                                                                 const gchar              *action_id,
                                                                 const gchar              *message,
                                                                 const gchar              *icon_name,
                                                                 PolkitDetails            *details,
                                                                 const gchar              *cookie,
                                                                 GList                    *identities,
                                                                 GCancellable             *cancellable,
                                                                 GAsyncReadyCallback       callback,
                                                                 gpointer                  user_data);

gboolean  polkit_agent_listener_initiate_authentication_finish  (PolkitAgentListener      *listener,
                                                                 GAsyncResult             *res,
                                                                 GError                  **error);

gboolean  polkit_agent_register_listener                        (PolkitAgentListener      *listener,
                                                                 PolkitSubject            *subject,
                                                                 const gchar              *object_path,
115
                                                                 GError                  **error) G_GNUC_DEPRECATED_FOR (polkit_agent_listener_register);
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136

/**
 * PolkitAgentRegisterFlags:
 * @POLKIT_AGENT_REGISTER_FLAGS_NONE: No flags are set.
 * @POLKIT_AGENT_REGISTER_FLAGS_RUN_IN_THREAD: Run the listener in a dedicated thread.
 *
 * Flags used in polkit_agent_listener_register().
 */
typedef enum
{
  POLKIT_AGENT_REGISTER_FLAGS_NONE = 0,
  POLKIT_AGENT_REGISTER_FLAGS_RUN_IN_THREAD = (1<<0)
} PolkitAgentRegisterFlags;

gpointer  polkit_agent_listener_register                        (PolkitAgentListener      *listener,
                                                                 PolkitAgentRegisterFlags  flags,
                                                                 PolkitSubject            *subject,
                                                                 const gchar              *object_path,
                                                                 GCancellable             *cancellable,
                                                                 GError                  **error);

137 138 139 140 141 142 143 144
gpointer  polkit_agent_listener_register_with_options           (PolkitAgentListener      *listener,
                                                                 PolkitAgentRegisterFlags  flags,
                                                                 PolkitSubject            *subject,
                                                                 const gchar              *object_path,
                                                                 GVariant                 *options,
                                                                 GCancellable             *cancellable,
                                                                 GError                  **error);

145
void      polkit_agent_listener_unregister                      (gpointer                  registration_handle);
146 147 148 149

G_END_DECLS

#endif /* __POLKIT_AGENT_LISTENER_H */