GIO Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy |
#include <gio/gio.h> GTlsInteraction; enum GTlsInteractionResult; GTlsInteractionResult g_tls_interaction_ask_password (GTlsInteraction *interaction
,GTlsPassword *password
,GCancellable *cancellable
,GError **error
); void g_tls_interaction_ask_password_async (GTlsInteraction *interaction
,GTlsPassword *password
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
); GTlsInteractionResult g_tls_interaction_ask_password_finish (GTlsInteraction *interaction
,GAsyncResult *result
,GError **error
); GTlsInteractionResult g_tls_interaction_invoke_ask_password (GTlsInteraction *interaction
,GTlsPassword *password
,GCancellable *cancellable
,GError **error
);
GTlsInteraction provides a mechanism for the TLS connection and database code to interact with the user. It can be used to ask the user for passwords.
To use a GTlsInteraction with a TLS connection use
g_tls_connection_set_interaction()
.
Callers should instantiate a derived class that implements the various interaction methods to show the required dialogs.
Callers should use the 'invoke' functions like
g_tls_interaction_invoke_ask_password()
to run interaction methods. These
functions make sure that the interaction is invoked in the main loop
and not in the current thread, if the current thread is not running the
main loop.
Derived classes can choose to implement whichever interactions methods they'd
like to support by overriding those virtual methods in their class
initialization function. Any interactions not implemented will return
G_TLS_INTERACTION_UNHANDLED
. If a derived class implements an async method,
it must also implement the corresponding finish method.
typedef struct _GTlsInteraction GTlsInteraction;
An object representing interaction that the TLS connection and database might have with the user.
Since 2.30
typedef enum { G_TLS_INTERACTION_UNHANDLED, G_TLS_INTERACTION_HANDLED, G_TLS_INTERACTION_FAILED } GTlsInteractionResult;
GTlsInteractionResult is returned by various functions in GTlsInteraction when finishing an interaction request.
The interaction was unhandled (i.e. not implemented). | |
The interaction completed, and resulting data is available. | |
The interaction has failed, or was cancelled. and the operation should be aborted. |
Since 2.30
GTlsInteractionResult g_tls_interaction_ask_password (GTlsInteraction *interaction
,GTlsPassword *password
,GCancellable *cancellable
,GError **error
);
Run synchronous interaction to ask the user for a password. In general,
g_tls_interaction_invoke_ask_password()
should be used instead of this
function.
Derived subclasses usually implement a password prompt, although they may
also choose to provide a password from elsewhere. The password
value will
be filled in and then callback
will be called. Alternatively the user may
abort this password request, which will usually abort the TLS connection.
If the interaction is cancelled by the cancellation object, or by the
user then G_TLS_INTERACTION_FAILED
will be returned with an error that
contains a G_IO_ERROR_CANCELLED
error code. Certain implementations may
not support immediate cancellation.
|
a GTlsInteraction object |
|
a GTlsPassword object |
|
an optional GCancellable cancellation object |
|
an optional location to place an error on failure |
Returns : |
The status of the ask password interaction. |
Since 2.30
void g_tls_interaction_ask_password_async (GTlsInteraction *interaction
,GTlsPassword *password
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Run asynchronous interaction to ask the user for a password. In general,
g_tls_interaction_invoke_ask_password()
should be used instead of this
function.
Derived subclasses usually implement a password prompt, although they may
also choose to provide a password from elsewhere. The password
value will
be filled in and then callback
will be called. Alternatively the user may
abort this password request, which will usually abort the TLS connection.
If the interaction is cancelled by the cancellation object, or by the
user then G_TLS_INTERACTION_FAILED
will be returned with an error that
contains a G_IO_ERROR_CANCELLED
error code. Certain implementations may
not support immediate cancellation.
Certain implementations may not support immediate cancellation.
|
a GTlsInteraction object |
|
a GTlsPassword object |
|
an optional GCancellable cancellation object |
|
will be called when the interaction completes. [allow-none] |
|
data to pass to the callback . [allow-none]
|
Since 2.30
GTlsInteractionResult g_tls_interaction_ask_password_finish (GTlsInteraction *interaction
,GAsyncResult *result
,GError **error
);
Complete an ask password user interaction request. This should be once
the g_tls_interaction_ask_password_async()
completion callback is called.
If G_TLS_INTERACTION_HANDLED
is returned, then the GTlsPassword passed
to g_tls_interaction_ask_password()
will have its password filled in.
If the interaction is cancelled by the cancellation object, or by the
user then G_TLS_INTERACTION_FAILED
will be returned with an error that
contains a G_IO_ERROR_CANCELLED
error code.
|
a GTlsInteraction object |
|
the result passed to the callback |
|
an optional location to place an error on failure |
Returns : |
The status of the ask password interaction. |
Since 2.30
GTlsInteractionResult g_tls_interaction_invoke_ask_password (GTlsInteraction *interaction
,GTlsPassword *password
,GCancellable *cancellable
,GError **error
);
Invoke the interaction to ask the user for a password. It invokes this
interaction in the main loop, specifically the GMainContext returned by
g_main_context_get_thread_default()
when the interaction is created. This
is called by called by GTlsConnection or GTlsDatabase to ask the user
for a password.
Derived subclasses usually implement a password prompt, although they may
also choose to provide a password from elsewhere. The password
value will
be filled in and then callback
will be called. Alternatively the user may
abort this password request, which will usually abort the TLS connection.
The implementation can either be a synchronous (eg: modal dialog) or an asynchronous one (eg: modeless dialog). This function will take care of calling which ever one correctly.
If the interaction is cancelled by the cancellation object, or by the
user then G_TLS_INTERACTION_FAILED
will be returned with an error that
contains a G_IO_ERROR_CANCELLED
error code. Certain implementations may
not support immediate cancellation.
|
a GTlsInteraction object |
|
a GTlsPassword object |
|
an optional GCancellable cancellation object |
|
an optional location to place an error on failure |
Returns : |
The status of the ask password interaction. |
Since 2.30