solenv/clang-format/excludelist         |    1 
 ucb/Library_ucpdav1.mk                  |    1 
 ucb/source/ucp/webdav-curl/DAVTypes.cxx |   68 +++++++++++++++++
 ucb/source/ucp/webdav-curl/DAVTypes.hxx |  124 ++++++++++++++++++++++++++++----
 4 files changed, 182 insertions(+), 12 deletions(-)

New commits:
commit f472792a3ec03797b55e83d2de759caba3e57f79
Author:     Giuseppe Castagno <giuseppe.casta...@acca-esse.eu>
AuthorDate: Sat Jan 9 17:32:26 2016 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon Nov 1 18:31:35 2021 +0100

    ucb: webdav-curl: tdf#101094 (1) OPTIONS: New class to store retrieved 
OPTIONS
    
    This class describes the DAV options useful to LO.
    Added behavioural unit tests as well.
    
    [ port of commit f950b49393ee6539f2a7b3c306aa4fc119f24a84 ]
    
    Change-Id: Idfcd66229a2bbbdf4452da731a5b921527447358
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123282
    Tested-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index a70248a605ea..af38ed914cb2 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -14001,6 +14001,7 @@ ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx
 ucb/source/ucp/webdav-curl/DAVResourceAccess.hxx
 ucb/source/ucp/webdav-curl/DAVSession.hxx
 ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx
+ucb/source/ucp/webdav-curl/DAVTypes.cxx
 ucb/source/ucp/webdav-curl/DAVTypes.hxx
 ucb/source/ucp/webdav-curl/DateTimeHelper.cxx
 ucb/source/ucp/webdav-curl/DateTimeHelper.hxx
diff --git a/ucb/Library_ucpdav1.mk b/ucb/Library_ucpdav1.mk
index bedea713b179..ee1c944b1fbd 100644
--- a/ucb/Library_ucpdav1.mk
+++ b/ucb/Library_ucpdav1.mk
@@ -46,6 +46,7 @@ $(eval $(call gb_Library_add_exception_objects,ucpdav1,\
        ucb/source/ucp/webdav-curl/DAVProperties \
        ucb/source/ucp/webdav-curl/DAVResourceAccess \
        ucb/source/ucp/webdav-curl/DAVSessionFactory \
+       ucb/source/ucp/webdav-curl/DAVTypes \
        ucb/source/ucp/webdav-curl/DateTimeHelper \
        ucb/source/ucp/webdav-curl/SerfLockStore \
        ucb/source/ucp/webdav-curl/UCBDeadPropertyValue \
diff --git a/ucb/source/ucp/webdav-curl/DAVTypes.cxx 
b/ucb/source/ucp/webdav-curl/DAVTypes.cxx
new file mode 100644
index 000000000000..b71f61a1a3d3
--- /dev/null
+++ b/ucb/source/ucp/webdav-curl/DAVTypes.cxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+
+#include "DAVTypes.hxx"
+
+#include "../inc/urihelper.hxx"
+
+#include <osl/time.h>
+
+
+using namespace http_dav_ucp;
+using namespace com::sun::star;
+
+// DAVCapabilities implementation
+
+DAVOptions::DAVOptions() :
+    m_isResourceFound( false ),
+    m_isClass1( false ),
+    m_isClass2( false ),
+    m_isClass3( false ),
+    m_aAllowedMethods(),
+    m_nStaleTime( 0 ),
+    m_sURL(),
+    m_sRedirectedURL()
+{
+}
+
+
+DAVOptions::DAVOptions( const DAVOptions & rOther ) :
+    m_isResourceFound( rOther.m_isResourceFound ),
+    m_isClass1( rOther.m_isClass1 ),
+    m_isClass2( rOther.m_isClass2 ),
+    m_isClass3( rOther.m_isClass3 ),
+    m_aAllowedMethods( rOther.m_aAllowedMethods ),
+    m_nStaleTime( rOther.m_nStaleTime ),
+    m_sURL( rOther.m_sURL ),
+    m_sRedirectedURL( rOther.m_sRedirectedURL)
+{
+}
+
+
+DAVOptions::~DAVOptions()
+{
+}
+
+
+bool DAVOptions::operator==( const DAVOptions& rOpts ) const
+{
+    return
+        m_isResourceFound == rOpts.m_isResourceFound &&
+        m_isClass1 == rOpts.m_isClass1 &&
+        m_isClass2 == rOpts.m_isClass2 &&
+        m_isClass3 == rOpts.m_isClass3 &&
+        m_aAllowedMethods == rOpts.m_aAllowedMethods &&
+        m_nStaleTime == rOpts.m_nStaleTime &&
+        m_sURL == rOpts.m_sURL &&
+        m_sRedirectedURL == rOpts.m_sRedirectedURL;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/ucb/source/ucp/webdav-curl/DAVTypes.hxx 
b/ucb/source/ucp/webdav-curl/DAVTypes.hxx
index 3928d42e921e..e1d53909b4b9 100644
--- a/ucb/source/ucp/webdav-curl/DAVTypes.hxx
+++ b/ucb/source/ucp/webdav-curl/DAVTypes.hxx
@@ -20,28 +20,128 @@
 
 #pragma once
 
+#include <memory>
+#include <list>
+#include <map>
+#include <osl/mutex.hxx>
+#include <rtl/uri.hxx>
 #include <rtl/ustring.hxx>
 #include <com/sun/star/uno/Any.hxx>
 
 namespace http_dav_ucp
 {
+/* Excerpt from RFC 4918
+   <https://tools.ietf.org/html/rfc4918#section-18>
 
-enum Depth { DAVZERO = 0, DAVONE = 1, DAVINFINITY = -1 };
+   18.1 Class 1
 
-enum ProppatchOperation { PROPSET = 0, PROPREMOVE = 1 };
+   A class 1 compliant resource MUST meet all "MUST" requirements in all
+   sections of this document.
 
-struct ProppatchValue
-{
-    ProppatchOperation       operation;
-    OUString                 name;
-    css::uno::Any            value;
+   Class 1 compliant resources MUST return, at minimum, the value "1" in
+   the DAV header on all responses to the OPTIONS method.
+
+   18.2 Class 2
+
+   A class 2 compliant resource MUST meet all class 1 requirements and
+   support the LOCK method, the DAV:supportedlock property, the DAV:
+   lockdiscovery property, the Time-Out response header and the Lock-
+   Token request header.  A class 2 compliant resource SHOULD also
+   support the Timeout request header and the 'owner' XML element.
+
+   Class 2 compliant resources MUST return, at minimum, the values "1"
+   and "2" in the DAV header on all responses to the OPTIONS method.
+
+   18.3.  Class 3
+
+   A resource can explicitly advertise its support for the revisions to
+   [RFC2518] made in this document.  Class 1 MUST be supported as well.
+   Class 2 MAY be supported.  Advertising class 3 support in addition to
+   class 1 and 2 means that the server supports all the requirements in
+   this specification.  Advertising class 3 and class 1 support, but not
+   class 2, means that the server supports all the requirements in this
+   specification except possibly those that involve locking support.
+
+*/
+
+    class DAVOptions
+    {
+    private:
+        bool    m_isResourceFound;   // true if the resource was found, else 
false
+        bool    m_isClass1;
+        bool    m_isClass2;
+        bool    m_isClass3;
+        // contains the methods allowed on this resource
+        OUString    m_aAllowedMethods;
+
+        /// target time when this capability becomes stale
+        sal_uInt32 m_nStaleTime;
+        OUString  m_sURL;
+        OUString  m_sRedirectedURL;
+
+    public:
+        DAVOptions();
+
+        DAVOptions( const DAVOptions & rOther );
+
+        virtual ~DAVOptions();
+
+        bool isResourceFound() { return m_isResourceFound; };
+        void setResourceFound( bool ResourceFound = true ) { m_isResourceFound 
= ResourceFound; };
+
+        bool isClass1() { return m_isClass1; };
+        void setClass1( bool Class1 = true ) { m_isClass1 = Class1; };
+
+        bool isClass2() { return m_isClass2; };
+        void setClass2( bool Class2 = true ) { m_isClass2 = Class2; };
+
+        bool isClass3() { return m_isClass3; };
+        void setClass3( bool Class3 = true ) { m_isClass3 = Class3; };
+
+        sal_uInt32  getStaleTime() { return m_nStaleTime ; };
+        void setStaleTime( sal_uInt32 nStaleTime ) { m_nStaleTime = 
nStaleTime; };
+
+        OUString & getURL() { return m_sURL; };
+        void setURL( OUString & sURL ) { m_sURL = sURL; };
+
+        OUString & getRedirectedURL() { return m_sRedirectedURL; };
+        void setRedirectedURL( OUString & sRedirectedURL ) { m_sRedirectedURL 
= sRedirectedURL; };
+
+        void  setAllowedMethods( OUString & aAllowedMethods ) { 
m_aAllowedMethods = aAllowedMethods; } ;
+        OUString & getAllowedMethods() { return m_aAllowedMethods; } ;
+        bool isLockAllowed() { return ( m_aAllowedMethods.indexOf( "LOCK" ) != 
-1 ); };
+        bool isUnlockAllowed() { return ( m_aAllowedMethods.indexOf( "UNLOCK" 
) != -1 ); };
+
+        void reset() {
+            m_isResourceFound = false;
+            m_isClass1 = false;
+            m_isClass2 = false;
+            m_isClass3 = false;
+            m_aAllowedMethods.clear();
+            m_nStaleTime = 0;
+            m_sURL.clear();
+            m_sRedirectedURL.clear();
+        };
+
+        bool operator==( const DAVOptions& rOpts ) const;
+
+    };
+
+    enum Depth { DAVZERO = 0, DAVONE = 1, DAVINFINITY = -1 };
+
+    enum ProppatchOperation { PROPSET = 0, PROPREMOVE = 1 };
 
-    ProppatchValue( const ProppatchOperation o,
-                    const OUString & n,
-                    const css::uno::Any & v )
-    : operation( o ), name( n ), value( v ) {}
-};
+    struct ProppatchValue
+    {
+        ProppatchOperation  operation;
+        OUString            name;
+        css::uno::Any       value;
 
+        ProppatchValue( const ProppatchOperation o,
+                        const OUString & n,
+                        const css::uno::Any & v )
+            : operation( o ), name( n ), value( v ) {}
+    };
 } // namespace http_dav_ucp
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to