Debian Codegraph @

ucb/source/ucp/webdav-curl/DAVSession.hxx

raw
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 <rtl/ustring.hxx>
25 #include <com/sun/star/io/XInputStream.hpp>
26 #include <com/sun/star/io/XOutputStream.hpp>
27 #include <utility>
28 #include "DAVResource.hxx"
29 #include "DAVSessionFactory.hxx"
30 #include "DAVTypes.hxx"
31 #include "DAVRequestEnvironment.hxx"
32
33 namespace com { namespace sun { namespace star { namespace beans {
34 struct NamedValue;
35 } } } }
36
37 namespace com::sun::star::ucb {
38 struct Lock;
39 }
40
41 namespace http_dav_ucp
42 {
43
44 class DAVSession
45 {
46 public:
47 void acquire()
48 {
49 osl_atomic_increment( &m_nRefCount );
50 }
51
52 void release()
53 {
54 if ( osl_atomic_decrement( &m_nRefCount ) == 0 )
55 {
56 m_xFactory->releaseElement( this );
57 delete this;
58 }
59 }
60
61 virtual bool CanUse( const OUString & rURI,
62 const css::uno::Sequence<css::beans::NamedValue>& rFlags ) = 0;
63
64 virtual bool UsesProxy() = 0;
65
66 // DAV methods
67
68 virtual void OPTIONS( const OUString & inPath,
69 DAVOptions & rOptions,
70 const DAVRequestEnvironment & rEnv ) = 0;
71
72 // allprop & named
73 /// @throws DAVException
74 virtual void PROPFIND( const OUString & inPath,
75 const Depth inDepth,
76 const std::vector< OUString > & inPropertyNames,
77 std::vector< DAVResource > & ioResources,
78 const DAVRequestEnvironment & rEnv ) = 0;
79
80 // propnames
81 /// @throws DAVException
82 virtual void PROPFIND( const OUString & inPath,
83 const Depth inDepth,
84 std::vector< DAVResourceInfo > & ioResInfo,
85 const DAVRequestEnvironment & rEnv ) = 0;
86
87 /// @throws DAVException
88 virtual void PROPPATCH( const OUString & inPath,
89 const std::vector< ProppatchValue > & inValues,
90 const DAVRequestEnvironment & rEnv ) = 0;
91
92 /// @throws DAVException
93 virtual void HEAD( const OUString & inPath,
94 const std::vector< OUString > & inHeaderNames,
95 DAVResource & ioResource,
96 const DAVRequestEnvironment & rEnv ) = 0;
97
98 /// @throws DAVException
99 virtual css::uno::Reference< css::io::XInputStream >
100 GET( const OUString & inPath,
101 const DAVRequestEnvironment & rEnv ) = 0;
102
103 /// @throws DAVException
104 virtual void GET( const OUString & inPath,
105 css::uno::Reference< css::io::XOutputStream >& o,
106 const DAVRequestEnvironment & rEnv ) = 0;
107
108 /// @throws DAVException
109 virtual css::uno::Reference< css::io::XInputStream >
110 GET( const OUString & inPath,
111 const std::vector< OUString > & inHeaderNames,
112 DAVResource & ioResource,
113 const DAVRequestEnvironment & rEnv ) = 0;
114
115 /// @throws DAVException
116 virtual void
117 GET( const OUString & inPath,
118 css::uno::Reference< css::io::XOutputStream >& o,
119 const std::vector< OUString > & inHeaderNames,
120 DAVResource & ioResource,
121 const DAVRequestEnvironment & rEnv ) = 0;
122
123 /// @throws DAVException
124 virtual void PUT( const OUString & inPath,
125 const css::uno::Reference< css::io::XInputStream >& s,
126 const DAVRequestEnvironment & rEnv ) = 0;
127
128 /// @throws DAVException
129 virtual css::uno::Reference< css::io::XInputStream >
130 POST( const OUString & inPath,
131 const OUString & rContentType,
132 const OUString & rReferer,
133 const css::uno::Reference< css::io::XInputStream > & inInputStream,
134 const DAVRequestEnvironment & rEnv ) = 0;
135
136 /// @throws DAVException
137 virtual void POST( const OUString & inPath,
138 const OUString & rContentType,
139 const OUString & rReferer,
140 const css::uno::Reference< css::io::XInputStream > & inInputStream,
141 css::uno::Reference< css::io::XOutputStream > & oOutputStream,
142 const DAVRequestEnvironment & rEnv ) = 0;
143
144 /// @throws DAVException
145 virtual void MKCOL( const OUString & inPath,
146 const DAVRequestEnvironment & rEnv ) = 0;
147
148 /// @throws DAVException
149 virtual void COPY( const OUString & inSource,
150 const OUString & inDestination,
151 const DAVRequestEnvironment & rEnv,
152 bool inOverwrite = false ) = 0;
153
154 /// @throws DAVException
155 virtual void MOVE( const OUString & inSource,
156 const OUString & inDestination,
157 const DAVRequestEnvironment & rEnv,
158 bool inOverwrite = false ) = 0;
159
160 /// @throws DAVException
161 virtual void DESTROY( const OUString & inPath,
162 const DAVRequestEnvironment & rEnv ) = 0;
163
164 // set new lock.
165 /// @throws DAVException
166 virtual void LOCK( const OUString & inPath,
167 css::ucb::Lock & inLock,
168 const DAVRequestEnvironment & rEnv ) = 0;
169
170 /// @throws DAVException
171 virtual void UNLOCK( const OUString & inPath,
172 const DAVRequestEnvironment & rEnv ) = 0;
173
174 /// @throws DAVException
175 virtual void abort() = 0;
176
177 protected:
178 explicit DAVSession( rtl::Reference< DAVSessionFactory > xFactory )
179 : m_xFactory(std::move( xFactory )), m_nRefCount( 0 ) {}
180
181 virtual ~DAVSession() {}
182
183 private:
184 rtl::Reference< DAVSessionFactory > m_xFactory;
185 DAVSessionFactory::Map::iterator m_aContainerIt;
186 oslInterlockedCount m_nRefCount;
187
188 friend class DAVSessionFactory;
189 friend struct std::default_delete< DAVSession >;
190 };
191
192 } // namespace http_dav_ucp
193
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */