summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorAndreas Bille <abi@openoffice.org>2002-10-24 15:43:05 +0000
committerAndreas Bille <abi@openoffice.org>2002-10-24 15:43:05 +0000
commit6e91aac6d53f9707af7daf18ada0c20f036acc61 (patch)
treee4bacee8abe91c81f98f78135e6451bf55d35f99 /ucb
parentf53dd7caf41dd05a5084d56e15d3895847726798 (diff)
#104475# partly due to 104477, partly missing command (del)
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/ftp/ftpcontent.cxx53
-rw-r--r--ucb/source/ucp/ftp/ftpcontentcaps.cxx11
-rw-r--r--ucb/source/ucp/ftp/ftpurl.cxx88
-rw-r--r--ucb/source/ucp/ftp/ftpurl.hxx10
4 files changed, 149 insertions, 13 deletions
diff --git a/ucb/source/ucp/ftp/ftpcontent.cxx b/ucb/source/ucp/ftp/ftpcontent.cxx
index b9db030963fe..ce9c05e3aec8 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.14 $
+ * $Revision: 1.15 $
*
- * last change: $Author: abi $ $Date: 2002-10-24 11:55:41 $
+ * last change: $Author: abi $ $Date: 2002-10-24 16:43:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -80,6 +80,7 @@
#include <memory>
#include <vector>
#include <rtl/memory.h>
+#include <rtl/uri.hxx>
#include <curl/curl.h>
#include <curl/easy.h>
#include <ucbhelper/cancelcommandexecution.hxx>
@@ -102,6 +103,7 @@
#include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
#include <com/sun/star/ucb/InteractiveNetworkConnectException.hpp>
#include <com/sun/star/ucb/InteractiveNetworkResolveNameException.hpp>
+#include <com/sun/star/ucb/InteractiveIOException.hpp>
#include <com/sun/star/ucb/MissingPropertiesException.hpp>
#include <com/sun/star/ucb/MissingInputStreamException.hpp>
#include <com/sun/star/ucb/NameClashException.hpp>
@@ -473,6 +475,10 @@ Any SAL_CALL FTPContent::execute(
}
insert(aInsertArgument,Environment);
}
+ else if(aCommand.Name.compareToAscii("delete") == 0) {
+ m_aFTPURL.del();
+ deleted();
+ }
else if(aCommand.Name.compareToAscii( "open" ) == 0) {
OpenCommandArgument2 aOpenCommand;
if ( !( aCommand.Argument >>= aOpenCommand ) ) {
@@ -717,6 +723,7 @@ void FTPContent::insert(const InsertCommandArgument& aInsertCommand,
// May not be reached, because both mkdir and insert can throw curl-
// exceptions
m_bInserted = false;
+ inserted();
}
@@ -779,14 +786,46 @@ Sequence<Any> FTPContent::setPropertyValues(
getProperties(Reference<XCommandEnvironment>(0));
Sequence<Any> ret(seqPropVal.getLength());
+ Sequence<PropertyChangeEvent > evt;
osl::MutexGuard aGuard(m_aMutex);
for(sal_Int32 i = 0; i < ret.getLength(); ++i) {
- if(m_bInserted && seqPropVal[i].Name.equalsAscii("Title")) {
+ if(seqPropVal[i].Name.equalsAscii("Title")) {
rtl::OUString Title;
- seqPropVal[i].Value >>= Title;
- m_aFTPURL.child(Title);
- m_bTitleSet = true;
+ if(!(seqPropVal[i].Value >>= Title)) {
+ ret[i] <<= IllegalTypeException();
+ continue;
+ } else if(!Title.getLength()) {
+ ret[i] <<= IllegalArgumentException();
+ continue;
+ }
+
+ Title =
+ rtl::Uri::encode(Title,
+ rtl_UriCharClassPchar,
+ rtl_UriEncodeIgnoreEscapes,
+ RTL_TEXTENCODING_UTF8);
+
+ if(m_bInserted) {
+ m_aFTPURL.child(Title);
+ m_bTitleSet = true;
+ } else
+ try {
+ rtl::OUString OldTitle = m_aFTPURL.ren(Title);
+ evt.realloc(1);
+ evt[0].PropertyName =
+ rtl::OUString::createFromAscii("Title");
+ evt[0].Further = false;
+ evt[0].PropertyHandle = -1;
+ evt[0].OldValue <<= OldTitle;
+ evt[0].NewValue <<= Title;
+ } catch(const curl_exception&) {
+ InteractiveIOException excep;
+ // any better possibility here?
+ // ( the error code is always CURLE_FTP_QUOTE_ERROR )
+ excep.Code = IOErrorCode_ACCESS_DENIED;
+ ret[i] <<= excep;
+ }
} else {
// either not unknown or illegal
ret[i] <<= UnknownPropertyException();
@@ -798,5 +837,7 @@ Sequence<Any> FTPContent::setPropertyValues(
}
}
+ if(evt.getLength())
+ notifyPropertiesChange(evt);
return ret;
}
diff --git a/ucb/source/ucp/ftp/ftpcontentcaps.cxx b/ucb/source/ucp/ftp/ftpcontentcaps.cxx
index 06ef0d875551..9b6b902283a4 100644
--- a/ucb/source/ucp/ftp/ftpcontentcaps.cxx
+++ b/ucb/source/ucp/ftp/ftpcontentcaps.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ftpcontentcaps.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: abi $ $Date: 2002-10-17 16:28:21 $
+ * last change: $Author: abi $ $Date: 2002-10-24 16:43:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -145,7 +145,7 @@ Sequence< CommandInfo > FTPContent::getCommands(
//
//=================================================================
-#define COMMAND_COUNT 6
+#define COMMAND_COUNT 7
static CommandInfo aCommandInfoTable[] =
{
@@ -181,6 +181,11 @@ Sequence< CommandInfo > FTPContent::getCommands(
OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ),
-1,
getCppuType( static_cast< InsertCommandArgument * >( 0 ) )
+ ),
+ CommandInfo(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
+ -1,
+ getCppuType( static_cast< sal_Bool * >( 0 ) )
)
};
diff --git a/ucb/source/ucp/ftp/ftpurl.cxx b/ucb/source/ucp/ftp/ftpurl.cxx
index 6d4bf30dd54a..23b9c883b66b 100644
--- a/ucb/source/ucp/ftp/ftpurl.cxx
+++ b/ucb/source/ucp/ftp/ftpurl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ftpurl.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: abi $ $Date: 2002-10-24 11:55:41 $
+ * last change: $Author: abi $ $Date: 2002-10-24 16:43:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -762,3 +762,87 @@ void FTPURL::mkdir(bool ReplaceExisting) const
if(err != CURLE_OK)
throw curl_exception(err);
}
+
+
+rtl::OUString FTPURL::ren(const rtl::OUString& NewTitle)
+ throw(curl_exception)
+{
+ CURL *curl = m_pFCP->handle();
+
+ // post request
+ rtl::OString renamefrom("RNFR ");
+ rtl::OUString OldTitle = net_title();
+ renamefrom +=
+ rtl::OString(OldTitle.getStr(),
+ OldTitle.getLength(),
+ RTL_TEXTENCODING_UTF8);
+
+ rtl::OString renameto("RNTO ");
+ renameto +=
+ rtl::OString(NewTitle.getStr(),
+ NewTitle.getLength(),
+ RTL_TEXTENCODING_UTF8);
+
+ struct curl_slist *slist = 0;
+ slist = curl_slist_append(slist,renamefrom.getStr());
+ slist = curl_slist_append(slist,renameto.getStr());
+ curl_easy_setopt(curl,CURLOPT_POSTQUOTE,slist);
+
+ SET_CONTROL_CONTAINER;
+ curl_easy_setopt(curl,CURLOPT_NOBODY,TRUE); // no data => no transfer
+ curl_easy_setopt(curl,CURLOPT_QUOTE,0);
+
+ rtl::OUString url(parent(true));
+ if(1+url.lastIndexOf(sal_Unicode('/')) != url.getLength())
+ url += rtl::OUString::createFromAscii("/");
+ SET_URL(url);
+
+ CURLcode err = curl_easy_perform(curl);
+ curl_slist_free_all(slist);
+ if(err != CURLE_OK)
+ throw curl_exception(err);
+ else if(m_aPathSegmentVec.size() &&
+ !m_aPathSegmentVec.back().equalsAscii(".."))
+ m_aPathSegmentVec.back() = NewTitle;
+ return OldTitle;
+}
+
+
+
+void FTPURL::del() const
+ throw(curl_exception)
+{
+ FTPDirentry aDirentry(direntry());
+
+ rtl::OString dele(aDirentry.m_aName.getStr(),
+ aDirentry.m_aName.getLength(),
+ RTL_TEXTENCODING_UTF8);
+
+ if(aDirentry.m_nMode & INETCOREFTP_FILEMODE_ISDIR)
+ dele = rtl::OString("RMD ") + dele;
+ else if(aDirentry.m_nMode != INETCOREFTP_FILEMODE_UNKNOWN)
+ dele = rtl::OString("DELE ") + dele;
+ else
+ return;
+
+ // post request
+ CURL *curl = m_pFCP->handle();
+ struct curl_slist *slist = 0;
+ slist = curl_slist_append(slist,dele.getStr());
+ curl_easy_setopt(curl,CURLOPT_POSTQUOTE,slist);
+
+ SET_CONTROL_CONTAINER;
+ curl_easy_setopt(curl,CURLOPT_NOBODY,TRUE); // no data => no transfer
+ curl_easy_setopt(curl,CURLOPT_QUOTE,0);
+
+ rtl::OUString url(parent(true));
+ if(1+url.lastIndexOf(sal_Unicode('/')) != url.getLength())
+ url += rtl::OUString::createFromAscii("/");
+ SET_URL(url);
+
+ CURLcode err = curl_easy_perform(curl);
+ curl_slist_free_all(slist);
+ if(err != CURLE_OK)
+ throw curl_exception(err);
+}
+
diff --git a/ucb/source/ucp/ftp/ftpurl.hxx b/ucb/source/ucp/ftp/ftpurl.hxx
index 75740779dc25..db4daea8a853 100644
--- a/ucb/source/ucp/ftp/ftpurl.hxx
+++ b/ucb/source/ucp/ftp/ftpurl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ftpurl.hxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: abi $ $Date: 2002-10-23 08:00:11 $
+ * last change: $Author: abi $ $Date: 2002-10-24 16:43:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -171,6 +171,12 @@ namespace ftp {
void mkdir(bool ReplaceExisting) const
throw(curl_exception);
+ rtl::OUString ren(const rtl::OUString& NewTitle)
+ throw(curl_exception);
+
+ void del() const;
+
+
private:
osl::Mutex m_mutex;