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_SERFREQUESTPROCESSOR_HXX
22 #define INCLUDED_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>
36 namespace http_dav_ucp
40 class SerfRequestProcessorImpl
;
42 class SerfRequestProcessor
45 SerfRequestProcessor( SerfSession
& rSerfSession
,
46 const rtl::OUString
& inPath
,
47 const bool bUseChunkedEncoding
);
48 ~SerfRequestProcessor();
50 // PROPFIND - allprop & named
51 bool processPropFind( const Depth inDepth
,
52 const std::vector
< ::rtl::OUString
> & inPropNames
,
53 std::vector
< DAVResource
> & ioResources
,
54 apr_status_t
& outSerfStatus
);
56 // PROPFIND - property names
57 bool processPropFind( const Depth inDepth
,
58 std::vector
< DAVResourceInfo
> & ioResInfo
,
59 apr_status_t
& outSerfStatus
);
62 bool processPropPatch( const std::vector
< ProppatchValue
> & inProperties
,
63 apr_status_t
& outSerfStatus
);
66 bool processGet( const com::sun::star::uno::Reference
< SerfInputStream
>& xioInStrm
,
67 apr_status_t
& outSerfStatus
);
69 // GET inclusive header fields
70 bool processGet( const com::sun::star::uno::Reference
< SerfInputStream
>& xioInStrm
,
71 const std::vector
< ::rtl::OUString
> & inHeaderNames
,
72 DAVResource
& ioResource
,
73 apr_status_t
& outSerfStatus
);
76 bool processGet( const com::sun::star::uno::Reference
< com::sun::star::io::XOutputStream
>& xioOutStrm
,
77 apr_status_t
& outSerfStatus
);
79 // GET inclusive header fields
80 bool processGet( const com::sun::star::uno::Reference
< com::sun::star::io::XOutputStream
>& xioOutStrm
,
81 const std::vector
< ::rtl::OUString
> & inHeaderNames
,
82 DAVResource
& ioResource
,
83 apr_status_t
& outSerfStatus
);
86 bool processHead( const std::vector
< ::rtl::OUString
> & inHeaderNames
,
87 DAVResource
& ioResource
,
88 apr_status_t
& outSerfStatus
);
91 bool processPut( const char* inData
,
93 apr_status_t
& outSerfStatus
);
96 bool processPost( const char* inData
,
98 const rtl::OUString
& inContentType
,
99 const rtl::OUString
& inReferer
,
100 const com::sun::star::uno::Reference
< SerfInputStream
>& xioInStrm
,
101 apr_status_t
& outSerfStatus
);
104 bool processPost( const char* inData
,
105 apr_size_t inDataLen
,
106 const rtl::OUString
& inContentType
,
107 const rtl::OUString
& inReferer
,
108 const com::sun::star::uno::Reference
< com::sun::star::io::XOutputStream
>& xioOutStrm
,
109 apr_status_t
& outSerfStatus
);
112 bool processDelete( apr_status_t
& outSerfStatus
);
115 bool processMkCol( apr_status_t
& outSerfStatus
);
118 bool processCopy( const rtl::OUString
& inDestinationPath
,
119 const bool inOverwrite
,
120 apr_status_t
& outSerfStatus
);
123 bool processMove( const rtl::OUString
& inDestinationPath
,
124 const bool inOverwrite
,
125 apr_status_t
& outSerfStatus
);
127 apr_status_t
provideSerfCredentials( char ** outUsername
,
129 serf_request_t
* inRequest
,
131 const char *inAuthProtocol
,
133 apr_pool_t
*inAprPool
);
135 apr_status_t
setupSerfRequest( serf_request_t
* inSerfRequest
,
136 serf_bucket_t
** outSerfRequestBucket
,
137 serf_response_acceptor_t
* outSerfResponseAcceptor
,
138 void ** outSerfResponseAcceptorBaton
,
139 serf_response_handler_t
* outSerfResponseHandler
,
140 void ** outSerfResponseHandlerBaton
,
141 apr_pool_t
* inAprPool
);
143 serf_bucket_t
* acceptSerfResponse( serf_request_t
* inSerfRequest
,
144 serf_bucket_t
* inSerfStreamBucket
,
145 apr_pool_t
* inAprPool
);
147 apr_status_t
handleSerfResponse( serf_request_t
* inSerfRequest
,
148 serf_bucket_t
* inSerfResponseBucket
,
149 apr_pool_t
* inAprPool
);
152 void prepareProcessor();
153 apr_status_t
runProcessor();
154 void postprocessProcessor( const apr_status_t inStatus
);
156 SerfSession
& mrSerfSession
;
157 const char* mPathStr
;
158 const bool mbUseChunkedEncoding
;
159 const char* mDestPathStr
;
160 const char* mContentType
;
161 const char* mReferer
;
162 SerfRequestProcessorImpl
* mpProcImpl
;
164 bool mbProcessingDone
;
166 DAVException
* mpDAVException
;
167 sal_uInt16 mnHTTPStatusCode
;
168 rtl::OUString mHTTPStatusCodeText
;
169 rtl::OUString mRedirectLocation
;
171 sal_uInt8 mnSuccessfulCredentialAttempts
;
172 bool mbInputOfCredentialsAborted
;
173 bool mbSetupSerfRequestCalled
;
174 bool mbAcceptSerfResponseCalled
;
175 bool mbHandleSerfResponseCalled
;
178 } // namespace http_dav_ucp
180 #endif // INCLUDED_SERFREQUESTPROCESSOR_HXX
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */