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 238590a0fdSAndre Fischer #ifndef INCLUDED_SERFLOCKSTORE_HXX 248590a0fdSAndre Fischer #define INCLUDED_SERFLOCKSTORE_HXX 258590a0fdSAndre Fischer 268590a0fdSAndre Fischer #include <map> 27*c1c10f68SAriel Constenla-Haile #include <osl/mutex.hxx> 28*c1c10f68SAriel Constenla-Haile #include <rtl/ref.hxx> 298590a0fdSAndre Fischer #include "SerfTypes.hxx" 308590a0fdSAndre Fischer 318590a0fdSAndre Fischer namespace http_dav_ucp 328590a0fdSAndre Fischer { 338590a0fdSAndre Fischer 348590a0fdSAndre Fischer class TickerThread; 358590a0fdSAndre Fischer class SerfSession; 368590a0fdSAndre Fischer 378590a0fdSAndre Fischer struct ltptr 388590a0fdSAndre Fischer { 398590a0fdSAndre Fischer bool operator()( const SerfLock * p1, const SerfLock * p2 ) const 408590a0fdSAndre Fischer { 418590a0fdSAndre Fischer return p1 < p2; 428590a0fdSAndre Fischer } 438590a0fdSAndre Fischer }; 448590a0fdSAndre Fischer 458590a0fdSAndre Fischer typedef struct _LockInfo 468590a0fdSAndre Fischer { 478590a0fdSAndre Fischer rtl::Reference< SerfSession > xSession; 488590a0fdSAndre Fischer sal_Int32 nLastChanceToSendRefreshRequest; 498590a0fdSAndre Fischer 508590a0fdSAndre Fischer _LockInfo() 518590a0fdSAndre Fischer : nLastChanceToSendRefreshRequest( -1 ) {} 528590a0fdSAndre Fischer 538590a0fdSAndre Fischer _LockInfo( rtl::Reference< SerfSession > const & _xSession, 548590a0fdSAndre Fischer sal_Int32 _nLastChanceToSendRefreshRequest ) 558590a0fdSAndre Fischer : xSession( _xSession ), 568590a0fdSAndre Fischer nLastChanceToSendRefreshRequest( _nLastChanceToSendRefreshRequest ) {} 578590a0fdSAndre Fischer 588590a0fdSAndre Fischer } LockInfo; 598590a0fdSAndre Fischer 608590a0fdSAndre Fischer typedef std::map< SerfLock *, LockInfo, ltptr > LockInfoMap; 618590a0fdSAndre Fischer 628590a0fdSAndre Fischer class SerfLockStore 638590a0fdSAndre Fischer { 648590a0fdSAndre Fischer osl::Mutex m_aMutex; 658590a0fdSAndre Fischer // ne_lock_store * m_pSerfLockStore; 668590a0fdSAndre Fischer TickerThread * m_pTickerThread; 678590a0fdSAndre Fischer LockInfoMap m_aLockInfoMap; 688590a0fdSAndre Fischer 698590a0fdSAndre Fischer public: 708590a0fdSAndre Fischer SerfLockStore(); 718590a0fdSAndre Fischer ~SerfLockStore(); 728590a0fdSAndre Fischer 738590a0fdSAndre Fischer void registerSession( HttpSession * pHttpSession ); 748590a0fdSAndre Fischer 758590a0fdSAndre Fischer SerfLock * findByUri( rtl::OUString const & rUri ); 768590a0fdSAndre Fischer 778590a0fdSAndre Fischer void addLock( SerfLock * pLock, 788590a0fdSAndre Fischer rtl::Reference< SerfSession > 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 838590a0fdSAndre Fischer void updateLock( SerfLock * pLock, 848590a0fdSAndre Fischer sal_Int32 nLastChanceToSendRefreshRequest ); 858590a0fdSAndre Fischer 868590a0fdSAndre Fischer void removeLock( SerfLock * 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 978590a0fdSAndre Fischer #endif // INCLUDED_SERFLOCKSTORE_HXX 98