summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2018-01-22 17:06:00 +0100
committerMilian Wolff <milian.wolff@kdab.com>2018-01-22 17:12:42 +0100
commit81e4d45342d4698acb3ccc1dcd6bc03e65ffe690 (patch)
tree8829106724ff53cfe606a9f2d76f9b2b436e8189
parentcheck for boost/process/child.hpp in configure.ac if --enable-gtk3-kde5 (diff)
downloadcore-feature/gtk3_kde5.tar.gz
core-feature/gtk3_kde5.zip
Support opening of (some) remote URLs through the KDE file dialog feature/gtk3_kde5
LO already supports http, https, webdav and webdavs through the WebDAVContentProvider. Ftp is supported via FTPContentProvider and then finally we have the GIOContentProvider that can potentially support SMB, if the dependencies for that are met. We now configure the KDE file dialog to allow these remote protocols. Note that this filtering depends on https://phabricator.kde.org/D10024 and https://phabricator.kde.org/D10025 to have any effect. Then we rewrite the URLs we receive from KIO to a format that is supported by LO. Most notably, we prepend `vnd.sun.star.` to the webdav URL schemes, such that they get picked up by the WebDAVContentProvider. Then finally, we clear the username from the smb:// URLs we get from KIO, as that prevents GIO from opening them. In all cases, the user will get prompted a second time for the credentials required to access the remote resource. This is unfortunate, but better than nothing. In the future, we may solve this issue through either a separate KIO UCP or by getting support for the FDO Secret Service specification in KWallet. Change-Id: I91df28434b115639c2698968e2a672b3320bf8e2
-rw-r--r--vcl/unx/gtk3_kde5/kde5_filepicker.cxx45
-rw-r--r--vcl/unx/gtk3_kde5/kde5_filepicker.hxx3
-rw-r--r--vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx27
3 files changed, 31 insertions, 44 deletions
diff --git a/vcl/unx/gtk3_kde5/kde5_filepicker.cxx b/vcl/unx/gtk3_kde5/kde5_filepicker.cxx
index db7d04cf7d4a..456ba645808b 100644
--- a/vcl/unx/gtk3_kde5/kde5_filepicker.cxx
+++ b/vcl/unx/gtk3_kde5/kde5_filepicker.cxx
@@ -32,17 +32,6 @@
#include <QtWidgets/QWidget>
#include <QtWidgets/QApplication>
-// The dialog should check whether LO also supports the protocol
-// provided by KIO, and KFileWidget::dirOperator() is only 4.3+ .
-// Moreover it's only in this somewhat internal KFileWidget class,
-// which may not necessarily be what QFileDialog::fileWidget() returns,
-// but that's hopefully not a problem in practice.
-//#if Qt_VERSION_MAJOR == 4 && Qt_VERSION_MINOR >= 2
-//#define ALLOW_REMOTE_URLS 1
-//#else
-#define ALLOW_REMOTE_URLS 0
-//#endif
-
// KDE5FilePicker
KDE5FilePicker::KDE5FilePicker(QObject* parent)
@@ -53,16 +42,15 @@ KDE5FilePicker::KDE5FilePicker(QObject* parent)
, _winId(0)
, allowRemoteUrls(false)
{
-#if ALLOW_REMOTE_URLS
- if (KFileWidget* fileWidget = dynamic_cast<KFileWidget*>(_dialog->fileWidget()))
- {
- allowRemoteUrls = true;
- // Use finishedLoading signal rather than e.g. urlEntered, because if there's a problem
- // such as the URL being mistyped, there's no way to prevent two message boxes about it,
- // one from us and one from Qt code.
- connect(fileWidget->dirOperator(), SIGNAL(finishedLoading()), SLOT(checkProtocol()));
- }
-#endif
+ _dialog->setSupportedSchemes({
+ QStringLiteral("file"),
+ QStringLiteral("ftp"),
+ QStringLiteral("http"),
+ QStringLiteral("https"),
+ QStringLiteral("webdav"),
+ QStringLiteral("webdavs"),
+ QStringLiteral("smb"),
+ });
setMultiSelectionMode(false);
@@ -245,21 +233,6 @@ void SAL_CALL KDE5FilePicker::initialize(bool saveDialog)
}
}
-void KDE5FilePicker::checkProtocol()
-{
- // There's no libreoffice.desktop :(, so find a matching one.
- /*
- KService::List services = KServiceTypeTrader::self()->query( "Application", "Exec =~ 'libreoffice %U'" );
- QStringList protocols;
- if( !services.isEmpty())
- protocols = services[ 0 ]->property( "X-Qt-Protocols" ).toStringList();
- if( protocols.isEmpty()) // incorrect (developer?) installation ?
- protocols << "file" << "http";
- if( !protocols.contains( _dialog->baseUrl().protocol()) && !protocols.contains( "KIO" ))
- KMessageBox::error( _dialog, KIO::buildErrorString( KIO::ERR_UNSUPPORTED_PROTOCOL, _dialog->baseUrl().protocol()));
-*/
-}
-
void KDE5FilePicker::setWinId(sal_uIntPtr winId) { _winId = winId; }
bool KDE5FilePicker::eventFilter(QObject* o, QEvent* e)
diff --git a/vcl/unx/gtk3_kde5/kde5_filepicker.hxx b/vcl/unx/gtk3_kde5/kde5_filepicker.hxx
index 8b364832c6af..25c7454f86b5 100644
--- a/vcl/unx/gtk3_kde5/kde5_filepicker.hxx
+++ b/vcl/unx/gtk3_kde5/kde5_filepicker.hxx
@@ -102,9 +102,6 @@ private:
protected:
bool eventFilter(QObject* watched, QEvent* event) override;
-private Q_SLOTS:
- void checkProtocol();
-
Q_SIGNALS:
void filterChanged();
void selectionChanged();
diff --git a/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx b/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx
index 9911219d010a..1ae6289677d6 100644
--- a/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx
+++ b/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx
@@ -44,12 +44,12 @@ void sendIpcArg(std::ostream& stream, const QString& string)
sendIpcStringArg(stream, utf8.size(), utf8.data());
}
-void sendIpcArg(std::ostream& stream, const QList<QUrl>& urls)
+void sendIpcArg(std::ostream& stream, const QStringList& list)
{
- stream << static_cast<uint32_t>(urls.size()) << ' ';
- for (const auto& url : urls)
+ stream << static_cast<uint32_t>(list.size()) << ' ';
+ for (const auto& entry : list)
{
- sendIpcArg(stream, url.toString());
+ sendIpcArg(stream, entry);
}
}
@@ -126,7 +126,24 @@ void FilePickerIpc::readCommand()
}
case Commands::GetSelectedFiles:
{
- sendIpcArgs(std::cout, messageId, m_filePicker->getSelectedFiles());
+ QStringList files;
+ for (auto url : m_filePicker->getSelectedFiles())
+ {
+ if (url.scheme() == QLatin1String("webdav")
+ || url.scheme() == QLatin1String("webdavs"))
+ {
+ // translate webdav and webdavs URLs into a format supported by LO
+ url.setScheme(QLatin1String("vnd.sun.star.") + url.scheme());
+ }
+ else if (url.scheme() == QLatin1String("smb"))
+ {
+ // clear the user name - the GIO backend does not support this apparently
+ // when no username is available, it will ask for the password
+ url.setUserName({});
+ }
+ files << url.toString();
+ }
+ sendIpcArgs(std::cout, messageId, files);
return;
}
case Commands::AppendFilter: