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/ucb/Lock.hpp>
30 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
31 #include <com/sun/star/ucb/WebDAVHTTPMethod.hpp>
32 #include "DAVAuthListener.hxx"
33 #include "DAVException.hxx"
34 #include "DAVSession.hxx"
35 #include "DAVResource.hxx"
36 #include "DAVTypes.hxx"
37 #include "SerfUri.hxx"
38 
39 namespace http_dav_ucp
40 {
41 
42 class DAVSessionFactory;
43 
45 {
46  osl::Mutex m_aMutex;
47  OUString m_aURL;
48  OUString m_aPath;
51  css::uno::Reference< css::uno::XComponentContext > m_xContext;
52  std::vector< SerfUri > m_aRedirectURIs;
53 
54 public:
55  DAVResourceAccess() = default;
56  DAVResourceAccess( const css::uno::Reference< css::uno::XComponentContext > & rContext,
57  rtl::Reference< DAVSessionFactory > const & rSessionFactory,
58  const OUString & rURL );
59  DAVResourceAccess( const DAVResourceAccess & rOther );
60 
61  DAVResourceAccess & operator=( const DAVResourceAccess & rOther );
62 
64  void setURL( const OUString & rNewURL );
65 
66  void resetUri();
67 
68  const OUString & getURL() const { return m_aURL; }
69 
71  { return m_xSessionFactory; }
72 
73  // DAV methods
74 
75 
76  // allprop & named
78  void
79  PROPFIND( const Depth nDepth,
80  const std::vector< OUString > & rPropertyNames,
81  std::vector< DAVResource > & rResources,
82  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
83 
84  // propnames
86  void
87  PROPFIND( const Depth nDepth,
88  std::vector< DAVResourceInfo > & rResInfo,
89  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
90 
92  void
93  PROPPATCH( const std::vector< ProppatchValue > & rValues,
94  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
95 
97  void
98  HEAD( const std::vector< OUString > & rHeaderNames, // empty == 'all'
99  DAVResource & rResource,
100  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
101 
103  css::uno::Reference< css::io::XInputStream >
104  GET( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
105 
107  void
108  GET( css::uno::Reference< css::io::XOutputStream > & rStream,
109  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
110 
112  css::uno::Reference< css::io::XInputStream >
113  GET( const std::vector< OUString > & rHeaderNames, // empty == 'all'
114  DAVResource & rResource,
115  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
116 
118  css::uno::Reference< css::io::XInputStream >
119  GET( DAVRequestHeaders & rRequestHeaders,
120  const std::vector< OUString > & rHeaderNames, // empty == 'all'
121  DAVResource & rResource,
122  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
123 
125  void
126  GET( css::uno::Reference< css::io::XOutputStream > & rStream,
127  const std::vector< OUString > & rHeaderNames, // empty == 'all'
128  DAVResource & rResource,
129  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
130 
132  void
133  PUT( const css::uno::Reference< css::io::XInputStream > & rStream,
134  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
135 
137  css::uno::Reference< css::io::XInputStream >
138  POST( const OUString & rContentType,
139  const OUString & rReferer,
140  const css::uno::Reference< css::io::XInputStream > & rInputStream,
141  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
142 
144  void
145  POST( const OUString & rContentType,
146  const OUString & rReferer,
147  const css::uno::Reference< css::io::XInputStream > & rInputStream,
148  css::uno::Reference< css::io::XOutputStream > & rOutputStream,
149  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
150 
152  void
153  MKCOL( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
154 
156  void
157  COPY( const OUString & rSourcePath,
158  const OUString & rDestinationURI,
159  bool bOverwrite,
160  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
161 
163  void
164  MOVE( const OUString & rSourcePath,
165  const OUString & rDestinationURI,
166  bool bOverwrite,
167  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
168 
170  void
171  DESTROY( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
172 
173  // set new lock.
175  void
176  LOCK( css::ucb::Lock & inLock,
177  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
178 
180  void
181  UNLOCK( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
182 
184  void
185  static abort();
186 
187  // helper
188  static void
190  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv,
191  const OUString & rURI,
192  css::ucb::WebDAVHTTPMethod eMethod,
193  DAVRequestHeaders & rRequestHeaders );
194 
195 private:
196  const OUString & getRequestURI() const;
198  bool detectRedirectCycle( const OUString& rRedirectURL );
200  bool handleException( DAVException & e, int errorCount );
202  void initialize();
203 };
204 
205 } // namespace http_dav_ucp
206 
207 /* 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)