/* * tvm2vdr.c: TVM2VDR plugin for the Video Disk Recorder * * See the README file for copyright information and how to reach the author. * */ #include "config.h" #include "update.h" #include "tvm2vdr.h" #if defined (APIVERSNUM) && (APIVERSNUM < 10600) # error VDR API versions < 1.6.0 are not supported ! #endif static const char* DESCRIPTION = trNOOP("Tvm2vdr EPG-Data from tvmovie"); static const char* MAINMENUENTRY = tr("tv movie"); cUpdate* oUpdate; //*************************************************************************** // cPluginTVM2VDR //*************************************************************************** class cPluginTVM2VDR : public cPlugin { public: cPluginTVM2VDR(void); virtual ~cPluginTVM2VDR(); virtual const char* Version(void) { return VERSION; } virtual const char* VersionDate(void) { return VERSION_DATE; } virtual const char* Description(void) { return tr(DESCRIPTION); } virtual const char* CommandLineHelp(void); virtual const char** SVDRPHelpPages(void); virtual cString SVDRPCommand(const char* Cmd, const char* Option, int& ReplyCode); virtual bool Start(void); virtual cString Active(void); virtual const char* MainMenuEntry(void) { return TVM2VDRConfig.mainmenuVisible ? MAINMENUENTRY : 0; } virtual cOsdObject* MainMenuAction(void); virtual cMenuSetupPage* SetupMenu(void); virtual bool SetupParse(const char* Name, const char* Value); virtual void Stop(); void DisplayMessage(const char* s); private: // ... }; //*************************************************************************** // cMenuSetupTVM2VDR //*************************************************************************** class cMenuSetupTVM2VDR : public cMenuSetupPage { private: cTVM2VDRConfig data; virtual void Setup(void); const char* EpgImageSizeItems[3]; protected: virtual eOSState ProcessKey(eKeys Key); virtual void Store(void); public: cMenuSetupTVM2VDR(void); }; //*************************************************************************** // Plugins Main Menu //*************************************************************************** class cTvmMenu : public cOsdMenu { public: cTvmMenu(const char* title, cPluginTVM2VDR* aPlugin); virtual ~cTvmMenu() { }; virtual eOSState ProcessKey(eKeys key); protected: cPluginTVM2VDR* plugin; }; cTvmMenu::cTvmMenu(const char* title, cPluginTVM2VDR* aPlugin) : cOsdMenu(title) { plugin = aPlugin; Clear(); cOsdMenu::Add(new cOsdItem(tr("Reload"))); cOsdMenu::Add(new cOsdItem(tr("Update"))); cOsdMenu::Add(new cOsdItem(tr("Fullupdate"))); SetHelp(0, 0, 0,0); Display(); } //*************************************************************************** // Process Key //*************************************************************************** eOSState cTvmMenu::ProcessKey(eKeys key) { eOSState state = cOsdMenu::ProcessKey(key); if (state != osUnknown) return state; switch (key) { case kOk: { if (Current() == 0) { Skins.Message(mtInfo, tr("refresh EPG")); oUpdate->triggerUpdate(false, true); } else if (Current() == 1) { Skins.Message(mtInfo, tr("Update EPG")); oUpdate->triggerUpdate(); } else if (Current() == 2) { Skins.Message(mtInfo, tr("Full-Update EPG")); oUpdate->triggerUpdate(true); } return osEnd; } default: break; } return state; } //*************************************************************************** // //*************************************************************************** cMenuSetupTVM2VDR::cMenuSetupTVM2VDR(void) { data = TVM2VDRConfig; EpgImageSizeItems[0] = "174x130"; // http://wwwa.tvmovie.de/imageTransfer/XL%s.jpg EpgImageSizeItems[1] = "329x245"; // http://wwwa.tvmovie.de/imageTransfer/XXL%s.jpg EpgImageSizeItems[2] = "525x400"; // http://img.tvmovie.de/imageTransfer/F1_%s.jpg Setup(); } void cMenuSetupTVM2VDR::Setup(void) { char* buf; int current = Current(); Clear(); asprintf(&buf, "-------------------- %s ----------------------------------", tr("EPG Update")); Add(new cOsdItem(buf)); free(buf); cList::Last()->SetSelectable(false); Add(new cMenuEditBoolItem(tr("Auto Update"), &data.autoupdate)); Add(new cMenuEditIntItem(tr("Updatetime (hours)"), &data.updatetime)); Add(new cMenuEditIntItem(tr("Days in advance"), &data.days)); Add(new cMenuEditIntItem(tr("Days to update"), &data.upddays)); Add(new cMenuEditBoolItem(tr("Show In Main Menu"), &data.mainmenuVisible)); Add(new cMenuEditBoolItem(tr("Menu Action start Fullupdate"), &data.mainmenuFullupdate)); asprintf(&buf, "--------------------- %s ---------------------------------", tr("EPG Images")); Add(new cOsdItem(buf)); free(buf); cList::Last()->SetSelectable(false); Add(new cMenuEditBoolItem(tr("Get EPG images"), &data.getepgimages)); Add(new cMenuEditIntItem(tr("Max. images per event"), &data.maximagesperevent)); Add(new cMenuEditStraItem(tr("Download EPG images in"), &data.epgImageSize, 3, EpgImageSizeItems)); asprintf(&buf, "--------------------- %s ---------------------------------", tr("Constabel Eplists")); Add(new cOsdItem(buf)); free(buf); cList::Last()->SetSelectable(false); Add(new cMenuEditBoolItem(tr("Load an evaluate eplists from constable"), &data.seriesEnabled)); Add(new cMenuEditStrItem(tr("Constabel URL"), data.seriesUrl, sizeof(data.seriesUrl), tr(FileNameChars))); Add(new cMenuEditIntItem(tr("Constabel port (default 2006)"), &data.seriesPort)); Add(new cMenuEditBoolItem(tr("Store eplist-files to disk"), &data.storeSeriesToFs)); asprintf(&buf, "--------------------- %s ---------------------------------", tr("NO EPG")); Add(new cOsdItem(buf)); free(buf); Add(new cMenuEditBoolItem(tr("blacklist not configured channels"), &data.blacklist)); asprintf(&buf, "--------------------- %s ---------------------------------", tr("Technical Stuff")); Add(new cOsdItem(buf)); free(buf); cList::Last()->SetSelectable(false); Add(new cOsdItem(tr("Reload Channel/VPS maps"), osUser9)); Add(new cMenuEditIntItem(tr("Log level"), &data.loglevel, 0, 3)); Add(new cMenuEditBoolItem(tr("Use HTTP Proxy"), &data.useproxy)); if (data.useproxy) { Add(new cMenuEditStrItem(tr(" HTTP Proxy"), data.httpproxy, sizeof(data.httpproxy), tr(FileNameChars))); Add(new cMenuEditStrItem(tr("Proxy User Name"), data.username, sizeof(data.username), tr(FileNameChars))); Add(new cMenuEditStrItem(tr("Proxy Password"), data.password, sizeof(data.password), tr(FileNameChars))); } SetCurrent(Get(current)); Display(); } eOSState cMenuSetupTVM2VDR::ProcessKey(eKeys Key) { eOSState state = cMenuSetupPage::ProcessKey(Key); int olduseproxy = data.useproxy; switch (state) { case osUser9: { state = osContinue; if (Interface->Confirm(tr("Really reload Channel/VPS maps?"))) { oUpdate->reloadMaps(); state = osEnd; } break; } case osContinue: { if (NORMALKEY(Key) == kUp || NORMALKEY(Key) == kDown) { cOsdItem* item = Get(Current()); if (item) item->ProcessKey(kNone); } break; } default: break; } if (Key != kNone && data.useproxy != olduseproxy) Setup(); return state; } void cMenuSetupTVM2VDR::Store(void) { int updatetime = TVM2VDRConfig.updatetime; int autoupdate = TVM2VDRConfig.autoupdate; TVM2VDRConfig = data; SetupStore("UserName", TVM2VDRConfig.username); SetupStore("Password", TVM2VDRConfig.password); SetupStore("UseProxy", TVM2VDRConfig.useproxy); SetupStore("HTTPProxy", TVM2VDRConfig.httpproxy); SetupStore("LogLevel", TVM2VDRConfig.loglevel); SetupStore("AutoUpdate", TVM2VDRConfig.autoupdate); SetupStore("UpdateTime", TVM2VDRConfig.updatetime); SetupStore("DaysInAdvance", TVM2VDRConfig.days); SetupStore("DaysToUpdate", TVM2VDRConfig.upddays); SetupStore("ShowInMainMenu", TVM2VDRConfig.mainmenuVisible); SetupStore("MainmenuFullupdate", TVM2VDRConfig.mainmenuFullupdate); SetupStore("GetEPGImages", TVM2VDRConfig.getepgimages); SetupStore("MaxImagesPerEvent", TVM2VDRConfig.maximagesperevent); SetupStore("EpgImageSize", TVM2VDRConfig.epgImageSize); SetupStore("SeriesUrl", TVM2VDRConfig.seriesUrl); SetupStore("SeriesPort", TVM2VDRConfig.seriesPort); SetupStore("SeriesStoreToFs", TVM2VDRConfig.storeSeriesToFs); SetupStore("SeriesEnabled", TVM2VDRConfig.seriesEnabled); SetupStore("Blacklist", TVM2VDRConfig.blacklist); // update thread steering oUpdate->loglevel = TVM2VDRConfig.loglevel; if (updatetime != TVM2VDRConfig.updatetime || autoupdate != TVM2VDRConfig.autoupdate) { oUpdate->scheduleAutoUpdate(); } } //*************************************************************************** // Plugin - TVM2VDR //*************************************************************************** cPluginTVM2VDR::cPluginTVM2VDR(void) { oUpdate = 0; } cPluginTVM2VDR::~cPluginTVM2VDR() { delete oUpdate; } void cPluginTVM2VDR::DisplayMessage(const char *s) { tell(0, "TVM2VDR: %s", s); Skins.Message(mtInfo, tr(s)); sleep(Setup.OSDMessageTime); } const char *cPluginTVM2VDR::CommandLineHelp(void) { return 0; } const char **cPluginTVM2VDR::SVDRPHelpPages(void) { static const char *HelpPages[] = { "LOADXSLT\n" " (Re)loads the XSLT files.", "RELOAD\n" " Reloads the channel/vps map configuration files.", "UPDATE\n" " Download new/cahnged TVM files and update the EPG.", "FULLUPDATE\n" " Download all TVM files and update the EPG, even the already applied files.", "REFRESH\n" " Reload all TVM events from database to EPG without download", 0 }; return HelpPages; } cString cPluginTVM2VDR::SVDRPCommand(const char *Cmd, const char *Option, int &ReplyCode) { if (strcasecmp(Cmd, "LOADXSLT") == 0) { oUpdate->loadXSLT(); return "XSLT files reloaded."; } else if (strcasecmp(Cmd, "RELOAD") == 0) { oUpdate->reloadMaps(); return "Channel/VPS maps reloaded."; } else if (strcasecmp(Cmd, "UPDATE") == 0) { oUpdate->triggerUpdate(); return "TVM2VDR update started."; } else if (strcasecmp(Cmd, "FULLUPDATE") == 0) { oUpdate->triggerUpdate(true); return "TVM2VDR full update started."; } else if (strcasecmp(Cmd, "REFRESH") == 0) { oUpdate->triggerUpdate(false, true); return "TVM2VDR refresh started."; } return 0; } //*************************************************************************** // Start //*************************************************************************** bool cPluginTVM2VDR::Start(void) { // Start any background activities the plugin shall perform. oUpdate = new cUpdate(); oUpdate->loglevel = TVM2VDRConfig.loglevel; // start thread oUpdate->Start(); // on autoupdate we trigger it at first 60 seconds after startup if (TVM2VDRConfig.autoupdate) oUpdate->scheduleAutoUpdate(60); return true; } cString cPluginTVM2VDR::Active(void) { if (oUpdate->isUpdateActive()) return tr("TVM2VDR EPG update running"); return 0; } cOsdObject *cPluginTVM2VDR::MainMenuAction(void) { return new cTvmMenu(MAINMENUENTRY, this); } cMenuSetupPage *cPluginTVM2VDR::SetupMenu(void) { return new cMenuSetupTVM2VDR; } bool cPluginTVM2VDR::SetupParse(const char *Name, const char *Value) { // Parse your own setup parameters and store their values. if (!strcasecmp(Name, "UserName")) strcpy(TVM2VDRConfig.username, Value); else if (!strcasecmp(Name, "Password")) strcpy(TVM2VDRConfig.password, Value); else if (!strcasecmp(Name, "UseProxy")) TVM2VDRConfig.useproxy = atoi(Value); else if (!strcasecmp(Name, "HTTPProxy")) strcpy(TVM2VDRConfig.httpproxy, Value); else if (!strcasecmp(Name, "LogLevel")) TVM2VDRConfig.loglevel = atoi(Value); else if (!strcasecmp(Name, "AutoUpdate")) TVM2VDRConfig.autoupdate = atoi(Value); else if (!strcasecmp(Name, "UpdateTime")) TVM2VDRConfig.updatetime = atoi(Value); else if (!strcasecmp(Name, "DaysInAdvance")) TVM2VDRConfig.days = atoi(Value); else if (!strcasecmp(Name, "DaysToUpdate")) TVM2VDRConfig.upddays = atoi(Value); else if (!strcasecmp(Name, "ShowInMainMenu")) TVM2VDRConfig.mainmenuVisible = atoi(Value); else if (!strcasecmp(Name, "MainmenuFullupdate")) TVM2VDRConfig.mainmenuFullupdate = atoi(Value); else if (!strcasecmp(Name, "GetEPGImages")) TVM2VDRConfig.getepgimages = atoi(Value); else if (!strcasecmp(Name, "MaxImagesPerEvent")) TVM2VDRConfig.maximagesperevent = atoi(Value); else if (!strcasecmp(Name, "EpgImageSize")) TVM2VDRConfig.epgImageSize = atoi(Value); else if (!strcasecmp(Name, "SeriesUrl")) strcpy(TVM2VDRConfig.seriesUrl, Value); else if (!strcasecmp(Name, "SeriesEnabled")) TVM2VDRConfig.seriesEnabled = atoi(Value); else if (!strcasecmp(Name, "Blacklist")) TVM2VDRConfig.blacklist = atoi(Value); else if (!strcasecmp(Name, "SeriesPort")) TVM2VDRConfig.seriesPort = atoi(Value); else if (!strcasecmp(Name, "SeriesStoreToFs")) TVM2VDRConfig.storeSeriesToFs = atoi(Value); else return false; return true; } void cPluginTVM2VDR::Stop() { oUpdate->Stop(); } //*************************************************************************** VDRPLUGINCREATOR(cPluginTVM2VDR); // Don't touch this!