1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _NEONSESSION_HXX_
30 #define _NEONSESSION_HXX_
33 #include <osl/mutex.hxx>
34 #include "DAVSession.hxx"
35 #include "NeonTypes.hxx"
36 #include "NeonLockStore.hxx"
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
39 namespace ucbhelper
{ class ProxyDecider
; }
44 // -------------------------------------------------------------------
46 // A DAVSession implementation using the neon/expat library
47 // -------------------------------------------------------------------
49 class NeonSession
: public DAVSession
53 rtl::OUString m_aScheme
;
54 rtl::OUString m_aHostName
;
55 rtl::OUString m_aProxyName
;
57 sal_Int32 m_nProxyPort
;
58 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
> m_aFlags
;
59 HttpSession
* m_pHttpSession
;
60 void * m_pRequestData
;
61 const ucbhelper::InternetProxyDecider
& m_rProxyDecider
;
63 // @@@ This should really be per-request data. But Neon currently
64 // (0.23.5) has no interface for passing per-request user data.
65 // Theoretically, a NeonSession instance could handle multiple requests
66 // at a time --currently it doesn't. Thus this is not an issue at the
68 DAVRequestEnvironment m_aEnv
;
70 static bool m_bGlobalsInited
;
71 static NeonLockStore m_aNeonLockStore
;
74 virtual ~NeonSession();
77 NeonSession( const rtl::Reference
< DAVSessionFactory
> & rSessionFactory
,
78 const rtl::OUString
& inUri
,
79 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
>& rFlags
,
80 const ucbhelper::InternetProxyDecider
& rProxyDecider
)
81 throw ( DAVException
);
84 virtual sal_Bool
CanUse( const ::rtl::OUString
& inPath
,
85 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
>& rFlags
);
87 virtual sal_Bool
UsesProxy();
89 const DAVRequestEnvironment
& getRequestEnvironment() const
93 OPTIONS( const ::rtl::OUString
& inPath
,
94 DAVCapabilities
& outCapabilities
,
95 const DAVRequestEnvironment
& rEnv
)
96 throw ( DAVException
);
100 PROPFIND( const ::rtl::OUString
& inPath
,
102 const std::vector
< ::rtl::OUString
> & inPropNames
,
103 std::vector
< DAVResource
> & ioResources
,
104 const DAVRequestEnvironment
& rEnv
)
105 throw ( DAVException
);
109 PROPFIND( const ::rtl::OUString
& inPath
,
111 std::vector
< DAVResourceInfo
>& ioResInfo
,
112 const DAVRequestEnvironment
& rEnv
)
113 throw ( DAVException
);
116 PROPPATCH( const ::rtl::OUString
& inPath
,
117 const std::vector
< ProppatchValue
> & inValues
,
118 const DAVRequestEnvironment
& rEnv
)
119 throw ( DAVException
);
122 HEAD( const ::rtl::OUString
& inPath
,
123 const std::vector
< ::rtl::OUString
> & inHeaderNames
,
124 DAVResource
& ioResource
,
125 const DAVRequestEnvironment
& rEnv
)
126 throw ( DAVException
);
128 virtual com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
>
129 GET( const ::rtl::OUString
& inPath
,
130 const DAVRequestEnvironment
& rEnv
)
131 throw ( DAVException
);
134 GET( const ::rtl::OUString
& inPath
,
135 com::sun::star::uno::Reference
<
136 com::sun::star::io::XOutputStream
> & ioOutputStream
,
137 const DAVRequestEnvironment
& rEnv
)
138 throw ( DAVException
);
140 virtual com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
>
141 GET( const ::rtl::OUString
& inPath
,
142 const std::vector
< ::rtl::OUString
> & inHeaderNames
,
143 DAVResource
& ioResource
,
144 const DAVRequestEnvironment
& rEnv
)
145 throw ( DAVException
);
148 GET( const ::rtl::OUString
& inPath
,
149 com::sun::star::uno::Reference
<
150 com::sun::star::io::XOutputStream
> & ioOutputStream
,
151 const std::vector
< ::rtl::OUString
> & inHeaderNames
,
152 DAVResource
& ioResource
,
153 const DAVRequestEnvironment
& rEnv
)
154 throw ( DAVException
);
157 PUT( const ::rtl::OUString
& inPath
,
158 const com::sun::star::uno::Reference
<
159 com::sun::star::io::XInputStream
> & inInputStream
,
160 const DAVRequestEnvironment
& rEnv
)
161 throw ( DAVException
);
163 virtual com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
>
164 POST( const rtl::OUString
& inPath
,
165 const rtl::OUString
& rContentType
,
166 const rtl::OUString
& rReferer
,
167 const com::sun::star::uno::Reference
<
168 com::sun::star::io::XInputStream
> & inInputStream
,
169 const DAVRequestEnvironment
& rEnv
)
170 throw ( DAVException
);
173 POST( const rtl::OUString
& inPath
,
174 const rtl::OUString
& rContentType
,
175 const rtl::OUString
& rReferer
,
176 const com::sun::star::uno::Reference
<
177 com::sun::star::io::XInputStream
> & inInputStream
,
178 com::sun::star::uno::Reference
<
179 com::sun::star::io::XOutputStream
> & oOutputStream
,
180 const DAVRequestEnvironment
& rEnv
)
181 throw ( DAVException
);
184 MKCOL( const ::rtl::OUString
& inPath
,
185 const DAVRequestEnvironment
& rEnv
)
186 throw ( DAVException
);
189 COPY( const ::rtl::OUString
& inSourceURL
,
190 const ::rtl::OUString
& inDestinationURL
,
191 const DAVRequestEnvironment
& rEnv
,
192 sal_Bool inOverWrite
)
193 throw ( DAVException
);
196 MOVE( const ::rtl::OUString
& inSourceURL
,
197 const ::rtl::OUString
& inDestinationURL
,
198 const DAVRequestEnvironment
& rEnv
,
199 sal_Bool inOverWrite
)
200 throw ( DAVException
);
202 virtual void DESTROY( const ::rtl::OUString
& inPath
,
203 const DAVRequestEnvironment
& rEnv
)
204 throw ( DAVException
);
207 virtual void LOCK( const ::rtl::OUString
& inURL
,
208 com::sun::star::ucb::Lock
& inLock
,
209 const DAVRequestEnvironment
& rEnv
)
210 throw ( DAVException
);
212 // refresh existing lock.
213 virtual sal_Int64
LOCK( const ::rtl::OUString
& inURL
,
215 const DAVRequestEnvironment
& rEnv
)
216 throw ( DAVException
);
218 virtual void UNLOCK( const ::rtl::OUString
& inURL
,
219 const DAVRequestEnvironment
& rEnv
)
220 throw ( DAVException
);
224 throw ( DAVException
);
226 const rtl::OUString
& getHostName() const { return m_aHostName
; }
228 const ::uno::Reference
< ::lang::XMultiServiceFactory
> getMSF()
229 { return m_xFactory
->getServiceFactory(); }
231 const void * getRequestData() const { return m_pRequestData
; }
233 sal_Bool
isDomainMatch( rtl::OUString certHostName
);
236 friend class NeonLockStore
;
239 throw ( DAVException
);
241 void Init( const DAVRequestEnvironment
& rEnv
)
242 throw ( DAVException
);
244 // ret: true => retry request.
245 void HandleError( int nError
,
246 const rtl::OUString
& inPath
,
247 const DAVRequestEnvironment
& rEnv
)
248 throw ( DAVException
);
250 const ucbhelper::InternetProxyServer
& getProxySettings() const;
252 bool removeExpiredLocktoken( const rtl::OUString
& inURL
,
253 const DAVRequestEnvironment
& rEnv
);
255 // refresh lock, called by NeonLockStore::refreshLocks
256 bool LOCK( NeonLock
* pLock
,
257 sal_Int32
& rlastChanceToSendRefreshRequest
);
259 // unlock, called by NeonLockStore::~NeonLockStore
260 bool UNLOCK( NeonLock
* pLock
);
262 // low level GET implementation, used by public GET implementations
263 static int GET( ne_session
* sess
,
265 ne_block_reader reader
,
269 // Buffer-based PUT implementation. Neon only has file descriptor-
271 static int PUT( ne_session
* sess
,
276 // Buffer-based POST implementation. Neon only has file descriptor-
278 int POST( ne_session
* sess
,
281 ne_block_reader reader
,
283 const rtl::OUString
& rContentType
,
284 const rtl::OUString
& rReferer
);
286 // Helper: XInputStream -> Sequence< sal_Int8 >
287 static bool getDataFromInputStream(
288 const com::sun::star::uno::Reference
<
289 com::sun::star::io::XInputStream
> & xStream
,
290 com::sun::star::uno::Sequence
< sal_Int8
> & rData
,
291 bool bAppendTrailingZeroByte
);
293 rtl::OUString
makeAbsoluteURL( rtl::OUString
const & rURL
) const;
296 } // namespace webdav_ucp
298 #endif // _NEONSESSION_HXX_
300 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */