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 .
21 #ifndef INCLUDED_UCB_SOURCE_UCP_WEBDAV_SERFREQUESTPROCESSOR_HXX
22 #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_SERFREQUESTPROCESSOR_HXX
24 #include <apr_errno.h>
25 #include <apr_pools.h>
29 #include "DAVTypes.hxx"
30 #include "DAVResource.hxx"
31 #include "DAVException.hxx"
33 #include "SerfInputStream.hxx"
34 #include <com/sun/star/io/XOutputStream.hpp>
35 #include <com/sun/star/ucb/Lock.hpp>
37 namespace http_dav_ucp
41 class SerfRequestProcessorImpl
;
43 class SerfRequestProcessor
46 SerfRequestProcessor( SerfSession
& rSerfSession
,
47 const OUString
& inPath
,
48 const bool bUseChunkedEncoding
);
49 ~SerfRequestProcessor();
51 // PROPFIND - allprop & named
52 bool processPropFind( const Depth inDepth
,
53 const std::vector
< OUString
> & inPropNames
,
54 std::vector
< DAVResource
> & ioResources
,
55 apr_status_t
& outSerfStatus
);
57 // PROPFIND - property names
58 bool processPropFind( const Depth inDepth
,
59 std::vector
< DAVResourceInfo
> & ioResInfo
,
60 apr_status_t
& outSerfStatus
);
63 bool processPropPatch( const std::vector
< ProppatchValue
> & inProperties
,
64 apr_status_t
& outSerfStatus
);
67 bool processGet( const com::sun::star::uno::Reference
< SerfInputStream
>& xioInStrm
,
68 apr_status_t
& outSerfStatus
);
70 // GET inclusive header fields
71 bool processGet( const com::sun::star::uno::Reference
< SerfInputStream
>& xioInStrm
,
72 const std::vector
< OUString
> & inHeaderNames
,
73 DAVResource
& ioResource
,
74 apr_status_t
& outSerfStatus
);
77 bool processGet( const com::sun::star::uno::Reference
< com::sun::star::io::XOutputStream
>& xioOutStrm
,
78 apr_status_t
& outSerfStatus
);
80 // GET inclusive header fields
81 bool processGet( const com::sun::star::uno::Reference
< com::sun::star::io::XOutputStream
>& xioOutStrm
,
82 const std::vector
< OUString
> & inHeaderNames
,
83 DAVResource
& ioResource
,
84 apr_status_t
& outSerfStatus
);
87 bool processHead( const std::vector
< OUString
> & inHeaderNames
,
88 DAVResource
& ioResource
,
89 apr_status_t
& outSerfStatus
);
92 bool processPut( const char* inData
,
94 apr_status_t
& outSerfStatus
);
97 bool processPost( const char* inData
,
99 const OUString
& inContentType
,
100 const OUString
& inReferer
,
101 const com::sun::star::uno::Reference
< SerfInputStream
>& xioInStrm
,
102 apr_status_t
& outSerfStatus
);
105 bool processPost( const char* inData
,
106 apr_size_t inDataLen
,
107 const OUString
& inContentType
,
108 const OUString
& inReferer
,
109 const com::sun::star::uno::Reference
< com::sun::star::io::XOutputStream
>& xioOutStrm
,
110 apr_status_t
& outSerfStatus
);
113 bool processDelete( apr_status_t
& outSerfStatus
);
116 bool processMkCol( apr_status_t
& outSerfStatus
);
119 bool processCopy( const OUString
& inDestinationPath
,
120 const bool inOverwrite
,
121 apr_status_t
& outSerfStatus
);
124 bool processMove( const OUString
& inDestinationPath
,
125 const bool inOverwrite
,
126 apr_status_t
& outSerfStatus
);
129 bool processLock( const css::ucb::Lock
& rLock
, sal_Int32
*plastChanceToSendRefreshRequest
= 0 );
132 bool processUnlock();
134 apr_status_t
provideSerfCredentials( char ** outUsername
,
136 serf_request_t
* inRequest
,
138 const char *inAuthProtocol
,
140 apr_pool_t
*inAprPool
);
142 apr_status_t
setupSerfRequest( serf_request_t
* inSerfRequest
,
143 serf_bucket_t
** outSerfRequestBucket
,
144 serf_response_acceptor_t
* outSerfResponseAcceptor
,
145 void ** outSerfResponseAcceptorBaton
,
146 serf_response_handler_t
* outSerfResponseHandler
,
147 void ** outSerfResponseHandlerBaton
,
148 apr_pool_t
* inAprPool
);
150 serf_bucket_t
* acceptSerfResponse( serf_request_t
* inSerfRequest
,
151 serf_bucket_t
* inSerfStreamBucket
,
152 apr_pool_t
* inAprPool
);
154 apr_status_t
handleSerfResponse( serf_request_t
* inSerfRequest
,
155 serf_bucket_t
* inSerfResponseBucket
,
156 apr_pool_t
* inAprPool
);
159 void prepareProcessor();
160 apr_status_t
runProcessor();
161 void postprocessProcessor( const apr_status_t inStatus
);
163 SerfSession
& mrSerfSession
;
164 const char* mPathStr
;
165 const bool mbUseChunkedEncoding
;
166 const char* mDestPathStr
;
167 const char* mContentType
;
168 const char* mReferer
;
169 SerfRequestProcessorImpl
* mpProcImpl
;
171 bool mbProcessingDone
;
173 DAVException
* mpDAVException
;
174 sal_uInt16 mnHTTPStatusCode
;
175 OUString mHTTPStatusCodeText
;
176 OUString mRedirectLocation
;
178 sal_uInt8 mnSuccessfulCredentialAttempts
;
179 bool mbInputOfCredentialsAborted
;
180 bool mbSetupSerfRequestCalled
;
181 bool mbAcceptSerfResponseCalled
;
182 bool mbHandleSerfResponseCalled
;
185 } // namespace http_dav_ucp
187 #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_SERFREQUESTPROCESSOR_HXX
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */