fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / ucb / source / ucp / webdav / SerfSession.hxx
bloba2f5402059ce5bac1e7b30898b7f372cc4466d88
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #ifndef INCLUDED_UCB_SOURCE_UCP_WEBDAV_SERFSESSION_HXX
23 #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_SERFSESSION_HXX
25 #include <vector>
26 #include <boost/shared_ptr.hpp>
27 #include <osl/mutex.hxx>
28 #include "DAVSession.hxx"
29 #include "SerfUri.hxx"
31 #include <serf.h>
33 namespace ucbhelper { class ProxyDecider; }
35 namespace http_dav_ucp
38 class SerfRequestProcessor;
41 // SerfSession
42 // A DAVSession implementation using the neon/expat library
45 class SerfSession : public DAVSession
47 private:
48 osl::Mutex m_aMutex;
50 SerfUri m_aUri;
52 OUString m_aProxyName;
53 sal_Int32 m_nProxyPort;
55 serf_connection_t* m_pSerfConnection;
56 serf_context_t* m_pSerfContext;
57 serf_bucket_alloc_t* m_pSerfBucket_Alloc;
58 bool m_bIsHeadRequestInProgress;
59 bool m_bUseChunkedEncoding;
60 sal_Int16 m_bNoOfTransferEncodingSwitches;
62 const ucbhelper::InternetProxyDecider & m_rProxyDecider;
64 DAVRequestEnvironment m_aEnv;
66 char* getHostinfo();
67 bool isSSLNeeded();
69 SerfRequestProcessor* createReqProc( const OUString & inPath );
71 protected:
72 virtual ~SerfSession();
74 public:
75 SerfSession( const rtl::Reference< DAVSessionFactory > & rSessionFactory,
76 const OUString& inUri,
77 const ucbhelper::InternetProxyDecider & rProxyDecider )
78 throw ( DAVException );
80 // Serf library callbacks
81 apr_status_t setupSerfConnection( apr_socket_t * inAprSocket,
82 serf_bucket_t **outSerfInputBucket,
83 serf_bucket_t **outSerfOutputBucket,
84 apr_pool_t* inAprPool );
86 apr_status_t provideSerfCredentials( bool bGiveProvidedCredentialsASecondTry,
87 char ** outUsername,
88 char ** outPassword,
89 serf_request_t * inRequest,
90 int inCode,
91 const char *inAuthProtocol,
92 const char *inRealm,
93 apr_pool_t *inAprPool );
95 apr_status_t verifySerfCertificateChain (
96 int nFailures,
97 const serf_ssl_certificate_t * const * pCertificateChainBase64Encoded,
98 int nCertificateChainLength);
100 serf_bucket_t* acceptSerfResponse( serf_request_t * inSerfRequest,
101 serf_bucket_t * inSerfStreamBucket,
102 apr_pool_t* inAprPool );
104 // Serf-related data structures
105 apr_pool_t* getAprPool();
106 serf_bucket_alloc_t* getSerfBktAlloc();
107 serf_context_t* getSerfContext();
108 serf_connection_t* getSerfConnection();
110 // DAVSession methods
111 virtual bool CanUse( const OUString & inUri ) SAL_OVERRIDE;
113 virtual bool UsesProxy() SAL_OVERRIDE;
115 const DAVRequestEnvironment & getRequestEnvironment() const
116 { return m_aEnv; }
118 // allprop & named
119 virtual void
120 PROPFIND( const OUString & inPath,
121 const Depth inDepth,
122 const std::vector< OUString > & inPropNames,
123 std::vector< DAVResource > & ioResources,
124 const DAVRequestEnvironment & rEnv )
125 throw ( DAVException ) SAL_OVERRIDE;
127 // propnames
128 virtual void
129 PROPFIND( const OUString & inPath,
130 const Depth inDepth,
131 std::vector< DAVResourceInfo >& ioResInfo,
132 const DAVRequestEnvironment & rEnv )
133 throw ( DAVException ) SAL_OVERRIDE;
135 virtual void
136 PROPPATCH( const OUString & inPath,
137 const std::vector< ProppatchValue > & inValues,
138 const DAVRequestEnvironment & rEnv )
139 throw ( DAVException ) SAL_OVERRIDE;
141 virtual void
142 HEAD( const OUString & inPath,
143 const std::vector< OUString > & inHeaderNames,
144 DAVResource & ioResource,
145 const DAVRequestEnvironment & rEnv )
146 throw ( DAVException ) SAL_OVERRIDE;
148 bool isHeadRequestInProgress();
150 virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
151 GET( const OUString & inPath,
152 const DAVRequestEnvironment & rEnv )
153 throw ( DAVException ) SAL_OVERRIDE;
155 virtual void
156 GET( const OUString & inPath,
157 com::sun::star::uno::Reference<
158 com::sun::star::io::XOutputStream > & ioOutputStream,
159 const DAVRequestEnvironment & rEnv )
160 throw ( DAVException ) SAL_OVERRIDE;
162 virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
163 GET( const OUString & inPath,
164 const std::vector< OUString > & inHeaderNames,
165 DAVResource & ioResource,
166 const DAVRequestEnvironment & rEnv )
167 throw ( DAVException ) SAL_OVERRIDE;
169 virtual void
170 GET( const OUString & inPath,
171 com::sun::star::uno::Reference<
172 com::sun::star::io::XOutputStream > & ioOutputStream,
173 const std::vector< OUString > & inHeaderNames,
174 DAVResource & ioResource,
175 const DAVRequestEnvironment & rEnv )
176 throw ( DAVException ) SAL_OVERRIDE;
178 virtual void
179 PUT( const OUString & inPath,
180 const com::sun::star::uno::Reference<
181 com::sun::star::io::XInputStream > & inInputStream,
182 const DAVRequestEnvironment & rEnv )
183 throw ( DAVException ) SAL_OVERRIDE;
185 virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
186 POST( const OUString & inPath,
187 const OUString & rContentType,
188 const OUString & rReferer,
189 const com::sun::star::uno::Reference<
190 com::sun::star::io::XInputStream > & inInputStream,
191 const DAVRequestEnvironment & rEnv )
192 throw ( DAVException ) SAL_OVERRIDE;
194 virtual void
195 POST( const OUString & inPath,
196 const OUString & rContentType,
197 const OUString & rReferer,
198 const com::sun::star::uno::Reference<
199 com::sun::star::io::XInputStream > & inInputStream,
200 com::sun::star::uno::Reference<
201 com::sun::star::io::XOutputStream > & oOutputStream,
202 const DAVRequestEnvironment & rEnv )
203 throw ( DAVException ) SAL_OVERRIDE;
205 virtual void
206 MKCOL( const OUString & inPath,
207 const DAVRequestEnvironment & rEnv )
208 throw ( DAVException ) SAL_OVERRIDE;
210 virtual void
211 COPY( const OUString & inSourceURL,
212 const OUString & inDestinationURL,
213 const DAVRequestEnvironment & rEnv,
214 bool inOverWrite )
215 throw ( DAVException ) SAL_OVERRIDE;
217 virtual void
218 MOVE( const OUString & inSourceURL,
219 const OUString & inDestinationURL,
220 const DAVRequestEnvironment & rEnv,
221 bool inOverWrite )
222 throw ( DAVException ) SAL_OVERRIDE;
224 virtual void DESTROY( const OUString & inPath,
225 const DAVRequestEnvironment & rEnv )
226 throw ( DAVException ) SAL_OVERRIDE;
228 // set new lock.
229 virtual void LOCK( const OUString & inURL,
230 com::sun::star::ucb::Lock & inLock,
231 const DAVRequestEnvironment & rEnv )
232 throw ( DAVException ) SAL_OVERRIDE;
234 // refresh existing lock.
235 virtual sal_Int64 LOCK( const OUString & inURL,
236 sal_Int64 nTimeout,
237 const DAVRequestEnvironment & rEnv )
238 throw ( DAVException ) SAL_OVERRIDE;
240 virtual void UNLOCK( const OUString & inURL,
241 const DAVRequestEnvironment & rEnv )
242 throw ( DAVException ) SAL_OVERRIDE;
244 // helpers
245 virtual void abort()
246 throw ( DAVException ) SAL_OVERRIDE;
248 const OUString & getHostName() const { return m_aUri.GetHost(); }
249 int getPort() const { return m_aUri.GetPort(); }
251 bool isDomainMatch( const OUString & certHostName );
253 private:
254 friend class SerfLockStore;
256 void Init()
257 throw ( DAVException );
259 void Init( const DAVRequestEnvironment & rEnv )
260 throw ( DAVException );
262 void HandleError( boost::shared_ptr<SerfRequestProcessor> rReqProc )
263 throw ( DAVException );
265 const ucbhelper::InternetProxyServer & getProxySettings() const;
267 bool removeExpiredLocktoken( const OUString & inURL,
268 const DAVRequestEnvironment & rEnv );
270 // refresh lock, called by SerfLockStore::refreshLocks
271 bool LOCK( const OUString& rLock, sal_Int32 *plastChanceToSendRefreshRequest );
273 // unlock, called by SerfLockStore::~SerfLockStore
274 void UNLOCK( const OUString& rLock );
277 // low level GET implementation, used by public GET implementations
278 static int GET( serf_connection_t * sess,
279 const char * uri,
280 //ne_block_reader reader,
281 bool getheaders,
282 void * userdata );
284 // Buffer-based PUT implementation. Serf only has file descriptor-
285 // based API.
286 static int PUT( serf_connection_t * sess,
287 const char * uri,
288 const char * buffer,
289 size_t size );
291 // Buffer-based POST implementation. Serf only has file descriptor-
292 // based API.
293 int POST( serf_connection_t * sess,
294 const char * uri,
295 const char * buffer,
296 //ne_block_reader reader,
297 void * userdata,
298 const OUString & rContentType,
299 const OUString & rReferer );
302 // Helper: XInputStream -> Sequence< sal_Int8 >
303 static bool getDataFromInputStream(
304 const com::sun::star::uno::Reference<
305 com::sun::star::io::XInputStream > & xStream,
306 com::sun::star::uno::Sequence< sal_Int8 > & rData,
307 bool bAppendTrailingZeroByte );
310 OUString makeAbsoluteURL( OUString const & rURL ) const;
314 } // namespace http_dav_ucp
316 #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_SERFSESSION_HXX
318 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */