summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--global.cpp15
-rw-r--r--global.h2
-rw-r--r--infosatepg.cpp40
-rw-r--r--infosatepg.h1
4 files changed, 34 insertions, 24 deletions
diff --git a/global.cpp b/global.cpp
index 7f57839..ed2c691 100644
--- a/global.cpp
+++ b/global.cpp
@@ -161,7 +161,6 @@ cGlobalInfosatepg::cGlobalInfosatepg()
MAC[4]=0x02;
WaitTime=10; // default 10 seconds
SetDirectory ("/tmp");
- ProcessedAll=false;
NoWakeup=false;
NoDeferredShutdown=false;
ActualMac=0;
@@ -367,7 +366,6 @@ void cGlobalInfosatepg::ResetReceivedAll(void)
Infosatdata[mac].ResetReceivedAll();
}
wakeuptime=-1;
- ProcessedAll=false;
}
void cGlobalInfosatepg::ResetProcessed (void)
@@ -377,7 +375,18 @@ void cGlobalInfosatepg::ResetProcessed (void)
Infosatdata[mac].Processed=false;
}
wakeuptime=-1;
- ProcessedAll=false;
+}
+
+bool cGlobalInfosatepg::ProcessedAll()
+{
+ int numProcessed=0;
+ for (int mac=EPG_FIRST_DAY_MAC; mac<=EPG_LAST_DAY_MAC; mac++)
+ {
+ if (Infosatdata[mac].Processed) numProcessed++;
+ }
+ // all days processed
+ if (numProcessed==EPG_DAYS) return true;
+ return false;
}
bool cGlobalInfosatepg::ReceivedAll(int *Day, int *Month)
diff --git a/global.h b/global.h
index fd5dad1..2f25aad 100644
--- a/global.h
+++ b/global.h
@@ -184,7 +184,7 @@ public:
int Load();
int Save();
- bool ProcessedAll;
+ bool ProcessedAll();
void ResetProcessed (void);
void ResetReceivedAll(void);
bool ReceivedAll (int *Day, int *Month);
diff --git a/infosatepg.cpp b/infosatepg.cpp
index f1fcaa7..f1ad47a 100644
--- a/infosatepg.cpp
+++ b/infosatepg.cpp
@@ -26,7 +26,6 @@ cPluginInfosatepg::cPluginInfosatepg(void)
// VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
statusMonitor=NULL;
global=new cGlobalInfosatepg;
- numprocessed=0;
pmac=EPG_FIRST_DAY_MAC;
}
@@ -128,28 +127,21 @@ void cPluginInfosatepg::MainThreadHook(void)
// Perform actions in the context of the main program thread.
if (!global->WaitOk()) return;
- if (!global->ProcessedAll)
+ if (!global->ProcessedAll())
{
if ((!global->Infosatdata[pmac].Processed) && global->Infosatdata[pmac].ReceivedAll())
{
isyslog ("infosatepg: found data to be processed: day=%i month=%i",
global->Infosatdata[pmac].Day(),global->Infosatdata[pmac].Month());
cProcessInfosatepg process(pmac,global);
- if (global->Infosatdata[pmac].Processed)
- {
- numprocessed++;
- pmac++;
- }
-
- if (numprocessed==EPG_DAYS)
- {
- global->ProcessedAll=true;
- numprocessed=0;
- pmac=EPG_FIRST_DAY_MAC;
- }
+ if (global->Infosatdata[pmac].Processed) pmac++;
}
global->SetWaitTimer();
}
+ else
+ {
+ pmac=EPG_FIRST_DAY_MAC;
+ }
if ((global->Switched()) || (global->ReceivedAll()) || (global->Channel()==-1)) return;
@@ -210,7 +202,7 @@ cString cPluginInfosatepg::Active(void)
// if we cannot receive, we shouldn't wait
if (global->Channel()==-1) return NULL;
- if (!global->ProcessedAll)
+ if (!global->ProcessedAll())
return tr("Infosat plugin still working");
// we are done
@@ -241,8 +233,18 @@ time_t cPluginInfosatepg::WakeupTime(void)
if (global->WakeupTime()==-1) global->SetWakeupTime(300); // just to be safe
time_t Now = time(NULL);
time_t Time = cTimer::SetTime(Now,cTimer::TimeToInt(global->WakeupTime()));
- if (Time <= Now)
+ double diff = difftime(Time,Now);
+ if (diff<0)
+ {
+ // wakeup time is in the past -> add a day
Time = cTimer::IncDay(Time,1);
+ }
+ else
+ {
+ // wakeup time is in less than 1 hour -> add a day
+ if (diff<3600)
+ Time = cTimer::IncDay(Time,1);
+ }
return Time;
}
@@ -298,6 +300,8 @@ const char **cPluginInfosatepg::SVDRPHelpPages(void)
" Reset received all",
"REPR\n"
" Reprocess again",
+ "SAVE\n",
+ " Save state of plugin",
NULL
};
return HelpPages;
@@ -310,7 +314,6 @@ cString cPluginInfosatepg::SVDRPCommand(const char *Command, const char *Option,
if (!strcasecmp(Command,"RESR"))
{
global->ResetReceivedAll();
- numprocessed=0;
pmac=EPG_FIRST_DAY_MAC;
asprintf(&output,"Restarted receiver\n");
@@ -318,7 +321,6 @@ cString cPluginInfosatepg::SVDRPCommand(const char *Command, const char *Option,
if (!strcasecmp(Command,"REPR"))
{
global->ResetProcessed();
- numprocessed=0;
pmac=EPG_FIRST_DAY_MAC;
asprintf(&output,"Reprocess\n");
@@ -336,7 +338,7 @@ cString cPluginInfosatepg::SVDRPCommand(const char *Command, const char *Option,
asprintf(&output,"%s Received all: yes (%02i.%02i.)",output,day,month);
else
asprintf(&output,"%s Received all: no",output);
- asprintf(&output,"%s Processed all: %s",output,global->ProcessedAll ? "yes" : "no");
+ asprintf(&output,"%s Processed all: %s",output,global->ProcessedAll() ? "yes" : "no");
asprintf(&output,"%s Switched: %s\n",output,global->Switched() ? "yes" : "no");
if (global->WakeupTime()!=-1)
{
diff --git a/infosatepg.h b/infosatepg.h
index 992369c..eb383f2 100644
--- a/infosatepg.h
+++ b/infosatepg.h
@@ -20,7 +20,6 @@ private:
// Add any member variables or functions you may need here.
cGlobalInfosatepg *global;
cStatusInfosatepg *statusMonitor;
- int numprocessed;
int pmac;
public:
cPluginInfosatepg(void);