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 _DAVRESOURCEACCESS_HXX_ 25 #define _DAVRESOURCEACCESS_HXX_ 26 27 #include <vector> 28 #include <rtl/ustring.hxx> 29 #include <rtl/ref.hxx> 30 #include <osl/mutex.hxx> 31 #include <com/sun/star/io/XInputStream.hpp> 32 #include <com/sun/star/io/XOutputStream.hpp> 33 #include <com/sun/star/ucb/Lock.hpp> 34 #include <com/sun/star/ucb/XCommandEnvironment.hpp> 35 #include <com/sun/star/ucb/WebDAVHTTPMethod.hpp> 36 #include "DAVAuthListener.hxx" 37 #include "DAVException.hxx" 38 #include "DAVSession.hxx" 39 #include "DAVResource.hxx" 40 #include "DAVTypes.hxx" 41 #include "CurlUri.hxx" 42 43 namespace http_dav_ucp 44 { 45 46 class DAVSessionFactory; 47 48 class DAVResourceAccess 49 { 50 osl::Mutex m_aMutex; 51 rtl::OUString m_aURL; 52 rtl::OUString m_aPath; 53 rtl::Reference< DAVSession > m_xSession; 54 rtl::Reference< DAVSessionFactory > m_xSessionFactory; 55 com::sun::star::uno::Reference< 56 com::sun::star::lang::XMultiServiceFactory > m_xSMgr; 57 std::vector< CurlUri > m_aRedirectURIs; 58 59 public: DAVResourceAccess()60 DAVResourceAccess() : m_xSessionFactory( 0 ) {} 61 DAVResourceAccess( const com::sun::star::uno::Reference< 62 com::sun::star::lang::XMultiServiceFactory > & rSMgr, 63 rtl::Reference< 64 DAVSessionFactory > const & rSessionFactory, 65 const rtl::OUString & rURL ); 66 DAVResourceAccess( const DAVResourceAccess & rOther ); 67 68 DAVResourceAccess & operator=( const DAVResourceAccess & rOther ); 69 70 void setURL( const rtl::OUString & rNewURL ) 71 throw ( DAVException ); 72 73 void resetUri(); 74 getURL() const75 const rtl::OUString & getURL() const { return m_aURL; } 76 getSessionFactory() const77 rtl::Reference< DAVSessionFactory > getSessionFactory() const 78 { return m_xSessionFactory; } 79 80 // DAV methods 81 // 82 83 // allprop & named 84 void 85 PROPFIND( const Depth nDepth, 86 const std::vector< rtl::OUString > & rPropertyNames, 87 std::vector< DAVResource > & rResources, 88 const com::sun::star::uno::Reference< 89 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 90 throw ( DAVException ); 91 92 // propnames 93 void 94 PROPFIND( const Depth nDepth, 95 std::vector< DAVResourceInfo > & rResInfo, 96 const com::sun::star::uno::Reference< 97 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 98 throw ( DAVException ); 99 100 void 101 PROPPATCH( const std::vector< ProppatchValue > & rValues, 102 const com::sun::star::uno::Reference< 103 com::sun::star::ucb::XCommandEnvironment >& xEnv ) 104 throw ( DAVException ); 105 106 void 107 HEAD( const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all' 108 DAVResource & rResource, 109 const com::sun::star::uno::Reference< 110 com::sun::star::ucb::XCommandEnvironment >& xEnv ) 111 throw ( DAVException ); 112 113 com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 114 GET( const com::sun::star::uno::Reference< 115 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 116 throw ( DAVException ); 117 118 void 119 GET( com::sun::star::uno::Reference< 120 com::sun::star::io::XOutputStream > & rStream, 121 const com::sun::star::uno::Reference< 122 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 123 throw ( DAVException ); 124 125 com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 126 GET( const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all' 127 DAVResource & rResource, 128 const com::sun::star::uno::Reference< 129 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 130 throw ( DAVException ); 131 132 com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 133 GET( DAVRequestHeaders & rRequestHeaders, 134 const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all' 135 DAVResource & rResource, 136 const com::sun::star::uno::Reference< 137 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 138 throw ( DAVException ); 139 140 void 141 GET( com::sun::star::uno::Reference< 142 com::sun::star::io::XOutputStream > & rStream, 143 const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all' 144 DAVResource & rResource, 145 const com::sun::star::uno::Reference< 146 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 147 throw ( DAVException ); 148 149 void 150 PUT( const com::sun::star::uno::Reference< 151 com::sun::star::io::XInputStream > & rStream, 152 const com::sun::star::uno::Reference< 153 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 154 throw ( DAVException ); 155 156 com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 157 POST( const rtl::OUString & rContentType, 158 const rtl::OUString & rReferer, 159 const com::sun::star::uno::Reference< 160 com::sun::star::io::XInputStream > & rInputStream, 161 const com::sun::star::uno::Reference< 162 com::sun::star::ucb::XCommandEnvironment >& xEnv ) 163 throw ( DAVException ); 164 165 void 166 POST( const rtl::OUString & rContentType, 167 const rtl::OUString & rReferer, 168 const com::sun::star::uno::Reference< 169 com::sun::star::io::XInputStream > & rInputStream, 170 com::sun::star::uno::Reference< 171 com::sun::star::io::XOutputStream > & rOutputStream, 172 const com::sun::star::uno::Reference< 173 com::sun::star::ucb::XCommandEnvironment >& xEnv ) 174 throw ( DAVException ); 175 176 void 177 MKCOL( const com::sun::star::uno::Reference< 178 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 179 throw ( DAVException ); 180 181 void 182 COPY( const ::rtl::OUString & rSourcePath, 183 const ::rtl::OUString & rDestinationURI, 184 sal_Bool bOverwrite, 185 const com::sun::star::uno::Reference< 186 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 187 throw ( DAVException ); 188 189 void 190 MOVE( const ::rtl::OUString & rSourcePath, 191 const ::rtl::OUString & rDestinationURI, 192 sal_Bool bOverwrite, 193 const com::sun::star::uno::Reference< 194 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 195 throw ( DAVException ); 196 197 void 198 DESTROY( const com::sun::star::uno::Reference< 199 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 200 throw ( DAVException ); 201 202 // set new lock. 203 void 204 LOCK( com::sun::star::ucb::Lock & inLock, 205 const com::sun::star::uno::Reference< 206 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 207 throw( DAVException ); 208 209 #if 0 // currently not used, but please don't remove code 210 // refresh existing lock. 211 sal_Int64 212 LOCK( sal_Int64 nTimeout, 213 const com::sun::star::uno::Reference< 214 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 215 throw ( DAVException ); 216 #endif 217 218 void 219 UNLOCK( const com::sun::star::uno::Reference< 220 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 221 throw ( DAVException ); 222 223 void 224 abort() 225 throw ( DAVException ); 226 227 // helper 228 static void 229 getUserRequestHeaders( 230 const com::sun::star::uno::Reference< 231 com::sun::star::ucb::XCommandEnvironment > & xEnv, 232 const rtl::OUString & rURI, 233 com::sun::star::ucb::WebDAVHTTPMethod eMethod, 234 DAVRequestHeaders & rRequestHeaders ); 235 236 private: 237 const rtl::OUString & getRequestURI() const; 238 sal_Bool detectRedirectCycle( const rtl::OUString& rRedirectURL ) 239 throw ( DAVException ); 240 sal_Bool handleException( DAVException & e, int errorCount ) 241 throw ( DAVException ); 242 void initialize() 243 throw ( DAVException ); 244 }; 245 246 } // namespace http_dav_ucp 247 248 #endif // _DAVRESOURCEACCESS_HXX_ 249