diff options
| -rw-r--r-- | dist/epgdata2xmltv/epgdata2xmltv.xsl | 19 | ||||
| -rw-r--r-- | import.cpp | 556 | ||||
| -rw-r--r-- | import.h | 7 | ||||
| -rw-r--r-- | po/de_DE.po | 32 | ||||
| -rw-r--r-- | po/it_IT.po | 32 | ||||
| -rw-r--r-- | setup.cpp | 332 | ||||
| -rw-r--r-- | setup.h | 44 | ||||
| -rw-r--r-- | source.cpp | 42 | ||||
| -rw-r--r-- | source.h | 4 | ||||
| -rw-r--r-- | xmltv2vdr.cpp | 170 | ||||
| -rw-r--r-- | xmltv2vdr.h | 263 |
11 files changed, 855 insertions, 646 deletions
diff --git a/dist/epgdata2xmltv/epgdata2xmltv.xsl b/dist/epgdata2xmltv/epgdata2xmltv.xsl index 1b0fe9e..b84ac9e 100644 --- a/dist/epgdata2xmltv/epgdata2xmltv.xsl +++ b/dist/epgdata2xmltv/epgdata2xmltv.xsl @@ -32,6 +32,10 @@ G <xsl:value-of select="d25"/> </xsl:variable> +<xsl:variable name="EPISODE"> +<xsl:if test="d26 > 0"><xsl:value-of select="d26 - 1"/></xsl:if> +</xsl:variable> + <xsl:variable name="PICS"> <xsl:if test="string-length(d38)"> <xsl:element name="icon"> @@ -122,6 +126,15 @@ G <xsl:value-of select="d25"/> </xsl:if> </xsl:variable> +<xsl:variable name="TIPP"> +<xsl:if test="d18=1"> +<star-rating system="TagesTipp"><value>1/1</value></star-rating><xsl:text>
</xsl:text> +</xsl:if> +<xsl:if test="d18=2"> +<star-rating system="TopTipp"><value>1/1</value></star-rating><xsl:text>
</xsl:text> +</xsl:if> +</xsl:variable> + <xsl:variable name="vps_iso8601"> <xsl:if test="string-length(d8)"> <xsl:call-template name="date2UTC"> @@ -202,6 +215,9 @@ G <xsl:value-of select="d25"/> <xsl:if test="string-length($LAND)"> <country><xsl:value-of select="$LAND"/></country><xsl:text>
</xsl:text> </xsl:if> +<xsl:if test="string-length($EPISODE)"> +<episode-num system='xmltv_ns'>.<xsl:value-of select="$EPISODE"/>.</episode-num><xsl:text>
</xsl:text> +</xsl:if> <xsl:if test="string-length($VIDEO)"> <video><xsl:text>
</xsl:text><xsl:copy-of select="$VIDEO"/></video><xsl:text>
</xsl:text> </xsl:if> @@ -212,6 +228,9 @@ G <xsl:value-of select="d25"/> <xsl:if test="string-length($STARRATING)"> <xsl:copy-of select="$STARRATING"/> </xsl:if> +<xsl:if test="string-length($TIPP)"> +<xsl:copy-of select="$TIPP"/> +</xsl:if> </xsl:element> <xsl:text>
</xsl:text> @@ -253,13 +253,13 @@ char *cImport::AddEOT2Description(char *description, bool checkutf8) if (checkutf8) { - if (!codeset) + if (!g->Codeset()) { description=strcatrealloc(description,nbspUTF8); } else { - if (strncasecmp(codeset,"UTF-8",5) || strncasecmp(codeset,"UTF8",4)) + if (strncasecmp(g->Codeset(),"UTF-8",5) || strncasecmp(g->Codeset(),"UTF8",4)) { description=strcatrealloc(description,nbsp); } @@ -303,11 +303,11 @@ void cImport::LinkPictures(const char *Source, cXMLTVStringList *Pics, tEventID int ret; if (!i) { - ret=asprintf(&dstold,"%s/%i.%s",imgdir,DestID,ext); + ret=asprintf(&dstold,"%s/%i.%s",g->ImgDir(),DestID,ext); } else { - ret=asprintf(&dstold,"%s/%i_%i.%s",imgdir,DestID,i,ext); + ret=asprintf(&dstold,"%s/%i_%i.%s",g->ImgDir(),DestID,i,ext); } if (ret==-1) { @@ -317,11 +317,11 @@ void cImport::LinkPictures(const char *Source, cXMLTVStringList *Pics, tEventID if (!i) { - ret=asprintf(&dst,"%s/%s_%i.%s",imgdir,*ChanID.ToString(),DestID,ext); + ret=asprintf(&dst,"%s/%s_%i.%s",g->ImgDir(),*ChanID.ToString(),DestID,ext); } else { - ret=asprintf(&dst,"%s/%s_%i_%i.%s",imgdir,*ChanID.ToString(),DestID,i,ext); + ret=asprintf(&dst,"%s/%s_%i_%i.%s",g->ImgDir(),*ChanID.ToString(),DestID,i,ext); } if (ret==-1) { @@ -386,234 +386,26 @@ void cImport::LinkPictures(const char *Source, cXMLTVStringList *Pics, tEventID } } -bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule, - cEvent *Event, cXMLTVEvent *xEvent,int Flags) +char *cImport::Add2Description(char *description, cXMLTVEvent *xEvent, int Flags, int what) { - if (!Source) return false; - if (!Db) return false; - if (!xEvent) return false; - -#define CHANGED_NOTHING 0 -#define CHANGED_TITLE 1 -#define CHANGED_SHORTTEXT 2 -#define CHANGED_DESCRIPTION 4 - - struct tm tm; - char from[80]; - char till[80]; - time_t start,end; - - int changed=CHANGED_NOTHING; - bool append=false; - bool retcode=false; - bool added=false; - - if ((Flags & OPT_APPEND)==OPT_APPEND) append=true; - - if (append && !Event) - { - if (!Schedule) return false; - start=xEvent->StartTime(); - end=start+xEvent->Duration(); - - /* checking the "space" for our new event */ - cEvent *prev=GetEventBefore(Schedule,start); - if (prev) - { - if (cEvent *next=(cEvent *) prev->Next()) - { - if (prev->EndTime()==next->StartTime()) - { - localtime_r(&start,&tm); - strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm); - localtime_r(&end,&tm); - strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm); - esyslogs(Source,"cannot add '%s'@%s-%s",xEvent->Title(),from,till); - - time_t pstart=prev->StartTime(); - time_t pstop=prev->EndTime(); - localtime_r(&pstart,&tm); - strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm); - localtime_r(&pstop,&tm); - strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm); - esyslogs(Source,"found '%s'@%s-%s",prev->Title(),from,till); - - time_t nstart=next->StartTime(); - time_t nstop=next->EndTime(); - localtime_r(&nstart,&tm); - strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm); - localtime_r(&nstop,&tm); - strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm); - esyslogs(Source,"found '%s'@%s-%s",next->Title(),from,till); - return false; - } - - if (end>next->StartTime()) - { - int diff=(int) difftime(prev->EndTime(),start); - if (diff>300) - { - - localtime_r(&start,&tm); - strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm); - localtime_r(&end,&tm); - strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm); - esyslogs(Source,"cannot add '%s'@%s-%s",xEvent->Title(),from,till); - - time_t nstart=next->StartTime(); - time_t nstop=next->EndTime(); - localtime_r(&nstart,&tm); - strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm); - localtime_r(&nstop,&tm); - strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm); - esyslogs(Source,"found '%s'@%s-%s",next->Title(),from,till); - return false; - } - else - { - xEvent->SetDuration(xEvent->Duration()-diff); - } - } - } - else - { - // no next event, check for gaps - if (prev->EndTime()!=start) - { - tsyslogs(Source,"detected gap of %lis",(long int)(start-prev->EndTime())); - } - } - - if (prev->EndTime()>start) - { - int diff=(int) difftime(prev->EndTime(),start); - if (diff>300) - { - localtime_r(&start,&tm); - strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm); - localtime_r(&end,&tm); - strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm); - esyslogs(Source,"cannot add '%s'@%s-%s",xEvent->Title(),from,till); - - time_t pstart=prev->StartTime(); - time_t pstop=prev->EndTime(); - localtime_r(&pstart,&tm); - strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm); - localtime_r(&pstop,&tm); - strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm); - esyslogs(Source,"found '%s'@%s-%s",prev->Title(),from,till); - return false; - } - else - { - prev->SetDuration(prev->Duration()-diff); - } - } - - if (!xEvent->Duration()) - { - if (!prev->Duration()) - { - prev->SetDuration(start-prev->StartTime()); - } - } - } - /* add event */ - Event=new cEvent(xEvent->EventID()); - if (!Event) return false; - Event->SetStartTime(start); - Event->SetDuration(xEvent->Duration()); - Event->SetTitle(xEvent->Title()); - Event->SetVersion(0); - Event->SetTableID(0); - Schedule->AddEvent(Event); - Schedule->Sort(); - added=true; - if (xEvent->Pics()->Size() && Source->UsePics()) - { - /* here's a good place to link pictures! */ - LinkPictures(xEvent->Source(),xEvent->Pics(),Event->EventID(),Event->ChannelID()); - } - if (Source->Trace()) - { - localtime_r(&start,&tm); - strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm); - localtime_r(&end,&tm); - strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm); - tsyslogs(Source,"{%5i} adding '%s'/'%s'@%s-%s",xEvent->EventID(),xEvent->Title(), - xEvent->ShortText(),from,till); - } - retcode=true; - } - - if (!Event) return false; - - if (!append) + if (what==USE_LONGTEXT) { - const char *eitdescription=Event->Description(); - if (WasChanged(Event)) eitdescription=NULL; // we cannot use Event->Description() - it is already changed! - if (!xEvent->EITEventID() || eitdescription) - { - if (!xEvent->EITEventID() && xEvent->Pics()->Size() && Source->UsePics()) - { - /* here's a good place to link pictures! */ - LinkPictures(xEvent->Source(),xEvent->Pics(),Event->EventID(),Event->ChannelID()); - } - UpdateXMLTVEvent(Source,Db,Event,xEvent,eitdescription); - } - } - - if ((Flags & USE_TITLE)==USE_TITLE) - { - if (xEvent->Title() && (strlen(xEvent->Title())>0)) - { - const char *dp=conv->Convert(xEvent->Title()); - if (!Event->Title() || strcmp(Event->Title(),dp)) - { - Event->SetTitle(dp); - changed|=CHANGED_TITLE; // title really changed - } - } - } - - if (((Flags & USE_SHORTTEXT)==USE_SHORTTEXT) || (append)) - { - if (xEvent->ShortText() && (strlen(xEvent->ShortText())>0)) + if (((Flags & USE_LONGTEXT)==USE_LONGTEXT) || ((Flags & OPT_APPEND)==OPT_APPEND)) { - if (!strcasecmp(xEvent->ShortText(),Event->Title())) - { - tsyslogs(Source,"title and subtitle equal, clearing subtitle"); - Event->SetShortText(NULL); - } - else + if (xEvent->Description() && (strlen(xEvent->Description())>0)) { - const char *dp=conv->Convert(xEvent->ShortText()); - if (!Event->ShortText() || strcmp(Event->ShortText(),dp)) - { - Event->SetShortText(dp); - changed|=CHANGED_SHORTTEXT; // shorttext really changed - } + description=Add2Description(description,xEvent->Description()); } } - } - char *description=NULL; - if (((Flags & USE_LONGTEXT)==USE_LONGTEXT) || (append)) - { - if (xEvent->Description() && (strlen(xEvent->Description())>0)) + if (!description && xEvent->EITDescription() && (strlen(xEvent->EITDescription())>0)) { - description=strdup(xEvent->Description()); + description=Add2Description(description,xEvent->EITDescription()); } + description=Add2Description(description,"\n"); } - if (!description && xEvent->EITDescription() && (strlen(xEvent->EITDescription())>0)) - { - description=strdup(xEvent->EITDescription()); - } - - description=Add2Description(description,"\n"); - - if ((Flags & USE_CREDITS)==USE_CREDITS) + if (what==USE_CREDITS) { cXMLTVStringList *credits=xEvent->Credits(); if (credits->Size()) @@ -639,7 +431,7 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule, (strcasecmp(ctype,"director"))) add=false; if (add) { - cTEXTMapping *text=texts->GetMap(ctype); + cTEXTMapping *text=g->TEXTMappings()->GetMap(ctype); if ((Flags & CREDITS_LIST)==CREDITS_LIST) { if (oldtext!=text) @@ -678,28 +470,28 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule, } } - if ((Flags & USE_COUNTRYDATE)==USE_COUNTRYDATE) + if (what==USE_COUNTRYDATE) { if (xEvent->Country()) { - cTEXTMapping *text=texts->GetMap("country"); + cTEXTMapping *text=g->TEXTMappings()->GetMap("country"); if (text) description=Add2Description(description,text->Value(),xEvent->Country()); } if (xEvent->Year()) { - cTEXTMapping *text=texts->GetMap("year"); + cTEXTMapping *text=g->TEXTMappings()->GetMap("year"); if (text) description=Add2Description(description,text->Value(),xEvent->Year()); } } - if (((Flags & USE_ORIGTITLE)==USE_ORIGTITLE) && (xEvent->OrigTitle())) + if ((what==USE_ORIGTITLE) && (xEvent->OrigTitle())) { - cTEXTMapping *text=texts->GetMap("originaltitle"); + cTEXTMapping *text=g->TEXTMappings()->GetMap("originaltitle"); if (text) description=Add2Description(description,text->Value(),xEvent->OrigTitle()); } - if (((Flags & USE_CATEGORIES)==USE_CATEGORIES) && (xEvent->Category()->Size())) + if ((what==USE_CATEGORIES) && (xEvent->Category()->Size())) { - cTEXTMapping *text=texts->GetMap("category"); + cTEXTMapping *text=g->TEXTMappings()->GetMap("category"); if (text) { cXMLTVStringList *categories=xEvent->Category(); @@ -713,9 +505,9 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule, } } - if (((Flags & USE_VIDEO)==USE_VIDEO) && (xEvent->Video()->Size())) + if ((what==USE_VIDEO) && (xEvent->Video()->Size())) { - cTEXTMapping *text=texts->GetMap("video"); + cTEXTMapping *text=g->TEXTMappings()->GetMap("video"); if (text) { description=Add2Description(description,text->Value()); @@ -741,7 +533,7 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule, { if (!strcasecmp(vval,"no")) { - cTEXTMapping *text=texts->GetMap("blacknwhite"); + cTEXTMapping *text=g->TEXTMappings()->GetMap("blacknwhite"); description=Add2Description(description,text->Value()); } } @@ -757,11 +549,11 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule, } } - if ((Flags & USE_AUDIO)==USE_AUDIO) + if (what==USE_AUDIO) { if (xEvent->Audio()) { - cTEXTMapping *text=texts->GetMap("audio"); + cTEXTMapping *text=g->TEXTMappings()->GetMap("audio"); if (text) { description=Add2Description(description,text->Value()); @@ -774,7 +566,7 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule, } else { - cTEXTMapping *text=texts->GetMap(xEvent->Audio()); + cTEXTMapping *text=g->TEXTMappings()->GetMap(xEvent->Audio()); if (text) { description=Add2Description(description,text->Value()); @@ -784,28 +576,28 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule, } } } - if ((Flags & USE_SEASON)==USE_SEASON) + if (what==USE_SEASON) { if (xEvent->Season()) { - cTEXTMapping *text=texts->GetMap("season"); + cTEXTMapping *text=g->TEXTMappings()->GetMap("season"); if (text) description=Add2Description(description,text->Value(),xEvent->Season()); } if (xEvent->Episode()) { - cTEXTMapping *text=texts->GetMap("episode"); + cTEXTMapping *text=g->TEXTMappings()->GetMap("episode"); if (text) description=Add2Description(description,text->Value(),xEvent->Episode()); } if (xEvent->EpisodeOverall()) { - cTEXTMapping *text=texts->GetMap("episodeoverall"); + cTEXTMapping *text=g->TEXTMappings()->GetMap("episodeoverall"); if (text) description=Add2Description(description,text->Value(),xEvent->EpisodeOverall()); } } - if (((Flags & USE_RATING)==USE_RATING) && (xEvent->Rating()->Size())) + if ((what==USE_RATING) && (xEvent->Rating()->Size())) { #if VDRVERSNUM < 10711 && !EPGHANDLER Flags|=OPT_RATING_TEXT; // always add to text if we dont have the internal tag! @@ -835,9 +627,9 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule, } } - if (((Flags & USE_STARRATING)==USE_STARRATING) && (xEvent->StarRating()->Size())) + if ((what==USE_STARRATING) && (xEvent->StarRating()->Size())) { - cTEXTMapping *text=texts->GetMap("starrating"); + cTEXTMapping *text=g->TEXTMappings()->GetMap("starrating"); if (text) { description=Add2Description(description,text->Value()); @@ -872,9 +664,9 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule, } } - if (((Flags & USE_REVIEW)==USE_REVIEW) && (xEvent->Review()->Size())) + if ((what==USE_REVIEW) && (xEvent->Review()->Size())) { - cTEXTMapping *text=texts->GetMap("review"); + cTEXTMapping *text=g->TEXTMappings()->GetMap("review"); if (text) { cXMLTVStringList *review=xEvent->Review(); @@ -885,6 +677,243 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule, } } + return description; +} + +bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule, + cEvent *Event, cXMLTVEvent *xEvent,int Flags) +{ + if (!Source) return false; + if (!Db) return false; + if (!xEvent) return false; + if (!g) return false; + +#define CHANGED_NOTHING 0 +#define CHANGED_TITLE 1 +#define CHANGED_SHORTTEXT 2 +#define CHANGED_DESCRIPTION 4 + + struct tm tm; + char from[80]; + char till[80]; + time_t start,end; + + int changed=CHANGED_NOTHING; + bool append=false; + bool retcode=false; + bool added=false; + + if ((Flags & OPT_APPEND)==OPT_APPEND) append=true; + + if (append && !Event) + { + if (!Schedule) return false; + start=xEvent->StartTime(); + end=start+xEvent->Duration(); + + /* checking the "space" for our new event */ + cEvent *prev=GetEventBefore(Schedule,start); + if (prev) + { + if (cEvent *next=(cEvent *) prev->Next()) + { + if (prev->EndTime()==next->StartTime()) + { + localtime_r(&start,&tm); + strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm); + localtime_r(&end,&tm); + strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm); + esyslogs(Source,"cannot add '%s'@%s-%s",xEvent->Title(),from,till); + + time_t pstart=prev->StartTime(); + time_t pstop=prev->EndTime(); + localtime_r(&pstart,&tm); + strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm); + localtime_r(&pstop,&tm); + strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm); + esyslogs(Source,"found '%s'@%s-%s",prev->Title(),from,till); + + time_t nstart=next->StartTime(); + time_t nstop=next->EndTime(); + localtime_r(&nstart,&tm); + strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm); + localtime_r(&nstop,&tm); + strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm); + esyslogs(Source,"found '%s'@%s-%s",next->Title(),from,till); + return false; + } + + if (end>next->StartTime()) + { + int diff=(int) difftime(prev->EndTime(),start); + if (diff>300) + { + + localtime_r(&start,&tm); + strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm); + localtime_r(&end,&tm); + strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm); + esyslogs(Source,"cannot add '%s'@%s-%s",xEvent->Title(),from,till); + + time_t nstart=next->StartTime(); + time_t nstop=next->EndTime(); + localtime_r(&nstart,&tm); + strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm); + localtime_r(&nstop,&tm); + strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm); + esyslogs(Source,"found '%s'@%s-%s",next->Title(),from,till); + return false; + } + else + { + xEvent->SetDuration(xEvent->Duration()-diff); + } + } + } + else + { + // no next event, check for gaps + if (prev->EndTime()!=start) + { + tsyslogs(Source,"detected gap of %lis",(long int)(start-prev->EndTime())); + } + } + + if (prev->EndTime()>start) + { + int diff=(int) difftime(prev->EndTime(),start); + if (diff>300) + { + localtime_r(&start,&tm); + strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm); + localtime_r(&end,&tm); + strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm); + esyslogs(Source,"cannot add '%s'@%s-%s",xEvent->Title(),from,till); + + time_t pstart=prev->StartTime(); + time_t pstop=prev->EndTime(); + localtime_r(&pstart,&tm); + strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm); + localtime_r(&pstop,&tm); + strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm); + esyslogs(Source,"found '%s'@%s-%s",prev->Title(),from,till); + return false; + } + else + { + prev->SetDuration(prev->Duration()-diff); + } + } + + if (!xEvent->Duration()) + { + if (!prev->Duration()) + { + prev->SetDuration(start-prev->StartTime()); + } + } + } + /* add event */ + Event=new cEvent(xEvent->EventID()); + if (!Event) return false; + Event->SetStartTime(start); + Event->SetDuration(xEvent->Duration()); + Event->SetTitle(xEvent->Title()); + Event->SetVersion(0); + Event->SetTableID(0); + Schedule->AddEvent(Event); + Schedule->Sort(); + added=true; + if (xEvent->Pics()->Size() && Source->UsePics()) + { + /* here's a good place to link pictures! */ + LinkPictures(xEvent->Source(),xEvent->Pics(),Event->EventID(),Event->ChannelID()); + } + if (Source->Trace()) + { + localtime_r(&start,&tm); + strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm); + localtime_r(&end,&tm); + strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm); + tsyslogs(Source,"{%5i} adding '%s'/'%s'@%s-%s",xEvent->EventID(),xEvent->Title(), + xEvent->ShortText(),from,till); + } + retcode=true; + } + + if (!Event) return false; + + if (!append) + { + const char *eitdescription=Event->Description(); + if (WasChanged(Event)) eitdescription=NULL; // we cannot use Event->Description() - it is already changed! + if (!xEvent->EITEventID() || eitdescription) + { + if (!xEvent->EITEventID() && xEvent->Pics()->Size() && Source->UsePics()) + { + /* here's a good place to link pictures! */ + LinkPictures(xEvent->Source(),xEvent->Pics(),Event->EventID(),Event->ChannelID()); + } + UpdateXMLTVEvent(Source,Db,Event,xEvent,eitdescription); + } + } + + if ((Flags & USE_TITLE)==USE_TITLE) + { + if (xEvent->Title() && (strlen(xEvent->Title())>0)) + { + const char *dp=conv->Convert(xEvent->Title()); + if (!Event->Title() || strcmp(Event->Title(),dp)) + { + Event->SetTitle(dp); + changed|=CHANGED_TITLE; // title really changed + } + } + } + + if (((Flags & USE_SHORTTEXT)==USE_SHORTTEXT) || (append)) + { + if (xEvent->ShortText() && (strlen(xEvent->ShortText())>0)) + { + if (!strcasecmp(xEvent->ShortText(),Event->Title())) + { + tsyslogs(Source,"title and subtitle equal, clearing subtitle"); + Event->SetShortText(NULL); + } + else + { + const char *dp=conv->Convert(xEvent->ShortText()); + if (!Event->ShortText() || strcmp(Event->ShortText(),dp)) + { + Event->SetShortText(dp); + changed|=CHANGED_SHORTTEXT; // shorttext really changed + } + } + } + } + + char *description=NULL; + + const char *ot=g->Order(); + if (!ot) return false; + + while (*ot) + { + if (*ot==',') ot++; + if (!strncmp(ot,"LOT",3)) description=Add2Description(description,xEvent,Flags,USE_LONGTEXT); + if (!strncmp(ot,"CRS",3)) description=Add2Description(description,xEvent,Flags,USE_CREDITS); + if (!strncmp(ot,"CAD",3)) description=Add2Description(description,xEvent,Flags,USE_COUNTRYDATE); + if (!strncmp(ot,"ORT",3)) description=Add2Description(description,xEvent,Flags,USE_ORIGTITLE); + if (!strncmp(ot,"CAT",3)) description=Add2Description(description,xEvent,Flags,USE_CATEGORIES); + if (!strncmp(ot,"VID",3)) description=Add2Description(description,xEvent,Flags,USE_VIDEO); + if (!strncmp(ot,"AUD",3)) description=Add2Description(description,xEvent,Flags,USE_AUDIO); + if (!strncmp(ot,"SEE",3)) description=Add2Description(description,xEvent,Flags,USE_SEASON); + if (!strncmp(ot,"RAT",3)) description=Add2Description(description,xEvent,Flags,USE_RATING); + if (!strncmp(ot,"STR",3)) description=Add2Description(description,xEvent,Flags,USE_STARRATING); + if (!strncmp(ot,"REV",3)) description=Add2Description(description,xEvent,Flags,USE_REVIEW); + ot+=3; + } + if (description) { description=RemoveLastCharFromDescription(description); @@ -1257,9 +1286,9 @@ cXMLTVEvent *cImport::SearchXMLTVEvent(sqlite3 **Db,const char *ChannelID, const if (!*Db) { // we need READWRITE because the epg.db maybe updated later - if (sqlite3_open_v2(epgfile,Db,SQLITE_OPEN_READWRITE,NULL)!=SQLITE_OK) + if (sqlite3_open_v2(g->EPGFile(),Db,SQLITE_OPEN_READWRITE,NULL)!=SQLITE_OK) { - esyslog("failed to open %s",epgfile); + esyslog("failed to open %s",g->EPGFile()); *Db=NULL; return NULL; } @@ -1400,9 +1429,9 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor) dsyslogs(Source,"importing from db"); sqlite3 *db=NULL; - if (sqlite3_open(epgfile,&db)!=SQLITE_OK) + if (sqlite3_open(g->EPGFile(),&db)!=SQLITE_OK) { - esyslogs(Source,"failed to open %s",epgfile); + esyslogs(Source,"failed to open %s",g->EPGFile()); delete schedulesLock; return 141; } @@ -1441,7 +1470,7 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor) cXMLTVEvent xevent; if (FetchXMLTVEvent(stmt,&xevent)) { - cEPGMapping *map=maps->GetMap(tChannelID::FromString(xevent.ChannelID())); + cEPGMapping *map=g->EPGMappings()->GetMap(tChannelID::FromString(xevent.ChannelID())); if (!map) { if (lerr!=IMPORT_NOMAPPING) @@ -1532,41 +1561,34 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor) bool cImport::DBExists() { - if (!epgfile) return true; // is this safe? + if (!g->EPGFile()) return true; // is this safe? struct stat statbuf; - if (stat(epgfile,&statbuf)==-1) return false; // no database + if (stat(g->EPGFile(),&statbuf)==-1) return false; // no database if (!statbuf.st_size) return false; // no database return true; } cImport::cImport(cGlobals *Global) { - maps=Global->EPGMappings(); - texts=Global->TEXTMappings(); - epgfile=Global->EPGFile(); - codeset=Global->Codeset(); - imgdir=Global->ImgDir(); + g=Global; pendingtransaction=false; - conv = new cCharSetConv("UTF-8",codeset); + conv = new cCharSetConv("UTF-8",g->Codeset()); - epdir=Global->EPDir(); - if (epdir) + if (Global->EPDir()) { cep2ascii=iconv_open("ASCII//TRANSLIT",Global->EPCodeset()); cutf2ascii=iconv_open("ASCII//TRANSLIT","UTF-8"); } else { - epdir=NULL; + cep2ascii=(iconv_t) -1; + cutf2ascii=(iconv_t) -1; } } cImport::~cImport() { - if (epdir) - { - iconv_close(cep2ascii); - iconv_close(cutf2ascii); - } + if (cep2ascii!=(iconv_t) -1) iconv_close(cep2ascii); + if (cutf2ascii!=(iconv_t) -1) iconv_close(cutf2ascii); delete conv; } @@ -38,20 +38,17 @@ private: IMPORT_NOCHANNELID, IMPORT_EMPTYSCHEDULE }; - cEPGMappings *maps; - cTEXTMappings *texts; + cGlobals *g; cCharSetConv *conv; - const char *codeset; - const char *imgdir; iconv_t cep2ascii; iconv_t cutf2ascii; const char *epdir; bool pendingtransaction; - const char *epgfile; char *RemoveLastCharFromDescription(char *description); char *Add2Description(char *description, const char *value); char *Add2Description(char *description, const char *name, const char *value); char *Add2Description(char *description, const char *name, int value); + char *Add2Description(char *description, cXMLTVEvent *xEvent, int Flags, int what); char *AddEOT2Description(char *description, bool checkutf8=false); struct split split(char *in, char delim); cEvent *GetEventBefore(cSchedule* schedule, time_t start); diff --git a/po/de_DE.po b/po/de_DE.po index c1fd331..4420931 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2012-05-08 00:36+0200\n" +"POT-Creation-Date: 2012-06-04 17:24+0200\n" "PO-Revision-Date: 2010-12-23 23:59+0100\n" "Last-Translator: Jochen Dolze <vdr@dolze.de>\n" "Language-Team: <vdr@linuxtv.org>\n" @@ -34,6 +34,9 @@ msgstr "nie" msgid "text mapping" msgstr "Textzuordnungen" +msgid "order of epg data" +msgstr "Reihenfolge der EPG Daten" + msgid "epg sources" msgstr "EPG Quellen" @@ -91,6 +94,21 @@ msgstr "Wertung" msgid "season and episode" msgstr "Staffel und Episode" +msgid "order" +msgstr "Reihenfolge" + +msgid "long text" +msgstr "Langtext" + +msgid "video" +msgstr "Video" + +msgid "audio" +msgstr "Audio" + +msgid "rating" +msgstr "Freigabe" + msgid "overview" msgstr "Übersicht" @@ -157,9 +175,6 @@ msgstr "erstellen" msgid "short text" msgstr "Kurztext" -msgid "long text" -msgstr "Langtext" - msgid " actors" msgstr " Darsteller" @@ -178,18 +193,9 @@ msgstr "mehrzeilig" msgid "singleline" msgstr "einzeilig" -msgid "rating" -msgstr "Freigabe" - msgid " rating in description" msgstr " Freigabe im Text" -msgid "video" -msgstr "Video" - -msgid "audio" -msgstr "Audio" - msgid " add shorttext from list" msgstr " Kurztext von Liste übernehmen" diff --git a/po/it_IT.po b/po/it_IT.po index fc7dad5..c11af83 100644 --- a/po/it_IT.po +++ b/po/it_IT.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2012-05-08 00:36+0200\n" +"POT-Creation-Date: 2012-06-04 17:24+0200\n" "PO-Revision-Date: 2011-03-05 15:45+0100\n" "Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n" "Language-Team: <vdr@linuxtv.org>\n" @@ -37,6 +37,9 @@ msgstr "" msgid "text mapping" msgstr "Mappatura testo" +msgid "order of epg data" +msgstr "" + msgid "epg sources" msgstr "Fonti EPG" @@ -94,6 +97,21 @@ msgstr "" msgid "season and episode" msgstr "" +msgid "order" +msgstr "" + +msgid "long text" +msgstr "Testo completo" + +msgid "video" +msgstr "Video" + +msgid "audio" +msgstr "Audio" + +msgid "rating" +msgstr "Valutazione" + msgid "overview" msgstr "" @@ -160,9 +178,6 @@ msgstr "Creare" msgid "short text" msgstr "Testo breve" -msgid "long text" -msgstr "Testo completo" - msgid " actors" msgstr " Attore" @@ -181,18 +196,9 @@ msgstr "" msgid "singleline" msgstr "" -msgid "rating" -msgstr "Valutazione" - msgid " rating in description" msgstr "" -msgid "video" -msgstr "Video" - -msgid "audio" -msgstr "Audio" - msgid " add shorttext from list" msgstr "" @@ -54,14 +54,13 @@ void cMyMenuEditBitItem::Set(void) // -------------------------------------------------------------------------------------------------------- -cMenuSetupXmltv2vdr::cMenuSetupXmltv2vdr(cPluginXmltv2vdr *Plugin) +cMenuSetupXmltv2vdr::cMenuSetupXmltv2vdr(cGlobals *Global) { - baseplugin=Plugin; - baseplugin->SetSetupState(true); + g=Global; sourcesBegin=sourcesEnd=mappingBegin=mappingEnd=mappingEntry=0; - epall=(unsigned int) baseplugin->EPAll(); - wakeup=(int) baseplugin->WakeUp(); - imgdelafter=baseplugin->ImgDelAfter(); + epall=g->EPAll(); + wakeup=g->WakeUp(); + imgdelafter=g->ImgDelAfter(); if (imgdelafter<=6) imgdelafter=6; cs=NULL; cm=NULL; @@ -70,21 +69,20 @@ cMenuSetupXmltv2vdr::cMenuSetupXmltv2vdr(cPluginXmltv2vdr *Plugin) cMenuSetupXmltv2vdr::~cMenuSetupXmltv2vdr() { - baseplugin->SetSetupState(false); if (cs) cs->ClearMenu(); if (cm) cm->ClearMenu(); } void cMenuSetupXmltv2vdr::Output(void) { - if (!baseplugin) return; + if (!g) return; int current=Current(); Clear(); cOsdItem *first=NewTitle(tr("options")); Add(first,true); epEntry=0; - if (baseplugin->EPDir()) + if (g->EPDir()) { Add(new cMyMenuEditBitItem(tr("add season/episode on all timers"), &epall,EPLIST_USE_SEASON),true); @@ -100,19 +98,21 @@ void cMenuSetupXmltv2vdr::Output(void) } } Add(new cMenuEditBoolItem(tr("automatic wakeup"),&wakeup),true); - if (baseplugin->ImgDir()) + if (g->ImgDir()) { Add(new cMenuEditIntItem(tr("delete pics after (days)"),&imgdelafter,6,365,tr("never")),true); } Add(new cOsdItem(tr("text mapping")),true); mappingEntry=Current(); + Add(new cOsdItem(tr("order of epg data")),true); + orderEntry=Current(); Add(NewTitle(tr("epg sources")),true); - if (!baseplugin->EPGSourceCount()) + if (!g->EPGSources()->Count()) { - baseplugin->ReadInEPGSources(); - if (!baseplugin->EPGSourceCount()) + g->EPGSources()->ReadIn(g); + if (!g->EPGSources()->Count()) { Add(new cOsdItem(tr("no epgsources installed"),osUnknown,false)); Display(); @@ -120,9 +120,9 @@ void cMenuSetupXmltv2vdr::Output(void) } } sourcesBegin=Current()+1; - for (int i=0; i<baseplugin->EPGSourceCount(); i++) + for (int i=0; i<g->EPGSources()->Count()-1; i++) { - cEPGSource *epgsrc=baseplugin->EPGSource(i); + cEPGSource *epgsrc=g->EPGSources()->Get(i); if (epgsrc) { if (epgsrc->Disabled()) @@ -144,7 +144,7 @@ void cMenuSetupXmltv2vdr::Output(void) for (int i=0; i<channels.Size(); i++) { bool mapped=false; - cEPGMapping *map=baseplugin->EPGMapping(channels[i]); + cEPGMapping *map=g->EPGMappings()->GetMap(channels[i]); if (map) { for (int x=0; x<map->NumChannelIDs(); x++) @@ -181,10 +181,11 @@ void cMenuSetupXmltv2vdr::Output(void) void cMenuSetupXmltv2vdr::generatesumchannellist() { channels.Clear(); - for (int i=0; i<baseplugin->EPGSourceCount(); i++) + if (!g->EPGSources()->Count()) return; + for (int i=0; i<g->EPGSources()->Count()-1; i++) { - cEPGSource *epgsrc=baseplugin->EPGSource(i); - if (epgsrc) + cEPGSource *epgsrc=g->EPGSources()->Get(i); + if (epgsrc && !epgsrc->Disabled()) { cEPGChannels *channellist=epgsrc->ChannelList(); if (channellist) @@ -202,7 +203,6 @@ void cMenuSetupXmltv2vdr::generatesumchannellist() { channels.Append(strdup(channellist->Get(x)->Name())); } - } } } @@ -213,53 +213,59 @@ void cMenuSetupXmltv2vdr::generatesumchannellist() void cMenuSetupXmltv2vdr::Store(void) { - - char *order=NULL; - for (int i=0; i<baseplugin->EPGSourceCount(); i++) + char *srcorder=NULL; + if (g->EPGSources()->Count()) { - cEPGSource *epgsrc=baseplugin->EPGSource(i); - if (epgsrc && epgsrc->Name()) + for (int i=0; i<g->EPGSources()->Count()-1; i++) { - if (epgsrc->Disabled()) + cEPGSource *epgsrc=g->EPGSources()->Get(i); + if (epgsrc && epgsrc->Name()) { - order=strcatrealloc(order,"-"); + if (epgsrc->Disabled()) + { + srcorder=strcatrealloc(srcorder,"-"); + } + srcorder=strcatrealloc(srcorder,epgsrc->Name()); + if (i<g->EPGSources()->Count()-2) srcorder=strcatrealloc(srcorder,","); } - order=strcatrealloc(order,epgsrc->Name()); - if (i<baseplugin->EPGSourceCount()-1) order=strcatrealloc(order,","); } } - if (order) + if (srcorder) { - SetupStore("source.order",order); - free(order); + SetupStore("source.order",srcorder); + free(srcorder); } if (imgdelafter<=6) imgdelafter=0; SetupStore("options.epall",epall); SetupStore("options.wakeup",wakeup); SetupStore("options.imgdelafter",imgdelafter); - baseplugin->SetEPAll(epall); - baseplugin->SetWakeUp((bool) wakeup); - baseplugin->SetImgDelAfter(imgdelafter); + g->SetEPAll(epall); + g->SetWakeUp((bool) wakeup); + g->SetImgDelAfter(imgdelafter); } eOSState cMenuSetupXmltv2vdr::edit() { if ((Current()>=sourcesBegin) && (Current()<=sourcesEnd)) { - cs=new cMenuSetupXmltv2vdrChannelSource(baseplugin,this,Current()-sourcesBegin); + cs=new cMenuSetupXmltv2vdrChannelSource(g,this,Current()-sourcesBegin); return AddSubMenu(cs); } if ((Current()>=mappingBegin) && (Current()<=mappingEnd)) { - cm=new cMenuSetupXmltv2vdrChannelMap(baseplugin,this,Current()-mappingBegin); + cm=new cMenuSetupXmltv2vdrChannelMap(g,this,Current()-mappingBegin); return AddSubMenu(cm); } if (Current()==mappingEntry) { - return AddSubMenu(new cMenuSetupXmltv2vdrTextMap(baseplugin)); + return AddSubMenu(new cMenuSetupXmltv2vdrTextMap(g)); + } + if (Current()==orderEntry) + { + return AddSubMenu(new cMenuSetupXmltv2vdrOrder(g)); } return osUnknown; } @@ -288,7 +294,7 @@ eOSState cMenuSetupXmltv2vdr::ProcessKey(eKeys Key) SetHelp(NULL,NULL,tr("Button$Log"),tr("Button$Edit")); } } - else if (Current()==mappingEntry) + else if ((Current()==mappingEntry) || (Current()==orderEntry)) { SetHelp(NULL,NULL,NULL,tr("Button$Edit")); } @@ -310,7 +316,7 @@ eOSState cMenuSetupXmltv2vdr::ProcessKey(eKeys Key) if ((Current()>=sourcesBegin) && (Current()<=sourcesEnd)) { int srcid=Current()-sourcesBegin; - cEPGSource *src=baseplugin->EPGSource(srcid); + cEPGSource *src=g->EPGSources()->Get(srcid); if (src) { if (src->Disabled()) @@ -333,7 +339,7 @@ eOSState cMenuSetupXmltv2vdr::ProcessKey(eKeys Key) { int From=Current()-sourcesBegin; int To=From-1; - if (baseplugin->EPGSourceMove(From,To)) + if (g->EPGSources()->MoveEPGSource(g,From,To)) { CursorUp(); Output(); @@ -348,7 +354,7 @@ eOSState cMenuSetupXmltv2vdr::ProcessKey(eKeys Key) { int From=Current()-sourcesBegin; int To=From+1; - if (baseplugin->EPGSourceMove(From,To)) + if (g->EPGSources()->MoveEPGSource(g,From,To)) { CursorDown(); Output(); @@ -369,10 +375,10 @@ eOSState cMenuSetupXmltv2vdr::ProcessKey(eKeys Key) { if ((Current()>=sourcesBegin) && (Current()<=sourcesEnd)) { - cEPGSource *src=baseplugin->EPGSource(Current()-sourcesBegin); + cEPGSource *src=g->EPGSources()->Get(Current()-sourcesBegin); if (src) { - return AddSubMenu(new cMenuSetupXmltv2vdrLog(baseplugin,src)); + return AddSubMenu(new cMenuSetupXmltv2vdrLog(src)); } } } @@ -386,15 +392,18 @@ eOSState cMenuSetupXmltv2vdr::ProcessKey(eKeys Key) // -------------------------------------------------------------------------------------------------------- -cMenuSetupXmltv2vdrTextMap::cMenuSetupXmltv2vdrTextMap(cPluginXmltv2vdr *Plugin) +cMenuSetupXmltv2vdrTextMap::cMenuSetupXmltv2vdrTextMap(cGlobals *Global) { - baseplugin=Plugin; - SetPlugin(baseplugin); - SetSection(cString::sprintf("%s '%s' : %s",trVDR("Plugin"), baseplugin->Name(), tr("texts"))); + cPlugin *plugin=cPluginManager::GetPlugin("xmltv2vdr"); + if (!plugin) return; + SetPlugin(plugin); + SetSection(cString::sprintf("%s '%s' : %s",trVDR("Plugin"), plugin->Name(), tr("texts"))); + + g=Global; cTEXTMapping *textmap; -#define settval(dummy) textmap=baseplugin->TEXTMapping(#dummy); \ +#define settval(dummy) textmap=g->TEXTMappings()->GetMap(#dummy); \ if (textmap) { \ strn0cpy(dummy,textmap->Value(),sizeof(dummy)-1); \ } else { \ @@ -472,14 +481,14 @@ cMenuSetupXmltv2vdrTextMap::cMenuSetupXmltv2vdrTextMap(cPluginXmltv2vdr *Plugin) void cMenuSetupXmltv2vdrTextMap::Store() { - if (!baseplugin) return; + if (!g) return; cTEXTMapping *textmap; -#define savetval(dummy) textmap=baseplugin->TEXTMapping(#dummy); \ +#define savetval(dummy) textmap=g->TEXTMappings()->GetMap(#dummy); \ if (textmap) { \ textmap->ChangeValue(dummy); \ } else { \ - baseplugin->TEXTMappingAdd(new cTEXTMapping(#dummy,dummy)); \ + g->TEXTMappings()->Add(new cTEXTMapping(#dummy,dummy)); \ } savetval(country); @@ -537,6 +546,151 @@ void cMenuSetupXmltv2vdrTextMap::Store() // -------------------------------------------------------------------------------------------------------- +cMenuSetupXmltv2vdrOrder::cMenuSetupXmltv2vdrOrder(cGlobals* Global) +{ + cPlugin *plugin=cPluginManager::GetPlugin("xmltv2vdr"); + if (!plugin) return; + SetPlugin(plugin); + SetSection(cString::sprintf("%s '%s' : %s",trVDR("Plugin"), plugin->Name(), tr("order"))); + SetHelp(trVDR("Button$Reset"),NULL,tr("Button$Down")); + + g=Global; + order=strdup(g->Order()); + output(); +} + +void cMenuSetupXmltv2vdrOrder::output(void) +{ + int current=Current(); + Clear(); + char *ot=order; + while (*ot) + { + if (*ot==',') ot++; + if (!strncmp(ot,"LOT",3)) Add(new cOsdItem(tr("long text"))); + if (!strncmp(ot,"CRS",3)) Add(new cOsdItem(tr("credits"))); + if (!strncmp(ot,"CAD",3)) Add(new cOsdItem(tr("country and date"))); + if (!strncmp(ot,"ORT",3)) Add(new cOsdItem(tr("original title"))); + if (!strncmp(ot,"CAT",3)) Add(new cOsdItem(tr("category"))); + if (!strncmp(ot,"VID",3)) Add(new cOsdItem(tr("video"))); + if (!strncmp(ot,"AUD",3)) Add(new cOsdItem(tr("audio"))); + if (!strncmp(ot,"SEE",3)) Add(new cOsdItem(tr("season and episode"))); + if (!strncmp(ot,"RAT",3)) Add(new cOsdItem(tr("rating"))); + if (!strncmp(ot,"STR",3)) Add(new cOsdItem(tr("starrating"))); + if (!strncmp(ot,"REV",3)) Add(new cOsdItem(tr("review"))); + ot+=3; + } + if (current==-1) + { + SetCurrent(Get(0)); + } + else + { + SetCurrent(Get(current)); + } + + if (Current()==0) + { + SetHelp(trVDR("Button$Reset"),NULL,tr("Button$Down")); + } + if ((Current()>0) && (Current()<Count()-1)) + { + SetHelp(trVDR("Button$Reset"),tr("Button$Up"),tr("Button$Down")); + } + if (Current()==Count()-1) + { + SetHelp(trVDR("Button$Reset"),tr("Button$Up"),NULL); + } + + Display(); +} + +eOSState cMenuSetupXmltv2vdrOrder::ProcessKey(eKeys Key) +{ + eOSState state = cOsdMenu::ProcessKey(Key); + if (HasSubMenu()) return osContinue; + + if (state==osContinue) + { + switch (Key) + { + case kDown: + case kUp: + case kDown|k_Repeat: + case kUp|k_Repeat: + case kLeft: + case kRight: + case kGreen: + if (Current()==0) + { + SetHelp(trVDR("Button$Reset"),NULL,tr("Button$Down")); + } + if ((Current()>0) && (Current()<Count()-1)) + { + SetHelp(trVDR("Button$Reset"),tr("Button$Up"),tr("Button$Down")); + } + if (Current()==Count()-1) + { + SetHelp(trVDR("Button$Reset"),tr("Button$Up"),NULL); + } + break; + default: + break; + } + } + + if (state==osUnknown) + { + switch (Key) + { + case kGreen: + if (Current()>0) + { + // up + char tmp[4]; + memcpy(&tmp,&order[(Current()-1)*4],3); + memmove(&order[(Current()-1)*4],&order[Current()*4],3); + memcpy(&order[Current()*4],&tmp,3); + CursorUp(); + output(); + } + break; + case kYellow: + if (Current()<Count()-1) + { + // down + char tmp[4]; + memcpy(&tmp,&order[Current()*4],3); + memmove(&order[Current()*4],&order[(Current()+1)*4],3); + memcpy(&order[(Current()+1)*4],&tmp,3); + CursorDown(); + output(); + } + break; + case kRed: + free(order); + order=strdup(g->GetDefaultOrder()); + output(); + break; + case kOk: + Store(); + state=osBack; + break; + default: + break; + } + } + return state; +} + +void cMenuSetupXmltv2vdrOrder::Store(void) +{ + SetupStore("options.order",order); + g->SetOrder(order); +} + +// -------------------------------------------------------------------------------------------------------- + void cMenuSetupXmltv2vdrLog::output(void) { int cur=Current(); @@ -629,12 +783,15 @@ void cMenuSetupXmltv2vdrLog::output(void) Display(); } -cMenuSetupXmltv2vdrLog::cMenuSetupXmltv2vdrLog(cPluginXmltv2vdr *Plugin, cEPGSource *Source) +cMenuSetupXmltv2vdrLog::cMenuSetupXmltv2vdrLog(cEPGSource *Source) :cOsdMenu("",25) { + cPlugin *plugin=cPluginManager::GetPlugin("xmltv2vdr"); + if (!plugin) return; + cString title=cString::sprintf("%s - %s '%s' : %s Log", trVDR("Setup"),trVDR("Plugin"), - Plugin->Name(), Source->Name()); + plugin->Name(), Source->Name()); SetTitle(title); src=Source; SetHelp(tr("Button$Info")); @@ -726,10 +883,13 @@ eOSState cMenuSetupXmltv2vdrLog::ProcessKey(eKeys Key) // -------------------------------------------------------------------------------------------------------- -cMenuSetupXmltv2vdrChannelSource::cMenuSetupXmltv2vdrChannelSource(cPluginXmltv2vdr *Plugin, cMenuSetupXmltv2vdr *Menu, int Index) +cMenuSetupXmltv2vdrChannelSource::cMenuSetupXmltv2vdrChannelSource(cGlobals *Global, cMenuSetupXmltv2vdr *Menu, int Index) { + cPlugin *plugin=cPluginManager::GetPlugin("xmltv2vdr"); + if (!plugin) return; + menu=Menu; - baseplugin=Plugin; + g=Global; sel=NULL; day=0; @@ -739,10 +899,11 @@ cMenuSetupXmltv2vdrChannelSource::cMenuSetupXmltv2vdrChannelSource(cPluginXmltv2 days=1; pin[0]=0; - epgsrc=baseplugin->EPGSource(Index); + epgsrc=g->EPGSources()->Get(Index); if (!epgsrc) return; - SetSection(cString::sprintf("%s '%s' : %s",trVDR("Plugin"), baseplugin->Name(), epgsrc->Name())); + SetPlugin(plugin); + SetSection(cString::sprintf("%s '%s' : %s",trVDR("Plugin"), plugin->Name(), epgsrc->Name())); usepics=epgsrc->UsePics(); weekday=epgsrc->ExecWeekDay(); @@ -836,7 +997,7 @@ eOSState cMenuSetupXmltv2vdrChannelSource::ProcessKey(eKeys Key) void cMenuSetupXmltv2vdrChannelSource::Store(void) { - if ((!baseplugin) || (!sel) || (!epgsrc)) return; + if ((!sel) || (!epgsrc)) return; epgsrc->ChangeExec(start,weekday); epgsrc->ChangeChannelSelection(sel); @@ -850,9 +1011,12 @@ void cMenuSetupXmltv2vdrChannelSource::Store(void) // -------------------------------------------------------------------------------------------------------- -cMenuSetupXmltv2vdrChannelMap::cMenuSetupXmltv2vdrChannelMap(cPluginXmltv2vdr *Plugin, cMenuSetupXmltv2vdr *Menu, int Index) +cMenuSetupXmltv2vdrChannelMap::cMenuSetupXmltv2vdrChannelMap(cGlobals *Global, cMenuSetupXmltv2vdr *Menu, int Index) { - baseplugin=Plugin; + cPlugin *plugin=cPluginManager::GetPlugin("xmltv2vdr"); + if (!plugin) return; + + g=Global; menu=Menu; hasmaps=false; flags=0; @@ -860,9 +1024,9 @@ cMenuSetupXmltv2vdrChannelMap::cMenuSetupXmltv2vdrChannelMap(cPluginXmltv2vdr *P const char *channel=(*menu->ChannelList())[Index]; if (!channel) return; - SetPlugin(baseplugin); + SetPlugin(plugin); - cEPGMapping *oldmap=baseplugin->EPGMapping(channel); + cEPGMapping *oldmap=g->EPGMappings()->GetMap(channel); if (oldmap) { lmap=new cEPGMapping(*oldmap); @@ -873,7 +1037,7 @@ cMenuSetupXmltv2vdrChannelMap::cMenuSetupXmltv2vdrChannelMap(cPluginXmltv2vdr *P } if (!lmap) return; - title=cString::sprintf("%s - %s '%s' : %s",trVDR("Setup"),trVDR("Plugin"), baseplugin->Name(), channel); + title=cString::sprintf("%s - %s '%s' : %s",trVDR("Setup"),trVDR("Plugin"),plugin->Name(), channel); SetTitle(title); flags=lmap->Flags(); @@ -946,7 +1110,7 @@ void cMenuSetupXmltv2vdrChannelMap::output(void) Add(new cMyMenuEditBitItem(tr("video"),&flags,USE_VIDEO),true); Add(new cMyMenuEditBitItem(tr("audio"),&flags,USE_AUDIO),true); - if (baseplugin->EPDir()) + if (g->EPDir()) { Add(new cMyMenuEditBitItem(tr("season and episode"),&flags,USE_SEASON),true); c4=Current(); @@ -1029,7 +1193,7 @@ eOSState cMenuSetupXmltv2vdrChannelMap::ProcessKey(eKeys Key) case kOk: if ((Current()>=cm) && (!hasmaps)) { - return AddSubMenu(new cMenuSetupXmltv2vdrChannelsVDR(baseplugin,this,lmap->ChannelName(),title)); + return AddSubMenu(new cMenuSetupXmltv2vdrChannelsVDR(g,this,lmap->ChannelName(),title)); } else { @@ -1053,18 +1217,18 @@ eOSState cMenuSetupXmltv2vdrChannelMap::ProcessKey(eKeys Key) break; case kGreen: if (Current()>=cm) - return AddSubMenu(new cMenuSetupXmltv2vdrChannelsVDR(baseplugin,this,lmap->ChannelName(),title)); + return AddSubMenu(new cMenuSetupXmltv2vdrChannelsVDR(g,this,lmap->ChannelName(),title)); break; case kBlue: // copy - if ((Current()<cm) && (baseplugin)) + if ((Current()<cm) && (g)) { if (Skins.Message(mtInfo,tr("Copy to all mapped channels?"))==kOk) { - for (int i=0; i<baseplugin->EPGMappingCount();i++) + for (int i=0; i<g->EPGMappings()->Count();i++) { - if (strcmp(baseplugin->EPGMapping(i)->ChannelName(),lmap->ChannelName())) + if (strcmp(g->EPGMappings()->Get(i)->ChannelName(),lmap->ChannelName())) { - Store(baseplugin->EPGMapping(i),false); + Store(g->EPGMappings()->Get(i),false); } } state=osContinue; @@ -1072,14 +1236,14 @@ eOSState cMenuSetupXmltv2vdrChannelMap::ProcessKey(eKeys Key) } break; case kYellow: // reset - if (Current()<cm) + if ((Current()<cm) && (g)) { if (Skins.Message(mtInfo,tr("Reset all channel settings?"))==kOk) { flags=0; - for (int i=0; i<baseplugin->EPGMappingCount();i++) + for (int i=0; i<g->EPGMappings()->Count();i++) { - Store(baseplugin->EPGMapping(i),false); + Store(g->EPGMappings()->Get(i),false); } output(); state=osContinue; @@ -1115,11 +1279,11 @@ bool cMenuSetupXmltv2vdrChannelMap::EPGMappingExists(tChannelID ChannelID) void cMenuSetupXmltv2vdrChannelMap::epgmappingreplace(cEPGMapping *newmapping) { if (!newmapping) return; - cEPGMapping *map=baseplugin->EPGMapping(newmapping->ChannelName()); + cEPGMapping *map=g->EPGMappings()->GetMap(newmapping->ChannelName()); if (!map) { map=new cEPGMapping(*newmapping); - baseplugin->EPGMappingAdd(map); + g->EPGMappings()->Add(map); } else { @@ -1163,11 +1327,11 @@ void cMenuSetupXmltv2vdrChannelMap::Store(cEPGMapping *newmapping, bool replacem // -------------------------------------------------------------------------------------------------------- -cMenuSetupXmltv2vdrChannelsVDR::cMenuSetupXmltv2vdrChannelsVDR(cPluginXmltv2vdr *Plugin, +cMenuSetupXmltv2vdrChannelsVDR::cMenuSetupXmltv2vdrChannelsVDR(cGlobals *Global, cMenuSetupXmltv2vdrChannelMap *Map, const char *Channel, cString Title) :cOsdMenu("",CHNUMWIDTH) { - baseplugin=Plugin; + g=Global; map=Map; SetHelp(NULL,NULL,tr("Button$Choose")); SetTitle(Title); @@ -1191,14 +1355,14 @@ cMenuSetupXmltv2vdrChannelsVDR::cMenuSetupXmltv2vdrChannelsVDR(cPluginXmltv2vdr bool cMenuSetupXmltv2vdrChannelsVDR::epgmappingexists(tChannelID channelid, const char *channel2ignore) { - if (!baseplugin) return true; - if (!baseplugin->EPGMappingCount()) return false; - for (int i=0; i<baseplugin->EPGMappingCount(); i++) + if (!g) return true; + if (!g->EPGMappings()->Count()) return false; + for (int i=0; i<g->EPGMappings()->Count(); i++) { - if (channel2ignore && !strcmp(baseplugin->EPGMapping(i)->ChannelName(),channel2ignore)) continue; - for (int x=0; x<baseplugin->EPGMapping(i)->NumChannelIDs(); x++) + if (channel2ignore && !strcmp(g->EPGMappings()->Get(i)->ChannelName(),channel2ignore)) continue; + for (int x=0; x<g->EPGMappings()->Get(i)->NumChannelIDs(); x++) { - if (baseplugin->EPGMapping(i)->ChannelIDs()[x]==channelid) return true; + if (g->EPGMappings()->Get(i)->ChannelIDs()[x]==channelid) return true; } } return false; @@ -31,12 +31,13 @@ protected: virtual void Store(void); private: cStringList channels; - cPluginXmltv2vdr *baseplugin; + cGlobals *g; cMenuSetupXmltv2vdrChannelSource *cs; cMenuSetupXmltv2vdrChannelMap *cm; int mappingBegin,mappingEnd; int sourcesBegin,sourcesEnd; int mappingEntry; + int orderEntry; int epEntry; eOSState edit(void); void generatesumchannellist(); @@ -54,7 +55,7 @@ public: { cm=NULL; } - cMenuSetupXmltv2vdr(cPluginXmltv2vdr *Plugin); + cMenuSetupXmltv2vdr(cGlobals *Global); ~cMenuSetupXmltv2vdr(); virtual eOSState ProcessKey(eKeys Key); cStringList *ChannelList() @@ -68,7 +69,7 @@ class cMenuSetupXmltv2vdrTextMap : public cMenuSetupPage protected: virtual void Store(void); private: - cPluginXmltv2vdr *baseplugin; + cGlobals *g; char country[255]; char year[255]; char originaltitle[255]; @@ -86,7 +87,7 @@ private: char category[255]; char season[255]; char episode[255]; - char episodeoverall[255]; + char episodeoverall[255]; char starrating[255]; char audio[255]; char video[255]; @@ -95,7 +96,24 @@ private: char dolbydigital[255]; char bilingual[255]; public: - cMenuSetupXmltv2vdrTextMap(cPluginXmltv2vdr *Plugin); + cMenuSetupXmltv2vdrTextMap(cGlobals *Global); +}; + +class cMenuSetupXmltv2vdrOrder : public cMenuSetupPage +{ +protected: + virtual void Store(void); + char *order; +private: + cGlobals *g; + void output(void); +public: + cMenuSetupXmltv2vdrOrder(cGlobals *Global); + ~cMenuSetupXmltv2vdrOrder() + { + free(order); + } + virtual eOSState ProcessKey(eKeys Key); }; class cMenuSetupXmltv2vdrChannelSource : public cMenuSetupPage @@ -104,7 +122,7 @@ protected: virtual void Store(void); private: cMenuSetupXmltv2vdr *menu; - cPluginXmltv2vdr *baseplugin; + cGlobals *g; cEPGSource *epgsrc; int *sel; time_t day; @@ -114,7 +132,7 @@ private: char pin[255]; void output(void); public: - cMenuSetupXmltv2vdrChannelSource(cPluginXmltv2vdr *Plugin, cMenuSetupXmltv2vdr *Menu, int Index); + cMenuSetupXmltv2vdrChannelSource(cGlobals *Global, cMenuSetupXmltv2vdr *Menu, int Index); ~cMenuSetupXmltv2vdrChannelSource(); virtual eOSState ProcessKey(eKeys Key); void ClearMenu() @@ -128,7 +146,7 @@ class cMenuSetupXmltv2vdrChannelMap : public cMenuSetupPage protected: virtual void Store(void); private: - cPluginXmltv2vdr *baseplugin; + cGlobals *g; cMenuSetupXmltv2vdr *menu; cEPGMapping *lmap; bool hasmaps; @@ -137,10 +155,10 @@ private: cString title; cOsdItem *option(const char *s, bool yesno); void epgmappingreplace(cEPGMapping *newmapping); - void Store(cEPGMapping *newmapping, bool replacemapping=true); + void Store(cEPGMapping *newmapping, bool replacemapping=true); int c1,c2,c3,c4,cm; public: - cMenuSetupXmltv2vdrChannelMap(cPluginXmltv2vdr *Plugin, cMenuSetupXmltv2vdr *Menu, int Index); + cMenuSetupXmltv2vdrChannelMap(cGlobals *Global, cMenuSetupXmltv2vdr *Menu, int Index); ~cMenuSetupXmltv2vdrChannelMap(); void AddChannel2Map(int ChannelNumber); bool EPGMappingExists(tChannelID ChannelID); @@ -154,11 +172,11 @@ public: class cMenuSetupXmltv2vdrChannelsVDR : public cOsdMenu { private: - cPluginXmltv2vdr *baseplugin; + cGlobals *g; cMenuSetupXmltv2vdrChannelMap *map; bool epgmappingexists(tChannelID channelid, const char *channel2ignore); public: - cMenuSetupXmltv2vdrChannelsVDR(cPluginXmltv2vdr *Plugin, cMenuSetupXmltv2vdrChannelMap *Map, + cMenuSetupXmltv2vdrChannelsVDR(cGlobals *Global, cMenuSetupXmltv2vdrChannelMap *Map, const char *Channel, cString Title); virtual eOSState ProcessKey(eKeys Key); virtual const char *MenuKind() @@ -184,7 +202,7 @@ private: time_t lastrefresh; const cFont *font; public: - cMenuSetupXmltv2vdrLog(cPluginXmltv2vdr *Plugin, cEPGSource *Source); + cMenuSetupXmltv2vdrLog(cEPGSource *Source); virtual const char *MenuKind() { return "MenuLog"; @@ -881,8 +881,42 @@ time_t cEPGSources::NextRunTime() return next; } -void cEPGSources::ReadIn(cGlobals *Global, const char *SourceOrder, - bool Reload) +bool cEPGSources::MoveEPGSource(cGlobals *Global, int From, int To) +{ + if (From==To) return false; + + sqlite3 *db=NULL; + if (sqlite3_open_v2(Global->EPGFile(),&db,SQLITE_OPEN_READWRITE,NULL)==SQLITE_OK) + { + char *sql=NULL; + if (asprintf(&sql,"BEGIN TRANSACTION;" \ + "UPDATE epg SET srcidx=98 WHERE srcidx=%i;" \ + "UPDATE epg SET srcidx=%i WHERE srcidx=%i;" \ + "UPDATE epg SET srcidx=%i WHERE srcidx=98;" \ + "COMMIT;", To, From, To, From)==-1) + { + sqlite3_close(db); + return false; + } + if (sqlite3_exec(db,sql,NULL,NULL,NULL)!=SQLITE_OK) + { + free(sql); + sqlite3_close(db); + return false; + } + free(sql); + } + else + { + return false; + } + sqlite3_close(db); + Global->EPGSources()->Move(From,To); + return true; +} + + +void cEPGSources::ReadIn(cGlobals *Global, bool Reload) { epgsearchexists=Global->EPGSearchExists(); if (Reload) Remove(); @@ -942,8 +976,8 @@ void cEPGSources::ReadIn(cGlobals *Global, const char *SourceOrder, Add(new cEPGSource(EITSOURCE,Global)); } - if (!SourceOrder) return; - char *buf=strdup(SourceOrder); + if (!Global->SrcOrder()) return; + char *buf=strdup(Global->SrcOrder()); if (!buf) return; char *saveptr; char *pch=strtok_r(buf,",",&saveptr); @@ -173,8 +173,7 @@ private: bool epgsearchexists; public: cEPGSources(); - void ReadIn(cGlobals *Global, const char *SourceOrder, - bool Reload=false); + void ReadIn(cGlobals *Global, bool Reload=false); bool RunItNow(); time_t NextRunTime(); bool Exists(const char *Name); @@ -182,6 +181,7 @@ public: cEPGSource *GetSourceDB(const char *EpgFile); int GetSourceIdx(const char *Name); void Remove(); + bool MoveEPGSource(cGlobals *Global, int From, int To); bool EPGSearchExists() { return epgsearchexists; diff --git a/xmltv2vdr.cpp b/xmltv2vdr.cpp index e79d428..2f2ac9e 100644 --- a/xmltv2vdr.cpp +++ b/xmltv2vdr.cpp @@ -225,7 +225,13 @@ cGlobals::cGlobals() epcodeset=NULL; imgdir=NULL; codeset=NULL; + srcorder=NULL; + wakeup=false; + epghandler=NULL; + epgtimer=NULL; + epall=0; epgsearchexists=(cPluginManager::GetPlugin("epgsearch")!=NULL); + order=strdup(GetDefaultOrder()); imgdelafter=30; if (asprintf(&epgfile,"%s/epg.db",VideoDirectory)==-1) {}; @@ -280,11 +286,23 @@ cGlobals::~cGlobals() free(epdir); free(imgdir); free(codeset); + free(order); + free(srcorder); + if (epgtimer) + { + epgtimer->Stop(); + delete epgtimer; + } epgsources.Remove(); epgmappings.Remove(); textmappings.Remove(); } +char *cGlobals::GetDefaultOrder() +{ + return (char *) "LOT,CRS,CAD,ORT,CAT,VID,AUD,SEE,RAT,STR,REV"; +} + void cGlobals::SetImgDir(const char* ImgDir) { if (!ImgDir) return; @@ -704,47 +722,41 @@ cPluginXmltv2vdr::cPluginXmltv2vdr(void) : housekeeping(&g),epgexecutor(g.EPGSou // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT! logfile=NULL; - srcorder=NULL; - epghandler=NULL; - epgtimer=NULL; - epgseasonepisode=NULL; last_maintime_t=0; last_timer_t=last_epcheck_t=last_housetime_t=time(NULL); // start this threads later! - wakeup=0; - insetup=false; - SetEPAll(0); - TEXTMappingAdd(new cTEXTMapping("country",tr("country"))); - TEXTMappingAdd(new cTEXTMapping("year",tr("year"))); - TEXTMappingAdd(new cTEXTMapping("originaltitle",tr("originaltitle"))); - TEXTMappingAdd(new cTEXTMapping("category",tr("category"))); - TEXTMappingAdd(new cTEXTMapping("actor",tr("actor"))); - TEXTMappingAdd(new cTEXTMapping("adapter",tr("adapter"))); - TEXTMappingAdd(new cTEXTMapping("commentator",tr("commentator"))); - TEXTMappingAdd(new cTEXTMapping("composer",tr("composer"))); - TEXTMappingAdd(new cTEXTMapping("director",tr("director"))); - TEXTMappingAdd(new cTEXTMapping("editor",tr("editor"))); - TEXTMappingAdd(new cTEXTMapping("guest",tr("guest"))); - TEXTMappingAdd(new cTEXTMapping("presenter",tr("presenter"))); - TEXTMappingAdd(new cTEXTMapping("producer",tr("producer"))); - TEXTMappingAdd(new cTEXTMapping("writer",tr("writer"))); - TEXTMappingAdd(new cTEXTMapping("video",tr("video"))); - TEXTMappingAdd(new cTEXTMapping("blacknwhite",tr("blacknwhite"))); - TEXTMappingAdd(new cTEXTMapping("audio",tr("audio"))); - TEXTMappingAdd(new cTEXTMapping("dolby",tr("dolby"))); - TEXTMappingAdd(new cTEXTMapping("dolbydigital",tr("dolbydigital"))); - TEXTMappingAdd(new cTEXTMapping("bilingual",tr("bilingual"))); - TEXTMappingAdd(new cTEXTMapping("review",tr("review"))); - TEXTMappingAdd(new cTEXTMapping("starrating",tr("starrating"))); - TEXTMappingAdd(new cTEXTMapping("season",tr("season"))); - TEXTMappingAdd(new cTEXTMapping("episode",tr("episode"))); - TEXTMappingAdd(new cTEXTMapping("episodeoverall",tr("episodeoverall"))); + g.SetEPAll(0); + g.TEXTMappings()->Add(new cTEXTMapping("country",tr("country"))); + g.TEXTMappings()->Add(new cTEXTMapping("year",tr("year"))); + g.TEXTMappings()->Add(new cTEXTMapping("originaltitle",tr("originaltitle"))); + g.TEXTMappings()->Add(new cTEXTMapping("category",tr("category"))); + g.TEXTMappings()->Add(new cTEXTMapping("actor",tr("actor"))); + g.TEXTMappings()->Add(new cTEXTMapping("adapter",tr("adapter"))); + g.TEXTMappings()->Add(new cTEXTMapping("commentator",tr("commentator"))); + g.TEXTMappings()->Add(new cTEXTMapping("composer",tr("composer"))); + g.TEXTMappings()->Add(new cTEXTMapping("director",tr("director"))); + g.TEXTMappings()->Add(new cTEXTMapping("editor",tr("editor"))); + g.TEXTMappings()->Add(new cTEXTMapping("guest",tr("guest"))); + g.TEXTMappings()->Add(new cTEXTMapping("presenter",tr("presenter"))); + g.TEXTMappings()->Add(new cTEXTMapping("producer",tr("producer"))); + g.TEXTMappings()->Add(new cTEXTMapping("writer",tr("writer"))); + g.TEXTMappings()->Add(new cTEXTMapping("video",tr("video"))); + g.TEXTMappings()->Add(new cTEXTMapping("blacknwhite",tr("blacknwhite"))); + g.TEXTMappings()->Add(new cTEXTMapping("audio",tr("audio"))); + g.TEXTMappings()->Add(new cTEXTMapping("dolby",tr("dolby"))); + g.TEXTMappings()->Add(new cTEXTMapping("dolbydigital",tr("dolbydigital"))); + g.TEXTMappings()->Add(new cTEXTMapping("bilingual",tr("bilingual"))); + g.TEXTMappings()->Add(new cTEXTMapping("review",tr("review"))); + g.TEXTMappings()->Add(new cTEXTMapping("starrating",tr("starrating"))); + g.TEXTMappings()->Add(new cTEXTMapping("season",tr("season"))); + g.TEXTMappings()->Add(new cTEXTMapping("episode",tr("episode"))); + g.TEXTMappings()->Add(new cTEXTMapping("episodeoverall",tr("episodeoverall"))); } cPluginXmltv2vdr::~cPluginXmltv2vdr() { // Clean up after yourself! #if VDRVERSNUM < 10726 && (!EPGHANDLER) - delete epghandler; + delete g.epghandler; #endif } @@ -775,41 +787,6 @@ int cPluginXmltv2vdr::GetLastImportSource() return idx; } -bool cPluginXmltv2vdr::EPGSourceMove(int From, int To) -{ - if (From==To) return false; - - sqlite3 *db=NULL; - if (sqlite3_open_v2(g.EPGFile(),&db,SQLITE_OPEN_READWRITE,NULL)==SQLITE_OK) - { - char *sql=NULL; - if (asprintf(&sql,"BEGIN TRANSACTION;" \ - "UPDATE epg SET srcidx=98 WHERE srcidx=%i;" \ - "UPDATE epg SET srcidx=%i WHERE srcidx=%i;" \ - "UPDATE epg SET srcidx=%i WHERE srcidx=98;" \ - "COMMIT;", To, From, To, From)==-1) - { - sqlite3_close(db); - return false; - } - if (sqlite3_exec(db,sql,NULL,NULL,NULL)!=SQLITE_OK) - { - free(sql); - sqlite3_close(db); - return false; - } - free(sql); - } - else - { - return false; - } - sqlite3_close(db); - g.EPGSources()->Move(From,To); - return true; -} - - const char *cPluginXmltv2vdr::CommandLineHelp(void) { // Return a string that describes all known command line options. @@ -824,7 +801,6 @@ const char *cPluginXmltv2vdr::CommandLineHelp(void) " (default is /var/cache/vdr/epgimages)\n" " -l FILE --logfile=FILE write trace logs into the given FILE (default is\n" " no trace log\n"; - } bool cPluginXmltv2vdr::ProcessArgs(int argc, char *argv[]) @@ -879,34 +855,25 @@ bool cPluginXmltv2vdr::Start(void) if (g.EPDir()) { isyslog("using dir '%s' (%s) for episodes",g.EPDir(),g.EPCodeset()); - epgtimer = new cEPGTimer(&g); - epgseasonepisode = new cEPGSeasonEpisode(&g); + g.AllocateEPGSeasonThread(); + } + if (g.EPAll()) + { + g.AllocateEPGTimerThread(); } if (g.ImgDir()) isyslog("using dir '%s' for epgimages (%i)",g.ImgDir(),g.ImgDelAfter()); - ReadInEPGSources(); - epghandler = new cEPGHandler(&g); + g.EPGSources()->ReadIn(&g); + g.epghandler = new cEPGHandler(&g); + g.SetEPAll(g.EPAll()); if (sqlite3_threadsafe()==0) esyslog("sqlite3 not threadsafe!"); cParse::InitLibXML(); - SetEPAll(epall); return true; } void cPluginXmltv2vdr::Stop(void) { // Stop any background activities the plugin is performing. - if (epgtimer) - { - epgtimer->Stop(); - delete epgtimer; - epgtimer=NULL; - } - if (epgseasonepisode) - { - epgseasonepisode->Stop(); - delete epgseasonepisode; - epgseasonepisode=NULL; - } epgexecutor.Stop(); housekeeping.Stop(); cParse::CleanupLibXML(); @@ -915,11 +882,6 @@ void cPluginXmltv2vdr::Stop(void) free(logfile); logfile=NULL; } - if (srcorder) - { - free(srcorder); - srcorder=NULL; - } } void cPluginXmltv2vdr::Housekeeping(void) @@ -954,15 +916,15 @@ void cPluginXmltv2vdr::MainThreadHook(void) /* if (now>=(last_epcheck_t+900)) { - if (epgseasonepisode) epgseasonepisode->Start(); + if (g.EPGSeasonEpisode()) g.EPGSeasonEpisode()->Start(); last_epcheck_t=(now/900)*900; } - */ - if (epall) + */ + if (g.EPAll()) { if (now>=(last_timer_t+600)) { - if (epgtimer) epgtimer->Start(); + if (g.EPGTimer()) g.EPGTimer()->Start(); last_timer_t=(now/600)*600; } } @@ -982,7 +944,7 @@ cString cPluginXmltv2vdr::Active(void) time_t cPluginXmltv2vdr::WakeupTime(void) { // Return custom wakeup time for shutdown script - if (!wakeup) return (time_t) 0; + if (!g.WakeUp()) return (time_t) 0; time_t nextruntime=g.EPGSources()->NextRunTime(); if (nextruntime) nextruntime-=(time_t) 180; #ifdef VDRDBG @@ -1006,7 +968,7 @@ cOsdObject *cPluginXmltv2vdr::MainMenuAction(void) cMenuSetupPage *cPluginXmltv2vdr::SetupMenu(void) { // Return a setup menu in case the plugin supports one. - return new cMenuSetupXmltv2vdr(this); + return new cMenuSetupXmltv2vdr(&g); } bool cPluginXmltv2vdr::SetupParse(const char *Name, const char *Value) @@ -1020,7 +982,7 @@ bool cPluginXmltv2vdr::SetupParse(const char *Name, const char *Value) else if (!strncasecmp(Name,"textmap",7)) { if (strlen(Name)<10) return false; - cTEXTMapping *textmap=TEXTMapping(&Name[8]); + cTEXTMapping *textmap=g.TEXTMappings()->GetMap(&Name[8]); if (textmap) { textmap->ChangeValue(Value); @@ -1032,19 +994,23 @@ bool cPluginXmltv2vdr::SetupParse(const char *Name, const char *Value) } else if (!strcasecmp(Name,"options.epall")) { - epall=atoi(Value); // set value later again in Start() + g.SetEPAll(atoi(Value)); } else if (!strcasecmp(Name,"options.wakeup")) { - wakeup=(bool) atoi(Value); + g.SetWakeUp((bool) atoi(Value)); } else if (!strcasecmp(Name,"options.imgdelafter")) { - SetImgDelAfter(atoi(Value)); + g.SetImgDelAfter(atoi(Value)); + } + else if (!strcasecmp(Name,"options.order")) + { + g.SetOrder(Value); } else if (!strcasecmp(Name,"source.order")) { - srcorder=strdup(Value); + g.SetSrcOrder(Value); } else return false; return true; diff --git a/xmltv2vdr.h b/xmltv2vdr.h index e140160..4da19f9 100644 --- a/xmltv2vdr.h +++ b/xmltv2vdr.h @@ -34,84 +34,24 @@ public: bool Send(const char *format, ...); }; -class cGlobals +class cEPGTimer : public cThread { private: - char *confdir; - char *epgfile; - char *epdir; - char *epcodeset; - char *imgdir; - char *codeset; - bool epgsearchexists; - int imgdelafter; - cEPGMappings epgmappings; - cTEXTMappings textmappings; - cEPGSources epgsources; + cEPGSources *sources; + cEPGMappings *maps; + cImport import; + int epall; public: - cGlobals(); - ~cGlobals(); - bool DBExists(); - cEPGMappings *EPGMappings() - { - return &epgmappings; - } - cTEXTMappings *TEXTMappings() - { - return &textmappings; - } - cEPGSources *EPGSources() - { - return &epgsources; - } - void SetConfDir(const char *ConfDir) - { - free(confdir); - confdir=strdup(ConfDir); - } - const char *ConfDir() - { - return confdir; - } - void SetEPGFile(const char *EPGFile) - { - free(epgfile); - epgfile=strdup(EPGFile); - } - const char *EPGFile() - { - return epgfile; - } - void SetEPDir(const char *EPDir); - const char *EPDir() - { - return epdir; - } - const char *EPCodeset() - { - return epcodeset; - } - const char *Codeset() - { - return codeset; - } - void SetImgDir(const char *ImgDir); - const char *ImgDir() - { - return imgdir; - } - void SetImgDelAfter(int Value) - { - imgdelafter=Value; - } - int ImgDelAfter() + cEPGTimer(cGlobals *Global); + void Stop() { - return imgdelafter; + Cancel(3); } - bool EPGSearchExists() + void SetEPAll(int Value) { - return epgsearchexists; + epall=Value; } + virtual void Action(); }; #if VDRVERSNUM < 10726 && !EPGHANDLER @@ -179,26 +119,6 @@ public: virtual bool SortSchedule(cSchedule *Schedule); }; -class cEPGTimer : public cThread -{ -private: - cEPGSources *sources; - cEPGMappings *maps; - cImport import; - int epall; -public: - cEPGTimer(cGlobals *Global); - void Stop() - { - Cancel(3); - } - void SetEPAll(int Value) - { - epall=Value; - } - virtual void Action(); -}; - class cHouseKeeping : public cThread { private: @@ -226,101 +146,158 @@ public: virtual void Action(); }; -class cPluginXmltv2vdr : public cPlugin +class cGlobals { private: - cGlobals g; - cEPGHandler *epghandler; - cEPGTimer *epgtimer; - cEPGSeasonEpisode *epgseasonepisode; - cHouseKeeping housekeeping; - cEPGExecutor epgexecutor; - time_t last_housetime_t; - time_t last_maintime_t; - time_t last_timer_t; - time_t last_epcheck_t; + char *confdir; + char *epgfile; + char *epdir; + char *epcodeset; + char *imgdir; + char *codeset; + char *order; char *srcorder; int epall; + int imgdelafter; bool wakeup; - bool insetup; - int GetLastImportSource(); + bool epgsearchexists; + cEPGMappings epgmappings; + cTEXTMappings textmappings; + cEPGSources epgsources; + cEPGTimer *epgtimer; + cEPGSeasonEpisode *epgseasonepisode; public: - void SetSetupState(bool Value) + cGlobals(); + ~cGlobals(); + cEPGHandler *epghandler; + bool DBExists(); + char *GetDefaultOrder(); + void AllocateEPGTimerThread() { - insetup=Value; + epgtimer=new cEPGTimer(this); } - void SetEPAll(int Value) + void AllocateEPGSeasonThread() { - epall=Value; - if (epghandler) epghandler->SetEPAll(Value); - if (epgtimer) epgtimer->SetEPAll(Value); + epgseasonepisode=new cEPGSeasonEpisode(this); } - int EPAll() + cEPGSeasonEpisode *EPGSeasonEpisode() { - return epall; + return epgseasonepisode; } - void SetWakeUp(bool Value) + cEPGTimer *EPGTimer() { - wakeup=Value; + return epgtimer; } - bool WakeUp() + cEPGMappings *EPGMappings() { - return wakeup; + return &epgmappings; } - void SetImgDelAfter(int Value) + cTEXTMappings *TEXTMappings() { - g.SetImgDelAfter(Value); + return &textmappings; } - int ImgDelAfter() + cEPGSources *EPGSources() { - return g.ImgDelAfter(); + return &epgsources; } - const char *ImgDir() + void SetConfDir(const char *ConfDir) + { + free(confdir); + confdir=strdup(ConfDir); + } + const char *ConfDir() + { + return confdir; + } + void SetEPGFile(const char *EPGFile) + { + free(epgfile); + epgfile=strdup(EPGFile); + } + const char *EPGFile() { - return g.ImgDir(); + return epgfile; } + void SetEPDir(const char *EPDir); const char *EPDir() { - return g.EPDir(); + return epdir; } - void ReadInEPGSources(bool Reload=false) + const char *EPCodeset() { - g.EPGSources()->ReadIn(&g,srcorder,Reload); + return epcodeset; } - bool EPGSourceMove(int From, int To); - int EPGSourceCount() + const char *Codeset() { - if (!g.EPGSources()->Count()) return 0; - return g.EPGSources()->Count()-1; + return codeset; } - cEPGSource *EPGSource(int Index) + void SetImgDir(const char *ImgDir); + const char *ImgDir() { - return g.EPGSources()->Get(Index); + return imgdir; } - int EPGMappingCount() + void SetImgDelAfter(int Value) { - return g.EPGMappings()->Count(); + imgdelafter=Value; } - cEPGMapping *EPGMapping(int Index) + int ImgDelAfter() { - return g.EPGMappings()->Get(Index); + return imgdelafter; } - cEPGMapping *EPGMapping(const char *ChannelName) + void SetSrcOrder(const char *NewOrder) { - return g.EPGMappings()->GetMap(ChannelName); + free(srcorder); + srcorder=strdup(NewOrder); } - void EPGMappingAdd(cEPGMapping *Map) + const char *SrcOrder() { - g.EPGMappings()->Add(Map); + return srcorder; } - cTEXTMapping *TEXTMapping(const char *Name) + void SetOrder(const char *NewOrder) { - return g.TEXTMappings()->GetMap(Name); + free(order); + order=strdup(NewOrder); } - void TEXTMappingAdd(cTEXTMapping *TextMap) + const char *Order() + { + return order; + } + bool EPGSearchExists() { - g.TEXTMappings()->Add(TextMap); + return epgsearchexists; + } + void SetEPAll(int Value) + { + epall=Value; + if (epghandler) epghandler->SetEPAll(Value); + if (epgtimer) epgtimer->SetEPAll(Value); } + int EPAll() + { + return epall; + } + void SetWakeUp(bool Value) + { + wakeup=Value; + } + bool WakeUp() + { + return wakeup; + } +}; + +class cPluginXmltv2vdr : public cPlugin +{ +private: + cGlobals g; + cHouseKeeping housekeeping; + cEPGExecutor epgexecutor; + time_t last_housetime_t; + time_t last_maintime_t; + time_t last_timer_t; + time_t last_epcheck_t; + int GetLastImportSource(); +public: cPluginXmltv2vdr(void); virtual ~cPluginXmltv2vdr(); virtual const char *Version(void) |
