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