diff --git a/installed-tests/fixtures/backend.js b/installed-tests/fixtures/backend.js index e126c35e7..d7eec1932 100644 --- a/installed-tests/fixtures/backend.js +++ b/installed-tests/fixtures/backend.js @@ -11,6 +11,17 @@ 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 @@ -127,7 +138,7 @@ var ChannelService = GObject.registerClass({ // Input stream this._udp6_stream = new Gio.DataInputStream({ - base_stream: new Gio.UnixInputStream({ + base_stream: new GioUnix.InputStream({ fd: this._udp6.fd, close_fd: false, }), @@ -159,7 +170,7 @@ var ChannelService = GObject.registerClass({ // Input stream this._udp4_stream = new Gio.DataInputStream({ - base_stream: new Gio.UnixInputStream({ + base_stream: new GioUnix.InputStream({ fd: this._udp4.fd, close_fd: false, }), diff --git a/src/gsconnect-preferences b/src/gsconnect-preferences index f9dad2355..5327686cb 100755 --- a/src/gsconnect-preferences +++ b/src/gsconnect-preferences @@ -11,6 +11,7 @@ imports.gi.versions.Gdk = '3.0'; imports.gi.versions.GdkPixbuf = '2.0'; imports.gi.versions.Gio = '2.0'; +imports.gi.versions.GioUnix = '2.0'; imports.gi.versions.GLib = '2.0'; imports.gi.versions.GObject = '2.0'; imports.gi.versions.Gtk = '3.0'; diff --git a/src/service/backends/lan.js b/src/service/backends/lan.js index a5357bf28..4d321f7ff 100644 --- a/src/service/backends/lan.js +++ b/src/service/backends/lan.js @@ -11,6 +11,16 @@ 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 @@ -264,7 +274,7 @@ var ChannelService = GObject.registerClass({ // Input stream this._udp6_stream = new Gio.DataInputStream({ - base_stream: new Gio.UnixInputStream({ + base_stream: new GioUnix.InputStream({ fd: this._udp6.fd, close_fd: false, }), @@ -296,7 +306,7 @@ var ChannelService = GObject.registerClass({ // Input stream this._udp4_stream = new Gio.DataInputStream({ - base_stream: new Gio.UnixInputStream({ + base_stream: new GioUnix.InputStream({ fd: this._udp4.fd, close_fd: false, }), diff --git a/src/service/daemon.js b/src/service/daemon.js index 0d51748d8..27a69e29c 100755 --- a/src/service/daemon.js +++ b/src/service/daemon.js @@ -9,6 +9,7 @@ imports.gi.versions.Gdk = '3.0'; imports.gi.versions.GdkPixbuf = '2.0'; imports.gi.versions.Gio = '2.0'; +imports.gi.versions.GioUnix = '2.0'; imports.gi.versions.GIRepository = '2.0'; imports.gi.versions.GLib = '2.0'; imports.gi.versions.GObject = '2.0'; diff --git a/src/service/nativeMessagingHost.js b/src/service/nativeMessagingHost.js index d83fc7f3f..c7711b754 100755 --- a/src/service/nativeMessagingHost.js +++ b/src/service/nativeMessagingHost.js @@ -7,6 +7,7 @@ 'use strict'; imports.gi.versions.Gio = '2.0'; +imports.gi.versions.GioUnix = '2.0'; imports.gi.versions.GLib = '2.0'; imports.gi.versions.GObject = '2.0'; @@ -15,6 +16,17 @@ 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', @@ -44,12 +56,12 @@ const NativeMessagingHost = GObject.registerClass({ // IO Channels this._stdin = new Gio.DataInputStream({ - base_stream: new Gio.UnixInputStream({fd: 0}), + base_stream: new GioUnix.InputStream({fd: 0}), byte_order: Gio.DataStreamByteOrder.HOST_ENDIAN, }); this._stdout = new Gio.DataOutputStream({ - base_stream: new Gio.UnixOutputStream({fd: 1}), + base_stream: new GioUnix.OutputStream({fd: 1}), byte_order: Gio.DataStreamByteOrder.HOST_ENDIAN, });