xref: /AOO41X/main/ucb/source/ucp/webdav/SerfRequestProcessor.hxx (revision 8590a0fdd306f78ee72b863c64cbcf09c28509eb)
1*8590a0fdSAndre Fischer /**************************************************************
2*8590a0fdSAndre Fischer  *
3*8590a0fdSAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
4*8590a0fdSAndre Fischer  * or more contributor license agreements.  See the NOTICE file
5*8590a0fdSAndre Fischer  * distributed with this work for additional information
6*8590a0fdSAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
7*8590a0fdSAndre Fischer  * to you under the Apache License, Version 2.0 (the
8*8590a0fdSAndre Fischer  * "License"); you may not use this file except in compliance
9*8590a0fdSAndre Fischer  * with the License.  You may obtain a copy of the License at
10*8590a0fdSAndre Fischer  *
11*8590a0fdSAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
12*8590a0fdSAndre Fischer  *
13*8590a0fdSAndre Fischer  * Unless required by applicable law or agreed to in writing,
14*8590a0fdSAndre Fischer  * software distributed under the License is distributed on an
15*8590a0fdSAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*8590a0fdSAndre Fischer  * KIND, either express or implied.  See the License for the
17*8590a0fdSAndre Fischer  * specific language governing permissions and limitations
18*8590a0fdSAndre Fischer  * under the License.
19*8590a0fdSAndre Fischer  *
20*8590a0fdSAndre Fischer  *************************************************************/
21*8590a0fdSAndre Fischer 
22*8590a0fdSAndre Fischer 
23*8590a0fdSAndre Fischer #ifndef INCLUDED_SERFREQUESTPROCESSOR_HXX
24*8590a0fdSAndre Fischer #define INCLUDED_SERFREQUESTPROCESSOR_HXX
25*8590a0fdSAndre Fischer 
26*8590a0fdSAndre Fischer #include <apr_errno.h>
27*8590a0fdSAndre Fischer #include <apr_pools.h>
28*8590a0fdSAndre Fischer 
29*8590a0fdSAndre Fischer #include <serf.h>
30*8590a0fdSAndre Fischer 
31*8590a0fdSAndre Fischer #include <DAVTypes.hxx>
32*8590a0fdSAndre Fischer #include <DAVResource.hxx>
33*8590a0fdSAndre Fischer #include <DAVException.hxx>
34*8590a0fdSAndre Fischer 
35*8590a0fdSAndre Fischer #include <SerfInputStream.hxx>
36*8590a0fdSAndre Fischer #include <com/sun/star/io/XOutputStream.hpp>
37*8590a0fdSAndre Fischer 
38*8590a0fdSAndre Fischer namespace http_dav_ucp
39*8590a0fdSAndre Fischer {
40*8590a0fdSAndre Fischer 
41*8590a0fdSAndre Fischer class SerfSession;
42*8590a0fdSAndre Fischer class SerfRequestProcessorImpl;
43*8590a0fdSAndre Fischer 
44*8590a0fdSAndre Fischer class SerfRequestProcessor
45*8590a0fdSAndre Fischer {
46*8590a0fdSAndre Fischer public:
47*8590a0fdSAndre Fischer     SerfRequestProcessor( SerfSession& rSerfSession,
48*8590a0fdSAndre Fischer                           const rtl::OUString & inPath );
49*8590a0fdSAndre Fischer     ~SerfRequestProcessor();
50*8590a0fdSAndre Fischer 
51*8590a0fdSAndre Fischer     // PROPFIND - allprop & named
52*8590a0fdSAndre Fischer     bool processPropFind( const Depth inDepth,
53*8590a0fdSAndre Fischer                           const std::vector< ::rtl::OUString > & inPropNames,
54*8590a0fdSAndre Fischer                           std::vector< DAVResource > & ioResources,
55*8590a0fdSAndre Fischer                           apr_status_t& outSerfStatus );
56*8590a0fdSAndre Fischer 
57*8590a0fdSAndre Fischer     // PROPFIND - property names
58*8590a0fdSAndre Fischer     bool processPropFind( const Depth inDepth,
59*8590a0fdSAndre Fischer                           std::vector< DAVResourceInfo > & ioResInfo,
60*8590a0fdSAndre Fischer                           apr_status_t& outSerfStatus );
61*8590a0fdSAndre Fischer 
62*8590a0fdSAndre Fischer     // PROPPATCH
63*8590a0fdSAndre Fischer     bool processPropPatch( const std::vector< ProppatchValue > & inProperties,
64*8590a0fdSAndre Fischer                            apr_status_t& outSerfStatus );
65*8590a0fdSAndre Fischer 
66*8590a0fdSAndre Fischer     // GET
67*8590a0fdSAndre Fischer     bool processGet( const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
68*8590a0fdSAndre Fischer                      apr_status_t& outSerfStatus );
69*8590a0fdSAndre Fischer 
70*8590a0fdSAndre Fischer     // GET inclusive header fields
71*8590a0fdSAndre Fischer     bool processGet( const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
72*8590a0fdSAndre Fischer                      const std::vector< ::rtl::OUString > & inHeaderNames,
73*8590a0fdSAndre Fischer                      DAVResource & ioResource,
74*8590a0fdSAndre Fischer                      apr_status_t& outSerfStatus );
75*8590a0fdSAndre Fischer 
76*8590a0fdSAndre Fischer     // GET
77*8590a0fdSAndre Fischer     bool processGet( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm,
78*8590a0fdSAndre Fischer                      apr_status_t& outSerfStatus );
79*8590a0fdSAndre Fischer 
80*8590a0fdSAndre Fischer     // GET inclusive header fields
81*8590a0fdSAndre Fischer     bool processGet( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm,
82*8590a0fdSAndre Fischer                      const std::vector< ::rtl::OUString > & inHeaderNames,
83*8590a0fdSAndre Fischer                      DAVResource & ioResource,
84*8590a0fdSAndre Fischer                      apr_status_t& outSerfStatus );
85*8590a0fdSAndre Fischer 
86*8590a0fdSAndre Fischer     // HEAD
87*8590a0fdSAndre Fischer     bool processHead( const std::vector< ::rtl::OUString > & inHeaderNames,
88*8590a0fdSAndre Fischer                       DAVResource & ioResource,
89*8590a0fdSAndre Fischer                       apr_status_t& outSerfStatus );
90*8590a0fdSAndre Fischer 
91*8590a0fdSAndre Fischer     // PUT
92*8590a0fdSAndre Fischer     bool processPut( const char* inData,
93*8590a0fdSAndre Fischer                      apr_size_t inDataLen,
94*8590a0fdSAndre Fischer                      apr_status_t& outSerfStatus );
95*8590a0fdSAndre Fischer 
96*8590a0fdSAndre Fischer     // POST
97*8590a0fdSAndre Fischer     bool processPost( const char* inData,
98*8590a0fdSAndre Fischer                       apr_size_t inDataLen,
99*8590a0fdSAndre Fischer                       const rtl::OUString & inContentType,
100*8590a0fdSAndre Fischer                       const rtl::OUString & inReferer,
101*8590a0fdSAndre Fischer                       const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
102*8590a0fdSAndre Fischer                       apr_status_t& outSerfStatus );
103*8590a0fdSAndre Fischer 
104*8590a0fdSAndre Fischer     // POST
105*8590a0fdSAndre Fischer     bool processPost( const char* inData,
106*8590a0fdSAndre Fischer                       apr_size_t inDataLen,
107*8590a0fdSAndre Fischer                       const rtl::OUString & inContentType,
108*8590a0fdSAndre Fischer                       const rtl::OUString & inReferer,
109*8590a0fdSAndre Fischer                       const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm,
110*8590a0fdSAndre Fischer                       apr_status_t& outSerfStatus );
111*8590a0fdSAndre Fischer 
112*8590a0fdSAndre Fischer     // DELETE
113*8590a0fdSAndre Fischer     bool processDelete( apr_status_t& outSerfStatus );
114*8590a0fdSAndre Fischer 
115*8590a0fdSAndre Fischer     // MKCOL
116*8590a0fdSAndre Fischer     bool processMkCol( apr_status_t& outSerfStatus );
117*8590a0fdSAndre Fischer 
118*8590a0fdSAndre Fischer     // COPY
119*8590a0fdSAndre Fischer     bool processCopy( const rtl::OUString & inDestinationPath,
120*8590a0fdSAndre Fischer                       const bool inOverwrite,
121*8590a0fdSAndre Fischer                       apr_status_t& outSerfStatus );
122*8590a0fdSAndre Fischer 
123*8590a0fdSAndre Fischer     // MOVE
124*8590a0fdSAndre Fischer     bool processMove( const rtl::OUString & inDestinationPath,
125*8590a0fdSAndre Fischer                       const bool inOverwrite,
126*8590a0fdSAndre Fischer                       apr_status_t& outSerfStatus );
127*8590a0fdSAndre Fischer 
128*8590a0fdSAndre Fischer     apr_status_t provideSerfCredentials( char ** outUsername,
129*8590a0fdSAndre Fischer                                          char ** outPassword,
130*8590a0fdSAndre Fischer                                          serf_request_t * inRequest,
131*8590a0fdSAndre Fischer                                          int inCode,
132*8590a0fdSAndre Fischer                                          const char *inAuthProtocol,
133*8590a0fdSAndre Fischer                                          const char *inRealm,
134*8590a0fdSAndre Fischer                                          apr_pool_t *inAprPool );
135*8590a0fdSAndre Fischer 
136*8590a0fdSAndre Fischer     apr_status_t setupSerfRequest( serf_request_t * inSerfRequest,
137*8590a0fdSAndre Fischer                                    serf_bucket_t ** outSerfRequestBucket,
138*8590a0fdSAndre Fischer                                    serf_response_acceptor_t * outSerfResponseAcceptor,
139*8590a0fdSAndre Fischer                                    void ** outSerfResponseAcceptorBaton,
140*8590a0fdSAndre Fischer                                    serf_response_handler_t * outSerfResponseHandler,
141*8590a0fdSAndre Fischer                                    void ** outSerfResponseHandlerBaton,
142*8590a0fdSAndre Fischer                                    apr_pool_t * inAprPool );
143*8590a0fdSAndre Fischer 
144*8590a0fdSAndre Fischer     serf_bucket_t* acceptSerfResponse( serf_request_t * inSerfRequest,
145*8590a0fdSAndre Fischer                                        serf_bucket_t * inSerfStreamBucket,
146*8590a0fdSAndre Fischer                                        apr_pool_t* inAprPool );
147*8590a0fdSAndre Fischer 
148*8590a0fdSAndre Fischer     apr_status_t handleSerfResponse( serf_request_t * inSerfRequest,
149*8590a0fdSAndre Fischer                                      serf_bucket_t * inSerfResponseBucket,
150*8590a0fdSAndre Fischer                                      apr_pool_t * inAprPool );
151*8590a0fdSAndre Fischer 
152*8590a0fdSAndre Fischer //private:
153*8590a0fdSAndre Fischer     void prepareProcessor();
154*8590a0fdSAndre Fischer     apr_status_t runProcessor();
155*8590a0fdSAndre Fischer     void postprocessProcessor( const apr_status_t inStatus );
156*8590a0fdSAndre Fischer 
157*8590a0fdSAndre Fischer     SerfSession& mrSerfSession;
158*8590a0fdSAndre Fischer     const char* mPathStr;
159*8590a0fdSAndre Fischer     const char* mDestPathStr;
160*8590a0fdSAndre Fischer     const char* mContentType;
161*8590a0fdSAndre Fischer     const char* mReferer;
162*8590a0fdSAndre Fischer     SerfRequestProcessorImpl* mpProcImpl;
163*8590a0fdSAndre Fischer 
164*8590a0fdSAndre Fischer     bool mbProcessingDone;
165*8590a0fdSAndre Fischer 
166*8590a0fdSAndre Fischer     DAVException* mpDAVException;
167*8590a0fdSAndre Fischer     sal_uInt16 mnHTTPStatusCode;
168*8590a0fdSAndre Fischer     rtl::OUString mHTTPStatusCodeText;
169*8590a0fdSAndre Fischer     rtl::OUString mRedirectLocation;
170*8590a0fdSAndre Fischer 
171*8590a0fdSAndre Fischer     bool mbSetupSerfRequestCalled;
172*8590a0fdSAndre Fischer     bool mbAcceptSerfResponseCalled;
173*8590a0fdSAndre Fischer     bool mbHandleSerfResponseCalled;
174*8590a0fdSAndre Fischer };
175*8590a0fdSAndre Fischer 
176*8590a0fdSAndre Fischer } // namespace http_dav_ucp
177*8590a0fdSAndre Fischer 
178*8590a0fdSAndre Fischer #endif // INCLUDED_SERFREQUESTPROCESSOR_HXX
179