1.1 --- a/premiereepg.c Sat Dec 29 11:17:41 2007 +0100
1.2 +++ b/premiereepg.c Sat Dec 29 11:18:14 2007 +0100
1.3 @@ -28,6 +28,7 @@
1.4 #include <vdr/epg.h>
1.5 #include <vdr/channels.h>
1.6 #include <vdr/dvbdevice.h>
1.7 +#include <vdr/i18n.h>
1.8 #include <libsi/section.h>
1.9 #include <libsi/descriptor.h>
1.10
1.11 @@ -48,8 +49,124 @@
1.12 #define PMT_SCAN_TIMEOUT 10 // seconds
1.13 #define PMT_SCAN_IDLE 300 // seconds
1.14
1.15 -static const char *VERSION = "0.0.1";
1.16 -static const char *DESCRIPTION = "Parse extended Premiere EPG data";
1.17 +static const char *VERSION = "0.0.2";
1.18 +static const char *DESCRIPTION = "Parses extended Premiere EPG data";
1.19 +
1.20 +// --- cSetupPremiereEpg -------------------------------------------------------
1.21 +
1.22 +const char *optPats[] = {
1.23 + "%s",
1.24 + "%s (Option %d)",
1.25 + "%s (O%d)",
1.26 + "#%2$d %1$s",
1.27 + "[%2$d] %1$s"
1.28 + };
1.29 +#define NUM_PATS (sizeof(optPats)/sizeof(char *))
1.30 +
1.31 +class cSetupPremiereEpg {
1.32 +public:
1.33 + int OptPat;
1.34 +public:
1.35 + cSetupPremiereEpg(void);
1.36 + };
1.37 +
1.38 +cSetupPremiereEpg SetupPE;
1.39 +
1.40 +cSetupPremiereEpg::cSetupPremiereEpg(void)
1.41 +{
1.42 + OptPat=1;
1.43 +}
1.44 +
1.45 +// --- i18n --------------------------------------------------------------------
1.46 +
1.47 +const tI18nPhrase Phrases[] = {
1.48 +/*
1.49 +*/
1.50 + { "PremiereEPG",
1.51 + "PremiereEPG",
1.52 + "", // TODO
1.53 + "", // TODO
1.54 + "", // TODO
1.55 + "", // TODO
1.56 + "", // TODO
1.57 + "", // TODO
1.58 + "", // TODO
1.59 + "", // TODO
1.60 + "", // TODO
1.61 + "", // TODO
1.62 + "", // TODO
1.63 + "", // TODO
1.64 + "", // TODO
1.65 + "", // TODO
1.66 + },
1.67 + { "Parses extended Premiere EPG data",
1.68 + "Liest erweiterte Premiere EPG Daten ein",
1.69 + "", // TODO
1.70 + "", // TODO
1.71 + "", // TODO
1.72 + "", // TODO
1.73 + "", // TODO
1.74 + "", // TODO
1.75 + "", // TODO
1.76 + "", // TODO
1.77 + "", // TODO
1.78 + "", // TODO
1.79 + "", // TODO
1.80 + "", // TODO
1.81 + "", // TODO
1.82 + "", // TODO
1.83 + },
1.84 + { "Tag option events",
1.85 + "Options Events markieren",
1.86 + "", // TODO
1.87 + "", // TODO
1.88 + "", // TODO
1.89 + "", // TODO
1.90 + "", // TODO
1.91 + "", // TODO
1.92 + "", // TODO
1.93 + "", // TODO
1.94 + "", // TODO
1.95 + "", // TODO
1.96 + "", // TODO
1.97 + "", // TODO
1.98 + "", // TODO
1.99 + "", // TODO
1.100 + },
1.101 +
1.102 + { NULL }
1.103 + };
1.104 +
1.105 +// --- cMenuSetupPremiereEpg ------------------------------------------------------------
1.106 +
1.107 +class cMenuSetupPremiereEpg : public cMenuSetupPage {
1.108 +private:
1.109 + cSetupPremiereEpg data;
1.110 + const char *optDisp[NUM_PATS];
1.111 + char buff[NUM_PATS][32];
1.112 +protected:
1.113 + virtual void Store(void);
1.114 +public:
1.115 + cMenuSetupPremiereEpg(void);
1.116 + };
1.117 +
1.118 +cMenuSetupPremiereEpg::cMenuSetupPremiereEpg(void)
1.119 +{
1.120 + data=SetupPE;
1.121 + SetSection(tr("PremiereEPG"));
1.122 + optDisp[0]=tr("off");
1.123 + for(unsigned int i=1; i<NUM_PATS; i++) {
1.124 + snprintf(buff[i],sizeof(buff[i]),optPats[i],"Event",1);
1.125 + optDisp[i]=buff[i];
1.126 + }
1.127 + Add(new cMenuEditStraItem(tr("Tag option events"),&data.OptPat,NUM_PATS,optDisp));
1.128 +}
1.129 +
1.130 +void cMenuSetupPremiereEpg::Store(void)
1.131 +{
1.132 + SetupPE=data;
1.133 + SetupStore("OptionPattern",SetupPE.OptPat);
1.134 +}
1.135
1.136 // --- CIT ---------------------------------------------------------------------
1.137
1.138 @@ -90,11 +207,11 @@
1.139 u_char duration_m :8;
1.140 u_char duration_s :8;
1.141 #if BYTE_ORDER == BIG_ENDIAN
1.142 - u_char reserved :4;
1.143 + u_char :4;
1.144 u_char descriptors_loop_length_hi :4;
1.145 #else
1.146 u_char descriptors_loop_length_hi :4;
1.147 - u_char reserved :4;
1.148 + u_char :4;
1.149 #endif
1.150 u_char descriptors_loop_length_lo :8;
1.151 };
1.152 @@ -383,11 +500,17 @@
1.153 continue;
1.154 }
1.155
1.156 + bool newEvent=false;
1.157 cEvent *pEvent=(cEvent *)pSchedule->GetEvent(EventId,StartTime);
1.158 if(!pEvent) {
1.159 d2(printf("(new)\n"))
1.160 - pEvent=pSchedule->AddEvent(new cEvent(channelID,EventId));
1.161 +#if VDRVERSNUM >= 10325
1.162 + pEvent=new cEvent(EventId);
1.163 +#else
1.164 + pEvent=new cEvent(channelID,EventId);
1.165 +#endif
1.166 if(!pEvent) continue;
1.167 + newEvent=true;
1.168 }
1.169 else {
1.170 d2(printf("(upd)\n"))
1.171 @@ -402,14 +525,15 @@
1.172 pEvent->SetDuration(cit.getDuration());
1.173
1.174 if(ShortEventDescriptor) {
1.175 - char buffer[256+32];
1.176 - ShortEventDescriptor->name.getText(buffer,sizeof(buffer)-32);
1.177 + char buffer[256];
1.178 + ShortEventDescriptor->name.getText(buffer,sizeof(buffer));
1.179 if(isOpt) {
1.180 - char o[32];
1.181 - snprintf(o,sizeof(o)," (Option %d)",optCount);
1.182 - strcat(buffer,o);
1.183 + char buffer2[sizeof(buffer)+32];
1.184 + snprintf(buffer2,sizeof(buffer2),optPats[SetupPE.OptPat],buffer,optCount);
1.185 + pEvent->SetTitle(buffer2);
1.186 }
1.187 - pEvent->SetTitle(buffer);
1.188 + else
1.189 + pEvent->SetTitle(buffer);
1.190 pEvent->SetShortText(ShortEventDescriptor->text.getText(buffer,sizeof(buffer)));
1.191 }
1.192 if(ExtendedEventDescriptors) {
1.193 @@ -417,6 +541,7 @@
1.194 pEvent->SetDescription(ExtendedEventDescriptors->getText(buffer,sizeof(buffer),": "));
1.195 }
1.196
1.197 + if(newEvent) pSchedule->AddEvent(pEvent);
1.198 pEvent->SetComponents(NULL);
1.199 pEvent->FixEpgBugs();
1.200 Modified=true;
1.201 @@ -446,9 +571,11 @@
1.202 public:
1.203 cPluginPremiereEpg(void);
1.204 virtual const char *Version(void) { return VERSION; }
1.205 - virtual const char *Description(void) { return DESCRIPTION; }
1.206 + virtual const char *Description(void) { return tr(DESCRIPTION); }
1.207 virtual bool Start(void);
1.208 virtual void Stop(void);
1.209 + virtual cMenuSetupPage *SetupMenu(void);
1.210 + virtual bool SetupParse(const char *Name, const char *Value);
1.211 };
1.212
1.213 cPluginPremiereEpg::cPluginPremiereEpg(void)
1.214 @@ -458,6 +585,7 @@
1.215
1.216 bool cPluginPremiereEpg::Start(void)
1.217 {
1.218 + RegisterI18n(Phrases);
1.219 for(int i=0; i<MAXDVBDEVICES; i++) {
1.220 cDevice *dev=cDevice::GetDevice(i);
1.221 if(dev) {
1.222 @@ -480,4 +608,16 @@
1.223 }
1.224 }
1.225
1.226 +cMenuSetupPage *cPluginPremiereEpg::SetupMenu(void)
1.227 +{
1.228 + return new cMenuSetupPremiereEpg;
1.229 +}
1.230 +
1.231 +bool cPluginPremiereEpg::SetupParse(const char *Name, const char *Value)
1.232 +{
1.233 + if (!strcasecmp(Name, "OptionPattern")) SetupPE.OptPat = atoi(Value);
1.234 + else return false;
1.235 + return true;
1.236 +}
1.237 +
1.238 VDRPLUGINCREATOR(cPluginPremiereEpg); // Don't touch this!