1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _DAVRESOURCEACCESS_HXX_ 29 #define _DAVRESOURCEACCESS_HXX_ 30 31 #include <vector> 32 #include <rtl/ustring.hxx> 33 #include <rtl/ref.hxx> 34 #include <osl/mutex.hxx> 35 #include <com/sun/star/io/XInputStream.hpp> 36 #include <com/sun/star/io/XOutputStream.hpp> 37 #include <com/sun/star/ucb/Lock.hpp> 38 #include <com/sun/star/ucb/XCommandEnvironment.hpp> 39 #include "DAVAuthListener.hxx" 40 #include "DAVException.hxx" 41 #include "DAVSession.hxx" 42 #include "DAVResource.hxx" 43 #include "DAVTypes.hxx" 44 #include "NeonUri.hxx" 45 46 namespace webdav_ucp 47 { 48 49 class DAVSessionFactory; 50 51 class DAVResourceAccess 52 { 53 osl::Mutex m_aMutex; 54 rtl::OUString m_aURL; 55 rtl::OUString m_aPath; 56 rtl::Reference< DAVSession > m_xSession; 57 rtl::Reference< DAVSessionFactory > m_xSessionFactory; 58 com::sun::star::uno::Reference< 59 com::sun::star::lang::XMultiServiceFactory > m_xSMgr; 60 std::vector< NeonUri > m_aRedirectURIs; 61 62 public: 63 DAVResourceAccess() : m_xSessionFactory( 0 ) {} 64 DAVResourceAccess( const com::sun::star::uno::Reference< 65 com::sun::star::lang::XMultiServiceFactory > & rSMgr, 66 rtl::Reference< 67 DAVSessionFactory > const & rSessionFactory, 68 const rtl::OUString & rURL ); 69 DAVResourceAccess( const DAVResourceAccess & rOther ); 70 71 DAVResourceAccess & operator=( const DAVResourceAccess & rOther ); 72 73 void setURL( const rtl::OUString & rNewURL ) 74 throw ( DAVException ); 75 76 void resetUri(); 77 78 const rtl::OUString & getURL() const { return m_aURL; } 79 80 rtl::Reference< DAVSessionFactory > getSessionFactory() const 81 { return m_xSessionFactory; } 82 83 // DAV methods 84 // 85 86 #if 0 // currently not used, but please don't remove code 87 void 88 OPTIONS( DAVCapabilities & rCapabilities, 89 const com::sun::star::uno::Reference< 90 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 91 throw ( DAVException ); 92 #endif 93 94 // allprop & named 95 void 96 PROPFIND( const Depth nDepth, 97 const std::vector< rtl::OUString > & rPropertyNames, 98 std::vector< DAVResource > & rResources, 99 const com::sun::star::uno::Reference< 100 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 101 throw ( DAVException ); 102 103 // propnames 104 void 105 PROPFIND( const Depth nDepth, 106 std::vector< DAVResourceInfo > & rResInfo, 107 const com::sun::star::uno::Reference< 108 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 109 throw ( DAVException ); 110 111 void 112 PROPPATCH( const std::vector< ProppatchValue > & rValues, 113 const com::sun::star::uno::Reference< 114 com::sun::star::ucb::XCommandEnvironment >& xEnv ) 115 throw ( DAVException ); 116 117 void 118 HEAD( const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all' 119 DAVResource & rResource, 120 const com::sun::star::uno::Reference< 121 com::sun::star::ucb::XCommandEnvironment >& xEnv ) 122 throw ( DAVException ); 123 124 com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 125 GET( const com::sun::star::uno::Reference< 126 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 127 throw ( DAVException ); 128 129 void 130 GET( com::sun::star::uno::Reference< 131 com::sun::star::io::XOutputStream > & rStream, 132 const com::sun::star::uno::Reference< 133 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 134 throw ( DAVException ); 135 136 com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 137 GET( const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all' 138 DAVResource & rResource, 139 const com::sun::star::uno::Reference< 140 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 141 throw ( DAVException ); 142 143 void 144 GET( com::sun::star::uno::Reference< 145 com::sun::star::io::XOutputStream > & rStream, 146 const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all' 147 DAVResource & rResource, 148 const com::sun::star::uno::Reference< 149 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 150 throw ( DAVException ); 151 152 void 153 PUT( const com::sun::star::uno::Reference< 154 com::sun::star::io::XInputStream > & rStream, 155 const com::sun::star::uno::Reference< 156 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 157 throw ( DAVException ); 158 159 com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 160 POST( const rtl::OUString & rContentType, 161 const rtl::OUString & rReferer, 162 const com::sun::star::uno::Reference< 163 com::sun::star::io::XInputStream > & rInputStream, 164 const com::sun::star::uno::Reference< 165 com::sun::star::ucb::XCommandEnvironment >& xEnv ) 166 throw ( DAVException ); 167 168 void 169 POST( const rtl::OUString & rContentType, 170 const rtl::OUString & rReferer, 171 const com::sun::star::uno::Reference< 172 com::sun::star::io::XInputStream > & rInputStream, 173 com::sun::star::uno::Reference< 174 com::sun::star::io::XOutputStream > & rOutputStream, 175 const com::sun::star::uno::Reference< 176 com::sun::star::ucb::XCommandEnvironment >& xEnv ) 177 throw ( DAVException ); 178 179 void 180 MKCOL( const com::sun::star::uno::Reference< 181 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 182 throw ( DAVException ); 183 184 void 185 COPY( const ::rtl::OUString & rSourcePath, 186 const ::rtl::OUString & rDestinationURI, 187 sal_Bool bOverwrite, 188 const com::sun::star::uno::Reference< 189 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 190 throw ( DAVException ); 191 192 void 193 MOVE( const ::rtl::OUString & rSourcePath, 194 const ::rtl::OUString & rDestinationURI, 195 sal_Bool bOverwrite, 196 const com::sun::star::uno::Reference< 197 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 198 throw ( DAVException ); 199 200 void 201 DESTROY( const com::sun::star::uno::Reference< 202 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 203 throw ( DAVException ); 204 205 // set new lock. 206 void 207 LOCK( com::sun::star::ucb::Lock & inLock, 208 const com::sun::star::uno::Reference< 209 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 210 throw( DAVException ); 211 212 #if 0 // currently not used, but please don't remove code 213 // refresh existing lock. 214 sal_Int64 215 LOCK( sal_Int64 nTimeout, 216 const com::sun::star::uno::Reference< 217 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 218 throw ( DAVException ); 219 #endif 220 221 void 222 UNLOCK( const com::sun::star::uno::Reference< 223 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 224 throw ( DAVException ); 225 226 void 227 abort() 228 throw ( DAVException ); 229 230 // helper 231 static void 232 getUserRequestHeaders( 233 const com::sun::star::uno::Reference< 234 com::sun::star::ucb::XCommandEnvironment > & xEnv, 235 const rtl::OUString & rURI, 236 const rtl::OUString & rMethod, 237 DAVRequestHeaders & rRequestHeaders ); 238 239 private: 240 const rtl::OUString & getRequestURI() const; 241 sal_Bool detectRedirectCycle( const rtl::OUString& rRedirectURL ) 242 throw ( DAVException ); 243 sal_Bool handleException( DAVException & e, int errorCount ) 244 throw ( DAVException ); 245 void initialize() 246 throw ( DAVException ); 247 }; 248 249 } // namespace webdav_ucp 250 251 #endif // _DAVRESOURCEACCESS_HXX_ 252