Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : *
6 : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : *
8 : * OpenOffice.org - a multi-platform office productivity suite
9 : *
10 : * This file is part of OpenOffice.org.
11 : *
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.
15 : *
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).
21 : *
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.
26 : *
27 : ************************************************************************/
28 :
29 : #ifndef _DAVSESSION_HXX_
30 : #define _DAVSESSION_HXX_
31 :
32 : #include <config_lgpl.h>
33 : #include <memory>
34 : #include <rtl/ustring.hxx>
35 : #include <com/sun/star/io/XInputStream.hpp>
36 : #include <com/sun/star/io/XOutputStream.hpp>
37 : #include "DAVException.hxx"
38 : #include "DAVProperties.hxx"
39 : #include "DAVResource.hxx"
40 : #include "DAVSessionFactory.hxx"
41 : #include "DAVTypes.hxx"
42 : #include "DAVRequestEnvironment.hxx"
43 :
44 : namespace com { namespace sun { namespace star { namespace beans {
45 : struct NamedValue;
46 : } } } }
47 :
48 : namespace com { namespace sun { namespace star { namespace ucb {
49 : struct Lock;
50 : } } } }
51 :
52 : namespace webdav_ucp
53 : {
54 :
55 : class DAVSession
56 : {
57 : public:
58 0 : inline void acquire() SAL_THROW(())
59 : {
60 0 : osl_atomic_increment( &m_nRefCount );
61 0 : }
62 :
63 0 : void release() SAL_THROW(())
64 : {
65 0 : if ( osl_atomic_decrement( &m_nRefCount ) == 0 )
66 : {
67 0 : m_xFactory->releaseElement( this );
68 0 : delete this;
69 : }
70 0 : }
71 :
72 : virtual sal_Bool CanUse( const OUString & inPath,
73 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rFlags ) = 0;
74 :
75 : virtual sal_Bool UsesProxy() = 0;
76 :
77 : // DAV methods
78 :
79 :
80 : virtual void OPTIONS( const OUString & inPath,
81 : DAVCapabilities & outCapabilities,
82 : const DAVRequestEnvironment & rEnv )
83 : throw( DAVException ) = 0;
84 :
85 : // allprop & named
86 : virtual void PROPFIND( const OUString & inPath,
87 : const Depth inDepth,
88 : const std::vector< OUString > & inPropertyNames,
89 : std::vector< DAVResource > & ioResources,
90 : const DAVRequestEnvironment & rEnv )
91 : throw( DAVException ) = 0;
92 :
93 : // propnames
94 : virtual void PROPFIND( const OUString & inPath,
95 : const Depth inDepth,
96 : std::vector< DAVResourceInfo > & ioResInfo,
97 : const DAVRequestEnvironment & rEnv )
98 : throw( DAVException ) = 0;
99 :
100 : virtual void PROPPATCH( const OUString & inPath,
101 : const std::vector< ProppatchValue > & inValues,
102 : const DAVRequestEnvironment & rEnv )
103 : throw( DAVException ) = 0;
104 :
105 : virtual void HEAD( const OUString & inPath,
106 : const std::vector< OUString > & inHeaderNames,
107 : DAVResource & ioResource,
108 : const DAVRequestEnvironment & rEnv )
109 : throw( DAVException ) = 0;
110 :
111 : virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
112 : GET( const OUString & inPath,
113 : const DAVRequestEnvironment & rEnv )
114 : throw( DAVException ) = 0;
115 :
116 : virtual void GET( const OUString & inPath,
117 : com::sun::star::uno::Reference<
118 : com::sun::star::io::XOutputStream >& o,
119 : const DAVRequestEnvironment & rEnv )
120 : throw( DAVException ) = 0;
121 :
122 : virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
123 : GET( const OUString & inPath,
124 : const std::vector< OUString > & inHeaderNames,
125 : DAVResource & ioResource,
126 : const DAVRequestEnvironment & rEnv )
127 : throw( DAVException ) = 0;
128 :
129 : virtual void
130 : GET( const OUString & inPath,
131 : com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& o,
132 : const std::vector< OUString > & inHeaderNames,
133 : DAVResource & ioResource,
134 : const DAVRequestEnvironment & rEnv )
135 : throw( DAVException ) = 0;
136 :
137 : virtual void PUT( const OUString & inPath,
138 : const com::sun::star::uno::Reference<
139 : com::sun::star::io::XInputStream >& s,
140 : const DAVRequestEnvironment & rEnv )
141 : throw( DAVException ) = 0;
142 :
143 : virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
144 : POST( const OUString & inPath,
145 : const OUString & rContentType,
146 : const OUString & rReferer,
147 : const com::sun::star::uno::Reference<
148 : com::sun::star::io::XInputStream > & inInputStream,
149 : const DAVRequestEnvironment & rEnv )
150 : throw ( DAVException ) = 0;
151 :
152 : virtual void POST( const OUString & inPath,
153 : const OUString & rContentType,
154 : const OUString & rReferer,
155 : const com::sun::star::uno::Reference<
156 : com::sun::star::io::XInputStream > & inInputStream,
157 : com::sun::star::uno::Reference<
158 : com::sun::star::io::XOutputStream > & oOutputStream,
159 : const DAVRequestEnvironment & rEnv )
160 : throw ( DAVException ) = 0;
161 :
162 : virtual void MKCOL( const OUString & inPath,
163 : const DAVRequestEnvironment & rEnv )
164 : throw( DAVException ) = 0;
165 :
166 : virtual void COPY( const OUString & inSource,
167 : const OUString & inDestination,
168 : const DAVRequestEnvironment & rEnv,
169 : sal_Bool inOverwrite = false )
170 : throw( DAVException ) = 0;
171 :
172 : virtual void MOVE( const OUString & inSource,
173 : const OUString & inDestination,
174 : const DAVRequestEnvironment & rEnv,
175 : sal_Bool inOverwrite = false )
176 : throw( DAVException ) = 0;
177 :
178 : virtual void DESTROY( const OUString & inPath,
179 : const DAVRequestEnvironment & rEnv )
180 : throw( DAVException ) = 0;
181 :
182 : // set new lock.
183 : virtual void LOCK( const OUString & inPath,
184 : com::sun::star::ucb::Lock & inLock,
185 : const DAVRequestEnvironment & rEnv )
186 : throw ( DAVException ) = 0;
187 :
188 : // refresh existing lock.
189 : virtual sal_Int64 LOCK( const OUString & inPath,
190 : sal_Int64 nTimeout,
191 : const DAVRequestEnvironment & rEnv )
192 : throw ( DAVException ) = 0;
193 :
194 : virtual void UNLOCK( const OUString & inPath,
195 : const DAVRequestEnvironment & rEnv )
196 : throw ( DAVException ) = 0;
197 :
198 : virtual void abort()
199 : throw( DAVException ) = 0;
200 :
201 : protected:
202 : rtl::Reference< DAVSessionFactory > m_xFactory;
203 :
204 0 : DAVSession( rtl::Reference< DAVSessionFactory > const & rFactory )
205 0 : : m_xFactory( rFactory ), m_nRefCount( 0 ) {}
206 :
207 0 : virtual ~DAVSession() {}
208 :
209 : private:
210 : DAVSessionFactory::Map::iterator m_aContainerIt;
211 : oslInterlockedCount m_nRefCount;
212 :
213 : friend class DAVSessionFactory;
214 : #if defined ( _MSC_VER ) && _MSC_VER < 1310
215 : friend struct std::auto_ptr< DAVSession >;
216 : // work around compiler bug...
217 : #else // WNT
218 : friend class std::auto_ptr< DAVSession >;
219 : #endif // WNT
220 : };
221 :
222 : } // namespace webdav_ucp
223 :
224 : #endif // _DAVSESSION_HXX_
225 :
226 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|