xref: /AOO41X/main/ucb/source/ucp/webdav/SerfRequestProcessor.hxx (revision fb7f54d274e818c0fa3cfcf886ef07ebf066acca)
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 
298590a0fdSAndre Fischer #include <serf.h>
308590a0fdSAndre Fischer 
318590a0fdSAndre Fischer #include <DAVTypes.hxx>
328590a0fdSAndre Fischer #include <DAVResource.hxx>
338590a0fdSAndre Fischer #include <DAVException.hxx>
348590a0fdSAndre Fischer 
358590a0fdSAndre Fischer #include <SerfInputStream.hxx>
368590a0fdSAndre Fischer #include <com/sun/star/io/XOutputStream.hpp>
378590a0fdSAndre Fischer 
388590a0fdSAndre Fischer namespace http_dav_ucp
398590a0fdSAndre Fischer {
408590a0fdSAndre Fischer 
418590a0fdSAndre Fischer class SerfSession;
428590a0fdSAndre Fischer class SerfRequestProcessorImpl;
438590a0fdSAndre Fischer 
448590a0fdSAndre Fischer class SerfRequestProcessor
458590a0fdSAndre Fischer {
468590a0fdSAndre Fischer public:
478590a0fdSAndre Fischer     SerfRequestProcessor( SerfSession& rSerfSession,
488590a0fdSAndre Fischer                           const rtl::OUString & inPath );
498590a0fdSAndre Fischer     ~SerfRequestProcessor();
508590a0fdSAndre Fischer 
518590a0fdSAndre Fischer     // PROPFIND - allprop & named
528590a0fdSAndre Fischer     bool processPropFind( const Depth inDepth,
538590a0fdSAndre Fischer                           const std::vector< ::rtl::OUString > & inPropNames,
548590a0fdSAndre Fischer                           std::vector< DAVResource > & ioResources,
558590a0fdSAndre Fischer                           apr_status_t& outSerfStatus );
568590a0fdSAndre Fischer 
578590a0fdSAndre Fischer     // PROPFIND - property names
588590a0fdSAndre Fischer     bool processPropFind( const Depth inDepth,
598590a0fdSAndre Fischer                           std::vector< DAVResourceInfo > & ioResInfo,
608590a0fdSAndre Fischer                           apr_status_t& outSerfStatus );
618590a0fdSAndre Fischer 
628590a0fdSAndre Fischer     // PROPPATCH
638590a0fdSAndre Fischer     bool processPropPatch( const std::vector< ProppatchValue > & inProperties,
648590a0fdSAndre Fischer                            apr_status_t& outSerfStatus );
658590a0fdSAndre Fischer 
668590a0fdSAndre Fischer     // GET
678590a0fdSAndre Fischer     bool processGet( const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
688590a0fdSAndre Fischer                      apr_status_t& outSerfStatus );
698590a0fdSAndre Fischer 
708590a0fdSAndre Fischer     // GET inclusive header fields
718590a0fdSAndre Fischer     bool processGet( const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
728590a0fdSAndre Fischer                      const std::vector< ::rtl::OUString > & inHeaderNames,
738590a0fdSAndre Fischer                      DAVResource & ioResource,
748590a0fdSAndre Fischer                      apr_status_t& outSerfStatus );
758590a0fdSAndre Fischer 
768590a0fdSAndre Fischer     // GET
778590a0fdSAndre Fischer     bool processGet( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm,
788590a0fdSAndre Fischer                      apr_status_t& outSerfStatus );
798590a0fdSAndre Fischer 
808590a0fdSAndre Fischer     // GET inclusive header fields
818590a0fdSAndre Fischer     bool processGet( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm,
828590a0fdSAndre Fischer                      const std::vector< ::rtl::OUString > & inHeaderNames,
838590a0fdSAndre Fischer                      DAVResource & ioResource,
848590a0fdSAndre Fischer                      apr_status_t& outSerfStatus );
858590a0fdSAndre Fischer 
868590a0fdSAndre Fischer     // HEAD
878590a0fdSAndre Fischer     bool processHead( const std::vector< ::rtl::OUString > & inHeaderNames,
888590a0fdSAndre Fischer                       DAVResource & ioResource,
898590a0fdSAndre Fischer                       apr_status_t& outSerfStatus );
908590a0fdSAndre Fischer 
918590a0fdSAndre Fischer     // PUT
928590a0fdSAndre Fischer     bool processPut( const char* inData,
938590a0fdSAndre Fischer                      apr_size_t inDataLen,
948590a0fdSAndre Fischer                      apr_status_t& outSerfStatus );
958590a0fdSAndre Fischer 
968590a0fdSAndre Fischer     // POST
978590a0fdSAndre Fischer     bool processPost( const char* inData,
988590a0fdSAndre Fischer                       apr_size_t inDataLen,
998590a0fdSAndre Fischer                       const rtl::OUString & inContentType,
1008590a0fdSAndre Fischer                       const rtl::OUString & inReferer,
1018590a0fdSAndre Fischer                       const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
1028590a0fdSAndre Fischer                       apr_status_t& outSerfStatus );
1038590a0fdSAndre Fischer 
1048590a0fdSAndre Fischer     // POST
1058590a0fdSAndre Fischer     bool processPost( const char* inData,
1068590a0fdSAndre Fischer                       apr_size_t inDataLen,
1078590a0fdSAndre Fischer                       const rtl::OUString & inContentType,
1088590a0fdSAndre Fischer                       const rtl::OUString & inReferer,
1098590a0fdSAndre Fischer                       const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm,
1108590a0fdSAndre Fischer                       apr_status_t& outSerfStatus );
1118590a0fdSAndre Fischer 
1128590a0fdSAndre Fischer     // DELETE
1138590a0fdSAndre Fischer     bool processDelete( apr_status_t& outSerfStatus );
1148590a0fdSAndre Fischer 
1158590a0fdSAndre Fischer     // MKCOL
1168590a0fdSAndre Fischer     bool processMkCol( apr_status_t& outSerfStatus );
1178590a0fdSAndre Fischer 
1188590a0fdSAndre Fischer     // COPY
1198590a0fdSAndre Fischer     bool processCopy( const rtl::OUString & inDestinationPath,
1208590a0fdSAndre Fischer                       const bool inOverwrite,
1218590a0fdSAndre Fischer                       apr_status_t& outSerfStatus );
1228590a0fdSAndre Fischer 
1238590a0fdSAndre Fischer     // MOVE
1248590a0fdSAndre Fischer     bool processMove( const rtl::OUString & inDestinationPath,
1258590a0fdSAndre Fischer                       const bool inOverwrite,
1268590a0fdSAndre Fischer                       apr_status_t& outSerfStatus );
1278590a0fdSAndre Fischer 
1288590a0fdSAndre Fischer     apr_status_t provideSerfCredentials( char ** outUsername,
1298590a0fdSAndre Fischer                                          char ** outPassword,
1308590a0fdSAndre Fischer                                          serf_request_t * inRequest,
1318590a0fdSAndre Fischer                                          int inCode,
1328590a0fdSAndre Fischer                                          const char *inAuthProtocol,
1338590a0fdSAndre Fischer                                          const char *inRealm,
1348590a0fdSAndre Fischer                                          apr_pool_t *inAprPool );
1358590a0fdSAndre Fischer 
1368590a0fdSAndre Fischer     apr_status_t setupSerfRequest( serf_request_t * inSerfRequest,
1378590a0fdSAndre Fischer                                    serf_bucket_t ** outSerfRequestBucket,
1388590a0fdSAndre Fischer                                    serf_response_acceptor_t * outSerfResponseAcceptor,
1398590a0fdSAndre Fischer                                    void ** outSerfResponseAcceptorBaton,
1408590a0fdSAndre Fischer                                    serf_response_handler_t * outSerfResponseHandler,
1418590a0fdSAndre Fischer                                    void ** outSerfResponseHandlerBaton,
1428590a0fdSAndre Fischer                                    apr_pool_t * inAprPool );
1438590a0fdSAndre Fischer 
1448590a0fdSAndre Fischer     serf_bucket_t* acceptSerfResponse( serf_request_t * inSerfRequest,
1458590a0fdSAndre Fischer                                        serf_bucket_t * inSerfStreamBucket,
1468590a0fdSAndre Fischer                                        apr_pool_t* inAprPool );
1478590a0fdSAndre Fischer 
1488590a0fdSAndre Fischer     apr_status_t handleSerfResponse( serf_request_t * inSerfRequest,
1498590a0fdSAndre Fischer                                      serf_bucket_t * inSerfResponseBucket,
1508590a0fdSAndre Fischer                                      apr_pool_t * inAprPool );
1518590a0fdSAndre Fischer 
1528590a0fdSAndre Fischer //private:
1538590a0fdSAndre Fischer     void prepareProcessor();
1548590a0fdSAndre Fischer     apr_status_t runProcessor();
1558590a0fdSAndre Fischer     void postprocessProcessor( const apr_status_t inStatus );
1568590a0fdSAndre Fischer 
1578590a0fdSAndre Fischer     SerfSession& mrSerfSession;
1588590a0fdSAndre Fischer     const char* mPathStr;
1598590a0fdSAndre Fischer     const char* mDestPathStr;
1608590a0fdSAndre Fischer     const char* mContentType;
1618590a0fdSAndre Fischer     const char* mReferer;
1628590a0fdSAndre Fischer     SerfRequestProcessorImpl* mpProcImpl;
1638590a0fdSAndre Fischer 
1648590a0fdSAndre Fischer     bool mbProcessingDone;
1658590a0fdSAndre Fischer 
1668590a0fdSAndre Fischer     DAVException* mpDAVException;
1678590a0fdSAndre Fischer     sal_uInt16 mnHTTPStatusCode;
1688590a0fdSAndre Fischer     rtl::OUString mHTTPStatusCodeText;
1698590a0fdSAndre Fischer     rtl::OUString mRedirectLocation;
1708590a0fdSAndre Fischer 
171*fb7f54d2SOliver-Rainer Wittmann     sal_uInt8 mnSuccessfulCredentialAttempts;
172*fb7f54d2SOliver-Rainer Wittmann     bool mbInputOfCredentialsAborted;
1738590a0fdSAndre Fischer     bool mbSetupSerfRequestCalled;
1748590a0fdSAndre Fischer     bool mbAcceptSerfResponseCalled;
1758590a0fdSAndre Fischer     bool mbHandleSerfResponseCalled;
1768590a0fdSAndre Fischer };
1778590a0fdSAndre Fischer 
1788590a0fdSAndre Fischer } // namespace http_dav_ucp
1798590a0fdSAndre Fischer 
1808590a0fdSAndre Fischer #endif // INCLUDED_SERFREQUESTPROCESSOR_HXX
181