xref: /aoo42x/main/ucb/source/ucp/webdav/DAVSession.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _DAVSESSION_HXX_
29 #define _DAVSESSION_HXX_
30 
31 #include <memory>
32 #include <rtl/ustring.hxx>
33 #include <com/sun/star/io/XInputStream.hpp>
34 #include <com/sun/star/io/XOutputStream.hpp>
35 #include "DAVException.hxx"
36 #include "DAVProperties.hxx"
37 #include "DAVResource.hxx"
38 #include "DAVSessionFactory.hxx"
39 #include "DAVTypes.hxx"
40 #include "DAVRequestEnvironment.hxx"
41 
42 namespace com { namespace sun { namespace star { namespace ucb {
43     struct Lock;
44 } } } }
45 
46 namespace webdav_ucp
47 {
48 
49 class DAVAuthListener;
50 
51 class DAVSession
52 {
53 public:
54     inline void acquire() SAL_THROW(())
55     {
56         osl_incrementInterlockedCount( &m_nRefCount );
57     }
58 
59     void release() SAL_THROW(())
60     {
61         if ( osl_decrementInterlockedCount( &m_nRefCount ) == 0 )
62         {
63             m_xFactory->releaseElement( this );
64             delete this;
65         }
66     }
67 
68     virtual sal_Bool CanUse( const ::rtl::OUString & inPath ) = 0;
69 
70     virtual sal_Bool UsesProxy() = 0;
71 
72     // DAV methods
73     //
74 
75     virtual void OPTIONS( const ::rtl::OUString & inPath,
76                           DAVCapabilities & outCapabilities,
77                           const DAVRequestEnvironment & rEnv )
78         throw( DAVException ) = 0;
79 
80     // allprop & named
81     virtual void PROPFIND( const ::rtl::OUString & inPath,
82                            const Depth inDepth,
83                            const std::vector< ::rtl::OUString > & inPropertyNames,
84                            std::vector< DAVResource > & ioResources,
85                            const DAVRequestEnvironment & rEnv )
86         throw( DAVException ) = 0;
87 
88     // propnames
89     virtual void PROPFIND( const ::rtl::OUString & inPath,
90                            const Depth inDepth,
91                            std::vector< DAVResourceInfo > & ioResInfo,
92                            const DAVRequestEnvironment & rEnv )
93         throw( DAVException ) = 0;
94 
95     virtual void PROPPATCH( const ::rtl::OUString & inPath,
96                             const std::vector< ProppatchValue > & inValues,
97                             const DAVRequestEnvironment & rEnv )
98         throw( DAVException ) = 0;
99 
100     virtual void HEAD( const ::rtl::OUString &  inPath,
101                        const std::vector< ::rtl::OUString > & inHeaderNames,
102                        DAVResource & ioResource,
103                        const DAVRequestEnvironment & rEnv )
104         throw( DAVException ) = 0;
105 
106     virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
107     GET( const ::rtl::OUString & inPath,
108          const DAVRequestEnvironment & rEnv )
109         throw( DAVException ) = 0;
110 
111     virtual void GET( const ::rtl::OUString & inPath,
112                       com::sun::star::uno::Reference<
113                           com::sun::star::io::XOutputStream >& o,
114                       const DAVRequestEnvironment & rEnv )
115         throw( DAVException ) = 0;
116 
117     virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
118     GET( const ::rtl::OUString & inPath,
119          const std::vector< ::rtl::OUString > & inHeaderNames,
120          DAVResource & ioResource,
121          const DAVRequestEnvironment & rEnv )
122         throw( DAVException ) = 0;
123 
124     virtual void
125     GET( const ::rtl::OUString & inPath,
126          com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& o,
127          const std::vector< ::rtl::OUString > & inHeaderNames,
128          DAVResource & ioResource,
129          const DAVRequestEnvironment & rEnv )
130         throw( DAVException ) = 0;
131 
132     virtual void PUT( const ::rtl::OUString & inPath,
133                       const com::sun::star::uno::Reference<
134                           com::sun::star::io::XInputStream >& s,
135                       const DAVRequestEnvironment & rEnv )
136         throw( DAVException ) = 0;
137 
138     virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
139     POST( const rtl::OUString & inPath,
140           const rtl::OUString & rContentType,
141           const rtl::OUString & rReferer,
142           const com::sun::star::uno::Reference<
143               com::sun::star::io::XInputStream > & inInputStream,
144           const DAVRequestEnvironment & rEnv )
145         throw ( DAVException ) = 0;
146 
147     virtual void POST( const rtl::OUString & inPath,
148                        const rtl::OUString & rContentType,
149                        const rtl::OUString & rReferer,
150                        const com::sun::star::uno::Reference<
151                            com::sun::star::io::XInputStream > & inInputStream,
152                        com::sun::star::uno::Reference<
153                            com::sun::star::io::XOutputStream > & oOutputStream,
154                        const DAVRequestEnvironment & rEnv )
155         throw ( DAVException ) = 0;
156 
157     virtual void MKCOL( const ::rtl::OUString & inPath,
158                         const DAVRequestEnvironment & rEnv )
159         throw( DAVException ) = 0;
160 
161     virtual void COPY( const ::rtl::OUString & inSource,
162                        const ::rtl::OUString & inDestination,
163                        const DAVRequestEnvironment & rEnv,
164                        sal_Bool inOverwrite = false )
165         throw( DAVException ) = 0;
166 
167     virtual void MOVE( const ::rtl::OUString & inSource,
168                        const ::rtl::OUString & inDestination,
169                        const DAVRequestEnvironment & rEnv,
170                        sal_Bool inOverwrite = false )
171         throw( DAVException ) = 0;
172 
173     virtual void DESTROY( const ::rtl::OUString & inPath,
174                           const DAVRequestEnvironment & rEnv )
175         throw( DAVException ) = 0;
176 
177     // set new lock.
178     virtual void LOCK( const ::rtl::OUString & inPath,
179                        com::sun::star::ucb::Lock & inLock,
180                        const DAVRequestEnvironment & rEnv )
181         throw ( DAVException ) = 0;
182 
183     // refresh existing lock.
184     virtual sal_Int64 LOCK( const ::rtl::OUString & inPath,
185                             sal_Int64 nTimeout,
186                             const DAVRequestEnvironment & rEnv )
187         throw ( DAVException ) = 0;
188 
189     virtual void UNLOCK( const ::rtl::OUString & inPath,
190                          const DAVRequestEnvironment & rEnv )
191         throw ( DAVException ) = 0;
192 
193     virtual void abort()
194         throw( DAVException ) = 0;
195 
196 protected:
197     rtl::Reference< DAVSessionFactory > m_xFactory;
198 
199     DAVSession( rtl::Reference< DAVSessionFactory > const & rFactory )
200     : m_xFactory( rFactory ), m_nRefCount( 0 ) {}
201 
202     virtual ~DAVSession() {}
203 
204 private:
205     DAVSessionFactory::Map::iterator m_aContainerIt;
206     oslInterlockedCount m_nRefCount;
207 
208     friend class DAVSessionFactory;
209 #if defined WNT && _MSC_VER < 1310
210     friend struct std::auto_ptr< DAVSession >;
211     // work around compiler bug...
212 #else // WNT
213     friend class std::auto_ptr< DAVSession >;
214 #endif // WNT
215 };
216 
217 } // namespace webdav_ucp
218 
219 #endif // _DAVSESSION_HXX_
220