1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
29 #ifndef INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_DAVTYPES_HXX
30 #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_DAVTYPES_HXX
32 #include <config_lgpl.h>
34 #include <osl/mutex.hxx>
35 #include <rtl/ustring.hxx>
36 #include <com/sun/star/uno/Any.hxx>
40 /* Excerpt from RFC 4918
41 <https://tools.ietf.org/html/rfc4918#section-18>
45 A class 1 compliant resource MUST meet all "MUST" requirements in all
46 sections of this document.
48 Class 1 compliant resources MUST return, at minimum, the value "1" in
49 the DAV header on all responses to the OPTIONS method.
53 A class 2 compliant resource MUST meet all class 1 requirements and
54 support the LOCK method, the DAV:supportedlock property, the DAV:
55 lockdiscovery property, the Time-Out response header and the Lock-
56 Token request header. A class 2 compliant resource SHOULD also
57 support the Timeout request header and the 'owner' XML element.
59 Class 2 compliant resources MUST return, at minimum, the values "1"
60 and "2" in the DAV header on all responses to the OPTIONS method.
64 A resource can explicitly advertise its support for the revisions to
65 [RFC2518] made in this document. Class 1 MUST be supported as well.
66 Class 2 MAY be supported. Advertising class 3 support in addition to
67 class 1 and 2 means that the server supports all the requirements in
68 this specification. Advertising class 3 and class 1 support, but not
69 class 2, means that the server supports all the requirements in this
70 specification except possibly those that involve locking support.
74 class DAVOptions final
80 /// for server that do not implement it
82 /// Internally used to maintain the locked state of the resource, only if it's a Class 2 resource
84 /// contains the methods allowed on this resource
85 OUString m_aAllowedMethods
;
87 /// target time when this capability becomes stale
88 sal_uInt32 m_nStaleTime
;
89 sal_uInt32 m_nRequestedTimeLife
;
91 OUString m_sRedirectedURL
;
93 /// The cached HTT response status code. It's 0 if the code was dealt with and there is no need to cache it
94 sal_uInt16 m_nHttpResponseStatusCode
;
95 /// The cached string with the server returned HTTP response status code string, corresponds to m_nHttpResponseStatusCode.
96 OUString m_sHttpResponseStatusText
;
101 DAVOptions( const DAVOptions
& rOther
);
105 bool isClass1() const { return m_isClass1
; };
106 void setClass1( bool Class1
= true ) { m_isClass1
= Class1
; };
108 bool isClass2() const { return m_isClass2
; };
109 void setClass2( bool Class2
= true ) { m_isClass2
= Class2
; };
111 bool isClass3() const { return m_isClass3
; };
112 void setClass3( bool Class3
= true ) { m_isClass3
= Class3
; };
114 bool isHeadAllowed() const { return m_isHeadAllowed
; };
115 void setHeadAllowed( bool HeadAllowed
= true ) { m_isHeadAllowed
= HeadAllowed
; };
117 sal_uInt32
getStaleTime() const { return m_nStaleTime
; };
118 void setStaleTime( const sal_uInt32 nStaleTime
) { m_nStaleTime
= nStaleTime
; };
120 sal_uInt32
getRequestedTimeLife() const { return m_nRequestedTimeLife
; };
121 void setRequestedTimeLife( const sal_uInt32 nRequestedTimeLife
) { m_nRequestedTimeLife
= nRequestedTimeLife
; };
123 const OUString
& getURL() const { return m_sURL
; };
124 void setURL( const OUString
& sURL
) { m_sURL
= sURL
; };
126 const OUString
& getRedirectedURL() const { return m_sRedirectedURL
; };
127 void setRedirectedURL( const OUString
& sRedirectedURL
) { m_sRedirectedURL
= sRedirectedURL
; };
129 void setAllowedMethods( const OUString
& aAllowedMethods
) { m_aAllowedMethods
= aAllowedMethods
; } ;
130 const OUString
& getAllowedMethods() const { return m_aAllowedMethods
; } ;
131 bool isLockAllowed() const { return ( m_aAllowedMethods
.indexOf( "LOCK" ) != -1 ); };
133 void setLocked( bool locked
= true ) { m_isLocked
= locked
; } ;
134 bool isLocked() const { return m_isLocked
; };
136 sal_uInt16
getHttpResponseStatusCode() const { return m_nHttpResponseStatusCode
; };
137 void setHttpResponseStatusCode( const sal_uInt16 nHttpResponseStatusCode
) { m_nHttpResponseStatusCode
= nHttpResponseStatusCode
; };
139 const OUString
& getHttpResponseStatusText() const { return m_sHttpResponseStatusText
; };
140 void setHttpResponseStatusText( const OUString
& rHttpResponseStatusText
) { m_sHttpResponseStatusText
= rHttpResponseStatusText
; };
146 m_isHeadAllowed
= true;
148 m_aAllowedMethods
.clear();
150 m_nRequestedTimeLife
= 0;
152 m_sRedirectedURL
.clear();
153 m_nHttpResponseStatusCode
= 0;
154 m_sHttpResponseStatusText
.clear();
157 DAVOptions
& operator=( const DAVOptions
& rOpts
);
158 bool operator==( const DAVOptions
& rOpts
) const;
162 // TODO: the OUString key element in std::map needs to be changed with a URI representation
163 // along with a specific compare (std::less) implementation, as suggested in
164 // <https://tools.ietf.org/html/rfc3986#section-6>, to find by URI and not by string comparison
165 typedef std::map
< OUString
, DAVOptions
,
166 std::less
< OUString
> > DAVOptionsMap
;
168 class DAVOptionsCache
170 DAVOptionsMap m_aTheCache
;
173 explicit DAVOptionsCache();
176 bool getDAVOptions( const OUString
& rURL
, DAVOptions
& rDAVOptions
);
177 void removeDAVOptions( const OUString
& rURL
);
178 void addDAVOptions( DAVOptions
& rDAVOptions
, const sal_uInt32 nLifeTime
);
180 void setHeadAllowed( const OUString
& rURL
, bool HeadAllowed
= true );
184 /// remove the last '/' in aUrl, if it exists
185 static void normalizeURLLastChar( OUString
& aUrl
) {
186 if ( aUrl
.getLength() > 1 &&
187 ( ( aUrl
.lastIndexOf( '/' ) + 1 ) == aUrl
.getLength() ) )
188 aUrl
= aUrl
.copy(0, aUrl
.getLength() - 1 );
192 enum Depth
{ DAVZERO
= 0, DAVONE
= 1, DAVINFINITY
= -1 };
194 enum ProppatchOperation
{ PROPSET
= 0, PROPREMOVE
= 1 };
196 struct ProppatchValue
198 ProppatchOperation
const operation
;
200 css::uno::Any
const value
;
202 ProppatchValue( const ProppatchOperation o
,
204 const css::uno::Any
& v
)
205 : operation( o
), name( n
), value( v
) {}
207 } // namespace webdav_ucp
209 #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_DAVTYPES_HXX
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */