summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorAndreas Bille <abi@openoffice.org>2002-07-31 14:13:44 +0000
committerAndreas Bille <abi@openoffice.org>2002-07-31 14:13:44 +0000
commit398ba30e1dae68404e47715f29bec2cd5f115213 (patch)
treeeaac38baa2305b3b1ef15f856a5efe680d6cde76 /ucb
parentb7de4d0960e007dd578760c39f5bfbb9806851ef (diff)
Saving the code
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/ftp/ftpcontent.cxx358
-rw-r--r--ucb/source/ucp/ftp/ftpcontent.hxx18
-rw-r--r--ucb/source/ucp/ftp/ftpcontentcaps.cxx183
-rw-r--r--ucb/source/ucp/ftp/ftpcontentidentifier.cxx63
-rw-r--r--ucb/source/ucp/ftp/ftpcontentidentifier.hxx60
-rw-r--r--ucb/source/ucp/ftp/ftpcontentprovider.cxx18
-rw-r--r--ucb/source/ucp/ftp/ftpdirp.cxx1310
-rw-r--r--ucb/source/ucp/ftp/ftpdirp.hxx226
-rw-r--r--ucb/source/ucp/ftp/ftpdynresultset.cxx127
-rw-r--r--ucb/source/ucp/ftp/ftpdynresultset.hxx106
-rw-r--r--ucb/source/ucp/ftp/ftpinpstr.cxx70
-rw-r--r--ucb/source/ucp/ftp/ftpinpstr.hxx26
-rw-r--r--ucb/source/ucp/ftp/ftploaderthread.hxx9
-rw-r--r--ucb/source/ucp/ftp/ftpresultsetI.cxx259
-rw-r--r--ucb/source/ucp/ftp/ftpresultsetI.hxx105
-rw-r--r--ucb/source/ucp/ftp/ftpresultsetbase.cxx710
-rw-r--r--ucb/source/ucp/ftp/ftpresultsetbase.hxx669
-rw-r--r--ucb/source/ucp/ftp/ftpresultsetfactory.hxx27
-rw-r--r--ucb/source/ucp/ftp/makefile.mk33
-rw-r--r--ucb/source/ucp/ftp/test.cxx174
-rw-r--r--ucb/source/ucp/ftp/test_activedatasink.cxx28
-rw-r--r--ucb/source/ucp/ftp/test_activedatasink.hxx62
-rw-r--r--ucb/source/ucp/ftp/test_multiservicefac.cxx78
-rw-r--r--ucb/source/ucp/ftp/test_multiservicefac.hxx69
24 files changed, 4636 insertions, 152 deletions
diff --git a/ucb/source/ucp/ftp/ftpcontent.cxx b/ucb/source/ucp/ftp/ftpcontent.cxx
index 7fa09380a95b..31e9c5c58f2e 100644
--- a/ucb/source/ucp/ftp/ftpcontent.cxx
+++ b/ucb/source/ucp/ftp/ftpcontent.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ftpcontent.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: abi $ $Date: 2002-06-24 15:17:55 $
+ * last change: $Author: abi $ $Date: 2002-07-31 15:12:53 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,45 +65,33 @@
*************************************************************************/
-#ifndef _FTP_FTPCONTENT_HXX_
+#include <memory>
+#include <vector>
+#include "ftpdynresultset.hxx"
+#include "ftpresultsetfactory.hxx"
+#include "ftpresultsetI.hxx"
#include "ftpcontent.hxx"
-#endif
-#ifndef _FTP_FTPCONTENTPROVIDER_HXX_
#include "ftpcontentprovider.hxx"
-#endif
-#ifndef _FTP_FTPLOADERTHREAD_HXX_
#include "ftploaderthread.hxx"
-#endif
-#ifndef _FTP_FTPINPSTR_HXX_
#include "ftpinpstr.hxx"
-#endif
-#ifndef __CURL_CURL_H
+#include "ftpdirp.hxx"
+
#include <curl/curl.h>
-#endif
-#ifndef __CURL_EASY_H
#include <curl/easy.h>
-#endif
-#ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_
+#include <ucbhelper/cancelcommandexecution.hxx>
+#include <ucbhelper/contentidentifier.hxx>
+#include <ucbhelper/propertyvalueset.hxx>
+#include <ucbhelper/cancelcommandexecution.hxx>
#include <com/sun/star/beans/Property.hpp>
-#endif
-#ifndef _COM_SUN_STAR_UCB_COMMANDINFO_HPP_
-#include <com/sun/star/ucb/CommandInfo.hpp>
-#endif
-#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_
+#include <com/sun/star/ucb/XCommandInfo.hpp>
#include <com/sun/star/io/XActiveDataSink.hpp>
-#endif
-#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
#include <com/sun/star/io/XOutputStream.hpp>
-#endif
-#ifndef _COM_SUN_STAR_IO_XACTIVEDATASTREAMER_HPP_
#include <com/sun/star/io/XActiveDataStreamer.hpp>
-#endif
-#ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDDATASINKEXCEPTION_HPP_
#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
-#endif
-#ifndef _COM_SUN_STAR_UCB_OPENCOMMANDARGUMENT2_HPP_
#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
-#endif
+#include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
+#include <com/sun/star/ucb/OpenMode.hpp>
+
using namespace ftp;
using namespace com::sun::star::lang;
@@ -111,6 +99,7 @@ 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;
//=========================================================================
@@ -171,8 +160,10 @@ XTYPEPROVIDER_IMPL_4( FtpContent,
#define XSERVICEINFO_CREATE_INSTANCE_IMPL( Class )
XSERVICEINFO_IMPL_1( FtpContent,
- rtl::OUString::createFromAscii("com.sun.star.comp.FtpContent"),
- rtl::OUString::createFromAscii("com.sun.star.ucb.FtpContent"));
+ rtl::OUString::createFromAscii(
+ "com.sun.star.comp.FtpContent"),
+ rtl::OUString::createFromAscii(
+ "com.sun.star.ucb.FtpContent"));
@@ -233,7 +224,7 @@ extern "C" {
FtpBufferContainer *p = reinterpret_cast<FtpBufferContainer*>(stream);
if(p && p->m_out)
- p->m_out->append(buffer,ret);
+ p->m_out->append(buffer,size,nmemb);
return ret;
}
@@ -252,8 +243,10 @@ extern "C" {
try{
StreamContainer *p = reinterpret_cast<StreamContainer*>(stream);
if(p && p->m_out.is())
- p->m_out->writeBytes(Sequence<sal_Int8>(static_cast<sal_Int8*>(buffer),
- size*nmemb));
+ p->m_out->writeBytes(
+ Sequence<sal_Int8>(static_cast<sal_Int8*>(buffer),
+ size*nmemb)
+ );
return ret;
} catch(const Exception&) {
return 0;
@@ -265,53 +258,242 @@ extern "C" {
#endif
-// virtual
-Any SAL_CALL FtpContent::execute( const Command& aCommand,
- sal_Int32 CommandId,
- const Reference<
- XCommandEnvironment >& Environment )
- throw( Exception, CommandAbortedException, RuntimeException )
+
+class ResultSetFactoryI
+ : public ResultSetFactory
{
+public:
+
+ ResultSetFactoryI(const Reference<XMultiServiceFactory >& xSMgr,
+ const Reference<XContentProvider >& xProvider,
+ sal_Int32 nOpenMode,
+ const Sequence<Property>& seq,
+ const Sequence<NumberedSortingInfo>& seqSort,
+ const std::vector<FTPDirentry>& dirvec)
+ : m_xSMgr(xSMgr),
+ m_xProvider(xProvider),
+ m_nOpenMode(nOpenMode),
+ m_seq(seq),
+ m_seqSort(seqSort),
+ m_dirvec(dirvec)
+ {
+ }
+
+ virtual ResultSetBase* createResultSet()
+ {
+ return new ResultSetI(m_xSMgr,
+ m_xProvider,
+ m_nOpenMode,
+ m_seq,
+ m_seqSort,
+ m_dirvec);
+ }
+public:
+
+ Reference< XMultiServiceFactory > m_xSMgr;
+ Reference< XContentProvider > m_xProvider;
+ sal_Int32 m_nOpenMode;
+ Sequence< Property > m_seq;
+ Sequence< NumberedSortingInfo > m_seqSort;
+ std::vector<FTPDirentry> m_dirvec;
+};
+
+
+
+
+
+// virtual
+Any SAL_CALL FtpContent::execute(
+ const Command& aCommand,
+ sal_Int32 CommandId,
+ const Reference<
+ XCommandEnvironment >& Environment
+)
+ throw(
+ Exception,
+ CommandAbortedException,
+ RuntimeException
+ )
+{
Any aRet;
- if( aCommand.Name.compareToAscii( "getPropertyValues" ) == 0 ) {
+ if(aCommand.Name.compareToAscii("getPropertyValues") == 0) {
+ Sequence< Property > Properties;
+ if(!( aCommand.Argument >>= Properties))
+ {
+ aRet <<= IllegalArgumentException();
+ ucbhelper::cancelCommandExecution(aRet,Environment);
+ }
+
+ aRet <<= getPropertyValues(Properties);
+ }
+ else if(aCommand.Name.compareToAscii("setPropertyValues") == 0) {
+ }
+ else if(aCommand.Name.compareToAscii("getCommandInfo") == 0) {
+ // Note: Implemented by base class.
+ aRet <<= getCommandInfo(Environment);
+ }
+ else if(aCommand.Name.compareToAscii("getPropertySetInfo") == 0) {
+ // Note: Implemented by base class.
+ aRet <<= getPropertySetInfo(Environment);
}
else if ( aCommand.Name.compareToAscii( "open" ) == 0 ) {
OpenCommandArgument2 aOpenCommand;
- if ( !( aCommand.Argument >>= aOpenCommand ) )
- throw IllegalArgumentException();
+ if ( !( aCommand.Argument >>= aOpenCommand ) ) {
+ aRet <<= IllegalArgumentException();
+ ucbhelper::cancelCommandExecution(aRet,Environment);
+ }
- Reference< XActiveDataStreamer > activeDataStreamer( aOpenCommand.Sink,UNO_QUERY );
- if(activeDataStreamer.is())
- throw UnsupportedDataSinkException();
CURL *curl = m_pFCP->handle();
- /** Now setting the URL
- */
+ // Setting the header write function,
+ // which receives the output of the control connection.
+
+ std::auto_ptr<FtpInputStream> header(new FtpInputStream());
+ FtpBufferContainer headerContainer(header.get());
+
+ curl_easy_setopt(curl,CURLOPT_HEADERFUNCTION,write2InputStream);
+ curl_easy_setopt(curl,CURLOPT_WRITEHEADER,&headerContainer);
+
+
+ // Now setting the URL
rtl::OUString aOUStr(m_xIdentifier->getContentIdentifier());
rtl::OString aOStr(aOUStr.getStr(),
aOUStr.getLength(),
- RTL_TEXTENCODING_UTF8); // Only ASCII in URLs => UTF8 ok
+ RTL_TEXTENCODING_UTF8); // Only ASCII in URLs
+ // // => UTF8 ok
+
curl_easy_setopt(curl,CURLOPT_URL,aOStr.getStr());
- Reference<XActiveDataSink> activeDataSink(aOpenCommand.Sink,UNO_QUERY);
- if(activeDataSink.is()) {
- FtpBufferContainer cont(new FtpInputStream());
+ 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()) {
+ FtpBufferContainer cont(new FtpInputStream());
+ curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,write2InputStream);
+ curl_easy_setopt(curl,CURLOPT_WRITEDATA,&cont);
+ curl_easy_perform(curl);
+ xActiveDataSink->setInputStream(cont.m_out);
+ }
+ else if(xOutputStream.is()) {
+ StreamContainer cont(xOutputStream);
+ curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,
+ write2OutputStream);
+ curl_easy_setopt(curl,CURLOPT_WRITEDATA,&cont);
+ curl_easy_perform(curl);
+ }
+ else {
+ aRet <<= UnsupportedDataSinkException();
+ ucbhelper::cancelCommandExecution(aRet,Environment);
+ }
+ }
+ else if(aOpenCommand.Mode == OpenMode::ALL ||
+ aOpenCommand.Mode == OpenMode::DOCUMENTS ||
+ aOpenCommand.Mode == OpenMode::FOLDERS ) {
+ std::auto_ptr<FtpInputStream> ap(new FtpInputStream());
+ FtpBufferContainer cont(ap.get());
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,write2InputStream);
curl_easy_setopt(curl,CURLOPT_WRITEDATA,&cont);
curl_easy_perform(curl);
- activeDataSink->setInputStream(cont.m_out);
- }
- Reference< XOutputStream > xOutputStream(aOpenCommand.Sink,UNO_QUERY);
- if(xOutputStream.is()) {
- StreamContainer cont(xOutputStream);
- curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,write2OutputStream);
- curl_easy_setopt(curl,CURLOPT_WRITEDATA,&cont);
- curl_easy_perform(curl);
+ rtl::OUString aStr((char*)header.get()->getBuffer(),
+ sal_Int32(header.get()->getLength()),
+ RTL_TEXTENCODING_UTF8);
+
+ // Now parse the content.
+ // Parsing is here somewhat ugly, because
+ // the regular expression does not forward
+ // the pointer to end of parsed expression.
+
+ sal_uInt32 len = (sal_uInt32) ap.get()->getLength();
+ char* fwd = (char*) ap.get()->getBuffer();
+ char *p1, *p2;
+ p1 = p2 = fwd;
+
+ enum OS { DOS,UNIX,VMS,UNKNOWN };
+ OS osKind(UNKNOWN);
+ std::vector<FTPDirentry> resvec;
+ FTPDirentry aDirEntry;
+
+ while(true) {
+ while(p2-fwd < int(len) && *p2 != '\n') ++p2;
+ if(p2-fwd == int(len)) break;
+
+ *p2 = 0;
+ switch(osKind) {
+ case DOS:
+ FTPDirectoryParser::parseDOS(aDirEntry,p1);
+ break;
+ case UNIX:
+ FTPDirectoryParser::parseUNIX(aDirEntry,p1);
+ break;
+ case VMS:
+ FTPDirectoryParser::parseUNIX(aDirEntry,p1);
+ break;
+ default:
+ if(FTPDirectoryParser::parseUNIX(aDirEntry,p1))
+ osKind = UNIX;
+ else if(FTPDirectoryParser::parseDOS(aDirEntry,p1))
+ osKind = DOS;
+ else if(FTPDirectoryParser::parseVMS(aDirEntry,p1))
+ osKind = VMS;
+ }
+ if(osKind != int(UNKNOWN)) {
+ if(1 + aOUStr.lastIndexOf(sal_Unicode('/')) ==
+ aOUStr.getLength())
+ aDirEntry.m_aURL =
+ aOUStr +
+ aDirEntry.m_aName;
+ else
+ aDirEntry.m_aURL =
+ aOUStr +
+ sal_Unicode('/') +
+ aDirEntry.m_aName;
+
+ resvec.push_back(aDirEntry);
+ aDirEntry.clear();
+ }
+
+ p1 = p2 + 1;
+ }
+
+ if(osKind == int(UNKNOWN)) {
+ // Ok, this was not a directory, but a file
+ //todo: Check here wether our parent lists our name
+ }
+ else {
+ Reference< XDynamicResultSet > xSet
+ = new DynamicResultSet(
+ m_xSMgr,
+ this,
+ aOpenCommand,
+ Environment,
+ new ResultSetFactoryI(m_xSMgr,
+ m_xProvider.getBodyPtr(),
+ aOpenCommand.Mode,
+ aOpenCommand.Properties,
+ aOpenCommand.SortingInfo,
+ resvec));
+ aRet <<= xSet;
+ }
+ }
+ else if(aOpenCommand.Mode == OpenMode::DOCUMENT_SHARE_DENY_NONE ||
+ aOpenCommand.Mode == OpenMode::DOCUMENT_SHARE_DENY_WRITE) {
+ // Unsupported OpenMode
+ aRet <<= UnsupportedOpenModeException();
+ ucbhelper::cancelCommandExecution(aRet,Environment);
+ }
+ else {
+ // IllegalArgumentException:: No OpenMode
+ aRet <<= IllegalArgumentException();
+ ucbhelper::cancelCommandExecution(aRet,Environment);
}
}
else
@@ -321,30 +503,54 @@ Any SAL_CALL FtpContent::execute( const Command& aCommand,
}
-// curl_easy_setopt(curl,CURLOPT_HEADERFUNCTION,write2OutputStream);
-// curl_easy_setopt(curl,CURLOPT_WRITEHEADER,&cont);
-
-
// curl_slist_free_all(list);
-Sequence<Property> FtpContent::getProperties(const Reference<XCommandEnvironment>& xEnv)
-{
- Sequence<Property> ret(0);
- return ret;
-}
-
-
-Sequence<CommandInfo> FtpContent::getCommands(const Reference<XCommandEnvironment> & xEnv)
+rtl::OUString FtpContent::getParentURL()
{
- return Sequence<CommandInfo>(0);
+ return rtl::OUString();
}
-rtl::OUString FtpContent::getParentURL()
+Reference< XRow > FtpContent::getPropertyValues(
+ const Sequence< Property >& seqProp
+)
{
- return rtl::OUString();
-}
+ FTPDirentry aDirEntry;
+ vos::ORef<::ucb::PropertyValueSet> xRow =
+ new ::ucb::PropertyValueSet(m_xSMgr);
+
+ for(sal_Int32 i = 0; i < seqProp.getLength(); ++i) {
+ const rtl::OUString& Name = seqProp[i].Name;
+ if(Name.compareToAscii("ContentType") == 0)
+ xRow->appendString(seqProp[i],
+ rtl::OUString::createFromAscii(
+ "application/ftp"));
+ else if(Name.compareToAscii("Title") == 0)
+ xRow->appendString(seqProp[i],aDirEntry.m_aName);
+ else if(Name.compareToAscii("IsReadOnly") == 0)
+ xRow->appendBoolean(seqProp[i],
+ sal_Bool(aDirEntry.m_nMode &
+ INETCOREFTP_FILEMODE_WRITE));
+ else if(Name.compareToAscii("IsDocument") == 0)
+ xRow->appendBoolean(seqProp[i],
+ ! sal_Bool(aDirEntry.m_nMode &
+ INETCOREFTP_FILEMODE_ISDIR));
+ else if(Name.compareToAscii("IsFolder") == 0)
+ xRow->appendBoolean(seqProp[i],
+ sal_Bool(aDirEntry.m_nMode &
+ INETCOREFTP_FILEMODE_ISDIR));
+ else if(Name.compareToAscii("Size") == 0)
+ xRow->appendLong(seqProp[i],
+ aDirEntry.m_nSize);
+ else if(Name.compareToAscii("DateCreated") == 0)
+ xRow->appendTimestamp(seqProp[i],
+ aDirEntry.m_aDate);
+ else
+ xRow->appendVoid(seqProp[i]);
+ }
+ return Reference<XRow>(xRow.getBodyPtr());
+}
diff --git a/ucb/source/ucp/ftp/ftpcontent.hxx b/ucb/source/ucp/ftp/ftpcontent.hxx
index 81efcf09b35f..b9f140ec8325 100644
--- a/ucb/source/ucp/ftp/ftpcontent.hxx
+++ b/ucb/source/ucp/ftp/ftpcontent.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ftpcontent.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: abi $ $Date: 2002-06-20 14:49:21 $
+ * last change: $Author: abi $ $Date: 2002-07-31 15:12:55 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -159,12 +159,20 @@ namespace ftp
com::sun::star::ucb::XCommandEnvironment > & xEnv );
- virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
- getCommands( const com::sun::star::uno::Reference<
- com::sun::star::ucb::XCommandEnvironment > & xEnv );
+ virtual com::sun::star::uno::Sequence<
+ com::sun::star::ucb::CommandInfo>
+ getCommands(const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XCommandEnvironment > & xEnv);
virtual ::rtl::OUString getParentURL();
+
+ com::sun::star::uno::Reference<com::sun::star::sdbc::XRow>
+ getPropertyValues(
+ const com::sun::star::uno::Sequence<
+ com::sun::star::beans::Property>& seqProp
+ );
+
};
}
diff --git a/ucb/source/ucp/ftp/ftpcontentcaps.cxx b/ucb/source/ucp/ftp/ftpcontentcaps.cxx
new file mode 100644
index 000000000000..b0e498ca1678
--- /dev/null
+++ b/ucb/source/ucp/ftp/ftpcontentcaps.cxx
@@ -0,0 +1,183 @@
+/*************************************************************************
+ *
+ * $RCSfile: ftpcontentcaps.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: abi $ $Date: 2002-07-31 15:12:57 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#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/util/DateTime.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include "ftpcontent.hxx"
+
+using namespace com::sun::star::beans;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::util;
+using namespace rtl;
+
+using namespace ftp;
+
+// virtual
+Sequence< Property > FtpContent::getProperties(
+ const Reference< XCommandEnvironment > & xEnv
+)
+{
+ Sequence< Property > props(6);
+
+ props[0] =
+ Property(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
+ -1,
+ getCppuType( static_cast< const OUString * >( 0 ) ),
+ PropertyAttribute::BOUND | PropertyAttribute::READONLY );
+
+ props[1] =
+ Property(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
+ -1,
+ getCppuBooleanType(),
+ PropertyAttribute::BOUND | PropertyAttribute::READONLY );
+
+ props[2] =
+ Property(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
+ -1,
+ getCppuBooleanType(),
+ PropertyAttribute::BOUND | PropertyAttribute::READONLY );
+
+ props[3] =
+ Property(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
+ -1,
+ getCppuType( static_cast< const OUString * >( 0 ) ),
+ PropertyAttribute::BOUND | PropertyAttribute::READONLY );
+
+ props[4] =
+ Property(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ),
+ -1,
+ getCppuType( static_cast< const sal_Int64 * >( 0 ) ),
+ PropertyAttribute::BOUND | PropertyAttribute::READONLY );
+
+ props[5] =
+ Property(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ),
+ -1,
+ getCppuType( static_cast< DateTime* >( 0 ) ),
+ PropertyAttribute::BOUND | PropertyAttribute::READONLY );
+
+ return props;
+}
+
+
+
+//=========================================================================
+// virtual
+Sequence< CommandInfo > FtpContent::getCommands(
+ const Reference< XCommandEnvironment > & xEnv )
+{
+// osl::MutexGuard aGuard( m_aMutex );
+
+ //=================================================================
+ //
+ // Supported commands
+ //
+ //=================================================================
+
+#define COMMAND_COUNT 5
+
+ static CommandInfo aCommandInfoTable[] =
+ {
+ ///////////////////////////////////////////////////////////////
+ // Required commands
+ ///////////////////////////////////////////////////////////////
+ CommandInfo(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
+ -1,
+ getCppuVoidType()
+ ),
+ CommandInfo(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
+ -1,
+ getCppuVoidType()
+ ),
+ CommandInfo(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
+ -1,
+ getCppuType( static_cast< Sequence< Property > * >( 0 ) )
+ ),
+ CommandInfo(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
+ -1,
+ getCppuType( static_cast< Sequence< PropertyValue > * >( 0 ) )
+ ),
+ CommandInfo(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
+ -1,
+ getCppuType( static_cast< OpenCommandArgument2 * >( 0 ) )
+ )
+ };
+
+ return Sequence<CommandInfo>(aCommandInfoTable,COMMAND_COUNT);
+}
+
diff --git a/ucb/source/ucp/ftp/ftpcontentidentifier.cxx b/ucb/source/ucp/ftp/ftpcontentidentifier.cxx
new file mode 100644
index 000000000000..05188fd4e19e
--- /dev/null
+++ b/ucb/source/ucp/ftp/ftpcontentidentifier.cxx
@@ -0,0 +1,63 @@
+#include "ftpcontentidentifier.hxx"
+
+
+
+using namespace ftp;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::ucb;
+
+
+FtpContentIdentifier::FtpContentIdentifier(const rtl::OUString& aIdent)
+ : m_aIdent(aIdent)
+{
+}
+
+
+Any SAL_CALL
+FtpContentIdentifier::queryInterface(
+ const Type& rType
+)
+ throw(
+ RuntimeException
+ )
+{
+ Any aRet = ::cppu::queryInterface(rType,
+ SAL_STATIC_CAST(XContentIdentifier*,this));
+
+ return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
+}
+
+
+
+void SAL_CALL FtpContentIdentifier::acquire( void ) throw() {
+ OWeakObject::acquire();
+}
+
+
+
+void SAL_CALL FtpContentIdentifier::release( void ) throw() {
+ OWeakObject::release();
+}
+
+
+::rtl::OUString SAL_CALL
+FtpContentIdentifier::getContentIdentifier(
+)
+ throw (
+ ::com::sun::star::uno::RuntimeException
+ )
+{
+ return m_aIdent;
+}
+
+
+::rtl::OUString SAL_CALL
+FtpContentIdentifier::getContentProviderScheme(
+)
+ throw (
+ ::com::sun::star::uno::RuntimeException
+ )
+{
+ return rtl::OUString::createFromAscii("ftp");
+}
+
diff --git a/ucb/source/ucp/ftp/ftpcontentidentifier.hxx b/ucb/source/ucp/ftp/ftpcontentidentifier.hxx
new file mode 100644
index 000000000000..d9859ccb5455
--- /dev/null
+++ b/ucb/source/ucp/ftp/ftpcontentidentifier.hxx
@@ -0,0 +1,60 @@
+#ifndef _FTP_FTPCONTENTIDENTIFIER_HXX_
+#define _FTP_FTPCONTENTIDENTIFIER_HXX_
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENTIDENTIFIER_HPP_
+#include <com/sun/star/ucb/XContentIdentifier.hpp>
+#endif
+
+
+namespace ftp {
+
+ class FtpContentIdentifier
+ : public cppu::OWeakObject,
+ public com::sun::star::ucb::XContentIdentifier
+ {
+ public:
+
+ FtpContentIdentifier(const rtl::OUString& ident);
+
+ // XInterface
+
+ virtual com::sun::star::uno::Any SAL_CALL
+ queryInterface( const com::sun::star::uno::Type& rType )
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL acquire( void ) throw();
+
+ virtual void SAL_CALL release( void ) throw();
+
+
+ // XContentIdentifier
+
+ virtual ::rtl::OUString SAL_CALL
+ getContentIdentifier(
+ )
+ throw (
+ ::com::sun::star::uno::RuntimeException
+ );
+
+ virtual ::rtl::OUString SAL_CALL
+ getContentProviderScheme(
+ )
+ throw (
+ ::com::sun::star::uno::RuntimeException
+ );
+
+ private:
+
+ rtl::OUString m_aIdent;
+ };
+
+}
+
+
+#endif
diff --git a/ucb/source/ucp/ftp/ftpcontentprovider.cxx b/ucb/source/ucp/ftp/ftpcontentprovider.cxx
index e538c280a0c4..78d780600f69 100644
--- a/ucb/source/ucp/ftp/ftpcontentprovider.cxx
+++ b/ucb/source/ucp/ftp/ftpcontentprovider.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ftpcontentprovider.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: abi $ $Date: 2002-06-20 14:49:21 $
+ * last change: $Author: abi $ $Date: 2002-07-31 15:13:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -152,9 +152,14 @@ ONE_INSTANCE_SERVICE_FACTORY_IMPL(FtpContentProvider);
//=========================================================================
// virtual
-Reference<XContent> SAL_CALL FtpContentProvider::queryContent(const Reference< XContentIdentifier >& xCanonicId)
- throw( IllegalIdentifierException,
- RuntimeException )
+Reference<XContent> SAL_CALL
+FtpContentProvider::queryContent(
+ const Reference< XContentIdentifier >& xCanonicId
+)
+ throw(
+ IllegalIdentifierException,
+ RuntimeException
+ )
{
// Check, if a content with given id already exists...
Reference<XContent> xContent
@@ -174,7 +179,8 @@ Reference<XContent> SAL_CALL FtpContentProvider::queryContent(const Reference< X
}
}
- xContent = new FtpContent(m_xSMgr,this,xCanonicId); // may throw IllegalIdentifierException
+ xContent = new FtpContent(m_xSMgr,this,xCanonicId);
+ // may throw IllegalIdentifierException
return xContent;
}
diff --git a/ucb/source/ucp/ftp/ftpdirp.cxx b/ucb/source/ucp/ftp/ftpdirp.cxx
new file mode 100644
index 000000000000..f8a77f7bf376
--- /dev/null
+++ b/ucb/source/ucp/ftp/ftpdirp.cxx
@@ -0,0 +1,1310 @@
+/*************************************************************************
+ *
+ * $RCSfile: ftpdirp.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: abi $ $Date: 2002-07-31 15:13:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+
+#ifndef _FTP_FTPDIRP_HXX_
+#include "ftpdirp.hxx"
+#endif
+#ifndef _OSL_TIME_H_
+#include <osl/time.h>
+#endif
+
+
+using namespace rtl;
+using namespace ftp;
+
+
+typedef sal_uInt32 ULONG;
+
+
+inline sal_Bool ascii_isLetter( sal_Unicode ch )
+{
+ return (( (ch >= 0x0041) && (ch <= 0x005A)) ||
+ (( ch >= 0x0061) && (ch <= 0x007A)));
+}
+
+inline sal_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
+ */
+
+sal_Bool FTPDirectoryParser::parseDOS (
+ FTPDirentry &rEntry,
+ const sal_Char *pBuffer)
+{
+ sal_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;
+ enum StateType eState = STATE_INIT_LWS;
+ for (const sal_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
+ eState = STATE_ERROR;
+ }
+ else
+ {
+ if (ascii_isWhitespace(*p) && (nMinute < 60))
+ eState = STATE_LWS_NAME;
+ else
+ eState = STATE_ERROR;
+ }
+ break;
+
+ case STATE_LWS_NAME:
+ if (!ascii_isWhitespace(*p))
+ {
+ setPath (rEntry.m_aName, p);
+ if (bDirectory)
+ rEntry.m_nMode |= INETCOREFTP_FILEMODE_ISDIR;
+ rEntry.m_nSize = nSize;
+
+ setYear (rEntry.m_aDate, nYear);
+
+ rEntry.m_aDate.SetMonth(nMonth);
+ rEntry.m_aDate.SetDay(nDay);
+ rEntry.m_aDate.SetHour(nHour);
+ rEntry.m_aDate.SetMin(nMinute);
+
+ return sal_True;
+ }
+ break;
+ }
+ }
+
+ return sal_False;
+}
+
+/*
+ * parseVMS.
+ * Directory entries may span one or two lines:
+ *
+ * entry: *lws name *1(*lws <NEWLINE>) 1*lws size 1*lws datetime rest
+ *
+ * name: filename "." filetype ";" version
+ * filename: 1*39fchar
+ * filetype: 1*39fchar
+ * version: non0digit *digit
+ *
+ * size: "0" / non0digit *digit
+ *
+ * datetime: date 1*lwsp time
+ * date: day "-" month "-" year
+ * day: (*1"0" non0digit) / ("1"-"2" digit) / ("3" "0"-"1")
+ * month: "JAN" / "FEB" / "MAR" / "APR" / "MAY" / "JUN" / "JUL" / "AUG"
+ * / "SEP" / "OCT" / "NOV" / "DEC" ; all case insensitive
+ * year: 2digit / 4digit
+ * time: hour ":" minute
+ * hour: ((*1"0" / "1") digit) / ("2" "0"-"3")
+ * minute: "0"-"5" digit
+ *
+ * rest: *1(lws *<ANY>)
+ *
+ * lws: <TAB> / <SPACE>
+ * non0digit: "1"-"9"
+ * digit: "0" / non0digit
+ * fchar: "A"-"Z" / "a"-"z" / digit / "-" / "_" / "$"
+ *
+ * For directories, the returned name is the <filename> part; for non-
+ * directory files, the returned name is the <filename "." filetype> part.
+ * An entry is a directory iff its filetype is "DIR" (ignoring case).
+ *
+ * The READ, WRITE, and ISLINK mode bits are not supported.
+ *
+ * The returned size is the <size> part, multiplied by 512, and with the high
+ * order bits truncated to fit into a ULONG.
+ *
+ */
+sal_Bool FTPDirectoryParser::parseVMS (
+ FTPDirentry &rEntry,
+ const sal_Char *pBuffer)
+{
+ static OUString aFirstLineName;
+ static sal_Bool bFirstLineDir = sal_False;
+
+ for (sal_Bool bFirstLine = sal_True;; bFirstLine = sal_False)
+ {
+ const sal_Char *p = pBuffer;
+ if (bFirstLine)
+ {
+ // Skip <*lws> part:
+ while (*p == '\t' || *p == ' ')
+ ++p;
+
+ // Parse <filename "."> part:
+ const sal_Char *pFileName = p;
+ while ((*p >= 'A' && *p <= 'Z') ||
+ (*p >= 'a' && *p <= 'z') ||
+ (*p >= '0' && *p <= '9') ||
+ *p == '-' || *p == '_' || *p == '$')
+ ++p;
+
+ if (*p != '.' || p == pFileName || p - pFileName > 39)
+ if (aFirstLineName.getLength())
+ continue;
+ else
+ return sal_False;
+
+ // Parse <filetype ";"> part:
+ const sal_Char *pFileType = ++p;
+ while ((*p >= 'A' && *p <= 'Z') ||
+ (*p >= 'a' && *p <= 'z') ||
+ (*p >= '0' && *p <= '9') ||
+ *p == '-' || *p == '_' || *p == '$')
+ ++p;
+
+ if (*p != ';' || p == pFileName || p - pFileName > 39)
+ if (aFirstLineName.getLength())
+ continue;
+ else
+ return sal_False;
+ ++p;
+
+ // Set entry's name and mode (ISDIR flag):
+ if ((p - pFileType == 4) &&
+ (pFileType[0] == 'D' || pFileType[0] == 'd') &&
+ (pFileType[1] == 'I' || pFileType[1] == 'i') &&
+ (pFileType[2] == 'R' || pFileType[2] == 'r') )
+ {
+ setPath (rEntry.m_aName, pFileName, (pFileType - pFileName));
+ rEntry.m_nMode = INETCOREFTP_FILEMODE_ISDIR;
+ }
+ else
+ {
+ setPath (rEntry.m_aName, pFileName, (p - pFileName));
+ rEntry.m_nMode = 0;
+ }
+
+ // Skip <version> part:
+ if (*p < '1' || *p > '9')
+ if (aFirstLineName.getLength())
+ continue;
+ else
+ return sal_False;
+ ++p;
+ while (*p >= '0' && *p <= '9')
+ ++p;
+
+ // Parse <1*lws> or <*lws <NEWLINE>> part:
+ sal_Bool bLWS = false;
+ while (*p == '\t' || *p == ' ')
+ {
+ bLWS = true;
+ ++p;
+ }
+ if (*p)
+ {
+ if (!bLWS)
+ if (aFirstLineName.getLength())
+ continue;
+ else
+ return sal_False;
+ }
+ else
+ {
+ /*
+ * First line of entry spanning two lines,
+ * wait for second line.
+ */
+ aFirstLineName = rEntry.m_aName;
+ bFirstLineDir =
+ ((rEntry.m_nMode & INETCOREFTP_FILEMODE_ISDIR) != 0);
+ return sal_False;
+ }
+ }
+ else
+ {
+ /*
+ * Second line of entry spanning two lines,
+ * restore entry's name and mode (ISDIR flag).
+ */
+ rEntry.m_aName = aFirstLineName;
+ rEntry.m_nMode = (bFirstLineDir ? INETCOREFTP_FILEMODE_ISDIR : 0);
+
+ // Skip <1*lws> part:
+ if (*p != '\t' && *p != ' ')
+ return sal_False;
+ ++p;
+ while (*p == '\t' || *p == ' ')
+ ++p;
+ }
+
+ // Parse <size> part and set entry's size:
+ if (*p < '0' || *p > '9')
+ return sal_False;
+ ULONG nSize = *p - '0';
+ if (*p++ != '0')
+ while (*p >= '0' && *p <= '9')
+ nSize = 10 * rEntry.m_nSize + (*p++ - '0');
+ rEntry.m_nSize = 512 * nSize;
+
+ // Skip <1*lws> part:
+ if (*p != '\t' && *p != ' ')
+ return sal_False;
+ ++p;
+ while (*p == '\t' || *p == ' ')
+ ++p;
+
+ // Parse <day "-"> part and set entry date's day:
+ sal_uInt16 nDay;
+ if (*p == '0')
+ {
+ ++p;
+ if (*p < '1' || *p > '9')
+ return sal_False;
+ nDay = *p++ - '0';
+ }
+ else if (*p == '1' || *p == '2')
+ {
+ nDay = *p++ - '0';
+ if (*p >= '0' && *p <= '9')
+ nDay = 10 * nDay + (*p++ - '0');
+ }
+ else if (*p == '3')
+ {
+ ++p;
+ nDay = (*p == '0' || *p == '1') ? 30 + (*p++ - '0') : 3;
+ }
+ else if (*p >= '4' && *p <= '9')
+ nDay = *p++ - '0';
+ else
+ return sal_False;
+
+ rEntry.m_aDate.SetDay(nDay);
+ if (*p++ != '-')
+ return sal_False;
+
+ // Parse <month "-"> part and set entry date's month:
+ sal_Char aMonth[4];
+ {for (int i = 0; i < 3; ++i)
+ if (*p >= 'A' && *p <= 'Z')
+ aMonth[i] = *p++;
+ else if (*p >= 'a' && *p <= 'z')
+ aMonth[i] = (sal_Char)(*p++ - 'A');
+ else
+ return sal_False;
+ }
+
+ if (aMonth == "JAN")
+ rEntry.m_aDate.SetMonth(1);
+ else if (aMonth == "FEB")
+ rEntry.m_aDate.SetMonth(2);
+ else if (aMonth == "MAR")
+ rEntry.m_aDate.SetMonth(3);
+ else if (aMonth == "APR")
+ rEntry.m_aDate.SetMonth(4);
+ else if (aMonth == "MAY")
+ rEntry.m_aDate.SetMonth(5);
+ else if (aMonth == "JUN")
+ rEntry.m_aDate.SetMonth(6);
+ else if (aMonth == "JUL")
+ rEntry.m_aDate.SetMonth(7);
+ else if (aMonth == "AUG")
+ rEntry.m_aDate.SetMonth(8);
+ else if (aMonth == "SEP")
+ rEntry.m_aDate.SetMonth(9);
+ else if (aMonth == "OCT")
+ rEntry.m_aDate.SetMonth(10);
+ else if (aMonth == "NOV")
+ rEntry.m_aDate.SetMonth(11);
+ else if (aMonth == "DEC")
+ rEntry.m_aDate.SetMonth(12);
+ else
+ return sal_False;
+ if (*p++ != '-')
+ return sal_False;
+
+ // Parse <year> part and set entry date's year:
+ sal_uInt16 nYear = 0;
+ {for (int i = 0; i < 2; ++i)
+ {
+ if (*p < '0' || *p > '9')
+ return sal_False;
+ nYear = 10 * nYear + (*p++ - '0');
+ }}
+ if (*p >= '0' && *p <= '9')
+ {
+ nYear = 10 * nYear + (*p++ - '0');
+ if (*p < '0' || *p > '9')
+ return sal_False;
+ nYear = 10 * nYear + (*p++ - '0');
+ }
+ setYear (rEntry.m_aDate, nYear);
+
+ // Skip <1*lws> part:
+ if (*p != '\t' && *p != ' ')
+ return sal_False;
+ ++p;
+ while (*p == '\t' || *p == ' ')
+ ++p;
+
+ // Parse <hour ":"> part and set entry time's hour:
+ sal_uInt16 nHour;
+ if (*p == '0' || *p == '1')
+ {
+ nHour = *p++ - '0';
+ if (*p >= '0' && *p <= '9')
+ nHour = 10 * nHour + (*p++ - '0');
+ }
+ else if (*p == '2')
+ {
+ ++p;
+ nHour = (*p >= '0' && *p <= '3') ? 20 + (*p++ - '0') : 2;
+ }
+ else if (*p >= '3' && *p <= '9')
+ nHour = *p++ - '0';
+ else
+ return sal_False;
+
+ rEntry.m_aDate.SetHour(nHour);
+ if (*p++ != ':')
+ return sal_False;
+
+ /*
+ * Parse <minute> part and set entry time's minutes,
+ * seconds (0), and 1/100 seconds (0).
+ */
+ if (*p < '0' || *p > '5')
+ return sal_False;
+
+ sal_uInt16 nMinute = *p++ - '0';
+ if (*p < '0' || *p > '9')
+ return sal_False;
+
+ nMinute = 10 * nMinute + (*p++ - '0');
+ rEntry.m_aDate.SetMin(nMinute);
+ rEntry.m_aDate.SetSec(0);
+ rEntry.m_aDate.Set100Sec(0);
+
+ // Skip <rest> part:
+ if (*p && (*p != '\t' && *p != ' '))
+ return sal_False;
+
+ return sal_True;
+ }
+}
+
+/*
+ * parseUNIX
+ */
+sal_Bool FTPDirectoryParser::parseUNIX (
+ FTPDirentry &rEntry,
+ const sal_Char *pBuffer)
+{
+ const sal_Char *p1, *p2;
+ p1 = p2 = pBuffer;
+
+ if (!((*p1 == '-') || (*p1 == 'd') || (*p1 == 'l')))
+ return sal_False;
+
+ // 1st column: FileMode.
+ if (*p1 == 'd')
+ rEntry.m_nMode |= INETCOREFTP_FILEMODE_ISDIR;
+ if (*p1 == 'l')
+ rEntry.m_nMode |= INETCOREFTP_FILEMODE_ISLINK;
+
+ // Skip to end of column.
+ while (*p1 && !ascii_isWhitespace(*p1)) p1++;
+
+ /*
+ * Scan for the sequence of size and date fields:
+ * *LWS 1*DIGIT 1*LWS 3CHAR 1*LWS 1*2DIGIT 1*LWS
+ * (4DIGIT / (1*2DIGIT ":" 2DIGIT)) 1*LWS
+ */
+ enum Mode
+ {
+ FOUND_NONE, FOUND_SIZE, FOUND_MONTH, FOUND_DAY, FOUND_YEAR_TIME
+ };
+
+ const sal_Char *pDayStart, *pDayEnd;
+ Mode eMode;
+ for (eMode = FOUND_NONE; *p1 && eMode != FOUND_YEAR_TIME; p1 = p2 + 1)
+ {
+ while (*p1 && ascii_isWhitespace(*p1))
+ ++p1;
+ p2 = p1;
+ while (*p2 && !ascii_isWhitespace(*p2))
+ ++p2;
+
+ switch (eMode)
+ {
+ case FOUND_NONE:
+ if (parseUNIX_isSizeField (p1, p2, rEntry.m_nSize))
+ eMode = FOUND_SIZE;
+ break;
+
+ case FOUND_SIZE:
+ if (parseUNIX_isMonthField (p1, p2, rEntry.m_aDate))
+ eMode = FOUND_MONTH;
+ else if (!parseUNIX_isSizeField (p1, p2, rEntry.m_nSize))
+ eMode = FOUND_NONE;
+ break;
+
+ case FOUND_MONTH:
+ if (parseUNIX_isDayField (p1, p2, rEntry.m_aDate))
+ {
+ pDayStart = p1;
+ pDayEnd = p2;
+ eMode = FOUND_DAY;
+ }
+ else if (parseUNIX_isSizeField (p1, p2, rEntry.m_nSize))
+ eMode = FOUND_SIZE;
+ else
+ eMode = FOUND_NONE;
+ break;
+
+ case FOUND_DAY:
+ if (parseUNIX_isYearTimeField (p1, p2, rEntry.m_aDate))
+ eMode = FOUND_YEAR_TIME;
+ else if (
+ parseUNIX_isSizeField (
+ pDayStart, pDayEnd, rEntry.m_nSize) &&
+ parseUNIX_isMonthField (
+ p1, p2, rEntry.m_aDate))
+ eMode = FOUND_MONTH;
+ else if (parseUNIX_isSizeField (p1, p2, rEntry.m_nSize))
+ eMode = FOUND_SIZE;
+ else
+ eMode = FOUND_NONE;
+ break;
+ }
+ }
+
+ if (eMode == FOUND_YEAR_TIME)
+ {
+ // 9th column: FileName (rest of line).
+ while (*p1 && ascii_isWhitespace(*p1)) p1++;
+ setPath (rEntry.m_aName, p1);
+
+ // Done.
+ return sal_True;
+ }
+ return sal_False;
+}
+
+/*
+ * parseUNKNOWN.
+ */
+sal_Bool FTPDirectoryParser::parseUNKNOWN (
+ FTPDirentry &rEntry,
+ const sal_Char *pBuffer,
+ sal_uInt32 nLength)
+{
+ setPath (rEntry.m_aName, pBuffer,sal_Int32 (nLength));
+ return sal_True;
+}
+
+/*
+ * parseUNIX_isSizeField.
+ */
+sal_Bool FTPDirectoryParser::parseUNIX_isSizeField (
+ const sal_Char *pStart,
+ const sal_Char *pEnd,
+ sal_uInt32 &rSize)
+{
+ if (!*pStart || !*pEnd || pStart == pEnd)
+ return sal_False;
+
+ rSize = 0;
+ if (*pStart >= '0' && *pStart <= '9')
+ {
+ for (; pStart < pEnd; ++pStart)
+ if ((*pStart >= '0') && (*pStart <= '9'))
+ rSize = 10 * rSize + (*pStart - '0');
+ else
+ return sal_False;
+ return sal_True;
+ }
+ else
+ {
+ /*
+ * For a combination of long group name and large file size,
+ * some FTPDs omit LWS between those two columns.
+ */
+ int nNonDigits = 0;
+ int nDigits = 0;
+
+ for (; pStart < pEnd; ++pStart)
+ if ((*pStart >= '1') && (*pStart <= '9'))
+ {
+ ++nDigits;
+ rSize = 10 * rSize + (*pStart - '0');
+ }
+ else if ((*pStart == '0') && nDigits)
+ {
+ ++nDigits;
+ rSize *= 10;
+ }
+ else if ((*pStart > ' ') && (*pStart <= '\x7F'))
+ {
+ nNonDigits += nDigits + 1;
+ nDigits = 0;
+ rSize = 0;
+ }
+ else
+ return sal_False;
+ return ((nNonDigits >= 9) && (nDigits >= 7));
+ }
+}
+
+/*
+ * parseUNIX_isMonthField.
+ */
+sal_Bool FTPDirectoryParser::parseUNIX_isMonthField (
+ const sal_Char *pStart,
+ const sal_Char *pEnd,
+ DateTime &rDateTime)
+{
+ if (!*pStart || !*pEnd || pStart + 3 != pEnd)
+ return sal_False;
+
+ if ((pStart[0] == 'j' || pStart[0] == 'J') &&
+ (pStart[1] == 'a' || pStart[1] == 'A') &&
+ (pStart[2] == 'n' || pStart[2] == 'N') )
+ {
+ rDateTime.SetMonth(1);
+ return sal_True;
+ }
+ if ((pStart[0] == 'f' || pStart[0] == 'F') &&
+ (pStart[1] == 'e' || pStart[1] == 'E') &&
+ (pStart[2] == 'b' || pStart[2] == 'B') )
+ {
+ rDateTime.SetMonth(2);
+ return sal_True;
+ }
+ if ((pStart[0] == 'm' || pStart[0] == 'M') &&
+ (pStart[1] == 'a' || pStart[1] == 'A') &&
+ (pStart[2] == 'r' || pStart[2] == 'R') )
+ {
+ rDateTime.SetMonth(3);
+ return sal_True;
+ }
+ if ((pStart[0] == 'a' || pStart[0] == 'A') &&
+ (pStart[1] == 'p' || pStart[1] == 'P') &&
+ (pStart[2] == 'r' || pStart[2] == 'R') )
+ {
+ rDateTime.SetMonth(4);
+ return sal_True;
+ }
+ if ((pStart[0] == 'm' || pStart[0] == 'M') &&
+ (pStart[1] == 'a' || pStart[1] == 'A') &&
+ (pStart[2] == 'y' || pStart[2] == 'Y') )
+ {
+ rDateTime.SetMonth(5);
+ return sal_True;
+ }
+ if ((pStart[0] == 'j' || pStart[0] == 'J') &&
+ (pStart[1] == 'u' || pStart[1] == 'U') &&
+ (pStart[2] == 'n' || pStart[2] == 'N') )
+ {
+ rDateTime.SetMonth(6);
+ return sal_True;
+ }
+ if ((pStart[0] == 'j' || pStart[0] == 'J') &&
+ (pStart[1] == 'u' || pStart[1] == 'U') &&
+ (pStart[2] == 'l' || pStart[2] == 'L') )
+ {
+ rDateTime.SetMonth(7);
+ return sal_True;
+ }
+ if ((pStart[0] == 'a' || pStart[0] == 'A') &&
+ (pStart[1] == 'u' || pStart[1] == 'U') &&
+ (pStart[2] == 'g' || pStart[2] == 'G') )
+ {
+ rDateTime.SetMonth(8);
+ return sal_True;
+ }
+ if ((pStart[0] == 's' || pStart[0] == 'S') &&
+ (pStart[1] == 'e' || pStart[1] == 'E') &&
+ (pStart[2] == 'p' || pStart[2] == 'P') )
+ {
+ rDateTime.SetMonth(9);
+ return sal_True;
+ }
+ if ((pStart[0] == 'o' || pStart[0] == 'O') &&
+ (pStart[1] == 'c' || pStart[1] == 'C') &&
+ (pStart[2] == 't' || pStart[2] == 'T') )
+ {
+ rDateTime.SetMonth(10);
+ return sal_True;
+ }
+ if ((pStart[0] == 'n' || pStart[0] == 'N') &&
+ (pStart[1] == 'o' || pStart[1] == 'O') &&
+ (pStart[2] == 'v' || pStart[2] == 'V') )
+ {
+ rDateTime.SetMonth(11);
+ return sal_True;
+ }
+ if ((pStart[0] == 'd' || pStart[0] == 'D') &&
+ (pStart[1] == 'e' || pStart[1] == 'E') &&
+ (pStart[2] == 'c' || pStart[2] == 'C') )
+ {
+ rDateTime.SetMonth(12);
+ return sal_True;
+ }
+ return sal_False;
+}
+
+/*
+ * parseUNIX_isDayField.
+ */
+sal_Bool FTPDirectoryParser::parseUNIX_isDayField (
+ const sal_Char *pStart,
+ const sal_Char *pEnd,
+ DateTime &rDateTime)
+{
+ if (!*pStart || !*pEnd || pStart == pEnd)
+ return sal_False;
+ if (*pStart < '0' || *pStart > '9')
+ return sal_False;
+
+ sal_uInt16 nDay = *pStart - '0';
+ if (pStart + 1 < pEnd)
+ {
+ if (pStart + 2 != pEnd || pStart[1] < '0' || pStart[1] > '9')
+ return sal_False;
+ nDay = 10 * nDay + (pStart[1] - '0');
+ }
+ if (!nDay || nDay > 31)
+ return sal_False;
+
+ rDateTime.SetDay(nDay);
+ return sal_True;
+}
+
+/*
+ * parseUNIX_isYearTimeField.
+ */
+sal_Bool FTPDirectoryParser::parseUNIX_isYearTimeField (
+ const sal_Char *pStart,
+ const sal_Char *pEnd,
+ DateTime &rDateTime)
+{
+ if (!*pStart || !*pEnd || pStart == pEnd ||
+ *pStart < '0' || *pStart > '9')
+ return sal_False;
+
+ sal_uInt16 nNumber = *pStart - '0';
+ ++pStart;
+
+ if (pStart == pEnd)
+ return sal_False;
+ if (*pStart == ':')
+ return parseUNIX_isTime (pStart, pEnd, nNumber, rDateTime);
+ if (*pStart < '0' || *pStart > '9')
+ return sal_False;
+
+ nNumber = 10 * nNumber + (*pStart - '0');
+ ++pStart;
+
+ if (pStart == pEnd)
+ return sal_False;
+ if (*pStart == ':')
+ return parseUNIX_isTime (pStart, pEnd, nNumber, rDateTime);
+ if (*pStart < '0' || *pStart > '9')
+ return sal_False;
+
+ nNumber = 10 * nNumber + (*pStart - '0');
+ ++pStart;
+
+ if (pStart == pEnd || *pStart < '0' || *pStart > '9')
+ return sal_False;
+
+ nNumber = 10 * nNumber + (*pStart - '0');
+ if (pStart + 1 != pEnd || nNumber < 1970)
+ return sal_False;
+
+ rDateTime.SetYear(nNumber);
+ rDateTime.SetTime(0);
+ return sal_True;
+}
+
+/*
+ * parseUNIX_isTime.
+ */
+sal_Bool FTPDirectoryParser::parseUNIX_isTime (
+ const sal_Char *pStart,
+ const sal_Char *pEnd,
+ sal_uInt16 nHour,
+ DateTime &rDateTime)
+{
+ if ((nHour > 23 ) || (pStart + 3 != pEnd) ||
+ (pStart[1] < '0') || (pStart[1] > '5') ||
+ (pStart[2] < '0') || (pStart[2] > '9') )
+ return sal_False;
+
+ sal_uInt16 nMin = 10 * (pStart[1] - '0') + (pStart[2] - '0');
+
+ rDateTime.SetHour (nHour);
+ rDateTime.SetMin (nMin);
+ rDateTime.SetSec (0);
+ rDateTime.Set100Sec (0);
+
+// Date aCurDate;
+// if (rDateTime.GetMonth() > aCurDate.GetMonth())
+// rDateTime.SetYear(aCurDate.GetYear() - 1);
+// else
+// rDateTime.SetYear(aCurDate.GetYear());
+// return sal_True;
+
+ TimeValue aTimeVal;
+ osl_getSystemTime(&aTimeVal);
+ oslDateTime aCurrDateTime;
+ osl_getDateTimeFromTimeValue(&aTimeVal,&aCurrDateTime);
+
+ if (rDateTime.GetMonth() > aCurrDateTime.Month)
+ rDateTime.SetYear(aCurrDateTime.Year - 1);
+ else
+ rDateTime.SetYear(aCurrDateTime.Year);
+ return sal_True;
+}
+
+/*
+ * setYear.
+ *
+ * Two-digit years are taken as within 50 years back and 49 years forward
+ * (both ends inclusive) from the current year. The returned date is not
+ * checked for validity of the given day in the given month and year.
+ *
+ */
+sal_Bool FTPDirectoryParser::setYear (
+ DateTime &rDateTime, sal_uInt16 nYear)
+{
+ if (nYear < 100)
+ {
+ TimeValue aTimeVal;
+ osl_getSystemTime(&aTimeVal);
+ oslDateTime aCurrDateTime;
+ osl_getDateTimeFromTimeValue(&aTimeVal,&aCurrDateTime);
+ sal_uInt16 nCurrentYear = aCurrDateTime.Year;
+// sal_uInt16 nCurrentYear = Date().GetYear();
+ sal_uInt16 nCurrentCentury = nCurrentYear / 100;
+ nCurrentYear %= 100;
+ if (nCurrentYear < 50)
+ if (nYear <= nCurrentYear)
+ nYear += nCurrentCentury * 100;
+ else if (nYear < nCurrentYear + 50)
+ nYear += nCurrentCentury * 100;
+ else
+ nYear += (nCurrentCentury - 1) * 100;
+ else
+ if (nYear >= nCurrentYear)
+ nYear += nCurrentCentury * 100;
+ else if (nYear >= nCurrentYear - 50)
+ nYear += nCurrentCentury * 100;
+ else
+ nYear += (nCurrentCentury + 1) * 100;
+ }
+
+ rDateTime.SetYear(nYear);
+ return sal_True;
+}
+
+/*
+ * setPath.
+ */
+sal_Bool FTPDirectoryParser::setPath (
+ OUString &rPath, const sal_Char *value, sal_Int32 length)
+{
+ if (value)
+ {
+ if (length < 0)
+ length = rtl_str_getLength (value);
+ rPath = OUString (value, length, RTL_TEXTENCODING_UTF8);
+ }
+ return (!!value);
+}
diff --git a/ucb/source/ucp/ftp/ftpdirp.hxx b/ucb/source/ucp/ftp/ftpdirp.hxx
new file mode 100644
index 000000000000..c312accce25b
--- /dev/null
+++ b/ucb/source/ucp/ftp/ftpdirp.hxx
@@ -0,0 +1,226 @@
+/*************************************************************************
+ *
+ * $RCSfile: ftpdirp.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: abi $ $Date: 2002-07-31 15:13:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+#ifndef _FTP_FTPDIRP_HXX_
+#define _FTP_FTPDIRP_HXX_
+
+#ifndef _OSL_TIME_H_
+#include <osl/time.h>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_
+#include <com/sun/star/util/DateTime.hpp>
+#endif
+
+
+namespace ftp {
+
+ /*========================================================================
+ *
+ * the DateTime structure
+ *
+ *======================================================================*/
+
+ struct DateTime
+ : public com::sun::star::util::DateTime
+ {
+ DateTime(const sal_uInt16& hundredthSeconds,
+ const sal_uInt16& seconds,
+ const sal_uInt16& minutes,
+ const sal_uInt16& hours,
+ const sal_uInt16& day,
+ const sal_uInt16& month,
+ const sal_uInt16& year) SAL_THROW( () )
+ : DateTime(hundredthSeconds,
+ seconds,
+ minutes,
+ hours,
+ day,
+ month,
+ year) { }
+
+ void SetYear(sal_uInt16 year) { Year = year; }
+ void SetMonth(sal_uInt16 month) { Month = month; }
+ void SetDay(sal_uInt16 day) { Day = day; }
+ // Only zero allowed and used for time-argument
+ void SetTime(sal_uInt16 time) { Hours = Minutes = Seconds = HundredthSeconds = 0; }
+ void SetHour(sal_uInt16 hours) { Hours = hours; }
+ void SetMin(sal_uInt16 minutes) { Minutes = minutes; }
+ void SetSec(sal_uInt16 seconds) { Seconds = seconds; }
+ void Set100Sec(sal_uInt16 hundredthSec) { HundredthSeconds = hundredthSec; }
+
+ sal_uInt16 GetMonth(void) { return Month; }
+ };
+
+
+
+/*========================================================================
+ *
+ * the directory information structure
+ *
+ *======================================================================*/
+
+ enum FtpDirentryMode { INETCOREFTP_FILEMODE_UNKNOWN = 0x00,
+ INETCOREFTP_FILEMODE_READ = 0x01,
+ INETCOREFTP_FILEMODE_WRITE = 0x02,
+ INETCOREFTP_FILEMODE_ISDIR = 0x04,
+ INETCOREFTP_FILEMODE_ISLINK = 0x08 };
+
+ struct FTPDirentry
+ {
+ rtl::OUString m_aURL;
+ rtl::OUString m_aName;
+ DateTime m_aDate;
+ sal_uInt32 m_nMode;
+ sal_uInt32 m_nSize;
+
+ FTPDirentry(void)
+ : m_aDate(0,0,0,0,0,0,0),
+ m_nMode(INETCOREFTP_FILEMODE_UNKNOWN),
+ m_nSize((sal_uInt32)(-1)) { }
+
+ void clear() {
+ m_aURL = m_aName = rtl::OUString();
+ m_aDate = DateTime(0,0,0,0,0,0,0);
+ m_nMode = INETCOREFTP_FILEMODE_UNKNOWN;
+ m_nSize = sal_uInt32(-1);
+ }
+ };
+
+
+/*========================================================================
+ *
+ * the directory parser
+ *
+ *======================================================================*/
+
+
+ class FTPDirectoryParser
+ {
+ public:
+ static sal_Bool parseDOS (
+ FTPDirentry &rEntry,
+ const sal_Char *pBuffer );
+
+ static sal_Bool parseVMS (
+ FTPDirentry &rEntry,
+ const sal_Char *pBuffer );
+
+ static sal_Bool parseUNIX (
+ FTPDirentry &rEntry,
+ const sal_Char *pBuffer );
+
+ static sal_Bool parseUNKNOWN (
+ FTPDirentry &rEntry,
+ const sal_Char *pBuffer,
+ sal_uInt32 nLength);
+
+
+ private:
+
+ static sal_Bool parseUNIX_isSizeField (
+ const sal_Char *pStart,
+ const sal_Char *pEnd,
+ sal_uInt32 &rSize);
+
+ static sal_Bool parseUNIX_isMonthField (
+ const sal_Char *pStart,
+ const sal_Char *pEnd,
+ DateTime& rDateTime);
+
+ static sal_Bool parseUNIX_isDayField (
+ const sal_Char *pStart,
+ const sal_Char *pEnd,
+ DateTime& rDateTime);
+
+ static sal_Bool parseUNIX_isYearTimeField (
+ const sal_Char *pStart,
+ const sal_Char *pEnd,
+ DateTime& rDateTime);
+
+ static sal_Bool parseUNIX_isTime (
+ const sal_Char *pStart,
+ const sal_Char *pEnd,
+ sal_uInt16 nHour,
+ DateTime& rDateTime);
+
+ static sal_Bool setYear (
+ DateTime& rDateTime,
+ sal_uInt16 nYear);
+
+ static sal_Bool setPath (
+ rtl::OUString& rPath,
+ const sal_Char *value,
+ sal_Int32 length = -1);
+ };
+
+
+}
+
+
+#endif
diff --git a/ucb/source/ucp/ftp/ftpdynresultset.cxx b/ucb/source/ucp/ftp/ftpdynresultset.cxx
new file mode 100644
index 000000000000..ff8a06aea751
--- /dev/null
+++ b/ucb/source/ucp/ftp/ftpdynresultset.cxx
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * $RCSfile: ftpdynresultset.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: abi $ $Date: 2002-07-31 15:13:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+#ifndef _FTP_FTPDYNRESULTSET_HXX_
+#include "ftpdynresultset.hxx"
+#endif
+#ifndef _FTP_FTPRESULTSETFACTORY_HXX_
+#include "ftpresultsetfactory.hxx"
+#endif
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::uno;
+
+
+using namespace ftp;
+
+//=========================================================================
+//=========================================================================
+//
+// DynamicResultSet Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+DynamicResultSet::DynamicResultSet(
+ const Reference< XMultiServiceFactory >& rxSMgr,
+ const vos::ORef< FtpContent >& rxContent,
+ const OpenCommandArgument2& rCommand,
+ const Reference< XCommandEnvironment >& rxEnv,
+ ResultSetFactory* pFactory )
+ : ResultSetImplHelper( rxSMgr, rCommand ),
+ m_xContent( rxContent ),
+ m_xEnv( rxEnv ),
+ m_pFactory( pFactory )
+{
+}
+
+DynamicResultSet::~DynamicResultSet()
+{
+ delete m_pFactory;
+}
+
+//=========================================================================
+//
+// Non-interface methods.
+//
+//=========================================================================
+
+void DynamicResultSet::initStatic()
+{
+ m_xResultSet1 = Reference< XResultSet >( m_pFactory->createResultSet() );
+}
+
+//=========================================================================
+void DynamicResultSet::initDynamic()
+{
+ m_xResultSet1 = Reference< XResultSet >( m_pFactory->createResultSet() );
+
+ m_xResultSet2 = m_xResultSet1;
+}
+
+
+
+
diff --git a/ucb/source/ucp/ftp/ftpdynresultset.hxx b/ucb/source/ucp/ftp/ftpdynresultset.hxx
new file mode 100644
index 000000000000..aef86c145b20
--- /dev/null
+++ b/ucb/source/ucp/ftp/ftpdynresultset.hxx
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * $RCSfile: ftpdynresultset.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: abi $ $Date: 2002-07-31 15:13:19 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FTP_FTPDYNRESULTSET_HXX
+#define _FTP_FTPDYNRESULTSET_HXX
+
+#ifndef _UCBHELPER_RESULTSETHELPER_HXX
+#include <ucbhelper/resultsethelper.hxx>
+#endif
+#ifndef _VOS_REF_HXX_
+#include <vos/ref.hxx>
+#endif
+#ifndef _FTP_FTPCONTENT_HXX_
+#include "ftpcontent.hxx"
+#endif
+
+namespace ftp {
+
+ class ResultSetFactory;
+
+ class DynamicResultSet : public ::ucb::ResultSetImplHelper
+ {
+ vos::ORef< FtpContent > m_xContent;
+ com::sun::star::uno::Reference<
+ com::sun::star::ucb::XCommandEnvironment > m_xEnv;
+ ResultSetFactory* m_pFactory;
+
+ private:
+ virtual void initStatic();
+ virtual void initDynamic();
+
+ public:
+ DynamicResultSet(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
+ const vos::ORef< FtpContent >& rxContent,
+ const com::sun::star::ucb::OpenCommandArgument2& rCommand,
+ const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XCommandEnvironment >& rxEnv,
+ ResultSetFactory* pFactory );
+
+ ~DynamicResultSet();
+ };
+
+}
+
+#endif
+
diff --git a/ucb/source/ucp/ftp/ftpinpstr.cxx b/ucb/source/ucp/ftp/ftpinpstr.cxx
index 24b91bec3649..eb7f97806884 100644
--- a/ucb/source/ucp/ftp/ftpinpstr.cxx
+++ b/ucb/source/ucp/ftp/ftpinpstr.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ftpinpstr.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: abi $ $Date: 2002-06-24 15:17:55 $
+ * last change: $Author: abi $ $Date: 2002-07-31 15:13:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -75,6 +75,7 @@
#include <algorithm>
#define STD_ALGORITHM
#endif
+#include <stdio.h>
using namespace ftp;
using namespace com::sun::star::uno;
@@ -82,12 +83,13 @@ using namespace com::sun::star::lang;
using namespace com::sun::star::io;
-
FtpInputStream::FtpInputStream()
- : m_nLen(0),
+ : m_nMaxLen(1024*1024),
+ m_nLen(0),
m_nWritePos(0),
m_nReadPos(0),
- m_pBuffer(NULL) { }
+ m_pBuffer(0),
+ m_pFile(0) { }
FtpInputStream::~FtpInputStream() {
@@ -116,6 +118,9 @@ void SAL_CALL FtpInputStream::release( void ) throw() {
}
+/** nBytesToRead < 0
+ returns zero written bytes.
+*/
sal_Int32 SAL_CALL FtpInputStream::readBytes(Sequence< sal_Int8 >& aData,
sal_Int32 nBytesToRead)
@@ -130,10 +135,9 @@ sal_Int32 SAL_CALL FtpInputStream::readBytes(Sequence< sal_Int8 >& aData,
if(0 <= curr && aData.getLength() < curr)
aData.realloc(curr);
- for(sal_Int32 k = 0; k < curr; ++k )
- aData[k] = static_cast<sal_Int8*>(m_pBuffer)[m_nReadPos+k];
+ for(sal_Int32 k = 0; k < curr; )
+ aData[k++] = static_cast<sal_Int8*>(m_pBuffer)[m_nReadPos++];
- m_nReadPos += curr;
return curr > 0 ? curr : 0;
}
@@ -197,8 +201,12 @@ void SAL_CALL FtpInputStream::seek(sal_Int64 location)
-sal_Int64 SAL_CALL FtpInputStream::getPosition( void ) throw( IOException,
- RuntimeException ) {
+sal_Int64 SAL_CALL
+FtpInputStream::getPosition(
+ void )
+ throw( IOException,
+ RuntimeException )
+{
osl::MutexGuard aGuard( m_aMutex );
return sal_Int64(m_nReadPos);
}
@@ -212,16 +220,52 @@ sal_Int64 SAL_CALL FtpInputStream::getLength( void ) throw(
}
-void FtpInputStream::append(const void* pBuffer,sal_uInt32 nLen) throw() {
+const void* FtpInputStream::getBuffer(void) const throw()
+{
+ return m_pBuffer;
+}
+
+
+
+void
+FtpInputStream::append(
+ const void* pBuffer,
+ size_t size,
+ size_t nmemb
+) throw()
+{
+ if(m_pFile)
+ append2File(pBuffer,size,nmemb);
+
osl::MutexGuard aGuard( m_aMutex );
+ sal_uInt32 nLen = size*nmemb;
sal_uInt32 tmp(nLen + m_nWritePos);
+ if(tmp > 1024*1024) {
+ // if download is larger than 1MB store in file
+ m_pFile = tmpfile();
+ fwrite(m_pBuffer,m_nWritePos,1,m_pFile);
+ rtl_freeMemory(m_pBuffer),m_nLen = 0,m_nWritePos = 0,m_nReadPos = 0;
+ }
+ else
if(m_nLen < tmp) { // enlarge in steps of multiples of 1K
do {
m_nLen+=1024;
} while(m_nLen < tmp);
+
m_pBuffer = rtl_reallocateMemory(m_pBuffer,m_nLen);
}
-
- rtl_copyMemory(static_cast<sal_Int8*>(m_pBuffer)+m_nWritePos,pBuffer,nLen);
+ rtl_copyMemory(static_cast<sal_Int8*>(m_pBuffer)+m_nWritePos,
+ pBuffer,nLen);
m_nWritePos = tmp;
}
+
+
+void
+FtpInputStream::append2File(
+ const void* pBuffer,
+ size_t size,
+ size_t nmemb
+) throw()
+{
+ fwrite(pBuffer,size,nmemb,m_pFile);
+}
diff --git a/ucb/source/ucp/ftp/ftpinpstr.hxx b/ucb/source/ucp/ftp/ftpinpstr.hxx
index 7111bde54f61..49be6ded94b9 100644
--- a/ucb/source/ucp/ftp/ftpinpstr.hxx
+++ b/ucb/source/ucp/ftp/ftpinpstr.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ftpinpstr.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: abi $ $Date: 2002-06-24 15:17:55 $
+ * last change: $Author: abi $ $Date: 2002-07-31 15:13:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -68,6 +68,9 @@
#ifndef _FTP_FTPINPSTR_HXX_
#define _FTP_FTPINPSTR_HXX_
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
#ifndef _CPPUHELPER_WEAK_HXX_
#include <cppuhelper/weak.hxx>
#endif
@@ -80,6 +83,8 @@
#ifndef _COM_SUN_STAR_IO_XSEEKABLE_HPP_
#include <com/sun/star/io/XSeekable.hpp>
#endif
+#include <stdio.h>
+
namespace ftp {
@@ -98,6 +103,10 @@ namespace ftp {
{
public:
+ /** Defines the storage kind found
+ * on which the inputstream acts.
+ */
+
FtpInputStream();
~FtpInputStream();
@@ -170,14 +179,25 @@ namespace ftp {
/** appends the content of *pBuffer.
*/
- void append(const void* pBuffer,sal_uInt32 nLen) throw();
+ void append(const void* pBuffer,size_t size,size_t nmemb) throw();
+
+ const void* getBuffer() const throw();
private:
+ /** Don't hold more than 1MB in memory.
+ */
+
+ const sal_uInt32 m_nMaxLen;
+
osl::Mutex m_aMutex;
sal_uInt32 m_nLen,m_nWritePos,m_nReadPos;
void* m_pBuffer;
+ rtl::OUString m_aTmpFileURL;
+
+ FILE* m_pFile;
+ void append2File(const void* pBuffer,size_t size,size_t nmemb) throw();
};
diff --git a/ucb/source/ucp/ftp/ftploaderthread.hxx b/ucb/source/ucp/ftp/ftploaderthread.hxx
index d873d63218fc..7f210abf2efa 100644
--- a/ucb/source/ucp/ftp/ftploaderthread.hxx
+++ b/ucb/source/ucp/ftp/ftploaderthread.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ftploaderthread.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: abi $ $Date: 2002-06-24 15:17:55 $
+ * last change: $Author: abi $ $Date: 2002-07-31 15:13:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -78,7 +78,8 @@
namespace ftp {
- /** A loaderthread acts as factory for CURL-handles.
+ /** A loaderthread acts as factory for CURL-handles,
+ * the key being ( implicit ) the threadid.
* Owner is a FtpContentProvider-instance
*/
@@ -94,7 +95,7 @@ namespace ftp {
private:
- /** Don't enable assignment and copyconstruction.
+ /** Don't enable assignment and copy construction.
* Not defined:
*/
diff --git a/ucb/source/ucp/ftp/ftpresultsetI.cxx b/ucb/source/ucp/ftp/ftpresultsetI.cxx
new file mode 100644
index 000000000000..5c34f48a00e7
--- /dev/null
+++ b/ucb/source/ucp/ftp/ftpresultsetI.cxx
@@ -0,0 +1,259 @@
+/*************************************************************************
+ *
+ * $RCSfile: ftpresultsetI.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: abi $ $Date: 2002-07-31 15:13:29 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _COM_SUN_STAR_UCB_COMMAND_HPP_
+#include <com/sun/star/ucb/Command.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCOMMANDENVIRONMENT_HPP_
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCOMMANDPROCESSOR_HPP_
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
+#endif
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <ucbhelper/propertyvalueset.hxx>
+#include <vos/ref.hxx>
+#include "ftpresultsetI.hxx"
+
+
+
+using namespace std;
+using namespace ftp;
+using namespace com::sun::star;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+
+
+ResultSetI::ResultSetI(const Reference< lang::XMultiServiceFactory >& xMSF,
+ const Reference< XContentProvider >& xProvider,
+ sal_Int32 nOpenMode,
+ const Sequence< beans::Property >& seqProp,
+ const Sequence< NumberedSortingInfo >& seqSort,
+ const std::vector<FTPDirentry>& dirvec)
+ : ResultSetBase(xMSF,xProvider,nOpenMode,seqProp,seqSort)
+{
+ for(unsigned i = 0; i < dirvec.size(); ++i)
+ m_aPath.push_back(dirvec[i].m_aURL);
+
+ // m_aIdents holds the contentidentifiers
+
+ m_aItems.resize( m_aPath.size() );
+ m_aIdents.resize( m_aPath.size() );
+
+ for(unsigned n = 0; n < m_aItems.size(); ++n) {
+ vos::ORef<::ucb::PropertyValueSet> xRow =
+ new ::ucb::PropertyValueSet(xMSF);
+
+ for(i = 0; i < seqProp.getLength(); ++i) {
+ const rtl::OUString& Name = seqProp[i].Name;
+ if(Name.compareToAscii("ContentType") == 0 )
+ xRow->appendString(seqProp[i],
+ rtl::OUString::createFromAscii(
+ "application/ftp" ));
+ else if(Name.compareToAscii("Title") == 0)
+ xRow->appendString(seqProp[i],dirvec[n].m_aName);
+ else if(Name.compareToAscii("IsReadOnly") == 0)
+ xRow->appendBoolean(seqProp[i],
+ sal_Bool(dirvec[n].m_nMode &
+ INETCOREFTP_FILEMODE_WRITE));
+ else if(Name.compareToAscii("IsDocument") == 0)
+ xRow->appendBoolean(seqProp[i],
+ ! sal_Bool(dirvec[n].m_nMode &
+ INETCOREFTP_FILEMODE_ISDIR));
+ else if(Name.compareToAscii("IsFolder") == 0)
+ xRow->appendBoolean(seqProp[i],
+ sal_Bool(dirvec[n].m_nMode &
+ INETCOREFTP_FILEMODE_ISDIR));
+ else if(Name.compareToAscii("Size") == 0)
+ xRow->appendLong(seqProp[i],
+ dirvec[n].m_nSize);
+ else if(Name.compareToAscii("DateCreated") == 0)
+ xRow->appendTimestamp(seqProp[i],
+ dirvec[n].m_aDate);
+ else
+ xRow->appendVoid(seqProp[i]);
+ }
+ m_aItems[n] = Reference<XRow>(xRow.getBodyPtr());
+ }
+
+// unsigned int i;
+// vector< vector< rtl::OUString > > queryList;
+
+// {
+// sal_Int32 idx;
+// rtl::OUString query = m_aURLParameter.get_query();
+// while( query.getLength() )
+// {
+// idx = query.indexOf( sal_Unicode( ' ' ) );
+// if( idx == -1 )
+// idx = query.getLength();
+
+// vector< rtl::OUString > currentQuery;
+// currentQuery.push_back( query.copy( 0,idx ) );
+// queryList.push_back( currentQuery );
+// query = query.copy( 1 + idx );
+// }
+// }
+
+// rtl::OUString scope = m_aURLParameter.get_scope();
+// StaticModuleInformation* inf =
+// m_pDatabases->getStaticInformationForModule( m_aURLParameter.get_module(),
+// m_aURLParameter.get_language() );
+
+// if( inf )
+// {
+// if( scope.compareToAscii( "Heading" ) == 0 )
+// scope = inf->get_heading();
+// else
+// scope = inf->get_fulltext();
+// }
+
+// sal_Int32 hitCount = m_aURLParameter.get_hitCount();
+
+// QueryResults* queryResults = 0;
+// QueryHitIterator* it = 0;
+// set< rtl::OUString > aSet,aCurrent,aResultSet;
+
+// try
+// {
+// rtl::OUString idxDir =
+// m_pDatabases->getInstallPathAsURL() +
+// m_pDatabases->lang( m_aURLParameter.get_language() ) +
+// rtl::OUString::createFromAscii( "/" ) +
+// m_aURLParameter.get_module() +
+// rtl::OUString::createFromAscii( ".idx/" );
+
+// for( i = 0; i < queryList.size(); ++i )
+// {
+// QueryProcessor queryProcessor(idxDir);
+// QueryStatement queryStatement(hitCount,queryList[i],scope);
+// queryResults = queryProcessor.processQuery( queryStatement );
+
+// it = 0;
+// if( queryResults )
+// it = queryResults->makeQueryHitIterator();
+
+// aSet.clear();
+// while( it && it->next() )
+// {
+// QueryHitData* qhd = it->getHit( 0 /*PrefixTranslator*/ );
+// if(qhd)
+// aSet.insert(qhd->getDocument());
+// }
+
+// delete it; // deletes also queryResults[i]
+
+// // intersect
+// if( i == 0 )
+// aResultSet = aSet;
+// else
+// {
+// aCurrent = aResultSet;
+// aResultSet.clear();
+// set_intersection( aSet.begin(),aSet.end(),
+// aCurrent.begin(),aCurrent.end(),
+// inserter(aResultSet,aResultSet.begin()));
+// }
+// }
+// }
+// catch( IOException )
+// {
+// }
+
+// sal_Int32 replIdx = rtl::OUString::createFromAscii( "#HLP#" ).getLength();
+// rtl::OUString replWith = rtl::OUString::createFromAscii( "vnd.sun.star.help://" );
+
+// set< rtl::OUString >::const_iterator set_it = aResultSet.begin();
+// while( set_it != aResultSet.end() )
+// {
+// m_aPath.push_back(replWith + set_it->copy(replIdx));
+// ++set_it;
+// }
+
+// m_aItems.resize( m_aPath.size() );
+// m_aIdents.resize( m_aPath.size() );
+
+// Command aCommand;
+// aCommand.Name = rtl::OUString::createFromAscii( "getPropertyValues" );
+// aCommand.Argument <<= m_sProperty;
+
+// for( m_nRow = 0; m_nRow < m_aPath.size(); ++m_nRow )
+// {
+// m_aPath[m_nRow] =
+// m_aPath[m_nRow] +
+// rtl::OUString::createFromAscii( "?Language=" ) +
+// m_aURLParameter.get_language() +
+// rtl::OUString::createFromAscii( "&System=" ) +
+// m_aURLParameter.get_system();
+
+// Reference< XContent > content = queryContent();
+// if( content.is() )
+// {
+// Reference< XCommandProcessor > cmd( content,UNO_QUERY );
+// if( ! ( cmd->execute( aCommand,0,Reference< XCommandEnvironment >( 0 ) ) >>= m_aItems[m_nRow] ) )
+// ;
+// }
+// }
+// m_nRow = -1;
+}
diff --git a/ucb/source/ucp/ftp/ftpresultsetI.hxx b/ucb/source/ucp/ftp/ftpresultsetI.hxx
new file mode 100644
index 000000000000..98ab70cff1da
--- /dev/null
+++ b/ucb/source/ucp/ftp/ftpresultsetI.hxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * $RCSfile: ftpresultsetI.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: abi $ $Date: 2002-07-31 15:13:31 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _FTP_FTPRESULTSETI_HXX_
+#define _FTP_FTPRESULTSETI_HXX_
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDER_HPP_
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_
+#include <com/sun/star/beans/Property.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_NUMBEREDSORTINGINFO_HPP_
+#include <com/sun/star/ucb/NumberedSortingInfo.hpp>
+#endif
+#include "ftpresultsetbase.hxx"
+#include "ftpdirp.hxx"
+
+
+namespace ftp {
+
+ class ResultSetI
+ : public ResultSetBase
+ {
+ public:
+
+ ResultSetI(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory>& xMSF,
+ const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentProvider>& xProvider,
+ sal_Int32 nOpenMode,
+ const com::sun::star::uno::Sequence<
+ com::sun::star::beans::Property >& seq,
+ const com::sun::star::uno::Sequence<
+ com::sun::star::ucb::NumberedSortingInfo >& seqSort,
+ const std::vector<FTPDirentry>& dirvec);
+
+ private:
+ };
+
+}
+
+
+#endif
diff --git a/ucb/source/ucp/ftp/ftpresultsetbase.cxx b/ucb/source/ucp/ftp/ftpresultsetbase.cxx
new file mode 100644
index 000000000000..8f8e6a57470f
--- /dev/null
+++ b/ucb/source/ucp/ftp/ftpresultsetbase.cxx
@@ -0,0 +1,710 @@
+/*************************************************************************
+ *
+ * $RCSfile: ftpresultsetbase.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: abi $ $Date: 2002-07-31 15:13:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _UCBHELPER_CONTENTIDENTIFIER_HXX
+#include <ucbhelper/contentidentifier.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UCB_OPENMODE_HPP_
+#include <com/sun/star/ucb/OpenMode.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
+#include <com/sun/star/uno/Reference.h>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_LISTACTIONTYPE_HPP_
+#include <com/sun/star/ucb/ListActionType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XSOURCEINITIALIZATION_HPP_
+#include <com/sun/star/ucb/XSourceInitialization.hpp>
+#endif
+#ifndef _UCBHELPER_RESULTSETMETADATA_HXX
+#include <ucbhelper/resultsetmetadata.hxx>
+#endif
+#ifndef _FTP_FTPRESULTSETBASE_HXX_
+#include "ftpresultsetbase.hxx"
+#endif
+
+using namespace ftp;
+using namespace com::sun::star;
+using namespace com::sun::star::ucb;
+
+
+ResultSetBase::ResultSetBase(
+ const uno::Reference< lang::XMultiServiceFactory >& xMSF,
+ const uno::Reference< XContentProvider >& xProvider,
+ sal_Int32 nOpenMode,
+ const uno::Sequence< beans::Property >& seq,
+ const uno::Sequence< NumberedSortingInfo >& seqSort )
+ : m_xMSF( xMSF ),
+ m_xProvider( xProvider ),
+ m_nRow( -1 ),
+ m_nWasNull( true ),
+ m_nOpenMode( nOpenMode ),
+ m_bRowCountFinal( true ),
+ m_sProperty( seq ),
+ m_sSortingInfo( seqSort ),
+ m_pDisposeEventListeners( 0 ),
+ m_pRowCountListeners( 0 ),
+ m_pIsFinalListeners( 0 )
+{
+}
+
+ResultSetBase::~ResultSetBase()
+{
+ delete m_pIsFinalListeners;
+ delete m_pRowCountListeners;
+ delete m_pDisposeEventListeners;
+}
+
+
+// XInterface
+
+void SAL_CALL
+ResultSetBase::acquire(
+ void )
+ throw()
+{
+ OWeakObject::acquire();
+}
+
+
+void SAL_CALL
+ResultSetBase::release(
+ void )
+ throw()
+{
+ OWeakObject::release();
+}
+
+
+
+uno::Any SAL_CALL
+ResultSetBase::queryInterface(
+ const uno::Type& rType )
+ throw( uno::RuntimeException )
+{
+ uno::Any aRet = cppu::queryInterface(
+ rType,
+ SAL_STATIC_CAST( lang::XComponent*, this),
+ SAL_STATIC_CAST( sdbc::XRow*, this),
+ SAL_STATIC_CAST( sdbc::XResultSet*, this),
+ SAL_STATIC_CAST( sdbc::XResultSetMetaDataSupplier*, this),
+ SAL_STATIC_CAST( beans::XPropertySet*, this ),
+ SAL_STATIC_CAST( XContentAccess*, this) );
+ return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
+}
+
+
+
+// XComponent
+
+
+void SAL_CALL
+ResultSetBase::addEventListener(
+ const uno::Reference< lang::XEventListener >& Listener )
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( ! m_pDisposeEventListeners )
+ m_pDisposeEventListeners =
+ new cppu::OInterfaceContainerHelper( m_aMutex );
+
+ m_pDisposeEventListeners->addInterface( Listener );
+}
+
+
+void SAL_CALL
+ResultSetBase::removeEventListener(
+ const uno::Reference< lang::XEventListener >& Listener )
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pDisposeEventListeners )
+ m_pDisposeEventListeners->removeInterface( Listener );
+}
+
+
+
+void SAL_CALL
+ResultSetBase::dispose()
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ lang::EventObject aEvt;
+ aEvt.Source = static_cast< lang::XComponent * >( this );
+
+ if ( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
+ {
+ m_pDisposeEventListeners->disposeAndClear( aEvt );
+ }
+ if( m_pRowCountListeners && m_pRowCountListeners->getLength() )
+ {
+ m_pRowCountListeners->disposeAndClear( aEvt );
+ }
+ if( m_pIsFinalListeners && m_pIsFinalListeners->getLength() )
+ {
+ m_pIsFinalListeners->disposeAndClear( aEvt );
+ }
+}
+
+
+
+// XResultSet
+
+sal_Bool SAL_CALL
+ResultSetBase::next(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException )
+{
+ sal_Bool test;
+ if( ++m_nRow < m_aItems.size() )
+ test = true;
+ else
+ test = false;
+ return test;
+}
+
+
+sal_Bool SAL_CALL
+ResultSetBase::isBeforeFirst(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException )
+{
+ return m_nRow == -1;
+}
+
+
+sal_Bool SAL_CALL
+ResultSetBase::isAfterLast(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException )
+{
+ return m_nRow >= m_aItems.size(); // Cannot happen, if m_aFolder.isOpen()
+}
+
+
+sal_Bool SAL_CALL
+ResultSetBase::isFirst(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException )
+{
+ return m_nRow == 0;
+}
+
+
+sal_Bool SAL_CALL
+ResultSetBase::isLast(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException)
+{
+ if( m_nRow == m_aItems.size() - 1 )
+ return true;
+ else
+ return false;
+}
+
+
+void SAL_CALL
+ResultSetBase::beforeFirst(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException)
+{
+ m_nRow = -1;
+}
+
+
+void SAL_CALL
+ResultSetBase::afterLast(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException )
+{
+ m_nRow = m_aItems.size();
+}
+
+
+sal_Bool SAL_CALL
+ResultSetBase::first(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException)
+{
+ m_nRow = -1;
+ return next();
+}
+
+
+sal_Bool SAL_CALL
+ResultSetBase::last(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException )
+{
+ m_nRow = m_aItems.size() - 1;
+ return true;
+}
+
+
+sal_Int32 SAL_CALL
+ResultSetBase::getRow(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException)
+{
+ // Test, whether behind last row
+ if( -1 == m_nRow || m_nRow >= m_aItems.size() )
+ return 0;
+ else
+ return m_nRow+1;
+}
+
+
+sal_Bool SAL_CALL ResultSetBase::absolute( sal_Int32 row )
+ throw( sdbc::SQLException, uno::RuntimeException)
+{
+ if( row >= 0 )
+ m_nRow = row - 1;
+ else
+ {
+ last();
+ m_nRow += ( row + 1 );
+ if( m_nRow < -1 )
+ m_nRow = -1;
+ }
+
+ return 0<= m_nRow && m_nRow < m_aItems.size();
+}
+
+
+
+
+sal_Bool SAL_CALL
+ResultSetBase::relative(
+ sal_Int32 row )
+ throw( sdbc::SQLException,
+ uno::RuntimeException)
+{
+ if( isAfterLast() || isBeforeFirst() )
+ throw sdbc::SQLException();
+
+ if( row > 0 )
+ while( row-- )
+ next();
+ else if( row < 0 )
+ while( row++ && m_nRow > - 1 )
+ previous();
+
+ return 0 <= m_nRow && m_nRow < m_aItems.size();
+}
+
+
+
+sal_Bool SAL_CALL
+ResultSetBase::previous(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException)
+{
+ if( m_nRow > m_aItems.size() )
+ m_nRow = m_aItems.size(); // Correct Handling of afterLast
+ if( 0 <= m_nRow ) -- m_nRow;
+
+ return 0 <= m_nRow && m_nRow < m_aItems.size();
+}
+
+
+void SAL_CALL
+ResultSetBase::refreshRow(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException)
+{
+}
+
+
+sal_Bool SAL_CALL
+ResultSetBase::rowUpdated(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException )
+{
+ return false;
+}
+
+sal_Bool SAL_CALL
+ResultSetBase::rowInserted(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException )
+{
+ return false;
+}
+
+sal_Bool SAL_CALL
+ResultSetBase::rowDeleted(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException )
+{
+ return false;
+}
+
+
+uno::Reference< uno::XInterface > SAL_CALL
+ResultSetBase::getStatement(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException )
+{
+ uno::Reference< uno::XInterface > test( 0 );
+ return test;
+}
+
+
+// XCloseable
+
+void SAL_CALL
+ResultSetBase::close(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException)
+{
+}
+
+
+rtl::OUString SAL_CALL
+ResultSetBase::queryContentIdentifierString(
+ void )
+ throw( uno::RuntimeException )
+{
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aPath[m_nRow];
+ else
+ return rtl::OUString();
+}
+
+
+uno::Reference< XContentIdentifier > SAL_CALL
+ResultSetBase::queryContentIdentifier(
+ void
+)
+ throw(
+ uno::RuntimeException
+ )
+{
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ {
+ if(!m_aIdents[m_nRow].is()) {
+ rtl::OUString url = queryContentIdentifierString();
+ if(url.getLength() )
+ m_aIdents[m_nRow] =
+ uno::Reference< XContentIdentifier >(
+ new ::ucb::ContentIdentifier(m_xMSF,url) );
+ }
+ return m_aIdents[m_nRow];
+ }
+
+ return uno::Reference<XContentIdentifier>();
+}
+
+
+uno::Reference< XContent > SAL_CALL
+ResultSetBase::queryContent(
+ void )
+ throw( uno::RuntimeException )
+{
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_xProvider->queryContent(queryContentIdentifier());
+ else
+ return uno::Reference< XContent >();
+}
+
+
+
+class XPropertySetInfoImpl
+ : public cppu::OWeakObject,
+ public beans::XPropertySetInfo
+{
+public:
+
+ XPropertySetInfoImpl( const uno::Sequence< beans::Property >& aSeq )
+ : m_aSeq( aSeq )
+ {
+ }
+
+ void SAL_CALL acquire( void )
+ throw()
+ {
+ OWeakObject::acquire();
+ }
+
+
+ void SAL_CALL release( void )
+ throw()
+ {
+ OWeakObject::release();
+ }
+
+ uno::Any SAL_CALL queryInterface( const uno::Type& rType )
+ throw( uno::RuntimeException )
+ {
+ uno::Any aRet = cppu::queryInterface(
+ rType,
+ SAL_STATIC_CAST( beans::XPropertySetInfo*, this ) );
+ return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
+ }
+
+ uno::Sequence< beans::Property > SAL_CALL getProperties()
+ throw( uno::RuntimeException )
+ {
+ return m_aSeq;
+ }
+
+ beans::Property SAL_CALL getPropertyByName( const ::rtl::OUString& aName )
+ throw( beans::UnknownPropertyException,
+ uno::RuntimeException)
+ {
+ for( int i = 0; i < m_aSeq.getLength(); ++i )
+ if( aName == m_aSeq[i].Name )
+ return m_aSeq[i];
+ throw beans::UnknownPropertyException();
+ }
+
+ sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& Name )
+ throw( uno::RuntimeException )
+ {
+ for( int i = 0; i < m_aSeq.getLength(); ++i )
+ if( Name == m_aSeq[i].Name )
+ return true;
+ return false;
+ }
+
+private:
+
+ uno::Sequence< beans::Property > m_aSeq;
+};
+
+
+
+// XPropertySet
+uno::Reference< beans::XPropertySetInfo > SAL_CALL
+ResultSetBase::getPropertySetInfo()
+ throw( uno::RuntimeException)
+{
+ uno::Sequence< beans::Property > seq(2);
+ seq[0].Name = rtl::OUString::createFromAscii( "RowCount" );
+ seq[0].Handle = -1;
+ seq[0].Type = getCppuType( static_cast< sal_Int32* >(0) );
+ seq[0].Attributes = beans::PropertyAttribute::READONLY;
+
+ seq[1].Name = rtl::OUString::createFromAscii( "IsRowCountFinal" );
+ seq[1].Handle = -1;
+ seq[1].Type = getCppuType( static_cast< sal_Bool* >(0) );
+ seq[1].Attributes = beans::PropertyAttribute::READONLY;
+
+ //t
+ return uno::Reference< beans::XPropertySetInfo > (
+ new XPropertySetInfoImpl( seq ) );
+}
+
+
+
+void SAL_CALL ResultSetBase::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw( beans::UnknownPropertyException,
+ beans::PropertyVetoException,
+ lang::IllegalArgumentException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ if( aPropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) ||
+ aPropertyName == rtl::OUString::createFromAscii( "RowCount" ) )
+ return;
+
+ throw beans::UnknownPropertyException();
+}
+
+
+uno::Any SAL_CALL ResultSetBase::getPropertyValue(
+ const rtl::OUString& PropertyName )
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ if( PropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) )
+ {
+ uno::Any aAny;
+ aAny <<= m_bRowCountFinal;
+ return aAny;
+ }
+ else if ( PropertyName == rtl::OUString::createFromAscii( "RowCount" ) )
+ {
+ uno::Any aAny;
+ sal_Int32 count = m_aItems.size();
+ aAny <<= count;
+ return aAny;
+ }
+ else
+ throw beans::UnknownPropertyException();
+}
+
+
+void SAL_CALL ResultSetBase::addPropertyChangeListener(
+ const rtl::OUString& aPropertyName,
+ const uno::Reference< beans::XPropertyChangeListener >& xListener )
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ if( aPropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) )
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+ if ( ! m_pIsFinalListeners )
+ m_pIsFinalListeners =
+ new cppu::OInterfaceContainerHelper( m_aMutex );
+
+ m_pIsFinalListeners->addInterface( xListener );
+ }
+ else if ( aPropertyName == rtl::OUString::createFromAscii( "RowCount" ) )
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+ if ( ! m_pRowCountListeners )
+ m_pRowCountListeners =
+ new cppu::OInterfaceContainerHelper( m_aMutex );
+ m_pRowCountListeners->addInterface( xListener );
+ }
+ else
+ throw beans::UnknownPropertyException();
+}
+
+
+void SAL_CALL ResultSetBase::removePropertyChangeListener(
+ const rtl::OUString& aPropertyName,
+ const uno::Reference< beans::XPropertyChangeListener >& aListener )
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ if( aPropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) &&
+ m_pIsFinalListeners )
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+ m_pIsFinalListeners->removeInterface( aListener );
+ }
+ else if ( aPropertyName == rtl::OUString::createFromAscii( "RowCount" ) &&
+ m_pRowCountListeners )
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+ m_pRowCountListeners->removeInterface( aListener );
+ }
+ else
+ throw beans::UnknownPropertyException();
+}
+
+
+void SAL_CALL ResultSetBase::addVetoableChangeListener(
+ const rtl::OUString& PropertyName,
+ const uno::Reference< beans::XVetoableChangeListener >& aListener )
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+}
+
+
+void SAL_CALL ResultSetBase::removeVetoableChangeListener(
+ const rtl::OUString& PropertyName,
+ const uno::Reference< beans::XVetoableChangeListener >& aListener )
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+}
+
+
+
+// XResultSetMetaDataSupplier
+uno::Reference< sdbc::XResultSetMetaData > SAL_CALL
+ResultSetBase::getMetaData(
+ void )
+ throw( sdbc::SQLException,
+ uno::RuntimeException )
+{
+ ::ucb::ResultSetMetaData* p =
+ new ::ucb::ResultSetMetaData(
+ m_xMSF, m_sProperty );
+ return uno::Reference< sdbc::XResultSetMetaData >( p );
+}
+
+
+
+
diff --git a/ucb/source/ucp/ftp/ftpresultsetbase.hxx b/ucb/source/ucp/ftp/ftpresultsetbase.hxx
new file mode 100644
index 000000000000..3fba3da8ca69
--- /dev/null
+++ b/ucb/source/ucp/ftp/ftpresultsetbase.hxx
@@ -0,0 +1,669 @@
+/*************************************************************************
+ *
+ * $RCSfile: ftpresultsetbase.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: abi $ $Date: 2002-07-31 15:13:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _FTP_FTPRESULTSETBASE_HXX_
+#define _FTP_FTPRESULTSETBASE_HXX_
+
+#include <vector>
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENTACCESS_HPP_
+#include <com/sun/star/ucb/XContentAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_NUMBEREDSORTINGINFO_HPP_
+#include <com/sun/star/ucb/NumberedSortingInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDER_HPP_
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENTIDENTIFIER_HPP_
+#include <com/sun/star/ucb/XContentIdentifier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_
+#include <com/sun/star/beans/Property.hpp>
+#endif
+
+
+namespace ftp {
+
+ class ResultSetBase
+ : public cppu::OWeakObject,
+ public com::sun::star::lang::XComponent,
+ public com::sun::star::sdbc::XRow,
+ public com::sun::star::sdbc::XResultSet,
+ public com::sun::star::sdbc::XCloseable,
+ public com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ public com::sun::star::beans::XPropertySet,
+ public com::sun::star::ucb::XContentAccess
+ {
+ public:
+
+ ResultSetBase(const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >& xMSF,
+ const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentProvider >& xProvider,
+ sal_Int32 nOpenMode,
+ const com::sun::star::uno::Sequence<
+ com::sun::star::beans::Property >& seq,
+ const com::sun::star::uno::Sequence<
+ com::sun::star::ucb::NumberedSortingInfo >& seqSort);
+
+ virtual ~ResultSetBase();
+
+ // XInterface
+ virtual com::sun::star::uno::Any SAL_CALL
+ queryInterface(
+ const com::sun::star::uno::Type& aType )
+ throw( com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ acquire(
+ void )
+ throw();
+
+ virtual void SAL_CALL
+ release(
+ void )
+ throw();
+
+ // XComponent
+ virtual void SAL_CALL
+ dispose(
+ void )
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ addEventListener(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XEventListener >& xListener )
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ removeEventListener( const com::sun::star::uno::Reference<
+ com::sun::star::lang::XEventListener >& aListener )
+ throw( com::sun::star::uno::RuntimeException );
+
+
+ // XRow
+ virtual sal_Bool SAL_CALL
+ wasNull(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException )
+ {
+ if( 0<= m_nRow && m_nRow < m_aItems.size() )
+ m_nWasNull = m_aItems[m_nRow]->wasNull();
+ else
+ m_nWasNull = true;
+ return m_nWasNull;
+ }
+
+ virtual rtl::OUString SAL_CALL
+ getString(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException)
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getString( columnIndex );
+ else
+ return rtl::OUString();
+ }
+
+ virtual sal_Bool SAL_CALL
+ getBoolean(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException)
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getBoolean( columnIndex );
+ else
+ return false;
+ }
+
+ virtual sal_Int8 SAL_CALL
+ getByte(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException)
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getByte( columnIndex );
+ else
+ return sal_Int8( 0 );
+ }
+
+ virtual sal_Int16 SAL_CALL
+ getShort(
+ sal_Int32 columnIndex )
+ throw(
+ com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException)
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getShort( columnIndex );
+ else
+ return sal_Int16( 0 );
+ }
+
+ virtual sal_Int32 SAL_CALL
+ getInt(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException )
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getInt( columnIndex );
+ else
+ return sal_Int32( 0 );
+ }
+
+ virtual sal_Int64 SAL_CALL
+ getLong(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException)
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getLong( columnIndex );
+ else
+ return sal_Int64( 0 );
+ }
+
+ virtual float SAL_CALL
+ getFloat(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException )
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getFloat( columnIndex );
+ else
+ return float( 0 );
+ }
+
+ virtual double SAL_CALL
+ getDouble(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException )
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getDouble( columnIndex );
+ else
+ return double( 0 );
+ }
+
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
+ getBytes(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException )
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getBytes( columnIndex );
+ else
+ return com::sun::star::uno::Sequence< sal_Int8 >();
+ }
+
+ virtual com::sun::star::util::Date SAL_CALL
+ getDate(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException)
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getDate( columnIndex );
+ else
+ return com::sun::star::util::Date();
+ }
+
+ virtual com::sun::star::util::Time SAL_CALL
+ getTime(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException)
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getTime( columnIndex );
+ else
+ return com::sun::star::util::Time();
+ }
+
+ virtual com::sun::star::util::DateTime SAL_CALL
+ getTimestamp(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException)
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getTimestamp( columnIndex );
+ else
+ return com::sun::star::util::DateTime();
+ }
+
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::io::XInputStream > SAL_CALL
+ getBinaryStream(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException)
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getBinaryStream( columnIndex );
+ else
+ return com::sun::star::uno::Reference<
+ com::sun::star::io::XInputStream >();
+ }
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::io::XInputStream > SAL_CALL
+ getCharacterStream(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException)
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getCharacterStream( columnIndex );
+ else
+ return com::sun::star::uno::Reference<
+ com::sun::star::io::XInputStream >();
+ }
+
+ virtual com::sun::star::uno::Any SAL_CALL
+ getObject(
+ sal_Int32 columnIndex,
+ const com::sun::star::uno::Reference<
+ com::sun::star::container::XNameAccess >& typeMap )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException)
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getObject( columnIndex,typeMap );
+ else
+ return com::sun::star::uno::Any();
+ }
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XRef > SAL_CALL
+ getRef(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException)
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getRef( columnIndex );
+ else
+ return com::sun::star::uno::Reference< com::sun::star::sdbc::XRef >();
+ }
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XBlob > SAL_CALL
+ getBlob(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException)
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getBlob( columnIndex );
+ else
+ return com::sun::star::uno::Reference< com::sun::star::sdbc::XBlob >();
+ }
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XClob > SAL_CALL
+ getClob(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException)
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getClob( columnIndex );
+ else
+ return com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XClob >();
+ }
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XArray > SAL_CALL
+ getArray(
+ sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException)
+ {
+ if( 0 <= m_nRow && m_nRow < m_aItems.size() )
+ return m_aItems[m_nRow]->getArray( columnIndex );
+ else
+ return com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XArray >();
+ }
+
+
+ // XResultSet
+
+ virtual sal_Bool SAL_CALL
+ next(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL
+ isBeforeFirst(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL
+ isAfterLast(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL
+ isFirst(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL
+ isLast(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ beforeFirst(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ afterLast(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL
+ first(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL
+ last(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL
+ getRow(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL
+ absolute(
+ sal_Int32 row )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL
+ relative(
+ sal_Int32 rows )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL
+ previous(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ refreshRow(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL
+ rowUpdated(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL
+ rowInserted(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL
+ rowDeleted(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::uno::XInterface > SAL_CALL
+ getStatement(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ // XCloseable
+
+ virtual void SAL_CALL
+ close(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+ // XContentAccess
+
+ virtual rtl::OUString SAL_CALL
+ queryContentIdentifierString(
+ void )
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentIdentifier > SAL_CALL
+ queryContentIdentifier(
+ void )
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContent > SAL_CALL
+ queryContent(
+ void )
+ throw( com::sun::star::uno::RuntimeException );
+
+ // XResultSetMetaDataSupplier
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XResultSetMetaData > SAL_CALL
+ getMetaData(
+ void )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException);
+
+
+ // XPropertySet
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo()
+ throw( com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL setPropertyValue(
+ const rtl::OUString& aPropertyName,
+ const com::sun::star::uno::Any& aValue )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::beans::PropertyVetoException,
+ com::sun::star::lang::IllegalArgumentException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual com::sun::star::uno::Any SAL_CALL
+ getPropertyValue(
+ const rtl::OUString& PropertyName )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ addPropertyChangeListener(
+ const rtl::OUString& aPropertyName,
+ const com::sun::star::uno::Reference<
+ com::sun::star::beans::XPropertyChangeListener >& xListener )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ removePropertyChangeListener(
+ const rtl::OUString& aPropertyName,
+ const com::sun::star::uno::Reference<
+ com::sun::star::beans::XPropertyChangeListener >& aListener )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ addVetoableChangeListener(
+ const rtl::OUString& PropertyName,
+ const com::sun::star::uno::Reference<
+ com::sun::star::beans::XVetoableChangeListener >& aListener )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL removeVetoableChangeListener(
+ const rtl::OUString& PropertyName,
+ const com::sun::star::uno::Reference<
+ com::sun::star::beans::XVetoableChangeListener >& aListener )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException);
+
+ protected:
+
+ com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > m_xMSF;
+ com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentProvider > m_xProvider;
+ sal_uInt32 m_nRow;
+ sal_Bool m_nWasNull;
+ sal_Int32 m_nOpenMode;
+ sal_Bool m_bRowCountFinal;
+
+ typedef std::vector< com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentIdentifier > > IdentSet;
+ typedef std::vector< com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XRow > > ItemSet;
+ typedef std::vector< rtl::OUString >
+ PathSet;
+
+ IdentSet m_aIdents;
+ ItemSet m_aItems;
+ PathSet m_aPath;
+
+ com::sun::star::uno::Sequence<
+ com::sun::star::beans::Property > m_sProperty;
+ com::sun::star::uno::Sequence<
+ com::sun::star::ucb::NumberedSortingInfo > m_sSortingInfo;
+
+ osl::Mutex m_aMutex;
+ cppu::OInterfaceContainerHelper* m_pDisposeEventListeners;
+
+ cppu::OInterfaceContainerHelper* m_pRowCountListeners;
+ cppu::OInterfaceContainerHelper* m_pIsFinalListeners;
+ };
+
+
+} // end namespace fileaccess
+
+
+#endif
diff --git a/ucb/source/ucp/ftp/ftpresultsetfactory.hxx b/ucb/source/ucp/ftp/ftpresultsetfactory.hxx
new file mode 100644
index 000000000000..9516b5dd0c25
--- /dev/null
+++ b/ucb/source/ucp/ftp/ftpresultsetfactory.hxx
@@ -0,0 +1,27 @@
+#ifndef _FTP_FTPRESULTSETFACTORY_HXX_
+#define _FTP_FTPRESULTSETFACTORY_HXX_
+
+#ifndef _FTP_FTPRESULTSETBASE_HXX_
+#include "ftpresultsetbase.hxx"
+#endif
+
+
+
+namespace ftp {
+
+ class ResultSetBase;
+
+ class ResultSetFactory
+ {
+ public:
+
+ virtual ~ResultSetFactory() { };
+
+ virtual ResultSetBase* createResultSet() = 0;
+ };
+
+}
+
+
+
+#endif
diff --git a/ucb/source/ucp/ftp/makefile.mk b/ucb/source/ucp/ftp/makefile.mk
index aa6c5302ce56..b39bb9139129 100644
--- a/ucb/source/ucp/ftp/makefile.mk
+++ b/ucb/source/ucp/ftp/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.2 $
+# $Revision: 1.3 $
#
-# last change: $Author: abi $ $Date: 2002-06-24 15:17:55 $
+# last change: $Author: abi $ $Date: 2002-07-31 15:13:37 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -79,9 +79,16 @@ UCPFTP_MAJOR=1
SLOFILES=\
$(SLO)$/ftpservices.obj \
$(SLO)$/ftpcontentprovider.obj \
+ $(SLO)$/ftpurl.obj \
$(SLO)$/ftpcontent.obj \
+ $(SLO)$/ftpcontentidentifier.obj \
+ $(SLO)$/ftpcontentcaps.obj \
+ $(SLO)$/ftpdynresultset.obj \
+ $(SLO)$/ftpresultsetbase.obj \
+ $(SLO)$/ftpresultsetI.obj \
$(SLO)$/ftploaderthread.obj \
- $(SLO)$/ftpinpstr.obj
+ $(SLO)$/ftpinpstr.obj \
+ $(SLO)$/ftpdirp.obj
LIB1TARGET=$(SLB)$/_$(TARGET).lib
LIB1OBJFILES=$(SLOFILES)
@@ -110,7 +117,20 @@ SHL1LIBS= \
APP1TARGET=ftptest
APP1OBJS=\
- $(OBJ)$/test.obj
+ $(OBJ)$/test.obj \
+ $(OBJ)$/test_activedatasink.obj \
+ $(OBJ)$/test_multiservicefac.obj \
+ $(SLO)$/ftpcontentcaps.obj \
+ $(SLO)$/ftpservices.obj \
+ $(SLO)$/ftpcontentprovider.obj \
+ $(SLO)$/ftpcontent.obj \
+ $(SLO)$/ftpdynresultset.obj \
+ $(SLO)$/ftpresultsetbase.obj \
+ $(SLO)$/ftpresultsetI.obj \
+ $(SLO)$/ftpcontentidentifier.obj \
+ $(SLO)$/ftploaderthread.obj \
+ $(SLO)$/ftpinpstr.obj \
+ $(SLO)$/ftpdirp.obj
.IF "$(COMPHELPERLIB)"==""
.IF "$(GUI)" == "UNX"
@@ -125,7 +145,10 @@ APP1STDLIBS=\
$(CPPULIB) \
$(CPPUHELPERLIB) \
$(SALLIB) \
- $(COMPHELPERLIB)
+ $(VOSLIB) \
+ $(COMPHELPERLIB) \
+ $(UCBHELPERLIB) \
+ $(SOLARLIBDIR)$/libcurl.lib
APP1DEF= $(MISC)\$(APP1TARGET).def
diff --git a/ucb/source/ucp/ftp/test.cxx b/ucb/source/ucp/ftp/test.cxx
index a77fba834c4a..6baf6d990a5c 100644
--- a/ucb/source/ucp/ftp/test.cxx
+++ b/ucb/source/ucp/ftp/test.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: test.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: abi $ $Date: 2002-06-24 15:17:55 $
+ * last change: $Author: abi $ $Date: 2002-07-31 15:13:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,14 +65,15 @@
*************************************************************************/
+
#ifndef _OSL_PROCESS_H_
#include <osl/process.h>
#endif
#ifndef _OSL_FILE_HXX_
#include <osl/file.hxx>
#endif
-#ifndef _RTL_BOOTSTRAP_HXX_
-#include <rtl/bootstrap.hxx>
+#ifndef _THREAD_HXX_
+#include <osl/thread.hxx>
#endif
#ifndef _RTL_USTRING_HXX_
#include <rtl/ustring.hxx>
@@ -92,67 +93,160 @@
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENTIDENTIFIERFACTORY_HPP_
+#include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
+#include <com/sun/star/ucb/XContent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDER_HPP_
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCOMMANDPROCESSOR_HPP_
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_OPENMODE_HPP_
+#include <com/sun/star/ucb/OpenMode.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_COMMAND_HPP_
+#include <com/sun/star/ucb/Command.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_OPENCOMMANDARGUMENT2_HPP_
+#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_
+#include <com/sun/star/beans/Property.hpp>
+#endif
+
+
+#ifndef _TEST_ACTIVEDATASINK_HXX_
+#include "test_activedatasink.hxx"
+#endif
+#ifndef _TEST_MULTISERVICEFAC_HXX_
+#include "test_multiservicefac.hxx"
+#endif
+#ifndef _FTP_CONTENTPROVIDER_HXX_
+#include "ftpcontentprovider.hxx"
+#endif
+#ifndef _FTP_CONTENTIDENTIFIER_HXX_
+#include "ftpcontentidentifier.hxx"
+#endif
+using namespace test_ftp;
using namespace rtl;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::io;
+
+
+
+class FtpThread
+ : public osl::Thread
+{
+public:
+
+ FtpThread(const Reference<XContentProvider>& xProvider);
+
+
+protected:
+
+ void SAL_CALL run();
+
+
+private:
+
+ Reference<XContentProvider> m_xProvider;
+};
+
+
+
+
+FtpThread::FtpThread(const Reference<XContentProvider>& xProvider)
+ : m_xProvider(xProvider) { }
+
+
+void FtpThread::run() {
+// Reference<XContentIdentifierFactory> xFactory(m_xProvider,
+// UNO_QUERY);
+// xFactory->createContentIdentifier(
+// rtl::OUString::createFromAscii("ftp://chagall/"));
+
+ Reference<XContentIdentifier> xIdent(
+ new ftp::FtpContentIdentifier(
+ rtl::OUString::createFromAscii("ftp://chagall/")));
+
+
+ Reference<XContent> xContent = m_xProvider->queryContent(xIdent);
+
+ Reference<XActiveDataSink> xActDS(new Test_ActiveDataSink());
+ OpenCommandArgument2 aOpenCommand(OpenMode::DOCUMENTS,
+ 0,
+ Reference<XInterface>(xActDS,UNO_QUERY),
+ Sequence<Property>(0),
+ Sequence<NumberedSortingInfo>(0));
+ Any aAny; aAny <<= aOpenCommand;
+
+ Command aCommand(OUString::createFromAscii("open"),
+ -1,
+ aAny);
+
+ Reference<XCommandProcessor> xCommandProcessor(xContent,UNO_QUERY);
+ xCommandProcessor->execute(aCommand,0,Reference<XCommandEnvironment>(0));
+
+ int n;
+ Reference<XInputStream> xInputStream = xActDS->getInputStream();
+ if(xInputStream.is())
+ do {
+ Sequence<sal_Int8> seq(0);
+ n = xInputStream->readBytes(seq,2048);
+ fprintf(stdout,OString(reinterpret_cast<const sal_Char*>(seq.getConstArray()),
+ seq.getLength()).getStr());
+ } while(n == 2048);
+
+}
+
int main(int argc,char* argv[])
{
Reference< XMultiServiceFactory > xFac;
- Reference< XComponent > xComponent;
-
- try
- {
- OUString workDir;
- osl_getProcessWorkingDir(&workDir.pData);
- OUString dir;
- osl::FileBase::getSystemPathFromFileURL(workDir,
- dir);
- OString oDir(dir.getStr(),
- dir.getLength(),
- RTL_TEXTENCODING_UTF8);
- fprintf(stdout,"\nworking directory: %s",oDir.getStr());
- OUString systemRegistryPath;
- Bootstrap::get(OUString::createFromAscii("SystemRegistryPath"),
- systemRegistryPath,
- comphelper::getPathToSystemRegistry());
+ try {
+ OUString systemRegistryPath = comphelper::getPathToSystemRegistry();
OString path(systemRegistryPath.getStr(),
systemRegistryPath.getLength(),
RTL_TEXTENCODING_UTF8);
fprintf(stdout,"\nsystem registry path: %s\n",path.getStr());
- xFac = cppu::createRegistryServiceFactory( systemRegistryPath,
- OUString(),
- true);
- if(!xFac.is())
- {
+ xFac = cppu::createRegistryServiceFactory(systemRegistryPath,
+ OUString(),
+ true);
+ if(!xFac.is()) {
fprintf(stderr,"\ncould not create ServiceFactory");
return 1;
}
comphelper::setProcessServiceFactory(xFac);
- xComponent = Reference< XComponent >(xFac,UNO_QUERY);
- if(!xComponent.is())
- {
- fprintf(stderr,"\nERROR: could not set processServiceFactory");
- fprintf(stderr,"\nERROR: P0-bug to ABI\n");
- return 1;
- }
- int anyerr = 0;
+ Reference< XMultiServiceFactory > xFac(new Test_MultiServiceFactory());
+ Reference< XContentProvider> xProvider(new ftp::FtpContentProvider(xFac));
+ FtpThread aThread(xProvider);
+ aThread.create();
+ aThread.join();
- xComponent->dispose();
- return anyerr;
- }
- catch ( const Exception& e)
- {
+ Reference< XComponent > xComponent(xFac,UNO_QUERY);
+ if(xComponent.is())
+ xComponent->dispose();
+ return 0;
+ } catch(const Exception& e) {
fprintf(stderr,"\nERROR: any other error");
fprintf(stderr,"\nERROR: P0-bug to ABI\n");
return 1;
}
- return 0;
}
diff --git a/ucb/source/ucp/ftp/test_activedatasink.cxx b/ucb/source/ucp/ftp/test_activedatasink.cxx
new file mode 100644
index 000000000000..0776efc81d7b
--- /dev/null
+++ b/ucb/source/ucp/ftp/test_activedatasink.cxx
@@ -0,0 +1,28 @@
+#ifndef _TEST_ACTIVEDATASINK_HXX_
+#include "test_activedatasink.hxx"
+#endif
+
+
+using namespace test_ftp;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::io;
+
+
+Any SAL_CALL Test_ActiveDataSink::queryInterface( const Type& rType ) throw( RuntimeException ) {
+ Any aRet = ::cppu::queryInterface(rType,
+ SAL_STATIC_CAST( XActiveDataSink*,this ));
+
+ return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
+}
+
+
+
+void SAL_CALL Test_ActiveDataSink::acquire( void ) throw() {
+ OWeakObject::acquire();
+}
+
+
+
+void SAL_CALL Test_ActiveDataSink::release( void ) throw() {
+ OWeakObject::release();
+}
diff --git a/ucb/source/ucp/ftp/test_activedatasink.hxx b/ucb/source/ucp/ftp/test_activedatasink.hxx
new file mode 100644
index 000000000000..1acca70bee3b
--- /dev/null
+++ b/ucb/source/ucp/ftp/test_activedatasink.hxx
@@ -0,0 +1,62 @@
+#ifndef _TEST_ACTIVEDATASINK_HXX_
+#define _TEST_ACTIVEDATASINK_HXX_
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#endif
+
+namespace test_ftp {
+
+
+ class Test_ActiveDataSink
+ : public cppu::OWeakObject,
+ public com::sun::star::io::XActiveDataSink
+ {
+ public:
+
+ // XInterface
+
+ virtual com::sun::star::uno::Any SAL_CALL
+ queryInterface( const com::sun::star::uno::Type& rType )
+ throw( com::sun::star::uno::RuntimeException );
+
+
+ virtual void SAL_CALL acquire( void ) throw();
+
+ virtual void SAL_CALL release( void ) throw();
+
+
+ // XActiveDataSink
+
+ virtual void SAL_CALL
+ setInputStream(const ::com::sun::star::uno::Reference<::com::sun::star::io::XInputStream>& aStream )
+ throw(::com::sun::star::uno::RuntimeException)
+ {
+ m_xInputStream = aStream;
+ }
+
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL
+ getInputStream( )
+ throw(::com::sun::star::uno::RuntimeException)
+ {
+ return m_xInputStream;
+ }
+
+
+ private:
+
+ com::sun::star::uno::Reference<com::sun::star::io::XInputStream> m_xInputStream;
+
+ };
+
+}
+
+
+#endif
diff --git a/ucb/source/ucp/ftp/test_multiservicefac.cxx b/ucb/source/ucp/ftp/test_multiservicefac.cxx
new file mode 100644
index 000000000000..3107e03883d6
--- /dev/null
+++ b/ucb/source/ucp/ftp/test_multiservicefac.cxx
@@ -0,0 +1,78 @@
+#include "test_multiservicefac.hxx"
+
+
+using namespace test_ftp;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+
+
+Any SAL_CALL
+Test_MultiServiceFactory::queryInterface(
+ const Type& rType
+)
+ throw(
+ RuntimeException
+ )
+{
+ Any aRet = ::cppu::queryInterface(rType,
+ SAL_STATIC_CAST( XMultiServiceFactory*,
+ this ));
+
+ return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
+
+}
+
+
+void SAL_CALL Test_MultiServiceFactory::acquire( void ) throw()
+{
+ OWeakObject::acquire();
+}
+
+
+void SAL_CALL Test_MultiServiceFactory::release( void ) throw()
+{
+ OWeakObject::release();
+}
+
+ // XMultiServiceFactory
+
+ Reference<
+XInterface > SAL_CALL
+Test_MultiServiceFactory::createInstance(
+ const ::rtl::OUString& aServiceSpecifier
+)
+ throw (
+ Exception,
+ RuntimeException
+ )
+{
+ return Reference<
+ XInterface >(0);
+}
+
+
+Reference<
+XInterface > SAL_CALL
+Test_MultiServiceFactory::createInstanceWithArguments(
+ const ::rtl::OUString& ServiceSpecifier,
+ const Sequence
+ < Any >& Arguments
+)
+ throw (
+ Exception,
+ RuntimeException
+ )
+{
+ return Reference<
+ XInterface >(0);
+}
+
+Sequence< ::rtl::OUString > SAL_CALL
+Test_MultiServiceFactory::getAvailableServiceNames(
+)
+ throw (
+ RuntimeException
+ )
+{
+ return Sequence< ::rtl::OUString >(0);
+}
diff --git a/ucb/source/ucp/ftp/test_multiservicefac.hxx b/ucb/source/ucp/ftp/test_multiservicefac.hxx
new file mode 100644
index 000000000000..f3159c419626
--- /dev/null
+++ b/ucb/source/ucp/ftp/test_multiservicefac.hxx
@@ -0,0 +1,69 @@
+#ifndef _TEST_MULTISERVICEFAC_HXX_
+#define _TEST_MULTISERVICEFAC_HXX_
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+
+
+namespace test_ftp {
+
+ class Test_MultiServiceFactory
+ : public cppu::OWeakObject,
+ public com::sun::star::lang::XMultiServiceFactory
+ {
+ public:
+
+ // XInterface
+
+ virtual com::sun::star::uno::Any SAL_CALL
+ queryInterface( const com::sun::star::uno::Type& rType )
+ throw( com::sun::star::uno::RuntimeException );
+
+
+ virtual void SAL_CALL acquire( void ) throw();
+
+ virtual void SAL_CALL release( void ) throw();
+
+ // XMultiServiceFactory
+
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XInterface > SAL_CALL
+ createInstance(
+ const ::rtl::OUString& aServiceSpecifier
+ )
+ throw (
+ ::com::sun::star::uno::Exception,
+ ::com::sun::star::uno::RuntimeException
+ );
+
+ virtual
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XInterface > SAL_CALL
+ createInstanceWithArguments(
+ const ::rtl::OUString& ServiceSpecifier,
+ const ::com::sun::star::uno::Sequence
+ < ::com::sun::star::uno::Any >& Arguments
+ )
+ throw (
+ ::com::sun::star::uno::Exception,
+ ::com::sun::star::uno::RuntimeException
+ );
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
+ getAvailableServiceNames(
+ )
+ throw (
+ ::com::sun::star::uno::RuntimeException
+ );
+ };
+
+}
+
+#endif