[polari] telepathyClient: Use Async D-Bus wrappers
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] telepathyClient: Use Async D-Bus wrappers
- Date: Wed, 28 Sep 2022 10:11:40 +0000 (UTC)
commit cda446f9a1fe6ee425c44f6c4b19666427850613
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Jun 23 22:35:45 2022 +0200
telepathyClient: Use Async D-Bus wrappers
gjs' D-Bus wrapper now generates an Async variant that returns a
promise. Use that to replace some more callbacks with async code.
Part-of: <https://gitlab.gnome.org/GNOME/polari/-/merge_requests/261>
src/telepathyClient.js | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
---
diff --git a/src/telepathyClient.js b/src/telepathyClient.js
index 6f94e958..1dfd1767 100644
--- a/src/telepathyClient.js
+++ b/src/telepathyClient.js
@@ -80,13 +80,18 @@ class SASLAuthHandler {
let account = this._channel.connection.get_account();
try {
const password = await Utils.lookupAccountPassword(account);
- this._proxy.StartMechanismWithDataRemote(
+ await this._proxy.StartMechanismWithDataAsync(
'X-TELEPATHY-PASSWORD', password);
} catch (e) {
- this._proxy.AbortSASLRemote(
+ await this._proxy.AbortSASLAsync(
SASLAbortReason.USER_ABORT,
- 'Password not available',
- this._resetPrompt.bind(this));
+ 'Password not available');
+
+ let prompt = new GLib.Variant('b', false);
+ let params = new GLib.Variant('a{sv}', { 'password-prompt': prompt });
+ await account.update_parameters_vardict_async(params, []);
+ await account.request_presence_async(Tp.ConnectionPresenceType.AVAILABLE,
+ 'available', '', null);
}
}
@@ -102,7 +107,7 @@ class SASLAuthHandler {
break;
case SASLStatus.SERVER_SUCCEEDED:
- this._proxy.AcceptSASLRemote();
+ this._proxy.AcceptSASLAsync();
break;
case SASLStatus.SUCCEEDED:
@@ -112,15 +117,6 @@ class SASLAuthHandler {
break;
}
}
-
- async _resetPrompt() {
- let account = this._channel.connection.get_account();
- let prompt = new GLib.Variant('b', false);
- let params = new GLib.Variant('a{sv}', { 'password-prompt': prompt });
- await account.update_parameters_vardict_async(params, []);
- await account.request_presence_async(Tp.ConnectionPresenceType.AVAILABLE,
- 'available', '', null);
- }
}
export default GObject.registerClass(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]