diff options
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | maps.h | 33 | ||||
-rw-r--r-- | parse.cpp | 89 | ||||
-rw-r--r-- | parse.h | 2 | ||||
-rw-r--r-- | po/de_DE.po | 20 | ||||
-rw-r--r-- | setup.cpp | 85 | ||||
-rw-r--r-- | setup.h | 1 | ||||
-rw-r--r-- | xmltv2vdr.cpp | 31 |
8 files changed, 185 insertions, 84 deletions
@@ -18,7 +18,7 @@ VERSION = $(shell grep 'static const char \*VERSION *=' $(PLUGIN).h | awk '{ pri ### The C++ compiler and options: CXX ?= g++ -CXXFLAGS ?= -fPIC -g -O0 -Wall -Wextra -pedantic -Woverloaded-virtual -Wno-parentheses +CXXFLAGS ?= -fPIC -g -O2 -Wall -Wextra -pedantic -Woverloaded-virtual -Wno-parentheses PKG-CONFIG ?= pkg-config ### The directory environment: @@ -27,6 +27,10 @@ VDRDIR = ../../.. LIBDIR = ../../lib TMPDIR = /tmp +### Make sure that necessary options are included: + +-include $(VDRDIR)/Make.global + ### Allow user defined options to overwrite defaults: -include $(VDRDIR)/Make.config @@ -85,7 +89,7 @@ I18Npot = $(PODIR)/$(PLUGIN).pot %.mo: %.po msgfmt -c -o $@ $< -$(I18Npot): $(wildcard *.cpp) +$(I18Npot): $(wildcard *.cpp *.h) xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='<see README>' -o $@ $^ %.po: $(I18Npot) @@ -17,22 +17,27 @@ // Bit 24-30 OPT_ flags // Bit 31 always zero -#define USE_NOTHING 0 +#define USE_NOTHING 0 -#define USE_SHORTTEXT 0x1 -#define USE_LONGTEXT 0x2 -#define USE_COUNTRYDATE 0x4 -#define USE_ORIGTITLE 0x8 -#define USE_CATEGORY 0x10 -#define USE_CREDITS 0x20 -#define USE_RATING 0x40 -#define USE_REVIEW 0x80 -#define USE_VIDEO 0x100 -#define USE_AUDIO 0x200 +#define USE_SHORTTEXT 0x1 +#define USE_LONGTEXT 0x2 +#define USE_COUNTRYDATE 0x4 +#define USE_ORIGTITLE 0x8 +#define USE_CATEGORY 0x10 +#define USE_CREDITS 0x20 +#define USE_RATING 0x40 +#define USE_REVIEW 0x80 +#define USE_VIDEO 0x100 +#define USE_AUDIO 0x200 -#define OPT_MERGELTEXT 0x10000000 -#define OPT_VPS 0x20000000 -#define OPT_APPEND 0x40000000 +#define CREDITS_ACTORS 0x100000 +#define CREDITS_DIRECTOR 0x200000 +#define CREDITS_OTHER 0x400000 +#define CREDITS_ACTORS_LIST 0x800000 + +#define OPT_MERGELTEXT 0x10000000 +#define OPT_VPS 0x20000000 +#define OPT_APPEND 0x40000000 class cTEXTMapping : public cListObject { @@ -8,7 +8,7 @@ #include <string.h> #include <stdlib.h> #include <limits.h> - +#include <ctype.h> #include <fcntl.h> #include <unistd.h> @@ -425,29 +425,47 @@ bool cParse::FetchEvent(xmlNodePtr enode) xmlFree(content); } } - else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "country"))) + else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "credits"))) + { + } + else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "date"))) { xmlChar *content=xmlNodeListGetString(node->doc,node->xmlChildrenNode,1); if (content) { - xevent.SetCountry(conv->Convert((const char *) content)); + xevent.SetYear(atoi((const char *) content)); xmlFree(content); } } - else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "date"))) + else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "category"))) { + // what to do with attribute lang? xmlChar *content=xmlNodeListGetString(node->doc,node->xmlChildrenNode,1); if (content) { - xevent.SetYear(atoi((const char *) content)); + if (isdigit(content[0])) + { + xevent.SetEventID(atoi((const char *) content)); + } + else + { + } xmlFree(content); } } - else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "category"))) + else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "country"))) { - // attribute lang + xmlChar *content=xmlNodeListGetString(node->doc,node->xmlChildrenNode,1); + if (content) + { + xevent.SetCountry(conv->Convert((const char *) content)); + xmlFree(content); + } } - else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "credits"))) + else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "video"))) + { + } + else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "audio"))) { } else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "rating"))) @@ -455,15 +473,26 @@ bool cParse::FetchEvent(xmlNodePtr enode) xmlChar *system=xmlGetProp(node,(const xmlChar *) "system"); if (system) { - xmlChar *content=xmlNodeListGetString(node->doc,node->xmlChildrenNode,1); - if (content) + xmlNodePtr vnode=node->xmlChildrenNode; + while (vnode) { - const char *crating=strdup(conv->Convert((const char *) content)); - const char *csystem=strdup(conv->Convert((const char *) system)); - xevent.SetRating(csystem,crating); - if (crating) free((void *) crating); - if (csystem) free((void *) csystem); - xmlFree(content); + if (vnode->type==XML_ELEMENT_NODE) + { + if ((!xmlStrcasecmp(vnode->name, (const xmlChar *) "value"))) + { + xmlChar *content=xmlNodeListGetString(vnode->doc,vnode->xmlChildrenNode,1); + if (content) + { + const char *crating=strdup(conv->Convert((const char *) content)); + const char *csystem=strdup(conv->Convert((const char *) system)); + xevent.SetRating(csystem,crating); + if (crating) free((void *) crating); + if (csystem) free((void *) csystem); + xmlFree(content); + } + } + } + vnode=vnode->next; } xmlFree(system); } @@ -482,12 +511,6 @@ bool cParse::FetchEvent(xmlNodePtr enode) xmlFree(type); } } - else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "video"))) - { - } - else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "audio"))) - { - } else { esyslog("xmltv2vdr: '%s' unknown element %s, please report!",name,node->name); @@ -542,11 +565,11 @@ bool cParse::Process(char *buffer, int bufsize) { if ((!xmlStrcasecmp(node->name, (const xmlChar *) "programme"))) { - xmlChar *channelid=xmlGetProp(node,(const xmlChar *) "channelid"); + xmlChar *channelid=xmlGetProp(node,(const xmlChar *) "channel"); cEPGMapping *map=NULL; if (channelid && (map=EPGMapping((const char *) channelid))) { - time_t end=begin+86000*map->Days(); + time_t end=begin+(86000*map->Days())+3600; // 1 hour overlap xmlChar *start,*stop; time_t starttime=(time_t) 0; time_t stoptime=(time_t) 0; @@ -570,14 +593,6 @@ bool cParse::Process(char *buffer, int bufsize) { xevent.Clear(); - xmlChar *eventid; - eventid=xmlGetProp(node,(const xmlChar *) "eventid"); - if (eventid) - { - xevent.SetEventID(atoi((const char *) eventid)); - xmlFree(eventid); - } - xmlChar *vpsstart=xmlGetProp(node,(const xmlChar *) "vps-start"); if (vpsstart) { @@ -627,6 +642,16 @@ bool cParse::Process(char *buffer, int bufsize) return true; } +void cParse::InitLibXML() +{ + xmlInitParser(); +} + +void cParse::CleanupLibXML() +{ + xmlCleanupParser(); +} + cParse::cParse(const char *Name, cEPGMappings *Maps, cTEXTMappings *Texts) { #if VDRVERSNUM < 10701 || defined(__FreeBSD__) @@ -141,6 +141,8 @@ public: cParse(const char *Name, cEPGMappings *Maps, cTEXTMappings *Texts); ~cParse(); bool Process(char *buffer, int bufsize); + static void InitLibXML(); + static void CleanupLibXML(); }; #endif diff --git a/po/de_DE.po b/po/de_DE.po index 87313cf..56c7aeb 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: 2010-12-28 18:28+0100\n" +"POT-Creation-Date: 2011-01-03 20:10+0100\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" @@ -126,12 +126,24 @@ msgstr "Kurztext" msgid "long text" msgstr "Langtext" -msgid "merge long texts" -msgstr "Langtexte zusammenführen" +msgid " merge long texts" +msgstr " Langtexte zusammenführen" msgid "category" msgstr "Kategorie" +msgid " actors" +msgstr " Darsteller" + +msgid " add in a list" +msgstr " in einer Liste hinzufügen" + +msgid " director" +msgstr " Regisseur" + +msgid " other crew" +msgstr " Sonstige" + msgid "rating" msgstr "Freigabe" @@ -162,3 +174,5 @@ msgstr "Auswahl" msgid "xmltv2vdr plugin still working" msgstr "xmltv2vdr plugin ist noch aktiv" +msgid "Imports xmltv epg into vdr" +msgstr "Importiert xmltv epg in den VDR" @@ -699,6 +699,7 @@ cMenuSetupXmltv2vdrChannelMap::cMenuSetupXmltv2vdrChannelMap(cPluginXmltv2vdr *P flags=map->Flags(); days=map->Days(); daysmax=getdaysmax(); + c1=c2=c3=c4=cm=0; output(); } @@ -758,56 +759,77 @@ void cMenuSetupXmltv2vdrChannelMap::output(void) int current=Current(); Clear(); + cOsdItem *first=newtitle(tr("epg source channel options")); + Add(first,true); - Add(newtitle(tr("epg source channel options"))); - - Add(new cMenuEditIntItem(tr("days in advance"),&days,1,daysmax)); - Add(new cMenuEditBitItem(tr("type of processing"),&flags,OPT_APPEND,tr("merge"),tr("append"))); - + Add(new cMenuEditIntItem(tr("days in advance"),&days,1,daysmax),true); + Add(new cMenuEditBitItem(tr("type of processing"),&flags,OPT_APPEND,tr("merge"),tr("append")),true); + c1=Current(); if ((flags & OPT_APPEND)!=OPT_APPEND) { - Add(new cMenuEditBitItem(tr("short text"),&flags,USE_SHORTTEXT)); - Add(new cMenuEditBitItem(tr("long text"),&flags,USE_LONGTEXT)); + Add(new cMenuEditBitItem(tr("short text"),&flags,USE_SHORTTEXT),true); + Add(new cMenuEditBitItem(tr("long text"),&flags,USE_LONGTEXT),true); + c2=Current(); if ((flags & USE_LONGTEXT)==USE_LONGTEXT) { - Add(new cMenuEditBitItem(tr("merge long texts"),&flags,OPT_MERGELTEXT)); - } - else - { - Add(option(tr("merge long texts"),false)); + Add(new cMenuEditBitItem(tr(" merge long texts"),&flags,OPT_MERGELTEXT),true); } } else { - Add(option(tr("short text"),true)); - Add(option(tr("long text"),true)); - Add(option(tr("merge long texts"),false)); + Add(option(tr("short text"),true),true); + Add(option(tr("long text"),true),true); + Add(option(tr(" merge long texts"),false),true); + } + Add(new cMenuEditBitItem(tr("country and date"),&flags,USE_COUNTRYDATE),true); + Add(new cMenuEditBitItem(tr("original title"),&flags,USE_ORIGTITLE),true); + Add(new cMenuEditBitItem(tr("category"),&flags,USE_CATEGORY),true); + Add(new cMenuEditBitItem(tr("credits"),&flags,USE_CREDITS),true); + c3=Current(); + if ((flags & USE_CREDITS)==USE_CREDITS) + { + Add(new cMenuEditBitItem(tr(" actors"),&flags,CREDITS_ACTORS),true); + c4=Current(); + if ((flags & CREDITS_ACTORS)==CREDITS_ACTORS) + Add(new cMenuEditBitItem(tr(" add in a list"),&flags,CREDITS_ACTORS_LIST),true); + Add(new cMenuEditBitItem(tr(" director"),&flags,CREDITS_DIRECTOR),true); + Add(new cMenuEditBitItem(tr(" other crew"),&flags,CREDITS_OTHER),true); } - Add(new cMenuEditBitItem(tr("country and date"),&flags,USE_COUNTRYDATE)); - Add(new cMenuEditBitItem(tr("original title"),&flags,USE_ORIGTITLE)); - Add(new cMenuEditBitItem(tr("category"),&flags,USE_CATEGORY)); - Add(new cMenuEditBitItem(tr("credits"),&flags,USE_CREDITS)); - Add(new cMenuEditBitItem(tr("rating"),&flags,USE_RATING)); - Add(new cMenuEditBitItem(tr("review"),&flags,USE_REVIEW)); - Add(new cMenuEditBitItem(tr("video"),&flags,USE_VIDEO)); - Add(new cMenuEditBitItem(tr("audio"),&flags,USE_AUDIO)); - Add(new cMenuEditBitItem(tr("vps"),&flags,OPT_VPS)); + + Add(new cMenuEditBitItem(tr("rating"),&flags,USE_RATING),true); + Add(new cMenuEditBitItem(tr("review"),&flags,USE_REVIEW),true); + Add(new cMenuEditBitItem(tr("video"),&flags,USE_VIDEO),true); + Add(new cMenuEditBitItem(tr("audio"),&flags,USE_AUDIO),true); + Add(new cMenuEditBitItem(tr("vps"),&flags,OPT_VPS),true); hasmaps=false; - Add(newtitle(tr("epg source channel mappings"))); + Add(newtitle(tr("epg source channel mappings")),true); for (int i=0; i<map->NumChannelIDs(); i++) { cChannel *chan=Channels.GetByChannelID(map->ChannelIDs()[i]); if (chan) { cString buffer = cString::sprintf("%-*i %s", CHNUMWIDTH, chan->Number(),chan->Name()); - Add(new cOsdItem(buffer)); + Add(new cOsdItem(buffer),true); + if (!hasmaps) cm=Current(); hasmaps=true; } } - if (!hasmaps) Add(new cOsdItem(tr("none"))); - if (current!=-1) for (int i=1; i<=current; i++) CursorDown(); + if (!hasmaps) + { + Add(new cOsdItem(tr("none")),true); + cm=Current(); + } + if (current==-1) + { + SetCurrent(first); + CursorDown(); + } + else + { + SetCurrent(Get(current)); + } Display(); } @@ -822,14 +844,15 @@ eOSState cMenuSetupXmltv2vdrChannelMap::ProcessKey (eKeys Key) { case kLeft: case kRight: - if ((Current()==2) || (Current()==4)) output(); + if ((Current()==c1) || (Current()==c2) || + (Current()==c3) || (Current()==c4)) output(); break; case kDown: - if (Current()>=16) + if (Current()>=cm) SetHelp(tr("unmap"),tr("map")); break; case kUp: - if (Current()<16) + if (Current()<cm) SetHelp(NULL,NULL); default: break; @@ -96,6 +96,7 @@ private: cOsdItem *newtitle (const char *s); cOsdItem *option(const char *s, bool yesno); void epgmappingreplace(cEPGMapping *newmapping); + int c1,c2,c3,c4,cm; public: cMenuSetupXmltv2vdrChannelMap(cPluginXmltv2vdr *Plugin, cMenuSetupXmltv2vdr *Menu, int Index); ~cMenuSetupXmltv2vdrChannelMap(); diff --git a/xmltv2vdr.cpp b/xmltv2vdr.cpp index 1b2f589..a0d2fe9 100644 --- a/xmltv2vdr.cpp +++ b/xmltv2vdr.cpp @@ -406,11 +406,36 @@ void cPluginXmltv2vdr::ReadInEPGSources(bool Reload) { if (access(path,R_OK|W_OK)!=-1) { - epgsources.Add(new cEPGSource(dirent->d_name,&epgmappings,&textmappings)); + int fd=open(path,O_RDONLY); + if (fd!=-1) + { + char id[5]; + if (read(fd,id,4)!=4) + { + esyslog("xmltv2vdr: cannot read config file '%s'",dirent->d_name); + } + else + { + id[4]=0; + if (!strcmp(id,"file") || !strcmp(id,"pipe")) + { + epgsources.Add(new cEPGSource(dirent->d_name,&epgmappings,&textmappings)); + } + else + { + dsyslog("xmltv2vdr: ignoring non config file '%s'",dirent->d_name); + } + close(fd); + } + } + else + { + esyslog("xmltv2vdr: cannot open config file '%s'",dirent->d_name); + } } else { - esyslog("xmltv2vdr: cannot access config file for '%s'",dirent->d_name); + esyslog("xmltv2vdr: cannot access config file '%s'",dirent->d_name); } free(path); } @@ -475,6 +500,7 @@ bool cPluginXmltv2vdr::Initialize(void) bool cPluginXmltv2vdr::Start(void) { // Start any background activities the plugin shall perform. + cParse::InitLibXML(); ReadInEPGSources(); return true; } @@ -485,6 +511,7 @@ void cPluginXmltv2vdr::Stop(void) removeepgsources(); removeepgmappings(); removetextmappings(); + cParse::CleanupLibXML(); } void cPluginXmltv2vdr::Housekeeping(void) |