Bump version to 24.04.3.4
[LibreOffice.git] / ucb / source / ucp / webdav-curl / DAVResourceAccess.hxx
blob5d5ea07bdd017e0f16737b462d2c1f81aa84dd39
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #pragma once
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"
40 namespace http_dav_ucp
43 class DAVSessionFactory;
45 class DAVResourceAccess
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;
51 rtl::Reference< DAVSession > m_xSession;
52 rtl::Reference< DAVSessionFactory > m_xSessionFactory;
53 css::uno::Reference< css::uno::XComponentContext > m_xContext;
54 std::vector<CurlUri> m_aRedirectURIs;
56 public:
57 DAVResourceAccess() = default;
58 DAVResourceAccess( css::uno::Reference< css::uno::XComponentContext > xContext,
59 rtl::Reference< DAVSessionFactory > xSessionFactory,
60 OUString aURL );
61 DAVResourceAccess( const DAVResourceAccess & rOther );
63 DAVResourceAccess & operator=( const DAVResourceAccess & rOther );
65 /// @throws DAVException
66 void setFlags( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rFlags );
68 /// @throws DAVException
69 void setURL( const OUString & rNewURL );
71 void resetUri();
73 const OUString & getURL() const { return m_aURL; }
75 const rtl::Reference< DAVSessionFactory > & getSessionFactory() const
76 { return m_xSessionFactory; }
78 // DAV methods
80 /// @throws DAVException
81 void
82 OPTIONS(
83 DAVOptions & rOptions,
84 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
86 // allprop & named
87 /// @throws DAVException
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 );
94 // propnames
95 /// @throws DAVException
96 void
97 PROPFIND( const Depth nDepth,
98 std::vector< DAVResourceInfo > & rResInfo,
99 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
101 /// @throws DAVException
102 void
103 PROPPATCH( const std::vector< ProppatchValue > & rValues,
104 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
106 /// @throws DAVException
107 void
108 HEAD( const std::vector< OUString > & rHeaderNames, // empty == 'all'
109 DAVResource & rResource,
110 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
112 /// @throws DAVException
113 css::uno::Reference< css::io::XInputStream >
114 GET( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
116 /// @throws DAVException
117 void
118 GET( css::uno::Reference< css::io::XOutputStream > & rStream,
119 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
121 /// @throws DAVException
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 );
127 /// used as HEAD substitute when HEAD is not implemented on server
128 /// @throws DAVException
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 );
135 /// @throws DAVException
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 );
142 /// @throws DAVException
143 void
144 PUT( const css::uno::Reference< css::io::XInputStream > & rStream,
145 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
147 /// @throws DAVException
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 );
154 /// @throws DAVException
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 );
162 /// @throws DAVException
163 void
164 MKCOL( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
166 /// @throws DAVException
167 void
168 COPY( const OUString & rSourcePath,
169 const OUString & rDestinationURI,
170 bool bOverwrite,
171 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
173 /// @throws DAVException
174 void
175 MOVE( const OUString & rSourcePath,
176 const OUString & rDestinationURI,
177 bool bOverwrite,
178 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
180 /// @throws DAVException
181 void
182 DESTROY( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
184 // set new lock.
185 /// @throws DAVException
186 void
187 LOCK( css::ucb::Lock & inLock,
188 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
190 /// @throws DAVException
191 void
192 UNLOCK( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
194 /// @throws DAVException
195 void
196 abort();
198 // helper
199 static void
200 getUserRequestHeaders(
201 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv,
202 const OUString & rURI,
203 css::ucb::WebDAVHTTPMethod eMethod,
204 DAVRequestHeaders & rRequestHeaders );
206 /// @throws DAVException
207 bool handleException(DAVException const& e, int errorCount);
209 private:
210 const OUString & getRequestURI() const;
211 /// @throws DAVException
212 bool detectRedirectCycle(::std::u16string_view rRedirectURL);
213 /// @throws DAVException
214 void initialize();
217 } // namespace http_dav_ucp
219 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */