summaryrefslogtreecommitdiff
path: root/ucb/source/ucp/webdav/webdavprovider.cxx
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2012-10-04 11:25:41 +0100
committerMichael Meeks <michael.meeks@suse.com>2012-10-04 20:16:37 +0100
commit015b29b74aaf16f5bdf6a90f6e7d5c1d210fe281 (patch)
tree3fb0abccc28bb0e97213793ab3426e2d215651f2 /ucb/source/ucp/webdav/webdavprovider.cxx
parent03ded70913f957460f90608465e4d0a182879074 (diff)
re-base on ALv2 code. Includes:
clarify Option->Language UI option Patch contributed by Herbert Duerr http://svn.apache.org/viewvc?view=revision&revision=1173991 cws mba34issues01: #i117712#: fix several resource errors introduced by IAccessible2 implementation Patch contributed by Mathias Bauer http://svn.apache.org/viewvc?view=revision&revision=1173991 cws mba34issues01: #i117709#: add missing string resource Patch contributed by Mathias Bauer http://svn.apache.org/viewvc?view=revision&revision=1172348 cws mba34issues01: #i117716#: fix missing resources my removing unused code Patch contributed by Mathias Bauer http://svn.apache.org/viewvc?view=revision&revision=1172345 re-add Crystal, Tango, Oxygen icon theme listings. correct method signature Patch contributed by Jean-Louis 'Hans' Fuchs http://svn.apache.org/viewvc?view=revision&revision=1306725 i#119063 - correct serf integration Patch contributed by Oliver-Rainer Wittmann http://svn.apache.org/viewvc?view=revision&revision=1300521 i#119036 - adapt serf integration -- use transfer-encoding 'chunked' on HTTPS -- switch transfer-encoding between 'chunked' and none on 413 HTTP status code -- refactoring -- improve user experience of certification dialog - only shown once Patch contributed by Oliver-Rainer Wittmann http://svn.apache.org/viewvc?view=revision&revision=1299727 118569: Use whole certification chain for verification. Patch contributed by Andre Fischer http://svn.apache.org/viewvc?view=revision&revision=1295493 serf integration: improve credential input handling Patch contributed by Oliver-Rainer Wittmann http://svn.apache.org/viewvc?view=revision&revision=1294557 warning-free ucb/source/ucp/webdav Patch contributed by Pavel Janik http://svn.apache.org/viewvc?view=revision&revision=1294086 some refactoring to PROPPATCH and PROPFIND requests Patch contributed by Oliver-Rainer Wittmann http://svn.apache.org/viewvc?view=revision&revision=1293281 i#118569: Replace neon with serf Patch contributed by Oliver-Rainer Wittmann http://svn.apache.org/viewvc?view=revision&revision=1292832 http://svn.apache.org/viewvc?view=revision&revision=1292794 remove OS/2 conditionals for now. re-enable webdav unit tests.
Diffstat (limited to 'ucb/source/ucp/webdav/webdavprovider.cxx')
-rw-r--r--ucb/source/ucp/webdav/webdavprovider.cxx225
1 files changed, 225 insertions, 0 deletions
diff --git a/ucb/source/ucp/webdav/webdavprovider.cxx b/ucb/source/ucp/webdav/webdavprovider.cxx
new file mode 100644
index 000000000000..318b9e952056
--- /dev/null
+++ b/ucb/source/ucp/webdav/webdavprovider.cxx
@@ -0,0 +1,225 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_ucb.hxx"
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+#include <ucbhelper/contentidentifier.hxx>
+#include "webdavprovider.hxx"
+#include "webdavcontent.hxx"
+
+#include "osl/mutex.hxx"
+
+using namespace com::sun::star;
+using namespace http_dav_ucp;
+
+//=========================================================================
+//=========================================================================
+//
+// ContentProvider Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+ContentProvider::ContentProvider(
+ const uno::Reference< lang::XMultiServiceFactory >& rSMgr )
+: ::ucbhelper::ContentProviderImplHelper( rSMgr ),
+ m_xDAVSessionFactory( new DAVSessionFactory() ),
+ m_pProps( 0 )
+{
+}
+
+//=========================================================================
+// virtual
+ContentProvider::~ContentProvider()
+{
+ delete m_pProps;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_3( ContentProvider,
+ lang::XTypeProvider,
+ lang::XServiceInfo,
+ ucb::XContentProvider );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_3( ContentProvider,
+ lang::XTypeProvider,
+ lang::XServiceInfo,
+ ucb::XContentProvider );
+
+//=========================================================================
+//
+// XServiceInfo methods.
+//
+//=========================================================================
+
+XSERVICEINFO_IMPL_1( ContentProvider,
+ rtl::OUString::createFromAscii(
+ "com.sun.star.comp.WebDAVContentProvider" ),
+ rtl::OUString::createFromAscii(
+ WEBDAV_CONTENT_PROVIDER_SERVICE_NAME ) );
+
+//=========================================================================
+//
+// Service factory implementation.
+//
+//=========================================================================
+
+ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider );
+
+//=========================================================================
+//
+// XContentProvider methods.
+//
+//=========================================================================
+
+// virtual
+uno::Reference< ucb::XContent > SAL_CALL
+ContentProvider::queryContent(
+ const uno::Reference<
+ ucb::XContentIdentifier >& Identifier )
+ throw( ucb::IllegalIdentifierException,
+ uno::RuntimeException )
+{
+ // Check URL scheme...
+
+ const rtl::OUString aScheme
+ = Identifier->getContentProviderScheme().toAsciiLowerCase();
+ if ( !aScheme.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( HTTP_URL_SCHEME ) ) &&
+ !aScheme.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( HTTPS_URL_SCHEME ) ) &&
+ !aScheme.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( WEBDAV_URL_SCHEME ) ) &&
+ !aScheme.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( DAV_URL_SCHEME ) ) &&
+ !aScheme.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( DAVS_URL_SCHEME ) ) )
+ throw ucb::IllegalIdentifierException();
+
+ // Normalize URL and create new Id, if nessacary.
+ rtl::OUString aURL = Identifier->getContentIdentifier();
+
+ // At least: <scheme> + "://"
+ if ( aURL.getLength() < ( aScheme.getLength() + 3 ) )
+ throw ucb::IllegalIdentifierException();
+
+ if ( ( aURL.getStr()[ aScheme.getLength() ] != sal_Unicode( ':' ) ) ||
+ ( aURL.getStr()[ aScheme.getLength() + 1 ] != sal_Unicode( '/' ) ) ||
+ ( aURL.getStr()[ aScheme.getLength() + 2 ] != sal_Unicode( '/' ) ) )
+ throw ucb::IllegalIdentifierException();
+
+ uno::Reference< ucb::XContentIdentifier > xCanonicId;
+
+ bool bNewId = false;
+ if ( aScheme.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( WEBDAV_URL_SCHEME ) ) )
+ {
+ aURL = aURL.replaceAt( 0,
+ WEBDAV_URL_SCHEME_LENGTH,
+ rtl::OUString::createFromAscii(
+ HTTP_URL_SCHEME ) );
+ bNewId = true;
+ }
+ else if ( aScheme.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( DAV_URL_SCHEME ) ) )
+ {
+ aURL = aURL.replaceAt( 0,
+ DAV_URL_SCHEME_LENGTH,
+ rtl::OUString::createFromAscii(
+ HTTP_URL_SCHEME ) );
+ bNewId = true;
+ }
+ else if ( aScheme.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( DAVS_URL_SCHEME ) ) )
+ {
+ aURL = aURL.replaceAt( 0,
+ DAVS_URL_SCHEME_LENGTH,
+ rtl::OUString::createFromAscii(
+ HTTPS_URL_SCHEME ) );
+ bNewId = true;
+ }
+
+ sal_Int32 nPos = aURL.lastIndexOf( '/' );
+ if ( nPos != aURL.getLength() - 1 )
+ {
+ // Find second slash in URL.
+ nPos = aURL.indexOf( '/', aURL.indexOf( '/' ) + 1 );
+ if ( nPos == -1 )
+ throw ucb::IllegalIdentifierException();
+
+ nPos = aURL.indexOf( '/', nPos + 1 );
+ if ( nPos == -1 )
+ {
+ aURL += rtl::OUString::createFromAscii( "/" );
+ bNewId = true;
+ }
+ }
+
+ if ( bNewId )
+ xCanonicId = new ::ucbhelper::ContentIdentifier( m_xSMgr, aURL );
+ else
+ xCanonicId = Identifier;
+
+ osl::MutexGuard aGuard( m_aMutex );
+
+ // Check, if a content with given id already exists...
+ uno::Reference< ucb::XContent > xContent
+ = queryExistingContent( xCanonicId ).get();
+ if ( xContent.is() )
+ return xContent;
+
+ // Create a new content.
+
+ try
+ {
+ xContent = new ::http_dav_ucp::Content(
+ m_xSMgr, this, xCanonicId, m_xDAVSessionFactory );
+ registerNewContent( xContent );
+ }
+ catch ( ucb::ContentCreationException const & )
+ {
+ throw ucb::IllegalIdentifierException();
+ }
+
+ if ( !xContent->getIdentifier().is() )
+ throw ucb::IllegalIdentifierException();
+
+ return xContent;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */