xref: /AOO41X/main/ucb/source/ucp/webdav/SerfRequestProcessor.hxx (revision 3edf699282957a8d2e0e344ed73ba96dfb5a45a4)
18590a0fdSAndre Fischer /**************************************************************
28590a0fdSAndre Fischer  *
38590a0fdSAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
48590a0fdSAndre Fischer  * or more contributor license agreements.  See the NOTICE file
58590a0fdSAndre Fischer  * distributed with this work for additional information
68590a0fdSAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
78590a0fdSAndre Fischer  * to you under the Apache License, Version 2.0 (the
88590a0fdSAndre Fischer  * "License"); you may not use this file except in compliance
98590a0fdSAndre Fischer  * with the License.  You may obtain a copy of the License at
108590a0fdSAndre Fischer  *
118590a0fdSAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
128590a0fdSAndre Fischer  *
138590a0fdSAndre Fischer  * Unless required by applicable law or agreed to in writing,
148590a0fdSAndre Fischer  * software distributed under the License is distributed on an
158590a0fdSAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
168590a0fdSAndre Fischer  * KIND, either express or implied.  See the License for the
178590a0fdSAndre Fischer  * specific language governing permissions and limitations
188590a0fdSAndre Fischer  * under the License.
198590a0fdSAndre Fischer  *
208590a0fdSAndre Fischer  *************************************************************/
218590a0fdSAndre Fischer 
228590a0fdSAndre Fischer 
238590a0fdSAndre Fischer #ifndef INCLUDED_SERFREQUESTPROCESSOR_HXX
248590a0fdSAndre Fischer #define INCLUDED_SERFREQUESTPROCESSOR_HXX
258590a0fdSAndre Fischer 
268590a0fdSAndre Fischer #include <apr_errno.h>
278590a0fdSAndre Fischer #include <apr_pools.h>
288590a0fdSAndre Fischer 
2908bb353fSPedro Giffuni #include <serf.h>
308590a0fdSAndre Fischer 
31c1c10f68SAriel Constenla-Haile #include "DAVTypes.hxx"
32c1c10f68SAriel Constenla-Haile #include "DAVResource.hxx"
33c1c10f68SAriel Constenla-Haile #include "DAVException.hxx"
348590a0fdSAndre Fischer 
35*3edf6992SAndrea Pescetti #include "SerfTypes.hxx"
36c1c10f68SAriel Constenla-Haile #include "SerfInputStream.hxx"
378590a0fdSAndre Fischer #include <com/sun/star/io/XOutputStream.hpp>
388590a0fdSAndre Fischer 
398590a0fdSAndre Fischer namespace http_dav_ucp
408590a0fdSAndre Fischer {
418590a0fdSAndre Fischer 
428590a0fdSAndre Fischer class SerfSession;
438590a0fdSAndre Fischer class SerfRequestProcessorImpl;
448590a0fdSAndre Fischer 
458590a0fdSAndre Fischer class SerfRequestProcessor
468590a0fdSAndre Fischer {
478590a0fdSAndre Fischer public:
488590a0fdSAndre Fischer     SerfRequestProcessor( SerfSession& rSerfSession,
4949989859SOliver-Rainer Wittmann                           const rtl::OUString & inPath,
5049989859SOliver-Rainer Wittmann                           const bool bUseChunkedEncoding );
518590a0fdSAndre Fischer     ~SerfRequestProcessor();
528590a0fdSAndre Fischer 
538590a0fdSAndre Fischer     // PROPFIND - allprop & named
548590a0fdSAndre Fischer     bool processPropFind( const Depth inDepth,
558590a0fdSAndre Fischer                           const std::vector< ::rtl::OUString > & inPropNames,
568590a0fdSAndre Fischer                           std::vector< DAVResource > & ioResources,
578590a0fdSAndre Fischer                           apr_status_t& outSerfStatus );
588590a0fdSAndre Fischer 
598590a0fdSAndre Fischer     // PROPFIND - property names
608590a0fdSAndre Fischer     bool processPropFind( const Depth inDepth,
618590a0fdSAndre Fischer                           std::vector< DAVResourceInfo > & ioResInfo,
628590a0fdSAndre Fischer                           apr_status_t& outSerfStatus );
638590a0fdSAndre Fischer 
648590a0fdSAndre Fischer     // PROPPATCH
658590a0fdSAndre Fischer     bool processPropPatch( const std::vector< ProppatchValue > & inProperties,
66*3edf6992SAndrea Pescetti                            const com::sun::star::ucb::Lock  inLock,
678590a0fdSAndre Fischer                            apr_status_t& outSerfStatus );
688590a0fdSAndre Fischer 
698590a0fdSAndre Fischer     // GET
708590a0fdSAndre Fischer     bool processGet( const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
718590a0fdSAndre Fischer                      apr_status_t& outSerfStatus );
728590a0fdSAndre Fischer 
738590a0fdSAndre Fischer     // GET inclusive header fields
748590a0fdSAndre Fischer     bool processGet( const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
758590a0fdSAndre Fischer                      const std::vector< ::rtl::OUString > & inHeaderNames,
768590a0fdSAndre Fischer                      DAVResource & ioResource,
778590a0fdSAndre Fischer                      apr_status_t& outSerfStatus );
788590a0fdSAndre Fischer 
798590a0fdSAndre Fischer     // GET
808590a0fdSAndre Fischer     bool processGet( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm,
818590a0fdSAndre Fischer                      apr_status_t& outSerfStatus );
828590a0fdSAndre Fischer 
838590a0fdSAndre Fischer     // GET inclusive header fields
848590a0fdSAndre Fischer     bool processGet( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm,
858590a0fdSAndre Fischer                      const std::vector< ::rtl::OUString > & inHeaderNames,
868590a0fdSAndre Fischer                      DAVResource & ioResource,
878590a0fdSAndre Fischer                      apr_status_t& outSerfStatus );
888590a0fdSAndre Fischer 
898590a0fdSAndre Fischer     // HEAD
908590a0fdSAndre Fischer     bool processHead( const std::vector< ::rtl::OUString > & inHeaderNames,
918590a0fdSAndre Fischer                       DAVResource & ioResource,
928590a0fdSAndre Fischer                       apr_status_t& outSerfStatus );
938590a0fdSAndre Fischer 
948590a0fdSAndre Fischer     // PUT
958590a0fdSAndre Fischer     bool processPut( const char* inData,
968590a0fdSAndre Fischer                      apr_size_t inDataLen,
97*3edf6992SAndrea Pescetti                      const com::sun::star::ucb::Lock  inLock,
988590a0fdSAndre Fischer                      apr_status_t& outSerfStatus );
998590a0fdSAndre Fischer 
1008590a0fdSAndre Fischer     // POST
1018590a0fdSAndre Fischer     bool processPost( const char* inData,
1028590a0fdSAndre Fischer                       apr_size_t inDataLen,
1038590a0fdSAndre Fischer                       const rtl::OUString & inContentType,
1048590a0fdSAndre Fischer                       const rtl::OUString & inReferer,
105*3edf6992SAndrea Pescetti                       const com::sun::star::ucb::Lock  inLock,
1068590a0fdSAndre Fischer                       const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
1078590a0fdSAndre Fischer                       apr_status_t& outSerfStatus );
1088590a0fdSAndre Fischer 
1098590a0fdSAndre Fischer     // POST
1108590a0fdSAndre Fischer     bool processPost( const char* inData,
1118590a0fdSAndre Fischer                       apr_size_t inDataLen,
1128590a0fdSAndre Fischer                       const rtl::OUString & inContentType,
1138590a0fdSAndre Fischer                       const rtl::OUString & inReferer,
114*3edf6992SAndrea Pescetti                       const com::sun::star::ucb::Lock  inLock,
1158590a0fdSAndre Fischer                       const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm,
1168590a0fdSAndre Fischer                       apr_status_t& outSerfStatus );
1178590a0fdSAndre Fischer 
1188590a0fdSAndre Fischer     // DELETE
119*3edf6992SAndrea Pescetti     bool processDelete( const com::sun::star::ucb::Lock inLock,
120*3edf6992SAndrea Pescetti                         apr_status_t& outSerfStatus );
1218590a0fdSAndre Fischer 
1228590a0fdSAndre Fischer     // MKCOL
123*3edf6992SAndrea Pescetti     bool processMkCol( const com::sun::star::ucb::Lock inLock,
124*3edf6992SAndrea Pescetti                        apr_status_t& outSerfStatus );
1258590a0fdSAndre Fischer 
1268590a0fdSAndre Fischer     // COPY
1278590a0fdSAndre Fischer     bool processCopy( const rtl::OUString & inDestinationPath,
1288590a0fdSAndre Fischer                       const bool inOverwrite,
129*3edf6992SAndrea Pescetti                       const com::sun::star::ucb::Lock inLock,
1308590a0fdSAndre Fischer                       apr_status_t& outSerfStatus );
1318590a0fdSAndre Fischer 
1328590a0fdSAndre Fischer     // MOVE
1338590a0fdSAndre Fischer     bool processMove( const rtl::OUString & inDestinationPath,
1348590a0fdSAndre Fischer                       const bool inOverwrite,
135*3edf6992SAndrea Pescetti                       const com::sun::star::ucb::Lock inLock,
136*3edf6992SAndrea Pescetti                       apr_status_t& outSerfStatus );
137*3edf6992SAndrea Pescetti 
138*3edf6992SAndrea Pescetti     // LOCK
139*3edf6992SAndrea Pescetti     bool processLock( const rtl::OUString & inDestinationPath,
140*3edf6992SAndrea Pescetti                       const com::sun::star::ucb::Lock& inLock,
141*3edf6992SAndrea Pescetti                       DAVPropertyValue & outLock,
142*3edf6992SAndrea Pescetti                       apr_status_t& outSerfStatus );
143*3edf6992SAndrea Pescetti 
144*3edf6992SAndrea Pescetti     // LOCK refresh
145*3edf6992SAndrea Pescetti     bool processLockRefresh( const rtl::OUString & inDestinationPath,
146*3edf6992SAndrea Pescetti                       const com::sun::star::ucb::Lock& inLock,
147*3edf6992SAndrea Pescetti                       DAVPropertyValue & outLock,
148*3edf6992SAndrea Pescetti                       apr_status_t& outSerfStatus );
149*3edf6992SAndrea Pescetti 
150*3edf6992SAndrea Pescetti     //UNLOCK
151*3edf6992SAndrea Pescetti     bool processUnlock( const rtl::OUString & inDestinationPath,
152*3edf6992SAndrea Pescetti                         const com::sun::star::ucb::Lock& inLock,
1538590a0fdSAndre Fischer                         apr_status_t& outSerfStatus );
1548590a0fdSAndre Fischer 
1558590a0fdSAndre Fischer     apr_status_t provideSerfCredentials( char ** outUsername,
1568590a0fdSAndre Fischer                                          char ** outPassword,
1578590a0fdSAndre Fischer                                          serf_request_t * inRequest,
1588590a0fdSAndre Fischer                                          int inCode,
1598590a0fdSAndre Fischer                                          const char *inAuthProtocol,
1608590a0fdSAndre Fischer                                          const char *inRealm,
1618590a0fdSAndre Fischer                                          apr_pool_t *inAprPool );
1628590a0fdSAndre Fischer 
1638590a0fdSAndre Fischer     apr_status_t setupSerfRequest( serf_request_t * inSerfRequest,
1648590a0fdSAndre Fischer                                    serf_bucket_t ** outSerfRequestBucket,
1658590a0fdSAndre Fischer                                    serf_response_acceptor_t * outSerfResponseAcceptor,
1668590a0fdSAndre Fischer                                    void ** outSerfResponseAcceptorBaton,
1678590a0fdSAndre Fischer                                    serf_response_handler_t * outSerfResponseHandler,
1688590a0fdSAndre Fischer                                    void ** outSerfResponseHandlerBaton,
1698590a0fdSAndre Fischer                                    apr_pool_t * inAprPool );
1708590a0fdSAndre Fischer 
1718590a0fdSAndre Fischer     serf_bucket_t* acceptSerfResponse( serf_request_t * inSerfRequest,
1728590a0fdSAndre Fischer                                        serf_bucket_t * inSerfStreamBucket,
1738590a0fdSAndre Fischer                                        apr_pool_t* inAprPool );
1748590a0fdSAndre Fischer 
1758590a0fdSAndre Fischer     apr_status_t handleSerfResponse( serf_request_t * inSerfRequest,
1768590a0fdSAndre Fischer                                      serf_bucket_t * inSerfResponseBucket,
1778590a0fdSAndre Fischer                                      apr_pool_t * inAprPool );
1788590a0fdSAndre Fischer 
1798590a0fdSAndre Fischer //private:
1808590a0fdSAndre Fischer     void prepareProcessor();
1818590a0fdSAndre Fischer     apr_status_t runProcessor();
1828590a0fdSAndre Fischer     void postprocessProcessor( const apr_status_t inStatus );
1838590a0fdSAndre Fischer 
1848590a0fdSAndre Fischer     SerfSession& mrSerfSession;
1858590a0fdSAndre Fischer     const char* mPathStr;
18649989859SOliver-Rainer Wittmann     const bool mbUseChunkedEncoding;
1878590a0fdSAndre Fischer     const char* mDestPathStr;
1888590a0fdSAndre Fischer     const char* mContentType;
1898590a0fdSAndre Fischer     const char* mReferer;
1908590a0fdSAndre Fischer     SerfRequestProcessorImpl* mpProcImpl;
1918590a0fdSAndre Fischer 
1928590a0fdSAndre Fischer     bool mbProcessingDone;
1938590a0fdSAndre Fischer 
1948590a0fdSAndre Fischer     DAVException* mpDAVException;
1958590a0fdSAndre Fischer     sal_uInt16 mnHTTPStatusCode;
1968590a0fdSAndre Fischer     rtl::OUString mHTTPStatusCodeText;
1978590a0fdSAndre Fischer     rtl::OUString mRedirectLocation;
1988590a0fdSAndre Fischer 
199fb7f54d2SOliver-Rainer Wittmann     sal_uInt8 mnSuccessfulCredentialAttempts;
200fb7f54d2SOliver-Rainer Wittmann     bool mbInputOfCredentialsAborted;
2018590a0fdSAndre Fischer     bool mbSetupSerfRequestCalled;
2028590a0fdSAndre Fischer     bool mbAcceptSerfResponseCalled;
2038590a0fdSAndre Fischer     bool mbHandleSerfResponseCalled;
2048590a0fdSAndre Fischer };
2058590a0fdSAndre Fischer 
2068590a0fdSAndre Fischer } // namespace http_dav_ucp
2078590a0fdSAndre Fischer 
2088590a0fdSAndre Fischer #endif // INCLUDED_SERFREQUESTPROCESSOR_HXX
209