Update ooo320-m1
[ooovba.git] / ucb / source / ucp / webdav / webdavcontent.hxx
blob90325d31614a33b5eae1ba7350f33787418d3b15
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: webdavcontent.hxx,v $
10 * $Revision: 1.23.32.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _WEBDAV_UCP_CONTENT_HXX
32 #define _WEBDAV_UCP_CONTENT_HXX
34 #include <memory>
35 #include <list>
36 #include <osl/signal.h>
37 #include <rtl/ref.hxx>
38 #include <com/sun/star/ucb/ContentCreationException.hpp>
39 #include <com/sun/star/ucb/XContentCreator.hpp>
40 #include <com/sun/star/ucb/Lock.hpp>
41 #include <ucbhelper/contenthelper.hxx>
43 #include "DAVResourceAccess.hxx"
44 #include "PropertyMap.hxx"
46 namespace com { namespace sun { namespace star { namespace beans {
47 struct Property;
48 struct PropertyValue;
49 } } } }
51 namespace com { namespace sun { namespace star { namespace io {
52 class XInputStream;
53 } } } }
55 namespace com { namespace sun { namespace star { namespace sdbc {
56 class XRow;
57 } } } }
59 namespace com { namespace sun { namespace star { namespace ucb {
60 struct OpenCommandArgument2;
61 struct PostCommandArgument2;
62 struct TransferInfo;
63 } } } }
65 namespace webdav_ucp
68 //=========================================================================
70 // UNO service name for the content.
71 #define WEBDAV_CONTENT_SERVICE_NAME "com.sun.star.ucb.WebDAVContent"
73 //=========================================================================
75 class ContentProvider;
76 class ContentProperties;
78 class Content : public ::ucbhelper::ContentImplHelper,
79 public com::sun::star::ucb::XContentCreator
81 enum ResourceType
83 UNKNOWN,
84 FTP,
85 NON_DAV,
86 DAV
89 std::auto_ptr< DAVResourceAccess > m_xResAccess;
90 std::auto_ptr< ContentProperties > m_xCachedProps; // locally cached props
91 rtl::OUString m_aEscapedTitle;
92 ResourceType m_eResourceType;
93 ContentProvider* m_pProvider; // No need for a ref, base class holds object
94 bool m_bTransient;
95 bool m_bCollection;
96 bool m_bDidGetOrHead;
97 bool m_bForceReadOnly;
98 com::sun::star::ucb::Lock *m_pLock;
99 uno::Reference< ucb::XCommandEnvironment > m_xLockEnv;
100 std::vector< rtl::OUString > m_aFailedPropNames;
102 private:
103 virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
104 getProperties( const com::sun::star::uno::Reference<
105 com::sun::star::ucb::XCommandEnvironment > & xEnv );
106 virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
107 getCommands( const com::sun::star::uno::Reference<
108 com::sun::star::ucb::XCommandEnvironment > & xEnv );
109 virtual ::rtl::OUString getParentURL();
111 sal_Bool isFolder( const ::com::sun::star::uno::Reference<
112 ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
113 throw ( ::com::sun::star::uno::Exception );
115 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
116 getPropertyValues( const ::com::sun::star::uno::Sequence<
117 ::com::sun::star::beans::Property >& rProperties,
118 const ::com::sun::star::uno::Reference<
119 ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
120 throw ( ::com::sun::star::uno::Exception );
122 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
123 setPropertyValues(
124 const ::com::sun::star::uno::Sequence<
125 ::com::sun::star::beans::PropertyValue >& rValues,
126 const ::com::sun::star::uno::Reference<
127 ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
128 throw ( ::com::sun::star::uno::Exception );
130 typedef rtl::Reference< Content > ContentRef;
131 typedef std::list< ContentRef > ContentRefList;
132 void queryChildren( ContentRefList& rChildren);
134 sal_Bool exchangeIdentity(
135 const ::com::sun::star::uno::Reference<
136 ::com::sun::star::ucb::XContentIdentifier >& xNewId );
138 const rtl::OUString getBaseURI( const std::auto_ptr< DAVResourceAccess > & rResAccess );
140 const ResourceType & getResourceType(
141 const ::com::sun::star::uno::Reference<
142 ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
143 throw ( ::com::sun::star::uno::Exception );
145 const ResourceType & getResourceType(
146 const ::com::sun::star::uno::Reference<
147 ::com::sun::star::ucb::XCommandEnvironment >& xEnv,
148 const std::auto_ptr< DAVResourceAccess > & rResAccess )
149 throw ( ::com::sun::star::uno::Exception );
151 // Command "open"
152 com::sun::star::uno::Any open(
153 const com::sun::star::ucb::OpenCommandArgument2 & rArg,
154 const com::sun::star::uno::Reference<
155 com::sun::star::ucb::XCommandEnvironment > & xEnv )
156 throw( ::com::sun::star::uno::Exception );
158 // Command "post"
159 void post( const com::sun::star::ucb::PostCommandArgument2 & rArg,
160 const com::sun::star::uno::Reference<
161 com::sun::star::ucb::XCommandEnvironment > & xEnv )
162 throw( ::com::sun::star::uno::Exception );
164 // Command "insert"
165 void insert( const ::com::sun::star::uno::Reference<
166 ::com::sun::star::io::XInputStream > & xInputStream,
167 sal_Bool bReplaceExisting,
168 const com::sun::star::uno::Reference<
169 com::sun::star::ucb::XCommandEnvironment >& Environment )
170 throw( ::com::sun::star::uno::Exception );
172 // Command "transfer"
173 void transfer( const ::com::sun::star::ucb::TransferInfo & rArgs,
174 const com::sun::star::uno::Reference<
175 com::sun::star::ucb::XCommandEnvironment >& Environment )
176 throw( ::com::sun::star::uno::Exception );
178 // Command "delete"
179 void destroy( sal_Bool bDeletePhysical )
180 throw( ::com::sun::star::uno::Exception );
182 ::com::sun::star::uno::Any MapDAVException( const DAVException & e,
183 sal_Bool bWrite );
184 void cancelCommandExecution(
185 const DAVException & e,
186 const ::com::sun::star::uno::Reference<
187 com::sun::star::ucb::XCommandEnvironment > & xEnv,
188 sal_Bool bWrite = sal_False )
189 throw( ::com::sun::star::uno::Exception );
191 static bool shouldAccessNetworkAfterException( const DAVException & e );
193 oslSignalHandler m_pSignalHandler;
194 int m_nToExpire;
195 osl::Mutex m_aLock;
197 // Refresh the lock of the resource
198 void RefreshLock( void );
200 // Refresh the lock if necessary, or unlock the resource when
201 // OOo crashes or is terminated
202 static oslSignalAction HandleLockingSignal( void* pData, oslSignalInfo* pInfo );
204 public:
205 Content( const ::com::sun::star::uno::Reference<
206 ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
207 ContentProvider* pProvider,
208 const ::com::sun::star::uno::Reference<
209 ::com::sun::star::ucb::XContentIdentifier >& Identifier,
210 rtl::Reference< DAVSessionFactory > const & rSessionFactory )
211 throw ( ::com::sun::star::ucb::ContentCreationException );
212 Content( const ::com::sun::star::uno::Reference<
213 ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
214 ContentProvider* pProvider,
215 const ::com::sun::star::uno::Reference<
216 ::com::sun::star::ucb::XContentIdentifier >& Identifier,
217 rtl::Reference< DAVSessionFactory > const & rSessionFactory,
218 sal_Bool isCollection )
219 throw ( ::com::sun::star::ucb::ContentCreationException );
220 virtual ~Content();
222 // XInterface
223 XINTERFACE_DECL()
225 // XTypeProvider
226 XTYPEPROVIDER_DECL()
228 // XServiceInfo
229 virtual ::rtl::OUString SAL_CALL
230 getImplementationName()
231 throw( ::com::sun::star::uno::RuntimeException );
232 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
233 getSupportedServiceNames()
234 throw( ::com::sun::star::uno::RuntimeException );
236 // XContent
237 virtual rtl::OUString SAL_CALL
238 getContentType()
239 throw( com::sun::star::uno::RuntimeException );
241 // XCommandProcessor
242 virtual com::sun::star::uno::Any SAL_CALL
243 execute( const com::sun::star::ucb::Command& aCommand,
244 sal_Int32 CommandId,
245 const com::sun::star::uno::Reference<
246 com::sun::star::ucb::XCommandEnvironment >& Environment )
247 throw( com::sun::star::uno::Exception,
248 com::sun::star::ucb::CommandAbortedException,
249 com::sun::star::uno::RuntimeException );
250 virtual void SAL_CALL
251 abort( sal_Int32 CommandId )
252 throw( com::sun::star::uno::RuntimeException );
254 // XPropertyContainer
255 virtual void SAL_CALL
256 addProperty( const rtl::OUString& Name,
257 sal_Int16 Attributes,
258 const com::sun::star::uno::Any& DefaultValue )
259 throw( com::sun::star::beans::PropertyExistException,
260 com::sun::star::beans::IllegalTypeException,
261 com::sun::star::lang::IllegalArgumentException,
262 com::sun::star::uno::RuntimeException );
264 virtual void SAL_CALL
265 removeProperty( const rtl::OUString& Name )
266 throw( com::sun::star::beans::UnknownPropertyException,
267 com::sun::star::beans::NotRemoveableException,
268 com::sun::star::uno::RuntimeException );
270 //////////////////////////////////////////////////////////////////////
271 // Additional interfaces
272 //////////////////////////////////////////////////////////////////////
274 // XContentCreator
275 virtual com::sun::star::uno::Sequence<
276 com::sun::star::ucb::ContentInfo > SAL_CALL
277 queryCreatableContentsInfo()
278 throw( com::sun::star::uno::RuntimeException );
279 virtual com::sun::star::uno::Reference<
280 com::sun::star::ucb::XContent > SAL_CALL
281 createNewContent( const com::sun::star::ucb::ContentInfo& Info )
282 throw( com::sun::star::uno::RuntimeException );
284 //////////////////////////////////////////////////////////////////////
285 // Non-interface methods.
286 //////////////////////////////////////////////////////////////////////
288 DAVResourceAccess & getResourceAccess() { return *m_xResAccess; }
290 // Called from resultset data supplier.
291 static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
292 getPropertyValues( const ::com::sun::star::uno::Reference<
293 ::com::sun::star::lang::XMultiServiceFactory >& rSMgr,
294 const ::com::sun::star::uno::Sequence<
295 ::com::sun::star::beans::Property >& rProperties,
296 const ContentProperties& rData,
297 const rtl::Reference<
298 ::ucbhelper::ContentProviderImplHelper >& rProvider,
299 const ::rtl::OUString& rContentId );
304 #endif