Repository.mk | 1 desktop/Library_crashreport.mk | 4 extensions/Library_updchk.mk | 4 external/curl/ExternalProject_curl.mk | 2 external/curl/curl-msvc-disable-protocols.patch.1 | 2 include/curlinit.hxx | 29 linguistic/Library_lng.mk | 4 officecfg/registry/data/org/openoffice/ucb/Configuration.xcu | 11 officecfg/registry/schema/org/openoffice/Office/Security.xcs | 11 qadevOOo/Jar_OOoRunner.mk | 1 qadevOOo/objdsc/ucpftp/com.sun.star.comp.ucb.FTPContentProvider.csv | 2 qadevOOo/tests/java/mod/_ucpftp/FTPContentProvider.java | 66 ucb/JunitTest_ucb_complex.mk | 26 ucb/Library_ucpcmis1.mk | 4 ucb/Library_ucpftp1.mk | 46 ucb/Module_ucb.mk | 2 ucb/qa/complex/ucb/UCB.java | 151 - ucb/qa/complex/ucb/makefile.mk | 53 ucb/qa/unoapi/ucb.sce | 1 ucb/source/ucp/ftp/curl.hxx | 24 ucb/source/ucp/ftp/ftpcfunc.cxx | 50 ucb/source/ucp/ftp/ftpcfunc.hxx | 39 ucb/source/ucp/ftp/ftpcontainer.hxx | 56 ucb/source/ucp/ftp/ftpcontent.cxx | 853 ------ ucb/source/ucp/ftp/ftpcontent.hxx | 146 - ucb/source/ucp/ftp/ftpcontentcaps.cxx | 167 - ucb/source/ucp/ftp/ftpcontentidentifier.cxx | 65 ucb/source/ucp/ftp/ftpcontentidentifier.hxx | 59 ucb/source/ucp/ftp/ftpcontentprovider.cxx | 244 - ucb/source/ucp/ftp/ftpcontentprovider.hxx | 107 ucb/source/ucp/ftp/ftpdirp.cxx | 1269 ---------- ucb/source/ucp/ftp/ftpdirp.hxx | 158 - ucb/source/ucp/ftp/ftpdynresultset.cxx | 67 ucb/source/ucp/ftp/ftpdynresultset.hxx | 48 ucb/source/ucp/ftp/ftpintreq.cxx | 64 ucb/source/ucp/ftp/ftpintreq.hxx | 84 ucb/source/ucp/ftp/ftploaderthread.cxx | 96 ucb/source/ucp/ftp/ftploaderthread.hxx | 59 ucb/source/ucp/ftp/ftpresultsetI.cxx | 90 ucb/source/ucp/ftp/ftpresultsetI.hxx | 46 ucb/source/ucp/ftp/ftpresultsetbase.cxx | 510 ---- ucb/source/ucp/ftp/ftpresultsetbase.hxx | 410 --- ucb/source/ucp/ftp/ftpresultsetfactory.hxx | 57 ucb/source/ucp/ftp/ftpurl.cxx | 793 ------ ucb/source/ucp/ftp/ftpurl.hxx | 161 - ucb/source/ucp/ftp/ucpftp1.component | 26 ucb/source/ucp/webdav-curl/CurlSession.cxx | 13 ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx | 18 48 files changed, 73 insertions(+), 6126 deletions(-)
New commits: commit 4a26dcac8e4f3ff3cbc3c356ad0a34968ef9d8fe Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Tue Nov 7 11:57:58 2023 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Nov 9 16:51:42 2023 +0100 tdf#146386 curl,ucb: remove FTP UCP FTP support has been deprecated since LO 7.4. The UCP currently doesn't even support TLS connections. Also disable FTP protocol in libcurl. Also remove JunitTest_ucb_complex: turns out the only test in it, checkWrongFtpConnection, fails on Linux because now GIO UCP handles ftp:// URLs and it throws InteractiveAugmentedIOException instead of expected ones, and on other platforms it would fail differently because there is no GIO. Change-Id: I4631d124371fef390f105fb16bf09aaa59e739e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159065 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/Repository.mk b/Repository.mk index f2d560b4cad3..72a88d3e8429 100644 --- a/Repository.mk +++ b/Repository.mk @@ -679,7 +679,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,PLAINLIBS_OOO,ooo, \ ucbhelper \ $(if $(WITH_WEBDAV),ucpdav1) \ ucpfile1 \ - ucpftp1 \ $(call gb_Helper_optional,XMLHELP,ucpchelp1) \ ucphier1 \ ucppkg1 \ diff --git a/external/curl/ExternalProject_curl.mk b/external/curl/ExternalProject_curl.mk index 5f72e4807394..c63a8e0465ce 100644 --- a/external/curl/ExternalProject_curl.mk +++ b/external/curl/ExternalProject_curl.mk @@ -38,7 +38,7 @@ $(call gb_ExternalProject_get_state_target,curl,build): $(gb_RUN_CONFIGURE) ./configure \ --without-amissl --without-bearssl --without-gnutls \ --without-mbedtls --without-rustls --without-wolfssl \ - --enable-ftp --enable-http --enable-ipv6 \ + --disable-ftp --enable-http --enable-ipv6 \ --without-libidn2 --without-libpsl --without-librtmp \ --without-libssh2 --without-nghttp2 \ --without-libssh --without-brotli \ diff --git a/external/curl/curl-msvc-disable-protocols.patch.1 b/external/curl/curl-msvc-disable-protocols.patch.1 index 71ff0c01a028..905a2d6a7ac3 100644 --- a/external/curl/curl-msvc-disable-protocols.patch.1 +++ b/external/curl/curl-msvc-disable-protocols.patch.1 @@ -8,7 +8,7 @@ disable protocols nobody needs in MSVC build +#define CURL_DISABLE_DICT 1 +#define CURL_DISABLE_FILE 1 -+#undef CURL_DISABLE_FTP ++#define CURL_DISABLE_FTP 1 +#define CURL_DISABLE_GOPHER 1 +#undef CURL_DISABLE_HTTP +#define CURL_DISABLE_IMAP 1 diff --git a/officecfg/registry/data/org/openoffice/ucb/Configuration.xcu b/officecfg/registry/data/org/openoffice/ucb/Configuration.xcu index 958202157838..9a2d98b31e69 100644 --- a/officecfg/registry/data/org/openoffice/ucb/Configuration.xcu +++ b/officecfg/registry/data/org/openoffice/ucb/Configuration.xcu @@ -89,17 +89,6 @@ <value/> </prop> </node> - <node oor:name="Provider6" oor:op="replace"> - <prop oor:name="ServiceName"> - <value>com.sun.star.ucb.FTPContentProvider</value> - </prop> - <prop oor:name="URLTemplate"> - <value>ftp</value> - </prop> - <prop oor:name="Arguments"> - <value/> - </prop> - </node> <node oor:name="Provider8" oor:op="replace"> <prop oor:name="ServiceName"> <value>com.sun.star.ucb.PackageContentProvider</value> diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk index 365ea75bc71b..3ba2d4525aee 100644 --- a/qadevOOo/Jar_OOoRunner.mk +++ b/qadevOOo/Jar_OOoRunner.mk @@ -1232,7 +1232,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\ qadevOOo/tests/java/mod/_ucpchelp/CHelpContentProvider \ qadevOOo/tests/java/mod/_ucpdav/WebDAVContentProvider \ qadevOOo/tests/java/mod/_ucpfile/FileProvider \ - qadevOOo/tests/java/mod/_ucpftp/FTPContentProvider \ qadevOOo/tests/java/mod/_ucphier/HierarchyContentProvider \ qadevOOo/tests/java/mod/_ucphier/HierarchyDataSource \ qadevOOo/tests/java/mod/_ucppkg/PackageContentProvider \ diff --git a/qadevOOo/objdsc/ucpftp/com.sun.star.comp.ucb.FTPContentProvider.csv b/qadevOOo/objdsc/ucpftp/com.sun.star.comp.ucb.FTPContentProvider.csv deleted file mode 100644 index c5adee391f2a..000000000000 --- a/qadevOOo/objdsc/ucpftp/com.sun.star.comp.ucb.FTPContentProvider.csv +++ /dev/null @@ -1,2 +0,0 @@ -"FTPContentProvider";"com::sun::star::ucb::XContentProvider";"queryContent()" -"FTPContentProvider";"com::sun::star::ucb::XContentProvider";"compareContentIds()" diff --git a/qadevOOo/tests/java/mod/_ucpftp/FTPContentProvider.java b/qadevOOo/tests/java/mod/_ucpftp/FTPContentProvider.java deleted file mode 100644 index 7bb047214d37..000000000000 --- a/qadevOOo/tests/java/mod/_ucpftp/FTPContentProvider.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package mod._ucpftp; - -import java.io.PrintWriter; - -import lib.TestCase; -import lib.TestEnvironment; -import lib.TestParameters; - -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.ucb.XContentIdentifierFactory; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XInterface; - -public class FTPContentProvider extends TestCase { - - @Override - public TestEnvironment createTestEnvironment - ( TestParameters Param,PrintWriter log ) throws Exception { - - XInterface oObj = null; - Object oInterface = null; - Object aUCB = null; - - XMultiServiceFactory xMSF = Param.getMSF(); - oInterface = xMSF.createInstance - ( "com.sun.star.ucb.FTPContentProvider" ); - aUCB = xMSF.createInstance - ( "com.sun.star.comp.ucb.UniversalContentBroker" ); - - oObj = (XInterface) oInterface; - - XContentIdentifierFactory CIF = UnoRuntime.queryInterface(XContentIdentifierFactory.class,aUCB); - - log.println("ImplementationName: "+util.utils.getImplName(oObj)); - util.dbg.printInterfaces(oObj); - TestEnvironment tEnv = new TestEnvironment( oObj ); - - //Adding ObjRelation for XContentProvider - tEnv.addObjRelation("FACTORY",CIF); - tEnv.addObjRelation("CONTENT1","ftp:///ftp.sun.com"); - tEnv.addObjRelation("CONTENT2","ftp:///ftp.openoffice.org"); - - return tEnv; - - } // finish method getTestEnvironment - -} // finish class FileProvider - diff --git a/ucb/JunitTest_ucb_complex.mk b/ucb/JunitTest_ucb_complex.mk deleted file mode 100644 index 6aa02ff9dbfb..000000000000 --- a/ucb/JunitTest_ucb_complex.mk +++ /dev/null @@ -1,26 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -$(eval $(call gb_JunitTest_JunitTest,ucb_complex)) - -$(eval $(call gb_JunitTest_set_defs,ucb_complex,\ - $$(DEFS) \ - -Dorg.openoffice.test.arg.tdoc=$(SRCDIR)/ucb/qa/complex/testdocuments \ -)) - -$(eval $(call gb_JunitTest_use_unoapi_jars,ucb_complex)) - -$(eval $(call gb_JunitTest_add_sourcefiles,ucb_complex,\ - ucb/qa/complex/ucb/UCB \ -)) -$(eval $(call gb_JunitTest_add_classes,ucb_complex,\ - complex.ucb.UCB \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/ucb/Library_ucpftp1.mk b/ucb/Library_ucpftp1.mk deleted file mode 100644 index a6ac6c69f69b..000000000000 --- a/ucb/Library_ucpftp1.mk +++ /dev/null @@ -1,50 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -$(eval $(call gb_Library_Library,ucpftp1)) - -$(eval $(call gb_Library_set_componentfile,ucpftp1,ucb/source/ucp/ftp/ucpftp1,services)) - -$(eval $(call gb_Library_use_external,ucpftp1,boost_headers)) - -$(eval $(call gb_Library_use_sdk_api,ucpftp1)) - -$(eval $(call gb_Library_use_custom_headers,ucpftp1,\ - officecfg/registry \ -)) - -$(eval $(call gb_Library_use_libraries,ucpftp1,\ - comphelper \ - cppu \ - cppuhelper \ - sal \ - ucbhelper \ -)) - -$(eval $(call gb_Library_use_externals,ucpftp1,\ - curl \ -)) - -$(eval $(call gb_Library_add_exception_objects,ucpftp1,\ - ucb/source/ucp/ftp/ftpcfunc \ - ucb/source/ucp/ftp/ftpcontentcaps \ - ucb/source/ucp/ftp/ftpcontent \ - ucb/source/ucp/ftp/ftpcontentidentifier \ - ucb/source/ucp/ftp/ftpcontentprovider \ - ucb/source/ucp/ftp/ftpdirp \ - ucb/source/ucp/ftp/ftpdynresultset \ - ucb/source/ucp/ftp/ftpintreq \ - ucb/source/ucp/ftp/ftploaderthread \ - ucb/source/ucp/ftp/ftpresultsetbase \ - ucb/source/ucp/ftp/ftpresultsetI \ - ucb/source/ucp/ftp/ftpurl \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/ucb/Module_ucb.mk b/ucb/Module_ucb.mk index 7bbcc925e28d..3964eb1d9c39 100644 --- a/ucb/Module_ucb.mk +++ b/ucb/Module_ucb.mk @@ -18,7 +18,6 @@ $(eval $(call gb_Module_add_targets,ucb,\ Library_ucpexpand1 \ Library_ucpext \ Library_ucpfile1 \ - $(if $(ENABLE_CURL),Library_ucpftp1) \ Library_ucphier1 \ Library_ucpimage \ Library_ucppkg1 \ @@ -40,7 +39,6 @@ $(eval $(call gb_Module_add_check_targets,ucb,\ endif $(eval $(call gb_Module_add_subsequentcheck_targets,ucb,\ - JunitTest_ucb_complex \ JunitTest_ucb_unoapi \ )) diff --git a/ucb/qa/complex/ucb/UCB.java b/ucb/qa/complex/ucb/UCB.java deleted file mode 100644 index 16ee670805ff..000000000000 --- a/ucb/qa/complex/ucb/UCB.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package complex.ucb; - -import com.sun.star.beans.Property; -import com.sun.star.sdbc.XRow; -import com.sun.star.ucb.*; -import com.sun.star.uno.UnoRuntime; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openoffice.test.OfficeConnection; -import static org.junit.Assert.*; - -/** - * This class is used to copy the content of a folder to - * another folder. - * There is an inconsistency with argument order. - * It should be always: dir,filename. - */ -public class UCB { - private XUniversalContentBroker ucb; - - public void init() throws Exception { - ucb = UniversalContentBroker.create(connection.getComponentContext()); - } - - public void delete(String filename) throws Exception { - executeCommand(getContent(filename), "delete", Boolean.TRUE); - } - - /** - * target name can be "", in which case the name stays lige the source name - */ - public Object executeCommand( - Object xContent, - String aCommandName, - Object aArgument) - throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception { - XCommandProcessor xCmdProcessor = - UnoRuntime.queryInterface(XCommandProcessor.class, xContent); - Command aCommand = new Command(); - aCommand.Name = aCommandName; - aCommand.Handle = -1; // not available - aCommand.Argument = aArgument; - return xCmdProcessor.execute(aCommand, 0, null); - } - - public Object getContentProperty( - Object content, - String propName, - Class type) - throws Exception { - Property[] pv = new Property[1]; - pv[0] = new Property(); - pv[0].Name = propName; - pv[0].Handle = -1; - - Object row = executeCommand(content, "getPropertyValues", pv); - XRow xrow = UnoRuntime.queryInterface(XRow.class, row); - if (type.equals(String.class)) - { - return xrow.getString(1); - } - else if (type.equals(Boolean.class)) - { - return xrow.getBoolean(1) ? Boolean.TRUE : Boolean.FALSE; - } - else if (type.equals(Integer.class)) - { - return Integer.valueOf(xrow.getInt(1)); - } - else if (type.equals(Short.class)) - { - return Short.valueOf(xrow.getShort(1)); - } - else - { - return null; - } - - } - - public Object getContent(String path) throws Exception - { - XContentIdentifier id = ucb.createContentIdentifier(path); - return ucb.queryContent(id); - } - - @Test public void checkWrongFtpConnection() { - try { - String acountUrl = "ftp://noname:nopasswd@*nohost.invalid"; - System.out.println(acountUrl); - init(); - Object content = getContent(acountUrl); - - OpenCommandArgument2 aArg = new OpenCommandArgument2(); - aArg.Mode = OpenMode.ALL; // FOLDER, DOCUMENTS -> simple filter - aArg.Priority = 32768; // Ignored by most implementations - - System.out.println("now executing open"); - executeCommand(content, "open", aArg); - fail("Expected exception 'IllegalArgumentException' or 'IllegalIdentifierException' was not thrown."); - } catch (com.sun.star.lang.IllegalArgumentException ex) { - // correct - } catch (com.sun.star.ucb.IllegalIdentifierException ex) { - // correct - } catch(com.sun.star.ucb.InteractiveNetworkException ex) { - System.out.println("This Exception is correctly thrown when no Proxy in StarOffice is used."); - System.out.println("To reproduce the bug behaviour, use a Proxy and try again."); - } catch (Exception ex) { - ex.printStackTrace(); - String exceptionName = ex.toString(); - System.out.println("ExName: '"+exceptionName+"'"); - fail("Wrong exception thrown: " + exceptionName); - } - } - - // setup and close connections - @BeforeClass public static void setUpConnection() throws Exception { - System.out.println("setUpConnection()"); - connection.setUp(); - } - - @AfterClass public static void tearDownConnection() - throws InterruptedException, com.sun.star.uno.Exception - { - System.out.println("tearDownConnection()"); - connection.tearDown(); - } - - private static final OfficeConnection connection = new OfficeConnection(); - -} diff --git a/ucb/qa/complex/ucb/makefile.mk b/ucb/qa/complex/ucb/makefile.mk deleted file mode 100644 index 401576c9cf16..000000000000 --- a/ucb/qa/complex/ucb/makefile.mk +++ /dev/null @@ -1,53 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -.IF "$(OOO_SUBSEQUENT_TESTS)" == "" -nothing .PHONY: -.ELSE - -PRJ = ../../.. -PRJNAME = UCB -TARGET = qa_complex_ucb - -.IF "$(OOO_JUNIT_JAR)" != "" -PACKAGE = complex/ucb -JAVATESTFILES = \ - UCB.java - -JAVAFILES = $(JAVATESTFILES) - -JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar jurt.jar -EXTRAJARFILES = $(OOO_JUNIT_JAR) - -# Sample how to debug -# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y -.END - -.INCLUDE: settings.mk -.INCLUDE: target.mk -.INCLUDE: installationtest.mk - -ALLTAR : javatest - -.END - - - - - - diff --git a/ucb/qa/unoapi/ucb.sce b/ucb/qa/unoapi/ucb.sce index 0c798cfdedab..7898f55c5a98 100644 --- a/ucb/qa/unoapi/ucb.sce +++ b/ucb/qa/unoapi/ucb.sce @@ -22,7 +22,6 @@ -o ucpchelp.CHelpContentProvider -o ucpdav.WebDAVContentProvider -o ucpfile.FileProvider --o ucpftp.FTPContentProvider -o ucphier.HierarchyContentProvider -o ucphier.HierarchyDataSource -o ucppkg.PackageContentProvider diff --git a/ucb/source/ucp/ftp/curl.hxx b/ucb/source/ucp/ftp/curl.hxx deleted file mode 100644 index 3dac8a057ffa..000000000000 --- a/ucb/source/ucp/ftp/curl.hxx +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#pragma once - -#include <curl/curl.h> - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/ftp/ftpcfunc.cxx b/ucb/source/ucp/ftp/ftpcfunc.cxx deleted file mode 100644 index a39043aa792e..000000000000 --- a/ucb/source/ucp/ftp/ftpcfunc.cxx +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -/************************************************************************** - TODO - ************************************************************************** - - *************************************************************************/ -#include <osl/file.h> -#include "ftpcontentidentifier.hxx" -#include "ftpcfunc.hxx" - -using namespace ftp; -using namespace com::sun::star::uno; - -extern "C" { - - int file_write(void *buffer,size_t size,size_t nmemb,void *stream) - { - oslFileHandle aFile = reinterpret_cast< oslFileHandle >( stream ); - if( !aFile ) - return 0; - - sal_uInt64 nWritten = 0; - sal_uInt64 nToWrite( size * nmemb ); - osl_writeFile( aFile, buffer, nToWrite, &nWritten ); - - return nWritten != nToWrite ? 0 : nmemb; - } - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/ftp/ftpcfunc.hxx b/ucb/source/ucp/ftp/ftpcfunc.hxx deleted file mode 100644 index f5a29a3fbf46..000000000000 --- a/ucb/source/ucp/ftp/ftpcfunc.hxx +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -/************************************************************************** - TODO - ************************************************************************** - - *************************************************************************/ -#pragma once - -#include <stddef.h> - -extern "C" { - -/** callback for curl_easy_perform(), - * forwarding the written content to the stream. - * stream has to be of type oslFileHandle. - */ - -int file_write(void* buffer, size_t size, size_t nmemb, void* stream); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/ftp/ftpcontainer.hxx b/ucb/source/ucp/ftp/ftpcontainer.hxx deleted file mode 100644 index e555111a223d..000000000000 --- a/ucb/source/ucp/ftp/ftpcontainer.hxx +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -/************************************************************************** - TODO - ************************************************************************** - - *************************************************************************/ - -#pragma once - -#include <sal/types.h> - -namespace ftp { - -class MemoryContainer { - -public: - - MemoryContainer(); - - ~MemoryContainer(); - - int append( - const void* pBuffer, - size_t size, - size_t nmemb - ) noexcept; - - - sal_uInt32 m_nLen,m_nWritePos; - void *m_pBuffer; -}; - -} - - -extern "C" int memory_write( - void *buffer,size_t size,size_t nmemb,void *stream); - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/ftp/ftpcontent.cxx b/ucb/source/ucp/ftp/ftpcontent.cxx deleted file mode 100644 index 4cca92f3b601..000000000000 --- a/ucb/source/ucp/ftp/ftpcontent.cxx +++ /dev/null @@ -1,853 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -/************************************************************************** - TODO - ************************************************************************** - - *************************************************************************/ -#include <com/sun/star/beans/PropertyAttribute.hpp> - -#include "ftpdynresultset.hxx" -#include "ftpresultsetfactory.hxx" -#include "ftpresultsetI.hxx" -#include "ftpcontent.hxx" -#include "ftpcontentprovider.hxx" -#include "ftpdirp.hxx" -#include "ftpcontentidentifier.hxx" -#include "ftpintreq.hxx" - -#include <memory> -#include <utility> -#include <vector> -#include <string.h> -#include "curl.hxx" -#include <comphelper/propertysequence.hxx> -#include <cppuhelper/queryinterface.hxx> -#include <cppuhelper/supportsservice.hxx> -#include <cppuhelper/typeprovider.hxx> -#include <ucbhelper/cancelcommandexecution.hxx> -#include <ucbhelper/fd_inputstream.hxx> -#include <ucbhelper/propertyvalueset.hxx> -#include <ucbhelper/simpleauthenticationrequest.hxx> -#include <com/sun/star/lang/IllegalAccessException.hpp> -#include <com/sun/star/lang/NoSupportException.hpp> -#include <com/sun/star/ucb/ContentInfoAttribute.hpp> -#include <com/sun/star/ucb/UnsupportedCommandException.hpp> -#include <com/sun/star/beans/IllegalTypeException.hpp> -#include <com/sun/star/beans/UnknownPropertyException.hpp> -#include <com/sun/star/beans/Property.hpp> -#include <com/sun/star/ucb/XCommandInfo.hpp> -#include <com/sun/star/io/BufferSizeExceededException.hpp> -#include <com/sun/star/io/IOException.hpp> -#include <com/sun/star/io/NotConnectedException.hpp> -#include <com/sun/star/io/XActiveDataSink.hpp> -#include <com/sun/star/io/XOutputStream.hpp> -#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp> -#include <com/sun/star/ucb/OpenCommandArgument2.hpp> -#include <com/sun/star/ucb/UnsupportedOpenModeException.hpp> -#include <com/sun/star/ucb/IllegalIdentifierException.hpp> -#include <com/sun/star/ucb/InteractiveNetworkConnectException.hpp> -#include <com/sun/star/ucb/InteractiveNetworkResolveNameException.hpp> -#include <com/sun/star/ucb/InteractiveIOException.hpp> -#include <com/sun/star/ucb/MissingPropertiesException.hpp> -#include <com/sun/star/ucb/MissingInputStreamException.hpp> -#include <com/sun/star/ucb/UnsupportedNameClashException.hpp> -#include <com/sun/star/ucb/OpenMode.hpp> -#include <com/sun/star/ucb/IOErrorCode.hpp> - -using namespace ftp; -using namespace com::sun::star::task; -using namespace com::sun::star::container; -using namespace com::sun::star::lang; -using namespace com::sun::star::uno; -using namespace com::sun::star::ucb; -using namespace com::sun::star::beans; -using namespace com::sun::star::io; -using namespace com::sun::star::sdbc; - - -// Content Implementation. - -FTPContent::FTPContent( const Reference< XComponentContext >& rxContext, - FTPContentProvider* pProvider, - const Reference< XContentIdentifier >& Identifier, - const FTPURL& aFTPURL) - : ContentImplHelper(rxContext,pProvider,Identifier) - , m_pFCP(pProvider) - , m_aFTPURL(aFTPURL) - , m_bInserted(false) - , m_bTitleSet(false) -{ -} - -FTPContent::FTPContent( const Reference< XComponentContext >& rxContext, - FTPContentProvider* pProvider, - const Reference< XContentIdentifier >& Identifier, - ContentInfo Info) - : ContentImplHelper(rxContext,pProvider,Identifier) - , m_pFCP(pProvider) - , m_aFTPURL(Identifier->getContentIdentifier(), pProvider) - , m_bInserted(true) - , m_bTitleSet(false) - , m_aInfo(std::move(Info)) -{ -} - -FTPContent::~FTPContent() -{ -} - -// XInterface methods. - -void SAL_CALL FTPContent::acquire() - noexcept -{ - OWeakObject::acquire(); -} - -void SAL_CALL FTPContent::release() - noexcept -{ - OWeakObject::release(); -} - -css::uno::Any SAL_CALL FTPContent::queryInterface( const css::uno::Type & rType ) -{ - css::uno::Any aRet = cppu::queryInterface( rType, - static_cast< XTypeProvider* >(this), - static_cast< XServiceInfo* >(this), - static_cast< XContent* >(this), - static_cast< XCommandProcessor* >(this), - static_cast< XContentCreator* >(this), - static_cast< XChild* >(this) - ); - return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); -} - -// XTypeProvider methods. - -css::uno::Sequence< sal_Int8 > SAL_CALL FTPContent::getImplementationId() -{ - return css::uno::Sequence<sal_Int8>(); -} - -css::uno::Sequence< css::uno::Type > SAL_CALL FTPContent::getTypes() -{ - static cppu::OTypeCollection s_aCollection( - cppu::UnoType<XTypeProvider>::get(), - cppu::UnoType<XServiceInfo>::get(), - cppu::UnoType<XContent>::get(), - cppu::UnoType<XCommandProcessor>::get(), - cppu::UnoType<XContentCreator>::get(), - cppu::UnoType<XChild>::get() - ); - - return s_aCollection.getTypes(); -} - - -// XServiceInfo methods. - -OUString SAL_CALL FTPContent::getImplementationName() -{ - return "com.sun.star.comp.FTPContent"; -} - -sal_Bool SAL_CALL FTPContent::supportsService( const OUString& ServiceName ) -{ - return cppu::supportsService( this, ServiceName ); -} - -css::uno::Sequence< OUString > SAL_CALL FTPContent::getSupportedServiceNames() -{ - return { "com.sun.star.ucb.FTPContent" }; -} - - -// XContent methods. - -// virtual -OUString SAL_CALL FTPContent::getContentType() -{ - return FTP_CONTENT_TYPE; -} - -// XCommandProcessor methods. - -//virtual -void SAL_CALL FTPContent::abort( sal_Int32 /*CommandId*/ ) -{ -} - - -ResultSetFactory::ResultSetFactory(const Reference<XComponentContext >& rxContext, - const Reference<XContentProvider >& xProvider, - const Sequence<Property>& seq, - std::vector<FTPDirentry>&& dirvec) - : m_xContext(rxContext), - m_xProvider(xProvider), - m_seq(seq), - m_dirvec(std::move(dirvec)) -{ -} - - -rtl::Reference<ResultSetBase> ResultSetFactory::createResultSet() -{ - return new ResultSetI(m_xContext, - m_xProvider, - m_seq, - m_dirvec); -} - - -// XCommandProcessor methods. - -namespace { - -enum ACTION { NOACTION, - THROWAUTHENTICATIONREQUEST, - THROWACCESSDENIED, - THROWINTERACTIVECONNECT, - THROWMALFORMED, - THROWRESOLVENAME, - THROWQUOTE, - THROWNOFILE, - THROWGENERAL }; - -} - -// virtual -Any SAL_CALL FTPContent::execute( const Command& aCommand, - sal_Int32 /*CommandId*/, - const Reference< - XCommandEnvironment >& Environment) -{ - ACTION action(NOACTION); - Any aRet; - - while(true) - { - try - { - if(action == THROWAUTHENTICATIONREQUEST) - { - // try to get a continuation first - OUString aPassword,aAccount; - m_pFCP->forHost(m_aFTPURL.host(), - m_aFTPURL.port(), - m_aFTPURL.username(), - aPassword, - aAccount); - rtl::Reference<ucbhelper::SimpleAuthenticationRequest> - p( new ucbhelper::SimpleAuthenticationRequest( - m_aFTPURL.ident(false, false), - m_aFTPURL.host(), // ServerName - ucbhelper::SimpleAuthenticationRequest::ENTITY_NA, - OUString(), - ucbhelper::SimpleAuthenticationRequest - ::ENTITY_FIXED, - m_aFTPURL.username(), - ucbhelper::SimpleAuthenticationRequest - ::ENTITY_MODIFY, - aPassword)); - - Reference<XInteractionHandler> xInteractionHandler; - if(Environment.is()) - xInteractionHandler = - Environment->getInteractionHandler(); - - if( xInteractionHandler.is()) { - xInteractionHandler->handle(p); - - Reference<XInterface> xSelection( - p->getSelection()); - - if(Reference<XInteractionRetry>( - xSelection,UNO_QUERY).is()) - action = NOACTION; - else if(Reference<XInteractionSupplyAuthentication>( - xSelection,UNO_QUERY).is()) { - m_pFCP->setHost( - m_aFTPURL.host(), - m_aFTPURL.port(), - m_aFTPURL.username(), - p->getAuthenticationSupplier()->getPassword(), - aAccount); - action = NOACTION; - } - } - aRet = p->getRequest(); - } - -// if(aCommand.Name.equalsAscii( -// "getPropertyValues") && -// action != NOACTION) { -// // It is not allowed to throw if -// // command is getPropertyValues -// rtl::Reference<ucbhelper::PropertyValueSet> xRow = -// new ucbhelper::PropertyValueSet(m_xSMgr); -// Sequence<Property> Properties; -// aCommand.Argument >>= Properties; -// for(int i = 0; i < Properties.getLength(); ++i) -// xRow->appendVoid(Properties[i]); -// aRet <<= Reference<XRow>(xRow.get()); -// return aRet; -// } - - switch (action) - { - case NOACTION: - break; - - case THROWAUTHENTICATIONREQUEST: - ucbhelper::cancelCommandExecution( - aRet, - Reference<XCommandEnvironment>(nullptr)); - break; - - case THROWACCESSDENIED: - { - Sequence<Any> seq(comphelper::InitAnyPropertySequence( - { - {"Uri", Any(m_aFTPURL.ident(false,false))} - })); - ucbhelper::cancelCommandExecution( - IOErrorCode_ACCESS_DENIED, - seq, - Environment); - break; - } - case THROWINTERACTIVECONNECT: - { - InteractiveNetworkConnectException excep; - excep.Server = m_aFTPURL.host(); - aRet <<= excep; - ucbhelper::cancelCommandExecution( - aRet, - Environment); - break; - } - case THROWMALFORMED: - { - IllegalIdentifierException ex; - aRet <<= ex; - ucbhelper::cancelCommandExecution( - aRet, - Environment); - break; - } - case THROWRESOLVENAME: - { - InteractiveNetworkResolveNameException excep; - excep.Server = m_aFTPURL.host(); - aRet <<= excep; - ucbhelper::cancelCommandExecution( - aRet, - Environment); - break; - } - case THROWNOFILE: - { - Sequence<Any> seq(comphelper::InitAnyPropertySequence( - { - {"Uri", Any(m_aFTPURL.ident(false,false))} - })); - ucbhelper::cancelCommandExecution( - IOErrorCode_NO_FILE, - seq, - Environment); - break; - } - case THROWQUOTE: - case THROWGENERAL: - ucbhelper::cancelCommandExecution( - IOErrorCode_GENERAL, - Sequence<Any>(0), - Environment); - break; - } - - if(aCommand.Name == "getPropertyValues") { - Sequence<Property> Properties; - if(!(aCommand.Argument >>= Properties)) - { - aRet <<= IllegalArgumentException( - "Wrong argument type!", - getXWeak(), - -1); - ucbhelper::cancelCommandExecution(aRet,Environment); - } - - aRet <<= getPropertyValues(Properties); - } - else if(aCommand.Name == "setPropertyValues") - { - Sequence<PropertyValue> propertyValues; - - if( ! ( aCommand.Argument >>= propertyValues ) ) { - aRet <<= IllegalArgumentException( - "Wrong argument type!", - getXWeak(), - -1); - ucbhelper::cancelCommandExecution(aRet,Environment); - } - - aRet <<= setPropertyValues(propertyValues); - } - else if(aCommand.Name == "getCommandInfo") { - // Note: Implemented by base class. - aRet <<= getCommandInfo(Environment); - } - else if(aCommand.Name == "getPropertySetInfo") { - // Note: Implemented by base class. - aRet <<= getPropertySetInfo(Environment); - } - else if(aCommand.Name == "insert") - { - InsertCommandArgument aInsertArgument; - if ( ! ( aCommand.Argument >>= aInsertArgument ) ) { - aRet <<= IllegalArgumentException( - "Wrong argument type!", - getXWeak(), - -1); - ucbhelper::cancelCommandExecution(aRet,Environment); - } - insert(aInsertArgument,Environment); - } - else if(aCommand.Name == "delete") { - m_aFTPURL.del(); - deleted(); - } - else if(aCommand.Name == "open") { - OpenCommandArgument2 aOpenCommand; - if ( !( aCommand.Argument >>= aOpenCommand ) ) { - aRet <<= IllegalArgumentException( - "Wrong argument type!", - getXWeak(), - -1); - - ucbhelper::cancelCommandExecution(aRet,Environment); - } - - if(aOpenCommand.Mode == OpenMode::DOCUMENT) { - // Open as a document - Reference<XActiveDataSink> - xActiveDataSink(aOpenCommand.Sink,UNO_QUERY); - Reference< XOutputStream > - xOutputStream(aOpenCommand.Sink,UNO_QUERY); - - if(xActiveDataSink.is()) { - xActiveDataSink->setInputStream( - new ucbhelper::FdInputStream(m_aFTPURL.open())); - } - else if(xOutputStream.is()) { - Reference<XInputStream> xStream( - new ucbhelper::FdInputStream(m_aFTPURL.open())); - for (;;) { - Sequence<sal_Int8> byte_seq(4096); - sal_Int32 n = xStream->readBytes(byte_seq, 4096); - if (n == 0) { - break; - } - try { - if(byte_seq.getLength() != n) - byte_seq.realloc(n); - xOutputStream->writeBytes(byte_seq); - } catch(const NotConnectedException&) { - - } catch(const BufferSizeExceededException&) { - - } catch(const IOException&) { - - } - } - } - else { - aRet <<= UnsupportedDataSinkException( - OUString(), - getXWeak(), - aOpenCommand.Sink); - ucbhelper::cancelCommandExecution(aRet,Environment); - } - } - else if(aOpenCommand.Mode == OpenMode::ALL || - aOpenCommand.Mode == OpenMode::DOCUMENTS || - aOpenCommand.Mode == OpenMode::FOLDERS ) { - std::vector<FTPDirentry> resvec = - m_aFTPURL.list(sal_Int16(aOpenCommand.Mode)); - Reference< XDynamicResultSet > xSet - = new DynamicResultSet( - m_xContext, - aOpenCommand, - std::make_unique<ResultSetFactory>(m_xContext, - m_xProvider.get(), - aOpenCommand.Properties, - std::move(resvec))); - aRet <<= xSet; - } - else if(aOpenCommand.Mode == - OpenMode::DOCUMENT_SHARE_DENY_NONE || - aOpenCommand.Mode == - OpenMode::DOCUMENT_SHARE_DENY_WRITE) { - // Unsupported OpenMode - aRet <<= UnsupportedOpenModeException( - OUString(), - getXWeak(), - static_cast< sal_Int16 >(aOpenCommand.Mode)); - ucbhelper::cancelCommandExecution(aRet,Environment); - } - else { - aRet <<= IllegalArgumentException( - "Unexpected OpenMode!", - getXWeak(), - -1); - - ucbhelper::cancelCommandExecution(aRet,Environment); - } - } else if(aCommand.Name == "createNewContent") { - ContentInfo aArg; - if (!(aCommand.Argument >>= aArg)) { - ucbhelper::cancelCommandExecution( - Any( - IllegalArgumentException( - "Wrong argument type!", - getXWeak(), - -1)), - Environment); - // Unreachable - } - aRet <<= createNewContent(aArg); - } else { - aRet <<= UnsupportedCommandException( - aCommand.Name, - getXWeak()); - ucbhelper::cancelCommandExecution(aRet,Environment); - } - - return aRet; - } - catch(const curl_exception& e) - { - if(e.code() == CURLE_COULDNT_CONNECT) - action = THROWINTERACTIVECONNECT; - else if (e.code() == CURLE_URL_MALFORMAT) - { - action = THROWMALFORMED; - } - else if(e.code() == CURLE_COULDNT_RESOLVE_HOST ) - action = THROWRESOLVENAME; - else if(e.code() == CURLE_FTP_USER_PASSWORD_INCORRECT || - e.code() == CURLE_LOGIN_DENIED || - e.code() == CURLE_BAD_PASSWORD_ENTERED || - e.code() == CURLE_FTP_WEIRD_PASS_REPLY) - action = THROWAUTHENTICATIONREQUEST; - else if(e.code() == CURLE_FTP_ACCESS_DENIED) - action = THROWACCESSDENIED; - else if(e.code() == CURLE_FTP_QUOTE_ERROR) - action = THROWQUOTE; - else if(e.code() == CURLE_FTP_COULDNT_RETR_FILE) - action = THROWNOFILE; - else - // nothing known about the cause of the error - action = THROWGENERAL; - } - } -} - -constexpr OUString FTP_FILE = u"application/vnd.sun.staroffice.ftp-file"_ustr; - -constexpr OUString FTP_FOLDER = u"application/vnd.sun.staroffice.ftp-folder"_ustr; - -Sequence<ContentInfo > SAL_CALL -FTPContent::queryCreatableContentsInfo( ) -{ - return queryCreatableContentsInfo_Static(); -} - -// static -Sequence<ContentInfo > -FTPContent::queryCreatableContentsInfo_Static( ) -{ - Sequence< Property > props{ Property( - "Title", - -1, - cppu::UnoType<OUString>::get(), - PropertyAttribute::MAYBEVOID - | PropertyAttribute::BOUND ) }; - return - { - { FTP_FILE, ContentInfoAttribute::INSERT_WITH_INPUTSTREAM | ContentInfoAttribute::KIND_DOCUMENT, props }, - { FTP_FOLDER, ContentInfoAttribute::KIND_FOLDER, props } - }; -} - -Reference<XContent > SAL_CALL -FTPContent::createNewContent( const ContentInfo& Info ) -{ - if( Info.Type =="application/vnd.sun.staroffice.ftp-file" || Info.Type == "application/vnd.sun.staroffice.ftp-folder" ) - return new FTPContent(m_xContext, - m_pFCP, - m_xIdentifier,Info); - else - return Reference<XContent>(nullptr); -} - - -Reference<XInterface > SAL_CALL -FTPContent::getParent( ) -{ - Reference<XContentIdentifier> - xIdent(new FTPContentIdentifier(m_aFTPURL.parent())); - return Reference<XInterface>( m_xProvider->queryContent(xIdent), UNO_QUERY ); -} - - -void SAL_CALL -FTPContent::setParent(const Reference<XInterface >& /*Parent*/ ) -{ - throw NoSupportException(); -} - - -OUString FTPContent::getParentURL() -{ - return m_aFTPURL.parent(); -} - -namespace { - -class InsertData - : public CurlInput { - -public: - - explicit InsertData(const Reference<XInputStream>& xInputStream) - : m_xInputStream(xInputStream) { } - virtual ~InsertData() {} - - // returns the number of bytes actually read - virtual sal_Int32 read(sal_Int8 *dest,sal_Int32 nBytesRequested) override; - -private: - - Reference<XInputStream> m_xInputStream; -}; - -} - -sal_Int32 InsertData::read(sal_Int8 *dest,sal_Int32 nBytesRequested) -{ - sal_Int32 m = 0; - - if(m_xInputStream.is()) { - Sequence<sal_Int8> seq(nBytesRequested); - m = m_xInputStream->readBytes(seq,nBytesRequested); - memcpy(dest,seq.getConstArray(),m); - } - return m; -} - - -void FTPContent::insert(const InsertCommandArgument& aInsertCommand, - const Reference<XCommandEnvironment>& Env) -{ - osl::MutexGuard aGuard(m_aMutex); - - if(m_bInserted && !m_bTitleSet) { - MissingPropertiesException excep; - excep.Properties = { "Title" }; - ucbhelper::cancelCommandExecution(Any(excep), Env); - } - - if(m_bInserted && - m_aInfo.Type == FTP_FILE && - !aInsertCommand.Data.is()) - { - MissingInputStreamException excep; - ucbhelper::cancelCommandExecution(Any(excep), Env); - } - - bool bReplace(aInsertCommand.ReplaceExisting); - - retry: - try { - if(m_aInfo.Type == FTP_FILE) { - InsertData data(aInsertCommand.Data); - m_aFTPURL.insert(bReplace,&data); - } else if(m_aInfo.Type == FTP_FOLDER) - m_aFTPURL.mkdir(bReplace); - } catch(const curl_exception& e) { - if(e.code() == FOLDER_MIGHT_EXIST_DURING_INSERT || - e.code() == FILE_MIGHT_EXIST_DURING_INSERT) { - // Interact - Reference<XInteractionHandler> xInt; - if(Env.is()) - xInt = Env->getInteractionHandler(); - - UnsupportedNameClashException excep; - excep.NameClash = 0; //NameClash::ERROR; - - if(!xInt.is()) { - ucbhelper::cancelCommandExecution(Any(excep), Env); - } - - XInteractionRequestImpl request; - const Reference<XInteractionRequest>& xReq(request.getRequest()); - xInt->handle(xReq); - if (request.approved()) { - bReplace = true; - goto retry; - } - else - throw excep; - } - else - throw; - } - - // May not be reached, because both mkdir and insert can throw curl- - // exceptions - m_bInserted = false; - inserted(); -} - - -Reference< XRow > FTPContent::getPropertyValues( - const Sequence< Property >& seqProp -) -{ - rtl::Reference<ucbhelper::PropertyValueSet> xRow = - new ucbhelper::PropertyValueSet(m_xContext); - - FTPDirentry aDirEntry = m_aFTPURL.direntry(); - - for(const auto& rProp : seqProp) { - const OUString& Name = rProp.Name; - if(Name == "Title") - xRow->appendString(rProp,aDirEntry.m_aName); - else if(Name == "CreatableContentsInfo") - xRow->appendObject(rProp, - Any(queryCreatableContentsInfo())); - else if(aDirEntry.m_nMode != INETCOREFTP_FILEMODE_UNKNOWN) { - if(Name == "ContentType") - xRow->appendString(rProp, - (aDirEntry.m_nMode & INETCOREFTP_FILEMODE_ISDIR) - ? FTP_FOLDER - : FTP_FILE ); - else if(Name == "IsReadOnly") - xRow->appendBoolean(rProp, - (aDirEntry.m_nMode - & INETCOREFTP_FILEMODE_WRITE) == 0 ); - else if(Name == "IsDocument") - xRow->appendBoolean(rProp, - (aDirEntry.m_nMode & - INETCOREFTP_FILEMODE_ISDIR) != INETCOREFTP_FILEMODE_ISDIR); - else if(Name == "IsFolder") - xRow->appendBoolean(rProp, - (aDirEntry.m_nMode & - INETCOREFTP_FILEMODE_ISDIR) == INETCOREFTP_FILEMODE_ISDIR); - else if(Name == "Size") - xRow->appendLong(rProp, - aDirEntry.m_nSize); - else if(Name == "DateCreated") - xRow->appendTimestamp(rProp, - aDirEntry.m_aDate); - else - xRow->appendVoid(rProp); - } else - xRow->appendVoid(rProp); - } - - return xRow; -} - - -Sequence<Any> FTPContent::setPropertyValues( - const Sequence<PropertyValue>& seqPropVal) -{ - Sequence<Any> ret(seqPropVal.getLength()); - auto retRange = asNonConstRange(ret); - Sequence<PropertyChangeEvent > evt; - - osl::MutexGuard aGuard(m_aMutex); - for(sal_Int32 i = 0; i < ret.getLength(); ++i) { - if ( seqPropVal[i].Name == "Title" ) { - OUString Title; - if(!(seqPropVal[i].Value >>= Title)) { - retRange[i] <<= IllegalTypeException(); - continue; - } else if(Title.isEmpty()) { - retRange[i] <<= IllegalArgumentException(); - continue; - } - - if(m_bInserted) { - m_aFTPURL.child(Title); - m_xIdentifier = - new FTPContentIdentifier(m_aFTPURL.ident(false,false)); - m_bTitleSet = true; - } else - try { - OUString OldTitle = m_aFTPURL.ren(Title); - evt = { { /* Source */ {}, - /* PropertyName */ "Title", - /* Further */ false, - /* PropertyHandle */ -1, - /* OldValue */ Any(OldTitle), - /* NewValue */ Any(Title) } }; - } catch(const curl_exception&) { - InteractiveIOException excep; - // any better possibility here? - // ( the error code is always CURLE_FTP_QUOTE_ERROR ) - excep.Code = IOErrorCode_ACCESS_DENIED; - retRange[i] <<= excep; - } - } else { - const Sequence<Property> props = - getProperties(Reference<XCommandEnvironment>(nullptr)); - - // either unknown or read-only - retRange[i] <<= UnknownPropertyException(); - const auto& rName = seqPropVal[i].Name; - auto pProp = std::find_if(props.begin(), props.end(), - [&rName](const Property& rProp) { return rProp.Name == rName; }); - if (pProp != props.end()) { - retRange[i] <<= IllegalAccessException( - "Property is read-only!", - //props[j].Attributes & PropertyAttribute::READONLY - // ? "Property is read-only!" - // : "Access denied!"), - getXWeak()); - } - } - } - - if(evt.hasElements()) { - // title has changed - notifyPropertiesChange(evt); - (void)exchange(new FTPContentIdentifier(m_aFTPURL.ident(false,false))); - } - - return ret; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/ftp/ftpcontent.hxx b/ucb/source/ucp/ftp/ftpcontent.hxx deleted file mode 100644 index 6eef6c30a5c6..000000000000 --- a/ucb/source/ucp/ftp/ftpcontent.hxx +++ /dev/null @@ -1,146 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#pragma once - -#include <ucbhelper/contenthelper.hxx> -#include <com/sun/star/ucb/InsertCommandArgument.hpp> -#include <com/sun/star/ucb/XContentCreator.hpp> -#include "ftpurl.hxx" - -namespace com::sun::star::beans { - struct Property; - struct PropertyValue; -} - -namespace com::sun::star::sdbc { - class XRow; -} - - -namespace ftp -{ - -class FTPContentProvider; - -class FTPContent : public ::ucbhelper::ContentImplHelper, - public css::ucb::XContentCreator -{ -public: - - FTPContent( const css::uno::Reference< - css::uno::XComponentContext >& rxContext, - FTPContentProvider* pProvider, - const css::uno::Reference< - css::ucb::XContentIdentifier >& Identifier, - const FTPURL& FtpUrl); - - FTPContent( const css::uno::Reference< - css::uno::XComponentContext >& rxContext, - FTPContentProvider* pProvider, - const css::uno::Reference< - css::ucb::XContentIdentifier >& Identifier, - css::ucb::ContentInfo aInfo); - - - virtual ~FTPContent() override; - - // XInterface - virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; - virtual void SAL_CALL acquire() - noexcept override; - virtual void SAL_CALL release() - noexcept override; - - // XTypeProvider - virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; - virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName() override; - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - - // XContent - virtual OUString SAL_CALL getContentType() override; - - // XCommandProcessor - virtual css::uno::Any SAL_CALL execute( const css::ucb::Command& aCommand, - sal_Int32 CommandId, - const css::uno::Reference< - css::ucb::XCommandEnvironment >& Environment ) override; - - virtual void SAL_CALL abort(sal_Int32 CommandId) override; - - // XContentCreator - virtual css::uno::Sequence< - css::ucb::ContentInfo > SAL_CALL - queryCreatableContentsInfo( ) override; - - virtual css::uno::Reference< - css::ucb::XContent > SAL_CALL - createNewContent( const css::ucb::ContentInfo& Info ) override; - - // XChild - - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override; - - virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override; - - /// @throws css::uno::RuntimeException - static css::uno::Sequence< css::ucb::ContentInfo > queryCreatableContentsInfo_Static(); - -private: - - FTPContentProvider *m_pFCP; - FTPURL m_aFTPURL; - bool m_bInserted; - bool m_bTitleSet; - css::ucb::ContentInfo m_aInfo; - - virtual css::uno::Sequence< css::beans::Property > - getProperties( const css::uno::Reference< - css::ucb::XCommandEnvironment > & xEnv ) override; - - - virtual css::uno::Sequence< css::ucb::CommandInfo> - getCommands(const css::uno::Reference< - css::ucb::XCommandEnvironment > & xEnv) override; - - - virtual OUString getParentURL() override; - - css::uno::Reference<css::sdbc::XRow> - getPropertyValues( - const css::uno::Sequence< - css::beans::Property>& seqProp - ); - - css::uno::Sequence<css::uno::Any> - setPropertyValues( const css::uno::Sequence< - css::beans::PropertyValue>& seqPropVal); - - void insert(const css::ucb::InsertCommandArgument&, - const css::uno::Reference< - css::ucb::XCommandEnvironment>&); - }; - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/ftp/ftpcontentcaps.cxx b/ucb/source/ucp/ftp/ftpcontentcaps.cxx deleted file mode 100644 index 64dd0e92d5a4..000000000000 --- a/ucb/source/ucp/ftp/ftpcontentcaps.cxx +++ /dev/null @@ -1,167 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <com/sun/star/beans/Property.hpp> -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/ucb/CommandInfo.hpp> -#include <com/sun/star/ucb/OpenCommandArgument2.hpp> -#include <com/sun/star/ucb/InsertCommandArgument.hpp> -#include <com/sun/star/util/DateTime.hpp> -#include <com/sun/star/uno/Sequence.hxx> - -#include "ftpcontent.hxx" - -using namespace com::sun::star; -using namespace ftp; - -// virtual -uno::Sequence< beans::Property > FTPContent::getProperties( - const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/) -{ - #define PROPS_COUNT 8 - - static const beans::Property aPropsInfoTable[] = - { - beans::Property( - "ContentType", - -1, - cppu::UnoType<OUString>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::READONLY - ), - beans::Property( - "IsDocument", - -1, - cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::READONLY - ), - beans::Property( - "IsFolder", - -1, - cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::READONLY - ), - beans::Property( - "Title", - -1, - cppu::UnoType<OUString>::get(), - beans::PropertyAttribute::BOUND - // | beans::PropertyAttribute::READONLY - ), - beans::Property( - "Size", - -1, - cppu::UnoType<sal_Int64>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::READONLY - ), - beans::Property( - "DateCreated", - -1, - cppu::UnoType<util::DateTime>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::READONLY - ), - beans::Property( - "IsReadOnly", - -1, - cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::READONLY - ), - beans::Property( - "CreatableContentsInfo", - -1, - cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::READONLY - ) - }; - - return uno::Sequence< beans::Property >( aPropsInfoTable, PROPS_COUNT ); -} - - -// virtual -uno::Sequence< ucb::CommandInfo > FTPContent::getCommands( - const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ ) -{ -// osl::MutexGuard aGuard( m_aMutex ); - - - // Supported commands - - - #define COMMAND_COUNT 8 - - static const ucb::CommandInfo aCommandInfoTable[] = - { - - // Required commands - - ucb::CommandInfo( - "getCommandInfo", - -1, - cppu::UnoType<void>::get() - ), - ucb::CommandInfo( - "getPropertySetInfo", - -1, - cppu::UnoType<void>::get() - ), - ucb::CommandInfo( - "getPropertyValues", - -1, - cppu::UnoType<uno::Sequence< beans::Property >>::get() - ), - ucb::CommandInfo( - "setPropertyValues", - -1, - cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get() - ), - ucb::CommandInfo( - "open", - -1, - cppu::UnoType<ucb::OpenCommandArgument2>::get() - ), - ucb::CommandInfo( - "insert", - -1, - cppu::UnoType<ucb::InsertCommandArgument>::get() - ), - ucb::CommandInfo( - "delete", - -1, - cppu::UnoType<bool>::get() - ), - ucb::CommandInfo( - "createNewContent", - -1, - cppu::UnoType<ucb::ContentInfo>::get() - ) - }; - - return uno::Sequence< ucb::CommandInfo >( aCommandInfoTable, COMMAND_COUNT ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/ftp/ftpcontentidentifier.cxx b/ucb/source/ucp/ftp/ftpcontentidentifier.cxx deleted file mode 100644 index b6df70ef7396..000000000000 --- a/ucb/source/ucp/ftp/ftpcontentidentifier.cxx +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -/************************************************************************** - TODO - ************************************************************************** - - *************************************************************************/ -#include <utility> - -#include "ftpcontentidentifier.hxx" - -using namespace ftp; -using namespace com::sun::star::uno; -using namespace com::sun::star::ucb; -using namespace com::sun::star::lang; - - -FTPContentIdentifier::FTPContentIdentifier( - OUString ident -) - : m_ident(std::move(ident)) -{ -} - - -FTPContentIdentifier::~FTPContentIdentifier() -{ -} - - -OUString SAL_CALL -FTPContentIdentifier::getContentIdentifier( -) -{ - return m_ident; -} - - -OUString SAL_CALL -FTPContentIdentifier::getContentProviderScheme( -) -{ - return "ftp"; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/ftp/ftpcontentidentifier.hxx b/ucb/source/ucp/ftp/ftpcontentidentifier.hxx deleted file mode 100644 index d5552559c7e4..000000000000 --- a/ucb/source/ucp/ftp/ftpcontentidentifier.hxx +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -/************************************************************************** - TODO - ************************************************************************** - - *************************************************************************/ -#pragma once - -#include <cppuhelper/implbase.hxx> -#include <com/sun/star/ucb/XContentIdentifier.hpp> - - -namespace ftp { - - class FTPContentIdentifier : - public cppu::WeakImplHelper<css::ucb::XContentIdentifier> - { - public: - - explicit FTPContentIdentifier(OUString ident); - - virtual ~FTPContentIdentifier() override; - - // XContentIdentifier - - virtual OUString SAL_CALL - getContentIdentifier() override; - - virtual OUString SAL_CALL - getContentProviderScheme() override; - - - private: - - OUString m_ident; - }; - -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/ftp/ftpcontentprovider.cxx b/ucb/source/ucp/ftp/ftpcontentprovider.cxx deleted file mode 100644 index 5200fcfd1acf..000000000000 --- a/ucb/source/ucp/ftp/ftpcontentprovider.cxx +++ /dev/null @@ -1,244 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <sal/config.h> - -#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> -#include <com/sun/star/ucb/IllegalIdentifierException.hpp> -#include <com/sun/star/ucb/UniversalContentBroker.hpp> -#include <cppuhelper/exc_hlp.hxx> -#include <cppuhelper/queryinterface.hxx> -#include <cppuhelper/typeprovider.hxx> -#include <cppuhelper/supportsservice.hxx> -#include <cppuhelper/weak.hxx> -#include "ftpcontentprovider.hxx" -#include "ftpcontent.hxx" -#include "ftploaderthread.hxx" - -using namespace ftp; -using namespace com::sun::star::lang; -using namespace com::sun::star::container; -using namespace com::sun::star::uno; -using namespace com::sun::star::ucb; -using namespace com::sun::star::beans; - -// ContentProvider Implementation. - -FTPContentProvider::FTPContentProvider( const Reference< XComponentContext >& rxContext) - : ::ucbhelper::ContentProviderImplHelper(rxContext) -{ -} - - -// virtual -FTPContentProvider::~FTPContentProvider() -{ - m_ftpLoaderThread.reset(); - m_pProxyDecider.reset(); -} - -// XInterface methods. -void SAL_CALL FTPContentProvider::acquire() - noexcept -{ - OWeakObject::acquire(); -} - -void SAL_CALL FTPContentProvider::release() - noexcept -{ - OWeakObject::release(); -} - -css::uno::Any SAL_CALL FTPContentProvider::queryInterface( const css::uno::Type & rType ) -{ - css::uno::Any aRet = cppu::queryInterface( rType, - static_cast< XTypeProvider* >(this), - static_cast< XServiceInfo* >(this), - static_cast< XContentProvider* >(this) - ); - return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); -} - -// XTypeProvider methods. -css::uno::Sequence< sal_Int8 > SAL_CALL FTPContentProvider::getImplementationId() -{ - return css::uno::Sequence<sal_Int8>(); -} - -css::uno::Sequence< css::uno::Type > SAL_CALL FTPContentProvider::getTypes() -{ - static cppu::OTypeCollection s_aCollection( - cppu::UnoType<XTypeProvider>::get(), - cppu::UnoType<XServiceInfo>::get(), - cppu::UnoType<XContentProvider>::get() - ); - - return s_aCollection.getTypes(); -} - - -// XServiceInfo methods. - -OUString SAL_CALL FTPContentProvider::getImplementationName() -{ - return "com.sun.star.comp.FTPContentProvider"; -} - -sal_Bool SAL_CALL FTPContentProvider::supportsService( const OUString& ServiceName ) -{ - return cppu::supportsService( this, ServiceName ); -} - -css::uno::Sequence< OUString > SAL_CALL FTPContentProvider::getSupportedServiceNames() -{ - return { FTP_CONTENT_PROVIDER_SERVICE_NAME }; -} - - - -// XContentProvider methods. - -// virtual -Reference<XContent> SAL_CALL FTPContentProvider::queryContent( - const Reference< XContentIdentifier >& xCanonicId) -{ - // Check, if a content with given id already exists... - Reference<XContent> xContent = queryExistingContent(xCanonicId); - if(xContent.is()) - return xContent; - - // A new content has to be returned: - { - // Initialize - osl::MutexGuard aGuard( m_aMutex ); - if(!m_ftpLoaderThread || !m_pProxyDecider) - { - try { - init(); - } catch (css::uno::Exception const & ex) { - css::uno::Any anyEx = cppu::getCaughtException(); - throw css::lang::WrappedTargetRuntimeException( ex.Message, - css::uno::Reference< css::uno::XInterface >(), - anyEx ); - } catch( ... ) { - throw RuntimeException(); - } - - if(!m_ftpLoaderThread || !m_pProxyDecider) - throw RuntimeException(); - } - } - - try { - FTPURL aURL(xCanonicId->getContentIdentifier(), - this); - - if(!m_pProxyDecider->shouldUseProxy( - "ftp", - aURL.host(), - aURL.port().toInt32())) - { - xContent = new FTPContent( m_xContext, this,xCanonicId,aURL); - registerNewContent(xContent); - } - else { - Reference<XContentProvider> xProvider(UniversalContentBroker::create( m_xContext )->queryContentProvider("http:")); - if(!xProvider.is()) - throw RuntimeException(); - return xProvider->queryContent(xCanonicId); - } - } catch(const malformed_exception&) { - throw IllegalIdentifierException(); - } - - // may throw IllegalIdentifierException - return xContent; -} - -void FTPContentProvider::init() -{ - m_ftpLoaderThread.reset( new FTPLoaderThread() ); - m_pProxyDecider.reset( new ucbhelper::InternetProxyDecider( m_xContext ) ); -} - -CURL* FTPContentProvider::handle() -{ - // Cannot be zero if called from here; - return m_ftpLoaderThread->handle(); -} - - -void FTPContentProvider::forHost( std::u16string_view host, - std::u16string_view port, - std::u16string_view username, - OUString& password, - OUString& account) -{ - osl::MutexGuard aGuard(m_aMutex); - for(const ServerInfo & i : m_ServerInfo) - if(host == i.host && - port == i.port && - username == i.username ) - { - password = i.password; - account = i.account; - return; - } -} - -bool FTPContentProvider::setHost( const OUString& host, - const OUString& port, - const OUString& username, - const OUString& password, - const OUString& account) -{ - ServerInfo inf; - inf.host = host; - inf.port = port; - inf.username = username; - inf.password = password; - inf.account = account; - - bool present(false); - osl::MutexGuard aGuard(m_aMutex); - for(ServerInfo & i : m_ServerInfo) - if(host == i.host && - port == i.port && - username == i.username) - { - present = true; - i.password = password; - i.account = account; - } - - if(!present) - m_ServerInfo.push_back(inf); - - return !present; -} - -extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* -ucb_ftp_FTPContentProvider_get_implementation( - css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) -{ - return cppu::acquire(new FTPContentProvider(context)); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/ftp/ftpcontentprovider.hxx b/ucb/source/ucp/ftp/ftpcontentprovider.hxx deleted file mode 100644 index 145fe15483c2..000000000000 --- a/ucb/source/ucp/ftp/ftpcontentprovider.hxx +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#pragma once - -#include <vector> -#include <ucbhelper/proxydecider.hxx> -#include <ucbhelper/providerhelper.hxx> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include "curl.hxx" - -// UNO service name for the provider. This name will be used by the UCB to -// create instances of the provider. - -inline constexpr OUString FTP_CONTENT_PROVIDER_SERVICE_NAME = u"com.sun.star.ucb.FTPContentProvider"_ustr; -inline constexpr OUString FTP_CONTENT_TYPE = u"application/ftp-content"_ustr; - -/** - * Definition of ftpcontentprovider - */ -namespace ftp -{ - class FTPLoaderThread; - - class FTPContentProvider: - public ::ucbhelper::ContentProviderImplHelper - { - public: - - explicit FTPContentProvider( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); - - virtual ~FTPContentProvider() override; - - // XInterface - virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; - virtual void SAL_CALL acquire() - noexcept override; - virtual void SAL_CALL release() - noexcept override; - - // XTypeProvider - virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; - virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName() override; - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - - // XContentProvider - virtual css::uno::Reference< css::ucb::XContent > SAL_CALL - queryContent( const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier ) override; - - CURL* handle(); - - /** host is in the form host:port. - */ - - void forHost(std::u16string_view host, - std::u16string_view port, - std::u16string_view username, - OUString& password, - OUString& account); - - bool setHost(const OUString& host, - const OUString& port, - const OUString& username, - const OUString& password, - const OUString& account); - - struct ServerInfo - { - OUString host; - OUString port; - OUString username; - OUString password; - OUString account; - }; - - private: - std::unique_ptr<FTPLoaderThread> m_ftpLoaderThread; - std::unique_ptr<ucbhelper::InternetProxyDecider> m_pProxyDecider; - std::vector<ServerInfo> m_ServerInfo; - - void init(); - }; // end class FTPContentProvider - -} // end namespace ftp - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/ftp/ftpdirp.cxx b/ucb/source/ucp/ftp/ftpdirp.cxx deleted file mode 100644 index 69bea64ab0e8..000000000000 --- a/ucb/source/ucp/ftp/ftpdirp.cxx +++ /dev/null @@ -1,1269 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -/************************************************************************** - TODO - ************************************************************************** - - *************************************************************************/ -#include "ftpdirp.hxx" -#include <osl/time.h> - - -using namespace ftp; - -static bool ascii_isWhitespace( sal_Unicode ch ) -{ - return ((ch <= 0x20) && ch); -} - - -/*======================================================================== - * - * FTPDirectoryParser implementation. - * - *======================================================================*/ -/* - * parseDOS. - * Accepts one of two styles: - * - * 1 *WSP 1*2DIGIT ("." / "-") 1*2DIGIT ("." / "-") 1*4DIGIT 1*WSP - * 1*2DIGIT ":" 1*2DIGIT [*WSP ("A" / "P") "M"] 1*WSP - * ((DIGIT *(DIGIT / "." / ",")) / "<DIR>") 1*WSP 1*OCTET - * - * interpreted as: mm.dd.yy hh:mm (size / <DIR>) name - * - * 2 *WSP 1*DIGIT 1*WSP *(1*CHAR *WSP) *1("DIR" 1*WSP) 1*2DIGIT "-" 1*2DIGIT - * "-" 1*4DIGIT 1*WSP 1*2DIGIT ":" 1*2DIGIT 1*WSP 1*OCTET - * - * interpreted as: size attribs DIR mm-dd-yy hh:mm name - */ - -bool FTPDirectoryParser::parseDOS ( - FTPDirentry &rEntry, - const char *pBuffer) -{ - bool bDirectory = false; - sal_uInt32 nSize = 0; - sal_uInt16 nYear = 0; - sal_uInt16 nMonth = 0; - sal_uInt16 nDay = 0; - sal_uInt16 nHour = 0; - sal_uInt16 nMinute = 0; - - enum StateType - { - STATE_INIT_LWS, - STATE_MONTH_OR_SIZE, - STATE_1_DAY, STATE_1_YEAR, STATE_1_YEAR_LWS, STATE_1_HOUR, - STATE_1_MINUTE, STATE_1_MINUTE_LWS, STATE_1_AP, - STATE_1_APM, STATE_1_LESS, STATE_1_D, STATE_1_DI, - STATE_1_DIR, STATE_1_SIZE, - STATE_2_SIZE, STATE_2_SIZE_LWS, STATE_2_ATTRIB, - STATE_2_D, STATE_2_DI, STATE_2_DIR_LWS, - STATE_2_MONTH, STATE_2_DAY, STATE_2_YEAR, STATE_2_YEAR_LWS, - STATE_2_HOUR, STATE_2_MINUTE, - STATE_LWS_NAME, - STATE_ERROR - }; - - int nDigits = 0; - enum StateType eState = STATE_INIT_LWS; - for (const char *p = pBuffer; - eState != STATE_ERROR && *p; - ++p) - { - switch (eState) - { - case STATE_INIT_LWS: - if (*p >= '0' && *p <= '9') - { - nMonth = *p - '0'; - nDigits = 1; - eState = STATE_MONTH_OR_SIZE; - } - else if (!ascii_isWhitespace(*p)) - eState = STATE_ERROR; - break; - - case STATE_MONTH_OR_SIZE: - if (*p >= '0' && *p <= '9') - { - nMonth = 10 * nMonth + (*p - '0'); - if (nDigits < 2) - ++nDigits; - else - { - nSize = nMonth; - nMonth = 0; - eState = STATE_2_SIZE; - } - } - else if (ascii_isWhitespace(*p)) - { - nSize = nMonth; - nMonth = 0; - eState = STATE_2_SIZE_LWS; - } - else if ((*p == '.' || *p == '-') && nMonth && nMonth <= 12) - { - nDigits = 0; - eState = STATE_1_DAY; - } - else - eState = STATE_ERROR; - break; - - case STATE_1_DAY: - if (*p >= '0' && *p <= '9') - if (nDigits < 2) - { - nDay = 10 * nDay + (*p - '0'); - ++nDigits; - } - else - eState = STATE_ERROR; - else if ((*p == '.' || *p == '-') && nDay && nDay <= 31) - { - nDigits = 0; - eState = STATE_1_YEAR; - } - else - eState = STATE_ERROR; - break; - - case STATE_1_YEAR: - if (*p >= '0' && *p <= '9') - { - if (nDigits < 4) - { - nYear = 10 * nYear + (*p - '0'); - ++nDigits; - } - else - eState = STATE_ERROR; - } - else - { - if (ascii_isWhitespace(*p)) - eState = STATE_1_YEAR_LWS; - else - eState = STATE_ERROR; - } - break; - - case STATE_1_YEAR_LWS: - if (*p >= '0' && *p <= '9') - { - nHour = *p - '0'; - nDigits = 1; - eState = STATE_1_HOUR; - } - else if (!ascii_isWhitespace(*p)) - eState = STATE_ERROR; - break; - - case STATE_1_HOUR: - if (*p >= '0' && *p <= '9') - if (nDigits < 2) - { - nHour = 10 * nHour + (*p - '0'); - ++nDigits; - } - else - eState = STATE_ERROR; - else if (*p == ':' && nHour < 24) - { - nDigits = 0; - eState = STATE_1_MINUTE; - } - else - eState = STATE_ERROR; - break; - - case STATE_1_MINUTE: - if (*p >= '0' && *p <= '9') - if (nDigits < 2) - { - nMinute = 10 * nMinute + (*p - '0'); - ++nDigits; - } - else - eState = STATE_ERROR; - else if ((*p == 'a' || *p == 'A') && nMinute < 60) - if (nHour >= 1 && nHour <= 11) - eState = STATE_1_AP; - else if (nHour == 12) - { - nHour = 0; - eState = STATE_1_AP; - } - else - eState = STATE_ERROR; - else if ((*p == 'p' || *p == 'P') && nMinute < 60) - if (nHour >= 1 && nHour <= 11) - { - nHour += 12; - eState = STATE_1_AP; - } - else if (nHour == 12) - eState = STATE_1_AP; - else - eState = STATE_ERROR; - else if (ascii_isWhitespace(*p) && (nMinute < 60)) - eState = STATE_1_MINUTE_LWS; - else - eState = STATE_ERROR; - break; - - case STATE_1_MINUTE_LWS: - if (*p == 'a' || *p == 'A') - if (nHour >= 1 && nHour <= 11) - eState = STATE_1_AP; - else if (nHour == 12) - { - nHour = 0; - eState = STATE_1_AP; - } - else - eState = STATE_ERROR; - else if (*p == 'p' || *p == 'P') - if (nHour >= 1 && nHour <= 11) - { - nHour += 12; - eState = STATE_1_AP; - } - else if (nHour == 12) - eState = STATE_1_AP; - else - eState = STATE_ERROR; - else if (*p == '<') - eState = STATE_1_LESS; - else if (*p >= '0' && *p <= '9') - { - nSize = *p - '0'; - eState = STATE_1_SIZE; - } - else if (!ascii_isWhitespace(*p)) - eState = STATE_ERROR; - break; - - case STATE_1_AP: - eState = *p == 'm' || *p == 'M' ? STATE_1_APM : STATE_ERROR; - break; - - case STATE_1_APM: - if (*p == '<') - eState = STATE_1_LESS; - else if (*p >= '0' && *p <= '9') - { - nSize = *p - '0'; - eState = STATE_1_SIZE; - } - else if (!ascii_isWhitespace(*p)) - eState = STATE_ERROR; - break; - - case STATE_1_LESS: - eState = *p == 'd' || *p == 'D' ? STATE_1_D : STATE_ERROR; - break; - - case STATE_1_D: - eState = *p == 'i' || *p == 'I' ? STATE_1_DI : STATE_ERROR; - break; - - case STATE_1_DI: - eState = *p == 'r' || *p == 'R' ? STATE_1_DIR : STATE_ERROR; - break; - - case STATE_1_DIR: - if (*p == '>') - { - bDirectory = true; - eState = STATE_LWS_NAME; - } - else - eState = STATE_ERROR; - break; - - case STATE_1_SIZE: - if (*p >= '0' && *p <= '9') - nSize = 10 * nSize + (*p - '0'); - else if (ascii_isWhitespace(*p)) - eState = STATE_LWS_NAME; - else - eState = STATE_ERROR; - break; - - case STATE_2_SIZE: - if (*p >= '0' && *p <= '9') - nSize = 10 * nSize + (*p - '0'); - else if (ascii_isWhitespace(*p)) - eState = STATE_2_SIZE_LWS; - else - eState = STATE_ERROR; - break; - - case STATE_2_SIZE_LWS: - if (*p == 'd' || *p == 'D') - eState = STATE_2_D; - else if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z')) - eState = STATE_2_ATTRIB; - else if (*p >= '0' && *p <= '9') - { - nMonth = *p - '0'; - nDigits = 1; - eState = STATE_2_MONTH; - } - else if (!ascii_isWhitespace(*p)) - eState = STATE_ERROR; - break; - - case STATE_2_ATTRIB: - if (ascii_isWhitespace(*p)) - eState = STATE_2_SIZE_LWS; - else if ((*p < 'a' || *p > 'z') && (*p < 'A' || *p > 'Z')) - eState = STATE_ERROR; - break; - - case STATE_2_D: - if (*p == 'i' || *p == 'I') - eState = STATE_2_DI; - else if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z')) - eState = STATE_2_ATTRIB; - else if (ascii_isWhitespace(*p)) - eState = STATE_2_SIZE_LWS; - else - eState = STATE_ERROR; - break; - - case STATE_2_DI: - if (*p == 'r' || *p == 'R') - { - bDirectory = true; - eState = STATE_2_DIR_LWS; - } - else - { - if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z')) - eState = STATE_2_ATTRIB; - else if (ascii_isWhitespace(*p)) - eState = STATE_2_SIZE_LWS; - else - eState = STATE_ERROR; - } - break; - - case STATE_2_DIR_LWS: - if (*p >= '0' && *p <= '9') - { - nMonth = *p - '0'; - nDigits = 1; - eState = STATE_2_MONTH; - } - else if (!ascii_isWhitespace(*p)) - eState = STATE_ERROR; - break; - - case STATE_2_MONTH: - if (*p >= '0' && *p <= '9') - if (nDigits < 2) - { - nMonth = 10 * nMonth + (*p - '0'); - ++nDigits; - } - else - eState = STATE_ERROR; - else if (*p == '-' && nMonth && nMonth <= 12) - { - nDigits = 0; - eState = STATE_2_DAY; - } - else - eState = STATE_ERROR; - break; - - case STATE_2_DAY: - if (*p >= '0' && *p <= '9') - if (nDigits < 2) - { - nDay = 10 * nDay + (*p - '0'); - ++nDigits; - } - else - eState = STATE_ERROR; - else if (*p == '-' && nDay && nDay <= 31) - { - nDigits = 0; - eState = STATE_2_YEAR; - } - else - eState = STATE_ERROR; - break; - - case STATE_2_YEAR: - if (*p >= '0' && *p <= '9') - { - if (nDigits < 4) - { - nYear = 10 * nYear + (*p - '0'); - ++nDigits; - } - else - eState = STATE_ERROR; - } - else - { - if (ascii_isWhitespace(*p)) - eState = STATE_2_YEAR_LWS; - else - eState = STATE_ERROR; - } - break; - - case STATE_2_YEAR_LWS: - if (*p >= '0' && *p <= '9') - { - nHour = *p - '0'; - nDigits = 1; - eState = STATE_2_HOUR; - } - else if (!ascii_isWhitespace(*p)) - eState = STATE_ERROR; - break; - - case STATE_2_HOUR: - if (*p >= '0' && *p <= '9') - if (nDigits < 2) - { - nHour = 10 * nHour + (*p - '0'); - ++nDigits; - } - else - eState = STATE_ERROR; - else if (*p == ':' && nHour < 24) - { - nDigits = 0; - eState = STATE_2_MINUTE; - } - else - eState = STATE_ERROR; - break; - - case STATE_2_MINUTE: - if (*p >= '0' && *p <= '9') - { - if (nDigits < 2) - { - nMinute = 10 * nMinute + (*p - '0'); - ++nDigits; - } - else ... etc. - the rest is truncated