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