From ce4a004a3a0011b99b6f82f4144db1e0a6b1cd30 Mon Sep 17 00:00:00 2001 From: Midas Date: Wed, 2 Jun 2010 21:14:58 +0200 Subject: Added a new detection method. If the next show on the current channel is blocked the plugin will switch to another channel as soon as the next show begins. Strange behaviour could occur, if the station does not accurately update its EPG. Therefore you can still choose the old detection method (On Switch) in the plugins setup, which is also the default. --- block.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++-- config.c | 4 +++- config.h | 3 ++- control.c | 4 +++- i18n.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ po/de_DE.po | 11 ++++++++- setup.c | 8 ++++++- setup.h | 1 + status.c | 47 ++++++++++++++++++++------------------ 9 files changed, 190 insertions(+), 29 deletions(-) diff --git a/block.c b/block.c index 2634d9d..1734bdd 100644 --- a/block.c +++ b/block.c @@ -16,14 +16,20 @@ #include "setup.h" #include "config.h" #include "i18n.h" +#include "control.h" -static const char *VERSION = "0.0.1b+bf1"; +static const char *VERSION = "0.0.2rc1"; static const char *DESCRIPTION = trNOOP("Block unwanted shows by EPG title"); static const char *MAINMENUENTRY = trNOOP("Block broadcast"); +static int channelnumber=0; +static char *temptitle=NULL; + + class cPluginBlock : public cPlugin { private: cStatusBlock *mStatus; + int mLastChannel; public: cPluginBlock(void); @@ -36,12 +42,15 @@ public: virtual cOsdObject *MainMenuAction(void); virtual cMenuSetupPage *SetupMenu(void); virtual bool SetupParse(const char *Name, const char *Value); + virtual void MainThreadHook(void); }; cPluginBlock::cPluginBlock(void): cPlugin(), - mStatus(NULL) + mStatus(NULL), + mLastChannel(0) { + temptitle=""; } cPluginBlock::~cPluginBlock() @@ -93,4 +102,57 @@ bool cPluginBlock::SetupParse(const char *Name, const char *Value) return SetupBlock.Parse(Name, Value); } +void cPluginBlock::MainThreadHook() +{ + if (SetupBlock.DetectionMethod!=1) return;//other detection method active in setup + channelnumber=cDevice::PrimaryDevice()->CurrentChannel(); + if (mLastChannel==0) + { + mLastChannel=channelnumber; + } + + const cChannel *channel=Channels.GetByNumber(channelnumber); + + if (channel != NULL && !channel->GroupSep()) + { + cSchedulesLock schedLock; + const cSchedules *scheds = cSchedules::Schedules(schedLock); + + if (scheds == NULL) + { + return; + } + + const cSchedule *sched = scheds->GetSchedule(channel->GetChannelID()); + if (sched == NULL) + { + return; + } + + const cEvent *present = sched->GetPresentEvent(); + const cEvent *follow = sched->GetFollowingEvent(); + + if (present == NULL) + { + return; + } + + //TODO: check if isrequested is still necessary +// if (!cControlBlock::IsRequested() && !EventsBlock.Acceptable(present->Title())) + const char* title=present->Title(); +// dsyslog("plugin-block-DEV: comparing '%s' with '%s'.",title,temptitle); + if (strcmp(title,temptitle)==0) return; //current show has already been checked + temptitle=(char*)title; + if (!EventsBlock.Acceptable(title)) + { + isyslog("plugin-block: channel %d is not acceptable at present", channelnumber); + cControl::Launch(new cControlBlock(mLastChannel, channel, present, follow)); + mLastChannel=0; + } + } +} + + + + VDRPLUGINCREATOR(cPluginBlock); // Don't touch this! diff --git a/config.c b/config.c index 3b0a6f5..9a3a4a9 100644 --- a/config.c +++ b/config.c @@ -14,7 +14,8 @@ cSetupBlock SetupBlock; cSetupBlock::cSetupBlock(void): HideMenuEntry(0), - MessageTimeout(2) + MessageTimeout(2), + DetectionMethod(0) { } @@ -22,6 +23,7 @@ bool cSetupBlock::Parse(const char *Name, const char *Value) { if (strcmp(Name, "HideMenuEntry") == 0) HideMenuEntry = atoi(Value); else if (strcmp(Name, "MessageTimeout") == 0) MessageTimeout = atoi(Value); + else if (strcmp(Name, "DetectionMethod") == 0) DetectionMethod = atoi(Value); else return false; return true; } diff --git a/config.h b/config.h index 5273220..76e7903 100644 --- a/config.h +++ b/config.h @@ -12,7 +12,8 @@ class cSetupBlock { public: int HideMenuEntry; int MessageTimeout; - + int DetectionMethod; + cSetupBlock(void); bool Parse(const char *Name, const char *Value); }; diff --git a/control.c b/control.c index d6acd7e..4974888 100644 --- a/control.c +++ b/control.c @@ -30,7 +30,8 @@ cControlBlock::cControlBlock(int LastChannel, const cChannel *Channel, const cEv #else needsFastResponse = true; #endif - cRemote::Put(kOk, true); // Hide OSD + + cRemote::Put(kBack,true); //Hide OSD new version } cControlBlock::~cControlBlock() @@ -63,6 +64,7 @@ cControlBlock::~cControlBlock() direction = 1; if (!cDevice::SwitchChannel(direction) && (mLastChannel != 0)) Channels.SwitchTo(mLastChannel); + } } diff --git a/i18n.c b/i18n.c index f2e5496..a2f4302 100644 --- a/i18n.c +++ b/i18n.c @@ -153,6 +153,81 @@ const tI18nPhrase Phrases[] = { #if VDRVERSNUM >= 10313 "", #endif +#if VDRVERSNUM >= 10316 + "", +#endif + }, + { "Detection Method", + "Methode", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", +#if VDRVERSNUM >= 10313 + "", +#endif +#if VDRVERSNUM >= 10316 + "", +#endif + }, + { "On Switch", + "Beim Umschalten", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", +#if VDRVERSNUM >= 10313 + "", +#endif +#if VDRVERSNUM >= 10316 + "", +#endif + }, + { "Channel EPG", + "Kanal EPG", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", +#if VDRVERSNUM >= 10313 + "", +#endif #if VDRVERSNUM >= 10316 "", #endif diff --git a/po/de_DE.po b/po/de_DE.po index de5f09a..89c897e 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: VDR 1.5.7\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-04-27 14:26+0200\n" +"POT-Creation-Date: 2010-06-02 19:00+0200\n" "PO-Revision-Date: 2010-04-27 14:19+0200\n" "Last-Translator: Klaus Schmidinger \n" "Language-Team: \n" @@ -33,6 +33,15 @@ msgstr "Hauptmen msgid "Message Timeout [s]" msgstr "Wartezeit bis Umschalten [s]" +msgid "On Switch" +msgstr "" + +msgid "Channel EPG" +msgstr "" + +msgid "Detection Method" +msgstr "" + msgid "--- Keywords -------------------------------------------------------------------" msgstr "--- Schlagworte ----------------------------------------------------------------" diff --git a/setup.c b/setup.c index 4f48739..42a4eb6 100644 --- a/setup.c +++ b/setup.c @@ -26,6 +26,11 @@ void cMenuSetupBlock::Set(void) { Add(new cMenuEditBoolItem(tr("Hide Mainmenu Entry"), &mSetupData.HideMenuEntry)); Add(new cMenuEditIntItem(tr("Message Timeout [s]"), &mSetupData.MessageTimeout, 0, 10)); + DetectionMethods[0] = tr("On Switch"); + DetectionMethods[1] = tr("Channel EPG"); + + Add(new cMenuEditStraItem(tr("Detection Method"), &mSetupData.DetectionMethod, 2, DetectionMethods)); + item = new cOsdItem(""); item->SetSelectable(false); Add(item); @@ -34,7 +39,7 @@ void cMenuSetupBlock::Set(void) { item->SetSelectable(false); Add(item); -#define NONKEYWORDITEMS 4 +#define NONKEYWORDITEMS 5 int index = 0; cEventBlock *event = mEventsData.First(); @@ -71,6 +76,7 @@ void cMenuSetupBlock::Store(void) SetupBlock = mSetupData; SetupStore("HideMenuEntry", SetupBlock.HideMenuEntry); SetupStore("MessageTimeout", SetupBlock.MessageTimeout); + SetupStore("DetectionMethod", SetupBlock.DetectionMethod); } eOSState cMenuSetupBlock::Edit(void) diff --git a/setup.h b/setup.h index 1bbc7c6..459fca0 100644 --- a/setup.h +++ b/setup.h @@ -17,6 +17,7 @@ class cMenuSetupBlock : public cMenuSetupPage { private: cEventsBlock mEventsData; cSetupBlock mSetupData; + const char *DetectionMethods[2]; protected: virtual void Store(void); diff --git a/status.c b/status.c index 64b9d85..9ec44d1 100644 --- a/status.c +++ b/status.c @@ -10,6 +10,7 @@ #include "status.h" #include "control.h" #include "event.h" +#include "config.h" cStatusBlock::cStatusBlock(void): cStatus(), @@ -19,7 +20,12 @@ cStatusBlock::cStatusBlock(void): void cStatusBlock::ChannelSwitch(const cDevice *Device, int ChannelNumber) { - printf("cStatusBlock::ChannelSwitch(%p, %d)\n", Device, ChannelNumber); + if (SetupBlock.DetectionMethod!=0) + { +// dsyslog("plugin-block-DEV: StatusBlock::ChannelSwitch did nothing: Detection Method didn't match"); + return; + } + //printf("cStatusBlock::ChannelSwitch(%p, %d)\n", Device, ChannelNumber); #ifdef LOGGING dsyslog("plugin-block: cStatusBlock was informed about channel switch at device %d, channel no %d",Device->DeviceNumber(),ChannelNumber); @@ -75,29 +81,26 @@ void cStatusBlock::ChannelSwitch(const cDevice *Device, int ChannelNumber) return; } - const cChannel *channel = Channels.GetByNumber(ChannelNumber); - if (channel != NULL && !channel->GroupSep()) { - cSchedulesLock schedLock; - const cSchedules *scheds = cSchedules::Schedules(schedLock); - if (scheds == NULL) - return; + const cChannel *channel = Channels.GetByNumber(ChannelNumber); + if (channel != NULL && !channel->GroupSep()) + { + cSchedulesLock schedLock; + const cSchedules *scheds = cSchedules::Schedules(schedLock); + if (scheds == NULL) return; - const cSchedule *sched = scheds->GetSchedule(channel->GetChannelID()); - if (sched == NULL) - return; + const cSchedule *sched = scheds->GetSchedule(channel->GetChannelID()); + if (sched == NULL) return; - const cEvent *present = sched->GetPresentEvent(); - const cEvent *follow = sched->GetFollowingEvent(); - if (present == NULL) - return; + const cEvent *present = sched->GetPresentEvent(); + const cEvent *follow = sched->GetFollowingEvent(); + if (present == NULL) return; - if (!cControlBlock::IsRequested() && !EventsBlock.Acceptable(present->Title())) { - isyslog("plugin-block: channel %d is not acceptable at present", ChannelNumber); - cControl::Launch(new cControlBlock(mLastChannel, channel, present, follow)); - mLastChannel=0; - } - } - - + if (!cControlBlock::IsRequested() && !EventsBlock.Acceptable(present->Title())) + { + isyslog("plugin-block: channel %d is not acceptable at present", ChannelNumber); + cControl::Launch(new cControlBlock(mLastChannel, channel, present, follow)); + mLastChannel=0; + } + } } -- cgit v1.2.3