1*6df1ea1fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*6df1ea1fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*6df1ea1fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*6df1ea1fSAndrew Rist * distributed with this work for additional information 6*6df1ea1fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*6df1ea1fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*6df1ea1fSAndrew Rist * "License"); you may not use this file except in compliance 9*6df1ea1fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*6df1ea1fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*6df1ea1fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*6df1ea1fSAndrew Rist * software distributed under the License is distributed on an 15*6df1ea1fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*6df1ea1fSAndrew Rist * KIND, either express or implied. See the License for the 17*6df1ea1fSAndrew Rist * specific language governing permissions and limitations 18*6df1ea1fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*6df1ea1fSAndrew Rist *************************************************************/ 21*6df1ea1fSAndrew Rist 22*6df1ea1fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _DAVSESSION_HXX_ 25cdf0e10cSrcweir #define _DAVSESSION_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <memory> 28cdf0e10cSrcweir #include <rtl/ustring.hxx> 29cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 30cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 31cdf0e10cSrcweir #include "DAVException.hxx" 32cdf0e10cSrcweir #include "DAVProperties.hxx" 33cdf0e10cSrcweir #include "DAVResource.hxx" 34cdf0e10cSrcweir #include "DAVSessionFactory.hxx" 35cdf0e10cSrcweir #include "DAVTypes.hxx" 36cdf0e10cSrcweir #include "DAVRequestEnvironment.hxx" 37cdf0e10cSrcweir 38cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace ucb { 39cdf0e10cSrcweir struct Lock; 40cdf0e10cSrcweir } } } } 41cdf0e10cSrcweir 42cdf0e10cSrcweir namespace webdav_ucp 43cdf0e10cSrcweir { 44cdf0e10cSrcweir 45cdf0e10cSrcweir class DAVAuthListener; 46cdf0e10cSrcweir 47cdf0e10cSrcweir class DAVSession 48cdf0e10cSrcweir { 49cdf0e10cSrcweir public: 50cdf0e10cSrcweir inline void acquire() SAL_THROW(()) 51cdf0e10cSrcweir { 52cdf0e10cSrcweir osl_incrementInterlockedCount( &m_nRefCount ); 53cdf0e10cSrcweir } 54cdf0e10cSrcweir 55cdf0e10cSrcweir void release() SAL_THROW(()) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir if ( osl_decrementInterlockedCount( &m_nRefCount ) == 0 ) 58cdf0e10cSrcweir { 59cdf0e10cSrcweir m_xFactory->releaseElement( this ); 60cdf0e10cSrcweir delete this; 61cdf0e10cSrcweir } 62cdf0e10cSrcweir } 63cdf0e10cSrcweir 64cdf0e10cSrcweir virtual sal_Bool CanUse( const ::rtl::OUString & inPath ) = 0; 65cdf0e10cSrcweir 66cdf0e10cSrcweir virtual sal_Bool UsesProxy() = 0; 67cdf0e10cSrcweir 68cdf0e10cSrcweir // DAV methods 69cdf0e10cSrcweir // 70cdf0e10cSrcweir 71cdf0e10cSrcweir virtual void OPTIONS( const ::rtl::OUString & inPath, 72cdf0e10cSrcweir DAVCapabilities & outCapabilities, 73cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 74cdf0e10cSrcweir throw( DAVException ) = 0; 75cdf0e10cSrcweir 76cdf0e10cSrcweir // allprop & named 77cdf0e10cSrcweir virtual void PROPFIND( const ::rtl::OUString & inPath, 78cdf0e10cSrcweir const Depth inDepth, 79cdf0e10cSrcweir const std::vector< ::rtl::OUString > & inPropertyNames, 80cdf0e10cSrcweir std::vector< DAVResource > & ioResources, 81cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 82cdf0e10cSrcweir throw( DAVException ) = 0; 83cdf0e10cSrcweir 84cdf0e10cSrcweir // propnames 85cdf0e10cSrcweir virtual void PROPFIND( const ::rtl::OUString & inPath, 86cdf0e10cSrcweir const Depth inDepth, 87cdf0e10cSrcweir std::vector< DAVResourceInfo > & ioResInfo, 88cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 89cdf0e10cSrcweir throw( DAVException ) = 0; 90cdf0e10cSrcweir 91cdf0e10cSrcweir virtual void PROPPATCH( const ::rtl::OUString & inPath, 92cdf0e10cSrcweir const std::vector< ProppatchValue > & inValues, 93cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 94cdf0e10cSrcweir throw( DAVException ) = 0; 95cdf0e10cSrcweir 96cdf0e10cSrcweir virtual void HEAD( const ::rtl::OUString & inPath, 97cdf0e10cSrcweir const std::vector< ::rtl::OUString > & inHeaderNames, 98cdf0e10cSrcweir DAVResource & ioResource, 99cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 100cdf0e10cSrcweir throw( DAVException ) = 0; 101cdf0e10cSrcweir 102cdf0e10cSrcweir virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 103cdf0e10cSrcweir GET( const ::rtl::OUString & inPath, 104cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 105cdf0e10cSrcweir throw( DAVException ) = 0; 106cdf0e10cSrcweir 107cdf0e10cSrcweir virtual void GET( const ::rtl::OUString & inPath, 108cdf0e10cSrcweir com::sun::star::uno::Reference< 109cdf0e10cSrcweir com::sun::star::io::XOutputStream >& o, 110cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 111cdf0e10cSrcweir throw( DAVException ) = 0; 112cdf0e10cSrcweir 113cdf0e10cSrcweir virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 114cdf0e10cSrcweir GET( const ::rtl::OUString & inPath, 115cdf0e10cSrcweir const std::vector< ::rtl::OUString > & inHeaderNames, 116cdf0e10cSrcweir DAVResource & ioResource, 117cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 118cdf0e10cSrcweir throw( DAVException ) = 0; 119cdf0e10cSrcweir 120cdf0e10cSrcweir virtual void 121cdf0e10cSrcweir GET( const ::rtl::OUString & inPath, 122cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& o, 123cdf0e10cSrcweir const std::vector< ::rtl::OUString > & inHeaderNames, 124cdf0e10cSrcweir DAVResource & ioResource, 125cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 126cdf0e10cSrcweir throw( DAVException ) = 0; 127cdf0e10cSrcweir 128cdf0e10cSrcweir virtual void PUT( const ::rtl::OUString & inPath, 129cdf0e10cSrcweir const com::sun::star::uno::Reference< 130cdf0e10cSrcweir com::sun::star::io::XInputStream >& s, 131cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 132cdf0e10cSrcweir throw( DAVException ) = 0; 133cdf0e10cSrcweir 134cdf0e10cSrcweir virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 135cdf0e10cSrcweir POST( const rtl::OUString & inPath, 136cdf0e10cSrcweir const rtl::OUString & rContentType, 137cdf0e10cSrcweir const rtl::OUString & rReferer, 138cdf0e10cSrcweir const com::sun::star::uno::Reference< 139cdf0e10cSrcweir com::sun::star::io::XInputStream > & inInputStream, 140cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 141cdf0e10cSrcweir throw ( DAVException ) = 0; 142cdf0e10cSrcweir 143cdf0e10cSrcweir virtual void POST( const rtl::OUString & inPath, 144cdf0e10cSrcweir const rtl::OUString & rContentType, 145cdf0e10cSrcweir const rtl::OUString & rReferer, 146cdf0e10cSrcweir const com::sun::star::uno::Reference< 147cdf0e10cSrcweir com::sun::star::io::XInputStream > & inInputStream, 148cdf0e10cSrcweir com::sun::star::uno::Reference< 149cdf0e10cSrcweir com::sun::star::io::XOutputStream > & oOutputStream, 150cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 151cdf0e10cSrcweir throw ( DAVException ) = 0; 152cdf0e10cSrcweir 153cdf0e10cSrcweir virtual void MKCOL( const ::rtl::OUString & inPath, 154cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 155cdf0e10cSrcweir throw( DAVException ) = 0; 156cdf0e10cSrcweir 157cdf0e10cSrcweir virtual void COPY( const ::rtl::OUString & inSource, 158cdf0e10cSrcweir const ::rtl::OUString & inDestination, 159cdf0e10cSrcweir const DAVRequestEnvironment & rEnv, 160cdf0e10cSrcweir sal_Bool inOverwrite = false ) 161cdf0e10cSrcweir throw( DAVException ) = 0; 162cdf0e10cSrcweir 163cdf0e10cSrcweir virtual void MOVE( const ::rtl::OUString & inSource, 164cdf0e10cSrcweir const ::rtl::OUString & inDestination, 165cdf0e10cSrcweir const DAVRequestEnvironment & rEnv, 166cdf0e10cSrcweir sal_Bool inOverwrite = false ) 167cdf0e10cSrcweir throw( DAVException ) = 0; 168cdf0e10cSrcweir 169cdf0e10cSrcweir virtual void DESTROY( const ::rtl::OUString & inPath, 170cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 171cdf0e10cSrcweir throw( DAVException ) = 0; 172cdf0e10cSrcweir 173cdf0e10cSrcweir // set new lock. 174cdf0e10cSrcweir virtual void LOCK( const ::rtl::OUString & inPath, 175cdf0e10cSrcweir com::sun::star::ucb::Lock & inLock, 176cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 177cdf0e10cSrcweir throw ( DAVException ) = 0; 178cdf0e10cSrcweir 179cdf0e10cSrcweir // refresh existing lock. 180cdf0e10cSrcweir virtual sal_Int64 LOCK( const ::rtl::OUString & inPath, 181cdf0e10cSrcweir sal_Int64 nTimeout, 182cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 183cdf0e10cSrcweir throw ( DAVException ) = 0; 184cdf0e10cSrcweir 185cdf0e10cSrcweir virtual void UNLOCK( const ::rtl::OUString & inPath, 186cdf0e10cSrcweir const DAVRequestEnvironment & rEnv ) 187cdf0e10cSrcweir throw ( DAVException ) = 0; 188cdf0e10cSrcweir 189cdf0e10cSrcweir virtual void abort() 190cdf0e10cSrcweir throw( DAVException ) = 0; 191cdf0e10cSrcweir 192cdf0e10cSrcweir protected: 193cdf0e10cSrcweir rtl::Reference< DAVSessionFactory > m_xFactory; 194cdf0e10cSrcweir 195cdf0e10cSrcweir DAVSession( rtl::Reference< DAVSessionFactory > const & rFactory ) 196cdf0e10cSrcweir : m_xFactory( rFactory ), m_nRefCount( 0 ) {} 197cdf0e10cSrcweir 198cdf0e10cSrcweir virtual ~DAVSession() {} 199cdf0e10cSrcweir 200cdf0e10cSrcweir private: 201cdf0e10cSrcweir DAVSessionFactory::Map::iterator m_aContainerIt; 202cdf0e10cSrcweir oslInterlockedCount m_nRefCount; 203cdf0e10cSrcweir 204cdf0e10cSrcweir friend class DAVSessionFactory; 205cdf0e10cSrcweir #if defined WNT && _MSC_VER < 1310 206cdf0e10cSrcweir friend struct std::auto_ptr< DAVSession >; 207cdf0e10cSrcweir // work around compiler bug... 208cdf0e10cSrcweir #else // WNT 209cdf0e10cSrcweir friend class std::auto_ptr< DAVSession >; 210cdf0e10cSrcweir #endif // WNT 211cdf0e10cSrcweir }; 212cdf0e10cSrcweir 213cdf0e10cSrcweir } // namespace webdav_ucp 214cdf0e10cSrcweir 215cdf0e10cSrcweir #endif // _DAVSESSION_HXX_ 216