LibreOffice Module ucb (master)  1
webdavcontent.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 
21 #pragma once
22 
23 #include <memory>
24 #include <list>
25 #include <rtl/ref.hxx>
26 #include <com/sun/star/ucb/ContentCreationException.hpp>
27 #include <com/sun/star/ucb/XContentCreator.hpp>
29 #include "DAVResourceAccess.hxx"
30 #include "PropertyMap.hxx"
31 
32 namespace com::sun::star::beans {
33  struct Property;
34  struct PropertyValue;
35 }
36 
37 namespace com::sun::star::io {
38  class XInputStream;
39 }
40 
41 namespace com::sun::star::sdbc {
42  class XRow;
43 }
44 
45 namespace com::sun::star::ucb {
46  struct OpenCommandArgument2;
47  struct PropertyCommandArgument;
48  struct PostCommandArgument2;
49  struct TransferInfo;
50 }
51 
52 namespace http_dav_ucp
53 {
54 
55 
56 // UNO service name for the content.
57 #define WEBDAV_CONTENT_SERVICE_NAME "com.sun.star.ucb.WebDAVContent"
58 
59 
60 class ContentProvider;
61 class ContentProperties;
62 class CachableContentProperties;
63 
65  public css::ucb::XContentCreator
66 {
68  {
72  };
73 
74  std::unique_ptr< DAVResourceAccess > m_xResAccess;
75  std::unique_ptr< CachableContentProperties > m_xCachedProps; // locally cached props
76  OUString m_aEscapedTitle;
78  ContentProvider* m_pProvider; // No need for a ref, base class holds object
80  bool m_bLocked;
83  std::vector< OUString > m_aFailedPropNames;
84 
85 private:
86  virtual css::uno::Sequence< css::beans::Property >
87  getProperties( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv ) override;
88  virtual css::uno::Sequence< css::ucb::CommandInfo >
89  getCommands( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv ) override;
90  virtual OUString getParentURL() override;
91 
93  bool isFolder( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
94 
96  css::uno::Reference< css::sdbc::XRow >
97  getPropertyValues( const css::uno::Sequence< css::beans::Property >& rProperties,
98  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
99 
101  css::uno::Sequence< css::uno::Any >
102  setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& rValues,
103  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
104 
106  typedef std::vector< ContentRef > ContentRefList;
107  void queryChildren( ContentRefList& rChildren);
108 
109  bool
110  exchangeIdentity( const css::uno::Reference< css::ucb::XContentIdentifier >& xNewId );
111 
112  OUString
113  getBaseURI( const std::unique_ptr< DAVResourceAccess > & rResAccess );
114 
117  getResourceType( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
118 
121  getResourceType( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv,
122  const std::unique_ptr< DAVResourceAccess > & rResAccess,
123  bool * networkAccessAllowed = nullptr );
124 
125  // Command "open"
127  css::uno::Any open(
128  const css::ucb::OpenCommandArgument2 & rArg,
129  const css::uno::Reference<
130  css::ucb::XCommandEnvironment > & xEnv );
131 
132  // Command "post"
134  void post( const css::ucb::PostCommandArgument2 & rArg,
135  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
136 
137  // Command "insert"
139  void insert( const css::uno::Reference< css::io::XInputStream > & xInputStream,
140  bool bReplaceExisting,
141  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
142 
143  // Command "transfer"
145  void transfer( const css::ucb::TransferInfo & rArgs,
146  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
147 
148  // Command "delete"
150  void destroy( bool bDeletePhysical );
151 
152  // Command "lock"
154  void lock( const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
155 
156  // Command "unlock"
158  void unlock( const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
159 
160  css::uno::Any MapDAVException( const DAVException & e,
161  bool bWrite );
164  const DAVException & e,
165  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv,
166  bool bWrite = false );
167 
168  static bool shouldAccessNetworkAfterException( const DAVException & e );
169 
171  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
172 
173  // XPropertyContainer replacement
178  void addProperty( const css::ucb::PropertyCommandArgument &aCmdArg,
179  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
180 
184  void removeProperty( const OUString& Name,
185  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
186 public:
188  Content( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
189  ContentProvider* pProvider,
190  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
191  rtl::Reference< DAVSessionFactory > const & rSessionFactory );
193  Content( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
194  ContentProvider* pProvider,
195  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
196  rtl::Reference< DAVSessionFactory > const & rSessionFactory,
197  bool isCollection );
198  virtual ~Content() override;
199 
200  // XInterface
201  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
202  virtual void SAL_CALL acquire()
203  throw() override;
204  virtual void SAL_CALL release()
205  throw() override;
206 
207  // XTypeProvider
208  virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
209  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
210 
211  // XServiceInfo
212  virtual OUString SAL_CALL
213  getImplementationName() override;
214 
215  virtual css::uno::Sequence< OUString > SAL_CALL
216  getSupportedServiceNames() override;
217 
218  // XContent
219  virtual OUString SAL_CALL
220  getContentType() override;
221 
222  // XCommandProcessor
223  virtual css::uno::Any SAL_CALL
224  execute( const css::ucb::Command& aCommand,
225  sal_Int32 CommandId,
226  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override;
227  virtual void SAL_CALL
228  abort( sal_Int32 CommandId ) override;
229 
230  // XPropertyContainer
231  virtual void SAL_CALL
232  addProperty( const OUString& Name,
233  sal_Int16 Attributes,
234  const css::uno::Any& DefaultValue ) override;
235 
236  virtual void SAL_CALL
237  removeProperty( const OUString& Name ) override;
238 
239 
240  // Additional interfaces
241 
242 
243  // XContentCreator
244  virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL
245  queryCreatableContentsInfo() override;
246  virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
247  createNewContent( const css::ucb::ContentInfo& Info ) override;
248 
249 
250  // Non-interface methods.
251 
252 
254 
255  // Called from resultset data supplier.
256  static css::uno::Reference< css::sdbc::XRow >
257  getPropertyValues( const css::uno::Reference< css::uno::XComponentContext >& rContext,
258  const css::uno::Sequence< css::beans::Property >& rProperties,
259  const ContentProperties& rData,
261  const OUString& rContentId );
262 };
263 
264 }
265 
266 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< CachableContentProperties > m_xCachedProps
ContentProvider * m_pProvider
Type
virtual ~Content() override
virtual OUString SAL_CALL getImplementationName() override
bool supportsExclusiveWriteLock(const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
rtl::Reference< Content > ContentRef
void destroy(bool bDeletePhysical)
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Content(const css::uno::Reference< css::uno::XComponentContext > &rxContext, ContentProvider *pProvider, const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier, rtl::Reference< DAVSessionFactory > const &rSessionFactory)
virtual css::uno::Any SAL_CALL execute(const css::ucb::Command &aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment) override
css::uno::Any open(const css::ucb::OpenCommandArgument2 &rArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual void SAL_CALL acquire() override
signed char sal_Int8
void addProperty(const css::ucb::PropertyCommandArgument &aCmdArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
DAVResourceAccess & getResourceAccess()
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL release() override
virtual OUString SAL_CALL getContentType() override
ResourceType m_eResourceType
css::uno::Any MapDAVException(const DAVException &e, bool bWrite)
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL createNewContent(const css::ucb::ContentInfo &Info) override
bool isFolder(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual css::uno::Sequence< css::beans::Property > getProperties(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
ResourceType getResourceType(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void cancelCommandExecution(const DAVException &e, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, bool bWrite=false)
void queryChildren(ContentRefList &rChildren)
void unlock(const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
void transfer(const css::ucb::TransferInfo &rArgs, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
virtual css::uno::Sequence< css::ucb::CommandInfo > getCommands(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
bool exchangeIdentity(const css::uno::Reference< css::ucb::XContentIdentifier > &xNewId)
void post(const css::ucb::PostCommandArgument2 &rArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
OUString getBaseURI(const std::unique_ptr< DAVResourceAccess > &rResAccess)
css::uno::Sequence< css::uno::Any > setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &rValues, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
static bool shouldAccessNetworkAfterException(const DAVException &e)
std::vector< ContentRef > ContentRefList
friend ContentProvider
Definition: pkgprovider.cxx:53
void insert(const css::uno::Reference< css::io::XInputStream > &xInputStream, bool bReplaceExisting, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
std::vector< OUString > m_aFailedPropNames
css::uno::Reference< css::sdbc::XRow > getPropertyValues(const css::uno::Sequence< css::beans::Property > &rProperties, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void lock(const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
virtual OUString getParentURL() override
virtual void SAL_CALL abort(sal_Int32 CommandId) override
void removeProperty(const OUString &Name, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
std::unique_ptr< DAVResourceAccess > m_xResAccess
virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL queryCreatableContentsInfo() override