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