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
40namespace http_dav_ucp
41{
42
43class DAVSessionFactory;
44
46{
47 osl::Mutex m_aMutex;
48 OUString m_aURL;
49 OUString m_aPath;
53 css::uno::Reference< css::uno::XComponentContext > m_xContext;
54 std::vector<CurlUri> m_aRedirectURIs;
55
56public:
57 DAVResourceAccess() = default;
58 DAVResourceAccess( css::uno::Reference< css::uno::XComponentContext > xContext,
60 OUString aURL );
61 DAVResourceAccess( const DAVResourceAccess & rOther );
62
64
66 void setFlags( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rFlags );
67
69 void setURL( const OUString & rNewURL );
70
71 void resetUri();
72
73 const OUString & getURL() const { return m_aURL; }
74
76 { return m_xSessionFactory; }
77
78 // DAV methods
79
81 void
82 OPTIONS(
83 DAVOptions & rOptions,
84 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
85
86 // allprop & named
88 void
89 PROPFIND( const Depth nDepth,
90 const std::vector< OUString > & rPropertyNames,
91 std::vector< DAVResource > & rResources,
92 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
93
94 // propnames
96 void
97 PROPFIND( const Depth nDepth,
98 std::vector< DAVResourceInfo > & rResInfo,
99 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
100
102 void
103 PROPPATCH( const std::vector< ProppatchValue > & rValues,
104 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
105
107 void
108 HEAD( const std::vector< OUString > & rHeaderNames, // empty == 'all'
109 DAVResource & rResource,
110 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
111
113 css::uno::Reference< css::io::XInputStream >
114 GET( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
115
117 void
118 GET( css::uno::Reference< css::io::XOutputStream > & rStream,
119 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
120
122 css::uno::Reference< css::io::XInputStream >
123 GET( const std::vector< OUString > & rHeaderNames, // empty == 'all'
124 DAVResource & rResource,
125 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
126
129 void
130 GET0( DAVRequestHeaders & rRequestHeaders,
131 const std::vector< OUString > & rHeaderNames, // empty == 'all'
132 DAVResource & rResource,
133 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
134
136 void
137 GET( css::uno::Reference< css::io::XOutputStream > & rStream,
138 const std::vector< OUString > & rHeaderNames, // empty == 'all'
139 DAVResource & rResource,
140 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
141
143 void
144 PUT( const css::uno::Reference< css::io::XInputStream > & rStream,
145 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
146
148 css::uno::Reference< css::io::XInputStream >
149 POST( const OUString & rContentType,
150 const OUString & rReferer,
151 const css::uno::Reference< css::io::XInputStream > & rInputStream,
152 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
153
155 void
156 POST( const OUString & rContentType,
157 const OUString & rReferer,
158 const css::uno::Reference< css::io::XInputStream > & rInputStream,
159 css::uno::Reference< css::io::XOutputStream > & rOutputStream,
160 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
161
163 void
164 MKCOL( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
165
167 void
168 COPY( const OUString & rSourcePath,
169 const OUString & rDestinationURI,
170 bool bOverwrite,
171 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
172
174 void
175 MOVE( const OUString & rSourcePath,
176 const OUString & rDestinationURI,
177 bool bOverwrite,
178 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
179
181 void
182 DESTROY( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
183
184 // set new lock.
186 void
187 LOCK( css::ucb::Lock & inLock,
188 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
189
191 void
192 UNLOCK( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
193
195 void
196 abort();
197
198 // helper
199 static void
201 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv,
202 const OUString & rURI,
203 css::ucb::WebDAVHTTPMethod eMethod,
204 DAVRequestHeaders & rRequestHeaders );
205
207 bool handleException(DAVException const& e, int errorCount);
208
209private:
210 const OUString & getRequestURI() const;
212 bool detectRedirectCycle(::std::u16string_view rRedirectURL);
214 void initialize();
215};
216
217} // namespace http_dav_ucp
218
219/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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
css::uno::Reference< css::uno::XComponentContext > m_xContext
const OUString & getRequestURI() const
void setFlags(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > &rFlags)
void PUT(const css::uno::Reference< css::io::XInputStream > &rStream, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void PROPFIND(const Depth nDepth, const std::vector< OUString > &rPropertyNames, std::vector< DAVResource > &rResources, 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)
css::uno::Reference< css::io::XInputStream > GET(const std::vector< OUString > &rHeaderNames, DAVResource &rResource, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
DAVResourceAccess & operator=(const DAVResourceAccess &rOther)
bool detectRedirectCycle(::std::u16string_view rRedirectURL)
void MKCOL(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void HEAD(const std::vector< OUString > &rHeaderNames, DAVResource &rResource, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void DESTROY(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
std::vector< CurlUri > m_aRedirectURIs
bool handleException(DAVException const &e, int errorCount)
void MOVE(const OUString &rSourcePath, const OUString &rDestinationURI, bool bOverwrite, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void PROPPATCH(const std::vector< ProppatchValue > &rValues, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
DAVResourceAccess(css::uno::Reference< css::uno::XComponentContext > xContext, rtl::Reference< DAVSessionFactory > xSessionFactory, OUString aURL)
void GET(css::uno::Reference< css::io::XOutputStream > &rStream, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
rtl::Reference< DAVSession > m_xSession
::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > m_aFlags
void PROPFIND(const Depth nDepth, std::vector< DAVResourceInfo > &rResInfo, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void UNLOCK(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void setURL(const OUString &rNewURL)
void OPTIONS(DAVOptions &rOptions, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void LOCK(css::ucb::Lock &inLock, 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)
const rtl::Reference< DAVSessionFactory > & getSessionFactory() const
const OUString & getURL() const
static void getUserRequestHeaders(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, const OUString &rURI, css::ucb::WebDAVHTTPMethod eMethod, DAVRequestHeaders &rRequestHeaders)
void GET(css::uno::Reference< css::io::XOutputStream > &rStream, const std::vector< OUString > &rHeaderNames, DAVResource &rResource, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
css::uno::Reference< css::io::XInputStream > GET(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void POST(const OUString &rContentType, const OUString &rReferer, const css::uno::Reference< css::io::XInputStream > &rInputStream, css::uno::Reference< css::io::XOutputStream > &rOutputStream, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
rtl::Reference< DAVSessionFactory > m_xSessionFactory
std::vector< DAVRequestHeader > DAVRequestHeaders