:right-sidebar: True TlsInteraction =================================================================== .. currentmodule:: gi.repository.Gio .. versionadded:: 2.30 .. class:: TlsInteraction(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` ``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 :obj:`~gi.repository.Gio.TlsConnection.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 :obj:`~gi.repository.Gio.TlsInteraction.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. Methods ------- .. rst-class:: interim-class .. class:: TlsInteraction :no-index: .. method:: ask_password(password: ~gi.repository.Gio.TlsPassword, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.TlsInteractionResult Run synchronous interaction to ask the user for a password. In general, :func:`~gi.repository.Gio.TlsInteraction.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 :const:`~gi.repository.Gio.TlsInteractionResult.FAILED` will be returned with an error that contains a :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` error code. Certain implementations may not support immediate cancellation. .. versionadded:: 2.30 :param password: a :obj:`~gi.repository.Gio.TlsPassword` object :param cancellable: an optional :obj:`~gi.repository.Gio.Cancellable` cancellation object .. method:: ask_password_async(password: ~gi.repository.Gio.TlsPassword, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Run asynchronous interaction to ask the user for a password. In general, :func:`~gi.repository.Gio.TlsInteraction.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 :const:`~gi.repository.Gio.TlsInteractionResult.FAILED` will be returned with an error that contains a :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` error code. Certain implementations may not support immediate cancellation. Certain implementations may not support immediate cancellation. .. versionadded:: 2.30 :param password: a :obj:`~gi.repository.Gio.TlsPassword` object :param cancellable: an optional :obj:`~gi.repository.Gio.Cancellable` cancellation object :param callback: will be called when the interaction completes :param user_data: data to pass to the ``callback`` .. method:: ask_password_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.TlsInteractionResult Complete an ask password user interaction request. This should be once the :func:`~gi.repository.Gio.TlsInteraction.ask_password_async` completion callback is called. If :const:`~gi.repository.Gio.TlsInteractionResult.HANDLED` is returned, then the :obj:`~gi.repository.Gio.TlsPassword` passed to :func:`~gi.repository.Gio.TlsInteraction.ask_password` will have its password filled in. If the interaction is cancelled by the cancellation object, or by the user then :const:`~gi.repository.Gio.TlsInteractionResult.FAILED` will be returned with an error that contains a :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` error code. .. versionadded:: 2.30 :param result: the result passed to the callback .. method:: do_ask_password(self, password: ~gi.repository.Gio.TlsPassword, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.TlsInteractionResult :param password: :param cancellable: .. method:: do_ask_password_async(self, password: ~gi.repository.Gio.TlsPassword, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None :param password: :param cancellable: :param callback: :param user_data: .. method:: do_ask_password_finish(self, result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.TlsInteractionResult :param result: .. method:: do_request_certificate(self, connection: ~gi.repository.Gio.TlsConnection, flags: ~gi.repository.Gio.TlsCertificateRequestFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.TlsInteractionResult :param connection: :param flags: :param cancellable: .. method:: do_request_certificate_async(self, connection: ~gi.repository.Gio.TlsConnection, flags: ~gi.repository.Gio.TlsCertificateRequestFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None :param connection: :param flags: :param cancellable: :param callback: :param user_data: .. method:: do_request_certificate_finish(self, result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.TlsInteractionResult :param result: .. method:: invoke_ask_password(password: ~gi.repository.Gio.TlsPassword, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.TlsInteractionResult Invoke the interaction to ask the user for a password. It invokes this interaction in the main loop, specifically the :obj:`~gi.repository.GLib.MainContext` returned by :func:`~gi.repository.GLib.MainContext.get_thread_default` when the interaction is created. This is called by called by :obj:`~gi.repository.Gio.TlsConnection` or :obj:`~gi.repository.Gio.TlsDatabase` 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 :const:`~gi.repository.Gio.TlsInteractionResult.FAILED` will be returned with an error that contains a :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` error code. Certain implementations may not support immediate cancellation. .. versionadded:: 2.30 :param password: a :obj:`~gi.repository.Gio.TlsPassword` object :param cancellable: an optional :obj:`~gi.repository.Gio.Cancellable` cancellation object .. method:: invoke_request_certificate(connection: ~gi.repository.Gio.TlsConnection, flags: ~gi.repository.Gio.TlsCertificateRequestFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.TlsInteractionResult Invoke the interaction to ask the user to choose a certificate to use with the connection. It invokes this interaction in the main loop, specifically the :obj:`~gi.repository.GLib.MainContext` returned by :func:`~gi.repository.GLib.MainContext.get_thread_default` when the interaction is created. This is called by called by :obj:`~gi.repository.Gio.TlsConnection` when the peer requests a certificate during the handshake. Derived subclasses usually implement a certificate selector, although they may also choose to provide a certificate from elsewhere. Alternatively the user may abort this certificate request, which may or may not 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 :const:`~gi.repository.Gio.TlsInteractionResult.FAILED` will be returned with an error that contains a :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` error code. Certain implementations may not support immediate cancellation. .. versionadded:: 2.40 :param connection: a :obj:`~gi.repository.Gio.TlsConnection` object :param flags: flags providing more information about the request :param cancellable: an optional :obj:`~gi.repository.Gio.Cancellable` cancellation object .. method:: request_certificate(connection: ~gi.repository.Gio.TlsConnection, flags: ~gi.repository.Gio.TlsCertificateRequestFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.TlsInteractionResult Run synchronous interaction to ask the user to choose a certificate to use with the connection. In general, :func:`~gi.repository.Gio.TlsInteraction.invoke_request_certificate` should be used instead of this function. Derived subclasses usually implement a certificate selector, although they may also choose to provide a certificate from elsewhere. Alternatively the user may abort this certificate request, which will usually abort the TLS connection. If :const:`~gi.repository.Gio.TlsInteractionResult.HANDLED` is returned, then the :obj:`~gi.repository.Gio.TlsConnection` passed to :func:`~gi.repository.Gio.TlsInteraction.request_certificate` will have had its :obj:`~gi.repository.Gio.TlsConnection`\:certificate filled in. If the interaction is cancelled by the cancellation object, or by the user then :const:`~gi.repository.Gio.TlsInteractionResult.FAILED` will be returned with an error that contains a :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` error code. Certain implementations may not support immediate cancellation. .. versionadded:: 2.40 :param connection: a :obj:`~gi.repository.Gio.TlsConnection` object :param flags: flags providing more information about the request :param cancellable: an optional :obj:`~gi.repository.Gio.Cancellable` cancellation object .. method:: request_certificate_async(connection: ~gi.repository.Gio.TlsConnection, flags: ~gi.repository.Gio.TlsCertificateRequestFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Run asynchronous interaction to ask the user for a certificate to use with the connection. In general, :func:`~gi.repository.Gio.TlsInteraction.invoke_request_certificate` should be used instead of this function. Derived subclasses usually implement a certificate selector, although they may also choose to provide a certificate from elsewhere. ``callback`` will be called when the operation completes. Alternatively the user may abort this certificate request, which will usually abort the TLS connection. .. versionadded:: 2.40 :param connection: a :obj:`~gi.repository.Gio.TlsConnection` object :param flags: flags providing more information about the request :param cancellable: an optional :obj:`~gi.repository.Gio.Cancellable` cancellation object :param callback: will be called when the interaction completes :param user_data: data to pass to the ``callback`` .. method:: request_certificate_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.TlsInteractionResult Complete a request certificate user interaction request. This should be once the :func:`~gi.repository.Gio.TlsInteraction.request_certificate_async` completion callback is called. If :const:`~gi.repository.Gio.TlsInteractionResult.HANDLED` is returned, then the :obj:`~gi.repository.Gio.TlsConnection` passed to :func:`~gi.repository.Gio.TlsInteraction.request_certificate_async` will have had its :obj:`~gi.repository.Gio.TlsConnection`\:certificate filled in. If the interaction is cancelled by the cancellation object, or by the user then :const:`~gi.repository.Gio.TlsInteractionResult.FAILED` will be returned with an error that contains a :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` error code. .. versionadded:: 2.40 :param result: the result passed to the callback Virtual Methods --------------- .. rst-class:: interim-class .. class:: TlsInteraction :no-index: .. method:: do_ask_password(password: ~gi.repository.Gio.TlsPassword, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.TlsInteractionResult Run synchronous interaction to ask the user for a password. In general, :func:`~gi.repository.Gio.TlsInteraction.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 :const:`~gi.repository.Gio.TlsInteractionResult.FAILED` will be returned with an error that contains a :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` error code. Certain implementations may not support immediate cancellation. .. versionadded:: 2.30 :param password: a :obj:`~gi.repository.Gio.TlsPassword` object :param cancellable: an optional :obj:`~gi.repository.Gio.Cancellable` cancellation object .. method:: do_ask_password_async(password: ~gi.repository.Gio.TlsPassword, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Run asynchronous interaction to ask the user for a password. In general, :func:`~gi.repository.Gio.TlsInteraction.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 :const:`~gi.repository.Gio.TlsInteractionResult.FAILED` will be returned with an error that contains a :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` error code. Certain implementations may not support immediate cancellation. Certain implementations may not support immediate cancellation. .. versionadded:: 2.30 :param password: a :obj:`~gi.repository.Gio.TlsPassword` object :param cancellable: an optional :obj:`~gi.repository.Gio.Cancellable` cancellation object :param callback: will be called when the interaction completes :param user_data: data to pass to the ``callback`` .. method:: do_ask_password_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.TlsInteractionResult Complete an ask password user interaction request. This should be once the :func:`~gi.repository.Gio.TlsInteraction.ask_password_async` completion callback is called. If :const:`~gi.repository.Gio.TlsInteractionResult.HANDLED` is returned, then the :obj:`~gi.repository.Gio.TlsPassword` passed to :func:`~gi.repository.Gio.TlsInteraction.ask_password` will have its password filled in. If the interaction is cancelled by the cancellation object, or by the user then :const:`~gi.repository.Gio.TlsInteractionResult.FAILED` will be returned with an error that contains a :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` error code. .. versionadded:: 2.30 :param result: the result passed to the callback .. method:: do_request_certificate(connection: ~gi.repository.Gio.TlsConnection, flags: ~gi.repository.Gio.TlsCertificateRequestFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.TlsInteractionResult Run synchronous interaction to ask the user to choose a certificate to use with the connection. In general, :func:`~gi.repository.Gio.TlsInteraction.invoke_request_certificate` should be used instead of this function. Derived subclasses usually implement a certificate selector, although they may also choose to provide a certificate from elsewhere. Alternatively the user may abort this certificate request, which will usually abort the TLS connection. If :const:`~gi.repository.Gio.TlsInteractionResult.HANDLED` is returned, then the :obj:`~gi.repository.Gio.TlsConnection` passed to :func:`~gi.repository.Gio.TlsInteraction.request_certificate` will have had its :obj:`~gi.repository.Gio.TlsConnection`\:certificate filled in. If the interaction is cancelled by the cancellation object, or by the user then :const:`~gi.repository.Gio.TlsInteractionResult.FAILED` will be returned with an error that contains a :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` error code. Certain implementations may not support immediate cancellation. .. versionadded:: 2.40 :param connection: a :obj:`~gi.repository.Gio.TlsConnection` object :param flags: flags providing more information about the request :param cancellable: an optional :obj:`~gi.repository.Gio.Cancellable` cancellation object .. method:: do_request_certificate_async(connection: ~gi.repository.Gio.TlsConnection, flags: ~gi.repository.Gio.TlsCertificateRequestFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Run asynchronous interaction to ask the user for a certificate to use with the connection. In general, :func:`~gi.repository.Gio.TlsInteraction.invoke_request_certificate` should be used instead of this function. Derived subclasses usually implement a certificate selector, although they may also choose to provide a certificate from elsewhere. ``callback`` will be called when the operation completes. Alternatively the user may abort this certificate request, which will usually abort the TLS connection. .. versionadded:: 2.40 :param connection: a :obj:`~gi.repository.Gio.TlsConnection` object :param flags: flags providing more information about the request :param cancellable: an optional :obj:`~gi.repository.Gio.Cancellable` cancellation object :param callback: will be called when the interaction completes :param user_data: data to pass to the ``callback`` .. method:: do_request_certificate_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.TlsInteractionResult Complete a request certificate user interaction request. This should be once the :func:`~gi.repository.Gio.TlsInteraction.request_certificate_async` completion callback is called. If :const:`~gi.repository.Gio.TlsInteractionResult.HANDLED` is returned, then the :obj:`~gi.repository.Gio.TlsConnection` passed to :func:`~gi.repository.Gio.TlsInteraction.request_certificate_async` will have had its :obj:`~gi.repository.Gio.TlsConnection`\:certificate filled in. If the interaction is cancelled by the cancellation object, or by the user then :const:`~gi.repository.Gio.TlsInteractionResult.FAILED` will be returned with an error that contains a :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` error code. .. versionadded:: 2.40 :param result: the result passed to the callback Fields ------ .. rst-class:: interim-class .. class:: TlsInteraction :no-index: .. attribute:: parent_instance .. attribute:: priv