Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : *
6 : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : *
8 : * OpenOffice.org - a multi-platform office productivity suite
9 : *
10 : * This file is part of OpenOffice.org.
11 : *
12 : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : * it under the terms of the GNU Lesser General Public License version 3
14 : * only, as published by the Free Software Foundation.
15 : *
16 : * OpenOffice.org is distributed in the hope that it will be useful,
17 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : * GNU Lesser General Public License version 3 for more details
20 : * (a copy is included in the LICENSE file that accompanied this code).
21 : *
22 : * You should have received a copy of the GNU Lesser General Public License
23 : * version 3 along with OpenOffice.org. If not, see
24 : * <http://www.openoffice.org/license.html>
25 : * for a copy of the LGPLv3 License.
26 : *
27 : ************************************************************************/
28 :
29 : #ifndef _WEBDAV_UCP_CONTENT_HXX
30 : #define _WEBDAV_UCP_CONTENT_HXX
31 :
32 : #include <config_lgpl.h>
33 : #include <memory>
34 : #include <list>
35 : #include <rtl/ref.hxx>
36 : #include <com/sun/star/ucb/ContentCreationException.hpp>
37 : #include <com/sun/star/ucb/XContentCreator.hpp>
38 : #include <ucbhelper/contenthelper.hxx>
39 : #include "DAVResourceAccess.hxx"
40 : #include "PropertyMap.hxx"
41 :
42 : namespace com { namespace sun { namespace star { namespace beans {
43 : struct Property;
44 : struct PropertyValue;
45 : } } } }
46 :
47 : namespace com { namespace sun { namespace star { namespace io {
48 : class XInputStream;
49 : } } } }
50 :
51 : namespace com { namespace sun { namespace star { namespace sdbc {
52 : class XRow;
53 : } } } }
54 :
55 : namespace com { namespace sun { namespace star { namespace ucb {
56 : struct OpenCommandArgument3;
57 : struct PostCommandArgument2;
58 : struct TransferInfo;
59 : } } } }
60 :
61 : namespace webdav_ucp
62 : {
63 :
64 : //=========================================================================
65 :
66 : // UNO service name for the content.
67 : #define WEBDAV_CONTENT_SERVICE_NAME "com.sun.star.ucb.WebDAVContent"
68 :
69 : //=========================================================================
70 :
71 : class ContentProvider;
72 : class ContentProperties;
73 : class CachableContentProperties;
74 :
75 : class Content : public ::ucbhelper::ContentImplHelper,
76 : public com::sun::star::ucb::XContentCreator
77 : {
78 : enum ResourceType
79 : {
80 : UNKNOWN,
81 : FTP,
82 : NON_DAV,
83 : DAV
84 : };
85 :
86 : std::auto_ptr< DAVResourceAccess > m_xResAccess;
87 : std::auto_ptr< CachableContentProperties >
88 : m_xCachedProps; // locally cached props
89 : OUString m_aEscapedTitle;
90 : ResourceType m_eResourceType;
91 : ContentProvider* m_pProvider; // No need for a ref, base class holds object
92 : bool m_bTransient;
93 : bool m_bCollection;
94 : bool m_bDidGetOrHead;
95 : std::vector< OUString > m_aFailedPropNames;
96 :
97 : private:
98 : virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
99 : getProperties( const com::sun::star::uno::Reference<
100 : com::sun::star::ucb::XCommandEnvironment > & xEnv );
101 : virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
102 : getCommands( const com::sun::star::uno::Reference<
103 : com::sun::star::ucb::XCommandEnvironment > & xEnv );
104 : virtual OUString getParentURL();
105 :
106 : sal_Bool isFolder( const ::com::sun::star::uno::Reference<
107 : ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
108 : throw ( ::com::sun::star::uno::Exception );
109 :
110 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
111 : getPropertyValues( const ::com::sun::star::uno::Sequence<
112 : ::com::sun::star::beans::Property >& rProperties,
113 : const ::com::sun::star::uno::Reference<
114 : ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
115 : throw ( ::com::sun::star::uno::Exception );
116 :
117 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
118 : setPropertyValues( const ::com::sun::star::uno::Sequence<
119 : ::com::sun::star::beans::PropertyValue >& rValues,
120 : const ::com::sun::star::uno::Reference<
121 : ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
122 : throw ( ::com::sun::star::uno::Exception );
123 :
124 : typedef rtl::Reference< Content > ContentRef;
125 : typedef std::list< ContentRef > ContentRefList;
126 : void queryChildren( ContentRefList& rChildren);
127 :
128 : sal_Bool
129 : exchangeIdentity( const ::com::sun::star::uno::Reference<
130 : ::com::sun::star::ucb::XContentIdentifier >& xNewId );
131 :
132 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
133 : const OUString
134 : getBaseURI( const std::auto_ptr< DAVResourceAccess > & rResAccess );
135 : SAL_WNODEPRECATED_DECLARATIONS_POP
136 :
137 : ResourceType
138 : getResourceType( const ::com::sun::star::uno::Reference<
139 : ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
140 : throw ( ::com::sun::star::uno::Exception );
141 :
142 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
143 : ResourceType
144 : getResourceType( const ::com::sun::star::uno::Reference<
145 : ::com::sun::star::ucb::XCommandEnvironment >& xEnv,
146 : const std::auto_ptr< DAVResourceAccess > & rResAccess,
147 : bool * networkAccessAllowed = 0)
148 : throw ( ::com::sun::star::uno::Exception );
149 : SAL_WNODEPRECATED_DECLARATIONS_POP
150 :
151 : // Command "open"
152 : com::sun::star::uno::Any open(
153 : const com::sun::star::ucb::OpenCommandArgument3 & rArg,
154 : const com::sun::star::uno::Reference<
155 : com::sun::star::ucb::XCommandEnvironment > & xEnv )
156 : throw( ::com::sun::star::uno::Exception );
157 :
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 );
163 :
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 );
171 :
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 );
177 :
178 : // Command "delete"
179 : void destroy( sal_Bool bDeletePhysical )
180 : throw( ::com::sun::star::uno::Exception );
181 :
182 : // Command "lock"
183 : void lock( const com::sun::star::uno::Reference<
184 : com::sun::star::ucb::XCommandEnvironment >& Environment )
185 : throw( ::com::sun::star::uno::Exception );
186 :
187 : // Command "unlock"
188 : void unlock( const com::sun::star::uno::Reference<
189 : com::sun::star::ucb::XCommandEnvironment >& Environment )
190 : throw( ::com::sun::star::uno::Exception );
191 :
192 : ::com::sun::star::uno::Any MapDAVException( const DAVException & e,
193 : sal_Bool bWrite );
194 : void cancelCommandExecution(
195 : const DAVException & e,
196 : const ::com::sun::star::uno::Reference<
197 : com::sun::star::ucb::XCommandEnvironment > & xEnv,
198 : sal_Bool bWrite = sal_False )
199 : throw( ::com::sun::star::uno::Exception );
200 :
201 : static bool shouldAccessNetworkAfterException( const DAVException & e );
202 :
203 : bool supportsExclusiveWriteLock(
204 : const com::sun::star::uno::Reference<
205 : com::sun::star::ucb::XCommandEnvironment >& Environment );
206 :
207 : public:
208 : Content( const ::com::sun::star::uno::Reference<
209 : ::com::sun::star::uno::XComponentContext >& rxContext,
210 : ContentProvider* pProvider,
211 : const ::com::sun::star::uno::Reference<
212 : ::com::sun::star::ucb::XContentIdentifier >& Identifier,
213 : rtl::Reference< DAVSessionFactory > const & rSessionFactory )
214 : throw ( ::com::sun::star::ucb::ContentCreationException );
215 : Content( const ::com::sun::star::uno::Reference<
216 : ::com::sun::star::uno::XComponentContext >& rxContext,
217 : ContentProvider* pProvider,
218 : const ::com::sun::star::uno::Reference<
219 : ::com::sun::star::ucb::XContentIdentifier >& Identifier,
220 : rtl::Reference< DAVSessionFactory > const & rSessionFactory,
221 : sal_Bool isCollection )
222 : throw ( ::com::sun::star::ucb::ContentCreationException );
223 : virtual ~Content();
224 :
225 : // XInterface
226 : XINTERFACE_DECL()
227 :
228 : // XTypeProvider
229 : XTYPEPROVIDER_DECL()
230 :
231 : // XServiceInfo
232 : virtual OUString SAL_CALL
233 : getImplementationName()
234 : throw( ::com::sun::star::uno::RuntimeException );
235 :
236 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
237 : getSupportedServiceNames()
238 : throw( ::com::sun::star::uno::RuntimeException );
239 :
240 : // XContent
241 : virtual OUString SAL_CALL
242 : getContentType()
243 : throw( com::sun::star::uno::RuntimeException );
244 :
245 : // XCommandProcessor
246 : virtual com::sun::star::uno::Any SAL_CALL
247 : execute( const com::sun::star::ucb::Command& aCommand,
248 : sal_Int32 CommandId,
249 : const com::sun::star::uno::Reference<
250 : com::sun::star::ucb::XCommandEnvironment >& Environment )
251 : throw( com::sun::star::uno::Exception,
252 : com::sun::star::ucb::CommandAbortedException,
253 : com::sun::star::uno::RuntimeException );
254 : virtual void SAL_CALL
255 : abort( sal_Int32 CommandId )
256 : throw( com::sun::star::uno::RuntimeException );
257 :
258 : // XPropertyContainer
259 : virtual void SAL_CALL
260 : addProperty( const OUString& Name,
261 : sal_Int16 Attributes,
262 : const com::sun::star::uno::Any& DefaultValue )
263 : throw( com::sun::star::beans::PropertyExistException,
264 : com::sun::star::beans::IllegalTypeException,
265 : com::sun::star::lang::IllegalArgumentException,
266 : com::sun::star::uno::RuntimeException );
267 :
268 : virtual void SAL_CALL
269 : removeProperty( const OUString& Name )
270 : throw( com::sun::star::beans::UnknownPropertyException,
271 : com::sun::star::beans::NotRemoveableException,
272 : com::sun::star::uno::RuntimeException );
273 :
274 : //////////////////////////////////////////////////////////////////////
275 : // Additional interfaces
276 : //////////////////////////////////////////////////////////////////////
277 :
278 : // XContentCreator
279 : virtual com::sun::star::uno::Sequence<
280 : com::sun::star::ucb::ContentInfo > SAL_CALL
281 : queryCreatableContentsInfo()
282 : throw( com::sun::star::uno::RuntimeException );
283 : virtual com::sun::star::uno::Reference<
284 : com::sun::star::ucb::XContent > SAL_CALL
285 : createNewContent( const com::sun::star::ucb::ContentInfo& Info )
286 : throw( com::sun::star::uno::RuntimeException );
287 :
288 : //////////////////////////////////////////////////////////////////////
289 : // Non-interface methods.
290 : //////////////////////////////////////////////////////////////////////
291 :
292 0 : DAVResourceAccess & getResourceAccess() { return *m_xResAccess; }
293 :
294 : // Called from resultset data supplier.
295 : static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
296 : getPropertyValues( const ::com::sun::star::uno::Reference<
297 : ::com::sun::star::uno::XComponentContext >& rxContext,
298 : const ::com::sun::star::uno::Sequence<
299 : ::com::sun::star::beans::Property >& rProperties,
300 : const ContentProperties& rData,
301 : const rtl::Reference<
302 : ::ucbhelper::ContentProviderImplHelper >& rProvider,
303 : const OUString& rContentId );
304 : };
305 :
306 : }
307 :
308 : #endif
309 :
310 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|