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