1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #ifndef INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_PROPFINDCACHE_HXX
11 #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_PROPFINDCACHE_HXX
13 #include <sal/types.h>
14 #include <rtl/ustring.hxx>
19 #include "DAVResource.hxx"
21 namespace http_dav_ucp
23 // A property names cache mechanism, URL driven.
24 // It is used to cache the property names received
25 // from the WebDAV server, to minimize the need of
26 // net transactions (e.g. PROPFIND).
27 // The cache lifetime should be short
28 // just to remove the annoying slowness when
29 // typing text or moving cursor around when the
32 // Define the properties cache element
35 /// target time when this element becomes stale
36 sal_uInt32 m_nStaleTime
;
38 // the property name list received from WebDAV server
39 std::vector
< DAVResourceInfo
> m_aPropertiesNames
;
43 explicit PropertyNames( OUString aURL
);
45 sal_uInt32
getStaleTime() const { return m_nStaleTime
; };
46 void setStaleTime( const sal_uInt32 nStaleTime
) { m_nStaleTime
= nStaleTime
; };
48 OUString
& getURL() { return m_sURL
; };
50 const std::vector
< DAVResourceInfo
>& getPropertiesNames() { return m_aPropertiesNames
; };
51 void setPropertiesNames( const std::vector
< DAVResourceInfo
>& aPropertiesNames
) { m_aPropertiesNames
= aPropertiesNames
; };
54 // Define the PropertyNames cache
55 // TODO: the OUString key element in std::map needs to be changed with a URI representation
56 // with a specific compare (std::less) implementation, this last one implementing
57 // as suggested in <https://tools.ietf.org/html/rfc3986#section-6>.
58 // To find by URI and not by string equality.
59 typedef std::map
< OUString
, PropertyNames
,
60 std::less
< OUString
> >PropNameCache
;
62 class PropertyNamesCache
64 PropNameCache m_aTheCache
;
69 ~PropertyNamesCache();
71 bool getCachedPropertyNames( const OUString
& URL
, PropertyNames
& rCacheElement
);
72 void removeCachedPropertyNames( const OUString
& URL
);
73 void addCachePropertyNames( PropertyNames
& rCacheElement
, const sal_uInt32 nLifeTime
);
80 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */