summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorMidas <vdrportal_midas@gmx.de>2010-08-06 02:26:00 +0200
committerMidas <vdrportal_midas@gmx.de>2010-08-06 02:26:00 +0200
commitd04ad65095872e60613282b584ee10013ea18f44 (patch)
tree4d31cce2a685354dbb8f9dd0d5e7e8ea94da4f93 /block.c
parent1565ce3671072ce03dc126f015af2e660497e323 (diff)
downloadvdr-plugin-block-d04ad65095872e60613282b584ee10013ea18f44.tar.gz
vdr-plugin-block-d04ad65095872e60613282b584ee10013ea18f44.tar.bz2
Release 0.0.4. Main menu entry now also deblocks. Replay of recorded
shows won't stop anymore on block events. Channel +/- work now to change zap direction on block events.
Diffstat (limited to 'block.c')
-rw-r--r--block.c132
1 files changed, 119 insertions, 13 deletions
diff --git a/block.c b/block.c
index def0ebb..be5c1ea 100644
--- a/block.c
+++ b/block.c
@@ -18,13 +18,19 @@
#include "config.h"
#include "i18n.h"
#include "control.h"
+#include "common.h"
+#include <vdr/interface.h>
-static const char *VERSION = "0.0.3";
+static const char *VERSION = "0.0.4";
static const char *DESCRIPTION = trNOOP("Block unwanted shows by EPG title");
-static const char *MAINMENUENTRY = trNOOP("Block broadcast");
+static const char *MAINMENUENTRY = trNOOP("(De)Block broadcast");
static int channelnumber=0;
-static char *temptitle=NULL;
+#ifdef LOGGING
+ char *channel_groupsep_string=(char*)"";
+ char *has_been_checked_string=(char*)"";
+ bool temp_replaying_recording=false;
+#endif
class cPluginBlock : public cPlugin {
@@ -50,7 +56,7 @@ cPluginBlock::cPluginBlock(void):
cPlugin(),
mStatus(NULL)
{
- temptitle=(char*)"";
+ cEventBlock::LastTitle=(char*)"block_dummy_title1";
}
cPluginBlock::~cPluginBlock()
@@ -86,8 +92,33 @@ cOsdObject *cPluginBlock::MainMenuAction(void)
return NULL;
const cEvent *present = sched->GetPresentEvent();
- EventsBlock.Add(new cEventBlock(present->Title()));
- EventsBlock.Save();
+
+ if (EventsBlock.Acceptable(present->Title()))
+ {
+ EventsBlock.Add(new cEventBlock(present->Title()));
+ EventsBlock.Save();
+ }
+ else
+ {
+ int index=0;
+ const cEventBlock* blockeventpointer = EventsBlock.First();
+ while (blockeventpointer != NULL)
+ {
+ if (strcmp(blockeventpointer->Pattern(),present->Title())==0)
+ break;
+ index+=1;
+ blockeventpointer=EventsBlock.Next(blockeventpointer);
+ }
+ cEventBlock *event=EventsBlock.Get(index);
+ if (event!=NULL)
+ {
+ if (Interface->Confirm(tr("Delete keyword?")))
+ EventsBlock.Del(event);
+ EventsBlock.Save();
+ }
+ }
+
+ cEventBlock::LastTitle="block_dummy_title2";
}
return NULL;
}
@@ -104,27 +135,76 @@ bool cPluginBlock::SetupParse(const char *Name, const char *Value)
void cPluginBlock::MainThreadHook()
{
+
if (cSetupBlock::DetectionMethod!=1) return;//other detection method active in setup
- channelnumber=cDevice::PrimaryDevice()->CurrentChannel();
- if (channelnumber==0) return; //switch in progress
+ if (cEventBlock::ReplayingRecording) //no block events on the underlying channel processed - user watches recording
+ {
+#ifdef LOGGING
+ if (!temp_replaying_recording)
+ {
+ temp_replaying_recording=true;
+ dsyslog("plugin-block: doing nothing because user watches recording");
+ }
+#endif
+ return;
+ }
+#ifdef LOGGING
+ else
+ {
+ if (temp_replaying_recording)
+ {
+ temp_replaying_recording=false;
+ dsyslog("plugin-block: replay of recording ended. Resuming detection mode.");
+ }
+ return;
+ }
+#endif
+
+ channelnumber=cDevice::PrimaryDevice()->CurrentChannel();
+ if (channelnumber==0)
+ {
+#ifdef LOGGING
+ dsyslog("plugin-block: Channel number is 0 => Channel switch on primary device");
+#endif
+ return; //switch in progress
+ }
const cChannel *channel=Channels.GetByNumber(channelnumber);
if (channel != NULL && !channel->GroupSep())
{
+#ifdef LOGGING
+ char *temp_string;
+ asprintf(&temp_string,"channel: %d channel->GroupSep(): %d", channel->Number(), channel->GroupSep());
+ if (strcmp(temp_string,channel_groupsep_string)!=0)
+ {
+ dsyslog("plugin-block: %s",temp_string);
+ channel_groupsep_string=temp_string;
+ }
+#endif
cSchedulesLock schedLock;
const cSchedules *scheds = cSchedules::Schedules(schedLock);
if (scheds == NULL)
{
+#ifdef LOGGING
+ dsyslog("plugin-block: doing nothing because scheds==NULL");
+#endif
return;
}
const cSchedule *sched = scheds->GetSchedule(channel->GetChannelID());
if (sched == NULL)
{
- return;
+ char *dummy;
+ asprintf(&dummy, "%jd", (intmax_t)time_ms());
+ dsyslog("plugin-block: no EPG data - using dummy for LastTitle: %s",dummy);
+ cEventBlock::LastTitle=(char*)dummy;
+#ifdef LOGGING
+ dsyslog("plugin-block: doing nothing because sched==NULL");
+#endif
+ return;
}
const cEvent *present = sched->GetPresentEvent();
@@ -132,20 +212,46 @@ void cPluginBlock::MainThreadHook()
if (present == NULL)
{
+#ifdef LOGGING
+ dsyslog("plugin-block: doing nothing because present==NULL");
+#endif
return;
}
//TODO: check if isrequested is still necessary
// if (!cControlBlock::IsRequested() && !EventsBlock.Acceptable(present->Title()))
const char* title=present->Title();
- if (strcmp(title,temptitle)==0) return; //current show has already been checked
- temptitle=(char*)title;
+ if (strcmp(title,"")==0)
+ {
+ char *dummy;
+ asprintf(&dummy, "%jd", (intmax_t)time_ms());
+ dsyslog("plugin-block: no current EPG title - using dummy for LastTitle: %s",title);
+ }
+
+ if (strcmp(title,cEventBlock::LastTitle)==0)
+ {
+#ifdef LOGGING
+ char *temp_string;
+ asprintf(&temp_string, "'%s' has already been checked",title);
+ if (strcmp(temp_string,has_been_checked_string)!=0)
+ {
+ dsyslog("plugin-block: %s",temp_string);
+ has_been_checked_string=temp_string;
+ }
+#endif
+ return; //current show has already been checked
+ }
+#ifdef LOGGING
+ dsyslog("plugin-block: new EPG title detected: '%s' - comparing with '%s'",title, cEventBlock::LastTitle);
+#endif
+ cEventBlock::LastTitle=(char*)title;
if (!EventsBlock.Acceptable(title))
{
- isyslog("plugin-block: channel %d blocked", channelnumber);
- cControl::Launch(new cControlBlock(channel, present, follow));
+ isyslog("plugin-block: channel %d blocked", channelnumber);
+ cControl::Launch(new cControlBlock(channel, present, follow));
}
}
+
}
/*