diff options
author | Carl Kittelberger | 2022-04-17 09:48:44 +0200 |
---|---|---|
committer | Carl Kittelberger | 2022-04-17 09:48:44 +0200 |
commit | a68794ec33e9b31c11b9e2fa9f79a684c19f64d7 (patch) | |
tree | 3b81bd24a50e88fb680a0b4ecabda0ee5f1d74ab | |
download | aur-a68794ec33e9b31c11b9e2fa9f79a684c19f64d7.tar.gz |
Initial commit.
-rw-r--r-- | .SRCINFO | 31 | ||||
-rw-r--r-- | 0001-Use-QFileDialog-for-selecting-directories.patch | 69 | ||||
-rw-r--r-- | 0002-Show-only-local-files.patch | 49 | ||||
-rw-r--r-- | 0003-fuse-fileopen-urls-on-demand.patch | 256 | ||||
-rw-r--r-- | PKGBUILD | 54 |
5 files changed, 459 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..d345c2a7322e --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,31 @@ +pkgbase = xdg-desktop-portal-kde-steamos-kiofusefix + pkgdesc = A backend implementation for xdg-desktop-portal using Qt/KF5 (Version as used on SteamOS but fixed to work with remote files). + pkgver = 5.23.5 + pkgrel = 1 + url = https://kde.org/plasma-desktop/ + arch = x86_64 + groups = plasma + license = LGPL + makedepends = extra-cmake-modules + makedepends = plasma-wayland-protocols + depends = kirigami2 + depends = plasma-framework + provides = xdg-desktop-portal-kde + provides = xdg-desktop-portal-impl + conflicts = xdg-desktop-portal-kde + source = https://download.kde.org/stable/plasma/5.23.5/xdg-desktop-portal-kde-5.23.5.tar.xz + source = https://download.kde.org/stable/plasma/5.23.5/xdg-desktop-portal-kde-5.23.5.tar.xz.sig + source = 0001-Use-QFileDialog-for-selecting-directories.patch + source = 0002-Show-only-local-files.patch + source = 0003-fuse-fileopen-urls-on-demand.patch + validpgpkeys = E0A3EB202F8E57528E13E72FD7574483BB57B18D + validpgpkeys = 0AAC775BB6437A8D9AF7A3ACFE0784117FBCE11D + validpgpkeys = D07BD8662C56CB291B316EB2F5675605C74E02CF + validpgpkeys = 1FA881591C26B276D7A5518EEAAF29B42A678C20 + sha256sums = eb61f3bb1d62e50f01a81b632476bfa689607a066af7dabdddb8dbdce4754327 + sha256sums = SKIP + sha256sums = de6abeb05c6620c61c0b6cdd01daf3a37a8ebcb9452bff5522eb4843dbcc2f20 + sha256sums = 09c33c2f14f0592bd6582390f1240aac4d0dabb41d76f9f4ed4943556d45352a + sha256sums = 97b14f9d7cb19839d4b612c6977f42e44b0ec3f2b07f5fccefaf0aa8fa92d79d + +pkgname = xdg-desktop-portal-kde-steamos-kiofusefix diff --git a/0001-Use-QFileDialog-for-selecting-directories.patch b/0001-Use-QFileDialog-for-selecting-directories.patch new file mode 100644 index 000000000000..6910dcff1b56 --- /dev/null +++ b/0001-Use-QFileDialog-for-selecting-directories.patch @@ -0,0 +1,69 @@ +From eb684e42e768e4c57dbf81abf51f7597df164814 Mon Sep 17 00:00:00 2001 +From: Fabian Vogt <fabian@ritter-vogt.de> +Date: Mon, 17 Jan 2022 22:05:09 +0100 +Subject: [PATCH 1/3] Use QFileDialog for selecting directories + +KFileWidget is not as good at selecting directories as KDirSelectDialog +from plasma-integration. On top of that, directory selection appears to be +entirely broken currently. + +Use KDirSelectDialog through QFileDialog if possible. + +BUG: 437505 +--- + src/filechooser.cpp | 32 ++++++++++++++++++++++++++++++++ + 1 file changed, 32 insertions(+) + +diff --git a/src/filechooser.cpp b/src/filechooser.cpp +index 4302c24..97a48fc 100644 +--- a/src/filechooser.cpp ++++ b/src/filechooser.cpp +@@ -13,6 +13,7 @@ + #include <QDBusMetaType> + #include <QDialogButtonBox> + #include <QFile> ++#include <QFileDialog> + #include <QGridLayout> + #include <QLabel> + #include <QLoggingCategory> +@@ -256,6 +257,37 @@ uint FileChooserPortal::OpenFile(const QDBusObjectPath &handle, + return retCode; + } + ++ // Use QFileDialog for most directory requests to utilize ++ // plasma-integration's KDirSelectDialog ++ if (directory && !options.contains(QStringLiteral("choices"))) { ++ QFileDialog dirDialog; ++ dirDialog.setWindowTitle(title); ++ dirDialog.setModal(modalDialog); ++ dirDialog.setFileMode(QFileDialog::Directory); ++ dirDialog.setOptions(QFileDialog::ShowDirsOnly); ++ dirDialog.setSupportedSchemes(QStringList{QStringLiteral("file")}); ++ if (!acceptLabel.isEmpty()) { ++ dirDialog.setLabelText(QFileDialog::Accept, acceptLabel); ++ } ++ ++ dirDialog.winId(); // Trigger window creation ++ Utils::setParentWindow(&dirDialog, parent_window); ++ ++ if (dirDialog.exec() != QDialog::Accepted) { ++ return 1; ++ } ++ ++ const auto urls = dirDialog.selectedUrls(); ++ if (urls.empty()) { ++ return 2; ++ } ++ ++ results.insert(QStringLiteral("uris"), QUrl::toStringList(urls)); ++ results.insert(QStringLiteral("writable"), true); ++ ++ return 0; ++ } ++ + // for handling of options - choices + QScopedPointer<QWidget> optionsWidget; + // to store IDs for choices along with corresponding comboboxes/checkboxes +-- +2.35.0 + diff --git a/0002-Show-only-local-files.patch b/0002-Show-only-local-files.patch new file mode 100644 index 000000000000..834c013e99a7 --- /dev/null +++ b/0002-Show-only-local-files.patch @@ -0,0 +1,49 @@ +From a42107c2ca206fadb32496057089c240cfc0d160 Mon Sep 17 00:00:00 2001 +From: Fabian Vogt <fabian@ritter-vogt.de> +Date: Tue, 18 Jan 2022 09:42:12 +0100 +Subject: [PATCH 2/3] Show only local files + +Call setSupportedSchemes("file") to allow only local files to be selected. +That way QUrl::toStringList can be used as well. +--- + src/filechooser.cpp | 13 ++++--------- + 1 file changed, 4 insertions(+), 9 deletions(-) + +diff --git a/src/filechooser.cpp b/src/filechooser.cpp +index 97a48fc..d141212 100644 +--- a/src/filechooser.cpp ++++ b/src/filechooser.cpp +@@ -305,6 +305,7 @@ uint FileChooserPortal::OpenFile(const QDBusObjectPath &handle, + fileDialog->setModal(modalDialog); + KFile::Mode mode = directory ? KFile::Mode::Directory : multipleFiles ? KFile::Mode::Files : KFile::Mode::File; + fileDialog->m_fileWidget->setMode(mode | KFile::Mode::ExistingOnly); ++ fileDialog->m_fileWidget->setSupportedSchemes(QStringList{QStringLiteral("file")}); + fileDialog->m_fileWidget->okButton()->setText(!acceptLabel.isEmpty() ? acceptLabel : i18n("Open")); + + bool bMimeFilters = false; +@@ -320,19 +321,13 @@ uint FileChooserPortal::OpenFile(const QDBusObjectPath &handle, + } + + if (fileDialog->exec() == QDialog::Accepted) { +- QStringList files; +- const auto selectedFiles = fileDialog->m_fileWidget->selectedFiles(); +- for (const QString &filename : selectedFiles) { +- QUrl url = QUrl::fromLocalFile(filename); +- files << url.toDisplayString(); +- } +- +- if (files.isEmpty()) { ++ const auto urls = fileDialog->m_fileWidget->selectedUrls(); ++ if (urls.isEmpty()) { + qCDebug(XdgDesktopPortalKdeFileChooser) << "Failed to open file: no local file selected"; + return 2; + } + +- results.insert(QStringLiteral("uris"), files); ++ results.insert(QStringLiteral("uris"), QUrl::toStringList(urls)); + results.insert(QStringLiteral("writable"), true); + + if (optionsWidget) { +-- +2.35.0 + diff --git a/0003-fuse-fileopen-urls-on-demand.patch b/0003-fuse-fileopen-urls-on-demand.patch new file mode 100644 index 000000000000..3eb4bbfadfbc --- /dev/null +++ b/0003-fuse-fileopen-urls-on-demand.patch @@ -0,0 +1,256 @@ +From b283b4dd2058c26eb26205d666ea5a1561bce87c Mon Sep 17 00:00:00 2001 +From: Harald Sitter <sitter@kde.org> +Date: Mon, 28 Mar 2022 12:37:27 +0200 +Subject: [PATCH 3/3] fuse fileopen urls on-demand + +instead of restricting ourselves to file urls we now accept any url +(within the limitations from kprotocols ultimately) but then fuse them +into the local file system using kio-fuse. this enables us to pass smb: +and sftp: and whathaveyou urls into the sandbox without the sandbox +having to worry about anything +--- + CMakeLists.txt | 8 ++++- + cmake/FindKIOFuse.cmake | 18 ++++++++++ + data/org.kde.KIOFuse.VFS.xml | 17 +++++++++ + src/CMakeLists.txt | 4 ++- + src/filechooser.cpp | 69 +++++++++++++++++++++++++++++++----- + 5 files changed, 106 insertions(+), 10 deletions(-) + create mode 100644 cmake/FindKIOFuse.cmake + create mode 100644 data/org.kde.KIOFuse.VFS.xml + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 59eb4b7..b4c6071 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -14,7 +14,7 @@ set(KDE_COMPILERSETTINGS_LEVEL "5.82") + ################# set KDE specific information ################# + + find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) +-set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") ++set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + + include(KDEInstallDirs) + include(KDECMakeSettings) +@@ -50,6 +50,12 @@ find_package(Wayland 1.15 REQUIRED COMPONENTS Client) + find_package(PlasmaWaylandProtocols REQUIRED) + find_package(QtWaylandScanner REQUIRED) + ++find_package(KIOFuse) ++set_package_properties(KIOFuse PROPERTIES ++ URL https://commits.kde.org/system/kio-fuse ++ TYPE RUNTIME ++ PURPOSE "Automatic mounting of remote URLs") ++ + add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050c00) + add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054200) + +diff --git a/cmake/FindKIOFuse.cmake b/cmake/FindKIOFuse.cmake +new file mode 100644 +index 0000000..ef0e059 +--- /dev/null ++++ b/cmake/FindKIOFuse.cmake +@@ -0,0 +1,18 @@ ++# SPDX-License-Identifier: BSD-2-Clause ++# SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org> ++ ++execute_process( ++ COMMAND dbus-send --session --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListActivatableNames ++ OUTPUT_VARIABLE _kiofuseOut) ++ ++set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) ++if("${_kiofuseOut}" MATCHES "\"org.kde.KIOFuse\"") ++ set(${CMAKE_FIND_PACKAGE_NAME}_FOUND TRUE) ++endif() ++ ++include(FindPackageHandleStandardArgs) ++find_package_handle_standard_args(${CMAKE_FIND_PACKAGE_NAME} ++ FOUND_VAR ${CMAKE_FIND_PACKAGE_NAME}_FOUND ++ REQUIRED_VARS ${CMAKE_FIND_PACKAGE_NAME}_FOUND ++ REASON_FAILURE_MESSAGE "Could not find DBus service org.kde.KIOFuse in org.freedesktop.DBus.ListActivatableNames" ++) +diff --git a/data/org.kde.KIOFuse.VFS.xml b/data/org.kde.KIOFuse.VFS.xml +new file mode 100644 +index 0000000..30d7859 +--- /dev/null ++++ b/data/org.kde.KIOFuse.VFS.xml +@@ -0,0 +1,17 @@ ++<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> ++<!-- ++ SPDX-License-Identifier: CC0-1.0 ++ SPDX-FileCopyrightText: none ++--> ++<node> ++ <interface name="org.kde.KIOFuse.VFS"> ++ <method name="remoteUrl"> ++ <arg type="s" direction="out"/> ++ <arg name="localPath" type="s" direction="in"/> ++ </method> ++ <method name="mountUrl"> ++ <arg name="remoteUrl" type="s" direction="in"/> ++ <arg type="s" direction="out"/> ++ </method> ++ </interface> ++</node> +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index cba078b..115d961 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -50,9 +50,11 @@ ecm_add_qtwayland_client_protocol(xdg_desktop_portal_kde_SRCS + ) + + set_source_files_properties(../data/org.freedesktop.Accounts.User.xml PROPERTIES NO_NAMESPACE TRUE) +- + qt_add_dbus_interface(xdg_desktop_portal_kde_SRCS ../data/org.freedesktop.Accounts.User.xml user_interface) + ++set_source_files_properties(../data/org.kde.KIOFuse.VFS.xml PROPERTIES NO_NAMESPACE TRUE) ++qt_add_dbus_interface(xdg_desktop_portal_kde_SRCS ../data/org.kde.KIOFuse.VFS.xml fuse_interface) ++ + add_executable(xdg-desktop-portal-kde ${xdg_desktop_portal_kde_SRCS}) + + target_link_libraries(xdg-desktop-portal-kde +diff --git a/src/filechooser.cpp b/src/filechooser.cpp +index d141212..4b3bb9b 100644 +--- a/src/filechooser.cpp ++++ b/src/filechooser.cpp +@@ -4,6 +4,7 @@ + * SPDX-License-Identifier: LGPL-2.0-or-later + * + * SPDX-FileCopyrightText: 2016-2018 Jan Grulich <jgrulich@redhat.com> ++ * SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org> + */ + + #include "filechooser.h" +@@ -14,6 +15,7 @@ + #include <QDialogButtonBox> + #include <QFile> + #include <QFileDialog> ++#include <QFileInfo> + #include <QGridLayout> + #include <QLabel> + #include <QLoggingCategory> +@@ -30,6 +32,7 @@ + #include <KSharedConfig> + #include <KWindowConfig> + ++#include "fuse_interface.h" + #include <mobilefiledialog.h> + + Q_LOGGING_CATEGORY(XdgDesktopPortalKdeFileChooser, "xdp-kde-file-chooser") +@@ -131,6 +134,13 @@ const QDBusArgument &operator>>(const QDBusArgument &arg, FileChooserPortal::Opt + return arg; + } + ++static bool isKIOFuseAvailable() ++{ ++ static bool available = ++ QDBusConnection::sessionBus().interface() && QDBusConnection::sessionBus().interface()->activatableServiceNames().value().contains("org.kde.KIOFuse"); ++ return available; ++} ++ + FileDialog::FileDialog(QDialog *parent, Qt::WindowFlags flags) + : QDialog(parent, flags) + , m_fileWidget(new KFileWidget(QUrl(), this)) +@@ -181,6 +191,47 @@ FileChooserPortal::~FileChooserPortal() + { + } + ++static QStringList fuseRedirect(QList<QUrl> urls) ++{ ++ qCDebug(XdgDesktopPortalKdeFileChooser) << "mounting urls with fuse" << urls; ++ ++ OrgKdeKIOFuseVFSInterface kiofuse_iface(QStringLiteral("org.kde.KIOFuse"), QStringLiteral("/org/kde/KIOFuse"), QDBusConnection::sessionBus()); ++ struct MountRequest { ++ QDBusPendingReply<QString> reply; ++ int urlIndex; ++ QString basename; ++ }; ++ QVector<MountRequest> requests; ++ requests.reserve(urls.count()); ++ for (int i = 0; i < urls.count(); ++i) { ++ QUrl url = urls.at(i); ++ if (!url.isLocalFile()) { ++ const QString path(url.path()); ++ const int slashes = path.count(QLatin1Char('/')); ++ QString basename; ++ if (slashes > 1) { ++ url.setPath(path.section(QLatin1Char('/'), 0, slashes - 1)); ++ basename = path.section(QLatin1Char('/'), slashes, slashes); ++ } ++ requests.push_back({kiofuse_iface.mountUrl(url.toString()), i, basename}); ++ } ++ } ++ ++ for (auto &request : requests) { ++ request.reply.waitForFinished(); ++ if (request.reply.isError()) { ++ qWarning() << "FUSE request failed:" << request.reply.error(); ++ continue; ++ } ++ ++ urls[request.urlIndex] = QUrl::fromLocalFile(request.reply.value() + QLatin1Char('/') + request.basename); ++ }; ++ ++ qCDebug(XdgDesktopPortalKdeFileChooser) << "mounted urls with fuse, maybe" << urls; ++ ++ return QUrl::toStringList(urls); ++} ++ + uint FileChooserPortal::OpenFile(const QDBusObjectPath &handle, + const QString &app_id, + const QString &parent_window, +@@ -265,7 +316,9 @@ uint FileChooserPortal::OpenFile(const QDBusObjectPath &handle, + dirDialog.setModal(modalDialog); + dirDialog.setFileMode(QFileDialog::Directory); + dirDialog.setOptions(QFileDialog::ShowDirsOnly); +- dirDialog.setSupportedSchemes(QStringList{QStringLiteral("file")}); ++ if (!isKIOFuseAvailable()) { ++ dirDialog.setSupportedSchemes(QStringList{QStringLiteral("file")}); ++ } + if (!acceptLabel.isEmpty()) { + dirDialog.setLabelText(QFileDialog::Accept, acceptLabel); + } +@@ -282,7 +335,7 @@ uint FileChooserPortal::OpenFile(const QDBusObjectPath &handle, + return 2; + } + +- results.insert(QStringLiteral("uris"), QUrl::toStringList(urls)); ++ results.insert(QStringLiteral("uris"), fuseRedirect(urls)); + results.insert(QStringLiteral("writable"), true); + + return 0; +@@ -305,7 +358,9 @@ uint FileChooserPortal::OpenFile(const QDBusObjectPath &handle, + fileDialog->setModal(modalDialog); + KFile::Mode mode = directory ? KFile::Mode::Directory : multipleFiles ? KFile::Mode::Files : KFile::Mode::File; + fileDialog->m_fileWidget->setMode(mode | KFile::Mode::ExistingOnly); +- fileDialog->m_fileWidget->setSupportedSchemes(QStringList{QStringLiteral("file")}); ++ if (!isKIOFuseAvailable()) { ++ fileDialog->m_fileWidget->setSupportedSchemes(QStringList{QStringLiteral("file")}); ++ } + fileDialog->m_fileWidget->okButton()->setText(!acceptLabel.isEmpty() ? acceptLabel : i18n("Open")); + + bool bMimeFilters = false; +@@ -327,7 +382,7 @@ uint FileChooserPortal::OpenFile(const QDBusObjectPath &handle, + return 2; + } + +- results.insert(QStringLiteral("uris"), QUrl::toStringList(urls)); ++ results.insert(QStringLiteral("uris"), fuseRedirect(urls)); + results.insert(QStringLiteral("writable"), true); + + if (optionsWidget) { +@@ -486,10 +541,8 @@ uint FileChooserPortal::SaveFile(const QDBusObjectPath &handle, + } + + if (fileDialog->exec() == QDialog::Accepted) { +- QStringList files; +- QUrl url = QUrl::fromLocalFile(fileDialog->m_fileWidget->selectedFile()); +- files << url.toDisplayString(); +- results.insert(QStringLiteral("uris"), files); ++ const auto urls = fileDialog->m_fileWidget->selectedUrls(); ++ results.insert(QStringLiteral("uris"), fuseRedirect(urls)); + + if (optionsWidget) { + QVariant choices = EvaluateSelectedChoices(checkboxes, comboboxes); +-- +2.35.0 + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..cc9b9678653b --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,54 @@ +# Maintainer: Carl Kittelberger <icedream@icedream.pw> +# Derived from https://github.com/archlinux/svntogit-packages/blob/09541443aa24fe2ee143cfee51c3a03642633578/trunk/PKGBUILD + +origpkgname=xdg-desktop-portal-kde +origpkgversion=5.23.5 + +pkgname="${origpkgname}-steamos-kiofusefix" +pkgver="${origpkgversion}" +pkgrel=1 +pkgdesc='A backend implementation for xdg-desktop-portal using Qt/KF5 (Version as used on SteamOS but fixed to work with remote files).' +arch=(x86_64) +url='https://kde.org/plasma-desktop/' +license=(LGPL) +depends=(kirigami2 plasma-framework) +makedepends=(extra-cmake-modules plasma-wayland-protocols) +conflicts=("$origpkgname") +provides=("$origpkgname" xdg-desktop-portal-impl) +groups=(plasma) +source=(https://download.kde.org/stable/plasma/$pkgver/${origpkgname}-$pkgver.tar.xz{,.sig} + # https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/commit/551c583bd883056d28895597ce8d4571cd6a6f81 + 0001-Use-QFileDialog-for-selecting-directories.patch + # https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/commit/caaa100b89924d0fdcd3e8352e43f6137d06174b + 0002-Show-only-local-files.patch + # https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/commit/bbfa7471d26c84157e6a022b83e202a8de04fee7 + 0003-fuse-fileopen-urls-on-demand.patch) +sha256sums=('eb61f3bb1d62e50f01a81b632476bfa689607a066af7dabdddb8dbdce4754327' + 'SKIP' + 'de6abeb05c6620c61c0b6cdd01daf3a37a8ebcb9452bff5522eb4843dbcc2f20' + '09c33c2f14f0592bd6582390f1240aac4d0dabb41d76f9f4ed4943556d45352a' + '97b14f9d7cb19839d4b612c6977f42e44b0ec3f2b07f5fccefaf0aa8fa92d79d') +validpgpkeys=('E0A3EB202F8E57528E13E72FD7574483BB57B18D' # Jonathan Esk-Riddell <jr@jriddell.org> + '0AAC775BB6437A8D9AF7A3ACFE0784117FBCE11D' # Bhushan Shah <bshah@kde.org> + 'D07BD8662C56CB291B316EB2F5675605C74E02CF' # David Edmundson <davidedmundson@kde.org> + '1FA881591C26B276D7A5518EEAAF29B42A678C20') # Marco Martin <notmart@gmail.com> + +prepare() { + cd "$origpkgname-$pkgver" + + for patch in "$srcdir"/0*.patch + do + patch -p1 -i "$patch" + done +} + +build() { + cmake -B build -S $origpkgname-$pkgver \ + -DCMAKE_INSTALL_LIBEXECDIR=lib \ + -DBUILD_TESTING=OFF + cmake --build build +} + +package() { + DESTDIR="$pkgdir" cmake --install build +} |