LibreOffice Module ucb (master)  1
SerfRequestProcessor.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 
21 #ifndef INCLUDED_UCB_SOURCE_UCP_WEBDAV_SERFREQUESTPROCESSOR_HXX
22 #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_SERFREQUESTPROCESSOR_HXX
23 
24 #include <apr_errno.h>
25 #include <apr_pools.h>
26 
27 #include <serf.h>
28 
29 #include "DAVTypes.hxx"
30 #include "DAVResource.hxx"
31 #include "DAVException.hxx"
32 
33 #include "SerfInputStream.hxx"
34 #include <com/sun/star/io/XOutputStream.hpp>
35 #include <com/sun/star/ucb/Lock.hpp>
36 
37 #include <rtl/ref.hxx>
38 
39 namespace http_dav_ucp
40 {
41 
42 class SerfSession;
43 class SerfRequestProcessorImpl;
44 
46 {
47 public:
48  SerfRequestProcessor( SerfSession& rSerfSession,
49  const OUString & inPath,
50  const bool bUseChunkedEncoding );
52 
53  // PROPFIND - allprop & named
54  bool processPropFind( const Depth inDepth,
55  const std::vector< OUString > & inPropNames,
56  std::vector< DAVResource > & ioResources,
57  apr_status_t& outSerfStatus );
58 
59  // PROPFIND - property names
60  bool processPropFind( const Depth inDepth,
61  std::vector< DAVResourceInfo > & ioResInfo,
62  apr_status_t& outSerfStatus );
63 
64  // PROPPATCH
65  bool processPropPatch( const std::vector< ProppatchValue > & inProperties,
66  apr_status_t& outSerfStatus );
67 
68  // GET
69  bool processGet( const rtl::Reference< SerfInputStream >& xioInStrm,
70  apr_status_t& outSerfStatus );
71 
72  // GET inclusive header fields
73  bool processGet( const rtl::Reference< SerfInputStream >& xioInStrm,
74  const std::vector< OUString > & inHeaderNames,
75  DAVResource & ioResource,
76  apr_status_t& outSerfStatus );
77 
78  // GET
79  bool processGet( const css::uno::Reference< css::io::XOutputStream >& xioOutStrm,
80  apr_status_t& outSerfStatus );
81 
82  // GET inclusive header fields
83  bool processGet( const css::uno::Reference< css::io::XOutputStream >& xioOutStrm,
84  const std::vector< OUString > & inHeaderNames,
85  DAVResource & ioResource,
86  apr_status_t& outSerfStatus );
87 
88  // HEAD
89  bool processHead( const std::vector< OUString > & inHeaderNames,
90  DAVResource & ioResource,
91  apr_status_t& outSerfStatus );
92 
93  // PUT
94  bool processPut( const char* inData,
95  apr_size_t inDataLen,
96  apr_status_t& outSerfStatus );
97 
98  // POST
99  bool processPost( const char* inData,
100  apr_size_t inDataLen,
101  const OUString & inContentType,
102  const OUString & inReferer,
103  const rtl::Reference< SerfInputStream >& xioInStrm,
104  apr_status_t& outSerfStatus );
105 
106  // POST
107  bool processPost( const char* inData,
108  apr_size_t inDataLen,
109  const OUString & inContentType,
110  const OUString & inReferer,
111  const css::uno::Reference< css::io::XOutputStream >& xioOutStrm,
112  apr_status_t& outSerfStatus );
113 
114  // DELETE
115  bool processDelete( apr_status_t& outSerfStatus );
116 
117  // MKCOL
118  bool processMkCol( apr_status_t& outSerfStatus );
119 
120  // COPY
121  bool processCopy( const OUString & inDestinationPath,
122  const bool inOverwrite,
123  apr_status_t& outSerfStatus );
124 
125  // MOVE
126  bool processMove( const OUString & inDestinationPath,
127  const bool inOverwrite,
128  apr_status_t& outSerfStatus );
129 
130  //LOCK
131  bool processLock( const css::ucb::Lock & rLock, sal_Int32 *plastChanceToSendRefreshRequest = nullptr );
132 
133  //UNLOCK
134  bool processUnlock();
135 
136  apr_status_t provideSerfCredentials( char ** outUsername,
137  char ** outPassword,
138  serf_request_t * inRequest,
139  int inCode,
140  const char *inAuthProtocol,
141  const char *inRealm,
142  apr_pool_t *inAprPool );
143 
144  apr_status_t setupSerfRequest( serf_request_t * inSerfRequest,
145  serf_bucket_t ** outSerfRequestBucket,
146  serf_response_acceptor_t * outSerfResponseAcceptor,
147  void ** outSerfResponseAcceptorBaton,
148  serf_response_handler_t * outSerfResponseHandler,
149  void ** outSerfResponseHandlerBaton,
150  apr_pool_t * inAprPool );
151 
152  serf_bucket_t* acceptSerfResponse( serf_request_t * inSerfRequest,
153  serf_bucket_t * inSerfStreamBucket,
154  apr_pool_t* inAprPool );
155 
156  apr_status_t handleSerfResponse( serf_request_t * inSerfRequest,
157  serf_bucket_t * inSerfResponseBucket,
158  apr_pool_t * inAprPool );
159 
160 //private:
161  void prepareProcessor();
162  apr_status_t runProcessor();
163  void postprocessProcessor( const apr_status_t inStatus );
164 
166  const char* mPathStr;
168  const char* mDestPathStr;
169  const char* mContentType;
170  const char* mReferer;
172 
174 
176  sal_uInt16 mnHTTPStatusCode;
179 
185 };
186 
187 } // namespace http_dav_ucp
188 
189 #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_SERFREQUESTPROCESSOR_HXX
190 
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool processMove(const OUString &inDestinationPath, const bool inOverwrite, apr_status_t &outSerfStatus)
bool processCopy(const OUString &inDestinationPath, const bool inOverwrite, apr_status_t &outSerfStatus)
bool processHead(const std::vector< OUString > &inHeaderNames, DAVResource &ioResource, apr_status_t &outSerfStatus)
bool processMkCol(apr_status_t &outSerfStatus)
bool processDelete(apr_status_t &outSerfStatus)
SerfRequestProcessor(SerfSession &rSerfSession, const OUString &inPath, const bool bUseChunkedEncoding)
void postprocessProcessor(const apr_status_t inStatus)
apr_status_t provideSerfCredentials(char **outUsername, char **outPassword, serf_request_t *inRequest, int inCode, const char *inAuthProtocol, const char *inRealm, apr_pool_t *inAprPool)
bool processGet(const rtl::Reference< SerfInputStream > &xioInStrm, apr_status_t &outSerfStatus)
apr_status_t setupSerfRequest(serf_request_t *inSerfRequest, serf_bucket_t **outSerfRequestBucket, serf_response_acceptor_t *outSerfResponseAcceptor, void **outSerfResponseAcceptorBaton, serf_response_handler_t *outSerfResponseHandler, void **outSerfResponseHandlerBaton, apr_pool_t *inAprPool)
bool processPropPatch(const std::vector< ProppatchValue > &inProperties, apr_status_t &outSerfStatus)
bool processLock(const css::ucb::Lock &rLock, sal_Int32 *plastChanceToSendRefreshRequest=nullptr)
serf_bucket_t * acceptSerfResponse(serf_request_t *inSerfRequest, serf_bucket_t *inSerfStreamBucket, apr_pool_t *inAprPool)
apr_status_t handleSerfResponse(serf_request_t *inSerfRequest, serf_bucket_t *inSerfResponseBucket, apr_pool_t *inAprPool)
unsigned char sal_uInt8
bool processPost(const char *inData, apr_size_t inDataLen, const OUString &inContentType, const OUString &inReferer, const rtl::Reference< SerfInputStream > &xioInStrm, apr_status_t &outSerfStatus)
bool processPut(const char *inData, apr_size_t inDataLen, apr_status_t &outSerfStatus)
bool processPropFind(const Depth inDepth, const std::vector< OUString > &inPropNames, std::vector< DAVResource > &ioResources, apr_status_t &outSerfStatus)