#92937# - Improved redirection support.

This commit is contained in:
Kai Sommerfeld 2001-10-25 12:47:41 +00:00
parent 8dea1b9e0e
commit d479a2d67f
8 changed files with 101 additions and 35 deletions

View file

@ -2,9 +2,9 @@
*
* $RCSfile: ContentProperties.cxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: kso $ $Date: 2001-09-06 10:37:56 $
* last change: $Author: kso $ $Date: 2001-10-25 13:47:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -98,7 +98,8 @@ using namespace webdav_ucp;
//=========================================================================
ContentProperties::ContentProperties( const DAVResource& rResource )
: pIsDocument( 0 ),
: bTrailingSlash( sal_False ),
pIsDocument( 0 ),
pIsFolder( 0 ),
pSize( 0 ),
pDateCreated( 0 ),
@ -223,12 +224,20 @@ ContentProperties::ContentProperties( const DAVResource& rResource )
}
++it;
}
if ( rResource.uri.getStr()[ rResource.uri.getLength() - 1 ]
== sal_Unicode( '/' ) )
{
// if ( pIsFolder && *pIsFolder )
bTrailingSlash = sal_True;
}
}
//=========================================================================
ContentProperties::ContentProperties(
const rtl::OUString & rTitle, sal_Bool bFolder )
: aTitle( rTitle ),
bTrailingSlash( sal_False ),
pIsDocument( new sal_Bool( !bFolder ) ),
pIsFolder( new sal_Bool( bFolder ) ),
pSize( 0 ),
@ -252,6 +261,7 @@ ContentProperties::ContentProperties(
//=========================================================================
ContentProperties::ContentProperties( const rtl::OUString & rTitle )
: aTitle( rTitle ),
bTrailingSlash( sal_False ),
pIsDocument( 0 ),
pIsFolder( 0 ),
pSize( 0 ),

View file

@ -2,9 +2,9 @@
*
* $RCSfile: ContentProperties.hxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: kso $ $Date: 2001-09-06 10:37:56 $
* last change: $Author: kso $ $Date: 2001-10-25 13:47:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -126,6 +126,8 @@ public:
// Mandatory UCB props.
::rtl::OUString aTitle; // Title
::rtl::OUString aEscapedTitle; // escaped Title
sal_Bool bTrailingSlash;
sal_Bool * pIsFolder;
sal_Bool * pIsDocument;

View file

@ -2,9 +2,9 @@
*
* $RCSfile: DAVResourceAccess.cxx,v $
*
* $Revision: 1.6 $
* $Revision: 1.7 $
*
* last change: $Author: kso $ $Date: 2001-07-03 10:10:05 $
* last change: $Author: kso $ $Date: 2001-10-25 13:47:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -188,6 +188,7 @@ DAVResourceAccess::DAVResourceAccess(
const rtl::OUString & rURL )
throw( DAVException )
: m_aURL( rURL ),
m_bRedirected( sal_False ),
m_xSMgr( rSMgr ),
m_pSessionFactory( pSessionFactory )
{
@ -198,6 +199,7 @@ void DAVResourceAccess::setURL( const rtl::OUString & rNewURL )
throw( DAVException )
{
osl::Guard< osl::Mutex > aGuard( m_aMutex );
m_bRedirected = sal_True;
m_aURL = rNewURL;
m_aPath = rtl::OUString(); // Next initialize() will create new session.
}
@ -579,6 +581,15 @@ void DAVResourceAccess::UNLOCK ( const ucb::Lock & rLock,
OSL_ENSURE( sal_False, "DAVResourceAccess::UNLOCK - NYI" );
}
//=========================================================================
// DAVRedirectionListener method
// virtual
void DAVResourceAccess::redirectNotify( const rtl::OUString & rFromURI,
const rtl::OUString & rToURI )
{
setURL( rToURI );
}
//=========================================================================
// init dav session and path
void DAVResourceAccess::initialize()
@ -600,6 +611,7 @@ void DAVResourceAccess::initialize()
m_xSession
= m_pSessionFactory->createDAVSession( m_aURL, m_xSMgr );
m_xSession->setServerAuthListener( &webdavAuthListener );
m_xSession->setRedirectionListener( this );
}
catch ( DAVException const & )
{

View file

@ -2,9 +2,9 @@
*
* $RCSfile: DAVResourceAccess.hxx,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: kso $ $Date: 2001-07-03 10:10:06 $
* last change: $Author: kso $ $Date: 2001-10-25 13:47:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -91,6 +91,9 @@
#ifndef _DAVAUTHLISTENER_HXX_
#include "DAVAuthListener.hxx"
#endif
#ifndef _DAVREDIRECTIONLISTENER_HXX_
#include "DAVRedirectionListener.hxx"
#endif
#ifndef _DAVEXCEPTION_HXX_
#include "DAVException.hxx"
#endif
@ -109,18 +112,19 @@ namespace webdav_ucp
class DAVSessionFactory;
class DAVResourceAccess
class DAVResourceAccess : public DAVRedirectionListener
{
osl::Mutex m_aMutex;
rtl::OUString m_aURL;
rtl::OUString m_aPath;
rtl::Reference< DAVSession > m_xSession;
sal_Bool m_bRedirected;
DAVSessionFactory* m_pSessionFactory;
com::sun::star::uno::Reference<
com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
public:
DAVResourceAccess() : m_pSessionFactory( 0 ) {}
DAVResourceAccess() : m_pSessionFactory( 0 ), m_bRedirected( sal_False ) {}
DAVResourceAccess( const com::sun::star::uno::Reference<
com::sun::star::lang::XMultiServiceFactory > & rSMgr,
DAVSessionFactory* pSessionFactory,
@ -130,6 +134,8 @@ public:
void setURL( const rtl::OUString & rNewURL )
throw( DAVException );
const rtl::OUString & getURL() const { return m_aURL; }
DAVSessionFactory * getSessionFactory() const { return m_pSessionFactory; }
// DAV methods
@ -241,6 +247,10 @@ public:
com::sun::star::ucb::XCommandEnvironment > & xEnv )
throw( DAVException );
// DAVRedirectionListener methods
virtual void redirectNotify( const rtl::OUString & rFromURI,
const rtl::OUString & rToURI );
private:
sal_Bool handleException( DAVException & e );
void initialize()

View file

@ -2,9 +2,9 @@
*
* $RCSfile: DAVSession.hxx,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: kso $ $Date: 2001-06-27 08:57:37 $
* last change: $Author: kso $ $Date: 2001-10-25 13:47:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -99,6 +99,7 @@ namespace webdav_ucp
{
class DAVAuthListener;
class DAVRedirectionListener;
class DAVSession : public ::cppu::OWeakObject
{
@ -110,6 +111,11 @@ public:
virtual void setServerAuthListener(DAVAuthListener * inDAVAuthListener) = 0;
virtual void setProxyAuthListener(DAVAuthListener * inDAVAuthListener ) = 0;
// redirection notification
//
virtual void setRedirectionListener(
DAVRedirectionListener * inRedirectionListener) = 0;
// DAV methods
//

View file

@ -2,9 +2,9 @@
*
* $RCSfile: NeonSession.cxx,v $
*
* $Revision: 1.12 $
* $Revision: 1.13 $
*
* last change: $Author: mba $ $Date: 2001-09-14 13:46:58 $
* last change: $Author: kso $ $Date: 2001-10-25 13:47:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -76,6 +76,9 @@
#ifndef _DAVAUTHLISTENER_HXX_
#include "DAVAuthListener.hxx"
#endif
#ifndef _DAVREDIRECTIONLISTENER_HXX_
#include "DAVRedirectionListener.hxx"
#endif
#ifndef _NEONTYPES_HXX_
#include "NeonTypes.hxx"
#endif
@ -178,7 +181,9 @@ NeonSession::NeonSession( DAVSessionFactory* pSessionFactory,
const rtl::OUString& inUri,
const ProxyConfig& rProxyCfg )
throw ( DAVException )
: m_pSessionFactory( pSessionFactory )
: mListener( 0 ),
mRedirectionListener( 0 ),
m_pSessionFactory( pSessionFactory )
{
// @@@ We need to keep the char buffer for hostname and proxyname
// for the whole session lifetime because neon only stores a pointer
@ -270,6 +275,12 @@ void NeonSession::setProxyAuthListener(DAVAuthListener * inDAVAuthListener)
// Note: Content is currently not using proxy auth
}
void NeonSession::setRedirectionListener(
DAVRedirectionListener * inRedirectionListener )
{
mRedirectionListener = inRedirectionListener;
}
// -------------------------------------------------------------------
// OPTIONS
// -------------------------------------------------------------------
@ -1158,7 +1169,17 @@ int NeonSession::RedirectConfirm(
void NeonSession::RedirectNotify(
void * userdata, const char * src, const char * dest )
{
// NeonSession * theSession = ( NeonSession * )userdata;
NeonSession * pSession = static_cast< NeonSession * >( userdata );
if ( pSession )
{
if ( pSession->mRedirectionListener )
{
pSession->mRedirectionListener->redirectNotify(
rtl::OUString(),
rtl::OUString::createFromAscii(
http_redirect_location( pSession->mHttpSession ) ) );
}
}
}
// static

View file

@ -2,9 +2,9 @@
*
* $RCSfile: NeonSession.hxx,v $
*
* $Revision: 1.8 $
* $Revision: 1.9 $
*
* last change: $Author: sb $ $Date: 2001-08-08 10:04:35 $
* last change: $Author: kso $ $Date: 2001-10-25 13:47:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -86,17 +86,18 @@ namespace webdav_ucp
class NeonSession : public DAVSession
{
private:
osl::Mutex mMutex;
rtl::OUString mScheme;
rtl::OUString mHostName;
rtl::OUString mProxyName;
sal_Int32 mPort;
sal_Int32 mProxyPort;
HttpSession * mHttpSession;
DAVAuthListener * mListener;
DAVSessionFactory * m_pSessionFactory;
osl::Mutex mMutex;
rtl::OUString mScheme;
rtl::OUString mHostName;
rtl::OUString mProxyName;
sal_Int32 mPort;
sal_Int32 mProxyPort;
HttpSession * mHttpSession;
DAVAuthListener * mListener;
DAVRedirectionListener * mRedirectionListener;
DAVSessionFactory * m_pSessionFactory;
// Note: Uncomment the following if locking support is required
// NeonLockSession * mNeonLockSession;
// NeonLockSession * mNeonLockSession;
static sal_Bool sSockInited;
static http_request_hooks mRequestHooks;
@ -136,6 +137,9 @@ class NeonSession : public DAVSession
virtual void setServerAuthListener(DAVAuthListener * inDAVAuthListener);
virtual void setProxyAuthListener(DAVAuthListener * inDAVAuthListener);
virtual void setRedirectionListener(
DAVRedirectionListener * inRedirectionListener );
virtual void OPTIONS( const ::rtl::OUString & inPath,
DAVCapabilities & outCapabilities,
const com::sun::star::uno::Reference<

View file

@ -2,9 +2,9 @@
*
* $RCSfile: webdavdatasupplier.cxx,v $
*
* $Revision: 1.7 $
* $Revision: 1.8 $
*
* last change: $Author: kso $ $Date: 2001-09-06 08:43:38 $
* last change: $Author: kso $ $Date: 2001-10-25 13:47:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -208,8 +208,7 @@ rtl::OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex )
if ( getResult( nIndex ) )
{
rtl::OUString aId
= m_pImpl->m_xContent->getIdentifier()->getContentIdentifier();
rtl::OUString aId = m_pImpl->m_xContent->getResourceAccess().getURL();
const ContentProperties& props
= *( m_pImpl->m_aResults[ nIndex ]->pData );
@ -219,6 +218,9 @@ rtl::OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex )
aId += props.aEscapedTitle;
if ( props.bTrailingSlash )
aId += rtl::OUString::createFromAscii( "/" );
m_pImpl->m_aResults[ nIndex ]->aId = aId;
return aId;
}
@ -445,8 +447,7 @@ sal_Bool DataSupplier::getData()
return sal_False;
}
NeonUri aURI(
m_pImpl->m_xContent->getIdentifier()->getContentIdentifier() );
NeonUri aURI( m_pImpl->m_xContent->getResourceAccess().getURL() );
rtl::OUString aPath = aURI.GetPath();
if ( aPath.getStr()[ aPath.getLength() - 1 ] == sal_Unicode( '/' ) )
aPath = aPath.copy( 0, aPath.getLength() - 1 );