LibreOffice Module ucb (master)  1
neon/DAVResourceAccess.hxx
Go to the documentation of this file.
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 INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_DAVRESOURCEACCESS_HXX
30 #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_DAVRESOURCEACCESS_HXX
31 
32 #include <config_lgpl.h>
33 #include <vector>
34 #include <rtl/ustring.hxx>
35 #include <rtl/ref.hxx>
36 #include <osl/mutex.hxx>
37 #include <com/sun/star/io/XInputStream.hpp>
38 #include <com/sun/star/io/XOutputStream.hpp>
39 #include <com/sun/star/beans/NamedValue.hpp>
40 #include <com/sun/star/ucb/Lock.hpp>
41 #include <com/sun/star/ucb/WebDAVHTTPMethod.hpp>
42 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
43 #include "DAVAuthListener.hxx"
44 #include "DAVException.hxx"
45 #include "DAVSession.hxx"
46 #include "DAVResource.hxx"
47 #include "DAVTypes.hxx"
48 #include "NeonUri.hxx"
49 
50 namespace webdav_ucp
51 {
52 
53 class DAVSessionFactory;
54 
56 {
57  osl::Mutex m_aMutex;
58  OUString m_aURL;
59  OUString m_aPath;
60  css::uno::Sequence< css::beans::NamedValue > m_aFlags;
63  css::uno::Reference< css::uno::XComponentContext > m_xContext;
64  std::vector< NeonUri > m_aRedirectURIs;
65 
66 public:
67  DAVResourceAccess( const css::uno::Reference< css::uno::XComponentContext > & rxContext,
68  rtl::Reference< DAVSessionFactory > const & rSessionFactory,
69  const OUString & rURL );
70  DAVResourceAccess( const DAVResourceAccess & rOther );
71 
72  DAVResourceAccess & operator=( const DAVResourceAccess & rOther );
73 
75  void setFlags( const css::uno::Sequence< css::beans::NamedValue >& rFlags );
76 
78  void setURL( const OUString & rNewURL );
79 
80  void resetUri();
81 
82  const OUString & getURL() const { return m_aURL; }
83 
85  { return m_xSessionFactory; }
86 
87  // DAV methods
88 
90  void
91  OPTIONS( DAVOptions & rOptions,
92  const css::uno::Reference<
93  css::ucb::XCommandEnvironment > & xEnv );
94 
95  // allprop & named
97  void
98  PROPFIND( const Depth nDepth,
99  const std::vector< OUString > & rPropertyNames,
100  std::vector< DAVResource > & rResources,
101  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
102 
103  // propnames
105  void
106  PROPFIND( const Depth nDepth,
107  std::vector< DAVResourceInfo > & rResInfo,
108  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
109 
111  void
112  PROPPATCH( const std::vector< ProppatchValue > & rValues,
113  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
114 
116  void
117  HEAD( const std::vector< OUString > & rHeaderNames, // empty == 'all'
118  DAVResource & rResource,
119  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
120 
122  css::uno::Reference< css::io::XInputStream >
123  GET( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
124 
126  void
127  GET( css::uno::Reference< css::io::XOutputStream > & rStream,
128  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
129 
132  css::uno::Reference< css::io::XInputStream >
133  GET( const std::vector< OUString > & rHeaderNames, // empty == 'all'
134  DAVResource & rResource,
135  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
136 
137  // used as HEAD substitute when HEAD is not implemented on server
139  void
140  GET0( DAVRequestHeaders & rRequestHeaders,
141  const std::vector< OUString > & rHeaderNames, // empty == 'all'
142  DAVResource & rResource,
143  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
144 
146  void
147  GET( css::uno::Reference< css::io::XOutputStream > & rStream,
148  const std::vector< OUString > & rHeaderNames, // empty == 'all'
149  DAVResource & rResource,
150  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
151 
154  void
155  PUT( const css::uno::Reference< css::io::XInputStream > & rStream,
156  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
157 
160  css::uno::Reference< css::io::XInputStream >
161  POST( const OUString & rContentType,
162  const OUString & rReferer,
163  const css::uno::Reference< css::io::XInputStream > & rInputStream,
164  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
165 
168  void
169  POST( const OUString & rContentType,
170  const OUString & rReferer,
171  const css::uno::Reference< css::io::XInputStream > & rInputStream,
172  css::uno::Reference< css::io::XOutputStream > & rOutputStream,
173  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
174 
176  void
177  MKCOL( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
178 
180  void
181  COPY( const OUString & rSourcePath,
182  const OUString & rDestinationURI,
183  bool bOverwrite,
184  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
185 
187  void
188  MOVE( const OUString & rSourcePath,
189  const OUString & rDestinationURI,
190  bool bOverwrite,
191  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
192 
194  void
195  DESTROY( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
196 
197  // set new lock.
199  void
200  LOCK( css::ucb::Lock & inLock,
201  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
202 
204  void
205  UNLOCK( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
206 
208  void
209  abort();
210 
211  // helper
212  static void
214  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv,
215  const OUString & rURI,
216  css::ucb::WebDAVHTTPMethod eMethod,
217  DAVRequestHeaders & rRequestHeaders );
218 
220  bool handleException( const DAVException & e, int errorCount );
221 
222 private:
223  const OUString & getRequestURI() const;
225  bool detectRedirectCycle( const OUString& rRedirectURL );
227  void initialize();
228 };
229 
230 } // namespace webdav_ucp
231 
232 #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_DAVRESOURCEACCESS_HXX
233 
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const OUString & getRequestURI() const
void UNLOCK(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void setFlags(const css::uno::Sequence< css::beans::NamedValue > &rFlags)
rtl::Reference< DAVSessionFactory > m_xSessionFactory
DAVResourceAccess(const css::uno::Reference< css::uno::XComponentContext > &rxContext, rtl::Reference< DAVSessionFactory > const &rSessionFactory, const OUString &rURL)
std::vector< DAVRequestHeader > DAVRequestHeaders
void MKCOL(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void GET0(DAVRequestHeaders &rRequestHeaders, const std::vector< OUString > &rHeaderNames, DAVResource &rResource, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
rtl::Reference< DAVSession > m_xSession
void PROPPATCH(const std::vector< ProppatchValue > &rValues, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void PROPFIND(const Depth nDepth, const std::vector< OUString > &rPropertyNames, std::vector< DAVResource > &rResources, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
css::uno::Reference< css::uno::XComponentContext > m_xContext
void LOCK(css::ucb::Lock &inLock, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void MOVE(const OUString &rSourcePath, const OUString &rDestinationURI, bool bOverwrite, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void COPY(const OUString &rSourcePath, const OUString &rDestinationURI, bool bOverwrite, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
const rtl::Reference< DAVSessionFactory > & getSessionFactory() const
void PUT(const css::uno::Reference< css::io::XInputStream > &rStream, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
DAVResourceAccess & operator=(const DAVResourceAccess &rOther)
void DESTROY(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
const OUString & getURL() const
static void getUserRequestHeaders(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, const OUString &rURI, css::ucb::WebDAVHTTPMethod eMethod, DAVRequestHeaders &rRequestHeaders)
css::uno::Sequence< css::beans::NamedValue > m_aFlags
void OPTIONS(DAVOptions &rOptions, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
css::uno::Reference< css::io::XInputStream > POST(const OUString &rContentType, const OUString &rReferer, const css::uno::Reference< css::io::XInputStream > &rInputStream, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
std::vector< NeonUri > m_aRedirectURIs
void HEAD(const std::vector< OUString > &rHeaderNames, DAVResource &rResource, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void setURL(const OUString &rNewURL)
bool detectRedirectCycle(const OUString &rRedirectURL)
css::uno::Reference< css::io::XInputStream > GET(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
bool handleException(const DAVException &e, int errorCount)