LibreOffice Module ucb (master)  1
SerfLockStore.hxx
Go to the documentation of this file.
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 <map>
24 #include <osl/mutex.hxx>
25 #include <rtl/ref.hxx>
26 #include <rtl/ustring.hxx>
27 #include "SerfSession.hxx"
28 
29 namespace http_dav_ucp
30 {
31 
32 class TickerThread;
33 
34 struct LockInfo
35 {
36  OUString m_sToken;
39 
41  : m_nLastChanceToSendRefreshRequest( -1 ) {}
42 
43  LockInfo( const OUString& sToken,
44  rtl::Reference< SerfSession > const & xSession,
45  sal_Int32 nLastChanceToSendRefreshRequest )
46  : m_sToken( sToken ),
47  m_xSession( xSession ),
48  m_nLastChanceToSendRefreshRequest( nLastChanceToSendRefreshRequest ) {}
49 };
50 
51 typedef std::map< OUString, LockInfo > LockInfoMap;
52 
54 {
55  osl::Mutex m_aMutex;
58  LockInfoMap m_aLockInfoMap;
59 
60 public:
61  SerfLockStore();
63 
64  bool finishing() const;
65  OUString getLockToken( const OUString& rLock );
66 
67  void addLock( const OUString& rLock,
68  const OUString& sToken,
69  rtl::Reference< SerfSession > const & xSession,
70  // time in seconds since Jan 1 1970
71  // -1: infinite lock, no refresh
72  sal_Int32 nLastChanceToSendRefreshRequest );
73 
74  void updateLock( const OUString& rLock,
75  sal_Int32 nLastChanceToSendRefreshRequest );
76 
77  void removeLock( const OUString& rLock );
78 
79  void refreshLocks();
80 
81 private:
82  void startTicker();
83  void stopTicker();
84 };
85 
86 } // namespace http_dav_ucp
87 
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void addLock(const OUString &rLock, const OUString &sToken, rtl::Reference< SerfSession > const &xSession, sal_Int32 nLastChanceToSendRefreshRequest)
LockInfo(const OUString &sToken, rtl::Reference< SerfSession > const &xSession, sal_Int32 nLastChanceToSendRefreshRequest)
void updateLock(const OUString &rLock, sal_Int32 nLastChanceToSendRefreshRequest)
OUString getLockToken(const OUString &rLock)
sal_Int32 m_nLastChanceToSendRefreshRequest
void removeLock(const OUString &rLock)
std::map< OUString, LockInfo > LockInfoMap
rtl::Reference< SerfSession > m_xSession