LibreOffice Module ucb (master)  1
DAVResourceAccess.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 
21 #pragma once
22 
23 #include <vector>
24 #include <rtl/ustring.hxx>
25 #include <rtl/ref.hxx>
26 #include <osl/mutex.hxx>
27 #include <com/sun/star/io/XInputStream.hpp>
28 #include <com/sun/star/io/XOutputStream.hpp>
29 #include <com/sun/star/beans/NamedValue.hpp>
30 #include <com/sun/star/ucb/Lock.hpp>
31 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
32 #include <com/sun/star/ucb/WebDAVHTTPMethod.hpp>
33 #include "DAVAuthListener.hxx"
34 #include "DAVException.hxx"
35 #include "DAVSession.hxx"
36 #include "DAVResource.hxx"
37 #include "DAVTypes.hxx"
38 #include "CurlUri.hxx"
39 
40 namespace http_dav_ucp
41 {
42 
43 class DAVSessionFactory;
44 
46 {
47  osl::Mutex m_aMutex;
48  OUString m_aURL;
49  OUString m_aPath;
50  ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > m_aFlags;
53  css::uno::Reference< css::uno::XComponentContext > m_xContext;
54  std::vector<CurlUri> m_aRedirectURIs;
55  sal_uInt32 m_nRedirectLimit;
56 
57 public:
58  DAVResourceAccess() = default;
59  DAVResourceAccess( const css::uno::Reference< css::uno::XComponentContext > & rContext,
60  rtl::Reference< DAVSessionFactory > const & rSessionFactory,
61  const OUString & rURL );
62  DAVResourceAccess( const DAVResourceAccess & rOther );
63 
64  DAVResourceAccess & operator=( const DAVResourceAccess & rOther );
65 
67  void setFlags( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rFlags );
68 
70  void setURL( const OUString & rNewURL );
71 
72  void resetUri();
73 
74  const OUString & getURL() const { return m_aURL; }
75 
77  { return m_xSessionFactory; }
78 
79  // DAV methods
80 
82  void
83  OPTIONS(
84  DAVOptions & rOptions,
85  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
86 
87  // allprop & named
89  void
90  PROPFIND( const Depth nDepth,
91  const std::vector< OUString > & rPropertyNames,
92  std::vector< DAVResource > & rResources,
93  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
94 
95  // propnames
97  void
98  PROPFIND( const Depth nDepth,
99  std::vector< DAVResourceInfo > & rResInfo,
100  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
101 
103  void
104  PROPPATCH( const std::vector< ProppatchValue > & rValues,
105  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
106 
108  void
109  HEAD( const std::vector< OUString > & rHeaderNames, // empty == 'all'
110  DAVResource & rResource,
111  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
112 
114  css::uno::Reference< css::io::XInputStream >
115  GET( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
116 
118  void
119  GET( css::uno::Reference< css::io::XOutputStream > & rStream,
120  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
121 
123  css::uno::Reference< css::io::XInputStream >
124  GET( const std::vector< OUString > & rHeaderNames, // empty == 'all'
125  DAVResource & rResource,
126  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
127 
130  void
131  GET0( DAVRequestHeaders & rRequestHeaders,
132  const std::vector< OUString > & rHeaderNames, // empty == 'all'
133  DAVResource & rResource,
134  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
135 
137  void
138  GET( css::uno::Reference< css::io::XOutputStream > & rStream,
139  const std::vector< OUString > & rHeaderNames, // empty == 'all'
140  DAVResource & rResource,
141  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
142 
144  void
145  PUT( const css::uno::Reference< css::io::XInputStream > & rStream,
146  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
147 
149  css::uno::Reference< css::io::XInputStream >
150  POST( const OUString & rContentType,
151  const OUString & rReferer,
152  const css::uno::Reference< css::io::XInputStream > & rInputStream,
153  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
154 
156  void
157  POST( const OUString & rContentType,
158  const OUString & rReferer,
159  const css::uno::Reference< css::io::XInputStream > & rInputStream,
160  css::uno::Reference< css::io::XOutputStream > & rOutputStream,
161  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
162 
164  void
165  MKCOL( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
166 
168  void
169  COPY( const OUString & rSourcePath,
170  const OUString & rDestinationURI,
171  bool bOverwrite,
172  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
173 
175  void
176  MOVE( const OUString & rSourcePath,
177  const OUString & rDestinationURI,
178  bool bOverwrite,
179  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
180 
182  void
183  DESTROY( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
184 
185  // set new lock.
187  void
188  LOCK( css::ucb::Lock & inLock,
189  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
190 
192  void
193  UNLOCK( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
194 
196  void
197  abort();
198 
199  // helper
200  static void
202  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv,
203  const OUString & rURI,
204  css::ucb::WebDAVHTTPMethod eMethod,
205  DAVRequestHeaders & rRequestHeaders );
206 
208  bool handleException(DAVException const& e, int errorCount);
209 
210 private:
211  const OUString & getRequestURI() const;
213  bool detectRedirectCycle(::std::u16string_view rRedirectURL);
215  void initialize();
216 };
217 
218 } // namespace http_dav_ucp
219 
220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void HEAD(const std::vector< OUString > &rHeaderNames, DAVResource &rResource, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
std::vector< DAVRequestHeader > DAVRequestHeaders
void PROPPATCH(const std::vector< ProppatchValue > &rValues, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void OPTIONS(DAVOptions &rOptions, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
const OUString & getURL() const
DAVResourceAccess & operator=(const DAVResourceAccess &rOther)
bool handleException(DAVException const &e, int errorCount)
void UNLOCK(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
css::uno::Reference< css::io::XInputStream > POST(const OUString &rContentType, const OUString &rReferer, const css::uno::Reference< css::io::XInputStream > &rInputStream, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void MKCOL(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void COPY(const OUString &rSourcePath, const OUString &rDestinationURI, bool bOverwrite, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void setFlags(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > &rFlags)
static void getUserRequestHeaders(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, const OUString &rURI, css::ucb::WebDAVHTTPMethod eMethod, DAVRequestHeaders &rRequestHeaders)
void PUT(const css::uno::Reference< css::io::XInputStream > &rStream, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
std::vector< CurlUri > m_aRedirectURIs
void GET0(DAVRequestHeaders &rRequestHeaders, const std::vector< OUString > &rHeaderNames, DAVResource &rResource, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
used as HEAD substitute when HEAD is not implemented on server
rtl::Reference< DAVSession > m_xSession
css::uno::Reference< css::uno::XComponentContext > m_xContext
css::uno::Reference< css::io::XInputStream > GET(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void setURL(const OUString &rNewURL)
void PROPFIND(const Depth nDepth, const std::vector< OUString > &rPropertyNames, std::vector< DAVResource > &rResources, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
rtl::Reference< DAVSessionFactory > m_xSessionFactory
void MOVE(const OUString &rSourcePath, const OUString &rDestinationURI, bool bOverwrite, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > m_aFlags
rtl::Reference< DAVSessionFactory > getSessionFactory() const
bool detectRedirectCycle(::std::u16string_view rRedirectURL)
const OUString & getRequestURI() const
void DESTROY(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void LOCK(css::ucb::Lock &inLock, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)