premiereepg.c
branchtrunk
changeset 6 b0218bef406f
parent 4 ac6bf154890e
child 8 b5bd55cfd28f
equal deleted inserted replaced
5:48c1f5090868 6:b0218bef406f
    47 #endif
    47 #endif
    48 
    48 
    49 #define PMT_SCAN_TIMEOUT  10  // seconds
    49 #define PMT_SCAN_TIMEOUT  10  // seconds
    50 #define PMT_SCAN_IDLE     300 // seconds
    50 #define PMT_SCAN_IDLE     300 // seconds
    51 
    51 
    52 static const char *VERSION        = "0.0.3";
    52 static const char *VERSION        = "0.0.4";
    53 static const char *DESCRIPTION    = "Parses extended Premiere EPG data";
    53 static const char *DESCRIPTION    = "Parses extended Premiere EPG data";
    54 
    54 
    55 // --- cSetupPremiereEpg -------------------------------------------------------
    55 // --- cSetupPremiereEpg -------------------------------------------------------
    56 
    56 
    57 const char *optPats[] = {
    57 const char *optPats[] = {
    64 #define NUM_PATS (sizeof(optPats)/sizeof(char *))
    64 #define NUM_PATS (sizeof(optPats)/sizeof(char *))
    65 
    65 
    66 class cSetupPremiereEpg {
    66 class cSetupPremiereEpg {
    67 public:
    67 public:
    68   int OptPat;
    68   int OptPat;
       
    69   int OrderInfo;
       
    70   int RatingInfo;
    69 public:
    71 public:
    70   cSetupPremiereEpg(void);
    72   cSetupPremiereEpg(void);
    71   };
    73   };
    72 
    74 
    73 cSetupPremiereEpg SetupPE;
    75 cSetupPremiereEpg SetupPE;
    74 
    76 
    75 cSetupPremiereEpg::cSetupPremiereEpg(void)
    77 cSetupPremiereEpg::cSetupPremiereEpg(void)
    76 {
    78 {
    77   OptPat=1;
    79   OptPat=1;
       
    80   OrderInfo=1;
       
    81   RatingInfo=1;
    78 }
    82 }
    79 
    83 
    80 // --- i18n --------------------------------------------------------------------
    84 // --- i18n --------------------------------------------------------------------
    81 
    85 
    82 const tI18nPhrase Phrases[] = {
    86 const tI18nPhrase Phrases[] = {
   116     "", // TODO
   120     "", // TODO
   117     "", // TODO
   121     "", // TODO
   118   },
   122   },
   119   { "Tag option events",
   123   { "Tag option events",
   120     "Options Events markieren",
   124     "Options Events markieren",
       
   125     "", // TODO
       
   126     "", // TODO
       
   127     "", // TODO
       
   128     "", // TODO
       
   129     "", // TODO
       
   130     "", // TODO
       
   131     "", // TODO
       
   132     "", // TODO
       
   133     "", // TODO
       
   134     "", // TODO
       
   135     "", // TODO
       
   136     "", // TODO
       
   137     "", // TODO
       
   138     "", // TODO
       
   139   },
       
   140   { "Show order information",
       
   141     "Bestellhinweise anzeigen",
       
   142     "", // TODO
       
   143     "", // TODO
       
   144     "", // TODO
       
   145     "", // TODO
       
   146     "", // TODO
       
   147     "", // TODO
       
   148     "", // TODO
       
   149     "", // TODO
       
   150     "", // TODO
       
   151     "", // TODO
       
   152     "", // TODO
       
   153     "", // TODO
       
   154     "", // TODO
       
   155     "", // TODO
       
   156   },
       
   157   { "Show rating information",
       
   158     "Altersfreigaben anzeigen",
       
   159     "", // TODO
       
   160     "", // TODO
       
   161     "", // TODO
       
   162     "", // TODO
       
   163     "", // TODO
       
   164     "", // TODO
       
   165     "", // TODO
       
   166     "", // TODO
       
   167     "", // TODO
       
   168     "", // TODO
       
   169     "", // TODO
       
   170     "", // TODO
       
   171     "", // TODO
       
   172     "", // TODO
       
   173   },
       
   174 
       
   175   { "Ordernumber",
       
   176     "Bestellnummer",
       
   177     "", // TODO
       
   178     "", // TODO
       
   179     "", // TODO
       
   180     "", // TODO
       
   181     "", // TODO
       
   182     "", // TODO
       
   183     "", // TODO
       
   184     "", // TODO
       
   185     "", // TODO
       
   186     "", // TODO
       
   187     "", // TODO
       
   188     "", // TODO
       
   189     "", // TODO
       
   190     "", // TODO
       
   191   },
       
   192   { "Price",
       
   193     "Preis",
       
   194     "", // TODO
       
   195     "", // TODO
       
   196     "", // TODO
       
   197     "", // TODO
       
   198     "", // TODO
       
   199     "", // TODO
       
   200     "", // TODO
       
   201     "", // TODO
       
   202     "", // TODO
       
   203     "", // TODO
       
   204     "", // TODO
       
   205     "", // TODO
       
   206     "", // TODO
       
   207     "", // TODO
       
   208   },
       
   209   { "Ordering",
       
   210     "Bestellen",
       
   211     "", // TODO
       
   212     "", // TODO
       
   213     "", // TODO
       
   214     "", // TODO
       
   215     "", // TODO
       
   216     "", // TODO
       
   217     "", // TODO
       
   218     "", // TODO
       
   219     "", // TODO
       
   220     "", // TODO
       
   221     "", // TODO
       
   222     "", // TODO
       
   223     "", // TODO
       
   224     "", // TODO
       
   225   },
       
   226   { "SMS",
       
   227     "SMS",
       
   228     "", // TODO
       
   229     "", // TODO
       
   230     "", // TODO
       
   231     "", // TODO
       
   232     "", // TODO
       
   233     "", // TODO
       
   234     "", // TODO
       
   235     "", // TODO
       
   236     "", // TODO
       
   237     "", // TODO
       
   238     "", // TODO
       
   239     "", // TODO
       
   240     "", // TODO
       
   241     "", // TODO
       
   242   },
       
   243   { "WWW",
       
   244     "WWW",
       
   245     "", // TODO
       
   246     "", // TODO
       
   247     "", // TODO
       
   248     "", // TODO
       
   249     "", // TODO
       
   250     "", // TODO
       
   251     "", // TODO
       
   252     "", // TODO
       
   253     "", // TODO
       
   254     "", // TODO
       
   255     "", // TODO
       
   256     "", // TODO
       
   257     "", // TODO
       
   258     "", // TODO
       
   259   },
       
   260   { "Rating",
       
   261     "Altersfreigabe",
       
   262     "", // TODO
       
   263     "", // TODO
       
   264     "", // TODO
       
   265     "", // TODO
       
   266     "", // TODO
       
   267     "", // TODO
       
   268     "", // TODO
       
   269     "", // TODO
       
   270     "", // TODO
       
   271     "", // TODO
       
   272     "", // TODO
       
   273     "", // TODO
       
   274     "", // TODO
       
   275     "", // TODO
       
   276   },
       
   277   { "years",
       
   278     "Jahre",
   121     "", // TODO
   279     "", // TODO
   122     "", // TODO
   280     "", // TODO
   123     "", // TODO
   281     "", // TODO
   124     "", // TODO
   282     "", // TODO
   125     "", // TODO
   283     "", // TODO
   158   for(unsigned int i=1; i<NUM_PATS; i++) {
   316   for(unsigned int i=1; i<NUM_PATS; i++) {
   159     snprintf(buff[i],sizeof(buff[i]),optPats[i],"Event",1);
   317     snprintf(buff[i],sizeof(buff[i]),optPats[i],"Event",1);
   160     optDisp[i]=buff[i];
   318     optDisp[i]=buff[i];
   161     }
   319     }
   162   Add(new cMenuEditStraItem(tr("Tag option events"),&data.OptPat,NUM_PATS,optDisp));
   320   Add(new cMenuEditStraItem(tr("Tag option events"),&data.OptPat,NUM_PATS,optDisp));
       
   321   Add(new cMenuEditBoolItem(tr("Show order information"),&data.OrderInfo));
       
   322   Add(new cMenuEditBoolItem(tr("Show rating information"),&data.RatingInfo));
   163 }
   323 }
   164 
   324 
   165 void cMenuSetupPremiereEpg::Store(void)
   325 void cMenuSetupPremiereEpg::Store(void)
   166 {
   326 {
   167   SetupPE=data;
   327   SetupPE=data;
   168   SetupStore("OptionPattern",SetupPE.OptPat);
   328   SetupStore("OptionPattern",SetupPE.OptPat);
       
   329   SetupStore("OrderInfo",SetupPE.OrderInfo);
       
   330   SetupStore("RatingInfo",SetupPE.RatingInfo);
   169 }
   331 }
   170 
   332 
   171 // --- CIT ---------------------------------------------------------------------
   333 // --- CIT ---------------------------------------------------------------------
   172 
   334 
   173 namespace SI {
   335 namespace SI {
   420         int LanguagePreferenceShort=-1;
   582         int LanguagePreferenceShort=-1;
   421         int LanguagePreferenceExt=-1;
   583         int LanguagePreferenceExt=-1;
   422         bool UseExtendedEventDescriptor=false;
   584         bool UseExtendedEventDescriptor=false;
   423         SI::ExtendedEventDescriptors *ExtendedEventDescriptors=0;
   585         SI::ExtendedEventDescriptors *ExtendedEventDescriptors=0;
   424         SI::ShortEventDescriptor *ShortEventDescriptor=0;
   586         SI::ShortEventDescriptor *ShortEventDescriptor=0;
       
   587         char *order=0, *rating=0;
   425         for(SI::Loop::Iterator it; (d=cit.eventDescriptors.getNext(it)); ) {
   588         for(SI::Loop::Iterator it; (d=cit.eventDescriptors.getNext(it)); ) {
   426           switch(d->getDescriptorTag()) {
   589           switch(d->getDescriptorTag()) {
   427             case 0xF2:
   590             case 0xF0: // order information
       
   591               if(SetupPE.OrderInfo) {
       
   592                 static const char *text[] = {
       
   593                   "Ordernumber",
       
   594                   "Price",
       
   595                   "Ordering",
       
   596                   "SMS",
       
   597                   "WWW"
       
   598                   };
       
   599                 char buff[512];
       
   600                 int p=0;
       
   601                 const unsigned char *data=d->getData().getData()+2;
       
   602                 for(int i=0; i<5; i++) {
       
   603                   int l=data[0]; 
       
   604                   if(l>0) p+=snprintf(&buff[p],sizeof(buff)-p,"\n%s: %.*s",tr(text[i]),l,&data[1]);
       
   605                   data+=l+1;
       
   606                   }
       
   607                 if(p>0) order=strdup(buff);
       
   608                 }
       
   609               break;
       
   610             case 0xF1: // parental rating
       
   611               if(SetupPE.RatingInfo) {
       
   612                 char buff[512];
       
   613                 int p=0;
       
   614                 const unsigned char *data=d->getData().getData()+2;
       
   615                 p+=snprintf(&buff[p],sizeof(buff)-p,"\n%s: %d %s",tr("Rating"),data[0]+3,tr("years"));
       
   616                 data+=7;
       
   617                 int l=data[0]; 
       
   618                 if(l>0) p+=snprintf(&buff[p],sizeof(buff)-p," (%.*s)",l,&data[1]);
       
   619                 if(p>0) rating=strdup(buff);
       
   620                 }
       
   621               break;
       
   622             case 0xF2: // transmisions
   428               if(nCount>=0) {
   623               if(nCount>=0) {
   429                 nCount++;
   624                 nCount++;
   430                 cDescrF2 f2(d);
   625                 cDescrF2 f2(d);
   431                 if(f2.Next()) {
   626                 if(f2.Next()) {
   432                   if(nCount==1) firstTime=f2.StartTime();
   627                   if(nCount==1) firstTime=f2.StartTime();
   546                 }
   741                 }
   547               if(ExtendedEventDescriptors) {
   742               if(ExtendedEventDescriptors) {
   548                 char buffer[ExtendedEventDescriptors->getMaximumTextLength(": ")+1];
   743                 char buffer[ExtendedEventDescriptors->getMaximumTextLength(": ")+1];
   549                 pEvent->SetDescription(ExtendedEventDescriptors->getText(buffer,sizeof(buffer),": "));
   744                 pEvent->SetDescription(ExtendedEventDescriptors->getText(buffer,sizeof(buffer),": "));
   550                 }
   745                 }
       
   746               if(order || rating) {
       
   747                 int len=(pEvent->Description() ? strlen(pEvent->Description()) : 0) +
       
   748                         (order                 ? strlen(order) : 0) +
       
   749                         (rating                ? strlen(rating) : 0);
       
   750                 char buffer[len+32];
       
   751                 buffer[0]=0;
       
   752                 if(pEvent->Description()) strcat(buffer,pEvent->Description());
       
   753                 if(rating)                strcat(buffer,rating);
       
   754                 if(order)                 strcat(buffer,order);
       
   755                 pEvent->SetDescription(buffer);
       
   756                 }
   551 
   757 
   552               if(newEvent) pSchedule->AddEvent(pEvent);
   758               if(newEvent) pSchedule->AddEvent(pEvent);
   553               pEvent->SetComponents(NULL);
   759               pEvent->SetComponents(NULL);
   554               pEvent->FixEpgBugs();
   760               pEvent->FixEpgBugs();
   555               Modified=true;
   761               Modified=true;
   561             }
   767             }
   562           delete d;
   768           delete d;
   563           }
   769           }
   564         delete ExtendedEventDescriptors;
   770         delete ExtendedEventDescriptors;
   565         delete ShortEventDescriptor;
   771         delete ShortEventDescriptor;
       
   772         free(order);
       
   773         free(rating);
   566         }
   774         }
   567       }
   775       }
   568     }
   776     }
   569 }
   777 }
   570 
   778 
   621   return new cMenuSetupPremiereEpg;
   829   return new cMenuSetupPremiereEpg;
   622 }
   830 }
   623 
   831 
   624 bool cPluginPremiereEpg::SetupParse(const char *Name, const char *Value)
   832 bool cPluginPremiereEpg::SetupParse(const char *Name, const char *Value)
   625 {
   833 {
   626   if      (!strcasecmp(Name, "OptionPattern")) SetupPE.OptPat = atoi(Value);
   834   if      (!strcasecmp(Name, "OptionPattern")) SetupPE.OptPat     = atoi(Value);
       
   835   else if (!strcasecmp(Name, "OrderInfo"))     SetupPE.OrderInfo  = atoi(Value);
       
   836   else if (!strcasecmp(Name, "RatingInfo"))    SetupPE.RatingInfo = atoi(Value);
   627   else return false;
   837   else return false;
   628   return true;
   838   return true;
   629 }
   839 }
   630 
   840 
   631 VDRPLUGINCREATOR(cPluginPremiereEpg); // Don't touch this!
   841 VDRPLUGINCREATOR(cPluginPremiereEpg); // Don't touch this!