1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _DAVRESOURCEACCESS_HXX_
29*cdf0e10cSrcweir #define _DAVRESOURCEACCESS_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <vector>
32*cdf0e10cSrcweir #include <rtl/ustring.hxx>
33*cdf0e10cSrcweir #include <rtl/ref.hxx>
34*cdf0e10cSrcweir #include <osl/mutex.hxx>
35*cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/ucb/Lock.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandEnvironment.hpp>
39*cdf0e10cSrcweir #include "DAVAuthListener.hxx"
40*cdf0e10cSrcweir #include "DAVException.hxx"
41*cdf0e10cSrcweir #include "DAVSession.hxx"
42*cdf0e10cSrcweir #include "DAVResource.hxx"
43*cdf0e10cSrcweir #include "DAVTypes.hxx"
44*cdf0e10cSrcweir #include "NeonUri.hxx"
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir namespace webdav_ucp
47*cdf0e10cSrcweir {
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir class DAVSessionFactory;
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir class DAVResourceAccess
52*cdf0e10cSrcweir {
53*cdf0e10cSrcweir     osl::Mutex    m_aMutex;
54*cdf0e10cSrcweir     rtl::OUString m_aURL;
55*cdf0e10cSrcweir     rtl::OUString m_aPath;
56*cdf0e10cSrcweir     rtl::Reference< DAVSession > m_xSession;
57*cdf0e10cSrcweir     rtl::Reference< DAVSessionFactory > m_xSessionFactory;
58*cdf0e10cSrcweir     com::sun::star::uno::Reference<
59*cdf0e10cSrcweir         com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
60*cdf0e10cSrcweir     std::vector< NeonUri > m_aRedirectURIs;
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir public:
63*cdf0e10cSrcweir     DAVResourceAccess() : m_xSessionFactory( 0 ) {}
64*cdf0e10cSrcweir     DAVResourceAccess( const com::sun::star::uno::Reference<
65*cdf0e10cSrcweir                            com::sun::star::lang::XMultiServiceFactory > & rSMgr,
66*cdf0e10cSrcweir                        rtl::Reference<
67*cdf0e10cSrcweir                        DAVSessionFactory > const & rSessionFactory,
68*cdf0e10cSrcweir                        const rtl::OUString & rURL );
69*cdf0e10cSrcweir     DAVResourceAccess( const DAVResourceAccess & rOther );
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir     DAVResourceAccess & operator=( const DAVResourceAccess & rOther );
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir     void setURL( const rtl::OUString & rNewURL )
74*cdf0e10cSrcweir         throw ( DAVException );
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir     void resetUri();
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir     const rtl::OUString & getURL() const { return m_aURL; }
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir     rtl::Reference< DAVSessionFactory > getSessionFactory() const
81*cdf0e10cSrcweir     { return m_xSessionFactory; }
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir     // DAV methods
84*cdf0e10cSrcweir     //
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir #if 0 // currently not used, but please don't remove code
87*cdf0e10cSrcweir     void
88*cdf0e10cSrcweir     OPTIONS(  DAVCapabilities & rCapabilities,
89*cdf0e10cSrcweir               const com::sun::star::uno::Reference<
90*cdf0e10cSrcweir                   com::sun::star::ucb::XCommandEnvironment > & xEnv )
91*cdf0e10cSrcweir         throw ( DAVException );
92*cdf0e10cSrcweir #endif
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     // allprop & named
95*cdf0e10cSrcweir     void
96*cdf0e10cSrcweir     PROPFIND( const Depth nDepth,
97*cdf0e10cSrcweir               const std::vector< rtl::OUString > & rPropertyNames,
98*cdf0e10cSrcweir               std::vector< DAVResource > & rResources,
99*cdf0e10cSrcweir               const com::sun::star::uno::Reference<
100*cdf0e10cSrcweir                   com::sun::star::ucb::XCommandEnvironment > & xEnv )
101*cdf0e10cSrcweir         throw ( DAVException );
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir     // propnames
104*cdf0e10cSrcweir     void
105*cdf0e10cSrcweir     PROPFIND( const Depth nDepth,
106*cdf0e10cSrcweir               std::vector< DAVResourceInfo > & rResInfo,
107*cdf0e10cSrcweir               const com::sun::star::uno::Reference<
108*cdf0e10cSrcweir                   com::sun::star::ucb::XCommandEnvironment > & xEnv )
109*cdf0e10cSrcweir         throw ( DAVException );
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     void
112*cdf0e10cSrcweir     PROPPATCH( const std::vector< ProppatchValue > & rValues,
113*cdf0e10cSrcweir                const com::sun::star::uno::Reference<
114*cdf0e10cSrcweir                    com::sun::star::ucb::XCommandEnvironment >& xEnv )
115*cdf0e10cSrcweir         throw ( DAVException );
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir     void
118*cdf0e10cSrcweir     HEAD( const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all'
119*cdf0e10cSrcweir           DAVResource & rResource,
120*cdf0e10cSrcweir           const com::sun::star::uno::Reference<
121*cdf0e10cSrcweir               com::sun::star::ucb::XCommandEnvironment >& xEnv )
122*cdf0e10cSrcweir         throw ( DAVException );
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
125*cdf0e10cSrcweir     GET( const com::sun::star::uno::Reference<
126*cdf0e10cSrcweir              com::sun::star::ucb::XCommandEnvironment > & xEnv )
127*cdf0e10cSrcweir         throw ( DAVException );
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir     void
130*cdf0e10cSrcweir     GET( com::sun::star::uno::Reference<
131*cdf0e10cSrcweir              com::sun::star::io::XOutputStream > & rStream,
132*cdf0e10cSrcweir          const com::sun::star::uno::Reference<
133*cdf0e10cSrcweir              com::sun::star::ucb::XCommandEnvironment > & xEnv )
134*cdf0e10cSrcweir         throw ( DAVException );
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
137*cdf0e10cSrcweir     GET( const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all'
138*cdf0e10cSrcweir          DAVResource & rResource,
139*cdf0e10cSrcweir          const com::sun::star::uno::Reference<
140*cdf0e10cSrcweir              com::sun::star::ucb::XCommandEnvironment > & xEnv )
141*cdf0e10cSrcweir         throw ( DAVException );
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     void
144*cdf0e10cSrcweir     GET( com::sun::star::uno::Reference<
145*cdf0e10cSrcweir              com::sun::star::io::XOutputStream > & rStream,
146*cdf0e10cSrcweir          const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all'
147*cdf0e10cSrcweir          DAVResource & rResource,
148*cdf0e10cSrcweir          const com::sun::star::uno::Reference<
149*cdf0e10cSrcweir              com::sun::star::ucb::XCommandEnvironment > & xEnv )
150*cdf0e10cSrcweir         throw ( DAVException );
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     void
153*cdf0e10cSrcweir     PUT( const com::sun::star::uno::Reference<
154*cdf0e10cSrcweir              com::sun::star::io::XInputStream > & rStream,
155*cdf0e10cSrcweir          const com::sun::star::uno::Reference<
156*cdf0e10cSrcweir              com::sun::star::ucb::XCommandEnvironment > & xEnv )
157*cdf0e10cSrcweir         throw ( DAVException );
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
160*cdf0e10cSrcweir     POST( const rtl::OUString & rContentType,
161*cdf0e10cSrcweir           const rtl::OUString & rReferer,
162*cdf0e10cSrcweir           const com::sun::star::uno::Reference<
163*cdf0e10cSrcweir               com::sun::star::io::XInputStream > & rInputStream,
164*cdf0e10cSrcweir           const com::sun::star::uno::Reference<
165*cdf0e10cSrcweir           com::sun::star::ucb::XCommandEnvironment >& xEnv )
166*cdf0e10cSrcweir         throw ( DAVException );
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir     void
169*cdf0e10cSrcweir     POST( const rtl::OUString & rContentType,
170*cdf0e10cSrcweir           const rtl::OUString & rReferer,
171*cdf0e10cSrcweir           const com::sun::star::uno::Reference<
172*cdf0e10cSrcweir               com::sun::star::io::XInputStream > & rInputStream,
173*cdf0e10cSrcweir           com::sun::star::uno::Reference<
174*cdf0e10cSrcweir               com::sun::star::io::XOutputStream > & rOutputStream,
175*cdf0e10cSrcweir           const com::sun::star::uno::Reference<
176*cdf0e10cSrcweir               com::sun::star::ucb::XCommandEnvironment >& xEnv )
177*cdf0e10cSrcweir         throw ( DAVException );
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir     void
180*cdf0e10cSrcweir     MKCOL( const com::sun::star::uno::Reference<
181*cdf0e10cSrcweir                com::sun::star::ucb::XCommandEnvironment > & xEnv )
182*cdf0e10cSrcweir         throw ( DAVException );
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir     void
185*cdf0e10cSrcweir     COPY( const ::rtl::OUString & rSourcePath,
186*cdf0e10cSrcweir           const ::rtl::OUString & rDestinationURI,
187*cdf0e10cSrcweir           sal_Bool bOverwrite,
188*cdf0e10cSrcweir           const com::sun::star::uno::Reference<
189*cdf0e10cSrcweir               com::sun::star::ucb::XCommandEnvironment > & xEnv )
190*cdf0e10cSrcweir         throw ( DAVException );
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir     void
193*cdf0e10cSrcweir     MOVE( const ::rtl::OUString & rSourcePath,
194*cdf0e10cSrcweir           const ::rtl::OUString & rDestinationURI,
195*cdf0e10cSrcweir           sal_Bool bOverwrite,
196*cdf0e10cSrcweir           const com::sun::star::uno::Reference<
197*cdf0e10cSrcweir               com::sun::star::ucb::XCommandEnvironment > & xEnv )
198*cdf0e10cSrcweir         throw ( DAVException );
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir     void
201*cdf0e10cSrcweir     DESTROY( const com::sun::star::uno::Reference<
202*cdf0e10cSrcweir                  com::sun::star::ucb::XCommandEnvironment > & xEnv )
203*cdf0e10cSrcweir         throw ( DAVException );
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir     // set new lock.
206*cdf0e10cSrcweir     void
207*cdf0e10cSrcweir     LOCK( com::sun::star::ucb::Lock & inLock,
208*cdf0e10cSrcweir           const com::sun::star::uno::Reference<
209*cdf0e10cSrcweir               com::sun::star::ucb::XCommandEnvironment > & xEnv )
210*cdf0e10cSrcweir         throw( DAVException );
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir #if 0 // currently not used, but please don't remove code
213*cdf0e10cSrcweir     // refresh existing lock.
214*cdf0e10cSrcweir     sal_Int64
215*cdf0e10cSrcweir     LOCK( sal_Int64 nTimeout,
216*cdf0e10cSrcweir           const com::sun::star::uno::Reference<
217*cdf0e10cSrcweir               com::sun::star::ucb::XCommandEnvironment > & xEnv )
218*cdf0e10cSrcweir         throw ( DAVException );
219*cdf0e10cSrcweir #endif
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir     void
222*cdf0e10cSrcweir     UNLOCK( const com::sun::star::uno::Reference<
223*cdf0e10cSrcweir                 com::sun::star::ucb::XCommandEnvironment > & xEnv )
224*cdf0e10cSrcweir         throw ( DAVException );
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir     void
227*cdf0e10cSrcweir     abort()
228*cdf0e10cSrcweir         throw ( DAVException );
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir     // helper
231*cdf0e10cSrcweir     static void
232*cdf0e10cSrcweir     getUserRequestHeaders(
233*cdf0e10cSrcweir         const com::sun::star::uno::Reference<
234*cdf0e10cSrcweir             com::sun::star::ucb::XCommandEnvironment > & xEnv,
235*cdf0e10cSrcweir         const rtl::OUString & rURI,
236*cdf0e10cSrcweir         const rtl::OUString & rMethod,
237*cdf0e10cSrcweir         DAVRequestHeaders & rRequestHeaders );
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir private:
240*cdf0e10cSrcweir     const rtl::OUString & getRequestURI() const;
241*cdf0e10cSrcweir     sal_Bool detectRedirectCycle( const rtl::OUString& rRedirectURL )
242*cdf0e10cSrcweir         throw ( DAVException );
243*cdf0e10cSrcweir     sal_Bool handleException( DAVException & e, int errorCount )
244*cdf0e10cSrcweir         throw ( DAVException );
245*cdf0e10cSrcweir     void initialize()
246*cdf0e10cSrcweir         throw ( DAVException );
247*cdf0e10cSrcweir };
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir } // namespace webdav_ucp
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir #endif // _DAVRESOURCEACCESS_HXX_
252