merge the formfield patch from ooo-build
[ooovba.git] / ucb / source / ucp / webdav / NeonSession.hxx
blob581c01763dcc9cff212f387881922c6df4a41788
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: NeonSession.hxx,v $
10 * $Revision: 1.31.12.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _NEONSESSION_HXX_
32 #define _NEONSESSION_HXX_
34 #include <vector>
35 #include <osl/mutex.hxx>
36 #include "DAVSession.hxx"
37 #include "NeonTypes.hxx"
38 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 using namespace com::sun::star;
42 namespace ucbhelper { class ProxyDecider; }
44 namespace webdav_ucp
47 // -------------------------------------------------------------------
48 // NeonSession
49 // A DAVSession implementation using the neon/expat library
50 // -------------------------------------------------------------------
52 class NeonSession : public DAVSession
54 private:
55 osl::Mutex m_aMutex;
56 static osl::Mutex m_aGlobalMutex;
57 rtl::OUString m_aScheme;
58 rtl::OUString m_aHostName;
59 rtl::OUString m_aProxyName;
60 rtl::OUString m_aUserInfo;
61 sal_Int32 m_nPort;
62 sal_Int32 m_nProxyPort;
63 HttpSession * m_pHttpSession;
64 void * m_pRequestData;
65 const ucbhelper::InternetProxyDecider & m_rProxyDecider;
67 // @@@ This should really be per-request data. But Neon currently
68 // (0.23.5) has no interface for passing per-request user data.
69 // Theoretically, a NeonSession instance could handle multiple requests
70 // at a time --currently it doesn't. Thus this is not an issue at the
71 // moment.
72 DAVRequestEnvironment m_aEnv;
74 static NeonLockStore *s_aNeonLockStore;
76 static bool m_bGlobalsInited;
78 protected:
79 virtual ~NeonSession();
81 public:
82 NeonSession( const rtl::Reference< DAVSessionFactory > & rSessionFactory,
83 const rtl::OUString& inUri,
84 const ucbhelper::InternetProxyDecider & rProxyDecider )
85 throw ( DAVException );
87 // DAVSession methods
88 virtual sal_Bool CanUse( const ::rtl::OUString & inUri );
90 virtual sal_Bool UsesProxy();
92 const DAVRequestEnvironment & getRequestEnvironment() const
93 { return m_aEnv; }
95 const rtl::OUString & getUserInfo() const { return m_aUserInfo; }
97 virtual void
98 OPTIONS( const ::rtl::OUString & inPath,
99 DAVCapabilities & outCapabilities,
100 const DAVRequestEnvironment & rEnv )
101 throw ( DAVException );
103 // allprop & named
104 virtual void
105 PROPFIND( const ::rtl::OUString & inPath,
106 const Depth inDepth,
107 const std::vector< ::rtl::OUString > & inPropNames,
108 std::vector< DAVResource > & ioResources,
109 const DAVRequestEnvironment & rEnv )
110 throw ( DAVException );
112 // propnames
113 virtual void
114 PROPFIND( const ::rtl::OUString & inPath,
115 const Depth inDepth,
116 std::vector< DAVResourceInfo >& ioResInfo,
117 const DAVRequestEnvironment & rEnv )
118 throw ( DAVException );
120 virtual void
121 PROPPATCH( const ::rtl::OUString & inPath,
122 const std::vector< ProppatchValue > & inValues,
123 const DAVRequestEnvironment & rEnv )
124 throw( DAVException );
126 virtual void
127 HEAD( const ::rtl::OUString & inPath,
128 const std::vector< ::rtl::OUString > & inHeaderNames,
129 DAVResource & ioResource,
130 const DAVRequestEnvironment & rEnv )
131 throw( DAVException );
133 virtual com::sun::star::uno::Reference<
134 com::sun::star::io::XInputStream >
135 GET( const ::rtl::OUString & inPath,
136 const DAVRequestEnvironment & rEnv )
137 throw ( DAVException );
139 virtual void
140 GET( const ::rtl::OUString & inPath,
141 com::sun::star::uno::Reference<
142 com::sun::star::io::XOutputStream > & ioOutputStream,
143 const DAVRequestEnvironment & rEnv )
144 throw ( DAVException );
146 virtual com::sun::star::uno::Reference<
147 com::sun::star::io::XStream >
148 GET( const ::rtl::OUString & inPath,
149 const std::vector< ::rtl::OUString > & inHeaderNames,
150 DAVResource & ioResource,
151 const DAVRequestEnvironment & rEnv,
152 sal_Bool bAllowEmpty = sal_False )
153 throw ( DAVException );
155 virtual void
156 GET( const ::rtl::OUString & inPath,
157 com::sun::star::uno::Reference<
158 com::sun::star::io::XOutputStream > & ioOutputStream,
159 const std::vector< ::rtl::OUString > & inHeaderNames,
160 DAVResource & ioResource,
161 const DAVRequestEnvironment & rEnv )
162 throw ( DAVException );
164 virtual void
165 PUT( const ::rtl::OUString & inPath,
166 const com::sun::star::uno::Reference<
167 com::sun::star::io::XInputStream > & inInputStream,
168 const DAVRequestEnvironment & rEnv )
169 throw ( DAVException );
171 virtual void
172 PUT( const ::rtl::OUString & inPath,
173 const char * buffer,
174 size_t size,
175 const DAVRequestEnvironment & rEnv )
176 throw ( DAVException );
178 virtual com::sun::star::uno::Reference<
179 com::sun::star::io::XInputStream >
180 POST( const rtl::OUString & inPath,
181 const rtl::OUString & rContentType,
182 const rtl::OUString & rReferer,
183 const com::sun::star::uno::Reference<
184 com::sun::star::io::XInputStream > & inInputStream,
185 const DAVRequestEnvironment & rEnv )
186 throw ( DAVException );
188 virtual void
189 POST( const rtl::OUString & inPath,
190 const rtl::OUString & rContentType,
191 const rtl::OUString & rReferer,
192 const com::sun::star::uno::Reference<
193 com::sun::star::io::XInputStream > & inInputStream,
194 com::sun::star::uno::Reference<
195 com::sun::star::io::XOutputStream > & oOutputStream,
196 const DAVRequestEnvironment & rEnv )
197 throw ( DAVException );
199 virtual void
200 MKCOL( const ::rtl::OUString & inPath,
201 const DAVRequestEnvironment & rEnv )
202 throw ( DAVException );
204 virtual void
205 COPY( const ::rtl::OUString & inSourceURL,
206 const ::rtl::OUString & inDestinationURL,
207 const DAVRequestEnvironment & rEnv,
208 sal_Bool inOverWrite )
209 throw ( DAVException );
211 virtual void
212 MOVE( const ::rtl::OUString & inSourceURL,
213 const ::rtl::OUString & inDestinationURL,
214 const DAVRequestEnvironment & rEnv,
215 sal_Bool inOverWrite )
216 throw ( DAVException );
218 virtual void DESTROY( const ::rtl::OUString & inPath,
219 const DAVRequestEnvironment & rEnv )
220 throw ( DAVException );
222 virtual void ABORT()
223 throw ( DAVException );
225 virtual void LOCK ( com::sun::star::ucb::Lock & rLock,
226 const DAVRequestEnvironment & rEnv )
227 throw ( DAVException );
229 virtual void UNLOCK ( com::sun::star::ucb::Lock & rLock,
230 const DAVRequestEnvironment & rEnv )
231 throw ( DAVException );
233 // helpers
234 const rtl::OUString & getHostName() const { return m_aHostName; }
236 const ::uno::Reference< ::lang::XMultiServiceFactory > getMSF() { return m_xFactory->getServiceFactory(); }
238 const void * getRequestData() const { return m_pRequestData; }
240 sal_Bool isDomainMatch( rtl::OUString certHostName );
242 private:
243 // Initialise "Neon sockets"
244 void Init( void )
245 throw ( DAVException );
247 void HandleError( int nError )
248 throw ( DAVException );
250 const ucbhelper::InternetProxyServer & getProxySettings() const;
252 void Lockit( com::sun::star::ucb::Lock & rLock, bool bLockit )
253 throw ( DAVException );
255 // low level GET implementation, used by public GET implementations
256 static int GET( ne_session * sess,
257 const char * uri,
258 ne_block_reader reader,
259 bool getheaders,
260 void * userdata );
262 // Buffer-based PUT implementation. Neon only has file descriptor-
263 // based API.
264 static int PUT( ne_session * sess,
265 const char * uri,
266 const char * buffer,
267 size_t size );
269 // Buffer-based POST implementation. Neon only has file descriptor-
270 // based API.
271 int POST( ne_session * sess,
272 const char * uri,
273 const char * buffer,
274 ne_block_reader reader,
275 void * userdata,
276 const rtl::OUString & rContentType,
277 const rtl::OUString & rReferer );
279 // Helper: XInputStream -> Sequence< sal_Int8 >
280 static bool getDataFromInputStream(
281 const com::sun::star::uno::Reference<
282 com::sun::star::io::XInputStream > & xStream,
283 com::sun::star::uno::Sequence< sal_Int8 > & rData,
284 bool bAppendTrailingZeroByte );
286 typedef std::map< ::rtl::OUString, ::rtl::OUString > Map;
287 static Map certMap;
290 } // namespace_ucp
292 #endif // _NEONSESSION_HXX_