diff --git a/meson.build b/meson.build index 38db28aeb01d330e52d3e67767be9045931859ed..7dd3c4459dc2c42cbc42ab6c97f6310dd96da296 100644 --- a/meson.build +++ b/meson.build @@ -35,7 +35,7 @@ check_version = find_program('meson/check-version.py') gio = dependency('gio-2.0', version: '>= 2.43.4') telepathy_glib = dependency('telepathy-glib') girepository = dependency('gobject-introspection-1.0') -gjs = dependency('gjs-1.0', version: '>= 1.69.2') +gjs = dependency('gjs-1.0', version: '>= 1.73.1') conf = configuration_data() diff --git a/src/application.js b/src/application.js index 776b2e045608d26962fbee783953719568816206..605b7ab0081f7cdfc1ba6c6ba473344f6b946b39 100644 --- a/src/application.js +++ b/src/application.js @@ -217,74 +217,72 @@ class Application extends Adw.Application { vfunc_startup() { super.vfunc_startup(); - let actionEntries = [{ + const actionEntries = [{ name: 'show-join-dialog', activate: this._onShowJoinDialog.bind(this), accels: ['n'], }, { name: 'join-room', activate: this._onJoinRoom.bind(this), - parameter_type: GLib.VariantType.new('(ssb)'), + parameter_type: '(ssb)', }, { name: 'message-user', activate: this._onMessageUser.bind(this), - parameter_type: GLib.VariantType.new('(sssb)'), + parameter_type: '(sssb)', }, { name: 'leave-room', - parameter_type: GLib.VariantType.new('(ss)'), + parameter_type: '(ss)', }, { name: 'leave-current-room', activate: this._onLeaveCurrentRoom.bind(this), - create_hook: a => (a.enabled = false), accels: ['w'], }, { name: 'reconnect-room', - parameter_type: GLib.VariantType.new('s'), + parameter_type: 's', }, { name: 'authenticate-account', - parameter_type: GLib.VariantType.new('(os)'), + parameter_type: '(os)', }, { name: 'connect-account', activate: this._onConnectAccount.bind(this), - parameter_type: GLib.VariantType.new('o'), + parameter_type: 'o', }, { name: 'disconnect-account', activate: this._onConnectAccount.bind(this), - parameter_type: GLib.VariantType.new('o'), + parameter_type: 'o', }, { name: 'reconnect-account', activate: this._onConnectAccount.bind(this), - parameter_type: GLib.VariantType.new('o'), + parameter_type: 'o', }, { name: 'mute-nick', - parameter_type: GLib.VariantType.new('(ss)'), + parameter_type: '(ss)', }, { name: 'unmute-nick', - parameter_type: GLib.VariantType.new('(ss)'), + parameter_type: '(ss)', }, { name: 'user-list', activate: this._onToggleAction.bind(this), - create_hook: this._userListCreateHook.bind(this), - state: GLib.Variant.new('b', false), + state: 'false', accels: ['F9', 'u'], }, { name: 'remove-connection', activate: this._onRemoveConnection.bind(this), - parameter_type: GLib.VariantType.new('o'), + parameter_type: 'o', }, { name: 'undo-remove-connection', activate: this._onUndoRemoveConnection.bind(this), - parameter_type: GLib.VariantType.new('o'), + parameter_type: 'o', }, { name: 'edit-connection', activate: this._onEditConnection.bind(this), - parameter_type: GLib.VariantType.new('o'), + parameter_type: 'o', }, { name: 'save-identify-password', - parameter_type: GLib.VariantType.new('o'), + parameter_type: 'o', }, { name: 'discard-identify-password', - parameter_type: GLib.VariantType.new('o'), + parameter_type: 'o', }, { name: 'show-emoji-picker', accels: ['e'], @@ -316,7 +314,7 @@ class Application extends Adw.Application { accels: ['End'], }, { name: 'nth-room', - parameter_type: GLib.VariantType.new('i'), + parameter_type: 'i', }, { name: 'next-pending-room', accels: ['Down', 'Page_Down'], @@ -324,31 +322,27 @@ class Application extends Adw.Application { name: 'previous-pending-room', accels: ['Up', 'Page_Up'], }]; - actionEntries.forEach(actionEntry => { - let props = {}; - ['name', 'state', 'parameter_type'].forEach(prop => { - if (actionEntry[prop]) - props[prop] = actionEntry[prop]; - }); - let action = new Gio.SimpleAction(props); - if (actionEntry.create_hook) - actionEntry.create_hook(action); - if (actionEntry.activate) - action.connect('activate', actionEntry.activate); - if (actionEntry.change_state) - action.connect('change-state', actionEntry.change_state); - if (actionEntry.accels) { - this.set_accels_for_action( - `app.${actionEntry.name}`, - actionEntry.accels); - } - this.add_action(action); - }); + this.add_action_entries(actionEntries); this._settings = new Gio.Settings({ schema_id: 'org.gnome.Polari' }); let action = this._settings.create_action('run-in-background'); this.add_action(action); + action = this.lookup_action('user-list'); + action.connect('notify::enabled', () => { + if (!action.enabled) + action.change_state(GLib.Variant.new('b', false)); + }); + action.enabled = false; + + action = this.lookup_action('leave-current-room'); + action.enabled = false; + + for (const { name, accels } of actionEntries) { + if (accels) + this.set_accels_for_action(`app.${name}`, accels); + } + for (let i = 1; i < 10; i++) this.set_accels_for_action(`app.nth-room(${i})`, [`${i}`]); @@ -567,14 +561,6 @@ class Application extends Adw.Application { action.enabled = room && room.type === Tp.HandleType.ROOM && room.channel; } - _userListCreateHook(action) { - action.connect('notify::enabled', () => { - if (!action.enabled) - action.change_state(GLib.Variant.new('b', false)); - }); - action.enabled = false; - } - _onShowJoinDialog() { this.active_window.showJoinRoomDialog(); } diff --git a/src/telepathyClient.js b/src/telepathyClient.js index 6f94e958b716b81bd7eb909b701b177b951de083..1dfd17674038948296f91e95ab11594b4749ffd3 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(