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 void 132 GET( com::sun::star::uno::Reference< 133 com::sun::star::io::XOutputStream > & rStream, 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 PUT( const com::sun::star::uno::Reference< 142 com::sun::star::io::XInputStream > & rStream, 143 const com::sun::star::uno::Reference< 144 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 145 throw ( DAVException ); 146 147 com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 148 POST( const rtl::OUString & rContentType, 149 const rtl::OUString & rReferer, 150 const com::sun::star::uno::Reference< 151 com::sun::star::io::XInputStream > & rInputStream, 152 const com::sun::star::uno::Reference< 153 com::sun::star::ucb::XCommandEnvironment >& xEnv ) 154 throw ( DAVException ); 155 156 void 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 com::sun::star::uno::Reference< 162 com::sun::star::io::XOutputStream > & rOutputStream, 163 const com::sun::star::uno::Reference< 164 com::sun::star::ucb::XCommandEnvironment >& xEnv ) 165 throw ( DAVException ); 166 167 void 168 MKCOL( const com::sun::star::uno::Reference< 169 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 170 throw ( DAVException ); 171 172 void 173 COPY( const ::rtl::OUString & rSourcePath, 174 const ::rtl::OUString & rDestinationURI, 175 sal_Bool bOverwrite, 176 const com::sun::star::uno::Reference< 177 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 178 throw ( DAVException ); 179 180 void 181 MOVE( 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 DESTROY( const com::sun::star::uno::Reference< 190 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 191 throw ( DAVException ); 192 193 // set new lock. 194 void 195 LOCK( com::sun::star::ucb::Lock & inLock, 196 const com::sun::star::uno::Reference< 197 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 198 throw( DAVException ); 199 200 #if 0 // currently not used, but please don't remove code 201 // refresh existing lock. 202 sal_Int64 203 LOCK( sal_Int64 nTimeout, 204 const com::sun::star::uno::Reference< 205 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 206 throw ( DAVException ); 207 #endif 208 209 void 210 UNLOCK( const com::sun::star::uno::Reference< 211 com::sun::star::ucb::XCommandEnvironment > & xEnv ) 212 throw ( DAVException ); 213 214 void 215 abort() 216 throw ( DAVException ); 217 218 // helper 219 static void 220 getUserRequestHeaders( 221 const com::sun::star::uno::Reference< 222 com::sun::star::ucb::XCommandEnvironment > & xEnv, 223 const rtl::OUString & rURI, 224 const rtl::OUString & rMethod, 225 DAVRequestHeaders & rRequestHeaders ); 226 227 private: 228 const rtl::OUString & getRequestURI() const; 229 sal_Bool detectRedirectCycle( const rtl::OUString& rRedirectURL ) 230 throw ( DAVException ); 231 sal_Bool handleException( DAVException & e, int errorCount ) 232 throw ( DAVException ); 233 void initialize() 234 throw ( DAVException ); 235 }; 236 237 } // namespace http_dav_ucp 238 239 #endif // _DAVRESOURCEACCESS_HXX_ 240