File: | home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx |
Warning: | line 1595, column 9 Use of memory after it is freed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |||
2 | /************************************************************************* | |||
3 | * | |||
4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |||
5 | * | |||
6 | * Copyright 2000, 2010 Oracle and/or its affiliates. | |||
7 | * | |||
8 | * OpenOffice.org - a multi-platform office productivity suite | |||
9 | * | |||
10 | * This file is part of OpenOffice.org. | |||
11 | * | |||
12 | * OpenOffice.org is free software: you can redistribute it and/or modify | |||
13 | * it under the terms of the GNU Lesser General Public License version 3 | |||
14 | * only, as published by the Free Software Foundation. | |||
15 | * | |||
16 | * OpenOffice.org is distributed in the hope that it will be useful, | |||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
19 | * GNU Lesser General Public License version 3 for more details | |||
20 | * (a copy is included in the LICENSE file that accompanied this code). | |||
21 | * | |||
22 | * You should have received a copy of the GNU Lesser General Public License | |||
23 | * version 3 along with OpenOffice.org. If not, see | |||
24 | * <http://www.openoffice.org/license.html> | |||
25 | * for a copy of the LGPLv3 License. | |||
26 | * | |||
27 | ************************************************************************/ | |||
28 | ||||
29 | ||||
30 | #include <unordered_map> | |||
31 | #include <vector> | |||
32 | #include <string.h> | |||
33 | #include <sal/log.hxx> | |||
34 | #include <osl/diagnose.h> | |||
35 | #include <osl/thread.h> | |||
36 | #include <osl/time.h> | |||
37 | #include <ne_socket.h> | |||
38 | #include <ne_auth.h> | |||
39 | #include <ne_redirect.h> | |||
40 | #include <ne_ssl.h> | |||
41 | ||||
42 | // old neon versions forgot to set this | |||
43 | extern "C" { | |||
44 | #include <ne_compress.h> | |||
45 | } | |||
46 | ||||
47 | #include <libxml/parser.h> | |||
48 | #include <comphelper/sequence.hxx> | |||
49 | #include <ucbhelper/simplecertificatevalidationrequest.hxx> | |||
50 | ||||
51 | #include "DAVAuthListener.hxx" | |||
52 | #include "NeonTypes.hxx" | |||
53 | #include "NeonSession.hxx" | |||
54 | #include "NeonInputStream.hxx" | |||
55 | #include "NeonPropFindRequest.hxx" | |||
56 | #include "NeonHeadRequest.hxx" | |||
57 | #include "NeonUri.hxx" | |||
58 | #include "LinkSequence.hxx" | |||
59 | #include "UCBDeadPropertyValue.hxx" | |||
60 | ||||
61 | #include <officecfg/Inet.hxx> | |||
62 | #include <com/sun/star/io/BufferSizeExceededException.hpp> | |||
63 | #include <com/sun/star/io/IOException.hpp> | |||
64 | #include <com/sun/star/io/NotConnectedException.hpp> | |||
65 | #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp> | |||
66 | #include <com/sun/star/security/XCertificate.hpp> | |||
67 | #include <com/sun/star/security/CertificateValidity.hpp> | |||
68 | #include <com/sun/star/security/CertificateContainerStatus.hpp> | |||
69 | #include <com/sun/star/security/CertificateContainer.hpp> | |||
70 | #include <com/sun/star/security/XCertificateContainer.hpp> | |||
71 | #include <com/sun/star/ucb/Lock.hpp> | |||
72 | #include <com/sun/star/beans/NamedValue.hpp> | |||
73 | #include <com/sun/star/xml/crypto/SEInitializer.hpp> | |||
74 | ||||
75 | ||||
76 | using namespace com::sun::star; | |||
77 | using namespace webdav_ucp; | |||
78 | ||||
79 | #ifndef EOL"\r\n" | |||
80 | # define EOL"\r\n" "\r\n" | |||
81 | #endif | |||
82 | ||||
83 | namespace { | |||
84 | ||||
85 | struct RequestData | |||
86 | { | |||
87 | // POST | |||
88 | OUString aContentType; | |||
89 | OUString aReferer; | |||
90 | ||||
91 | RequestData() {} | |||
92 | RequestData( const OUString & rContentType, | |||
93 | const OUString & rReferer ) | |||
94 | : aContentType( rContentType ), aReferer( rReferer ) {} | |||
95 | }; | |||
96 | ||||
97 | struct equalPtr | |||
98 | { | |||
99 | bool operator()( const ne_request* p1, const ne_request* p2 ) const | |||
100 | { | |||
101 | return p1 == p2; | |||
102 | } | |||
103 | }; | |||
104 | ||||
105 | struct hashPtr | |||
106 | { | |||
107 | size_t operator()( const ne_request* p ) const | |||
108 | { | |||
109 | return reinterpret_cast<size_t>(p); | |||
110 | } | |||
111 | }; | |||
112 | ||||
113 | } | |||
114 | ||||
115 | typedef std::unordered_map | |||
116 | < | |||
117 | ne_request*, | |||
118 | RequestData, | |||
119 | hashPtr, | |||
120 | equalPtr | |||
121 | > | |||
122 | RequestDataMap; | |||
123 | ||||
124 | static sal_uInt16 makeStatusCode( const OUString & rStatusText ) | |||
125 | { | |||
126 | // Extract status code from session error string. Unfortunately | |||
127 | // neon provides no direct access to the status code... | |||
128 | ||||
129 | if ( rStatusText.getLength() < 3 ) | |||
130 | { | |||
131 | SAL_WARN( "ucb.ucp.webdav", "makeStatusCode - status text string to short!" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "makeStatusCode - status text string to short!" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "131" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "makeStatusCode - status text string to short!" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "makeStatusCode - status text string to short!"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "131" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "makeStatusCode - status text string to short!") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "131" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "makeStatusCode - status text string to short!" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "makeStatusCode - status text string to short!"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "131" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
132 | return 0; | |||
133 | } | |||
134 | ||||
135 | sal_Int32 nPos = rStatusText.indexOf( ' ' ); | |||
136 | if ( nPos == -1 ) | |||
137 | { | |||
138 | SAL_WARN( "ucb.ucp.webdav", "makeStatusCode - wrong status text format!" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "makeStatusCode - wrong status text format!" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "138" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "makeStatusCode - wrong status text format!" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "makeStatusCode - wrong status text format!"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "138" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "makeStatusCode - wrong status text format!") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "138" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "makeStatusCode - wrong status text format!" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "makeStatusCode - wrong status text format!"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "138" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
139 | return 0; | |||
140 | } | |||
141 | ||||
142 | return sal_uInt16( rStatusText.copy( 0, nPos ).toInt32() ); | |||
143 | } | |||
144 | ||||
145 | static bool noKeepAlive( const uno::Sequence< beans::NamedValue >& rFlags ) | |||
146 | { | |||
147 | if ( !rFlags.hasElements() ) | |||
148 | return false; | |||
149 | ||||
150 | // find "KeepAlive" property | |||
151 | const beans::NamedValue* pValue( | |||
152 | std::find_if(rFlags.begin(), rFlags.end(), | |||
153 | [] (beans::NamedValue const& rNV) { return rNV.Name == "KeepAlive"; } )); | |||
154 | return pValue != rFlags.end() && !pValue->Value.get<bool>(); | |||
155 | } | |||
156 | ||||
157 | namespace { | |||
158 | ||||
159 | struct NeonRequestContext | |||
160 | { | |||
161 | uno::Reference< io::XOutputStream > xOutputStream; | |||
162 | rtl::Reference< NeonInputStream > xInputStream; | |||
163 | const std::vector< OUString > * pHeaderNames; | |||
164 | DAVResource * pResource; | |||
165 | ||||
166 | explicit NeonRequestContext( uno::Reference< io::XOutputStream > const & xOutStrm ) | |||
167 | : xOutputStream( xOutStrm ), | |||
168 | pHeaderNames( nullptr ), pResource( nullptr ) {} | |||
169 | ||||
170 | explicit NeonRequestContext( const rtl::Reference< NeonInputStream > & xInStrm ) | |||
171 | : xInputStream( xInStrm ), | |||
172 | pHeaderNames( nullptr ), pResource( nullptr ) {} | |||
173 | ||||
174 | NeonRequestContext( uno::Reference< io::XOutputStream > const & xOutStrm, | |||
175 | const std::vector< OUString > & inHeaderNames, | |||
176 | DAVResource & ioResource ) | |||
177 | : xOutputStream( xOutStrm ), | |||
178 | pHeaderNames( &inHeaderNames ), pResource( &ioResource ) {} | |||
179 | ||||
180 | NeonRequestContext( const rtl::Reference< NeonInputStream > & xInStrm, | |||
181 | const std::vector< OUString > & inHeaderNames, | |||
182 | DAVResource & ioResource ) | |||
183 | : xInputStream( xInStrm ), | |||
184 | pHeaderNames( &inHeaderNames ), pResource( &ioResource ) {} | |||
185 | ||||
186 | void ResponseBlockReader(const char * inBuf, size_t inLen) | |||
187 | { | |||
188 | if (xInputStream.is()) | |||
189 | xInputStream->AddToStream( inBuf, inLen ); | |||
190 | } | |||
191 | ||||
192 | void ResponseBlockWriter(const char * inBuf, size_t inLen) | |||
193 | { | |||
194 | if (xOutputStream.is()) | |||
195 | { | |||
196 | const uno::Sequence< sal_Int8 > aSeq( reinterpret_cast<sal_Int8 const *>(inBuf), inLen ); | |||
197 | xOutputStream->writeBytes( aSeq ); | |||
198 | } | |||
199 | } | |||
200 | ||||
201 | }; | |||
202 | ||||
203 | } | |||
204 | ||||
205 | // A simple Neon response_block_reader for use with an XInputStream | |||
206 | extern "C" { | |||
207 | ||||
208 | static int NeonSession_ResponseBlockReader(void * inUserData, | |||
209 | const char * inBuf, | |||
210 | size_t inLen ) | |||
211 | { | |||
212 | // neon sometimes calls this function with (inLen == 0)... | |||
213 | if ( inLen > 0 ) | |||
214 | { | |||
215 | NeonRequestContext * pCtx = static_cast<NeonRequestContext*>(inUserData); | |||
216 | pCtx->ResponseBlockReader(inBuf, inLen); | |||
217 | } | |||
218 | return 0; | |||
219 | } | |||
220 | ||||
221 | // A simple Neon response_block_reader for use with an XOutputStream | |||
222 | static int NeonSession_ResponseBlockWriter( void * inUserData, | |||
223 | const char * inBuf, | |||
224 | size_t inLen ) | |||
225 | { | |||
226 | // neon calls this function with (inLen == 0)... | |||
227 | if ( inLen > 0 ) | |||
228 | { | |||
229 | NeonRequestContext * pCtx = static_cast<NeonRequestContext*>(inUserData); | |||
230 | pCtx->ResponseBlockWriter(inBuf, inLen); | |||
231 | } | |||
232 | return 0; | |||
233 | } | |||
234 | ||||
235 | static int NeonSession_NeonAuth( void * inUserData, | |||
236 | #if defined NE_FEATURE_SSPI(8) && ! defined SYSTEM_NEON | |||
237 | const char * inAuthProtocol, | |||
238 | #endif | |||
239 | const char * inRealm, | |||
240 | int attempt, | |||
241 | char * inoutUserName, | |||
242 | char * inoutPassWord ) | |||
243 | { | |||
244 | /* The callback used to request the username and password in the given | |||
245 | * realm. The username and password must be copied into the buffers | |||
246 | * which are both of size NE_ABUFSIZ. The 'attempt' parameter is zero | |||
247 | * on the first call to the callback, and increases by one each time | |||
248 | * an attempt to authenticate fails. | |||
249 | * | |||
250 | * The callback must return zero to indicate that authentication | |||
251 | * should be attempted with the username/password, or non-zero to | |||
252 | * cancel the request. (if non-zero, username and password are | |||
253 | * ignored.) */ | |||
254 | ||||
255 | NeonSession * theSession = static_cast<NeonSession*>(inUserData); | |||
256 | const char * pAuthProtocol; | |||
257 | #if defined NE_FEATURE_SSPI(8) && ! defined SYSTEM_NEON | |||
258 | pAuthProtocol = inAuthProtocol; | |||
259 | #else | |||
260 | pAuthProtocol = nullptr; | |||
261 | #endif | |||
262 | return theSession->NeonAuth(pAuthProtocol, inRealm, attempt, inoutUserName, inoutPassWord); | |||
263 | } | |||
264 | ||||
265 | } | |||
266 | ||||
267 | int NeonSession::NeonAuth(const char* inAuthProtocol, const char* inRealm, | |||
268 | int attempt, char* inoutUserName, char * inoutPassWord) | |||
269 | { | |||
270 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
271 | ||||
272 | /* The callback used to request the username and password in the given | |||
273 | * realm. The username and password must be copied into the buffers | |||
274 | * which are both of size NE_ABUFSIZ. The 'attempt' parameter is zero | |||
275 | * on the first call to the callback, and increases by one each time | |||
276 | * an attempt to authenticate fails. | |||
277 | * | |||
278 | * The callback must return zero to indicate that authentication | |||
279 | * should be attempted with the username/password, or non-zero to | |||
280 | * cancel the request. (if non-zero, username and password are | |||
281 | * ignored.) */ | |||
282 | ||||
283 | DAVAuthListener * pListener | |||
284 | = getRequestEnvironment().m_xAuthListener.get(); | |||
285 | if ( !pListener ) | |||
286 | { | |||
287 | // abort | |||
288 | return -1; | |||
289 | } | |||
290 | OUString theUserName; | |||
291 | OUString thePassWord; | |||
292 | ||||
293 | if ( attempt == 0 ) | |||
294 | { | |||
295 | // neon does not handle username supplied with request URI (for | |||
296 | // instance when doing FTP over proxy - last checked: 0.23.5 ) | |||
297 | ||||
298 | try | |||
299 | { | |||
300 | NeonUri uri( getRequestEnvironment().m_aRequestURI ); | |||
301 | const OUString& aUserInfo( uri.GetUserInfo() ); | |||
302 | if ( !aUserInfo.isEmpty() ) | |||
303 | { | |||
304 | sal_Int32 nPos = aUserInfo.indexOf( '@' ); | |||
305 | if ( nPos == -1 ) | |||
306 | { | |||
307 | theUserName = aUserInfo; | |||
308 | } | |||
309 | else | |||
310 | { | |||
311 | theUserName = aUserInfo.copy( 0, nPos ); | |||
312 | thePassWord = aUserInfo.copy( nPos + 1 ); | |||
313 | } | |||
314 | } | |||
315 | } | |||
316 | catch ( DAVException const & ) | |||
317 | { | |||
318 | // abort | |||
319 | return -1; | |||
320 | } | |||
321 | } | |||
322 | else | |||
323 | { | |||
324 | // username buffer is prefilled with user name from last attempt. | |||
325 | theUserName = OUString::createFromAscii( inoutUserName ); | |||
326 | // @@@ Neon does not initialize password buffer (last checked: 0.22.0). | |||
327 | //thePassWord = OUString::createFromAscii( inoutPassWord ); | |||
328 | } | |||
329 | ||||
330 | #if defined NE_FEATURE_SSPI(8) && ! defined SYSTEM_NEON | |||
331 | const bool bCanUseSystemCreds | |||
332 | = (attempt == 0) && // avoid endless loops | |||
333 | ne_has_support( NE_FEATURE_SSPI(8) ) && // Windows-only feature. | |||
334 | ( ( ne_strcasecmp( inAuthProtocol, "NTLM" ) == 0 ) || | |||
335 | ( ne_strcasecmp( inAuthProtocol, "Negotiate" ) == 0 ) ); | |||
336 | #else | |||
337 | (void)inAuthProtocol; | |||
338 | const bool bCanUseSystemCreds = false; | |||
339 | #endif | |||
340 | ||||
341 | int theRetVal = pListener->authenticate( | |||
342 | OUString::createFromAscii( inRealm ), | |||
343 | getHostName(), | |||
344 | theUserName, | |||
345 | thePassWord, | |||
346 | bCanUseSystemCreds); | |||
347 | ||||
348 | OString aUser( OUStringToOString( theUserName, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ) ); | |||
349 | if ( aUser.getLength() > ( NE_ABUFSIZ(256) - 1 ) ) | |||
350 | { | |||
351 | SAL_WARN( "ucb.ucp.webdav", "NeonSession_NeonAuth - username too long!" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "NeonSession_NeonAuth - username too long!" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "351" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "NeonSession_NeonAuth - username too long!" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "NeonSession_NeonAuth - username too long!"; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "351" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "NeonSession_NeonAuth - username too long!") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "351" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "NeonSession_NeonAuth - username too long!" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "NeonSession_NeonAuth - username too long!"; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "351" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
352 | return -1; | |||
353 | } | |||
354 | ||||
355 | OString aPass( OUStringToOString( thePassWord, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ) ); | |||
356 | if ( aPass.getLength() > ( NE_ABUFSIZ(256) - 1 ) ) | |||
357 | { | |||
358 | SAL_WARN( "ucb.ucp.webdav", "NeonSession_NeonAuth - password too long!" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "NeonSession_NeonAuth - password too long!" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "358" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "NeonSession_NeonAuth - password too long!" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "NeonSession_NeonAuth - password too long!"; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "358" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "NeonSession_NeonAuth - password too long!") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "358" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "NeonSession_NeonAuth - password too long!" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "NeonSession_NeonAuth - password too long!"; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "358" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
359 | return -1; | |||
360 | } | |||
361 | ||||
362 | // #100211# - checked | |||
363 | strcpy( inoutUserName, aUser.getStr() ); | |||
364 | strcpy( inoutPassWord, aPass.getStr() ); | |||
365 | ||||
366 | return theRetVal; | |||
367 | } | |||
368 | ||||
369 | namespace { | |||
370 | OUString GetHostnamePart( const OUString& _rRawString ) | |||
371 | { | |||
372 | OUString sPart; | |||
373 | OUString sPartId("CN="); | |||
374 | sal_Int32 nContStart = _rRawString.indexOf( sPartId ); | |||
375 | if ( nContStart != -1 ) | |||
376 | { | |||
377 | nContStart += sPartId.getLength(); | |||
378 | sal_Int32 nContEnd = _rRawString.indexOf( ',', nContStart ); | |||
379 | sPart = nContEnd != -1 ? | |||
380 | _rRawString.copy(nContStart, nContEnd - nContStart) : | |||
381 | _rRawString.copy(nContStart); | |||
382 | } | |||
383 | return sPart; | |||
384 | } | |||
385 | } // namespace | |||
386 | ||||
387 | extern "C" { | |||
388 | ||||
389 | static int NeonSession_CertificationNotify( void *userdata, | |||
390 | int, | |||
391 | const ne_ssl_certificate *cert ) | |||
392 | { | |||
393 | NeonSession * pSession = static_cast< NeonSession * >( userdata ); | |||
394 | return pSession->CertificationNotify(cert); | |||
395 | } | |||
396 | ||||
397 | } | |||
398 | ||||
399 | int NeonSession::CertificationNotify(const ne_ssl_certificate *cert) | |||
400 | { | |||
401 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
402 | ||||
403 | OSL_ASSERT( cert )do { if (true && (!(cert))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "403" ": "), "OSL_ASSERT: %s", "cert"); } } while (false ); | |||
404 | ||||
405 | uno::Reference< security::XCertificateContainer > xCertificateContainer; | |||
406 | try | |||
407 | { | |||
408 | xCertificateContainer = security::CertificateContainer::create( getComponentContext() ); | |||
409 | } | |||
410 | catch ( uno::Exception const & ) | |||
411 | { | |||
412 | } | |||
413 | ||||
414 | if ( !xCertificateContainer.is() ) | |||
415 | return 1; | |||
416 | ||||
417 | char * dn = ne_ssl_readable_dname( ne_ssl_cert_subject( cert ) ); | |||
418 | OUString cert_subject( dn, strlen( dn ), RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)), 0 ); | |||
419 | ||||
420 | ne_freefree( dn ); | |||
421 | ||||
422 | security::CertificateContainerStatus certificateContainer( | |||
423 | xCertificateContainer->hasCertificate( | |||
424 | getHostName(), cert_subject ) ); | |||
425 | ||||
426 | if ( certificateContainer != security::CertificateContainerStatus_NOCERT ) | |||
427 | return | |||
428 | certificateContainer == security::CertificateContainerStatus_TRUSTED | |||
429 | ? 0 | |||
430 | : 1; | |||
431 | ||||
432 | uno::Reference< xml::crypto::XSEInitializer > xSEInitializer; | |||
433 | try | |||
434 | { | |||
435 | xSEInitializer = xml::crypto::SEInitializer::create( getComponentContext() ); | |||
436 | } | |||
437 | catch ( uno::Exception const & ) | |||
438 | { | |||
439 | } | |||
440 | ||||
441 | if ( !xSEInitializer.is() ) | |||
442 | return 1; | |||
443 | ||||
444 | uno::Reference< xml::crypto::XXMLSecurityContext > xSecurityContext( | |||
445 | xSEInitializer->createSecurityContext( OUString() ) ); | |||
446 | ||||
447 | uno::Reference< xml::crypto::XSecurityEnvironment > xSecurityEnv( | |||
448 | xSecurityContext->getSecurityEnvironment() ); | |||
449 | ||||
450 | //The end entity certificate | |||
451 | char * eeCertB64 = ne_ssl_cert_export( cert ); | |||
452 | ||||
453 | OString sEECertB64( eeCertB64 ); | |||
454 | ||||
455 | uno::Reference< security::XCertificate > xEECert( | |||
456 | xSecurityEnv->createCertificateFromAscii( | |||
457 | OStringToOUString( sEECertB64, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) ) ) ); | |||
458 | ||||
459 | ne_freefree( eeCertB64 ); | |||
460 | eeCertB64 = nullptr; | |||
461 | ||||
462 | std::vector< uno::Reference< security::XCertificate > > vecCerts; | |||
463 | const ne_ssl_certificate * issuerCert = cert; | |||
464 | do | |||
465 | { | |||
466 | //get the intermediate certificate | |||
467 | //the returned value is const ! Therefore it does not need to be freed | |||
468 | //with ne_ssl_cert_free, which takes a non-const argument | |||
469 | issuerCert = ne_ssl_cert_signedby( issuerCert ); | |||
470 | if ( nullptr == issuerCert ) | |||
471 | break; | |||
472 | ||||
473 | char * imCertB64 = ne_ssl_cert_export( issuerCert ); | |||
474 | OString sInterMediateCertB64( imCertB64 ); | |||
475 | ne_freefree( imCertB64 ); | |||
476 | ||||
477 | uno::Reference< security::XCertificate> xImCert( | |||
478 | xSecurityEnv->createCertificateFromAscii( | |||
479 | OStringToOUString( sInterMediateCertB64, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) ) ) ); | |||
480 | if ( xImCert.is() ) | |||
481 | vecCerts.push_back( xImCert ); | |||
482 | } | |||
483 | while ( true ); | |||
484 | ||||
485 | sal_Int64 certValidity = xSecurityEnv->verifyCertificate( xEECert, | |||
486 | ::comphelper::containerToSequence( vecCerts ) ); | |||
487 | ||||
488 | if ( isDomainMatch( | |||
489 | GetHostnamePart( xEECert->getSubjectName() ) ) ) | |||
490 | { | |||
491 | // if host name matched with certificate then look if the | |||
492 | // certificate was ok | |||
493 | if( certValidity == security::CertificateValidity::VALID ) | |||
494 | return 0; | |||
495 | } | |||
496 | ||||
497 | const uno::Reference< ucb::XCommandEnvironment > xEnv( | |||
498 | getRequestEnvironment().m_xEnv ); | |||
499 | if ( xEnv.is() ) | |||
500 | { | |||
501 | uno::Reference< task::XInteractionHandler > xIH( | |||
502 | xEnv->getInteractionHandler() ); | |||
503 | if ( xIH.is() ) | |||
504 | { | |||
505 | rtl::Reference< ucbhelper::SimpleCertificateValidationRequest > | |||
506 | xRequest( new ucbhelper::SimpleCertificateValidationRequest( | |||
507 | static_cast<sal_Int32>(certValidity), xEECert, getHostName() ) ); | |||
508 | xIH->handle( xRequest.get() ); | |||
509 | ||||
510 | rtl::Reference< ucbhelper::InteractionContinuation > xSelection | |||
511 | = xRequest->getSelection(); | |||
512 | ||||
513 | if ( xSelection.is() ) | |||
514 | { | |||
515 | uno::Reference< task::XInteractionApprove > xApprove( | |||
516 | xSelection.get(), uno::UNO_QUERY ); | |||
517 | if ( xApprove.is() ) | |||
518 | { | |||
519 | xCertificateContainer->addCertificate( | |||
520 | getHostName(), cert_subject, true ); | |||
521 | return 0; | |||
522 | } | |||
523 | else | |||
524 | { | |||
525 | // Don't trust cert | |||
526 | xCertificateContainer->addCertificate( | |||
527 | getHostName(), cert_subject, false ); | |||
528 | return 1; | |||
529 | } | |||
530 | } | |||
531 | } | |||
532 | else | |||
533 | { | |||
534 | // Don't trust cert | |||
535 | xCertificateContainer->addCertificate( | |||
536 | getHostName(), cert_subject, false ); | |||
537 | return 1; | |||
538 | } | |||
539 | } | |||
540 | return 1; | |||
541 | } | |||
542 | ||||
543 | extern "C" { | |||
544 | ||||
545 | static void NeonSession_PreSendRequest( ne_request * req, | |||
546 | void * userdata, | |||
547 | ne_buffer * headers ) | |||
548 | { | |||
549 | // userdata -> value returned by 'create' | |||
550 | NeonSession * pSession = static_cast< NeonSession * >( userdata ); | |||
551 | if (!pSession) | |||
552 | return; | |||
553 | pSession->PreSendRequest(req, headers); | |||
554 | } | |||
555 | ||||
556 | } | |||
557 | ||||
558 | void NeonSession::PreSendRequest(ne_request* req, ne_buffer* headers) | |||
559 | { | |||
560 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
561 | ||||
562 | // If there is a proxy server in between, it shall never use | |||
563 | // cached data. We always want 'up-to-date' data. | |||
564 | ne_buffer_concat( headers, "Pragma: no-cache", EOL"\r\n", nullptr ); | |||
565 | // alternative, but understood by HTTP 1.1 servers only: | |||
566 | // ne_buffer_concat( headers, "Cache-Control: max-age=0", EOL, NULL ); | |||
567 | ||||
568 | const RequestDataMap * pRequestData | |||
569 | = static_cast< const RequestDataMap* >( | |||
570 | getRequestData() ); | |||
571 | ||||
572 | RequestDataMap::const_iterator it = pRequestData->find( req ); | |||
573 | if ( it != pRequestData->end() ) | |||
574 | { | |||
575 | if ( !(*it).second.aContentType.isEmpty() ) | |||
576 | { | |||
577 | char * pData = headers->data; | |||
578 | if ( strstr( pData, "Content-Type:" ) == nullptr ) | |||
579 | { | |||
580 | OString aType | |||
581 | = OUStringToOString( (*it).second.aContentType, | |||
582 | RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ); | |||
583 | ne_buffer_concat( headers, "Content-Type: ", | |||
584 | aType.getStr(), EOL"\r\n", nullptr ); | |||
585 | } | |||
586 | } | |||
587 | ||||
588 | if ( !(*it).second.aReferer.isEmpty() ) | |||
589 | { | |||
590 | char * pData = headers->data; | |||
591 | if ( strstr( pData, "Referer:" ) == nullptr ) | |||
592 | { | |||
593 | OString aReferer | |||
594 | = OUStringToOString( (*it).second.aReferer, | |||
595 | RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ); | |||
596 | ne_buffer_concat( headers, "Referer: ", | |||
597 | aReferer.getStr(), EOL"\r\n", nullptr ); | |||
598 | } | |||
599 | } | |||
600 | } | |||
601 | ||||
602 | const DAVRequestHeaders & rHeaders | |||
603 | = getRequestEnvironment().m_aRequestHeaders; | |||
604 | ||||
605 | for ( const auto& rHeader : rHeaders ) | |||
606 | { | |||
607 | OString aHeader | |||
608 | = OUStringToOString( rHeader.first, | |||
609 | RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ); | |||
610 | OString aValue | |||
611 | = OUStringToOString( rHeader.second, | |||
612 | RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ); | |||
613 | ne_buffer_concat( headers, aHeader.getStr(), ": ", | |||
614 | aValue.getStr(), EOL"\r\n", nullptr ); | |||
615 | } | |||
616 | } | |||
617 | ||||
618 | //See https://bugzilla.redhat.com/show_bug.cgi?id=544619#c4 | |||
619 | //neon is threadsafe, but uses gnutls which is only thread-safe | |||
620 | //if initialized to be thread-safe. cups, unfortunately, generally | |||
621 | //initializes it first, and as non-thread-safe, leaving the entire | |||
622 | //stack unsafe | |||
623 | namespace webdav_ucp | |||
624 | { | |||
625 | osl::Mutex& getGlobalNeonMutex() | |||
626 | { | |||
627 | static osl::Mutex aMutex; | |||
628 | return aMutex; | |||
629 | } | |||
630 | } | |||
631 | ||||
632 | // static members | |||
633 | bool NeonSession::m_bGlobalsInited = false; | |||
634 | NeonLockStore NeonSession::m_aNeonLockStore; | |||
635 | ||||
636 | NeonSession::NeonSession( const rtl::Reference< DAVSessionFactory > & rSessionFactory, | |||
637 | const OUString& inUri, | |||
638 | const uno::Sequence< beans::NamedValue >& rFlags, | |||
639 | const ucbhelper::InternetProxyDecider & rProxyDecider ) | |||
640 | : DAVSession( rSessionFactory ) | |||
641 | , m_nProxyPort( 0 ) | |||
642 | , m_aFlags( rFlags ) | |||
643 | , m_pHttpSession( nullptr ) | |||
644 | , m_pRequestData( new RequestDataMap ) | |||
645 | , m_rProxyDecider( rProxyDecider ) | |||
646 | { | |||
647 | NeonUri theUri( inUri ); | |||
648 | m_aScheme = theUri.GetScheme(); | |||
649 | m_aHostName = theUri.GetHost(); | |||
650 | m_nPort = theUri.GetPort(); | |||
651 | SAL_INFO( "ucb.ucp.webdav", "NeonSession ctor - URL <" << inUri << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "NeonSession ctor - URL <" << inUri << ">") == 1) { ::sal_detail_log( (:: SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "651" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "NeonSession ctor - URL <" << inUri << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "NeonSession ctor - URL <" << inUri << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "651" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "NeonSession ctor - URL <" << inUri << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "651" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "NeonSession ctor - URL <" << inUri << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "NeonSession ctor - URL <" << inUri << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "651" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
652 | } | |||
653 | ||||
654 | NeonSession::~NeonSession( ) | |||
655 | { | |||
656 | if ( m_pHttpSession ) | |||
657 | { | |||
658 | { | |||
659 | osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); | |||
660 | ne_session_destroy( m_pHttpSession ); | |||
661 | } | |||
662 | m_pHttpSession = nullptr; | |||
663 | } | |||
664 | delete static_cast< RequestDataMap * >( m_pRequestData ); | |||
665 | } | |||
666 | ||||
667 | void NeonSession::Init( const DAVRequestEnvironment & rEnv ) | |||
668 | { | |||
669 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
670 | m_aEnv = rEnv; | |||
671 | Init(); | |||
672 | } | |||
673 | ||||
674 | void NeonSession::Init() | |||
675 | { | |||
676 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
677 | ||||
678 | bool bCreateNewSession = m_bNeedNewSession; | |||
679 | m_bNeedNewSession = false; | |||
680 | ||||
681 | if ( m_pHttpSession == nullptr ) | |||
682 | { | |||
683 | // Ensure that Neon sockets are initialized | |||
684 | osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); | |||
685 | if (!m_bGlobalsInited ) | |||
686 | { | |||
687 | if ( ne_sock_init() != 0 ) | |||
688 | throw DAVException( DAVException::DAV_SESSION_CREATE, | |||
689 | NeonUri::makeConnectionEndPointString( | |||
690 | m_aHostName, m_nPort ) ); | |||
691 | ||||
692 | // #122205# - libxml2 needs to be initialized once if used by | |||
693 | // multithreaded programs like OOo. | |||
694 | xmlInitParser(); | |||
695 | #if OSL_DEBUG_LEVEL1 > 0 | |||
696 | // for more debug flags see ne_utils.h; NE_DEBUGGING must be defined | |||
697 | // while compiling neon in order to actually activate neon debug | |||
698 | // output. | |||
699 | ne_debug_init( stderrstderr, NE_DBG_FLUSH(1<<30) | |||
700 | | NE_DBG_HTTP(1<<1) | |||
701 | // | NE_DBG_HTTPBODY | |||
702 | // | NE_DBG_HTTPAUTH | |||
703 | // | NE_DBG_XML | |||
704 | // | NE_DBG_XMLPARSE | |||
705 | | NE_DBG_LOCKS(1<<5) | |||
706 | | NE_DBG_SSL(1<<8) | |||
707 | ); | |||
708 | #endif | |||
709 | m_bGlobalsInited = true; | |||
710 | } | |||
711 | ||||
712 | const ucbhelper::InternetProxyServer & rProxyCfg = getProxySettings(); | |||
713 | ||||
714 | m_aProxyName = rProxyCfg.aName; | |||
715 | m_nProxyPort = rProxyCfg.nPort; | |||
716 | ||||
717 | // Not yet initialized. Create new session. | |||
718 | bCreateNewSession = true; | |||
719 | } | |||
720 | else | |||
721 | { | |||
722 | // #112271# Check whether proxy settings are still valid (They may | |||
723 | // change at any time). If not, create new Neon session. | |||
724 | ||||
725 | const ucbhelper::InternetProxyServer & rProxyCfg = getProxySettings(); | |||
726 | ||||
727 | if ( ( rProxyCfg.aName != m_aProxyName ) | |||
728 | || ( rProxyCfg.nPort != m_nProxyPort ) ) | |||
729 | { | |||
730 | m_aProxyName = rProxyCfg.aName; | |||
731 | m_nProxyPort = rProxyCfg.nPort; | |||
732 | ||||
733 | bCreateNewSession = true; | |||
734 | } | |||
735 | ||||
736 | if (bCreateNewSession) | |||
737 | { | |||
738 | // new session needed, destroy old first | |||
739 | { | |||
740 | osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); | |||
741 | ne_session_destroy( m_pHttpSession ); | |||
742 | } | |||
743 | m_pHttpSession = nullptr; | |||
744 | } | |||
745 | } | |||
746 | ||||
747 | if ( !bCreateNewSession ) | |||
748 | return; | |||
749 | ||||
750 | const sal_Int32 nConnectTimeoutMax = 180; | |||
751 | const sal_Int32 nConnectTimeoutMin = 2; | |||
752 | const sal_Int32 nReadTimeoutMax = 180; | |||
753 | const sal_Int32 nReadTimeoutMin = 20; | |||
754 | ||||
755 | // @@@ For FTP over HTTP proxy inUserInfo is needed to be able to | |||
756 | // build the complete request URI (including user:pass), but | |||
757 | // currently (0.22.0) neon does not allow to pass the user info | |||
758 | // to the session | |||
759 | ||||
760 | { | |||
761 | osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); | |||
762 | m_pHttpSession = ne_session_create( | |||
763 | OUStringToOString( m_aScheme, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
764 | /* theUri.GetUserInfo(), | |||
765 | @@@ for FTP via HTTP proxy, but not supported by Neon */ | |||
766 | OUStringToOString( m_aHostName, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
767 | m_nPort ); | |||
768 | } | |||
769 | ||||
770 | if ( m_pHttpSession == nullptr ) | |||
771 | throw DAVException( DAVException::DAV_SESSION_CREATE, | |||
772 | NeonUri::makeConnectionEndPointString( | |||
773 | m_aHostName, m_nPort ) ); | |||
774 | ||||
775 | // Register the session with the lock store | |||
776 | m_aNeonLockStore.registerSession( m_pHttpSession ); | |||
777 | ||||
778 | if ( m_aScheme.equalsIgnoreAsciiCase("https") ) | |||
779 | { | |||
780 | // Set a failure callback for certificate check | |||
781 | ne_ssl_set_verify( | |||
782 | m_pHttpSession, NeonSession_CertificationNotify, this); | |||
783 | ||||
784 | // Tell Neon to tell the SSL library used (OpenSSL or | |||
785 | // GnuTLS, I guess) to use a default set of root | |||
786 | // certificates. | |||
787 | ne_ssl_trust_default_ca(m_pHttpSession); | |||
788 | } | |||
789 | ||||
790 | // Add hooks (i.e. for adding additional headers to the request) | |||
791 | ne_hook_pre_send( m_pHttpSession, NeonSession_PreSendRequest, this ); | |||
792 | ||||
793 | if ( !m_aProxyName.isEmpty() ) | |||
794 | { | |||
795 | ne_session_proxy( m_pHttpSession, | |||
796 | OUStringToOString( | |||
797 | m_aProxyName, | |||
798 | RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
799 | m_nProxyPort ); | |||
800 | } | |||
801 | ||||
802 | // avoid KeepAlive? | |||
803 | if ( noKeepAlive(m_aFlags) ) | |||
804 | ne_set_session_flag( m_pHttpSession, NE_SESSFLAG_PERSIST, 0 ); | |||
805 | ||||
806 | // Register for redirects. | |||
807 | ne_redirect_register( m_pHttpSession ); | |||
808 | ||||
809 | // authentication callbacks. | |||
810 | ne_add_server_auth( m_pHttpSession, NE_AUTH_ALL(0x2000), NeonSession_NeonAuth, this ); | |||
811 | ne_add_proxy_auth ( m_pHttpSession, NE_AUTH_ALL(0x2000), NeonSession_NeonAuth, this ); | |||
812 | ||||
813 | // set timeout to connect | |||
814 | // if connect_timeout is not set, neon returns NE_CONNECT when the TCP socket default | |||
815 | // timeout elapses | |||
816 | // with connect_timeout set neon returns NE_TIMEOUT if elapsed when the connection | |||
817 | // didn't succeed | |||
818 | // grab it from configuration | |||
819 | uno::Reference< uno::XComponentContext > rContext = m_xFactory->getComponentContext(); | |||
820 | ||||
821 | // set the timeout (in seconds) used when making a connection | |||
822 | sal_Int32 nConnectTimeout = officecfg::Inet::Settings::ConnectTimeout::get( rContext ); | |||
823 | ne_set_connect_timeout( m_pHttpSession, | |||
824 | std::max( nConnectTimeoutMin, | |||
825 | std::min( nConnectTimeout, nConnectTimeoutMax ) ) ); | |||
826 | ||||
827 | // provides a read time out facility as well | |||
828 | // set the timeout (in seconds) used when reading from a socket. | |||
829 | sal_Int32 nReadTimeout = officecfg::Inet::Settings::ReadTimeout::get( rContext ); | |||
830 | ne_set_read_timeout( m_pHttpSession, | |||
831 | std::max( nReadTimeoutMin, | |||
832 | std::min( nReadTimeout, nReadTimeoutMax ) ) ); | |||
833 | ||||
834 | ne_set_session_flag(m_pHttpSession, NE_SESSFLAG_SHAREPOINT, 1); | |||
835 | } | |||
836 | ||||
837 | bool NeonSession::CanUse( const OUString & inUri, | |||
838 | const uno::Sequence< beans::NamedValue >& rFlags ) | |||
839 | { | |||
840 | try | |||
841 | { | |||
842 | NeonUri theUri( inUri ); | |||
843 | if ( ( theUri.GetPort() == m_nPort ) && | |||
844 | ( theUri.GetHost() == m_aHostName ) && | |||
845 | ( theUri.GetScheme() == m_aScheme ) && | |||
846 | ( rFlags == m_aFlags ) ) | |||
847 | return true; | |||
848 | } | |||
849 | catch ( DAVException const & ) | |||
850 | { | |||
851 | return false; | |||
852 | } | |||
853 | return false; | |||
854 | } | |||
855 | ||||
856 | bool NeonSession::UsesProxy() | |||
857 | { | |||
858 | Init(); | |||
859 | return !m_aProxyName.isEmpty() ; | |||
860 | } | |||
861 | ||||
862 | void NeonSession::OPTIONS( const OUString & inPath, | |||
863 | DAVOptions & rOptions, // contains the name+values of every header | |||
864 | const DAVRequestEnvironment & rEnv ) | |||
865 | { | |||
866 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
867 | ||||
868 | SAL_INFO( "ucb.ucp.webdav", "OPTIONS - relative URL <" << inPath << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "OPTIONS - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "868" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "OPTIONS - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "OPTIONS - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "868" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "OPTIONS - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "868" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "OPTIONS - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "OPTIONS - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "868" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
869 | ||||
870 | rOptions.init(); | |||
871 | ||||
872 | Init( rEnv ); | |||
873 | int theRetVal; | |||
874 | ||||
875 | ne_request *req = ne_request_create(m_pHttpSession, "OPTIONS", OUStringToOString( | |||
876 | inPath, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr()); | |||
877 | { | |||
878 | osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); | |||
879 | theRetVal = ne_request_dispatch(req); | |||
880 | } | |||
881 | ||||
882 | //check if http error is in the 200 class (no error) | |||
883 | if (theRetVal == NE_OK(0) && ne_get_status(req)->klass != 2) { | |||
884 | theRetVal = NE_ERROR(1); | |||
885 | } | |||
886 | ||||
887 | if ( theRetVal == NE_OK(0) ) | |||
888 | { | |||
889 | void *cursor = nullptr; | |||
890 | const char *name, *value; | |||
891 | while ( ( cursor = ne_response_header_iterate( | |||
892 | req, cursor, &name, &value ) ) != nullptr ) | |||
893 | { | |||
894 | OUString aHeaderName(OUString(name, strlen(name), RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11))).toAsciiLowerCase()); | |||
895 | OUString aHeaderValue(value, strlen(value), RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11))); | |||
896 | ||||
897 | // display the single header | |||
898 | SAL_INFO( "ucb.ucp.webdav", "OPTIONS - received header: " << aHeaderName << ":" << aHeaderValue )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "OPTIONS - received header: " << aHeaderName << ":" << aHeaderValue) == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "898" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "OPTIONS - received header: " << aHeaderName << ":" << aHeaderValue), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "OPTIONS - received header: " << aHeaderName << ":" << aHeaderValue; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "898" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "OPTIONS - received header: " << aHeaderName << ":" << aHeaderValue) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "898" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "OPTIONS - received header: " << aHeaderName << ":" << aHeaderValue), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "OPTIONS - received header: " << aHeaderName << ":" << aHeaderValue; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "898" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
899 | ||||
900 | if ( aHeaderName == "allow" ) | |||
901 | { | |||
902 | rOptions.setAllowedMethods( aHeaderValue ); | |||
903 | } | |||
904 | else if ( aHeaderName == "dav" ) | |||
905 | { | |||
906 | // check type of dav capability | |||
907 | // need to parse the value, token separator: "," | |||
908 | // see <http://tools.ietf.org/html/rfc4918#section-10.1>, | |||
909 | // <http://tools.ietf.org/html/rfc4918#section-18>, | |||
910 | // and <http://tools.ietf.org/html/rfc7230#section-3.2> | |||
911 | // we detect the class (1, 2 and 3), other elements (token, URL) | |||
912 | // are not used for now | |||
913 | // silly parser written using OUString, not very efficient | |||
914 | // but quick and easy to write... | |||
915 | sal_Int32 nFromIndex = 0; | |||
916 | sal_Int32 nNextIndex = 0; | |||
917 | while( ( nNextIndex = aHeaderValue.indexOf( ",", nFromIndex ) ) != -1 ) | |||
918 | { // found a comma | |||
919 | // try to convert from nFromIndex to nNextIndex -1 in a number | |||
920 | // if this is 1 or 2 or 3, use for class setting | |||
921 | sal_Int32 nClass = | |||
922 | aHeaderValue.copy( nFromIndex, nNextIndex - nFromIndex ).toInt32(); | |||
923 | switch( nClass ) | |||
924 | { | |||
925 | case 1: | |||
926 | rOptions.setClass1(); | |||
927 | break; | |||
928 | case 2: | |||
929 | rOptions.setClass2(); | |||
930 | break; | |||
931 | case 3: | |||
932 | rOptions.setClass3(); | |||
933 | break; | |||
934 | default: | |||
935 | ; | |||
936 | } | |||
937 | // next starting point | |||
938 | nFromIndex = nNextIndex + 1; | |||
939 | } | |||
940 | // check for last fragment | |||
941 | if ( nFromIndex < aHeaderValue.getLength() ) | |||
942 | { | |||
943 | sal_Int32 nClass = aHeaderValue.copy( nFromIndex ).toInt32(); | |||
944 | switch( nClass ) | |||
945 | { | |||
946 | case 1: | |||
947 | rOptions.setClass1(); | |||
948 | break; | |||
949 | case 2: | |||
950 | rOptions.setClass2(); | |||
951 | break; | |||
952 | case 3: | |||
953 | rOptions.setClass3(); | |||
954 | break; | |||
955 | default: | |||
956 | ; | |||
957 | } | |||
958 | } | |||
959 | } | |||
960 | } | |||
961 | // if applicable, check for lock state: | |||
962 | if( rOptions.isClass2() || rOptions.isClass3() ) | |||
963 | { | |||
964 | //dav with lock possible, check for locked state | |||
965 | if ( m_aNeonLockStore.findByUri( | |||
966 | makeAbsoluteURL( inPath ) ) != nullptr ) | |||
967 | { | |||
968 | // we own a lock for this URL, | |||
969 | // set locked state | |||
970 | rOptions.setLocked(); | |||
971 | } | |||
972 | } | |||
973 | } | |||
974 | ||||
975 | ne_request_destroy(req); | |||
976 | ||||
977 | HandleError( theRetVal, inPath, rEnv ); | |||
978 | } | |||
979 | ||||
980 | void NeonSession::PROPFIND( const OUString & inPath, | |||
981 | const Depth inDepth, | |||
982 | const std::vector< OUString > & inPropNames, | |||
983 | std::vector< DAVResource > & ioResources, | |||
984 | const DAVRequestEnvironment & rEnv ) | |||
985 | { | |||
986 | ||||
987 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
988 | ||||
989 | #if defined SAL_LOG_INFO1 | |||
990 | { //debug | |||
991 | SAL_INFO( "ucb.ucp.webdav", "PROPFIND - relative URL: <" << inPath << "> Depth: " << inDepth )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "PROPFIND - relative URL: <" << inPath << "> Depth: " << inDepth) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "991" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "PROPFIND - relative URL: <" << inPath << "> Depth: " << inDepth), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "PROPFIND - relative URL: <" << inPath << "> Depth: " << inDepth; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "991" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "PROPFIND - relative URL: <" << inPath << "> Depth: " << inDepth) == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "991" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "PROPFIND - relative URL: <" << inPath << "> Depth: " << inDepth), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "PROPFIND - relative URL: <" << inPath << "> Depth: " << inDepth; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "991" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
992 | for(const auto& rPropName : inPropNames) | |||
993 | { | |||
994 | SAL_INFO( "ucb.ucp.webdav", "PROPFIND - property requested: " << rPropName )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "PROPFIND - property requested: " << rPropName) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "994" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "PROPFIND - property requested: " << rPropName), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "PROPFIND - property requested: " << rPropName; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "994" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "PROPFIND - property requested: " << rPropName ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "994" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "PROPFIND - property requested: " << rPropName), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "PROPFIND - property requested: " << rPropName; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "994" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
995 | } | |||
996 | } //debug | |||
997 | #endif | |||
998 | ||||
999 | Init( rEnv ); | |||
1000 | ||||
1001 | int theRetVal = NE_OK(0); | |||
1002 | NeonPropFindRequest theRequest( m_pHttpSession, | |||
1003 | OUStringToOString( | |||
1004 | inPath, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
1005 | inDepth, | |||
1006 | inPropNames, | |||
1007 | ioResources, | |||
1008 | theRetVal ); | |||
1009 | ||||
1010 | HandleError( theRetVal, inPath, rEnv ); | |||
1011 | } | |||
1012 | ||||
1013 | void NeonSession::PROPFIND( const OUString & inPath, | |||
1014 | const Depth inDepth, | |||
1015 | std::vector< DAVResourceInfo > & ioResInfo, | |||
1016 | const DAVRequestEnvironment & rEnv ) | |||
1017 | { | |||
1018 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1019 | SAL_INFO( "ucb.ucp.webdav", "PROPFIND - relative URL: <" << inPath << "> Depth: " << inDepth )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "PROPFIND - relative URL: <" << inPath << "> Depth: " << inDepth) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1019" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "PROPFIND - relative URL: <" << inPath << "> Depth: " << inDepth), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "PROPFIND - relative URL: <" << inPath << "> Depth: " << inDepth; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1019" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "PROPFIND - relative URL: <" << inPath << "> Depth: " << inDepth) == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1019" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "PROPFIND - relative URL: <" << inPath << "> Depth: " << inDepth), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "PROPFIND - relative URL: <" << inPath << "> Depth: " << inDepth; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1019" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1020 | ||||
1021 | Init( rEnv ); | |||
1022 | ||||
1023 | int theRetVal = NE_OK(0); | |||
1024 | NeonPropFindRequest theRequest( m_pHttpSession, | |||
1025 | OUStringToOString( | |||
1026 | inPath, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
1027 | inDepth, | |||
1028 | ioResInfo, | |||
1029 | theRetVal ); | |||
1030 | ||||
1031 | #if defined SAL_LOG_INFO1 | |||
1032 | { //debug | |||
1033 | for ( const auto& rResInfo : ioResInfo ) | |||
1034 | { | |||
1035 | for ( const auto& rProp : rResInfo.properties ) | |||
1036 | { | |||
1037 | SAL_INFO( "ucb.ucp.webdav", "PROPFIND - returned property (name only): " << rProp )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "PROPFIND - returned property (name only): " << rProp) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1037" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "PROPFIND - returned property (name only): " << rProp), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "PROPFIND - returned property (name only): " << rProp; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1037" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "PROPFIND - returned property (name only): " << rProp) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1037" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "PROPFIND - returned property (name only): " << rProp), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "PROPFIND - returned property (name only): " << rProp; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1037" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1038 | } | |||
1039 | } | |||
1040 | } //debug | |||
1041 | #endif | |||
1042 | ||||
1043 | HandleError( theRetVal, inPath, rEnv ); | |||
1044 | } | |||
1045 | ||||
1046 | void NeonSession::PROPPATCH( const OUString & inPath, | |||
1047 | const std::vector< ProppatchValue > & inValues, | |||
1048 | const DAVRequestEnvironment & rEnv ) | |||
1049 | { | |||
1050 | SAL_INFO( "ucb.ucp.webdav", "PROPPATCH - relative URL <" << inPath << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "PROPPATCH - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1050" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "PROPPATCH - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "PROPPATCH - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1050" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "PROPPATCH - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1050" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "PROPPATCH - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "PROPPATCH - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1050" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1051 | ||||
1052 | /* @@@ Which standard live properties can be set by the client? | |||
1053 | This is a known WebDAV RFC issue ( verified: 04/10/2001 ) | |||
1054 | --> http://www.ics.uci.edu/pub/ietf/webdav/protocol/issues.html | |||
1055 | ||||
1056 | mod_dav implementation: | |||
1057 | ||||
1058 | creationdate r ( File System prop ) | |||
1059 | displayname w | |||
1060 | getcontentlanguage r ( #ifdef DAV_DISABLE_WRITEABLE_PROPS ) | |||
1061 | getcontentlength r ( File System prop ) | |||
1062 | getcontenttype r ( #ifdef DAV_DISABLE_WRITEABLE_PROPS ) | |||
1063 | getetag r ( File System prop ) | |||
1064 | getlastmodified r ( File System prop ) | |||
1065 | lockdiscovery r | |||
1066 | resourcetype r | |||
1067 | source w | |||
1068 | supportedlock r | |||
1069 | executable w ( #ifndef WIN32 ) | |||
1070 | ||||
1071 | All dead properties are of course writable. | |||
1072 | */ | |||
1073 | ||||
1074 | int theRetVal = NE_OK(0); | |||
1075 | ||||
1076 | int n; // for the "for" loop | |||
1077 | ||||
1078 | // Generate the list of properties we want to set. | |||
1079 | int nPropCount = inValues.size(); | |||
1080 | std::unique_ptr<ne_proppatch_operation[]> pItems( | |||
1081 | new ne_proppatch_operation[ nPropCount + 1 ]); | |||
1082 | for ( n = 0; n < nPropCount; ++n ) | |||
1083 | { | |||
1084 | const ProppatchValue & rValue = inValues[ n ]; | |||
1085 | ||||
1086 | // Split fullname into namespace and name! | |||
1087 | ne_propname * pName = new ne_propname; | |||
1088 | DAVProperties::createNeonPropName( rValue.name, *pName ); | |||
1089 | pItems[ n ].name = pName; | |||
1090 | ||||
1091 | if ( rValue.operation == PROPSET ) | |||
1092 | { | |||
1093 | pItems[ n ].type = ne_propset; | |||
1094 | ||||
1095 | OUString aStringValue; | |||
1096 | if ( DAVProperties::isUCBDeadProperty( *pName ) ) | |||
1097 | { | |||
1098 | // DAV dead property added by WebDAV UCP? | |||
1099 | if ( !UCBDeadPropertyValue::toXML( rValue.value, | |||
1100 | aStringValue ) ) | |||
1101 | { | |||
1102 | // Error! | |||
1103 | pItems[ n ].value = nullptr; | |||
1104 | theRetVal = NE_ERROR(1); | |||
1105 | nPropCount = n + 1; | |||
1106 | break; | |||
1107 | } | |||
1108 | } | |||
1109 | else if ( !( rValue.value >>= aStringValue ) ) | |||
1110 | { | |||
1111 | // complex properties... | |||
1112 | if ( rValue.name == DAVProperties::SOURCE ) | |||
1113 | { | |||
1114 | uno::Sequence< ucb::Link > aLinks; | |||
1115 | if ( rValue.value >>= aLinks ) | |||
1116 | { | |||
1117 | LinkSequence::toXML( aLinks, aStringValue ); | |||
1118 | } | |||
1119 | else | |||
1120 | { | |||
1121 | // Error! | |||
1122 | pItems[ n ].value = nullptr; | |||
1123 | theRetVal = NE_ERROR(1); | |||
1124 | nPropCount = n + 1; | |||
1125 | break; | |||
1126 | } | |||
1127 | } | |||
1128 | else | |||
1129 | { | |||
1130 | SAL_WARN( "ucb.ucp.webdav", "PROPPATCH - Unsupported type!" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "PROPPATCH - Unsupported type!" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1130" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "PROPPATCH - Unsupported type!"), 0) ; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "PROPPATCH - Unsupported type!"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1130" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "PROPPATCH - Unsupported type!") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1130" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "PROPPATCH - Unsupported type!"), 0) ; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "PROPPATCH - Unsupported type!"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1130" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1131 | // Error! | |||
1132 | pItems[ n ].value = nullptr; | |||
1133 | theRetVal = NE_ERROR(1); | |||
1134 | nPropCount = n + 1; | |||
1135 | break; | |||
1136 | } | |||
1137 | } | |||
1138 | pItems[ n ].value | |||
1139 | = strdup( OUStringToOString( aStringValue, | |||
1140 | RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr() ); | |||
1141 | } | |||
1142 | else | |||
1143 | { | |||
1144 | pItems[ n ].type = ne_propremove; | |||
1145 | pItems[ n ].value = nullptr; | |||
1146 | } | |||
1147 | } | |||
1148 | ||||
1149 | if ( theRetVal == NE_OK(0) ) | |||
1150 | { | |||
1151 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1152 | ||||
1153 | Init( rEnv ); | |||
1154 | ||||
1155 | pItems[ n ].name = nullptr; | |||
1156 | ||||
1157 | theRetVal = ne_proppatch( m_pHttpSession, | |||
1158 | OUStringToOString( | |||
1159 | inPath, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
1160 | pItems.get() ); | |||
1161 | } | |||
1162 | ||||
1163 | for ( n = 0; n < nPropCount; ++n ) | |||
1164 | { | |||
1165 | free( const_cast<char *>(pItems[ n ].name->name) ); | |||
1166 | delete pItems[ n ].name; | |||
1167 | free( const_cast<char *>(pItems[ n ].value) ); | |||
1168 | } | |||
1169 | ||||
1170 | HandleError( theRetVal, inPath, rEnv ); | |||
1171 | } | |||
1172 | ||||
1173 | void NeonSession::HEAD( const OUString & inPath, | |||
1174 | const std::vector< OUString > & inHeaderNames, | |||
1175 | DAVResource & ioResource, | |||
1176 | const DAVRequestEnvironment & rEnv ) | |||
1177 | { | |||
1178 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1179 | SAL_INFO( "ucb.ucp.webdav", "HEAD - relative URL <" << inPath << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "HEAD - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1179" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "HEAD - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "HEAD - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1179" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "HEAD - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1179" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "HEAD - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "HEAD - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1179" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1180 | ||||
1181 | Init( rEnv ); | |||
1182 | ||||
1183 | int theRetVal = NE_OK(0); | |||
1184 | NeonHeadRequest theRequest( m_pHttpSession, | |||
1185 | inPath, | |||
1186 | inHeaderNames, | |||
1187 | ioResource, | |||
1188 | theRetVal ); | |||
1189 | ||||
1190 | HandleError( theRetVal, inPath, rEnv ); | |||
1191 | } | |||
1192 | ||||
1193 | uno::Reference< io::XInputStream > | |||
1194 | NeonSession::GET( const OUString & inPath, | |||
1195 | const DAVRequestEnvironment & rEnv ) | |||
1196 | { | |||
1197 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1198 | SAL_INFO( "ucb.ucp.webdav", "GET - relative URL <" << inPath << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "GET - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1198" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "GET - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "GET - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1198" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "GET - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1198" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "GET - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "GET - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1198" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1199 | ||||
1200 | Init( rEnv ); | |||
1201 | ||||
1202 | rtl::Reference< NeonInputStream > xInputStream( new NeonInputStream ); | |||
1203 | NeonRequestContext aCtx( xInputStream ); | |||
1204 | int theRetVal = GET( m_pHttpSession, | |||
1205 | OUStringToOString( | |||
1206 | inPath, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
1207 | NeonSession_ResponseBlockReader, | |||
1208 | false, | |||
1209 | &aCtx ); | |||
1210 | ||||
1211 | HandleError( theRetVal, inPath, rEnv ); | |||
1212 | ||||
1213 | return uno::Reference< io::XInputStream >( xInputStream.get() ); | |||
1214 | } | |||
1215 | ||||
1216 | void NeonSession::GET( const OUString & inPath, | |||
1217 | uno::Reference< io::XOutputStream > & ioOutputStream, | |||
1218 | const DAVRequestEnvironment & rEnv ) | |||
1219 | { | |||
1220 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1221 | SAL_INFO( "ucb.ucp.webdav", "GET - relative URL <" << inPath << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "GET - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1221" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "GET - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "GET - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1221" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "GET - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1221" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "GET - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "GET - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1221" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1222 | ||||
1223 | Init( rEnv ); | |||
1224 | ||||
1225 | NeonRequestContext aCtx( ioOutputStream ); | |||
1226 | int theRetVal = GET( m_pHttpSession, | |||
1227 | OUStringToOString( | |||
1228 | inPath, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
1229 | NeonSession_ResponseBlockWriter, | |||
1230 | false, | |||
1231 | &aCtx ); | |||
1232 | ||||
1233 | HandleError( theRetVal, inPath, rEnv ); | |||
1234 | } | |||
1235 | ||||
1236 | uno::Reference< io::XInputStream > | |||
1237 | NeonSession::GET( const OUString & inPath, | |||
1238 | const std::vector< OUString > & inHeaderNames, | |||
1239 | DAVResource & ioResource, | |||
1240 | const DAVRequestEnvironment & rEnv ) | |||
1241 | { | |||
1242 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1243 | SAL_INFO( "ucb.ucp.webdav", "GET - relative URL <" << inPath << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "GET - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1243" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "GET - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "GET - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1243" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "GET - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1243" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "GET - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "GET - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1243" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1244 | ||||
1245 | Init( rEnv ); | |||
1246 | ||||
1247 | ioResource.uri = inPath; | |||
1248 | ioResource.properties.clear(); | |||
1249 | ||||
1250 | rtl::Reference< NeonInputStream > xInputStream( new NeonInputStream ); | |||
1251 | NeonRequestContext aCtx( xInputStream, inHeaderNames, ioResource ); | |||
1252 | int theRetVal = GET( m_pHttpSession, | |||
1253 | OUStringToOString( | |||
1254 | inPath, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
1255 | NeonSession_ResponseBlockReader, | |||
1256 | true, | |||
1257 | &aCtx ); | |||
1258 | ||||
1259 | HandleError( theRetVal, inPath, rEnv ); | |||
1260 | ||||
1261 | return uno::Reference< io::XInputStream >( xInputStream.get() ); | |||
1262 | } | |||
1263 | ||||
1264 | void NeonSession::GET0( const OUString & inPath, | |||
1265 | const std::vector< OUString > & inHeaderNames, | |||
1266 | DAVResource & ioResource, | |||
1267 | const DAVRequestEnvironment & rEnv ) | |||
1268 | { | |||
1269 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1270 | SAL_INFO( "ucb.ucp.webdav", "GET - relative URL <" << inPath << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "GET - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1270" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "GET - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "GET - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1270" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "GET - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1270" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "GET - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "GET - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1270" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1271 | ||||
1272 | Init( rEnv ); | |||
1273 | ||||
1274 | ioResource.uri = inPath; | |||
1275 | ioResource.properties.clear(); | |||
1276 | ||||
1277 | rtl::Reference< NeonInputStream > xInputStream( new NeonInputStream ); | |||
1278 | NeonRequestContext aCtx( xInputStream, inHeaderNames, ioResource ); | |||
1279 | int theRetVal = GET0( m_pHttpSession, | |||
1280 | OUStringToOString( | |||
1281 | inPath, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
1282 | true, | |||
1283 | &aCtx ); | |||
1284 | ||||
1285 | HandleError( theRetVal, inPath, rEnv ); | |||
1286 | } | |||
1287 | ||||
1288 | void NeonSession::GET( const OUString & inPath, | |||
1289 | uno::Reference< io::XOutputStream > & ioOutputStream, | |||
1290 | const std::vector< OUString > & inHeaderNames, | |||
1291 | DAVResource & ioResource, | |||
1292 | const DAVRequestEnvironment & rEnv ) | |||
1293 | { | |||
1294 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1295 | SAL_INFO( "ucb.ucp.webdav", "GET - relative URL <" << inPath << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "GET - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1295" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "GET - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "GET - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1295" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "GET - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1295" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "GET - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "GET - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1295" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1296 | ||||
1297 | Init( rEnv ); | |||
1298 | ||||
1299 | ioResource.uri = inPath; | |||
1300 | ioResource.properties.clear(); | |||
1301 | ||||
1302 | NeonRequestContext aCtx( ioOutputStream, inHeaderNames, ioResource ); | |||
1303 | int theRetVal = GET( m_pHttpSession, | |||
1304 | OUStringToOString( | |||
1305 | inPath, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
1306 | NeonSession_ResponseBlockWriter, | |||
1307 | true, | |||
1308 | &aCtx ); | |||
1309 | ||||
1310 | HandleError( theRetVal, inPath, rEnv ); | |||
1311 | } | |||
1312 | ||||
1313 | void NeonSession::PUT( const OUString & inPath, | |||
1314 | const uno::Reference< io::XInputStream > & inInputStream, | |||
1315 | const DAVRequestEnvironment & rEnv ) | |||
1316 | { | |||
1317 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1318 | SAL_INFO( "ucb.ucp.webdav", "PUT - relative URL <" << inPath << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "PUT - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1318" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "PUT - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "PUT - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1318" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "PUT - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1318" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "PUT - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "PUT - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1318" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1319 | ||||
1320 | uno::Sequence< sal_Int8 > aDataToSend; | |||
1321 | if ( !getDataFromInputStream( inInputStream, aDataToSend, false ) ) | |||
1322 | throw DAVException( DAVException::DAV_INVALID_ARG ); | |||
1323 | ||||
1324 | Init( rEnv ); | |||
1325 | ||||
1326 | int theRetVal = PUT( m_pHttpSession, | |||
1327 | OUStringToOString( | |||
1328 | inPath, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
1329 | reinterpret_cast< const char * >( | |||
1330 | aDataToSend.getConstArray() ), | |||
1331 | aDataToSend.getLength() ); | |||
1332 | ||||
1333 | HandleError( theRetVal, inPath, rEnv ); | |||
1334 | } | |||
1335 | ||||
1336 | uno::Reference< io::XInputStream > | |||
1337 | NeonSession::POST( const OUString & inPath, | |||
1338 | const OUString & rContentType, | |||
1339 | const OUString & rReferer, | |||
1340 | const uno::Reference< io::XInputStream > & inInputStream, | |||
1341 | const DAVRequestEnvironment & rEnv ) | |||
1342 | { | |||
1343 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1344 | SAL_INFO( "ucb.ucp.webdav", "POST - relative URL <" << inPath << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "POST - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1344" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "POST - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "POST - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1344" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "POST - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1344" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "POST - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "POST - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1344" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1345 | ||||
1346 | uno::Sequence< sal_Int8 > aDataToSend; | |||
1347 | if ( !getDataFromInputStream( inInputStream, aDataToSend, true ) ) | |||
1348 | throw DAVException( DAVException::DAV_INVALID_ARG ); | |||
1349 | ||||
1350 | Init( rEnv ); | |||
1351 | ||||
1352 | rtl::Reference< NeonInputStream > xInputStream( new NeonInputStream ); | |||
1353 | NeonRequestContext aCtx( xInputStream ); | |||
1354 | int theRetVal = POST( m_pHttpSession, | |||
1355 | OUStringToOString( | |||
1356 | inPath, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
1357 | reinterpret_cast< const char * >( | |||
1358 | aDataToSend.getConstArray() ), | |||
1359 | NeonSession_ResponseBlockReader, | |||
1360 | &aCtx, | |||
1361 | rContentType, | |||
1362 | rReferer ); | |||
1363 | ||||
1364 | HandleError( theRetVal, inPath, rEnv ); | |||
1365 | ||||
1366 | return uno::Reference< io::XInputStream >( xInputStream.get() ); | |||
1367 | } | |||
1368 | ||||
1369 | void NeonSession::POST( const OUString & inPath, | |||
1370 | const OUString & rContentType, | |||
1371 | const OUString & rReferer, | |||
1372 | const uno::Reference< io::XInputStream > & inInputStream, | |||
1373 | uno::Reference< io::XOutputStream > & oOutputStream, | |||
1374 | const DAVRequestEnvironment & rEnv ) | |||
1375 | { | |||
1376 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1377 | SAL_INFO( "ucb.ucp.webdav", "POST - relative URL <" << inPath << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "POST - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1377" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "POST - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "POST - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1377" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "POST - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1377" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "POST - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "POST - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1377" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1378 | ||||
1379 | uno::Sequence< sal_Int8 > aDataToSend; | |||
1380 | if ( !getDataFromInputStream( inInputStream, aDataToSend, true ) ) | |||
1381 | throw DAVException( DAVException::DAV_INVALID_ARG ); | |||
1382 | ||||
1383 | Init( rEnv ); | |||
1384 | ||||
1385 | NeonRequestContext aCtx( oOutputStream ); | |||
1386 | int theRetVal = POST( m_pHttpSession, | |||
1387 | OUStringToOString( | |||
1388 | inPath, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
1389 | reinterpret_cast< const char * >( | |||
1390 | aDataToSend.getConstArray() ), | |||
1391 | NeonSession_ResponseBlockWriter, | |||
1392 | &aCtx, | |||
1393 | rContentType, | |||
1394 | rReferer ); | |||
1395 | ||||
1396 | HandleError( theRetVal, inPath, rEnv ); | |||
1397 | } | |||
1398 | ||||
1399 | void NeonSession::MKCOL( const OUString & inPath, | |||
1400 | const DAVRequestEnvironment & rEnv ) | |||
1401 | { | |||
1402 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1403 | SAL_INFO( "ucb.ucp.webdav", "MKCOL - relative URL <" << inPath << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "MKCOL - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1403" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "MKCOL - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "MKCOL - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1403" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "MKCOL - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1403" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "MKCOL - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "MKCOL - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1403" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1404 | ||||
1405 | Init( rEnv ); | |||
1406 | ||||
1407 | int theRetVal = ne_mkcol( m_pHttpSession, | |||
1408 | OUStringToOString( | |||
1409 | inPath, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr() ); | |||
1410 | ||||
1411 | HandleError( theRetVal, inPath, rEnv ); | |||
1412 | } | |||
1413 | ||||
1414 | void NeonSession::COPY( const OUString & inSourceURL, | |||
1415 | const OUString & inDestinationURL, | |||
1416 | const DAVRequestEnvironment & rEnv, | |||
1417 | bool inOverWrite ) | |||
1418 | { | |||
1419 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1420 | SAL_INFO( "ucb.ucp.webdav", "COPY - inSourceURL: "<<inSourceURL<<" inDestinationURL: "<<inDestinationURL)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "COPY - inSourceURL: " <<inSourceURL<<" inDestinationURL: "<<inDestinationURL ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1420" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "COPY - inSourceURL: "<<inSourceURL <<" inDestinationURL: "<<inDestinationURL), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "COPY - inSourceURL: "<<inSourceURL<<" inDestinationURL: " <<inDestinationURL; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1420" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "COPY - inSourceURL: "<<inSourceURL<< " inDestinationURL: "<<inDestinationURL) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1420" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "COPY - inSourceURL: "<<inSourceURL <<" inDestinationURL: "<<inDestinationURL), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "COPY - inSourceURL: "<<inSourceURL<<" inDestinationURL: " <<inDestinationURL; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1420" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1421 | ||||
1422 | Init( rEnv ); | |||
1423 | ||||
1424 | NeonUri theSourceUri( inSourceURL ); | |||
1425 | NeonUri theDestinationUri( inDestinationURL ); | |||
1426 | ||||
1427 | int theRetVal = ne_copy( m_pHttpSession, | |||
1428 | inOverWrite ? 1 : 0, | |||
1429 | NE_DEPTH_INFINITE(2), | |||
1430 | OUStringToOString( | |||
1431 | theSourceUri.GetPath(), | |||
1432 | RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
1433 | OUStringToOString( | |||
1434 | theDestinationUri.GetPath(), | |||
1435 | RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr() ); | |||
1436 | ||||
1437 | HandleError( theRetVal, inSourceURL, rEnv ); | |||
1438 | } | |||
1439 | ||||
1440 | void NeonSession::MOVE( const OUString & inSourceURL, | |||
1441 | const OUString & inDestinationURL, | |||
1442 | const DAVRequestEnvironment & rEnv, | |||
1443 | bool inOverWrite ) | |||
1444 | { | |||
1445 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1446 | SAL_INFO( "ucb.ucp.webdav", "MOVE - inSourceURL: "<<inSourceURL<<" inDestinationURL: "<<inDestinationURL)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "MOVE - inSourceURL: " <<inSourceURL<<" inDestinationURL: "<<inDestinationURL ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1446" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "MOVE - inSourceURL: "<<inSourceURL <<" inDestinationURL: "<<inDestinationURL), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "MOVE - inSourceURL: "<<inSourceURL<<" inDestinationURL: " <<inDestinationURL; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1446" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "MOVE - inSourceURL: "<<inSourceURL<< " inDestinationURL: "<<inDestinationURL) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1446" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "MOVE - inSourceURL: "<<inSourceURL <<" inDestinationURL: "<<inDestinationURL), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "MOVE - inSourceURL: "<<inSourceURL<<" inDestinationURL: " <<inDestinationURL; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1446" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1447 | ||||
1448 | Init( rEnv ); | |||
1449 | ||||
1450 | NeonUri theSourceUri( inSourceURL ); | |||
1451 | NeonUri theDestinationUri( inDestinationURL ); | |||
1452 | int theRetVal = ne_move( m_pHttpSession, | |||
1453 | inOverWrite ? 1 : 0, | |||
1454 | OUStringToOString( | |||
1455 | theSourceUri.GetPath(), | |||
1456 | RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
1457 | OUStringToOString( | |||
1458 | theDestinationUri.GetPath(), | |||
1459 | RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr() ); | |||
1460 | ||||
1461 | HandleError( theRetVal, inSourceURL, rEnv ); | |||
1462 | } | |||
1463 | ||||
1464 | void NeonSession::DESTROY( const OUString & inPath, | |||
1465 | const DAVRequestEnvironment & rEnv ) | |||
1466 | { | |||
1467 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1468 | SAL_INFO( "ucb.ucp.webdav", "DESTROY - relative URL <" << inPath << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DESTROY - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1468" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DESTROY - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "DESTROY - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1468" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DESTROY - relative URL <" << inPath << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1468" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DESTROY - relative URL <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "DESTROY - relative URL <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1468" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1469 | ||||
1470 | Init( rEnv ); | |||
1471 | ||||
1472 | int theRetVal = ne_delete( m_pHttpSession, | |||
1473 | OUStringToOString( | |||
1474 | inPath, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr() ); | |||
1475 | ||||
1476 | HandleError( theRetVal, inPath, rEnv ); | |||
1477 | } | |||
1478 | ||||
1479 | namespace | |||
1480 | { | |||
1481 | sal_Int32 lastChanceToSendRefreshRequest( TimeValue const & rStart, | |||
1482 | int timeout ) | |||
1483 | { | |||
1484 | TimeValue aEnd; | |||
1485 | osl_getSystemTime( &aEnd ); | |||
1486 | ||||
1487 | // Try to estimate a safe absolute time for sending the | |||
1488 | // lock refresh request. | |||
1489 | sal_Int32 lastChanceToSendRefreshRequest = -1; | |||
1490 | if ( timeout != NE_TIMEOUT_INFINITE-1 ) | |||
1491 | { | |||
1492 | sal_Int32 calltime = aEnd.Seconds - rStart.Seconds; | |||
1493 | if ( calltime <= timeout ) | |||
1494 | { | |||
1495 | lastChanceToSendRefreshRequest = rStart.Seconds + timeout; | |||
1496 | } | |||
1497 | else | |||
1498 | { | |||
1499 | SAL_WARN( "ucb.ucp.webdav", "LOCK - no chance to refresh lock before timeout!" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "LOCK - no chance to refresh lock before timeout!" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1499" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK - no chance to refresh lock before timeout!" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LOCK - no chance to refresh lock before timeout!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1499" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LOCK - no chance to refresh lock before timeout!" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1499" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK - no chance to refresh lock before timeout!" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LOCK - no chance to refresh lock before timeout!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1499" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1500 | } | |||
1501 | } | |||
1502 | return lastChanceToSendRefreshRequest; | |||
1503 | } | |||
1504 | ||||
1505 | } // namespace | |||
1506 | ||||
1507 | // Set new lock | |||
1508 | void NeonSession::LOCK( const OUString & inPath, | |||
1509 | ucb::Lock & rLock, | |||
1510 | const DAVRequestEnvironment & rEnv ) | |||
1511 | { | |||
1512 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1513 | SAL_INFO( "ucb.ucp.webdav", "LOCK (create) - relative URL: <" << inPath << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "LOCK (create) - relative URL: <" << inPath << ">") == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1513" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK (create) - relative URL: <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LOCK (create) - relative URL: <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1513" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LOCK (create) - relative URL: <" << inPath << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1513" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK (create) - relative URL: <" << inPath << ">"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LOCK (create) - relative URL: <" << inPath << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1513" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
| ||||
1514 | ||||
1515 | // before issuing the lock command, | |||
1516 | // better check first if we already have one on this href | |||
1517 | if ( m_aNeonLockStore.findByUri( | |||
1518 | makeAbsoluteURL( inPath ) ) != nullptr ) | |||
1519 | { | |||
1520 | // we already own a lock for this href | |||
1521 | // no need to ask for another | |||
1522 | // TODO: add a lockdiscovery request for confirmation | |||
1523 | // checking the locktoken, the only item that's unique | |||
1524 | return; | |||
1525 | } | |||
1526 | ||||
1527 | Init( rEnv ); | |||
1528 | ||||
1529 | /* Create a depth zero, exclusive write lock, with default timeout | |||
1530 | * (allowing a server to pick a default). token, owner and uri are | |||
1531 | * unset. */ | |||
1532 | NeonLock * theLock = ne_lock_create(); | |||
1533 | ||||
1534 | // Set the lock uri | |||
1535 | ne_uri aUri; | |||
1536 | ne_uri_parse( OUStringToOString( makeAbsoluteURL( inPath ), | |||
1537 | RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr(), | |||
1538 | &aUri ); | |||
1539 | theLock->uri = aUri; | |||
1540 | ||||
1541 | // Set the lock depth | |||
1542 | switch( rLock.Depth ) | |||
1543 | { | |||
1544 | case ucb::LockDepth_ZERO: | |||
1545 | theLock->depth = NE_DEPTH_ZERO(0); | |||
1546 | break; | |||
1547 | case ucb::LockDepth_ONE: | |||
1548 | theLock->depth = NE_DEPTH_ONE(1); | |||
1549 | break; | |||
1550 | case ucb::LockDepth_INFINITY: | |||
1551 | theLock->depth = NE_DEPTH_INFINITE(2); | |||
1552 | break; | |||
1553 | default: | |||
1554 | throw DAVException( DAVException::DAV_INVALID_ARG ); | |||
1555 | } | |||
1556 | ||||
1557 | // Set the lock scope | |||
1558 | switch ( rLock.Scope ) | |||
1559 | { | |||
1560 | case ucb::LockScope_EXCLUSIVE: | |||
1561 | theLock->scope = ne_lockscope_exclusive; | |||
1562 | break; | |||
1563 | case ucb::LockScope_SHARED: | |||
1564 | theLock->scope = ne_lockscope_shared; | |||
1565 | break; | |||
1566 | default: | |||
1567 | throw DAVException( DAVException::DAV_INVALID_ARG ); | |||
1568 | } | |||
1569 | ||||
1570 | // Set the lock timeout | |||
1571 | theLock->timeout = static_cast<long>(rLock.Timeout); | |||
1572 | ||||
1573 | // Set the lock owner | |||
1574 | OUString aValue; | |||
1575 | rLock.Owner >>= aValue; | |||
1576 | theLock->owner = | |||
1577 | ne_strdup( OUStringToOString( aValue, | |||
1578 | RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr() ); | |||
1579 | TimeValue startCall; | |||
1580 | osl_getSystemTime( &startCall ); | |||
1581 | ||||
1582 | int theRetVal = ne_lock( m_pHttpSession, theLock ); | |||
1583 | ||||
1584 | if ( theRetVal == NE_OK(0) ) | |||
1585 | { | |||
1586 | m_aNeonLockStore.addLock( theLock, | |||
1587 | this, | |||
1588 | lastChanceToSendRefreshRequest( | |||
1589 | startCall, theLock->timeout ) ); | |||
1590 | ||||
1591 | uno::Sequence< OUString > aTokens( 1 ); | |||
1592 | aTokens[ 0 ] = OUString::createFromAscii( theLock->token ); | |||
1593 | rLock.LockTokens = aTokens; | |||
1594 | ||||
1595 | SAL_INFO( "ucb.ucp.webdav", "LOCK (create) - Created lock for <" << makeAbsoluteURL( inPath )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "LOCK (create) - Created lock for <" << makeAbsoluteURL( inPath ) << "> token: <" << theLock->token << "> timeout: " << theLock->timeout << " sec.") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1596" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK (create) - Created lock for <" << makeAbsoluteURL( inPath ) << "> token: <" << theLock->token << "> timeout: " << theLock->timeout << " sec."), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LOCK (create) - Created lock for <" << makeAbsoluteURL( inPath ) << "> token: <" << theLock->token << "> timeout: " << theLock->timeout << " sec."; ::sal::detail::log( (:: SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1596" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LOCK (create) - Created lock for <" << makeAbsoluteURL ( inPath ) << "> token: <" << theLock->token << "> timeout: " << theLock->timeout << " sec.") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1596" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK (create) - Created lock for <" << makeAbsoluteURL( inPath ) << "> token: <" << theLock->token << "> timeout: " << theLock->timeout << " sec."), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LOCK (create) - Created lock for <" << makeAbsoluteURL( inPath ) << "> token: <" << theLock->token << "> timeout: " << theLock->timeout << " sec."; ::sal::detail::log( (:: SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1596" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
| ||||
1596 | << "> token: <" << theLock->token << "> timeout: " << theLock->timeout << " sec.")do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "LOCK (create) - Created lock for <" << makeAbsoluteURL( inPath ) << "> token: <" << theLock->token << "> timeout: " << theLock->timeout << " sec.") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1596" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK (create) - Created lock for <" << makeAbsoluteURL( inPath ) << "> token: <" << theLock->token << "> timeout: " << theLock->timeout << " sec."), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LOCK (create) - Created lock for <" << makeAbsoluteURL( inPath ) << "> token: <" << theLock->token << "> timeout: " << theLock->timeout << " sec."; ::sal::detail::log( (:: SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1596" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LOCK (create) - Created lock for <" << makeAbsoluteURL ( inPath ) << "> token: <" << theLock->token << "> timeout: " << theLock->timeout << " sec.") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1596" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK (create) - Created lock for <" << makeAbsoluteURL( inPath ) << "> token: <" << theLock->token << "> timeout: " << theLock->timeout << " sec."), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LOCK (create) - Created lock for <" << makeAbsoluteURL( inPath ) << "> token: <" << theLock->token << "> timeout: " << theLock->timeout << " sec."; ::sal::detail::log( (:: SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1596" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1597 | } | |||
1598 | else | |||
1599 | { | |||
1600 | ne_lock_destroy( theLock ); | |||
1601 | ||||
1602 | SAL_INFO( "ucb.ucp.webdav", "LOCK (create) - Obtaining lock for <"do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "LOCK (create) - Obtaining lock for <" << makeAbsoluteURL( inPath ) << " failed!") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1603" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK (create) - Obtaining lock for <" << makeAbsoluteURL( inPath ) << " failed!"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LOCK (create) - Obtaining lock for <" << makeAbsoluteURL ( inPath ) << " failed!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1603" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LOCK (create) - Obtaining lock for <" << makeAbsoluteURL( inPath ) << " failed!") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1603" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK (create) - Obtaining lock for <" << makeAbsoluteURL( inPath ) << " failed!"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LOCK (create) - Obtaining lock for <" << makeAbsoluteURL ( inPath ) << " failed!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1603" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
1603 | << makeAbsoluteURL( inPath ) << " failed!" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "LOCK (create) - Obtaining lock for <" << makeAbsoluteURL( inPath ) << " failed!") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1603" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK (create) - Obtaining lock for <" << makeAbsoluteURL( inPath ) << " failed!"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LOCK (create) - Obtaining lock for <" << makeAbsoluteURL ( inPath ) << " failed!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1603" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LOCK (create) - Obtaining lock for <" << makeAbsoluteURL( inPath ) << " failed!") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1603" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK (create) - Obtaining lock for <" << makeAbsoluteURL( inPath ) << " failed!"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LOCK (create) - Obtaining lock for <" << makeAbsoluteURL ( inPath ) << " failed!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1603" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1604 | } | |||
1605 | ||||
1606 | HandleError( theRetVal, inPath, rEnv ); | |||
1607 | } | |||
1608 | ||||
1609 | // Refresh existing lock | |||
1610 | bool NeonSession::LOCK( NeonLock * pLock, | |||
1611 | sal_Int32 & rlastChanceToSendRefreshRequest ) | |||
1612 | { | |||
1613 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1614 | ||||
1615 | #if defined SAL_LOG_INFO1 | |||
1616 | { | |||
1617 | char * p = ne_uri_unparse( &(pLock->uri) ); | |||
1618 | SAL_INFO( "ucb.ucp.webdav", "LOCK (refresh) - relative URL: <" << p << "> token: <" << pLock->token << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "LOCK (refresh) - relative URL: <" << p << "> token: <" << pLock->token << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1618" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK (refresh) - relative URL: <" << p << "> token: <" << pLock->token << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "LOCK (refresh) - relative URL: <" << p << "> token: <" << pLock->token << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1618" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LOCK (refresh) - relative URL: <" << p << "> token: <" << pLock->token << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1618" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK (refresh) - relative URL: <" << p << "> token: <" << pLock->token << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "LOCK (refresh) - relative URL: <" << p << "> token: <" << pLock->token << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1618" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1619 | ne_freefree( p ); | |||
1620 | } | |||
1621 | #endif | |||
1622 | ||||
1623 | // refresh existing lock. | |||
1624 | ||||
1625 | TimeValue startCall; | |||
1626 | osl_getSystemTime( &startCall ); | |||
1627 | ||||
1628 | // save the current requested timeout, because ne_lock_refresh uses | |||
1629 | // pLock->timeout as an out parameter. This prevents a feedback-loop, | |||
1630 | // where we would request a shorter timeout on each refresh. | |||
1631 | long timeout = pLock->timeout; | |||
1632 | const int theRetVal = ne_lock_refresh(m_pHttpSession, pLock); | |||
1633 | if (theRetVal == NE_OK(0)) | |||
1634 | { | |||
1635 | rlastChanceToSendRefreshRequest | |||
1636 | = lastChanceToSendRefreshRequest( startCall, pLock->timeout ); | |||
1637 | ||||
1638 | SAL_INFO( "ucb.ucp.webdav", "LOCK (refresh) - Lock successfully refreshed." )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "LOCK (refresh) - Lock successfully refreshed." ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1638" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK (refresh) - Lock successfully refreshed." ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LOCK (refresh) - Lock successfully refreshed."; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1638" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LOCK (refresh) - Lock successfully refreshed.") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1638" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK (refresh) - Lock successfully refreshed." ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LOCK (refresh) - Lock successfully refreshed."; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1638" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1639 | pLock->timeout = timeout; | |||
1640 | return true; | |||
1641 | } | |||
1642 | else | |||
1643 | { | |||
1644 | #if defined SAL_LOG_WARN1 | |||
1645 | char * p = ne_uri_unparse( &(pLock->uri) ); | |||
1646 | SAL_WARN( "ucb.ucp.webdav", "LOCK (refresh) - not refreshed! Relative URL: <" << p << "> token: <" << pLock->token << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "LOCK (refresh) - not refreshed! Relative URL: <" << p << "> token: <" << pLock->token << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1646" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK (refresh) - not refreshed! Relative URL: <" << p << "> token: <" << pLock->token << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "LOCK (refresh) - not refreshed! Relative URL: <" << p << "> token: <" << pLock->token << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1646" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LOCK (refresh) - not refreshed! Relative URL: <" << p << "> token: <" << pLock->token << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1646" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "LOCK (refresh) - not refreshed! Relative URL: <" << p << "> token: <" << pLock->token << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "LOCK (refresh) - not refreshed! Relative URL: <" << p << "> token: <" << pLock->token << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1646" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1647 | ne_freefree( p ); | |||
1648 | #endif | |||
1649 | if (theRetVal == NE_AUTH(3)) | |||
1650 | { | |||
1651 | // tdf#126279: see handling of NE_AUTH in HandleError | |||
1652 | m_bNeedNewSession = true; | |||
1653 | m_aNeonLockStore.removeLockDeferred(pLock); | |||
1654 | } | |||
1655 | return false; | |||
1656 | } | |||
1657 | } | |||
1658 | ||||
1659 | void NeonSession::UNLOCK( const OUString & inPath, | |||
1660 | const DAVRequestEnvironment & rEnv ) | |||
1661 | { | |||
1662 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1663 | ||||
1664 | // get the neon lock from lock store | |||
1665 | NeonLock * theLock | |||
1666 | = m_aNeonLockStore.findByUri( makeAbsoluteURL( inPath ) ); | |||
1667 | if ( !theLock ) | |||
1668 | throw DAVException( DAVException::DAV_NOT_LOCKED ); | |||
1669 | ||||
1670 | SAL_INFO( "ucb.ucp.webdav", "UNLOCK - relative URL: <" << inPath << "> token: <" << theLock->token << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "UNLOCK - relative URL: <" << inPath << "> token: <" << theLock ->token << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1670" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "UNLOCK - relative URL: <" << inPath << "> token: <" << theLock->token << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "UNLOCK - relative URL: <" << inPath << "> token: <" << theLock->token << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1670" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "UNLOCK - relative URL: <" << inPath << "> token: <" << theLock->token << ">" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1670" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "UNLOCK - relative URL: <" << inPath << "> token: <" << theLock->token << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "UNLOCK - relative URL: <" << inPath << "> token: <" << theLock->token << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1670" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1671 | Init( rEnv ); | |||
1672 | ||||
1673 | int theRetVal = ne_unlock( m_pHttpSession, theLock ); | |||
1674 | ||||
1675 | if ( theRetVal == NE_OK(0) ) | |||
1676 | { | |||
1677 | m_aNeonLockStore.removeLock( theLock ); | |||
1678 | ne_lock_destroy( theLock ); | |||
1679 | } | |||
1680 | else | |||
1681 | { | |||
1682 | SAL_INFO( "ucb.ucp.webdav", "UNLOCK - Unlocking of <"do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "UNLOCK - Unlocking of <" << makeAbsoluteURL( inPath ) << "> failed.") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1683" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "UNLOCK - Unlocking of <" << makeAbsoluteURL( inPath ) << "> failed."), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "UNLOCK - Unlocking of <" << makeAbsoluteURL( inPath ) << "> failed."; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1683" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "UNLOCK - Unlocking of <" << makeAbsoluteURL ( inPath ) << "> failed.") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1683" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "UNLOCK - Unlocking of <" << makeAbsoluteURL( inPath ) << "> failed."), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "UNLOCK - Unlocking of <" << makeAbsoluteURL( inPath ) << "> failed."; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1683" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
1683 | << makeAbsoluteURL( inPath ) << "> failed." )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "UNLOCK - Unlocking of <" << makeAbsoluteURL( inPath ) << "> failed.") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1683" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "UNLOCK - Unlocking of <" << makeAbsoluteURL( inPath ) << "> failed."), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "UNLOCK - Unlocking of <" << makeAbsoluteURL( inPath ) << "> failed."; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1683" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "UNLOCK - Unlocking of <" << makeAbsoluteURL ( inPath ) << "> failed.") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1683" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "UNLOCK - Unlocking of <" << makeAbsoluteURL( inPath ) << "> failed."), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "UNLOCK - Unlocking of <" << makeAbsoluteURL( inPath ) << "> failed."; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1683" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1684 | } | |||
1685 | ||||
1686 | HandleError( theRetVal, inPath, rEnv ); | |||
1687 | } | |||
1688 | ||||
1689 | bool NeonSession::UNLOCK( NeonLock * pLock ) | |||
1690 | { | |||
1691 | osl::Guard< osl::Mutex > theGuard( m_aMutex ); | |||
1692 | ||||
1693 | #if defined SAL_LOG_INFO1 | |||
1694 | { | |||
1695 | char * p = ne_uri_unparse( &(pLock->uri) ); | |||
1696 | SAL_INFO( "ucb.ucp.webdav", "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << ">" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1696" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1696" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << ">") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1696" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << ">"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << ">"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1696" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1697 | ne_freefree( p ); | |||
1698 | } | |||
1699 | #endif | |||
1700 | ||||
1701 | const int theRetVal = ne_unlock(m_pHttpSession, pLock); | |||
1702 | if (theRetVal == NE_OK(0)) | |||
1703 | { | |||
1704 | #if defined SAL_LOG_INFO1 | |||
1705 | { | |||
1706 | char * p = ne_uri_unparse( &(pLock->uri) ); | |||
1707 | SAL_INFO( "ucb.ucp.webdav", "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << "> succeeded." )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << "> succeeded.") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1707" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << "> succeeded."), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << "> succeeded."; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1707" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << "> succeeded.") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1707" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << "> succeeded."), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << "> succeeded."; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1707" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1708 | ne_freefree( p ); | |||
1709 | } | |||
1710 | #endif | |||
1711 | return true; | |||
1712 | } | |||
1713 | else | |||
1714 | { | |||
1715 | #if defined SAL_LOG_INFO1 | |||
1716 | { | |||
1717 | char * p = ne_uri_unparse( &(pLock->uri) ); | |||
1718 | SAL_INFO( "ucb.ucp.webdav", "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << "> failed!" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << "> failed!") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1718" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << "> failed!"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << "> failed!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1718" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << "> failed!") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1718" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << "> failed!"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "UNLOCK (from store) - relative URL: <" << p << "> token: <" << pLock->token << "> failed!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1718" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1719 | ne_freefree( p ); | |||
1720 | } | |||
1721 | #endif | |||
1722 | if (theRetVal == NE_AUTH(3)) | |||
1723 | { | |||
1724 | // tdf#126279: see handling of NE_AUTH in HandleError | |||
1725 | m_bNeedNewSession = true; | |||
1726 | } | |||
1727 | return false; | |||
1728 | } | |||
1729 | } | |||
1730 | ||||
1731 | void NeonSession::abort() | |||
1732 | { | |||
1733 | SAL_INFO( "ucb.ucp.webdav", "neon commands cannot be aborted" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "neon commands cannot be aborted" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1733" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "neon commands cannot be aborted"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "neon commands cannot be aborted"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1733" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "neon commands cannot be aborted") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1733" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "neon commands cannot be aborted"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "neon commands cannot be aborted"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1733" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1734 | } | |||
1735 | ||||
1736 | ucbhelper::InternetProxyServer NeonSession::getProxySettings() const | |||
1737 | { | |||
1738 | if ( m_aScheme == "http" || m_aScheme == "https" ) | |||
1739 | { | |||
1740 | return m_rProxyDecider.getProxy( m_aScheme, | |||
1741 | m_aHostName, | |||
1742 | m_nPort ); | |||
1743 | } | |||
1744 | else | |||
1745 | { | |||
1746 | return m_rProxyDecider.getProxy( m_aScheme, | |||
1747 | OUString() /* not used */, | |||
1748 | -1 /* not used */ ); | |||
1749 | } | |||
1750 | } | |||
1751 | ||||
1752 | namespace { | |||
1753 | ||||
1754 | bool containsLocktoken( const uno::Sequence< ucb::Lock > & rLocks, | |||
1755 | const char * token ) | |||
1756 | { | |||
1757 | return std::any_of(rLocks.begin(), rLocks.end(), [&token](const ucb::Lock& rLock) { | |||
1758 | const uno::Sequence< OUString > & rTokens = rLock.LockTokens; | |||
1759 | return std::any_of(rTokens.begin(), rTokens.end(), | |||
1760 | [&token](const OUString& rToken) { return rToken.equalsAscii( token ); }); | |||
1761 | }); | |||
1762 | } | |||
1763 | ||||
1764 | } // namespace | |||
1765 | ||||
1766 | bool NeonSession::removeExpiredLocktoken( const OUString & inURL, | |||
1767 | const DAVRequestEnvironment & rEnv ) | |||
1768 | { | |||
1769 | NeonLock * theLock = m_aNeonLockStore.findByUri( inURL ); | |||
1770 | if ( !theLock ) | |||
1771 | return false; | |||
1772 | ||||
1773 | // do a lockdiscovery to check whether this lock is still valid. | |||
1774 | try | |||
1775 | { | |||
1776 | // @@@ Alternative: use ne_lock_discover() => less overhead | |||
1777 | ||||
1778 | std::vector< DAVResource > aResources; | |||
1779 | std::vector< OUString > aPropNames; | |||
1780 | aPropNames.push_back( DAVProperties::LOCKDISCOVERY ); | |||
1781 | ||||
1782 | PROPFIND( rEnv.m_aRequestURI, DAVZERO, aPropNames, aResources, rEnv ); | |||
1783 | ||||
1784 | if ( aResources.empty() ) | |||
1785 | return false; | |||
1786 | ||||
1787 | for ( const auto& rProp : aResources[ 0 ].properties ) | |||
1788 | { | |||
1789 | if ( rProp.Name == DAVProperties::LOCKDISCOVERY ) | |||
1790 | { | |||
1791 | uno::Sequence< ucb::Lock > aLocks; | |||
1792 | if ( !( rProp.Value >>= aLocks ) ) | |||
1793 | return false; | |||
1794 | ||||
1795 | if ( !containsLocktoken( aLocks, theLock->token ) ) | |||
1796 | { | |||
1797 | // expired! | |||
1798 | break; | |||
1799 | } | |||
1800 | ||||
1801 | // still valid. | |||
1802 | return false; | |||
1803 | } | |||
1804 | } | |||
1805 | ||||
1806 | // No lockdiscovery prop in propfind result / locktoken not found | |||
1807 | // in propfind result -> not locked | |||
1808 | SAL_WARN( "ucb.ucp.webdav", "Removing expired lock token for <" << inURLdo { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "Removing expired lock token for <" << inURL << "> token: " << theLock-> token) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1809" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Removing expired lock token for <" << inURL << "> token: " << theLock-> token), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Removing expired lock token for <" << inURL << "> token: " << theLock->token; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1809" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "Removing expired lock token for <" << inURL << "> token: " << theLock->token) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1809" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Removing expired lock token for <" << inURL << "> token: " << theLock-> token), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Removing expired lock token for <" << inURL << "> token: " << theLock->token; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1809" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
1809 | << "> token: " << theLock->token )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "Removing expired lock token for <" << inURL << "> token: " << theLock-> token) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1809" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Removing expired lock token for <" << inURL << "> token: " << theLock-> token), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Removing expired lock token for <" << inURL << "> token: " << theLock->token; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1809" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "Removing expired lock token for <" << inURL << "> token: " << theLock->token) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1809" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Removing expired lock token for <" << inURL << "> token: " << theLock-> token), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Removing expired lock token for <" << inURL << "> token: " << theLock->token; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1809" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1810 | ||||
1811 | m_aNeonLockStore.removeLock( theLock ); | |||
1812 | ne_lock_destroy( theLock ); | |||
1813 | return true; | |||
1814 | } | |||
1815 | catch ( DAVException const & ) | |||
1816 | { | |||
1817 | } | |||
1818 | return false; | |||
1819 | } | |||
1820 | ||||
1821 | // Common error handler | |||
1822 | void NeonSession::HandleError( int nError, | |||
1823 | const OUString & inPath, | |||
1824 | const DAVRequestEnvironment & rEnv ) | |||
1825 | { | |||
1826 | // Map error code to DAVException. | |||
1827 | switch ( nError ) | |||
1828 | { | |||
1829 | case NE_OK(0): | |||
1830 | return; | |||
1831 | ||||
1832 | case NE_ERROR(1): // Generic error | |||
1833 | { | |||
1834 | const char* sErr = ne_get_error(m_pHttpSession); | |||
1835 | OUString aText(sErr, strlen(sErr), osl_getThreadTextEncoding()); | |||
1836 | ||||
1837 | sal_uInt16 code = makeStatusCode( aText ); | |||
1838 | ||||
1839 | SAL_WARN( "ucb.ucp.webdav", "Neon returned NE_ERROR, http response status code was: " << code << " '" << aText << "'" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "Neon returned NE_ERROR, http response status code was: " << code << " '" << aText << "'") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1839" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Neon returned NE_ERROR, http response status code was: " << code << " '" << aText << "'"), 0) ; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Neon returned NE_ERROR, http response status code was: " << code << " '" << aText << "'"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1839" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "Neon returned NE_ERROR, http response status code was: " << code << " '" << aText << "'") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1839" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Neon returned NE_ERROR, http response status code was: " << code << " '" << aText << "'"), 0) ; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Neon returned NE_ERROR, http response status code was: " << code << " '" << aText << "'"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1839" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1840 | if ( SC_BAD_REQUEST <= code && code < SC_INTERNAL_SERVER_ERROR ) | |||
1841 | { | |||
1842 | // error codes in the range 4xx | |||
1843 | switch ( code ) | |||
1844 | { | |||
1845 | case SC_LOCKED: | |||
1846 | { | |||
1847 | if ( m_aNeonLockStore.findByUri( | |||
1848 | makeAbsoluteURL( inPath ) ) == nullptr ) | |||
1849 | { | |||
1850 | // locked by 3rd party | |||
1851 | throw DAVException( DAVException::DAV_LOCKED ); | |||
1852 | } | |||
1853 | else | |||
1854 | { | |||
1855 | // locked by ourself | |||
1856 | throw DAVException( DAVException::DAV_LOCKED_SELF ); | |||
1857 | } | |||
1858 | } | |||
1859 | break; | |||
1860 | case SC_PRECONDITION_FAILED: | |||
1861 | case SC_BAD_REQUEST: | |||
1862 | { | |||
1863 | // Special handling for 400 and 412 status codes, which may indicate | |||
1864 | // that a lock previously obtained by us has been released meanwhile | |||
1865 | // by the server. Unfortunately, RFC is not clear at this point, | |||
1866 | // thus server implementations behave different... | |||
1867 | if ( removeExpiredLocktoken( makeAbsoluteURL( inPath ), rEnv ) ) | |||
1868 | throw DAVException( DAVException::DAV_LOCK_EXPIRED ); | |||
1869 | } | |||
1870 | break; | |||
1871 | case SC_REQUEST_TIMEOUT: | |||
1872 | { | |||
1873 | throw DAVException( DAVException::DAV_HTTP_TIMEOUT, | |||
1874 | NeonUri::makeConnectionEndPointString( | |||
1875 | m_aHostName, m_nPort ) ); | |||
1876 | } | |||
1877 | break; | |||
1878 | case SC_UNAUTHORIZED: // User authentication failed on server | |||
1879 | { | |||
1880 | throw DAVException( DAVException::DAV_HTTP_AUTH, | |||
1881 | NeonUri::makeConnectionEndPointString( | |||
1882 | m_aHostName, m_nPort ) ); | |||
1883 | } | |||
1884 | break; | |||
1885 | case SC_GONE: | |||
1886 | case SC_LENGTH_REQUIRED: | |||
1887 | case SC_REQUEST_ENTITY_TOO_LARGE: | |||
1888 | case SC_REQUEST_URI_TOO_LONG: | |||
1889 | case SC_UNSUPPORTED_MEDIA_TYPE: | |||
1890 | case SC_REQUESTED_RANGE_NOT_SATISFIABLE: | |||
1891 | case SC_EXPECTATION_FAILED: | |||
1892 | case SC_UNPROCESSABLE_ENTITY: | |||
1893 | case SC_FAILED_DEPENDENCY: | |||
1894 | case SC_CONFLICT: | |||
1895 | case SC_NOT_ACCEPTABLE: | |||
1896 | case SC_PAYMENT_REQUIRED: | |||
1897 | case SC_PROXY_AUTHENTICATION_REQUIRED: | |||
1898 | default: | |||
1899 | // set 400 error, if not one of others | |||
1900 | code = SC_BAD_REQUEST; | |||
1901 | [[fallthrough]]; | |||
1902 | case SC_FORBIDDEN: | |||
1903 | case SC_NOT_FOUND: | |||
1904 | case SC_METHOD_NOT_ALLOWED: | |||
1905 | throw DAVException( DAVException::DAV_HTTP_ERROR, aText, code ); | |||
1906 | break; | |||
1907 | } | |||
1908 | } | |||
1909 | else if ( SC_INTERNAL_SERVER_ERROR <= code ) | |||
1910 | { | |||
1911 | // deal with HTTP response status codes higher then 500 | |||
1912 | // error codes in the range 5xx, server errors | |||
1913 | // but there exists unofficial code in the range 1000 and up | |||
1914 | // for example see: | |||
1915 | // <https://support.cloudflare.com/hc/en-us/sections/200820298-Error-Pages> (retrieved 2016-10-05) | |||
1916 | switch ( code ) | |||
1917 | { | |||
1918 | // the error codes case before the default case are not actively | |||
1919 | // managed by LO | |||
1920 | case SC_BAD_GATEWAY: | |||
1921 | case SC_SERVICE_UNAVAILABLE: | |||
1922 | case SC_GATEWAY_TIMEOUT: | |||
1923 | case SC_HTTP_VERSION_NOT_SUPPORTED: | |||
1924 | case SC_INSUFFICIENT_STORAGE: | |||
1925 | default: | |||
1926 | // set 500 error, if not one of others | |||
1927 | // expand the error code | |||
1928 | code = SC_INTERNAL_SERVER_ERROR; | |||
1929 | [[fallthrough]]; | |||
1930 | case SC_INTERNAL_SERVER_ERROR: | |||
1931 | case SC_NOT_IMPLEMENTED: | |||
1932 | throw DAVException( DAVException::DAV_HTTP_ERROR, aText, code ); | |||
1933 | break; | |||
1934 | } | |||
1935 | } | |||
1936 | else | |||
1937 | throw DAVException( DAVException::DAV_HTTP_ERROR, aText, code ); | |||
1938 | } | |||
1939 | break; | |||
1940 | case NE_LOOKUP(2): // Name lookup failed. | |||
1941 | SAL_WARN( "ucb.ucp.webdav", "Name lookup failed" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "Name lookup failed") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1941" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Name lookup failed"), 0); } else { :: std::ostringstream sal_detail_stream; sal_detail_stream << "Name lookup failed"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1941" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "Name lookup failed") == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1941" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Name lookup failed"), 0); } else { :: std::ostringstream sal_detail_stream; sal_detail_stream << "Name lookup failed"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1941" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1942 | throw DAVException( DAVException::DAV_HTTP_LOOKUP, | |||
1943 | NeonUri::makeConnectionEndPointString( | |||
1944 | m_aHostName, m_nPort ) ); | |||
1945 | ||||
1946 | case NE_AUTH(3): // User authentication failed on server | |||
1947 | // m_pHttpSession could get invalidated, e.g., as result of clean_session called in | |||
1948 | // ah_post_send in case when auth_challenge failed, which invalidates the auth_session | |||
1949 | // which we established in Init(): the auth_session's sspi_host gets disposed, and | |||
1950 | // next attempt to authenticate would crash in continue_sspi trying to dereference it | |||
1951 | m_bNeedNewSession = true; | |||
1952 | throw DAVException( DAVException::DAV_HTTP_AUTH, | |||
1953 | NeonUri::makeConnectionEndPointString( | |||
1954 | m_aHostName, m_nPort ) ); | |||
1955 | ||||
1956 | case NE_PROXYAUTH(4): // User authentication failed on proxy | |||
1957 | SAL_WARN( "ucb.ucp.webdav", "DAVException::DAV_HTTP_AUTHPROXY" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DAVException::DAV_HTTP_AUTHPROXY" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1957" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DAVException::DAV_HTTP_AUTHPROXY"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DAVException::DAV_HTTP_AUTHPROXY"; ::sal::detail:: log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1957" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DAVException::DAV_HTTP_AUTHPROXY") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1957" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DAVException::DAV_HTTP_AUTHPROXY"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DAVException::DAV_HTTP_AUTHPROXY"; ::sal::detail:: log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1957" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1958 | throw DAVException( DAVException::DAV_HTTP_AUTHPROXY, | |||
1959 | NeonUri::makeConnectionEndPointString( | |||
1960 | m_aProxyName, m_nProxyPort ) ); | |||
1961 | ||||
1962 | case NE_CONNECT(5): // Could not connect to server | |||
1963 | SAL_WARN( "ucb.ucp.webdav", "DAVException::DAV_HTTP_CONNECT" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DAVException::DAV_HTTP_CONNECT" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1963" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DAVException::DAV_HTTP_CONNECT"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DAVException::DAV_HTTP_CONNECT"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1963" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DAVException::DAV_HTTP_CONNECT") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1963" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DAVException::DAV_HTTP_CONNECT"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DAVException::DAV_HTTP_CONNECT"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1963" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1964 | throw DAVException( DAVException::DAV_HTTP_CONNECT, | |||
1965 | NeonUri::makeConnectionEndPointString( | |||
1966 | m_aHostName, m_nPort ) ); | |||
1967 | ||||
1968 | case NE_TIMEOUT(6): // Connection timed out | |||
1969 | SAL_WARN( "ucb.ucp.webdav", "DAVException::DAV_HTTP_TIMEOUT" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DAVException::DAV_HTTP_TIMEOUT" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1969" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DAVException::DAV_HTTP_TIMEOUT"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DAVException::DAV_HTTP_TIMEOUT"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1969" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DAVException::DAV_HTTP_TIMEOUT") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1969" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DAVException::DAV_HTTP_TIMEOUT"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DAVException::DAV_HTTP_TIMEOUT"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1969" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1970 | throw DAVException( DAVException::DAV_HTTP_TIMEOUT, | |||
1971 | NeonUri::makeConnectionEndPointString( | |||
1972 | m_aHostName, m_nPort ) ); | |||
1973 | ||||
1974 | case NE_FAILED(7): // The precondition failed | |||
1975 | SAL_WARN( "ucb.ucp.webdav", "The precondition failed" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "The precondition failed" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1975" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "The precondition failed"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "The precondition failed"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1975" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "The precondition failed") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1975" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "The precondition failed"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "The precondition failed"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1975" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1976 | throw DAVException( DAVException::DAV_HTTP_FAILED, | |||
1977 | NeonUri::makeConnectionEndPointString( | |||
1978 | m_aHostName, m_nPort ) ); | |||
1979 | ||||
1980 | case NE_RETRY(8): // Retry request (ne_end_request ONLY) | |||
1981 | throw DAVException( DAVException::DAV_HTTP_RETRY, | |||
1982 | NeonUri::makeConnectionEndPointString( | |||
1983 | m_aHostName, m_nPort ) ); | |||
1984 | ||||
1985 | case NE_REDIRECT(9): | |||
1986 | { | |||
1987 | NeonUri aUri( ne_redirect_location( m_pHttpSession ) ); | |||
1988 | SAL_INFO( "ucb.ucp.webdav", "DAVException::DAV_HTTP_REDIRECT: new URI: " << aUri.GetURI() )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DAVException::DAV_HTTP_REDIRECT: new URI: " << aUri.GetURI()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1988" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DAVException::DAV_HTTP_REDIRECT: new URI: " << aUri.GetURI()), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "DAVException::DAV_HTTP_REDIRECT: new URI: " << aUri.GetURI(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1988" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DAVException::DAV_HTTP_REDIRECT: new URI: " << aUri.GetURI()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1988" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DAVException::DAV_HTTP_REDIRECT: new URI: " << aUri.GetURI()), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "DAVException::DAV_HTTP_REDIRECT: new URI: " << aUri.GetURI(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1988" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1989 | throw DAVException( | |||
1990 | DAVException::DAV_HTTP_REDIRECT, aUri.GetURI() ); | |||
1991 | } | |||
1992 | default: | |||
1993 | { | |||
1994 | SAL_WARN( "ucb.ucp.webdav", "Unknown Neon error code!" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "Unknown Neon error code!" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav" ), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1994" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Unknown Neon error code!"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Unknown Neon error code!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1994" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "Unknown Neon error code!") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1994" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Unknown Neon error code!"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Unknown Neon error code!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "1994" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1995 | const char* sErr = ne_get_error(m_pHttpSession); | |||
1996 | throw DAVException( DAVException::DAV_HTTP_ERROR, | |||
1997 | OUString(sErr, strlen(sErr), osl_getThreadTextEncoding()) ); | |||
1998 | } | |||
1999 | } | |||
2000 | } | |||
2001 | ||||
2002 | namespace { | |||
2003 | ||||
2004 | void runResponseHeaderHandler( void * userdata, | |||
2005 | const char * value ) | |||
2006 | { | |||
2007 | OUString aHeader(value, strlen(value), RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11))); | |||
2008 | sal_Int32 nPos = aHeader.indexOf( ':' ); | |||
2009 | ||||
2010 | if ( nPos == -1 ) | |||
2011 | return; | |||
2012 | ||||
2013 | OUString aHeaderName( aHeader.copy( 0, nPos ) ); | |||
2014 | ||||
2015 | NeonRequestContext * pCtx | |||
2016 | = static_cast< NeonRequestContext * >( userdata ); | |||
2017 | ||||
2018 | // Note: Empty vector means that all headers are requested. | |||
2019 | bool bIncludeIt = pCtx->pHeaderNames->empty(); | |||
2020 | ||||
2021 | if ( !bIncludeIt ) | |||
2022 | { | |||
2023 | // Check whether this header was requested. | |||
2024 | auto it = std::find_if(pCtx->pHeaderNames->cbegin(), pCtx->pHeaderNames->cend(), | |||
2025 | [&aHeaderName](const OUString& rName) { | |||
2026 | // header names are case insensitive | |||
2027 | return rName.equalsIgnoreAsciiCase( aHeaderName ); }); | |||
2028 | ||||
2029 | if ( it != pCtx->pHeaderNames->end() ) | |||
2030 | { | |||
2031 | aHeaderName = *it; | |||
2032 | bIncludeIt = true; | |||
2033 | } | |||
2034 | } | |||
2035 | ||||
2036 | if ( !bIncludeIt ) | |||
2037 | return; | |||
2038 | ||||
2039 | // Create & set the PropertyValue | |||
2040 | DAVPropertyValue thePropertyValue; | |||
2041 | // header names are case insensitive, so are the | |||
2042 | // corresponding property names. | |||
2043 | thePropertyValue.Name = aHeaderName.toAsciiLowerCase(); | |||
2044 | thePropertyValue.IsCaseSensitive = false; | |||
2045 | ||||
2046 | if ( nPos < aHeader.getLength() ) | |||
2047 | thePropertyValue.Value <<= aHeader.copy( nPos + 1 ).trim(); | |||
2048 | ||||
2049 | // Add the newly created PropertyValue | |||
2050 | pCtx->pResource->properties.push_back( thePropertyValue ); | |||
2051 | } | |||
2052 | ||||
2053 | } // namespace | |||
2054 | ||||
2055 | int NeonSession::GET( ne_session * sess, | |||
2056 | const char * uri, | |||
2057 | ne_block_reader reader, | |||
2058 | bool getheaders, | |||
2059 | void * userdata ) | |||
2060 | { | |||
2061 | //struct get_context ctx; | |||
2062 | ne_request * req = ne_request_create( sess, "GET", uri ); | |||
2063 | int ret; | |||
2064 | ||||
2065 | ne_decompress * dc | |||
2066 | = ne_decompress_reader( req, ne_accept_2xx, reader, userdata ); | |||
2067 | ||||
2068 | { | |||
2069 | osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); | |||
2070 | ret = ne_request_dispatch( req ); | |||
2071 | } | |||
2072 | ||||
2073 | if ( getheaders ) | |||
2074 | { | |||
2075 | void *cursor = nullptr; | |||
2076 | const char *name, *value; | |||
2077 | while ( ( cursor = ne_response_header_iterate( | |||
2078 | req, cursor, &name, &value ) ) != nullptr ) | |||
2079 | { | |||
2080 | char buffer[8192]; | |||
2081 | ||||
2082 | SAL_INFO( "ucb.ucp.webdav", "GET - received header: " << name << ": " << value )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "GET - received header: " << name << ": " << value) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "2082" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "GET - received header: " << name << ": " << value), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "GET - received header: " << name << ": " << value; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "2082" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "GET - received header: " << name << ": " << value) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "2082" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "GET - received header: " << name << ": " << value), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "GET - received header: " << name << ": " << value; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "2082" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
2083 | ne_snprintf(buffer, sizeof buffer, "%s: %s", name, value); | |||
2084 | runResponseHeaderHandler(userdata, buffer); | |||
2085 | } | |||
2086 | } | |||
2087 | ||||
2088 | if ( ret == NE_OK(0) && ne_get_status( req )->klass != 2 ) | |||
2089 | ret = NE_ERROR(1); | |||
2090 | ||||
2091 | if ( dc != nullptr ) | |||
2092 | ne_decompress_destroy(dc); | |||
2093 | ||||
2094 | ne_request_destroy( req ); | |||
2095 | return ret; | |||
2096 | } | |||
2097 | ||||
2098 | int NeonSession::GET0( ne_session * sess, | |||
2099 | const char * uri, | |||
2100 | bool getheaders, | |||
2101 | void * userdata ) | |||
2102 | { | |||
2103 | //struct get_context ctx; | |||
2104 | ne_request * req = ne_request_create( sess, "GET", uri ); | |||
2105 | int ret; | |||
2106 | ||||
2107 | { | |||
2108 | osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); | |||
2109 | ret = ne_request_dispatch( req ); | |||
2110 | } | |||
2111 | ||||
2112 | if ( getheaders ) | |||
2113 | { | |||
2114 | void *cursor = nullptr; | |||
2115 | const char *name, *value; | |||
2116 | while ( ( cursor = ne_response_header_iterate( | |||
2117 | req, cursor, &name, &value ) ) != nullptr ) | |||
2118 | { | |||
2119 | char buffer[8192]; | |||
2120 | ||||
2121 | SAL_INFO( "ucb.ucp.webdav", "GET - received header: " << name << ": " << value )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "ucb.ucp.webdav")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "GET - received header: " << name << ": " << value) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "2121" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "GET - received header: " << name << ": " << value), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "GET - received header: " << name << ": " << value; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "2121" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "GET - received header: " << name << ": " << value) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "2121" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "GET - received header: " << name << ": " << value), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "GET - received header: " << name << ": " << value; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("ucb.ucp.webdav"), ("/home/maarten/src/libreoffice/core/ucb/source/ucp/webdav-neon/NeonSession.cxx" ":" "2121" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
2122 | ne_snprintf(buffer, sizeof buffer, "%s: %s", name, value); | |||
2123 | runResponseHeaderHandler(userdata, buffer); | |||
2124 | } | |||
2125 | } | |||
2126 | ||||
2127 | if ( ret == NE_OK(0) && ne_get_status( req )->klass != 2 ) | |||
2128 | ret = NE_ERROR(1); | |||
2129 | ||||
2130 | ne_request_destroy( req ); | |||
2131 | return ret; | |||
2132 | } | |||
2133 | ||||
2134 | int NeonSession::PUT( ne_session * sess, | |||
2135 | const char * uri, | |||
2136 | const char * buffer, | |||
2137 | size_t size) | |||
2138 | { | |||
2139 | ne_request * req = ne_request_create( sess, "PUT", uri ); | |||
2140 | int ret; | |||
2141 | ||||
2142 | // tdf#99246 | |||
2143 | // extract the path of uri | |||
2144 | // ne_lock_using_resource below compares path, ignores all the rest. | |||
2145 | // in case of Web proxy active, this function uri parameter is instead absolute | |||
2146 | ne_uri aUri; | |||
2147 | ne_uri_parse( uri, &aUri ); | |||
2148 | ne_lock_using_resource( req, aUri.path, 0 ); | |||
2149 | ne_lock_using_parent( req, uri ); | |||
2150 | ||||
2151 | ne_set_request_body_buffer( req, buffer, size ); | |||
2152 | ||||
2153 | { | |||
2154 | osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); | |||
2155 | ret = ne_request_dispatch( req ); | |||
2156 | } | |||
2157 | ||||
2158 | if ( ret == NE_OK(0) && ne_get_status( req )->klass != 2 ) | |||
2159 | ret = NE_ERROR(1); | |||
2160 | ||||
2161 | ne_request_destroy( req ); | |||
2162 | return ret; | |||
2163 | } | |||
2164 | ||||
2165 | int NeonSession::POST( ne_session * sess, | |||
2166 | const char * uri, | |||
2167 | const char * buffer, | |||
2168 | ne_block_reader reader, | |||
2169 | void * userdata, | |||
2170 | const OUString & rContentType, | |||
2171 | const OUString & rReferer ) | |||
2172 | { | |||
2173 | ne_request * req = ne_request_create( sess, "POST", uri ); | |||
2174 | //struct get_context ctx; | |||
2175 | int ret; | |||
2176 | ||||
2177 | RequestDataMap * pData = nullptr; | |||
2178 | ||||
2179 | if ( !rContentType.isEmpty() || !rReferer.isEmpty() ) | |||
2180 | { | |||
2181 | // Remember contenttype and referer. Data will be added to HTTP request | |||
2182 | // header in 'PreSendRequest' callback. | |||
2183 | pData = static_cast< RequestDataMap* >( m_pRequestData ); | |||
2184 | (*pData)[ req ] = RequestData( rContentType, rReferer ); | |||
2185 | } | |||
2186 | ||||
2187 | //ctx.total = -1; | |||
2188 | //ctx.fd = fd; | |||
2189 | //ctx.error = 0; | |||
2190 | //ctx.session = sess; | |||
2191 | ||||
2192 | ///* Read the value of the Content-Length header into ctx.total */ | |||
2193 | //ne_add_response_header_handler( req, "Content-Length", | |||
2194 | // ne_handle_numeric_header, &ctx.total ); | |||
2195 | ||||
2196 | ne_add_response_body_reader( req, ne_accept_2xx, reader, userdata ); | |||
2197 | ||||
2198 | ne_set_request_body_buffer( req, buffer, strlen( buffer ) ); | |||
2199 | ||||
2200 | { | |||
2201 | osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); | |||
2202 | ret = ne_request_dispatch( req ); | |||
2203 | } | |||
2204 | ||||
2205 | //if ( ctx.error ) | |||
2206 | // ret = NE_ERROR; | |||
2207 | //else | |||
2208 | if ( ret == NE_OK(0) && ne_get_status( req )->klass != 2 ) | |||
2209 | ret = NE_ERROR(1); | |||
2210 | ||||
2211 | ne_request_destroy( req ); | |||
2212 | ||||
2213 | if ( pData ) | |||
2214 | { | |||
2215 | // Remove request data from session's list. | |||
2216 | RequestDataMap::iterator it = pData->find( req ); | |||
2217 | if ( it != pData->end() ) | |||
2218 | pData->erase( it ); | |||
2219 | } | |||
2220 | ||||
2221 | return ret; | |||
2222 | } | |||
2223 | ||||
2224 | bool | |||
2225 | NeonSession::getDataFromInputStream( | |||
2226 | const uno::Reference< io::XInputStream > & xStream, | |||
2227 | uno::Sequence< sal_Int8 > & rData, | |||
2228 | bool bAppendTrailingZeroByte ) | |||
2229 | { | |||
2230 | if ( xStream.is() ) | |||
2231 | { | |||
2232 | uno::Reference< io::XSeekable > xSeekable( xStream, uno::UNO_QUERY ); | |||
2233 | if ( xSeekable.is() ) | |||
2234 | { | |||
2235 | try | |||
2236 | { | |||
2237 | sal_Int32 nSize | |||
2238 | = sal::static_int_cast<sal_Int32>(xSeekable->getLength()); | |||
2239 | sal_Int32 nRead | |||
2240 | = xStream->readBytes( rData, nSize ); | |||
2241 | ||||
2242 | if ( nRead == nSize ) | |||
2243 | { | |||
2244 | if ( bAppendTrailingZeroByte ) | |||
2245 | { | |||
2246 | rData.realloc( nSize + 1 ); | |||
2247 | rData[ nSize ] = sal_Int8( 0 ); | |||
2248 | } | |||
2249 | return true; | |||
2250 | } | |||
2251 | } | |||
2252 | catch ( io::NotConnectedException const & ) | |||
2253 | { | |||
2254 | // readBytes | |||
2255 | } | |||
2256 | catch ( io::BufferSizeExceededException const & ) | |||
2257 | { | |||
2258 | // readBytes | |||
2259 | } | |||
2260 | catch ( io::IOException const & ) | |||
2261 | { | |||
2262 | // getLength, readBytes | |||
2263 | } | |||
2264 | } | |||
2265 | else | |||
2266 | { | |||
2267 | try | |||
2268 | { | |||
2269 | uno::Sequence< sal_Int8 > aBuffer; | |||
2270 | sal_Int32 nPos = 0; | |||
2271 | ||||
2272 | sal_Int32 nRead = xStream->readSomeBytes( aBuffer, 65536 ); | |||
2273 | while ( nRead > 0 ) | |||
2274 | { | |||
2275 | if ( rData.getLength() < ( nPos + nRead ) ) | |||
2276 | rData.realloc( nPos + nRead ); | |||
2277 | ||||
2278 | aBuffer.realloc( nRead ); | |||
2279 | memcpy( static_cast<void*>( rData.getArray() + nPos ), | |||
2280 | static_cast<const void*>(aBuffer.getConstArray()), | |||
2281 | nRead ); | |||
2282 | nPos += nRead; | |||
2283 | ||||
2284 | aBuffer.realloc( 0 ); | |||
2285 | nRead = xStream->readSomeBytes( aBuffer, 65536 ); | |||
2286 | } | |||
2287 | ||||
2288 | if ( bAppendTrailingZeroByte ) | |||
2289 | { | |||
2290 | rData.realloc( nPos + 1 ); | |||
2291 | rData[ nPos ] = sal_Int8( 0 ); | |||
2292 | } | |||
2293 | return true; | |||
2294 | } | |||
2295 | catch ( io::NotConnectedException const & ) | |||
2296 | { | |||
2297 | // readBytes | |||
2298 | } | |||
2299 | catch ( io::BufferSizeExceededException const & ) | |||
2300 | { | |||
2301 | // readBytes | |||
2302 | } | |||
2303 | catch ( io::IOException const & ) | |||
2304 | { | |||
2305 | // readBytes | |||
2306 | } | |||
2307 | } | |||
2308 | } | |||
2309 | return false; | |||
2310 | } | |||
2311 | ||||
2312 | bool | |||
2313 | NeonSession::isDomainMatch( const OUString& certHostName ) | |||
2314 | { | |||
2315 | OUString hostName = getHostName(); | |||
2316 | ||||
2317 | if (hostName.equalsIgnoreAsciiCase( certHostName ) ) | |||
2318 | return true; | |||
2319 | ||||
2320 | if ( certHostName.startsWith( "*" ) && | |||
2321 | hostName.getLength() >= certHostName.getLength() ) | |||
2322 | { | |||
2323 | OUString cmpStr = certHostName.copy( 1 ); | |||
2324 | ||||
2325 | if ( hostName.matchIgnoreAsciiCase( | |||
2326 | cmpStr, hostName.getLength() - cmpStr.getLength() ) ) | |||
2327 | return true; | |||
2328 | } | |||
2329 | return false; | |||
2330 | } | |||
2331 | ||||
2332 | OUString NeonSession::makeAbsoluteURL( OUString const & rURL ) const | |||
2333 | { | |||
2334 | try | |||
2335 | { | |||
2336 | // Is URL relative or already absolute? | |||
2337 | if ( !rURL.isEmpty() && rURL[ 0 ] != '/' ) | |||
2338 | { | |||
2339 | // absolute. | |||
2340 | return rURL; | |||
2341 | } | |||
2342 | else | |||
2343 | { | |||
2344 | ne_uri aUri = {}; | |||
2345 | ||||
2346 | ne_fill_server_uri( m_pHttpSession, &aUri ); | |||
2347 | aUri.path | |||
2348 | = ne_strdup( OUStringToOString( | |||
2349 | rURL, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ).getStr() ); | |||
2350 | NeonUri aNeonUri( &aUri ); | |||
2351 | ne_uri_free( &aUri ); | |||
2352 | return aNeonUri.GetURI(); | |||
2353 | } | |||
2354 | } | |||
2355 | catch ( DAVException const & ) | |||
2356 | { | |||
2357 | } | |||
2358 | // error. | |||
2359 | return OUString(); | |||
2360 | } | |||
2361 | ||||
2362 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_RTL_REF_HXX | ||||||
21 | #define INCLUDED_RTL_REF_HXX | ||||||
22 | |||||||
23 | #include "sal/config.h" | ||||||
24 | |||||||
25 | #include <cassert> | ||||||
26 | #include <cstddef> | ||||||
27 | #include <functional> | ||||||
28 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||
29 | #include <type_traits> | ||||||
30 | #endif | ||||||
31 | |||||||
32 | #include "sal/types.h" | ||||||
33 | |||||||
34 | namespace rtl | ||||||
35 | { | ||||||
36 | |||||||
37 | /** Template reference class for reference type. | ||||||
38 | */ | ||||||
39 | template <class reference_type> | ||||||
40 | class Reference | ||||||
41 | { | ||||||
42 | /** The <b>reference_type</b> body pointer. | ||||||
43 | */ | ||||||
44 | reference_type * m_pBody; | ||||||
45 | |||||||
46 | |||||||
47 | public: | ||||||
48 | /** Constructor... | ||||||
49 | */ | ||||||
50 | Reference() | ||||||
51 | : m_pBody (NULL__null) | ||||||
52 | {} | ||||||
53 | |||||||
54 | |||||||
55 | /** Constructor... | ||||||
56 | */ | ||||||
57 | Reference (reference_type * pBody, __sal_NoAcquire) | ||||||
58 | : m_pBody (pBody) | ||||||
59 | { | ||||||
60 | } | ||||||
61 | |||||||
62 | /** Constructor... | ||||||
63 | */ | ||||||
64 | Reference (reference_type * pBody) | ||||||
65 | : m_pBody (pBody) | ||||||
66 | { | ||||||
67 | if (m_pBody) | ||||||
68 | m_pBody->acquire(); | ||||||
69 | } | ||||||
70 | |||||||
71 | /** Copy constructor... | ||||||
72 | */ | ||||||
73 | Reference (const Reference<reference_type> & handle) | ||||||
74 | : m_pBody (handle.m_pBody) | ||||||
75 | { | ||||||
76 | if (m_pBody) | ||||||
77 | m_pBody->acquire(); | ||||||
78 | } | ||||||
79 | |||||||
80 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||
81 | /** Move constructor... | ||||||
82 | */ | ||||||
83 | Reference (Reference<reference_type> && handle) noexcept | ||||||
84 | : m_pBody (handle.m_pBody) | ||||||
85 | { | ||||||
86 | handle.m_pBody = nullptr; | ||||||
87 | } | ||||||
88 | #endif | ||||||
89 | |||||||
90 | #if defined LIBO_INTERNAL_ONLY1 | ||||||
91 | /** Up-casting conversion constructor: Copies interface reference. | ||||||
92 | |||||||
93 | Does not work for up-casts to ambiguous bases. | ||||||
94 | |||||||
95 | @param rRef another reference | ||||||
96 | */ | ||||||
97 | template< class derived_type > | ||||||
98 | inline Reference( | ||||||
99 | const Reference< derived_type > & rRef, | ||||||
100 | std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 ) | ||||||
101 | : m_pBody (rRef.get()) | ||||||
102 | { | ||||||
103 | if (m_pBody) | ||||||
104 | m_pBody->acquire(); | ||||||
105 | } | ||||||
106 | #endif | ||||||
107 | |||||||
108 | /** Destructor... | ||||||
109 | */ | ||||||
110 | ~Reference() COVERITY_NOEXCEPT_FALSE | ||||||
111 | { | ||||||
112 | if (m_pBody
| ||||||
113 | m_pBody->release(); | ||||||
114 | } | ||||||
115 | |||||||
116 | /** Set... | ||||||
117 | Similar to assignment. | ||||||
118 | */ | ||||||
119 | Reference<reference_type> & | ||||||
120 | SAL_CALL set (reference_type * pBody) | ||||||
121 | { | ||||||
122 | if (pBody) | ||||||
123 | pBody->acquire(); | ||||||
124 | reference_type * const pOld = m_pBody; | ||||||
125 | m_pBody = pBody; | ||||||
126 | if (pOld) | ||||||
127 | pOld->release(); | ||||||
128 | return *this; | ||||||
129 | } | ||||||
130 | |||||||
131 | /** Assignment. | ||||||
132 | Unbinds this instance from its body (if bound) and | ||||||
133 | bind it to the body represented by the handle. | ||||||
134 | */ | ||||||
135 | Reference<reference_type> & | ||||||
136 | SAL_CALL operator= (const Reference<reference_type> & handle) | ||||||
137 | { | ||||||
138 | return set( handle.m_pBody ); | ||||||
139 | } | ||||||
140 | |||||||
141 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||
142 | /** Assignment. | ||||||
143 | * Unbinds this instance from its body (if bound), | ||||||
144 | * bind it to the body represented by the handle, and | ||||||
145 | * set the body represented by the handle to nullptr. | ||||||
146 | */ | ||||||
147 | Reference<reference_type> & | ||||||
148 | operator= (Reference<reference_type> && handle) | ||||||
149 | { | ||||||
150 | // self-movement guts ourself | ||||||
151 | if (m_pBody) | ||||||
152 | m_pBody->release(); | ||||||
153 | m_pBody = handle.m_pBody; | ||||||
154 | handle.m_pBody = nullptr; | ||||||
155 | return *this; | ||||||
156 | } | ||||||
157 | #endif | ||||||
158 | |||||||
159 | /** Assignment... | ||||||
160 | */ | ||||||
161 | Reference<reference_type> & | ||||||
162 | SAL_CALL operator= (reference_type * pBody) | ||||||
163 | { | ||||||
164 | return set( pBody ); | ||||||
165 | } | ||||||
166 | |||||||
167 | /** Unbind the body from this handle. | ||||||
168 | Note that for a handle representing a large body, | ||||||
169 | "handle.clear().set(new body());" _might_ | ||||||
170 | perform a little bit better than "handle.set(new body());", | ||||||
171 | since in the second case two large objects exist in memory | ||||||
172 | (the old body and the new body). | ||||||
173 | */ | ||||||
174 | Reference<reference_type> & SAL_CALL clear() | ||||||
175 | { | ||||||
176 | if (m_pBody) | ||||||
177 | { | ||||||
178 | reference_type * const pOld = m_pBody; | ||||||
179 | m_pBody = NULL__null; | ||||||
180 | pOld->release(); | ||||||
181 | } | ||||||
182 | return *this; | ||||||
183 | } | ||||||
184 | |||||||
185 | |||||||
186 | /** Get the body. Can be used instead of operator->(). | ||||||
187 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() | ||||||
188 | are the same. | ||||||
189 | */ | ||||||
190 | reference_type * SAL_CALL get() const | ||||||
191 | { | ||||||
192 | return m_pBody; | ||||||
193 | } | ||||||
194 | |||||||
195 | |||||||
196 | /** Probably most common used: handle->someBodyOp(). | ||||||
197 | */ | ||||||
198 | reference_type * SAL_CALL operator->() const | ||||||
199 | { | ||||||
200 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 200, __extension__ __PRETTY_FUNCTION__)); | ||||||
201 | return m_pBody; | ||||||
202 | } | ||||||
203 | |||||||
204 | |||||||
205 | /** Allows (*handle).someBodyOp(). | ||||||
206 | */ | ||||||
207 | reference_type & SAL_CALL operator*() const | ||||||
208 | { | ||||||
209 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 209, __extension__ __PRETTY_FUNCTION__)); | ||||||
210 | return *m_pBody; | ||||||
211 | } | ||||||
212 | |||||||
213 | |||||||
214 | /** Returns True if the handle does point to a valid body. | ||||||
215 | */ | ||||||
216 | bool SAL_CALL is() const | ||||||
217 | { | ||||||
218 | return (m_pBody != NULL__null); | ||||||
219 | } | ||||||
220 | |||||||
221 | #if defined LIBO_INTERNAL_ONLY1 | ||||||
222 | /** Returns True if the handle does point to a valid body. | ||||||
223 | */ | ||||||
224 | explicit operator bool() const | ||||||
225 | { | ||||||
226 | return is(); | ||||||
227 | } | ||||||
228 | #endif | ||||||
229 | |||||||
230 | /** Returns True if this points to pBody. | ||||||
231 | */ | ||||||
232 | bool SAL_CALL operator== (const reference_type * pBody) const | ||||||
233 | { | ||||||
234 | return (m_pBody == pBody); | ||||||
235 | } | ||||||
236 | |||||||
237 | |||||||
238 | /** Returns True if handle points to the same body. | ||||||
239 | */ | ||||||
240 | bool | ||||||
241 | SAL_CALL operator== (const Reference<reference_type> & handle) const | ||||||
242 | { | ||||||
243 | return (m_pBody == handle.m_pBody); | ||||||
244 | } | ||||||
245 | |||||||
246 | |||||||
247 | /** Needed to place References into STL collection. | ||||||
248 | */ | ||||||
249 | bool | ||||||
250 | SAL_CALL operator!= (const Reference<reference_type> & handle) const | ||||||
251 | { | ||||||
252 | return (m_pBody != handle.m_pBody); | ||||||
253 | } | ||||||
254 | |||||||
255 | |||||||
256 | /** Needed to place References into STL collection. | ||||||
257 | */ | ||||||
258 | bool | ||||||
259 | SAL_CALL operator< (const Reference<reference_type> & handle) const | ||||||
260 | { | ||||||
261 | return (m_pBody < handle.m_pBody); | ||||||
262 | } | ||||||
263 | |||||||
264 | |||||||
265 | /** Needed to place References into STL collection. | ||||||
266 | */ | ||||||
267 | bool | ||||||
268 | SAL_CALL operator> (const Reference<reference_type> & handle) const | ||||||
269 | { | ||||||
270 | return (m_pBody > handle.m_pBody); | ||||||
271 | } | ||||||
272 | }; | ||||||
273 | |||||||
274 | } // namespace rtl | ||||||
275 | |||||||
276 | #if defined LIBO_INTERNAL_ONLY1 | ||||||
277 | namespace std | ||||||
278 | { | ||||||
279 | |||||||
280 | /// @cond INTERNAL | ||||||
281 | /** | ||||||
282 | Make rtl::Reference hashable by default for use in STL containers. | ||||||
283 | |||||||
284 | @since LibreOffice 6.3 | ||||||
285 | */ | ||||||
286 | template<typename T> | ||||||
287 | struct hash<::rtl::Reference<T>> | ||||||
288 | { | ||||||
289 | std::size_t operator()(::rtl::Reference<T> const & s) const | ||||||
290 | { return std::size_t(s.get()); } | ||||||
291 | }; | ||||||
292 | /// @endcond | ||||||
293 | |||||||
294 | } | ||||||
295 | |||||||
296 | #endif | ||||||
297 | |||||||
298 | #endif /* ! INCLUDED_RTL_REF_HXX */ | ||||||
299 | |||||||
300 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | /************************************************************************* |
3 | * |
4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 | * |
6 | * Copyright 2000, 2010 Oracle and/or its affiliates. |
7 | * |
8 | * OpenOffice.org - a multi-platform office productivity suite |
9 | * |
10 | * This file is part of OpenOffice.org. |
11 | * |
12 | * OpenOffice.org is free software: you can redistribute it and/or modify |
13 | * it under the terms of the GNU Lesser General Public License version 3 |
14 | * only, as published by the Free Software Foundation. |
15 | * |
16 | * OpenOffice.org is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | * GNU Lesser General Public License version 3 for more details |
20 | * (a copy is included in the LICENSE file that accompanied this code). |
21 | * |
22 | * You should have received a copy of the GNU Lesser General Public License |
23 | * version 3 along with OpenOffice.org. If not, see |
24 | * <http://www.openoffice.org/license.html> |
25 | * for a copy of the LGPLv3 License. |
26 | * |
27 | ************************************************************************/ |
28 | |
29 | #ifndef INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_DAVSESSION_HXX |
30 | #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_DAVSESSION_HXX |
31 | |
32 | #include <config_lgpl.h> |
33 | #include <memory> |
34 | #include <rtl/ustring.hxx> |
35 | #include <com/sun/star/io/XInputStream.hpp> |
36 | #include <com/sun/star/io/XOutputStream.hpp> |
37 | #include "DAVProperties.hxx" |
38 | #include "DAVResource.hxx" |
39 | #include "DAVSessionFactory.hxx" |
40 | #include "DAVTypes.hxx" |
41 | #include "DAVRequestEnvironment.hxx" |
42 | |
43 | namespace com::sun::star::beans { |
44 | struct NamedValue; |
45 | } |
46 | |
47 | namespace com::sun::star::ucb { |
48 | struct Lock; |
49 | } |
50 | |
51 | namespace webdav_ucp |
52 | { |
53 | |
54 | class DAVSession |
55 | { |
56 | public: |
57 | void acquire() |
58 | { |
59 | osl_atomic_increment( &m_nRefCount )__sync_add_and_fetch((&m_nRefCount), 1); |
60 | } |
61 | |
62 | void release() |
63 | { |
64 | if ( osl_atomic_decrement( &m_nRefCount )__sync_sub_and_fetch((&m_nRefCount), 1) == 0 ) |
65 | { |
66 | m_xFactory->releaseElement( this ); |
67 | delete this; |
68 | } |
69 | } |
70 | |
71 | virtual bool CanUse( const OUString & inPath, |
72 | const css::uno::Sequence< css::beans::NamedValue >& rFlags ) = 0; |
73 | |
74 | virtual bool UsesProxy() = 0; |
75 | |
76 | // DAV methods |
77 | |
78 | /// @throws std::exception |
79 | virtual void OPTIONS( const OUString & inPath, |
80 | DAVOptions& rOptions, |
81 | const DAVRequestEnvironment & rEnv ) = 0; |
82 | |
83 | // allprop & named |
84 | /// @throws std::exception |
85 | virtual void PROPFIND( const OUString & inPath, |
86 | const Depth inDepth, |
87 | const std::vector< OUString > & inPropertyNames, |
88 | std::vector< DAVResource > & ioResources, |
89 | const DAVRequestEnvironment & rEnv ) = 0; |
90 | |
91 | // propnames |
92 | /// @throws std::exception |
93 | virtual void PROPFIND( const OUString & inPath, |
94 | const Depth inDepth, |
95 | std::vector< DAVResourceInfo > & ioResInfo, |
96 | const DAVRequestEnvironment & rEnv ) = 0; |
97 | |
98 | /// @throws std::exception |
99 | virtual void PROPPATCH( const OUString & inPath, |
100 | const std::vector< ProppatchValue > & inValues, |
101 | const DAVRequestEnvironment & rEnv ) = 0; |
102 | |
103 | /// @throws std::exception |
104 | virtual void HEAD( const OUString & inPath, |
105 | const std::vector< OUString > & inHeaderNames, |
106 | DAVResource & ioResource, |
107 | const DAVRequestEnvironment & rEnv ) = 0; |
108 | |
109 | /// @throws std::exception |
110 | virtual css::uno::Reference< css::io::XInputStream > |
111 | GET( const OUString & inPath, |
112 | const DAVRequestEnvironment & rEnv ) = 0; |
113 | |
114 | /// @throws std::exception |
115 | virtual void GET( const OUString & inPath, |
116 | css::uno::Reference< css::io::XOutputStream >& o, |
117 | const DAVRequestEnvironment & rEnv ) = 0; |
118 | |
119 | /// @throws std::exception |
120 | virtual css::uno::Reference< css::io::XInputStream > |
121 | GET( const OUString & inPath, |
122 | const std::vector< OUString > & inHeaderNames, |
123 | DAVResource & ioResource, |
124 | const DAVRequestEnvironment & rEnv ) = 0; |
125 | |
126 | // used as HEAD substitute when HEAD is not implemented on server |
127 | /// @throws std::exception |
128 | virtual void |
129 | GET0( const OUString & inPath, |
130 | const std::vector< OUString > & inHeaderNames, |
131 | DAVResource & ioResource, |
132 | const DAVRequestEnvironment & rEnv ) = 0; |
133 | |
134 | /// @throws std::exception |
135 | virtual void |
136 | GET( const OUString & inPath, |
137 | css::uno::Reference< css::io::XOutputStream >& o, |
138 | const std::vector< OUString > & inHeaderNames, |
139 | DAVResource & ioResource, |
140 | const DAVRequestEnvironment & rEnv ) = 0; |
141 | |
142 | /// @throws std::exception |
143 | virtual void PUT( const OUString & inPath, |
144 | const css::uno::Reference< css::io::XInputStream >& s, |
145 | const DAVRequestEnvironment & rEnv ) = 0; |
146 | |
147 | /// @throws std::exception |
148 | virtual css::uno::Reference< css::io::XInputStream > |
149 | POST( const OUString & inPath, |
150 | const OUString & rContentType, |
151 | const OUString & rReferer, |
152 | const css::uno::Reference< css::io::XInputStream > & inInputStream, |
153 | const DAVRequestEnvironment & rEnv ) = 0; |
154 | |
155 | /// @throws std::exception |
156 | virtual void POST( const OUString & inPath, |
157 | const OUString & rContentType, |
158 | const OUString & rReferer, |
159 | const css::uno::Reference< css::io::XInputStream > & inInputStream, |
160 | css::uno::Reference< css::io::XOutputStream > & oOutputStream, |
161 | const DAVRequestEnvironment & rEnv ) = 0; |
162 | |
163 | /// @throws std::exception |
164 | virtual void MKCOL( const OUString & inPath, |
165 | const DAVRequestEnvironment & rEnv ) = 0; |
166 | |
167 | /// @throws std::exception |
168 | virtual void COPY( const OUString & inSource, |
169 | const OUString & inDestination, |
170 | const DAVRequestEnvironment & rEnv, |
171 | bool inOverwrite ) = 0; |
172 | |
173 | /// @throws std::exception |
174 | virtual void MOVE( const OUString & inSource, |
175 | const OUString & inDestination, |
176 | const DAVRequestEnvironment & rEnv, |
177 | bool inOverwrite ) = 0; |
178 | |
179 | /// @throws std::exception |
180 | virtual void DESTROY( const OUString & inPath, |
181 | const DAVRequestEnvironment & rEnv ) = 0; |
182 | |
183 | // set new lock. |
184 | /// @throws std::exception |
185 | virtual void LOCK( const OUString & inPath, |
186 | css::ucb::Lock & inLock, |
187 | const DAVRequestEnvironment & rEnv ) = 0; |
188 | |
189 | /// @throws std::exception |
190 | virtual void UNLOCK( const OUString & inPath, |
191 | const DAVRequestEnvironment & rEnv ) = 0; |
192 | |
193 | /// @throws std::exception |
194 | virtual void abort() = 0; |
195 | |
196 | protected: |
197 | rtl::Reference< DAVSessionFactory > m_xFactory; |
198 | |
199 | explicit DAVSession( rtl::Reference< DAVSessionFactory > const & rFactory ) |
200 | : m_xFactory( rFactory ), m_nRefCount( 0 ) {} |
201 | |
202 | virtual ~DAVSession() {} |
203 | |
204 | private: |
205 | DAVSessionFactory::Map::iterator m_aContainerIt; |
206 | oslInterlockedCount m_nRefCount; |
207 | |
208 | friend class DAVSessionFactory; |
209 | friend struct std::default_delete< DAVSession >; |
210 | }; |
211 | |
212 | } // namespace webdav_ucp |
213 | |
214 | #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_DAVSESSION_HXX |
215 | |
216 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |