18590a0fdSAndre Fischer /************************************************************** 28590a0fdSAndre Fischer * 38590a0fdSAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 48590a0fdSAndre Fischer * or more contributor license agreements. See the NOTICE file 58590a0fdSAndre Fischer * distributed with this work for additional information 68590a0fdSAndre Fischer * regarding copyright ownership. The ASF licenses this file 78590a0fdSAndre Fischer * to you under the Apache License, Version 2.0 (the 88590a0fdSAndre Fischer * "License"); you may not use this file except in compliance 98590a0fdSAndre Fischer * with the License. You may obtain a copy of the License at 108590a0fdSAndre Fischer * 118590a0fdSAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 128590a0fdSAndre Fischer * 138590a0fdSAndre Fischer * Unless required by applicable law or agreed to in writing, 148590a0fdSAndre Fischer * software distributed under the License is distributed on an 158590a0fdSAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 168590a0fdSAndre Fischer * KIND, either express or implied. See the License for the 178590a0fdSAndre Fischer * specific language governing permissions and limitations 188590a0fdSAndre Fischer * under the License. 198590a0fdSAndre Fischer * 208590a0fdSAndre Fischer *************************************************************/ 218590a0fdSAndre Fischer 228590a0fdSAndre Fischer 23*9646dec5SDamjan Jovanovic #ifndef INCLUDED_CURLLOCKSTORE_HXX 24*9646dec5SDamjan Jovanovic #define INCLUDED_CURLLOCKSTORE_HXX 258590a0fdSAndre Fischer 268590a0fdSAndre Fischer #include <map> 27c1c10f68SAriel Constenla-Haile #include <osl/mutex.hxx> 28c1c10f68SAriel Constenla-Haile #include <rtl/ref.hxx> 29*9646dec5SDamjan Jovanovic #include "CurlTypes.hxx" 30*9646dec5SDamjan Jovanovic #include "CurlSession.hxx" 318590a0fdSAndre Fischer 328590a0fdSAndre Fischer namespace http_dav_ucp 338590a0fdSAndre Fischer { 348590a0fdSAndre Fischer 358590a0fdSAndre Fischer class TickerThread; 36*9646dec5SDamjan Jovanovic class CurlSession; 378590a0fdSAndre Fischer 388590a0fdSAndre Fischer struct ltptr 398590a0fdSAndre Fischer { operator ()http_dav_ucp::ltptr40*9646dec5SDamjan Jovanovic bool operator()( const CurlLock * p1, const CurlLock * p2 ) const 418590a0fdSAndre Fischer { 428590a0fdSAndre Fischer return p1 < p2; 438590a0fdSAndre Fischer } 448590a0fdSAndre Fischer }; 458590a0fdSAndre Fischer 468590a0fdSAndre Fischer typedef struct _LockInfo 478590a0fdSAndre Fischer { 48*9646dec5SDamjan Jovanovic rtl::Reference< CurlSession > xSession; 498590a0fdSAndre Fischer sal_Int32 nLastChanceToSendRefreshRequest; 508590a0fdSAndre Fischer _LockInfohttp_dav_ucp::_LockInfo518590a0fdSAndre Fischer _LockInfo() 528590a0fdSAndre Fischer : nLastChanceToSendRefreshRequest( -1 ) {} 538590a0fdSAndre Fischer _LockInfohttp_dav_ucp::_LockInfo54*9646dec5SDamjan Jovanovic _LockInfo( rtl::Reference< CurlSession > const & _xSession, 558590a0fdSAndre Fischer sal_Int32 _nLastChanceToSendRefreshRequest ) 569c0c1533SAndrea Pescetti : xSession( _xSession ) 579c0c1533SAndrea Pescetti , nLastChanceToSendRefreshRequest( _nLastChanceToSendRefreshRequest ) {} 588590a0fdSAndre Fischer 598590a0fdSAndre Fischer } LockInfo; 608590a0fdSAndre Fischer 61*9646dec5SDamjan Jovanovic typedef std::map< CurlLock *, LockInfo, ltptr > LockInfoMap; 628590a0fdSAndre Fischer 63*9646dec5SDamjan Jovanovic class CurlLockStore 648590a0fdSAndre Fischer { 658590a0fdSAndre Fischer osl::Mutex m_aMutex; 668590a0fdSAndre Fischer TickerThread * m_pTickerThread; 678590a0fdSAndre Fischer LockInfoMap m_aLockInfoMap; 688590a0fdSAndre Fischer 698590a0fdSAndre Fischer public: 70*9646dec5SDamjan Jovanovic CurlLockStore(); 71*9646dec5SDamjan Jovanovic ~CurlLockStore(); 728590a0fdSAndre Fischer 73*9646dec5SDamjan Jovanovic void registerSession( CurlSession aSession ); 748590a0fdSAndre Fischer 75*9646dec5SDamjan Jovanovic CurlLock * findByUri( rtl::OUString const & rUri ); 768590a0fdSAndre Fischer 77*9646dec5SDamjan Jovanovic void addLock( CurlLock * pLock, 78*9646dec5SDamjan Jovanovic rtl::Reference< CurlSession > const & xSession, 798590a0fdSAndre Fischer // time in seconds since Jan 1 1970 808590a0fdSAndre Fischer // -1: infinite lock, no refresh 818590a0fdSAndre Fischer sal_Int32 nLastChanceToSendRefreshRequest ); 828590a0fdSAndre Fischer 83*9646dec5SDamjan Jovanovic void updateLock( CurlLock * pLock, 848590a0fdSAndre Fischer sal_Int32 nLastChanceToSendRefreshRequest ); 858590a0fdSAndre Fischer 86*9646dec5SDamjan Jovanovic void removeLock( CurlLock * pLock ); 878590a0fdSAndre Fischer 888590a0fdSAndre Fischer void refreshLocks(); 898590a0fdSAndre Fischer 908590a0fdSAndre Fischer private: 918590a0fdSAndre Fischer void startTicker(); 928590a0fdSAndre Fischer void stopTicker(); 938590a0fdSAndre Fischer }; 948590a0fdSAndre Fischer 958590a0fdSAndre Fischer } // namespace http_dav_ucp 968590a0fdSAndre Fischer 97*9646dec5SDamjan Jovanovic #endif // INCLUDED_CURLLOCKSTORE_HXX 98