summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-02-04 17:38:29 +0100
committerStephan Bergmann <sbergman@redhat.com>2019-02-05 19:55:04 +0100
commit46c645bf4e9909f5296e75028f1f5434e83942d2 (patch)
tree9312feef8f02fcbac1ca9b6726d273817e9c59a8 /ucb
parent48d757ed1ae69636c7eaba83d1938666d290c5df (diff)
Move dubious file: -> smb: conversion from INetURLObject to file UCP
The Linux-only conversion of file URLs with a non-empty (other than "localhost") authority to smb URLs had been added in 2010 with 0b9ef81ba5ff08d85f21275222458a5b9b9e484c "tools-urlobj-smb-scheme-patch.diff: migrated" (applying a Go-oo patch?) but giving no rationale beyond "process relative SMB paths (in hyperlinks) correctly". That makes it hard to tell whether that patch is (still) actively useful for anything, or was just a misguided hack from the beginning: * Why make this Linux only? What about other non-Windows OSs? (On Windows, such URLs can be resolved as UNC pathnames.) If the reason for Linux-only was that it is the only OS where LO can handle smb URLs via GIO, why not make it conditional on ENABLE_GIO? * Why map to smb? There are various remote file access protocols. Hardcoding smb looks arbitrary here. Anyway, INetURLObject is arguably at a wrong level for such a patch. To not drop the hack wholesale, reimplement it in the file UCP, forwarding to a potential other UCP that can handle smb URLs any file://<host>/... URLs (rewritten as smb URLs) that the file UCP cannot handle itself. (file://localhost/... URLs will already have been normalized to file:///... by INetURLObject when they reach the file UCP, and even if they were not, the osl/file.hxx functionality underlying fileaccess::TaskManager::getUnqFromUrl knows how to handle them, so they will not take the forward-to-smb code branch.) (The corresponding #ifdef WIN code from 0b9ef81ba5ff08d85f21275222458a5b9b9e484c has already been removed with 82034b04e81b74a048595b0eac0f73581ecbc9e4 "tdf#119326 crash when adding "Windows Share" File resource".) (I came across that 2010 patch while looking into <https://bugs.documentfoundation.org/show_bug.cgi?id=107461> "Does not support 'file://' scheme with actual hostname". A next step would be to make the file UCP actually handle any file://<host>/... URLs that denote the local host.) Change-Id: I77242705dc4c6c1e9cb3a4f32253224ac6cb13cb Reviewed-on: https://gerrit.libreoffice.org/67372 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'ucb')
-rw-r--r--ucb/Library_ucpfile1.mk1
-rw-r--r--ucb/source/ucp/file/prov.cxx19
2 files changed, 20 insertions, 0 deletions
diff --git a/ucb/Library_ucpfile1.mk b/ucb/Library_ucpfile1.mk
index 4505708cbac8..f676eacbde3f 100644
--- a/ucb/Library_ucpfile1.mk
+++ b/ucb/Library_ucpfile1.mk
@@ -21,6 +21,7 @@ $(eval $(call gb_Library_use_libraries,ucpfile1,\
cppu \
cppuhelper \
sal \
+ tl \
ucbhelper \
))
diff --git a/ucb/source/ucp/file/prov.cxx b/ucb/source/ucp/file/prov.cxx
index 22b77d8fadaf..a5b4c0d49c1f 100644
--- a/ucb/source/ucp/file/prov.cxx
+++ b/ucb/source/ucp/file/prov.cxx
@@ -21,6 +21,8 @@
#include <osl/file.hxx>
#include <osl/socket.h>
#include <sal/log.hxx>
+#include <tools/urlobj.hxx>
+#include <ucbhelper/content.hxx>
#include <cppuhelper/queryinterface.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -170,7 +172,24 @@ FileProvider::queryContent(
aUnc );
if( err )
+ {
+ // Hack to retry file://<host>/... URLs as smb URLs:
+ INetURLObject url(xIdentifier->getContentIdentifier());
+ if (url.GetProtocol() == INetProtocol::File
+ && !url.GetHost(INetURLObject::DecodeMechanism::NONE).isEmpty())
+ {
+ url.changeScheme(INetProtocol::Smb);
+ ucbhelper::Content content;
+ if (ucbhelper::Content::create(
+ url.GetMainURL(INetURLObject::DecodeMechanism::NONE),
+ css::uno::Reference<css::ucb::XCommandEnvironment>(), m_xContext, content))
+ {
+ return content.get();
+ }
+ }
+
throw IllegalIdentifierException( THROW_WHERE );
+ }
return Reference< XContent >( new BaseContent( m_pMyShell.get(), xIdentifier, aUnc ) );
}