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 INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_NEONSESSION_HXX
30 #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_NEONSESSION_HXX
32 #include <config_lgpl.h>
34 #include <osl/mutex.hxx>
35 #include "DAVSession.hxx"
36 #include "NeonTypes.hxx"
37 #include "NeonLockStore.hxx"
38 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 namespace ucbhelper
{ class ProxyDecider
; }
45 // A DAVSession implementation using the neon/expat library
46 class NeonSession
: public DAVSession
52 OUString m_aProxyName
;
54 sal_Int32 m_nProxyPort
;
55 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
> m_aFlags
;
56 HttpSession
* m_pHttpSession
;
57 void * m_pRequestData
;
58 const ucbhelper::InternetProxyDecider
& m_rProxyDecider
;
60 // @@@ This should really be per-request data. But Neon currently
61 // (0.23.5) has no interface for passing per-request user data.
62 // Theoretically, a NeonSession instance could handle multiple requests
63 // at a time --currently it doesn't. Thus this is not an issue at the
65 DAVRequestEnvironment m_aEnv
;
67 static bool m_bGlobalsInited
;
68 static NeonLockStore m_aNeonLockStore
;
71 virtual ~NeonSession();
74 NeonSession( const rtl::Reference
< DAVSessionFactory
> & rSessionFactory
,
75 const OUString
& inUri
,
76 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
>& rFlags
,
77 const ucbhelper::InternetProxyDecider
& rProxyDecider
)
78 throw ( std::exception
);
81 virtual bool CanUse( const OUString
& inPath
,
82 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
>& rFlags
) SAL_OVERRIDE
;
84 virtual bool UsesProxy() SAL_OVERRIDE
;
86 const DAVRequestEnvironment
& getRequestEnvironment() const
90 OPTIONS( const OUString
& inPath
,
91 DAVCapabilities
& outCapabilities
,
92 const DAVRequestEnvironment
& rEnv
)
93 throw ( std::exception
) SAL_OVERRIDE
;
97 PROPFIND( const OUString
& inPath
,
99 const std::vector
< OUString
> & inPropNames
,
100 std::vector
< DAVResource
> & ioResources
,
101 const DAVRequestEnvironment
& rEnv
)
102 throw ( std::exception
) SAL_OVERRIDE
;
106 PROPFIND( const OUString
& inPath
,
108 std::vector
< DAVResourceInfo
>& ioResInfo
,
109 const DAVRequestEnvironment
& rEnv
)
110 throw ( std::exception
) SAL_OVERRIDE
;
113 PROPPATCH( const OUString
& inPath
,
114 const std::vector
< ProppatchValue
> & inValues
,
115 const DAVRequestEnvironment
& rEnv
)
116 throw ( std::exception
) SAL_OVERRIDE
;
119 HEAD( const OUString
& inPath
,
120 const std::vector
< OUString
> & inHeaderNames
,
121 DAVResource
& ioResource
,
122 const DAVRequestEnvironment
& rEnv
)
123 throw ( std::exception
) SAL_OVERRIDE
;
125 virtual com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
>
126 GET( const OUString
& inPath
,
127 const DAVRequestEnvironment
& rEnv
)
128 throw ( std::exception
) SAL_OVERRIDE
;
131 GET( const OUString
& inPath
,
132 com::sun::star::uno::Reference
<
133 com::sun::star::io::XOutputStream
> & ioOutputStream
,
134 const DAVRequestEnvironment
& rEnv
)
135 throw ( std::exception
) SAL_OVERRIDE
;
137 virtual com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
>
138 GET( const OUString
& inPath
,
139 const std::vector
< OUString
> & inHeaderNames
,
140 DAVResource
& ioResource
,
141 const DAVRequestEnvironment
& rEnv
)
142 throw ( std::exception
) SAL_OVERRIDE
;
145 GET( const OUString
& inPath
,
146 com::sun::star::uno::Reference
<
147 com::sun::star::io::XOutputStream
> & ioOutputStream
,
148 const std::vector
< OUString
> & inHeaderNames
,
149 DAVResource
& ioResource
,
150 const DAVRequestEnvironment
& rEnv
)
151 throw ( std::exception
) SAL_OVERRIDE
;
154 PUT( const OUString
& inPath
,
155 const com::sun::star::uno::Reference
<
156 com::sun::star::io::XInputStream
> & inInputStream
,
157 const DAVRequestEnvironment
& rEnv
)
158 throw ( std::exception
) SAL_OVERRIDE
;
160 virtual com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
>
161 POST( const OUString
& inPath
,
162 const OUString
& rContentType
,
163 const OUString
& rReferer
,
164 const com::sun::star::uno::Reference
<
165 com::sun::star::io::XInputStream
> & inInputStream
,
166 const DAVRequestEnvironment
& rEnv
)
167 throw ( std::exception
) SAL_OVERRIDE
;
170 POST( const OUString
& inPath
,
171 const OUString
& rContentType
,
172 const OUString
& rReferer
,
173 const com::sun::star::uno::Reference
<
174 com::sun::star::io::XInputStream
> & inInputStream
,
175 com::sun::star::uno::Reference
<
176 com::sun::star::io::XOutputStream
> & oOutputStream
,
177 const DAVRequestEnvironment
& rEnv
)
178 throw ( std::exception
) SAL_OVERRIDE
;
181 MKCOL( const OUString
& inPath
,
182 const DAVRequestEnvironment
& rEnv
)
183 throw ( std::exception
) SAL_OVERRIDE
;
186 COPY( const OUString
& inSourceURL
,
187 const OUString
& inDestinationURL
,
188 const DAVRequestEnvironment
& rEnv
,
190 throw ( std::exception
) SAL_OVERRIDE
;
193 MOVE( const OUString
& inSourceURL
,
194 const OUString
& inDestinationURL
,
195 const DAVRequestEnvironment
& rEnv
,
197 throw ( std::exception
) SAL_OVERRIDE
;
199 virtual void DESTROY( const OUString
& inPath
,
200 const DAVRequestEnvironment
& rEnv
)
201 throw ( std::exception
) SAL_OVERRIDE
;
204 virtual void LOCK( const OUString
& inURL
,
205 com::sun::star::ucb::Lock
& inLock
,
206 const DAVRequestEnvironment
& rEnv
)
207 throw ( std::exception
) SAL_OVERRIDE
;
209 // refresh existing lock.
210 virtual sal_Int64
LOCK( const OUString
& inURL
,
212 const DAVRequestEnvironment
& rEnv
)
213 throw ( std::exception
) SAL_OVERRIDE
;
215 virtual void UNLOCK( const OUString
& inURL
,
216 const DAVRequestEnvironment
& rEnv
)
217 throw ( std::exception
) SAL_OVERRIDE
;
221 throw ( std::exception
) SAL_OVERRIDE
;
223 const OUString
& getHostName() const { return m_aHostName
; }
225 const ::uno::Reference
< ::uno::XComponentContext
> getComponentContext()
226 { return m_xFactory
->getComponentContext(); }
228 const void * getRequestData() const { return m_pRequestData
; }
230 bool isDomainMatch( const OUString
& certHostName
);
233 friend class NeonLockStore
;
236 throw (css::uno::RuntimeException
, std::exception
);
238 void Init( const DAVRequestEnvironment
& rEnv
)
239 throw (css::uno::RuntimeException
, std::exception
);
241 // ret: true => retry request.
242 void HandleError( int nError
,
243 const OUString
& inPath
,
244 const DAVRequestEnvironment
& rEnv
)
245 throw ( std::exception
);
247 const ucbhelper::InternetProxyServer
& getProxySettings() const;
249 bool removeExpiredLocktoken( const OUString
& inURL
,
250 const DAVRequestEnvironment
& rEnv
);
252 // refresh lock, called by NeonLockStore::refreshLocks
253 bool LOCK( NeonLock
* pLock
,
254 sal_Int32
& rlastChanceToSendRefreshRequest
);
256 // unlock, called by NeonLockStore::~NeonLockStore
257 bool UNLOCK( NeonLock
* pLock
);
259 // low level GET implementation, used by public GET implementations
260 static int GET( ne_session
* sess
,
262 ne_block_reader reader
,
266 // Buffer-based PUT implementation. Neon only has file descriptor-
268 static int PUT( ne_session
* sess
,
273 // Buffer-based POST implementation. Neon only has file descriptor-
275 int POST( ne_session
* sess
,
278 ne_block_reader reader
,
280 const OUString
& rContentType
,
281 const OUString
& rReferer
);
283 // Helper: XInputStream -> Sequence< sal_Int8 >
284 static bool getDataFromInputStream(
285 const com::sun::star::uno::Reference
<
286 com::sun::star::io::XInputStream
> & xStream
,
287 com::sun::star::uno::Sequence
< sal_Int8
> & rData
,
288 bool bAppendTrailingZeroByte
);
290 OUString
makeAbsoluteURL( OUString
const & rURL
) const;
293 } // namespace webdav_ucp
295 #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_NEONSESSION_HXX
297 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */