summaryrefslogtreecommitdiff
path: root/conflictcheck_thread.c
diff options
context:
space:
mode:
authorJohann Friedrichs <johann.friedrichs@web.de>2018-03-21 12:14:55 +0100
committerJohann Friedrichs <johann.friedrichs@web.de>2018-03-21 12:14:55 +0100
commite8a0e569152c50d6084f252d12854b8fd4e74466 (patch)
tree5a90ef7ea08ff2096df157ca109c5268cdc04903 /conflictcheck_thread.c
parent9c7d95ff8d6ba965cb23147507a859b1fd0491d6 (diff)
downloadvdr-plugin-epgsearch-e8a0e569152c50d6084f252d12854b8fd4e74466.tar.gz
vdr-plugin-epgsearch-e8a0e569152c50d6084f252d12854b8fd4e74466.tar.bz2
unified indentation
Diffstat (limited to 'conflictcheck_thread.c')
-rw-r--r--conflictcheck_thread.c164
1 files changed, 79 insertions, 85 deletions
diff --git a/conflictcheck_thread.c b/conflictcheck_thread.c
index 8c58a22..e9bce14 100644
--- a/conflictcheck_thread.c
+++ b/conflictcheck_thread.c
@@ -37,7 +37,7 @@ bool cConflictCheckThread::m_runOnce = false;
bool cConflictCheckThread::m_forceUpdate = false;
cConflictCheckThread::cConflictCheckThread(cPluginEpgsearch* thePlugin)
-: cThread("EPGSearch: conflictcheck")
+ : cThread("EPGSearch: conflictcheck")
{
m_plugin = thePlugin;
m_Active = false;
@@ -46,36 +46,36 @@ cConflictCheckThread::cConflictCheckThread(cPluginEpgsearch* thePlugin)
m_forceUpdate = false;
}
-cConflictCheckThread::~cConflictCheckThread() {
+cConflictCheckThread::~cConflictCheckThread()
+{
if (m_Active)
- Stop();
+ Stop();
}
void cConflictCheckThread::Init(cPluginEpgsearch* thePlugin, bool runOnce)
{
- if (EPGSearchConfig.checkTimerConflictsAfterUpdate || EPGSearchConfig.conflictCheckIntervall == 0)
- {
- if (!runOnce) return;
- m_runOnce = true;
- }
-
- if (m_Instance == NULL) {
- m_Instance = new cConflictCheckThread(thePlugin);
- m_Instance->Start();
- }
- else
- if (runOnce) m_forceUpdate = true; // force an update, because thread is already running
+ if (EPGSearchConfig.checkTimerConflictsAfterUpdate || EPGSearchConfig.conflictCheckIntervall == 0) {
+ if (!runOnce) return;
+ m_runOnce = true;
+ }
+
+ if (m_Instance == NULL) {
+ m_Instance = new cConflictCheckThread(thePlugin);
+ m_Instance->Start();
+ } else if (runOnce) m_forceUpdate = true; // force an update, because thread is already running
}
-void cConflictCheckThread::Exit(void) {
+void cConflictCheckThread::Exit(void)
+{
if (m_Instance != NULL) {
- m_Instance->Stop();
- DELETENULL(m_Instance);
+ m_Instance->Stop();
+ DELETENULL(m_Instance);
}
}
-void cConflictCheckThread::Stop(void) {
+void cConflictCheckThread::Stop(void)
+{
m_Active = false;
Wait.Signal();
Cancel(6);
@@ -87,80 +87,74 @@ void cConflictCheckThread::Action(void)
m_Active = true;
// let VDR do its startup
- if (!m_runOnce)
- {
- if (!cPluginEpgsearch::VDR_readyafterStartup)
- LogFile.Log(2, "ConflictCheckThread: waiting for VDR to become ready...");
- while(m_Active && !cPluginEpgsearch::VDR_readyafterStartup)
- Wait.Wait(1000);
- }
+ if (!m_runOnce) {
+ if (!cPluginEpgsearch::VDR_readyafterStartup)
+ LogFile.Log(2, "ConflictCheckThread: waiting for VDR to become ready...");
+ while (m_Active && !cPluginEpgsearch::VDR_readyafterStartup)
+ Wait.Wait(1000);
+ }
time_t nextUpdate = time(NULL);
- while (m_Active && Running())
- {
- time_t now = time(NULL);
- if (now >= nextUpdate || m_forceUpdate)
- {
- m_forceUpdate = false;
+ while (m_Active && Running()) {
+ time_t now = time(NULL);
+ if (now >= nextUpdate || m_forceUpdate) {
+ m_forceUpdate = false;
{
LOCK_TIMERS_WRITE;
Timers->SetExplicitModify();
}
- LogFile.iSysLog("timer conflict check started");
-
- cConflictCheck conflictCheck;
- conflictCheck.Check();
-
- time_t nextConflict = 0;
- if (conflictCheck.relevantConflicts > 0)
- {
- cString msgfmt = "";
- if (conflictCheck.relevantConflicts == 1)
- msgfmt = cString::sprintf(tr("timer conflict at %s! Show it?"),
- *DateTime(conflictCheck.nextRelevantConflictDate));
- else
- msgfmt = cString::sprintf(tr("%d timer conflicts! First at %s. Show them?"),
- conflictCheck.relevantConflicts,
- *DateTime(conflictCheck.nextRelevantConflictDate));
- bool doMessage = EPGSearchConfig.noConflMsgWhileReplay == 0 ||
- !cDevice::PrimaryDevice()->Replaying() ||
- conflictCheck.nextRelevantConflictDate - now < 2*60*60;
- if (doMessage && SendMsg(msgfmt, true,7, mtWarning) == kOk)
- {
- m_plugin->showConflicts = true;
- cRemote::CallPlugin("epgsearch");
- }
-
- if (EPGSearchConfig.sendMailOnConflicts)
- {
- cMailConflictNotifier mailNotifier;
- mailNotifier.SendConflictNotifications(conflictCheck);
- }
- conflictCheck.EvaluateConflCheckCmd();
- }
- // store for external access
- cConflictCheckThread::m_cacheNextConflict = conflictCheck.nextRelevantConflictDate;
- cConflictCheckThread::m_cacheRelevantConflicts = conflictCheck.relevantConflicts;
- cConflictCheckThread::m_cacheTotalConflicts = conflictCheck.numConflicts;
-
- LogFile.iSysLog("timer conflict check finished");
-
- m_lastUpdate = time(NULL);
- int Intervall = EPGSearchConfig.conflictCheckIntervall;
- if (nextConflict > 0 && EPGSearchConfig.conflictCheckWithinLimit > 0 &&
- nextConflict - time(NULL) < EPGSearchConfig.conflictCheckWithinLimit * 60)
- Intervall = EPGSearchConfig.conflictCheckIntervall2;
-
- nextUpdate = long(m_lastUpdate/60)*60 + (Intervall * 60);
- }
- if (m_Active && Running())
- Wait.Wait(2000); // to avoid high system load if time%30==0 ?????????????????????
- // no waiting in the while loop if m_runOnce is true
- while (Running() && m_Active && time(NULL)%30 != 0 && !m_runOnce) // sync heart beat to a multiple of 5secs
- Wait.Wait(1000);
+ LogFile.iSysLog("timer conflict check started");
+
+ cConflictCheck conflictCheck;
+ conflictCheck.Check();
+
+ time_t nextConflict = 0;
+ if (conflictCheck.relevantConflicts > 0) {
+ cString msgfmt = "";
+ if (conflictCheck.relevantConflicts == 1)
+ msgfmt = cString::sprintf(tr("timer conflict at %s! Show it?"),
+ *DateTime(conflictCheck.nextRelevantConflictDate));
+ else
+ msgfmt = cString::sprintf(tr("%d timer conflicts! First at %s. Show them?"),
+ conflictCheck.relevantConflicts,
+ *DateTime(conflictCheck.nextRelevantConflictDate));
+ bool doMessage = EPGSearchConfig.noConflMsgWhileReplay == 0 ||
+ !cDevice::PrimaryDevice()->Replaying() ||
+ conflictCheck.nextRelevantConflictDate - now < 2 * 60 * 60;
+ if (doMessage && SendMsg(msgfmt, true, 7, mtWarning) == kOk) {
+ m_plugin->showConflicts = true;
+ cRemote::CallPlugin("epgsearch");
+ }
+
+ if (EPGSearchConfig.sendMailOnConflicts) {
+ cMailConflictNotifier mailNotifier;
+ mailNotifier.SendConflictNotifications(conflictCheck);
+ }
+ conflictCheck.EvaluateConflCheckCmd();
+ }
+ // store for external access
+ cConflictCheckThread::m_cacheNextConflict = conflictCheck.nextRelevantConflictDate;
+ cConflictCheckThread::m_cacheRelevantConflicts = conflictCheck.relevantConflicts;
+ cConflictCheckThread::m_cacheTotalConflicts = conflictCheck.numConflicts;
+
+ LogFile.iSysLog("timer conflict check finished");
+
+ m_lastUpdate = time(NULL);
+ int Intervall = EPGSearchConfig.conflictCheckIntervall;
+ if (nextConflict > 0 && EPGSearchConfig.conflictCheckWithinLimit > 0 &&
+ nextConflict - time(NULL) < EPGSearchConfig.conflictCheckWithinLimit * 60)
+ Intervall = EPGSearchConfig.conflictCheckIntervall2;
+
+ nextUpdate = long(m_lastUpdate / 60) * 60 + (Intervall * 60);
+ }
+ if (m_Active && Running())
+ Wait.Wait(2000); // to avoid high system load if time%30==0 ?????????????????????
+ // no waiting in the while loop if m_runOnce is true
+ while (Running() && m_Active && time(NULL) % 30 != 0 && !m_runOnce) // sync heart beat to a multiple of 5secs
+ Wait.Wait(1000);
};
- m_Active = false; // always false at this point
+ m_Active = false; // always false at this point
LogFile.iSysLog("Leaving conflict check thread");
}