summaryrefslogtreecommitdiff
path: root/ucb/source
diff options
context:
space:
mode:
authorGiuseppe Castagno <giuseppe.castagno@acca-esse.eu>2016-01-09 17:32:26 +0100
committerGiuseppe Castagno <giuseppe.castagno@acca-esse.eu>2016-07-28 06:29:23 +0000
commitf950b49393ee6539f2a7b3c306aa4fc119f24a84 (patch)
tree524db5b7c87e96ce1ce8525310b926f73da0cf2b /ucb/source
parent66dd26659e7c4bb731a88e7dbc809c5b53cb79c3 (diff)
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. Change-Id: I7ba0230f1a1469b12f9b3f59f21e5c2730c65b81 Reviewed-on: https://gerrit.libreoffice.org/27595 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Giuseppe Castagno <giuseppe.castagno@acca-esse.eu>
Diffstat (limited to 'ucb/source')
-rw-r--r--ucb/source/ucp/webdav-neon/DAVTypes.cxx67
-rw-r--r--ucb/source/ucp/webdav-neon/DAVTypes.hxx124
2 files changed, 179 insertions, 12 deletions
diff --git a/ucb/source/ucp/webdav-neon/DAVTypes.cxx b/ucb/source/ucp/webdav-neon/DAVTypes.cxx
new file mode 100644
index 000000000000..1fbf84d09821
--- /dev/null
+++ b/ucb/source/ucp/webdav-neon/DAVTypes.cxx
@@ -0,0 +1,67 @@
+/* -*- 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 "osl/time.h"
+
+#include "DAVTypes.hxx"
+#include "../inc/urihelper.hxx"
+#include "NeonUri.hxx"
+
+using namespace webdav_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-neon/DAVTypes.hxx b/ucb/source/ucp/webdav-neon/DAVTypes.hxx
index 6ee993a29fda..b1499878e4d7 100644
--- a/ucb/source/ucp/webdav-neon/DAVTypes.hxx
+++ b/ucb/source/ucp/webdav-neon/DAVTypes.hxx
@@ -30,28 +30,128 @@
#define INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_DAVTYPES_HXX
#include <config_lgpl.h>
+#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 webdav_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 webdav_ucp
#endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_DAVTYPES_HXX