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