From ad2cf7f8fe1db91305dd374c347a5df9cdf6d78f Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sat, 6 Apr 2024 16:16:36 -0400 Subject: [PATCH] Import GioUnix with "polyfill" for compatibility --- installed-tests/fixtures/backend.js | 12 +++++++++++- src/service/backends/lan.js | 11 ++++++++++- src/service/nativeMessagingHost.js | 12 +++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/installed-tests/fixtures/backend.js b/installed-tests/fixtures/backend.js index cec523a21..d7eec1932 100644 --- a/installed-tests/fixtures/backend.js +++ b/installed-tests/fixtures/backend.js @@ -5,13 +5,23 @@ 'use strict'; const Gio = imports.gi.Gio; -const GioUnix = imports.gi.GioUnix; const GLib = imports.gi.GLib; const GObject = imports.gi.GObject; const Config = imports.config; const Core = imports.service.core; +// Retain compatibility with GLib < 2.80, which lacks GioUnix +let GioUnix; +try { + GioUnix = imports.gi.GioUnix; +} catch (e) { + GioUnix = { + InputStream: Gio.UnixInputStream, + OutputStream: Gio.UnixOutputStream, + }; +} + /** * TCP Port Constants diff --git a/src/service/backends/lan.js b/src/service/backends/lan.js index b6526b8d3..4d321f7ff 100644 --- a/src/service/backends/lan.js +++ b/src/service/backends/lan.js @@ -5,13 +5,22 @@ 'use strict'; const Gio = imports.gi.Gio; -const GioUnix = imports.gi.GioUnix; const GLib = imports.gi.GLib; const GObject = imports.gi.GObject; const Config = imports.config; const Core = imports.service.core; +// Retain compatibility with GLib < 2.80, which lacks GioUnix +let GioUnix; +try { + GioUnix = imports.gi.GioUnix; +} catch (e) { + GioUnix = { + InputStream: Gio.UnixInputStream, + OutputStream: Gio.UnixOutputStream, + }; +} /** * TCP Port Constants diff --git a/src/service/nativeMessagingHost.js b/src/service/nativeMessagingHost.js index f06d33e51..c7711b754 100755 --- a/src/service/nativeMessagingHost.js +++ b/src/service/nativeMessagingHost.js @@ -12,11 +12,21 @@ imports.gi.versions.GLib = '2.0'; imports.gi.versions.GObject = '2.0'; const Gio = imports.gi.Gio; -const GioUnix = imports.gi.GioUnix; const GLib = imports.gi.GLib; const GObject = imports.gi.GObject; const System = imports.system; +// Retain compatibility with GLib < 2.80, which lacks GioUnix +let GioUnix; +try { + GioUnix = imports.gi.GioUnix; +} catch (e) { + GioUnix = { + InputStream: Gio.UnixInputStream, + OutputStream: Gio.UnixOutputStream, + }; +} + const NativeMessagingHost = GObject.registerClass({ GTypeName: 'GSConnectNativeMessagingHost',