Debian Codegraph @

ucb/source/ucp/webdav-curl/DAVResourceAccess.hxx

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