00001 00002 // Program Name: upnptaskcache.h 00003 // Created : Jan. 9, 2007 00004 // 00005 // Purpose : UPnp Task to keep SSDPCache free of stale records 00006 // 00007 // Copyright (c) 2007 David Blain <dblain@mythtv.org> 00008 // 00009 // Licensed under the GPL v2 or later, see COPYING for details 00010 // 00012 00013 #ifndef __UPNPTASKCACHE_H__ 00014 #define __UPNPTASKCACHE_H__ 00015 00016 #include <QString> 00017 00018 #include "mythlogging.h" 00019 #include "upnp.h" 00020 00023 // 00024 // SSDPCacheTask Class Definition 00025 // 00028 00029 class SSDPCacheTask : public Task 00030 { 00031 protected: 00032 00033 int m_nInterval; // Number of ms between executing. 00034 int m_nExecuteCount; // Used for debugging. 00035 00036 // Destructor protected to force use of Release Method 00037 00038 virtual ~SSDPCacheTask() {}; 00039 00040 public: 00041 00042 SSDPCacheTask() 00043 { 00044 m_nExecuteCount = 0; 00045 m_nInterval = 1000 * 00046 UPnp::GetConfiguration()->GetValue("UPnP/SSDP/CacheInterval", 30); 00047 } 00048 00049 virtual QString Name () 00050 { 00051 return( "SSDPCache" ); 00052 } 00053 00054 virtual void Execute( TaskQueue *pQueue ) 00055 { 00056 m_nExecuteCount++; 00057 00058 int nCount = SSDPCache::Instance()->RemoveStale(); 00059 00060 if (nCount > 0) 00061 LOG(VB_UPNP, LOG_INFO, 00062 QString("SSDPCacheTask - Removed %1 stale entries.") 00063 .arg(nCount)); 00064 00065 if ((m_nExecuteCount % 60) == 0) 00066 SSDPCache::Instance()->Dump(); 00067 00068 pQueue->AddTask( m_nInterval, (Task *)this ); 00069 } 00070 00071 }; 00072 00073 #endif
1.6.3