xref: /aoo42x/main/ucb/source/ucp/webdav/DAVSession.hxx (revision 59ddfc10)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _DAVSESSION_HXX_
25 #define _DAVSESSION_HXX_
26 
27 #include <memory>
28 #include <rtl/ustring.hxx>
29 #include <com/sun/star/io/XInputStream.hpp>
30 #include <com/sun/star/io/XOutputStream.hpp>
31 #include "DAVException.hxx"
32 #include "DAVProperties.hxx"
33 #include "DAVResource.hxx"
34 #include "DAVSessionFactory.hxx"
35 #include "DAVTypes.hxx"
36 #include "DAVRequestEnvironment.hxx"
37 
38 namespace com { namespace sun { namespace star { namespace ucb {
39     struct Lock;
40 } } } }
41 
42 namespace http_dav_ucp
43 {
44 
45 class DAVAuthListener;
46 
47 class DAVSession
48 {
49 public:
acquire()50     inline void acquire() SAL_THROW(())
51     {
52         osl_incrementInterlockedCount( &m_nRefCount );
53     }
54 
release()55     void release() SAL_THROW(())
56     {
57         if ( osl_decrementInterlockedCount( &m_nRefCount ) == 0 )
58         {
59             m_xFactory->releaseElement( this );
60             delete this;
61         }
62     }
63 
64     virtual sal_Bool CanUse( const ::rtl::OUString & inPath ) = 0;
65 
66     virtual sal_Bool UsesProxy() = 0;
67 
68     // DAV methods
69     //
70 
71     // NOT USED
72     /*
73     virtual void OPTIONS( const ::rtl::OUString & inPath,
74                           DAVCapabilities & outCapabilities,
75                           const DAVRequestEnvironment & rEnv )
76         throw( DAVException ) = 0;
77     */
78 
79     // allprop & named
80     virtual void PROPFIND( const ::rtl::OUString & inPath,
81                            const Depth inDepth,
82                            const std::vector< ::rtl::OUString > & inPropertyNames,
83                            std::vector< DAVResource > & ioResources,
84                            const DAVRequestEnvironment & rEnv )
85         throw( DAVException ) = 0;
86 
87     // propnames
88     virtual void PROPFIND( const ::rtl::OUString & inPath,
89                            const Depth inDepth,
90                            std::vector< DAVResourceInfo > & ioResInfo,
91                            const DAVRequestEnvironment & rEnv )
92         throw( DAVException ) = 0;
93 
94     virtual void PROPPATCH( const ::rtl::OUString & inPath,
95                             const std::vector< ProppatchValue > & inValues,
96                             const DAVRequestEnvironment & rEnv )
97         throw( DAVException ) = 0;
98 
99     virtual void HEAD( const ::rtl::OUString &  inPath,
100                        const std::vector< ::rtl::OUString > & inHeaderNames,
101                        DAVResource & ioResource,
102                        const DAVRequestEnvironment & rEnv )
103         throw( DAVException ) = 0;
104 
105     virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
106     GET( const ::rtl::OUString & inPath,
107          const DAVRequestEnvironment & rEnv )
108         throw( DAVException ) = 0;
109 
110     virtual void GET( const ::rtl::OUString & inPath,
111                       com::sun::star::uno::Reference<
112                           com::sun::star::io::XOutputStream >& o,
113                       const DAVRequestEnvironment & rEnv )
114         throw( DAVException ) = 0;
115 
116     virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
117     GET( const ::rtl::OUString & inPath,
118          const std::vector< ::rtl::OUString > & inHeaderNames,
119          DAVResource & ioResource,
120          const DAVRequestEnvironment & rEnv )
121         throw( DAVException ) = 0;
122 
123     virtual void
124     GET( const ::rtl::OUString & inPath,
125          com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& o,
126          const std::vector< ::rtl::OUString > & inHeaderNames,
127          DAVResource & ioResource,
128          const DAVRequestEnvironment & rEnv )
129         throw( DAVException ) = 0;
130 
131     virtual void PUT( const ::rtl::OUString & inPath,
132                       const com::sun::star::uno::Reference<
133                           com::sun::star::io::XInputStream >& s,
134                       const DAVRequestEnvironment & rEnv )
135         throw( DAVException ) = 0;
136 
137     virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
138     POST( const rtl::OUString & inPath,
139           const rtl::OUString & rContentType,
140           const rtl::OUString & rReferer,
141           const com::sun::star::uno::Reference<
142               com::sun::star::io::XInputStream > & inInputStream,
143           const DAVRequestEnvironment & rEnv )
144         throw ( DAVException ) = 0;
145 
146     virtual void POST( const rtl::OUString & inPath,
147                        const rtl::OUString & rContentType,
148                        const rtl::OUString & rReferer,
149                        const com::sun::star::uno::Reference<
150                            com::sun::star::io::XInputStream > & inInputStream,
151                        com::sun::star::uno::Reference<
152                            com::sun::star::io::XOutputStream > & oOutputStream,
153                        const DAVRequestEnvironment & rEnv )
154         throw ( DAVException ) = 0;
155 
156     virtual void MKCOL( const ::rtl::OUString & inPath,
157                         const DAVRequestEnvironment & rEnv )
158         throw( DAVException ) = 0;
159 
160     virtual void COPY( const ::rtl::OUString & inSource,
161                        const ::rtl::OUString & inDestination,
162                        const DAVRequestEnvironment & rEnv,
163                        sal_Bool inOverwrite = false )
164         throw( DAVException ) = 0;
165 
166     virtual void MOVE( const ::rtl::OUString & inSource,
167                        const ::rtl::OUString & inDestination,
168                        const DAVRequestEnvironment & rEnv,
169                        sal_Bool inOverwrite = false )
170         throw( DAVException ) = 0;
171 
172     virtual void DESTROY( const ::rtl::OUString & inPath,
173                           const DAVRequestEnvironment & rEnv )
174         throw( DAVException ) = 0;
175 
176     // set new lock.
177     virtual void LOCK( const ::rtl::OUString & inPath,
178                        com::sun::star::ucb::Lock & inLock,
179                        const DAVRequestEnvironment & rEnv )
180         throw ( DAVException ) = 0;
181 
182     // refresh existing lock.
183     virtual sal_Int64 LOCK( const ::rtl::OUString & inPath,
184                             sal_Int64 nTimeout,
185                             const DAVRequestEnvironment & rEnv )
186         throw ( DAVException ) = 0;
187 
188     virtual void UNLOCK( const ::rtl::OUString & inPath,
189                          const DAVRequestEnvironment & rEnv )
190         throw ( DAVException ) = 0;
191 
192     virtual void abort()
193         throw( DAVException ) = 0;
194 
195 protected:
196     rtl::Reference< DAVSessionFactory > m_xFactory;
197 
DAVSession(rtl::Reference<DAVSessionFactory> const & rFactory)198     DAVSession( rtl::Reference< DAVSessionFactory > const & rFactory )
199     : m_xFactory( rFactory ), m_nRefCount( 0 ) {}
200 
~DAVSession()201     virtual ~DAVSession() {}
202 
203 private:
204     DAVSessionFactory::Map::iterator m_aContainerIt;
205     oslInterlockedCount m_nRefCount;
206 
207     friend class DAVSessionFactory;
208 #if defined WNT && _MSC_VER < 1310
209     friend struct std::auto_ptr< DAVSession >;
210     // work around compiler bug...
211 #else // WNT
212     friend class std::auto_ptr< DAVSession >;
213 #endif // WNT
214 };
215 
216 } // namespace http_dav_ucp
217 
218 #endif // _DAVSESSION_HXX_
219