1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 #include <apr_errno.h>
24 #include <apr_pools.h>
28 #include "DAVTypes.hxx"
29 #include "DAVResource.hxx"
30 #include "DAVException.hxx"
32 #include "SerfInputStream.hxx"
33 #include <com/sun/star/io/XOutputStream.hpp>
34 #include <com/sun/star/ucb/Lock.hpp>
36 #include <rtl/ref.hxx>
38 namespace http_dav_ucp
42 class SerfRequestProcessorImpl
;
44 class SerfRequestProcessor
47 SerfRequestProcessor( SerfSession
& rSerfSession
,
48 const OUString
& inPath
,
49 const bool bUseChunkedEncoding
);
50 ~SerfRequestProcessor();
52 // PROPFIND - allprop & named
53 bool processPropFind( const Depth inDepth
,
54 const std::vector
< OUString
> & inPropNames
,
55 std::vector
< DAVResource
> & ioResources
,
56 apr_status_t
& outSerfStatus
);
58 // PROPFIND - property names
59 bool processPropFind( const Depth inDepth
,
60 std::vector
< DAVResourceInfo
> & ioResInfo
,
61 apr_status_t
& outSerfStatus
);
64 bool processPropPatch( const std::vector
< ProppatchValue
> & inProperties
,
65 apr_status_t
& outSerfStatus
);
68 bool processGet( const rtl::Reference
< SerfInputStream
>& xioInStrm
,
69 apr_status_t
& outSerfStatus
);
71 // GET inclusive header fields
72 bool processGet( const rtl::Reference
< SerfInputStream
>& xioInStrm
,
73 const std::vector
< OUString
> & inHeaderNames
,
74 DAVResource
& ioResource
,
75 apr_status_t
& outSerfStatus
);
78 bool processGet( const css::uno::Reference
< css::io::XOutputStream
>& xioOutStrm
,
79 apr_status_t
& outSerfStatus
);
81 // GET inclusive header fields
82 bool processGet( const css::uno::Reference
< css::io::XOutputStream
>& xioOutStrm
,
83 const std::vector
< OUString
> & inHeaderNames
,
84 DAVResource
& ioResource
,
85 apr_status_t
& outSerfStatus
);
88 bool processHead( const std::vector
< OUString
> & inHeaderNames
,
89 DAVResource
& ioResource
,
90 apr_status_t
& outSerfStatus
);
93 bool processPut( const char* inData
,
95 apr_status_t
& outSerfStatus
);
98 bool processPost( const char* inData
,
100 const OUString
& inContentType
,
101 const OUString
& inReferer
,
102 const rtl::Reference
< SerfInputStream
>& xioInStrm
,
103 apr_status_t
& outSerfStatus
);
106 bool processPost( const char* inData
,
107 apr_size_t inDataLen
,
108 const OUString
& inContentType
,
109 const OUString
& inReferer
,
110 const css::uno::Reference
< css::io::XOutputStream
>& xioOutStrm
,
111 apr_status_t
& outSerfStatus
);
114 bool processDelete( apr_status_t
& outSerfStatus
);
117 bool processMkCol( apr_status_t
& outSerfStatus
);
120 bool processCopy( const OUString
& inDestinationPath
,
121 const bool inOverwrite
,
122 apr_status_t
& outSerfStatus
);
125 bool processMove( const OUString
& inDestinationPath
,
126 const bool inOverwrite
,
127 apr_status_t
& outSerfStatus
);
130 bool processLock( const css::ucb::Lock
& rLock
, sal_Int32
*plastChanceToSendRefreshRequest
= nullptr );
133 bool processUnlock();
135 apr_status_t
provideSerfCredentials( char ** outUsername
,
137 serf_request_t
* inRequest
,
139 const char *inAuthProtocol
,
141 apr_pool_t
*inAprPool
);
143 apr_status_t
setupSerfRequest( serf_request_t
* inSerfRequest
,
144 serf_bucket_t
** outSerfRequestBucket
,
145 serf_response_acceptor_t
* outSerfResponseAcceptor
,
146 void ** outSerfResponseAcceptorBaton
,
147 serf_response_handler_t
* outSerfResponseHandler
,
148 void ** outSerfResponseHandlerBaton
,
149 apr_pool_t
* inAprPool
);
151 serf_bucket_t
* acceptSerfResponse( serf_request_t
* inSerfRequest
,
152 serf_bucket_t
* inSerfStreamBucket
,
153 apr_pool_t
* inAprPool
);
155 apr_status_t
handleSerfResponse( serf_request_t
* inSerfRequest
,
156 serf_bucket_t
* inSerfResponseBucket
,
157 apr_pool_t
* inAprPool
);
160 void prepareProcessor();
161 apr_status_t
runProcessor();
162 void postprocessProcessor( const apr_status_t inStatus
);
164 SerfSession
& mrSerfSession
;
165 const char* mPathStr
;
166 const bool mbUseChunkedEncoding
;
167 const char* mDestPathStr
;
168 const char* mContentType
;
169 const char* mReferer
;
170 SerfRequestProcessorImpl
* mpProcImpl
;
172 bool mbProcessingDone
;
174 DAVException
* mpDAVException
;
175 sal_uInt16 mnHTTPStatusCode
;
176 OUString mHTTPStatusCodeText
;
177 OUString mRedirectLocation
;
179 sal_uInt8 mnSuccessfulCredentialAttempts
;
180 bool mbInputOfCredentialsAborted
;
181 bool mbSetupSerfRequestCalled
;
182 bool mbAcceptSerfResponseCalled
;
183 bool mbHandleSerfResponseCalled
;
186 } // namespace http_dav_ucp
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */