MythTV  master
upnptaskcache.h
Go to the documentation of this file.
1 // Program Name: upnptaskcache.h
3 // Created : Jan. 9, 2007
4 //
5 // Purpose : UPnp Task to keep SSDPCache free of stale records
6 //
7 // Copyright (c) 2007 David Blain <dblain@mythtv.org>
8 //
9 // Licensed under the GPL v2 or later, see COPYING for details
10 //
12 
13 #ifndef UPNPTASKCACHE_H
14 #define UPNPTASKCACHE_H
15 
16 #include <QString>
17 
18 #include "mythlogging.h"
19 #include "upnp.h"
20 
23 //
24 // SSDPCacheTask Class Definition
25 //
28 
29 class SSDPCacheTask : public Task
30 {
31  protected:
32 
33  int m_nInterval; // Number of ms between executing.
34  int m_nExecuteCount; // Used for debugging.
35 
36  // Destructor protected to force use of Release Method
37 
38  ~SSDPCacheTask() override = default;
39 
40  public:
41 
42  SSDPCacheTask() : Task("SSDPCacheTask")
43  {
44  m_nExecuteCount = 0;
45  m_nInterval = 1000 *
46  UPnp::GetConfiguration()->GetValue("UPnP/SSDP/CacheInterval", 30);
47  }
48 
49  QString Name() override // Task
50  {
51  return( "SSDPCache" );
52  }
53 
54  void Execute( TaskQueue *pQueue ) override // Task
55  {
57 
58  int nCount = SSDPCache::Instance()->RemoveStale();
59 
60  if (nCount > 0)
61  {
62  LOG(VB_UPNP, LOG_INFO,
63  QString("SSDPCacheTask - Removed %1 stale entries.")
64  .arg(nCount));
65  }
66 
67  if ((m_nExecuteCount % 60) == 0)
69 
70  pQueue->AddTask( m_nInterval, (Task *)this );
71  }
72 
73 };
74 
75 #endif // UPNPTASKCACHE_H
SSDPCacheTask::m_nExecuteCount
int m_nExecuteCount
Definition: upnptaskcache.h:34
arg
arg(title).arg(filename).arg(doDelete))
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
SSDPCacheTask::SSDPCacheTask
SSDPCacheTask()
Definition: upnptaskcache.h:42
SSDPCache::Instance
static SSDPCache * Instance()
Definition: ssdpcache.cpp:236
TaskQueue
Definition: taskqueue.h:82
SSDPCacheTask::Name
QString Name() override
Definition: upnptaskcache.h:49
upnp.h
mythlogging.h
SSDPCacheTask
Definition: upnptaskcache.h:30
Task
Definition: taskqueue.h:54
SSDPCache::RemoveStale
int RemoveStale()
Definition: ssdpcache.cpp:450
SSDPCache::Dump
void Dump(void)
Prints this device to the console in a human readable form.
Definition: ssdpcache.cpp:577
SSDPCacheTask::m_nInterval
int m_nInterval
Definition: upnptaskcache.h:33
SSDPCacheTask::~SSDPCacheTask
~SSDPCacheTask() override=default
Configuration::GetValue
virtual int GetValue(const QString &sSetting, int Default)=0
UPnp::GetConfiguration
static Configuration * GetConfiguration()
Definition: upnp.cpp:84
SSDPCacheTask::Execute
void Execute(TaskQueue *pQueue) override
Definition: upnptaskcache.h:54