16df1ea1fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 36df1ea1fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 46df1ea1fSAndrew Rist * or more contributor license agreements. See the NOTICE file 56df1ea1fSAndrew Rist * distributed with this work for additional information 66df1ea1fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 76df1ea1fSAndrew Rist * to you under the Apache License, Version 2.0 (the 86df1ea1fSAndrew Rist * "License"); you may not use this file except in compliance 96df1ea1fSAndrew Rist * with the License. You may obtain a copy of the License at 106df1ea1fSAndrew Rist * 116df1ea1fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 126df1ea1fSAndrew Rist * 136df1ea1fSAndrew Rist * Unless required by applicable law or agreed to in writing, 146df1ea1fSAndrew Rist * software distributed under the License is distributed on an 156df1ea1fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 166df1ea1fSAndrew Rist * KIND, either express or implied. See the License for the 176df1ea1fSAndrew Rist * specific language governing permissions and limitations 186df1ea1fSAndrew Rist * under the License. 196df1ea1fSAndrew Rist * 206df1ea1fSAndrew Rist *************************************************************/ 216df1ea1fSAndrew Rist 226df1ea1fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _DAVRESOURCEACCESS_HXX_ 25cdf0e10cSrcweir #define _DAVRESOURCEACCESS_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <vector> 28cdf0e10cSrcweir #include <rtl/ustring.hxx> 29cdf0e10cSrcweir #include <rtl/ref.hxx> 30cdf0e10cSrcweir #include <osl/mutex.hxx> 31cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 32cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 33cdf0e10cSrcweir #include <com/sun/star/ucb/Lock.hpp> 34cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandEnvironment.hpp> 35c5f58c9aSAriel Constenla-Haile #include <com/sun/star/ucb/WebDAVHTTPMethod.hpp> 36cdf0e10cSrcweir #include "DAVAuthListener.hxx" 37cdf0e10cSrcweir #include "DAVException.hxx" 38cdf0e10cSrcweir #include "DAVSession.hxx" 39cdf0e10cSrcweir #include "DAVResource.hxx" 40cdf0e10cSrcweir #include "DAVTypes.hxx" 4159ddfc10SAndre Fischer #include "SerfUri.hxx" 42cdf0e10cSrcweir 4359ddfc10SAndre Fischer namespace http_dav_ucp 44cdf0e10cSrcweir { 45cdf0e10cSrcweir 46cdf0e10cSrcweir class DAVSessionFactory; 47cdf0e10cSrcweir 48cdf0e10cSrcweir class DAVResourceAccess 49cdf0e10cSrcweir { 50cdf0e10cSrcweir osl::Mutex m_aMutex; 51cdf0e10cSrcweir rtl::OUString m_aURL; 52cdf0e10cSrcweir rtl::OUString m_aPath; 53cdf0e10cSrcweir rtl::Reference< DAVSession > m_xSession; 54cdf0e10cSrcweir rtl::Reference< DAVSessionFactory > m_xSessionFactory; 55cdf0e10cSrcweir com::sun::star::uno::Reference< 56cdf0e10cSrcweir com::sun::star::lang::XMultiServiceFactory > m_xSMgr; 5759ddfc10SAndre Fischer std::vector< SerfUri > m_aRedirectURIs; 58cdf0e10cSrcweir 59cdf0e10cSrcweir public: 60cdf0e10cSrcweir DAVResourceAccess() : m_xSessionFactory( 0 ) {} 61cdf0e10cSrcweir DAVResourceAccess( const com::sun::star::uno::Reference< 62cdf0e10cSrcweir com::sun::star::lang::XMultiServiceFactory > & rSMgr, 63cdf0e10cSrcweir rtl::Reference< 64cdf0e10cSrcweir DAVSessionFactory > const & rSessionFactory, 65cdf0e10cSrcweir const rtl::OUString & rURL ); 66cdf0e10cSrcweir DAVResourceAccess( const DAVResourceAccess & rOther ); 67cdf0e10cSrcweir 68cdf0e10cSrcweir DAVResourceAccess & operator=( const DAVResourceAccess & rOther ); 69cdf0e10cSrcweir 70cdf0e10cSrcweir void setURL( const rtl::OUString & rNewURL ) 71cdf0e10cSrcweir throw ( DAVException ); 72cdf0e10cSrcweir 73cdf0e10cSrcweir void resetUri(); 74cdf0e10cSrcweir 75cdf0e10cSrcweir const rtl::OUString & getURL() const { return m_aURL; } 76cdf0e10cSrcweir 77cdf0e10cSrcweir rtl::Reference< DAVSessionFactory > getSessionFactory() const 78cdf0e10cSrcweir { return m_xSessionFactory; } 79cdf0e10cSrcweir 80cdf0e10cSrcweir // DAV methods 81cdf0e10cSrcweir // 82cdf0e10cSrcweir 83cdf0e10cSrcweir // allprop & named 84cdf0e10cSrcweir void 85cdf0e10cSrcweir PROPFIND( const Depth nDepth, 86cdf0e10cSrcweir const std::vector< rtl::OUString > & rPropertyNames, 87cdf0e10cSrcweir std::vector< DAVResource > & rResources, 88cdf0e10cSrcweir const com::sun::star::uno::Reference< 89cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv ) 90cdf0e10cSrcweir throw ( DAVException ); 91cdf0e10cSrcweir 92cdf0e10cSrcweir // propnames 93cdf0e10cSrcweir void 94cdf0e10cSrcweir PROPFIND( const Depth nDepth, 95cdf0e10cSrcweir std::vector< DAVResourceInfo > & rResInfo, 96cdf0e10cSrcweir const com::sun::star::uno::Reference< 97cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv ) 98cdf0e10cSrcweir throw ( DAVException ); 99cdf0e10cSrcweir 100cdf0e10cSrcweir void 101cdf0e10cSrcweir PROPPATCH( const std::vector< ProppatchValue > & rValues, 102cdf0e10cSrcweir const com::sun::star::uno::Reference< 103cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment >& xEnv ) 104cdf0e10cSrcweir throw ( DAVException ); 105cdf0e10cSrcweir 106cdf0e10cSrcweir void 107cdf0e10cSrcweir HEAD( const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all' 108cdf0e10cSrcweir DAVResource & rResource, 109cdf0e10cSrcweir const com::sun::star::uno::Reference< 110cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment >& xEnv ) 111cdf0e10cSrcweir throw ( DAVException ); 112cdf0e10cSrcweir 113cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 114cdf0e10cSrcweir GET( const com::sun::star::uno::Reference< 115cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv ) 116cdf0e10cSrcweir throw ( DAVException ); 117cdf0e10cSrcweir 118cdf0e10cSrcweir void 119cdf0e10cSrcweir GET( com::sun::star::uno::Reference< 120cdf0e10cSrcweir com::sun::star::io::XOutputStream > & rStream, 121cdf0e10cSrcweir const com::sun::star::uno::Reference< 122cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv ) 123cdf0e10cSrcweir throw ( DAVException ); 124cdf0e10cSrcweir 125cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 126cdf0e10cSrcweir GET( const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all' 127cdf0e10cSrcweir DAVResource & rResource, 128cdf0e10cSrcweir const com::sun::star::uno::Reference< 129cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv ) 130cdf0e10cSrcweir throw ( DAVException ); 131cdf0e10cSrcweir 132c5b3447dSAriel Constenla-Haile com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 133c5b3447dSAriel Constenla-Haile GET( DAVRequestHeaders & rRequestHeaders, 134c5b3447dSAriel Constenla-Haile const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all' 135c5b3447dSAriel Constenla-Haile DAVResource & rResource, 136c5b3447dSAriel Constenla-Haile const com::sun::star::uno::Reference< 137c5b3447dSAriel Constenla-Haile com::sun::star::ucb::XCommandEnvironment > & xEnv ) 138c5b3447dSAriel Constenla-Haile throw ( DAVException ); 139c5b3447dSAriel Constenla-Haile 140cdf0e10cSrcweir void 141cdf0e10cSrcweir GET( com::sun::star::uno::Reference< 142cdf0e10cSrcweir com::sun::star::io::XOutputStream > & rStream, 143cdf0e10cSrcweir const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all' 144cdf0e10cSrcweir DAVResource & rResource, 145cdf0e10cSrcweir const com::sun::star::uno::Reference< 146cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv ) 147cdf0e10cSrcweir throw ( DAVException ); 148cdf0e10cSrcweir 149cdf0e10cSrcweir void 150cdf0e10cSrcweir PUT( const com::sun::star::uno::Reference< 151cdf0e10cSrcweir com::sun::star::io::XInputStream > & rStream, 152cdf0e10cSrcweir const com::sun::star::uno::Reference< 153cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv ) 154cdf0e10cSrcweir throw ( DAVException ); 155cdf0e10cSrcweir 156cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 157cdf0e10cSrcweir POST( const rtl::OUString & rContentType, 158cdf0e10cSrcweir const rtl::OUString & rReferer, 159cdf0e10cSrcweir const com::sun::star::uno::Reference< 160cdf0e10cSrcweir com::sun::star::io::XInputStream > & rInputStream, 161cdf0e10cSrcweir const com::sun::star::uno::Reference< 162cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment >& xEnv ) 163cdf0e10cSrcweir throw ( DAVException ); 164cdf0e10cSrcweir 165cdf0e10cSrcweir void 166cdf0e10cSrcweir POST( const rtl::OUString & rContentType, 167cdf0e10cSrcweir const rtl::OUString & rReferer, 168cdf0e10cSrcweir const com::sun::star::uno::Reference< 169cdf0e10cSrcweir com::sun::star::io::XInputStream > & rInputStream, 170cdf0e10cSrcweir com::sun::star::uno::Reference< 171cdf0e10cSrcweir com::sun::star::io::XOutputStream > & rOutputStream, 172cdf0e10cSrcweir const com::sun::star::uno::Reference< 173cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment >& xEnv ) 174cdf0e10cSrcweir throw ( DAVException ); 175cdf0e10cSrcweir 176cdf0e10cSrcweir void 177cdf0e10cSrcweir MKCOL( const com::sun::star::uno::Reference< 178cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv ) 179cdf0e10cSrcweir throw ( DAVException ); 180cdf0e10cSrcweir 181cdf0e10cSrcweir void 182cdf0e10cSrcweir COPY( const ::rtl::OUString & rSourcePath, 183cdf0e10cSrcweir const ::rtl::OUString & rDestinationURI, 184cdf0e10cSrcweir sal_Bool bOverwrite, 185cdf0e10cSrcweir const com::sun::star::uno::Reference< 186cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv ) 187cdf0e10cSrcweir throw ( DAVException ); 188cdf0e10cSrcweir 189cdf0e10cSrcweir void 190cdf0e10cSrcweir MOVE( const ::rtl::OUString & rSourcePath, 191cdf0e10cSrcweir const ::rtl::OUString & rDestinationURI, 192cdf0e10cSrcweir sal_Bool bOverwrite, 193cdf0e10cSrcweir const com::sun::star::uno::Reference< 194cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv ) 195cdf0e10cSrcweir throw ( DAVException ); 196cdf0e10cSrcweir 197cdf0e10cSrcweir void 198cdf0e10cSrcweir DESTROY( const com::sun::star::uno::Reference< 199cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv ) 200cdf0e10cSrcweir throw ( DAVException ); 201cdf0e10cSrcweir 202cdf0e10cSrcweir // set new lock. 203cdf0e10cSrcweir void 204cdf0e10cSrcweir LOCK( com::sun::star::ucb::Lock & inLock, 205cdf0e10cSrcweir const com::sun::star::uno::Reference< 206*9c0c1533SAndrea Pescetti com::sun::star::ucb::XCommandEnvironment > & xEnv ) 207cdf0e10cSrcweir throw( DAVException ); 208cdf0e10cSrcweir 209cdf0e10cSrcweir #if 0 // currently not used, but please don't remove code 210cdf0e10cSrcweir // refresh existing lock. 211cdf0e10cSrcweir sal_Int64 212cdf0e10cSrcweir LOCK( sal_Int64 nTimeout, 213cdf0e10cSrcweir const com::sun::star::uno::Reference< 214cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv ) 215cdf0e10cSrcweir throw ( DAVException ); 216cdf0e10cSrcweir #endif 217cdf0e10cSrcweir 218cdf0e10cSrcweir void 219cdf0e10cSrcweir UNLOCK( const com::sun::star::uno::Reference< 220cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv ) 221cdf0e10cSrcweir throw ( DAVException ); 222cdf0e10cSrcweir 223cdf0e10cSrcweir void 224cdf0e10cSrcweir abort() 225cdf0e10cSrcweir throw ( DAVException ); 226cdf0e10cSrcweir 227cdf0e10cSrcweir // helper 228cdf0e10cSrcweir static void 229cdf0e10cSrcweir getUserRequestHeaders( 230cdf0e10cSrcweir const com::sun::star::uno::Reference< 231cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv, 232cdf0e10cSrcweir const rtl::OUString & rURI, 233c5f58c9aSAriel Constenla-Haile com::sun::star::ucb::WebDAVHTTPMethod eMethod, 234cdf0e10cSrcweir DAVRequestHeaders & rRequestHeaders ); 235cdf0e10cSrcweir 236cdf0e10cSrcweir private: 237cdf0e10cSrcweir const rtl::OUString & getRequestURI() const; 238cdf0e10cSrcweir sal_Bool detectRedirectCycle( const rtl::OUString& rRedirectURL ) 239cdf0e10cSrcweir throw ( DAVException ); 240cdf0e10cSrcweir sal_Bool handleException( DAVException & e, int errorCount ) 241cdf0e10cSrcweir throw ( DAVException ); 242cdf0e10cSrcweir void initialize() 243cdf0e10cSrcweir throw ( DAVException ); 244cdf0e10cSrcweir }; 245cdf0e10cSrcweir 24659ddfc10SAndre Fischer } // namespace http_dav_ucp 247cdf0e10cSrcweir 248cdf0e10cSrcweir #endif // _DAVRESOURCEACCESS_HXX_ 249