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 #ifndef INCLUDED_UCB_SOURCE_UCP_WEBDAV_DAVRESOURCEACCESS_HXX
22 #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_DAVRESOURCEACCESS_HXX
23 
24 #include <vector>
25 #include <rtl/ustring.hxx>
26 #include <rtl/ref.hxx>
27 #include <osl/mutex.hxx>
28 #include <com/sun/star/io/XInputStream.hpp>
29 #include <com/sun/star/io/XOutputStream.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 "SerfUri.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;
52  css::uno::Reference< css::uno::XComponentContext > m_xContext;
53  std::vector< SerfUri > m_aRedirectURIs;
54 
55 public:
56  DAVResourceAccess() = default;
57  DAVResourceAccess( const css::uno::Reference< css::uno::XComponentContext > & rContext,
58  rtl::Reference< DAVSessionFactory > const & rSessionFactory,
59  const OUString & rURL );
60  DAVResourceAccess( const DAVResourceAccess & rOther );
61 
62  DAVResourceAccess & operator=( const DAVResourceAccess & rOther );
63 
65  void setURL( const OUString & rNewURL );
66 
67  void resetUri();
68 
69  const OUString & getURL() const { return m_aURL; }
70 
72  { return m_xSessionFactory; }
73 
74  // DAV methods
75 
76 
77  // allprop & named
79  void
80  PROPFIND( const Depth nDepth,
81  const std::vector< OUString > & rPropertyNames,
82  std::vector< DAVResource > & rResources,
83  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
84 
85  // propnames
87  void
88  PROPFIND( const Depth nDepth,
89  std::vector< DAVResourceInfo > & rResInfo,
90  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
91 
93  void
94  PROPPATCH( const std::vector< ProppatchValue > & rValues,
95  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
96 
98  void
99  HEAD( const std::vector< OUString > & rHeaderNames, // empty == 'all'
100  DAVResource & rResource,
101  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
102 
104  css::uno::Reference< css::io::XInputStream >
105  GET( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
106 
108  void
109  GET( css::uno::Reference< css::io::XOutputStream > & rStream,
110  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
111 
113  css::uno::Reference< css::io::XInputStream >
114  GET( const std::vector< OUString > & rHeaderNames, // empty == 'all'
115  DAVResource & rResource,
116  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
117 
119  css::uno::Reference< css::io::XInputStream >
120  GET( DAVRequestHeaders & rRequestHeaders,
121  const std::vector< OUString > & rHeaderNames, // empty == 'all'
122  DAVResource & rResource,
123  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
124 
126  void
127  GET( css::uno::Reference< css::io::XOutputStream > & rStream,
128  const std::vector< OUString > & rHeaderNames, // empty == 'all'
129  DAVResource & rResource,
130  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
131 
133  void
134  PUT( const css::uno::Reference< css::io::XInputStream > & rStream,
135  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
136 
138  css::uno::Reference< css::io::XInputStream >
139  POST( const OUString & rContentType,
140  const OUString & rReferer,
141  const css::uno::Reference< css::io::XInputStream > & rInputStream,
142  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
143 
145  void
146  POST( const OUString & rContentType,
147  const OUString & rReferer,
148  const css::uno::Reference< css::io::XInputStream > & rInputStream,
149  css::uno::Reference< css::io::XOutputStream > & rOutputStream,
150  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
151 
153  void
154  MKCOL( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
155 
157  void
158  COPY( const OUString & rSourcePath,
159  const OUString & rDestinationURI,
160  bool bOverwrite,
161  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
162 
164  void
165  MOVE( const OUString & rSourcePath,
166  const OUString & rDestinationURI,
167  bool bOverwrite,
168  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
169 
171  void
172  DESTROY( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
173 
174  // set new lock.
176  void
177  LOCK( css::ucb::Lock & inLock,
178  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
179 
181  void
182  UNLOCK( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
183 
185  void
186  static abort();
187 
188  // helper
189  static void
191  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv,
192  const OUString & rURI,
193  css::ucb::WebDAVHTTPMethod eMethod,
194  DAVRequestHeaders & rRequestHeaders );
195 
196 private:
197  const OUString & getRequestURI() const;
199  bool detectRedirectCycle( const OUString& rRedirectURL );
201  bool handleException( DAVException & e, int errorCount );
203  void initialize();
204 };
205 
206 } // namespace http_dav_ucp
207 
208 #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_DAVRESOURCEACCESS_HXX
209 
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< DAVRequestHeader > DAVRequestHeaders
const OUString & getURL() const
DAVResourceAccess & operator=(const DAVResourceAccess &rOther)
void DESTROY(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)
rtl::Reference< DAVSession > m_xSession
void MKCOL(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void UNLOCK(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
css::uno::Reference< css::uno::XComponentContext > m_xContext
void MOVE(const OUString &rSourcePath, const OUString &rDestinationURI, bool bOverwrite, 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)
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)
bool detectRedirectCycle(const OUString &rRedirectURL)
rtl::Reference< DAVSessionFactory > m_xSessionFactory
void HEAD(const std::vector< OUString > &rHeaderNames, DAVResource &rResource, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
std::vector< SerfUri > m_aRedirectURIs
rtl::Reference< DAVSessionFactory > getSessionFactory() const
static void getUserRequestHeaders(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, const OUString &rURI, css::ucb::WebDAVHTTPMethod eMethod, DAVRequestHeaders &rRequestHeaders)
void PROPPATCH(const std::vector< ProppatchValue > &rValues, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void PUT(const css::uno::Reference< css::io::XInputStream > &rStream, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
const OUString & getRequestURI() const
void LOCK(css::ucb::Lock &inLock, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
bool handleException(DAVException &e, int errorCount)