From 9269ed40a720546584736ca863a483fe0c01dddc Mon Sep 17 00:00:00 2001 From: aleksana Date: Fri, 21 Nov 2025 23:10:00 +0800 Subject: [PATCH 1/2] telepathy-idle: add glib-networking --- pkgs/by-name/te/telepathy-idle/package.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/te/telepathy-idle/package.nix b/pkgs/by-name/te/telepathy-idle/package.nix index 52559e1202704..9733627f0c5c9 100644 --- a/pkgs/by-name/te/telepathy-idle/package.nix +++ b/pkgs/by-name/te/telepathy-idle/package.nix @@ -7,6 +7,7 @@ pkg-config, dbus-glib, telepathy-glib, + glib-networking, python3, libxslt, makeWrapper, @@ -28,6 +29,7 @@ stdenv.mkDerivation rec { ]; buildInputs = [ glib + glib-networking telepathy-glib dbus-glib libxslt @@ -36,7 +38,12 @@ stdenv.mkDerivation rec { preFixup = '' wrapProgram "$out/libexec/telepathy-idle" \ - --prefix GIO_EXTRA_MODULES : "${lib.getLib dconf}/lib/gio/modules" + --prefix GIO_EXTRA_MODULES : "${ + lib.makeSearchPath "lib/gio/modules" [ + (lib.getLib dconf) + glib-networking + ] + }" ''; meta = { From ac0816b059b7fff3729e87a83484b0c91513ef88 Mon Sep 17 00:00:00 2001 From: aleksana Date: Fri, 14 Nov 2025 11:27:34 +0800 Subject: [PATCH 2/2] polari: 46.0 -> 49.0 --- ...Dialog-Fix-detecting-pointer-devices.patch | 50 +++++++++++ ...-Disconnect-event-handler-on-destroy.patch | 87 +++++++++++++++++++ ...ption-to-disable-URL-preview-feature.patch | 73 ++++++++++++++++ .../polari/check_dbus_unconditionally.patch | 14 +++ .../po/polari/fix_sparql_database_race.patch | 63 ++++++++++++++ pkgs/by-name/po/polari/package.nix | 57 ++++++++---- 6 files changed, 325 insertions(+), 19 deletions(-) create mode 100644 pkgs/by-name/po/polari/0001-joinDialog-Fix-detecting-pointer-devices.patch create mode 100644 pkgs/by-name/po/polari/0002-mainWindow-Disconnect-event-handler-on-destroy.patch create mode 100644 pkgs/by-name/po/polari/0003-Add-option-to-disable-URL-preview-feature.patch create mode 100644 pkgs/by-name/po/polari/check_dbus_unconditionally.patch create mode 100644 pkgs/by-name/po/polari/fix_sparql_database_race.patch diff --git a/pkgs/by-name/po/polari/0001-joinDialog-Fix-detecting-pointer-devices.patch b/pkgs/by-name/po/polari/0001-joinDialog-Fix-detecting-pointer-devices.patch new file mode 100644 index 0000000000000..34ab01d412d6e --- /dev/null +++ b/pkgs/by-name/po/polari/0001-joinDialog-Fix-detecting-pointer-devices.patch @@ -0,0 +1,50 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ball=C3=B3=20Gy=C3=B6rgy?= +Date: Fri, 30 Aug 2024 16:44:15 +0000 +Subject: [PATCH] joinDialog: Fix detecting pointer devices + +Gtk.get_current_event_device() is not available in GTK4. + +Closes: https://gitlab.gnome.org/GNOME/polari/-/issues/209 +--- + src/serverRoomManager.js | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/src/serverRoomManager.js b/src/serverRoomManager.js +index 88753648388d..3122a09500d9 100644 +--- a/src/serverRoomManager.js ++++ b/src/serverRoomManager.js +@@ -3,7 +3,6 @@ + // + // SPDX-License-Identifier: GPL-2.0-or-later + +-import Gdk from 'gi://Gdk'; + import Gio from 'gi://Gio'; + import GLib from 'gi://GLib'; + import GObject from 'gi://GObject'; +@@ -179,15 +178,23 @@ class ServerRoomList extends Gtk.Box { + this._toggleChecked(this._list.model.get_path(iter)); + }); + ++ let pointerDeviceEvent = false; ++ const clickController = new Gtk.GestureClick(); ++ clickController.connect('pressed', (_controller, _nPress, _x, _y) => { ++ pointerDeviceEvent = true; ++ }); ++ this._list.add_controller(clickController); ++ + this._list.connect('row-activated', (view, path, _column) => { + this._toggleChecked(path); ++ pointerDeviceEvent = false; + }); + + this._toggleRenderer.connect('toggled', (cell, pathStr) => { + // For pointer devices, ::row-activated is emitted as well +- const dev = Gtk.get_current_event_device(); +- if (dev && dev.input_source === Gdk.InputSource.KEYBOARD) ++ if (!pointerDeviceEvent) + this._toggleChecked(Gtk.TreePath.new_from_string(pathStr)); ++ pointerDeviceEvent = false; + }); + + this._manager = ServerRoomManager.getDefault(); diff --git a/pkgs/by-name/po/polari/0002-mainWindow-Disconnect-event-handler-on-destroy.patch b/pkgs/by-name/po/polari/0002-mainWindow-Disconnect-event-handler-on-destroy.patch new file mode 100644 index 0000000000000..a6e829435bfc6 --- /dev/null +++ b/pkgs/by-name/po/polari/0002-mainWindow-Disconnect-event-handler-on-destroy.patch @@ -0,0 +1,87 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ball=C3=B3=20Gy=C3=B6rgy?= +Date: Wed, 13 Nov 2024 13:39:36 +0100 +Subject: [PATCH] mainWindow: Disconnect event handler on destroy + +Without this, it remains active when the main window is closed and +reopened, causing a crash. + +Closes: https://gitlab.gnome.org/GNOME/polari/-/issues/233 +--- + src/mainWindow.js | 23 +++++++++++++---------- + 1 file changed, 13 insertions(+), 10 deletions(-) + +diff --git a/src/mainWindow.js b/src/mainWindow.js +index dfb2ea07dd16..7d813a881106 100644 +--- a/src/mainWindow.js ++++ b/src/mainWindow.js +@@ -96,49 +96,50 @@ class MainWindow extends Adw.ApplicationWindow { + } + }); + +- const app = this.application; +- if (app.isTestInstance) ++ this._app = this.application; ++ if (this._app.isTestInstance) + this.add_css_class('test-instance'); + if (GLib.get_application_name().toLowerCase().includes('snapshot')) + this.add_css_class('snapshot'); + + const actions = [{ + name: 'search', + handler: () => this._searchButton.activate(), + }]; + actions.forEach(a => { +- app.lookup_action(a.name).connect('activate', a.handler); ++ this._app.lookup_action(a.name).connect('activate', a.handler); + }); + + this._roomStack.connect('notify::view-height', + () => this.notify('view-height')); + + this._accountsMonitor = AccountsMonitor.getDefault(); + this._accountsChangedId = this._accountsMonitor.connect( + 'accounts-changed', this._onAccountsChanged.bind(this)); + this._onAccountsChanged(this._accountsMonitor); + + this._accountReachableId = this._accountsMonitor.connect( + 'account-reachable-changed', this._onAccountsReachableChanged.bind(this)); + this._onAccountsReachableChanged(); + + this._roomManager = RoomManager.getDefault(); + this._roomsLoadedId = this._roomManager.connect('rooms-loaded', + this._onRoomsLoaded.bind(this)); + this._roomRemovedId = this._roomManager.connect('room-removed', + this._onRoomRemoved.bind(this)); + this._onRoomsLoaded(); + + this._updateUserListLabel(); + +- this._userListAction = app.lookup_action('user-list'); ++ this._userListAction = this._app.lookup_action('user-list'); + +- app.connect('action-state-changed::user-list', (group, name, value) => { +- if (value.get_boolean()) +- this._userListPopover.popup(); +- else +- this._userListPopover.popdown(); +- }); ++ this._userListActionStateChangedId = ++ this._app.connect('action-state-changed::user-list', (group, name, value) => { ++ if (value.get_boolean()) ++ this._userListPopover.popup(); ++ else ++ this._userListPopover.popdown(); ++ }); + this._userListPopover.connect('notify::visible', () => { + if (!this._userListPopover.visible) + this._userListAction.change_state(GLib.Variant.new('b', false)); +@@ -207,6 +208,8 @@ class MainWindow extends Adw.ApplicationWindow { + + this._roomManager.disconnect(this._roomsLoadedId); + this._roomManager.disconnect(this._roomRemovedId); ++ ++ this._app.disconnect(this._userListActionStateChangedId); + } + + _onAccountsChanged() { diff --git a/pkgs/by-name/po/polari/0003-Add-option-to-disable-URL-preview-feature.patch b/pkgs/by-name/po/polari/0003-Add-option-to-disable-URL-preview-feature.patch new file mode 100644 index 0000000000000..82350cdb372e6 --- /dev/null +++ b/pkgs/by-name/po/polari/0003-Add-option-to-disable-URL-preview-feature.patch @@ -0,0 +1,73 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ball=C3=B3=20Gy=C3=B6rgy?= +Date: Wed, 13 Nov 2024 14:13:28 +0100 +Subject: [PATCH] Add option to disable URL preview feature + +It has security and privacy concerns. + +Closes: https://gitlab.gnome.org/GNOME/polari/-/issues/133 +--- + data/org.gnome.Polari.gschema.xml | 5 +++++ + data/ui/main-window.ui | 4 ++++ + src/application.js | 2 ++ + src/chatView.js | 3 ++- + 4 files changed, 13 insertions(+), 1 deletion(-) + +diff --git a/data/org.gnome.Polari.gschema.xml b/data/org.gnome.Polari.gschema.xml +index bfc3de08ab26..a97603976f40 100644 +--- a/data/org.gnome.Polari.gschema.xml ++++ b/data/org.gnome.Polari.gschema.xml +@@ -36,6 +36,11 @@ SPDX-FileCopyrightText: 2015 Florian Müllner + Last active channel + Last active (selected) channel + ++ ++ false ++ URL Preview ++ Show preview for URLs. ++ + + + +diff --git a/data/ui/main-window.ui b/data/ui/main-window.ui +index 0756a5e24f7d..021a71e3c0ef 100644 +--- a/data/ui/main-window.ui ++++ b/data/ui/main-window.ui +@@ -21,6 +21,10 @@ SPDX-License-Identifier: GPL-2.0-or-later + app.run-in-background + Run in Background + ++ ++ app.url-preview ++ URL Preview ++ + +
+ +diff --git a/src/application.js b/src/application.js +index 6a297646e39f..9a06fbd1081b 100644 +--- a/src/application.js ++++ b/src/application.js +@@ -361,6 +361,8 @@ class Application extends Adw.Application { + 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._settings.create_action('url-preview'); ++ this.add_action(action); + + action = this.lookup_action('user-list'); + action.connect('notify::enabled', () => { +diff --git a/src/chatView.js b/src/chatView.js +index fcb373687327..de13a80e2e44 100644 +--- a/src/chatView.js ++++ b/src/chatView.js +@@ -1305,7 +1305,8 @@ class ChatView extends Gtk.ScrolledWindow { + this._insertWithTags(iter, + url.name, tags.concat(this._lookupTag('url'), tag)); + +- if (GLib.uri_parse_scheme(url.url).startsWith('http')) ++ if (this._app._settings.get_boolean('url-preview') && ++ GLib.uri_parse_scheme(url.url).startsWith('http')) + previews.push(new URLPreview({uri: url.url})); + + pos = url.pos + url.name.length; diff --git a/pkgs/by-name/po/polari/check_dbus_unconditionally.patch b/pkgs/by-name/po/polari/check_dbus_unconditionally.patch new file mode 100644 index 0000000000000..0b6fac9c722aa --- /dev/null +++ b/pkgs/by-name/po/polari/check_dbus_unconditionally.patch @@ -0,0 +1,14 @@ +diff --git a/src/application.js b/src/application.js +index 6a29764..a14cd1a 100644 +--- a/src/application.js ++++ b/src/application.js +@@ -222,9 +222,6 @@ class Application extends Adw.Application { + } + + vfunc_dbus_register(conn, _path) { +- if (!Utils.isFlatpakSandbox()) +- return true; +- + GLib.setenv('IDLE_PERSIST', '1', false); + this._ensureService(conn, + Tp.ACCOUNT_MANAGER_BUS_NAME, diff --git a/pkgs/by-name/po/polari/fix_sparql_database_race.patch b/pkgs/by-name/po/polari/fix_sparql_database_race.patch new file mode 100644 index 0000000000000..7c316bf7ea9f3 --- /dev/null +++ b/pkgs/by-name/po/polari/fix_sparql_database_race.patch @@ -0,0 +1,63 @@ +diff --git a/src/utils.js b/src/utils.js +index 3a9863d..6314f39 100644 +--- a/src/utils.js ++++ b/src/utils.js +@@ -547,29 +547,40 @@ export function formatDateTime(date) { + } + + /** +- * @returns {Tracker.SparqlConnection} ++ * @returns {Promise} + */ + export async function getSparqlStore() { +- await _sparqlStorePromise; ++ if (_sparqlStorePromise) ++ return _sparqlStorePromise; + +- if (_sparqlStore) +- return _sparqlStore; +- +- const {promise, resolve} = Promise.withResolvers(); ++ const { promise, resolve, reject } = Promise.withResolvers(); + _sparqlStorePromise = promise; + +- const path = GLib.build_filenamev( +- [GLib.get_user_data_dir(), 'polari', 'chatlogs.v1']); +- const dir = Gio.File.new_for_path(path); +- const ontology = Gio.File.new_for_uri( +- 'resource:///org/gnome/Polari/ontologies/'); +- +- _sparqlStore = await Tracker.SparqlConnection.new_async( +- Tracker.SparqlConnectionFlags.FTS_ENABLE_STEMMER | +- Tracker.SparqlConnectionFlags.FTS_ENABLE_UNACCENT, +- dir, ontology, null); ++ (async () => { ++ try { ++ if (_sparqlStore) { ++ resolve(_sparqlStore); ++ return; ++ } + +- resolve(); ++ const path = GLib.build_filenamev( ++ [GLib.get_user_data_dir(), 'polari', 'chatlogs.v1']); ++ const dir = Gio.File.new_for_path(path); ++ const ontology = Gio.File.new_for_uri( ++ 'resource:///org/gnome/Polari/ontologies/'); ++ ++ const store = await Tracker.SparqlConnection.new_async( ++ Tracker.SparqlConnectionFlags.FTS_ENABLE_STEMMER | ++ Tracker.SparqlConnectionFlags.FTS_ENABLE_UNACCENT, ++ dir, ontology, null ++ ); ++ ++ _sparqlStore = store; ++ resolve(store); ++ } catch (e) { ++ reject(e); ++ } ++ })(); + +- return _sparqlStore; ++ return promise; + } diff --git a/pkgs/by-name/po/polari/package.nix b/pkgs/by-name/po/polari/package.nix index 70ee17118cf97..9f9fc64569e54 100644 --- a/pkgs/by-name/po/polari/package.nix +++ b/pkgs/by-name/po/polari/package.nix @@ -3,14 +3,14 @@ lib, itstool, fetchurl, - fetchpatch, gdk-pixbuf, telepathy-glib, + telepathy-idle, + telepathy-mission-control, gjs, meson, ninja, gettext, - telepathy-idle, libxml2, desktop-file-utils, pkg-config, @@ -19,6 +19,7 @@ libadwaita, gtk3, glib, + glib-networking, libsecret, libsoup_3, webkitgtk_4_1, @@ -29,13 +30,13 @@ gsettings-desktop-schemas, }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "polari"; - version = "46.0"; + version = "49.0"; src = fetchurl { - url = "mirror://gnome/sources/polari/${lib.versions.major version}/polari-${version}.tar.xz"; - hash = "sha256-0rFwnjeRiSlPU9TvFfA/i8u76MUvD0FeYvfV8Aw2CjE="; + url = "mirror://gnome/sources/polari/${lib.versions.major finalAttrs.version}/polari-${finalAttrs.version}.tar.xz"; + hash = "sha256-UmJv3jkJkhrFhsxMwQ8w8SOq9hVaF374hhyg5V1t6FA="; }; patches = [ @@ -44,15 +45,32 @@ stdenv.mkDerivation rec { # Let’s change the code to run the script directly by making it executable and having gjs in shebang. ./make-thumbnailer-wrappable.patch - # Switch to girepository-2.0 - # https://gitlab.gnome.org/GNOME/polari/-/merge_requests/356 - (fetchpatch { - url = "https://gitlab.gnome.org/GNOME/polari/-/commit/d7946c7fe39f112cd3f751bb95b170446022980d.patch"; - hash = "sha256-naRzZ5Iple11HJ+d8DL9oJy3C4VKLkz+FdMuhO7sc7k="; - }) + # fix TypeError: (intermediate value).get_current_event_device is not a function + # https://gitlab.gnome.org/GNOME/polari/-/merge_requests/320 + ./0001-joinDialog-Fix-detecting-pointer-devices.patch + + # https://gitlab.gnome.org/GNOME/polari/-/merge_requests/329 + ./0002-mainWindow-Disconnect-event-handler-on-destroy.patch + + # https://gitlab.gnome.org/GNOME/polari/-/merge_requests/330 + ./0003-Add-option-to-disable-URL-preview-feature.patch + + # This also helps us to distribute the app as a single package + # without enabling telepathy-{idle,mission-control} services + ./check_dbus_unconditionally.patch + + # This fixes Tracker.SparqlError: table Resource already exists + # and chat history spinning forever on second launch. + # Fixes the race condition by ensuring all callers wait on the + # same shared initialization promise + ./fix_sparql_database_race.patch ]; - propagatedUserEnvPkgs = [ telepathy-idle ]; + postPatch = '' + substituteInPlace src/application.js \ + --replace-fail "/app/libexec/mission-control-5" "${lib.getLib telepathy-mission-control}/libexec/mission-control-5" \ + --replace-fail "/app/libexec/telepathy-idle" "${telepathy-idle}/libexec/telepathy-idle" + ''; nativeBuildInputs = [ meson @@ -72,6 +90,7 @@ stdenv.mkDerivation rec { libadwaita gtk3 # for thumbnailer glib + glib-networking gsettings-desktop-schemas telepathy-glib gjs @@ -90,15 +109,15 @@ stdenv.mkDerivation rec { updateScript = gnome.updateScript { packageName = "polari"; }; }; - meta = with lib; { + meta = { homepage = "https://apps.gnome.org/Polari/"; description = "IRC chat client designed to integrate with the GNOME desktop"; mainProgram = "polari"; teams = [ - teams.gnome - teams.gnome-circle + lib.teams.gnome + lib.teams.gnome-circle ]; - license = licenses.gpl2Plus; - platforms = platforms.linux; + license = lib.licenses.gpl2Plus; + platforms = lib.platforms.linux; }; -} +})