1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef INCLUDED_SERFLOCKSTORE_HXX 24 #define INCLUDED_SERFLOCKSTORE_HXX 25 26 #include <map> 27 #include "osl/mutex.hxx" 28 #include "rtl/ref.hxx" 29 #include "SerfTypes.hxx" 30 31 namespace http_dav_ucp 32 { 33 34 class TickerThread; 35 class SerfSession; 36 37 struct ltptr 38 { 39 bool operator()( const SerfLock * p1, const SerfLock * p2 ) const 40 { 41 return p1 < p2; 42 } 43 }; 44 45 typedef struct _LockInfo 46 { 47 rtl::Reference< SerfSession > xSession; 48 sal_Int32 nLastChanceToSendRefreshRequest; 49 50 _LockInfo() 51 : nLastChanceToSendRefreshRequest( -1 ) {} 52 53 _LockInfo( rtl::Reference< SerfSession > const & _xSession, 54 sal_Int32 _nLastChanceToSendRefreshRequest ) 55 : xSession( _xSession ), 56 nLastChanceToSendRefreshRequest( _nLastChanceToSendRefreshRequest ) {} 57 58 } LockInfo; 59 60 typedef std::map< SerfLock *, LockInfo, ltptr > LockInfoMap; 61 62 class SerfLockStore 63 { 64 osl::Mutex m_aMutex; 65 // ne_lock_store * m_pSerfLockStore; 66 TickerThread * m_pTickerThread; 67 LockInfoMap m_aLockInfoMap; 68 69 public: 70 SerfLockStore(); 71 ~SerfLockStore(); 72 73 void registerSession( HttpSession * pHttpSession ); 74 75 SerfLock * findByUri( rtl::OUString const & rUri ); 76 77 void addLock( SerfLock * pLock, 78 rtl::Reference< SerfSession > const & xSession, 79 // time in seconds since Jan 1 1970 80 // -1: infinite lock, no refresh 81 sal_Int32 nLastChanceToSendRefreshRequest ); 82 83 void updateLock( SerfLock * pLock, 84 sal_Int32 nLastChanceToSendRefreshRequest ); 85 86 void removeLock( SerfLock * pLock ); 87 88 void refreshLocks(); 89 90 private: 91 void startTicker(); 92 void stopTicker(); 93 }; 94 95 } // namespace http_dav_ucp 96 97 #endif // INCLUDED_SERFLOCKSTORE_HXX 98