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 #pragma once
22 
23 #include <apr_errno.h>
24 #include <apr_pools.h>
25 
26 #include <serf.h>
27 
28 #include "DAVTypes.hxx"
29 #include "DAVResource.hxx"
30 #include "DAVException.hxx"
31 
32 #include "SerfInputStream.hxx"
33 #include <com/sun/star/io/XOutputStream.hpp>
34 #include <com/sun/star/ucb/Lock.hpp>
35 
36 #include <rtl/ref.hxx>
37 
38 namespace http_dav_ucp
39 {
40 
41 class SerfSession;
42 class SerfRequestProcessorImpl;
43 
45 {
46 public:
47  SerfRequestProcessor( SerfSession& rSerfSession,
48  const OUString & inPath,
49  const bool bUseChunkedEncoding );
51 
52  // PROPFIND - allprop & named
53  bool processPropFind( const Depth inDepth,
54  const std::vector< OUString > & inPropNames,
55  std::vector< DAVResource > & ioResources,
56  apr_status_t& outSerfStatus );
57 
58  // PROPFIND - property names
59  bool processPropFind( const Depth inDepth,
60  std::vector< DAVResourceInfo > & ioResInfo,
61  apr_status_t& outSerfStatus );
62 
63  // PROPPATCH
64  bool processPropPatch( const std::vector< ProppatchValue > & inProperties,
65  apr_status_t& outSerfStatus );
66 
67  // GET
68  bool processGet( const rtl::Reference< SerfInputStream >& xioInStrm,
69  apr_status_t& outSerfStatus );
70 
71  // GET inclusive header fields
72  bool processGet( const rtl::Reference< SerfInputStream >& xioInStrm,
73  const std::vector< OUString > & inHeaderNames,
74  DAVResource & ioResource,
75  apr_status_t& outSerfStatus );
76 
77  // GET
78  bool processGet( const css::uno::Reference< css::io::XOutputStream >& xioOutStrm,
79  apr_status_t& outSerfStatus );
80 
81  // GET inclusive header fields
82  bool processGet( const css::uno::Reference< css::io::XOutputStream >& xioOutStrm,
83  const std::vector< OUString > & inHeaderNames,
84  DAVResource & ioResource,
85  apr_status_t& outSerfStatus );
86 
87  // HEAD
88  bool processHead( const std::vector< OUString > & inHeaderNames,
89  DAVResource & ioResource,
90  apr_status_t& outSerfStatus );
91 
92  // PUT
93  bool processPut( const char* inData,
94  apr_size_t inDataLen,
95  apr_status_t& outSerfStatus );
96 
97  // POST
98  bool processPost( const char* inData,
99  apr_size_t inDataLen,
100  const OUString & inContentType,
101  const OUString & inReferer,
102  const rtl::Reference< SerfInputStream >& xioInStrm,
103  apr_status_t& outSerfStatus );
104 
105  // POST
106  bool processPost( const char* inData,
107  apr_size_t inDataLen,
108  const OUString & inContentType,
109  const OUString & inReferer,
110  const css::uno::Reference< css::io::XOutputStream >& xioOutStrm,
111  apr_status_t& outSerfStatus );
112 
113  // DELETE
114  bool processDelete( apr_status_t& outSerfStatus );
115 
116  // MKCOL
117  bool processMkCol( apr_status_t& outSerfStatus );
118 
119  // COPY
120  bool processCopy( const OUString & inDestinationPath,
121  const bool inOverwrite,
122  apr_status_t& outSerfStatus );
123 
124  // MOVE
125  bool processMove( const OUString & inDestinationPath,
126  const bool inOverwrite,
127  apr_status_t& outSerfStatus );
128 
129  //LOCK
130  bool processLock( const css::ucb::Lock & rLock, sal_Int32 *plastChanceToSendRefreshRequest = nullptr );
131 
132  //UNLOCK
133  bool processUnlock();
134 
135  apr_status_t provideSerfCredentials( char ** outUsername,
136  char ** outPassword,
137  serf_request_t * inRequest,
138  int inCode,
139  const char *inAuthProtocol,
140  const char *inRealm,
141  apr_pool_t *inAprPool );
142 
143  apr_status_t setupSerfRequest( serf_request_t * inSerfRequest,
144  serf_bucket_t ** outSerfRequestBucket,
145  serf_response_acceptor_t * outSerfResponseAcceptor,
146  void ** outSerfResponseAcceptorBaton,
147  serf_response_handler_t * outSerfResponseHandler,
148  void ** outSerfResponseHandlerBaton,
149  apr_pool_t * inAprPool );
150 
151  serf_bucket_t* acceptSerfResponse( serf_request_t * inSerfRequest,
152  serf_bucket_t * inSerfStreamBucket,
153  apr_pool_t* inAprPool );
154 
155  apr_status_t handleSerfResponse( serf_request_t * inSerfRequest,
156  serf_bucket_t * inSerfResponseBucket,
157  apr_pool_t * inAprPool );
158 
159 //private:
160  void prepareProcessor();
161  apr_status_t runProcessor();
162  void postprocessProcessor( const apr_status_t inStatus );
163 
165  const char* mPathStr;
167  const char* mDestPathStr;
168  const char* mContentType;
169  const char* mReferer;
171 
173 
175  sal_uInt16 mnHTTPStatusCode;
178 
184 };
185 
186 } // namespace http_dav_ucp
187 
188 /* 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)