PolicyKit Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy |
Synopsis
PolkitAgentListener; PolkitAgentListenerClass; 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, GError **error);
Description
PolkitAgentListener is an abstract base class used for implementing authentication
agents. To implement an authentication agent, simply subclass PolkitAgentListener and
implement the initiate_authentication
and initiate_authentication_finish
VFuncs.
Typically authentication agents use PolkitAgentSession to authenticate users (via passwords) and communicate back the authentication result to the PolicyKit daemon. This is however not requirement. Depending on the system an authentication agent may use other means (such as a Yes/No dialog) to obtain sufficient evidence that the user is one of the requested identities.
To register a PolkitAgentListener with the PolicyKit daemon, use polkit_agent_register_listener()
.
Details
PolkitAgentListener
typedef struct _PolkitAgentListener PolkitAgentListener;
The PolkitAgentListener struct should not be accessed directly.
PolkitAgentListenerClass
typedef struct { GObjectClass parent_class; /* Vtable */ void (*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 (*initiate_authentication_finish) (PolkitAgentListener *listener, GAsyncResult *res, GError **error); } PolkitAgentListenerClass;
VFuncs that authentication agents needs to implement.
GObjectClass |
The parent class. |
Handle an authentication request, see polkit_agent_listener_initiate_authentication() .
|
|
Finishes handling an authentication request, see polkit_agent_listener_initiate_authentication_finish() .
|
polkit_agent_listener_initiate_authentication ()
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);
Called on a registered authentication agent (see polkit_agent_register_listener()
) when
the user owning the session needs to prove he is one of the identities listed in identities
.
When the user is done authenticating (for example by dismissing an authentication dialog
or by successfully entering a password or otherwise proving the user is one of the
identities in identities
), callback
will be invoked. The caller then calls
polkit_agent_listener_initiate_authentication_finish()
to get the result.
PolkitAgentListener derived subclasses imlementing this method MUST not
ignore cancellable
; callers of this function can and will use it.
|
A PolkitAgentListener. |
|
The action to authenticate for. |
|
The message to present to the user. |
|
A themed icon name representing the action or NULL .
|
|
Details describing the action. |
|
The cookie for the authentication request. |
|
A list of PolkitIdentity objects that the user can choose to authenticate as. |
|
A GCancellable. |
|
Function to call when the user is done authenticating. |
|
Data to pass to callback .
|
polkit_agent_listener_initiate_authentication_finish ()
gboolean polkit_agent_listener_initiate_authentication_finish (PolkitAgentListener *listener, GAsyncResult *res, GError **error);
Finishes an authentication request from the PolicyKit daemon, see
polkit_agent_listener_initiate_authentication()
for details.
|
A PolkitAgentListener. |
|
A GAsyncResult obtained from the GAsyncReadyCallback function passed to polkit_agent_listener_initiate_authentication() .
|
|
Return location for error. |
Returns : |
TRUE if error is set.
|
polkit_agent_register_listener ()
gboolean polkit_agent_register_listener (PolkitAgentListener *listener, PolkitSubject *subject, const gchar *object_path, GError **error);
Registers listener
with the PolicyKit daemon as an authentication agent for subject
. This
is implemented by registering a D-Bus object at object_path
on the unique name assigned by the
system message bus.
Whenever the PolicyKit daemon needs to authenticate a processes that is related subject
, the methods
polkit_agent_listener_initiate_authentication()
and polkit_agent_listener_initiate_authentication_finish()
will be invoked on listener
.
Note that registration of an authentication agent can fail; for example another authentication agent may already be registered.
To unregister listener
, simply free it with g_object_unref()
.
|
An instance of a class that is derived from PolkitAgentListener. |
|
The subject to become an authentication agent for, typically a PolkitUnixSession object. |
|
The D-Bus object path to use for the authentication agent or NULL for the default object path.
|
|
Return location for error. |
Returns : |
TRUE if listener has been registered, FALSE if error is set.
|