PolkitAgent.Listener

g GObject.Object GObject.Object PolkitAgent.Listener PolkitAgent.Listener GObject.Object->PolkitAgent.Listener

Subclasses:

PolkitAgent.TextListener

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

unregister (registration_handle)

initiate_authentication (action_id, message, icon_name, details, cookie, identities, cancellable, callback, *user_data)

initiate_authentication_finish (res)

register (flags, subject, object_path, cancellable)

register_with_options (flags, subject, object_path, options, cancellable)

Virtual Methods

Inherited:

GObject.Object (7)

do_initiate_authentication (action_id, message, icon_name, details, cookie, identities, cancellable, callback, *user_data)

do_initiate_authentication_finish (res)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class PolkitAgent.Listener(**kwargs)
Bases:

GObject.Object

Abstract:

Yes

Structure:

PolkitAgent.ListenerClass

PolkitAgent.Listener is an abstract base class used for implementing authentication agents. To implement an authentication agent, simply subclass PolkitAgent.Listener and implement the initiate_authentication and initiate_authentication_finish methods.

Typically authentication agents use PolkitAgent.Session to authenticate users (via passwords) and communicate back the authentication result to the PolicyKit daemon.

To register a PolkitAgent.Listener with the PolicyKit daemon, use PolkitAgent.Listener.register() or PolkitAgent.Listener.register_with_options().

classmethod unregister(registration_handle)
Parameters:

registration_handle (object or None) – A handle obtained from PolkitAgent.Listener.register().

Unregisters listener.

initiate_authentication(action_id, message, icon_name, details, cookie, identities, cancellable, callback, *user_data)
Parameters:

Called on a registered authentication agent (see PolkitAgent.Listener.register()) 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 PolkitAgent.Listener.initiate_authentication_finish() to get the result.

PolkitAgent.Listener derived subclasses imlementing this method MUST not ignore cancellable; callers of this function can and will use it. Additionally, callback must be invoked in the thread-default main loop of the thread that this method is called from.

initiate_authentication_finish(res)
Parameters:

res (Gio.AsyncResult) – A Gio.AsyncResult obtained from the Gio.AsyncReadyCallback function passed to PolkitAgent.Listener.initiate_authentication().

Raises:

GLib.Error

Returns:

True if error is set.

Return type:

bool

Finishes an authentication request from the PolicyKit daemon, see PolkitAgent.Listener.initiate_authentication() for details.

register(flags, subject, object_path, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

None if error is set, otherwise a registration handle that can be used with PolkitAgent.Listener.unregister().

Return type:

object or None

Registers self 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 to subject, the methods PolkitAgent.Listener.initiate_authentication() and PolkitAgent.Listener.initiate_authentication_finish() will be invoked on self.

Note that registration of an authentication agent can fail; for example another authentication agent may already be registered for subject.

Note that the calling thread is blocked until a reply is received.

register_with_options(flags, subject, object_path, options, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

None if error is set, otherwise a registration handle that can be used with PolkitAgent.Listener.unregister().

Return type:

object or None

Like PolkitAgent.Listener.register() but takes options to influence registration. See the

‘RegisterAuthenticationAgentWithOptions() [eggdbus-method-org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgentWithOptions]’ D-Bus method for details.

do_initiate_authentication(action_id, message, icon_name, details, cookie, identities, cancellable, callback, *user_data) virtual
Parameters:

Called on a registered authentication agent (see PolkitAgent.Listener.register()) 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 PolkitAgent.Listener.initiate_authentication_finish() to get the result.

PolkitAgent.Listener derived subclasses imlementing this method MUST not ignore cancellable; callers of this function can and will use it. Additionally, callback must be invoked in the thread-default main loop of the thread that this method is called from.

do_initiate_authentication_finish(res) virtual
Parameters:

res (Gio.AsyncResult) – A Gio.AsyncResult obtained from the Gio.AsyncReadyCallback function passed to PolkitAgent.Listener.initiate_authentication().

Returns:

True if error is set.

Return type:

bool

Finishes an authentication request from the PolicyKit daemon, see PolkitAgent.Listener.initiate_authentication() for details.