summaryrefslogtreecommitdiff
path: root/ucb/source/ucp/ftp
diff options
context:
space:
mode:
authorKai Sommerfeld <kso@openoffice.org>2009-12-21 15:53:33 +0100
committerKai Sommerfeld <kso@openoffice.org>2009-12-21 15:53:33 +0100
commitee2ecbf89b002fa8f60316b4266b96dfca8b4591 (patch)
tree2be9d3aa751f3d2e69106ba3bd78b0da3f053a6b /ucb/source/ucp/ftp
parent22652581ffbb7b795f3ed5ee9dc4a85b24bac25f (diff)
#i61429#, deprecated css.ucb.XContentCreator, implemented replacement.
Diffstat (limited to 'ucb/source/ucp/ftp')
-rw-r--r--ucb/source/ucp/ftp/ftpcontent.cxx208
-rw-r--r--ucb/source/ucp/ftp/ftpcontent.hxx18
-rw-r--r--ucb/source/ucp/ftp/ftpcontentcaps.cxx28
-rw-r--r--ucb/source/ucp/ftp/ftpresultsetI.cxx6
-rw-r--r--ucb/source/ucp/ftp/ftpurl.cxx6
5 files changed, 179 insertions, 87 deletions
diff --git a/ucb/source/ucp/ftp/ftpcontent.cxx b/ucb/source/ucp/ftp/ftpcontent.cxx
index 63189c642e36..73300c16844b 100644
--- a/ucb/source/ucp/ftp/ftpcontent.cxx
+++ b/ucb/source/ucp/ftp/ftpcontent.cxx
@@ -218,7 +218,7 @@ void SAL_CALL FTPContent::abort( sal_Int32 /*CommandId*/ )
/***************************************************************************/
/* */
-/* Interne Implklasse */
+/* Internal implementation class. */
/* */
/***************************************************************************/
@@ -363,66 +363,85 @@ Any SAL_CALL FTPContent::execute(
// return aRet;
// }
- if(action == THROWAUTHENTICATIONREQUEST) {
+ switch (action)
+ {
+ case NOACTION:
+ break;
+
+ case THROWAUTHENTICATIONREQUEST:
ucbhelper::cancelCommandExecution(
aRet,
Reference<XCommandEnvironment>(0));
- } else if(action == THROWACCESSDENIED) {
- Sequence<Any> seq(1);
- PropertyValue value;
- value.Name =
- rtl::OUString::createFromAscii("Uri");
- value.Handle = -1;
- value.Value <<= m_aFTPURL.ident(false,false);
- value.State = PropertyState_DIRECT_VALUE;
- seq[0] <<= value;
- ucbhelper::cancelCommandExecution(
- IOErrorCode_ACCESS_DENIED,
- seq,
- Environment);
- } else if(action == THROWINTERACTIVECONNECT) {
- InteractiveNetworkConnectException
- excep;
- excep.Server = m_aFTPURL.host();
- aRet <<= excep;
- ucbhelper::cancelCommandExecution(
- aRet,
- Environment);
- } else if(action == THROWRESOLVENAME) {
- InteractiveNetworkResolveNameException
- excep;
- excep.Server = m_aFTPURL.host();
- aRet <<= excep;
- ucbhelper::cancelCommandExecution(
- aRet,
- Environment);
- } else if(action == THROWNOFILE) {
- Sequence<Any> seq(1);
- PropertyValue value;
- value.Name =
- rtl::OUString::createFromAscii("Uri");
- value.Handle = -1;
- value.Value <<= m_aFTPURL.ident(false,false);
- value.State = PropertyState_DIRECT_VALUE;
- seq[0] <<= value;
- ucbhelper::cancelCommandExecution(
- IOErrorCode_NO_FILE,
- seq,
- Environment);
- } else if(action == THROWQUOTE ||
- action == THROWGENERAL) {
+ break;
+
+ case THROWACCESSDENIED:
+ {
+ Sequence<Any> seq(1);
+ PropertyValue value;
+ value.Name = rtl::OUString::createFromAscii("Uri");
+ value.Handle = -1;
+ value.Value <<= m_aFTPURL.ident(false,false);
+ value.State = PropertyState_DIRECT_VALUE;
+ seq[0] <<= value;
+ ucbhelper::cancelCommandExecution(
+ IOErrorCode_ACCESS_DENIED,
+ seq,
+ Environment);
+ break;
+ }
+ case THROWINTERACTIVECONNECT:
+ {
+ InteractiveNetworkConnectException excep;
+ excep.Server = m_aFTPURL.host();
+ aRet <<= excep;
+ ucbhelper::cancelCommandExecution(
+ aRet,
+ Environment);
+ break;
+ }
+ case THROWRESOLVENAME:
+ {
+ InteractiveNetworkResolveNameException excep;
+ excep.Server = m_aFTPURL.host();
+ aRet <<= excep;
+ ucbhelper::cancelCommandExecution(
+ aRet,
+ Environment);
+ break;
+ }
+ case THROWNOFILE:
+ {
+ Sequence<Any> seq(1);
+ PropertyValue value;
+ value.Name = rtl::OUString::createFromAscii("Uri");
+ value.Handle = -1;
+ value.Value <<= m_aFTPURL.ident(false,false);
+ value.State = PropertyState_DIRECT_VALUE;
+ seq[0] <<= value;
+ ucbhelper::cancelCommandExecution(
+ IOErrorCode_NO_FILE,
+ seq,
+ Environment);
+ break;
+ }
+ case THROWQUOTE:
+ case THROWGENERAL:
ucbhelper::cancelCommandExecution(
IOErrorCode_GENERAL,
Sequence<Any>(0),
Environment);
+ break;
}
-
if(aCommand.Name.compareToAscii("getPropertyValues") == 0) {
Sequence<Property> Properties;
if(!(aCommand.Argument >>= Properties))
{
- aRet <<= IllegalArgumentException();
+ aRet <<= IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Wrong argument type!" ),
+ static_cast< cppu::OWeakObject * >(this),
+ -1);
ucbhelper::cancelCommandExecution(aRet,Environment);
}
@@ -433,7 +452,11 @@ Any SAL_CALL FTPContent::execute(
Sequence<PropertyValue> propertyValues;
if( ! ( aCommand.Argument >>= propertyValues ) ) {
- aRet <<= IllegalArgumentException();
+ aRet <<= IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Wrong argument type!" ),
+ static_cast< cppu::OWeakObject * >(this),
+ -1);
ucbhelper::cancelCommandExecution(aRet,Environment);
}
@@ -451,7 +474,11 @@ Any SAL_CALL FTPContent::execute(
{
InsertCommandArgument aInsertArgument;
if ( ! ( aCommand.Argument >>= aInsertArgument ) ) {
- aRet <<= IllegalArgumentException();
+ aRet <<= IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Wrong argument type!" ),
+ static_cast< cppu::OWeakObject * >(this),
+ -1);
ucbhelper::cancelCommandExecution(aRet,Environment);
}
insert(aInsertArgument,Environment);
@@ -463,7 +490,12 @@ Any SAL_CALL FTPContent::execute(
else if(aCommand.Name.compareToAscii( "open" ) == 0) {
OpenCommandArgument2 aOpenCommand;
if ( !( aCommand.Argument >>= aOpenCommand ) ) {
- aRet <<= IllegalArgumentException();
+ aRet <<= IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Wrong argument type!" ),
+ static_cast< cppu::OWeakObject * >(this),
+ -1);
+
ucbhelper::cancelCommandExecution(aRet,Environment);
}
@@ -516,7 +548,10 @@ Any SAL_CALL FTPContent::execute(
}
}
else {
- aRet <<= UnsupportedDataSinkException();
+ aRet <<= UnsupportedDataSinkException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >(this),
+ aOpenCommand.Sink);
ucbhelper::cancelCommandExecution(aRet,Environment);
}
}
@@ -544,17 +579,39 @@ Any SAL_CALL FTPContent::execute(
aOpenCommand.Mode ==
OpenMode::DOCUMENT_SHARE_DENY_WRITE) {
// Unsupported OpenMode
- aRet <<= UnsupportedOpenModeException();
+ aRet <<= UnsupportedOpenModeException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >(this),
+ static_cast< sal_Int16 >(aOpenCommand.Mode));
ucbhelper::cancelCommandExecution(aRet,Environment);
}
else {
- // IllegalArgumentException:: No OpenMode
- aRet <<= IllegalArgumentException();
+ aRet <<= IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Unexpected OpenMode!" ),
+ static_cast< cppu::OWeakObject * >(this),
+ -1);
+
ucbhelper::cancelCommandExecution(aRet,Environment);
}
- }
- else {
- aRet <<= UnsupportedCommandException();
+ } else if(aCommand.Name.compareToAscii("createNewContent") == 0) {
+ ContentInfo aArg;
+ if (!(aCommand.Argument >>= aArg)) {
+ ucbhelper::cancelCommandExecution(
+ makeAny(
+ IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Wrong argument type!" ),
+ static_cast< cppu::OWeakObject * >(this),
+ -1)),
+ Environment);
+ // Unreachable
+ }
+ aRet <<= createNewContent(aArg);
+ } else {
+ aRet <<= UnsupportedCommandException(
+ aCommand.Name,
+ static_cast< cppu::OWeakObject * >(this));
ucbhelper::cancelCommandExecution(aRet,Environment);
}
@@ -565,8 +622,11 @@ Any SAL_CALL FTPContent::execute(
else if(e.code() == CURLE_COULDNT_RESOLVE_HOST )
action = THROWRESOLVENAME;
else if(e.code() == CURLE_FTP_USER_PASSWORD_INCORRECT ||
+#if LIBCURL_VERSION_NUM>=0x070d01 /* 7.13.1 */
+ e.code() == CURLE_LOGIN_DENIED ||
+#endif
e.code() == CURLE_BAD_PASSWORD_ENTERED ||
- e.code() == CURLE_FTP_WEIRD_PASS_REPLY )
+ e.code() == CURLE_FTP_WEIRD_PASS_REPLY)
action = THROWAUTHENTICATIONREQUEST;
else if(e.code() == CURLE_FTP_ACCESS_DENIED)
action = THROWACCESSDENIED;
@@ -575,7 +635,7 @@ Any SAL_CALL FTPContent::execute(
else if(e.code() == CURLE_FTP_COULDNT_RETR_FILE)
action = THROWNOFILE;
else
- // nothing known about the course of the error
+ // nothing known about the cause of the error
action = THROWGENERAL;
}
}
@@ -592,6 +652,14 @@ Sequence<ContentInfo > SAL_CALL
FTPContent::queryCreatableContentsInfo( )
throw (RuntimeException)
{
+ return queryCreatableContentsInfo_Static();
+}
+
+// static
+Sequence<ContentInfo >
+FTPContent::queryCreatableContentsInfo_Static( )
+ throw (RuntimeException)
+{
Sequence< ContentInfo > seq(2);
seq[0].Type = FTP_FILE;
@@ -614,7 +682,6 @@ FTPContent::queryCreatableContentsInfo( )
return seq;
}
-
Reference<XContent > SAL_CALL
FTPContent::createNewContent( const ContentInfo& Info )
throw (RuntimeException)
@@ -785,6 +852,9 @@ Reference< XRow > FTPContent::getPropertyValues(
const rtl::OUString& Name = seqProp[i].Name;
if(Name.compareToAscii("Title") == 0)
xRow->appendString(seqProp[i],aDirEntry.m_aName);
+ else if(Name.compareToAscii("CreatableContentsInfo") == 0)
+ xRow->appendObject(seqProp[i],
+ makeAny(queryCreatableContentsInfo()));
else if(aDirEntry.m_nMode != INETCOREFTP_FILEMODE_UNKNOWN) {
if(Name.compareToAscii("ContentType") == 0)
xRow->appendString(seqProp[i],
@@ -825,9 +895,6 @@ Reference< XRow > FTPContent::getPropertyValues(
Sequence<Any> FTPContent::setPropertyValues(
const Sequence<PropertyValue>& seqPropVal)
{
- Sequence<Property> props =
- getProperties(Reference<XCommandEnvironment>(0));
-
Sequence<Any> ret(seqPropVal.getLength());
Sequence<PropertyChangeEvent > evt;
@@ -866,11 +933,20 @@ Sequence<Any> FTPContent::setPropertyValues(
ret[i] <<= excep;
}
} else {
- // either not unknown or illegal
+ Sequence<Property> props =
+ getProperties(Reference<XCommandEnvironment>(0));
+
+ // either unknown or read-only
ret[i] <<= UnknownPropertyException();
for(sal_Int32 j = 0; j < props.getLength(); ++j)
if(props[j].Name == seqPropVal[i].Name) {
- ret[i] <<= IllegalAccessException();
+ ret[i] <<= IllegalAccessException(
+ rtl::OUString::createFromAscii(
+ "Property is read-only!"),
+ //props[j].Attributes & PropertyAttribute::READONLY
+ // ? "Property is read-only!"
+ // : "Access denied!"),
+ static_cast< cppu::OWeakObject * >( this ));
break;
}
}
diff --git a/ucb/source/ucp/ftp/ftpcontent.hxx b/ucb/source/ucp/ftp/ftpcontent.hxx
index 1997537d0d81..0b41c9be1d03 100644
--- a/ucb/source/ucp/ftp/ftpcontent.hxx
+++ b/ucb/source/ucp/ftp/ftpcontent.hxx
@@ -57,19 +57,6 @@ namespace ftp
//=========================================================================
- struct ContentProperties
- {
- ::rtl::OUString aTitle; // Title
- ::rtl::OUString aContentType; // ContentType
- sal_Bool bIsDocument; // IsDocument
- sal_Bool bIsFolder; // IsFolder
-
- ContentProperties()
- : bIsDocument( sal_True ), bIsFolder( sal_False ) {}
- };
-
-//=========================================================================
-
class FTPContentProvider;
//=========================================================================
@@ -150,6 +137,11 @@ namespace ftp
::com::sun::star::uno::RuntimeException);
+ static com::sun::star::uno::Sequence<
+ com::sun::star::ucb::ContentInfo >
+ queryCreatableContentsInfo_Static( )
+ throw (com::sun::star::uno::RuntimeException);
+
private:
FTPContentProvider *m_pFCP;
diff --git a/ucb/source/ucp/ftp/ftpcontentcaps.cxx b/ucb/source/ucp/ftp/ftpcontentcaps.cxx
index 59fa976ff656..874bb9bbd0d0 100644
--- a/ucb/source/ucp/ftp/ftpcontentcaps.cxx
+++ b/ucb/source/ucp/ftp/ftpcontentcaps.cxx
@@ -49,7 +49,7 @@ using namespace ftp;
uno::Sequence< beans::Property > FTPContent::getProperties(
const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/)
{
- #define PROPS_COUNT 7
+ #define PROPS_COUNT 8
static const beans::Property aPropsInfoTable[] =
{
@@ -91,7 +91,7 @@ uno::Sequence< beans::Property > FTPContent::getProperties(
beans::Property(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ),
-1,
- getCppuType( static_cast< util::DateTime* >( 0 ) ),
+ getCppuType( static_cast< util::DateTime * >( 0 ) ),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY
),
@@ -101,10 +101,19 @@ uno::Sequence< beans::Property > FTPContent::getProperties(
getCppuBooleanType(),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY
+ ),
+ beans::Property(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "CreatableContentsInfo" ) ),
+ -1,
+ getCppuType(
+ static_cast< const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY
)
};
- return uno::Sequence< beans::Property >( aPropsInfoTable,PROPS_COUNT);
+ return uno::Sequence< beans::Property >( aPropsInfoTable, PROPS_COUNT );
}
//=========================================================================
@@ -112,7 +121,7 @@ uno::Sequence< beans::Property > FTPContent::getProperties(
uno::Sequence< ucb::CommandInfo > FTPContent::getCommands(
const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
{
-// osl::MutexGuard aGuard( m_aMutex );
+// osl::MutexGuard aGuard( m_aMutex );
//=================================================================
//
@@ -120,7 +129,7 @@ uno::Sequence< ucb::CommandInfo > FTPContent::getCommands(
//
//=================================================================
- #define COMMAND_COUNT 7
+ #define COMMAND_COUNT 8
static const ucb::CommandInfo aCommandInfoTable[] =
{
@@ -167,10 +176,15 @@ uno::Sequence< ucb::CommandInfo > FTPContent::getCommands(
ucb::CommandInfo(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
-1,
- getCppuType( static_cast< sal_Bool * >( 0 ) )
+ getCppuBooleanType()
+ ),
+ ucb::CommandInfo(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ),
+ -1,
+ getCppuType( static_cast< ucb::ContentInfo * >( 0 ) )
)
};
- return uno::Sequence<ucb::CommandInfo>(aCommandInfoTable,COMMAND_COUNT);
+ return uno::Sequence< ucb::CommandInfo >( aCommandInfoTable, COMMAND_COUNT );
}
diff --git a/ucb/source/ucp/ftp/ftpresultsetI.cxx b/ucb/source/ucp/ftp/ftpresultsetI.cxx
index ab18061de31a..696107238339 100644
--- a/ucb/source/ucp/ftp/ftpresultsetI.cxx
+++ b/ucb/source/ucp/ftp/ftpresultsetI.cxx
@@ -38,7 +38,7 @@
#include "com/sun/star/ucb/XCommandProcessor.hpp"
#include "com/sun/star/sdbc/XRow.hpp"
#include "ftpresultsetI.hxx"
-
+#include "ftpcontent.hxx"
using namespace std;
@@ -96,6 +96,10 @@ ResultSetI::ResultSetI(const Reference<XMultiServiceFactory>& xMSF,
else if(Name.compareToAscii("DateCreated") == 0)
xRow->appendTimestamp(seqProp[i],
dirvec[n].m_aDate);
+ else if(Name.compareToAscii("CreatableContentsInfo") == 0)
+ xRow->appendObject(
+ seqProp[i],
+ makeAny(FTPContent::queryCreatableContentsInfo_Static()));
else
xRow->appendVoid(seqProp[i]);
}
diff --git a/ucb/source/ucp/ftp/ftpurl.cxx b/ucb/source/ucp/ftp/ftpurl.cxx
index a0dfbc1b6f51..52615e79f90e 100644
--- a/ucb/source/ucp/ftp/ftpurl.cxx
+++ b/ucb/source/ucp/ftp/ftpurl.cxx
@@ -589,6 +589,12 @@ rtl::OUString FTPURL::net_title() const
// the client should retry after getting the correct
// username + password
throw curl_exception(err);
+#if LIBCURL_VERSION_NUM>=0x070d01 /* 7.13.1 */
+ else if(err == CURLE_LOGIN_DENIED)
+ // the client should retry after getting the correct
+ // username + password
+ throw curl_exception(err);
+#endif
else if(try_more && err == CURLE_FTP_ACCESS_DENIED) {
// We were either denied access when trying to login to
// an FTP server or when trying to change working directory