vdr-plugin-tvguide/tvguide.c

166 lines
4.3 KiB
C
Raw Normal View History

2013-01-17 13:16:44 +01:00
/*
* tvguide.c: A plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
* $Id$
*/
#include <time.h>
#include <getopt.h>
#include <vdr/osd.h>
#include <vdr/plugin.h>
#include <vdr/device.h>
2013-07-09 00:17:42 +02:00
#include <vdr/menu.h>
#include <Magick++.h>
2013-01-17 13:16:44 +01:00
2013-12-07 15:51:50 +01:00
#define DEFINE_CONFIG 1
2013-12-21 11:25:03 +01:00
#include "geometrymanager.h"
#include "fontmanager.h"
#include "imagecache.h"
2013-12-07 15:51:50 +01:00
#include "config.h"
#include "setup.h"
#include "tvguideosd.h"
2013-01-17 13:16:44 +01:00
2013-05-24 16:23:23 +02:00
#if defined(APIVERSNUM) && APIVERSNUM < 20000
#error "VDR-2.0.0 API version or greater is required!"
2013-01-17 13:16:44 +01:00
#endif
2020-03-04 14:39:55 +01:00
static const char *VERSION = "1.3.0";
2019-04-06 18:09:12 +02:00
static const char *DESCRIPTION = tr("A fancy 2d EPG Viewer");
2013-01-17 13:16:44 +01:00
static const char *MAINMENUENTRY = "Tvguide";
class cPluginTvguide : public cPlugin {
public:
cPluginTvguide(void);
virtual ~cPluginTvguide();
virtual const char *Version(void) { return VERSION; }
2019-04-06 18:09:12 +02:00
virtual const char *Description(void) { return tr(DESCRIPTION); }
2013-01-17 13:16:44 +01:00
virtual const char *CommandLineHelp(void);
virtual bool ProcessArgs(int argc, char *argv[]);
virtual bool Initialize(void);
virtual bool Start(void);
virtual void Stop(void);
virtual void Housekeeping(void);
virtual void MainThreadHook(void);
virtual cString Active(void);
virtual time_t WakeupTime(void);
2019-07-11 11:28:11 +02:00
virtual const char *MainMenuEntry(void) { return (config.showMainMenuEntry) ? MAINMENUENTRY : NULL; }
2013-01-17 13:16:44 +01:00
virtual cOsdObject *MainMenuAction(void);
virtual cMenuSetupPage *SetupMenu(void);
virtual bool SetupParse(const char *Name, const char *Value);
virtual bool Service(const char *Id, void *Data = NULL);
virtual const char **SVDRPHelpPages(void);
virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode);
};
2013-12-21 11:25:03 +01:00
cPluginTvguide::cPluginTvguide(void) {
2013-01-17 13:16:44 +01:00
}
2013-12-21 11:25:03 +01:00
cPluginTvguide::~cPluginTvguide() {
2013-01-17 13:16:44 +01:00
}
2013-12-21 11:25:03 +01:00
const char *cPluginTvguide::CommandLineHelp(void) {
2013-01-17 13:16:44 +01:00
return
" -e <IMAGESDIR>, --epgimages=<IMAGESDIR> Set directory where epgimages are stored.\n"
" -i <ICONDIR>, --iconpath=<ICONDIR> Set directory where icons are stored.\n"
" -l <LOGODIR>, --logopath=<LOGODIR> Set directory where logos are stored.\n";
2013-01-17 13:16:44 +01:00
}
2013-12-21 11:25:03 +01:00
bool cPluginTvguide::ProcessArgs(int argc, char *argv[]) {
2013-01-17 13:16:44 +01:00
static const struct option long_options[] = {
2013-12-21 11:25:03 +01:00
{ "epgimages", required_argument, NULL, 'e' },
{ "iconpath", required_argument, NULL, 'i' },
2013-01-17 13:16:44 +01:00
{ "logopath", required_argument, NULL, 'l' },
{ 0, 0, 0, 0 }
};
int c;
2013-12-21 11:25:03 +01:00
while ((c = getopt_long(argc, argv, "e:i:l:", long_options, NULL)) != -1) {
2013-05-26 11:38:05 +02:00
switch (c) {
2013-12-21 11:25:03 +01:00
case 'e':
2019-07-11 11:28:11 +02:00
config.SetImagesPath(cString(optarg));
2013-01-17 13:16:44 +01:00
break;
2013-12-21 11:25:03 +01:00
case 'i':
2019-07-11 11:28:11 +02:00
config.SetIconsPath(cString(optarg));
2013-12-21 11:25:03 +01:00
break;
2013-01-17 13:16:44 +01:00
case 'l':
2019-07-11 11:28:11 +02:00
config.SetLogoPath(cString(optarg));
2013-01-17 13:16:44 +01:00
break;
default:
return false;
}
}
return true;
}
__attribute__((constructor)) static void init(void) {
Magick::InitializeMagick(NULL);
}
2013-12-07 15:51:50 +01:00
bool cPluginTvguide::Initialize(void) {
2019-07-11 11:28:11 +02:00
config.SetDefaultPathes();
config.LoadTheme();
config.SetStyle();
config.setDynamicValues();
2013-12-21 11:25:03 +01:00
geoManager.SetGeometry(cOsd::OsdWidth(), cOsd::OsdHeight());
fontManager.SetFonts();
imgCache.CreateCache();
2013-12-07 15:51:50 +01:00
return true;
2013-01-17 13:16:44 +01:00
}
2013-12-21 11:25:03 +01:00
bool cPluginTvguide::Start(void) {
2013-05-26 11:38:05 +02:00
return true;
2013-01-17 13:16:44 +01:00
}
2013-12-21 11:25:03 +01:00
void cPluginTvguide::Stop(void) {
2013-01-17 13:16:44 +01:00
}
2013-12-21 11:25:03 +01:00
void cPluginTvguide::Housekeeping(void) {
2013-01-17 13:16:44 +01:00
}
2013-12-21 11:25:03 +01:00
void cPluginTvguide::MainThreadHook(void) {
2013-01-17 13:16:44 +01:00
}
2013-12-21 11:25:03 +01:00
cString cPluginTvguide::Active(void) {
2013-01-17 13:16:44 +01:00
return NULL;
}
2013-12-21 11:25:03 +01:00
time_t cPluginTvguide::WakeupTime(void) {
2013-01-17 13:16:44 +01:00
return 0;
}
2013-12-21 11:25:03 +01:00
cOsdObject *cPluginTvguide::MainMenuAction(void) {
return new cTvGuideOsd;
2013-01-17 13:16:44 +01:00
}
2013-12-21 11:25:03 +01:00
cMenuSetupPage *cPluginTvguide::SetupMenu(void) {
2013-01-17 13:16:44 +01:00
return new cTvguideSetup();
}
2013-12-21 11:25:03 +01:00
bool cPluginTvguide::SetupParse(const char *Name, const char *Value) {
2019-07-11 11:28:11 +02:00
return config.SetupParse(Name, Value);
2013-01-17 13:16:44 +01:00
}
2013-12-21 11:25:03 +01:00
bool cPluginTvguide::Service(const char *Id, void *Data) {
2019-07-11 11:28:11 +02:00
if (strcmp(Id, "MainMenuHooksPatch-v1.0::osSchedule") == 0 && config.replaceOriginalSchedule != 0) {
if (Data == NULL)
return true;
2013-07-12 17:23:16 +02:00
cOsdObject **guide = (cOsdObject**) Data;
if (guide)
*guide = MainMenuAction();
return true;
}
2013-01-17 13:16:44 +01:00
return false;
}
2013-12-21 11:25:03 +01:00
const char **cPluginTvguide::SVDRPHelpPages(void) {
2013-01-17 13:16:44 +01:00
return NULL;
}
2013-12-21 11:25:03 +01:00
cString cPluginTvguide::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode) {
2013-01-17 13:16:44 +01:00
return NULL;
}
2013-12-21 11:25:03 +01:00
VDRPLUGINCREATOR(cPluginTvguide);