summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--import.cpp4
-rw-r--r--parse.cpp2
-rw-r--r--po/de_DE.po8
-rw-r--r--po/it_IT.po8
-rw-r--r--setup.cpp9
-rw-r--r--setup.h1
-rw-r--r--xmltv2vdr.cpp158
-rw-r--r--xmltv2vdr.h28
8 files changed, 175 insertions, 43 deletions
diff --git a/import.cpp b/import.cpp
index 4d9360a..a63e3e9 100644
--- a/import.cpp
+++ b/import.cpp
@@ -278,7 +278,7 @@ bool cImport::WasChanged(cEvent* Event)
void cImport::LinkPictures(const char *Source, cXMLTVStringList *Pics, tEventID DestID)
{
// source-pics are located in /var/lib/epgsources/%SOURCE%-img/
- // dest-pics are located in /var/cache/vdr/epgimages
+ // dest-pics are located in imgdir (default /var/cache/vdr/epgimages)
for (int i=0; i<Pics->Size(); i++)
{
@@ -1468,7 +1468,7 @@ cImport::cImport(cGlobals *Global)
epgfile=Global->EPGFile();
codeset=Global->Codeset();
imgdir=Global->ImgDir();
- pendingtransaction=false;
+ pendingtransaction=false;
conv = new cCharSetConv("UTF-8",codeset);
epdir=Global->EPDir();
diff --git a/parse.cpp b/parse.cpp
index 8e1ab03..14371dc 100644
--- a/parse.cpp
+++ b/parse.cpp
@@ -101,7 +101,7 @@ void cParse::RemoveNonAlphaNumeric(char *String)
{
if (!String) return;
- // remove " Teil "
+ // remove " Teil " (special for .episodes files)
int len=strlen(String);
char *p=strstr(String," Teil ");
if (p)
diff --git a/po/de_DE.po b/po/de_DE.po
index 7651c4f..65e84a1 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-04 18:58+0200\n"
+"POT-Creation-Date: 2012-05-08 00:36+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"
@@ -25,6 +25,12 @@ msgstr " Kurztext/Titel von Liste übernehmen"
msgid "automatic wakeup"
msgstr "automatisch Aufwachen"
+msgid "delete pics after (days)"
+msgstr "Bilder löschen nach (Tagen)"
+
+msgid "never"
+msgstr "nie"
+
msgid "text mapping"
msgstr "Textzuordnungen"
diff --git a/po/it_IT.po b/po/it_IT.po
index 5468f97..fc7dad5 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-04 18:58+0200\n"
+"POT-Creation-Date: 2012-05-08 00:36+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"
@@ -28,6 +28,12 @@ msgstr ""
msgid "automatic wakeup"
msgstr "Risveglio automatico"
+msgid "delete pics after (days)"
+msgstr ""
+
+msgid "never"
+msgstr ""
+
msgid "text mapping"
msgstr "Mappatura testo"
diff --git a/setup.cpp b/setup.cpp
index ef008a4..c4a76a8 100644
--- a/setup.cpp
+++ b/setup.cpp
@@ -61,6 +61,7 @@ cMenuSetupXmltv2vdr::cMenuSetupXmltv2vdr(cPluginXmltv2vdr *Plugin)
sourcesBegin=sourcesEnd=mappingBegin=mappingEnd=mappingEntry=0;
epall=(unsigned int) baseplugin->EPAll();
wakeup=(int) baseplugin->WakeUp();
+ imgdelafter=baseplugin->ImgDelAfter();
cs=NULL;
cm=NULL;
Output();
@@ -98,6 +99,10 @@ void cMenuSetupXmltv2vdr::Output(void)
}
}
Add(new cMenuEditBoolItem(tr("automatic wakeup"),&wakeup),true);
+ if (baseplugin->ImgDir())
+ {
+ Add(new cMenuEditIntItem(tr("delete pics after (days)"),&imgdelafter,0,365,tr("never")),true);
+ }
Add(new cOsdItem(tr("text mapping")),true);
mappingEntry=Current();
@@ -219,8 +224,10 @@ void cMenuSetupXmltv2vdr::Store(void)
SetupStore("options.epall",epall);
SetupStore("options.wakeup",wakeup);
+ SetupStore("options.imgdelafter",imgdelafter);
baseplugin->SetEPAll(epall);
baseplugin->SetWakeUp((bool) wakeup);
+ baseplugin->SetImgDelAfter(imgdelafter);
}
eOSState cMenuSetupXmltv2vdr::edit()
@@ -815,7 +822,7 @@ void cMenuSetupXmltv2vdrChannelSource::Store(void)
if (epgsrc->NeedPin())
epgsrc->ChangePin(pin);
if (epgsrc->HasPics())
- epgsrc->ChangePics(usepics);
+ epgsrc->ChangePics(usepics);
epgsrc->Store();
}
diff --git a/setup.h b/setup.h
index 60ddd60..a738ce9 100644
--- a/setup.h
+++ b/setup.h
@@ -42,6 +42,7 @@ private:
void generatesumchannellist();
unsigned int epall;
int wakeup;
+ int imgdelafter;
public:
void Output(void);
static cOsdItem *NewTitle(const char *s);
diff --git a/xmltv2vdr.cpp b/xmltv2vdr.cpp
index 3b4c00b..957c693 100644
--- a/xmltv2vdr.cpp
+++ b/xmltv2vdr.cpp
@@ -135,6 +135,7 @@ cGlobals::cGlobals()
epcodeset=NULL;
imgdir=NULL;
codeset=NULL;
+ imgdelafter=30;
if (asprintf(&epgfile,"%s/epg.db",VideoDirectory)==-1) {};
if (asprintf(&imgdir,"%s","/var/cache/vdr/epgimages")==-1) {};
@@ -215,6 +216,7 @@ void cGlobals::SetEPDir(const char* EPDir)
return;
}
free(epdir);
+ epcodeset=codeset;
epdir=strdup(EPDir);
if (!epdir) return;
epcodeset=strchr((char *) epdir,',');
@@ -228,6 +230,15 @@ void cGlobals::SetEPDir(const char* EPDir)
}
}
+bool cGlobals::DBExists()
+{
+ if (!epgfile) return true; // is this safe?
+ struct stat statbuf;
+ if (stat(epgfile,&statbuf)==-1) return false; // no database
+ if (!statbuf.st_size) return false; // no database
+ return true;
+}
+
// -------------------------------------------------------------
cEPGHandler::cEPGHandler(cGlobals* Global): import(Global)
@@ -488,17 +499,87 @@ void cEPGTimer::Action()
cHouseKeeping::cHouseKeeping(cGlobals *Global): cThread("xmltv2vdr housekeeping")
{
- epgfile=Global->EPGFile();
+ global=Global;
+}
+
+int cHouseKeeping::checkdir(const char* imgdir, int age)
+{
+ if (age<=0) return 0;
+ DIR *dir=opendir(imgdir);
+ if (!dir) return 0;
+ time_t tmin=time(NULL);
+ tmin-=(age*86400);
+ struct dirent dirent_buf,*dirent;
+ int cnt=0;
+ while (readdir_r(dir,&dirent_buf,&dirent)==0)
+ {
+ if (!dirent) break;
+ if (dirent->d_name[0]=='.') continue;
+ if ((dirent->d_type==DT_LNK) || (dirent->d_type==DT_REG))
+ {
+ struct stat statbuf;
+ char *fpath;
+ if (asprintf(&fpath,"%s/%s",imgdir,dirent->d_name)!=-1)
+ {
+ if (stat(fpath,&statbuf)!=-1)
+ {
+ if (statbuf.st_mtime<tmin)
+ {
+ if (unlink(fpath)!=-1) cnt++;
+ }
+ }
+ free(fpath);
+ }
+ }
+ }
+ closedir(dir);
+ return cnt;
+}
+
+int sd_select(const dirent* dirent)
+{
+ if (!dirent) return 0;
+ if (strstr(dirent->d_name,"-img"))
+ {
+ if (dirent->d_type==DT_DIR) return 1;
+ }
+ return 0;
}
void cHouseKeeping::Action()
{
+ if (global->ImgDelAfter())
+ {
+ int cnt=checkdir(global->ImgDir(),global->ImgDelAfter());
+ struct dirent **names;
+ int ret=scandir("/var/lib/epgsources",&names,sd_select,alphasort);
+ if (ret>0)
+ {
+ for (int i=0; i<ret; i++)
+ {
+ char *newdir;
+ if (asprintf(&newdir,"/var/lib/epgsources/%s",names[i]->d_name)!=-1)
+ {
+ cnt+=checkdir(newdir,global->ImgDelAfter());
+ free(newdir);
+ }
+ }
+ free(names);
+ }
+ if (cnt)
+ {
+ isyslog("removed %i pics/links",cnt);
+ }
+ }
+
+ if (!global->DBExists()) return;
+
cSchedulesLock schedulesLock(true,10); // wait 10ms for lock!
const cSchedules *schedules = cSchedules::Schedules(schedulesLock);
if (!schedules) return;
sqlite3 *db=NULL;
- if (sqlite3_open_v2(epgfile,&db,SQLITE_OPEN_READWRITE,NULL)==SQLITE_OK)
+ if (sqlite3_open_v2(global->EPGFile(),&db,SQLITE_OPEN_READWRITE,NULL)==SQLITE_OK)
{
char *sql;
if (asprintf(&sql,"delete from epg where ((starttime+duration) < %li)",time(NULL))!=-1)
@@ -722,7 +803,7 @@ bool cPluginXmltv2vdr::Start(void)
epgtimer = new cEPGTimer(&g);
epgseasonepisode = new cEPGSeasonEpisode(&g);
}
- if (g.ImgDir()) isyslog("using dir '%s' for epgimages",g.ImgDir());
+ if (g.ImgDir()) isyslog("using dir '%s' for epgimages (%i)",g.ImgDir(),g.ImgDelAfter());
ReadInEPGSources();
epghandler = new cEPGHandler(&g);
@@ -771,14 +852,7 @@ void cPluginXmltv2vdr::Housekeeping(void)
{
if (!housekeeping.Active())
{
- struct stat statbuf;
- if (stat(g.EPGFile(),&statbuf)!=-1)
- {
- if (statbuf.st_size)
- {
- housekeeping.Start();
- }
- }
+ housekeeping.Start();
}
last_housetime_t=(now / 3600)*3600;
}
@@ -833,9 +907,9 @@ time_t cPluginXmltv2vdr::WakeupTime(void)
if (!wakeup) return (time_t) 0;
time_t nextruntime=g.EPGSources()->NextRunTime();
if (nextruntime) nextruntime-=(time_t) 180;
- #ifdef VDRDBG
+#ifdef VDRDBG
tsyslog("reporting wakeuptime %s",ctime(&nextruntime));
- #endif
+#endif
return nextruntime;
}
@@ -886,6 +960,10 @@ bool cPluginXmltv2vdr::SetupParse(const char *Name, const char *Value)
{
wakeup=(bool) atoi(Value);
}
+ else if (!strcasecmp(Name,"options.imgdelafter"))
+ {
+ SetImgDelAfter(atoi(Value));
+ }
else if (!strcasecmp(Name,"source.order"))
{
srcorder=strdup(Value);
@@ -909,6 +987,8 @@ const char **cPluginXmltv2vdr::SVDRPHelpPages(void)
" Start epg update from db, with force download data before\n",
"DELD\n"
" Delete xmltv2vdr epg database (triggers update)\n",
+ "HOUS\n"
+ " Start housekeeping manually\n",
NULL
};
return HelpPages;
@@ -918,20 +998,20 @@ cString cPluginXmltv2vdr::SVDRPCommand(const char *Command, const char *Option,
{
// Process SVDRP commands
- cString output;
+ cString output=NULL;
if (!strcasecmp(Command,"UPDT"))
{
if (!g.EPGSources()->Count())
{
ReplyCode=550;
- output="No epg sources installed\n";
+ output="no epg sources installed\n";
}
else
{
if (epgexecutor.Active())
{
ReplyCode=550;
- output="Update already running\n";
+ output="update already running\n";
}
else
{
@@ -946,42 +1026,52 @@ cString cPluginXmltv2vdr::SVDRPCommand(const char *Command, const char *Option,
if (epgexecutor.Start())
{
ReplyCode=250;
- output="Update started\n";
+ output="update started\n";
}
else
{
ReplyCode=550;
- output="Failed to start update\n";
+ output="failed to start update\n";
}
}
}
}
- else
- if (!strcasecmp(Command,"DELD"))
+ if (!strcasecmp(Command,"DELD"))
+ {
+ if (g.EPGFile())
{
- if (g.EPGFile())
+ if (unlink(g.EPGFile())==-1)
{
- if (unlink(g.EPGFile())==-1)
- {
- ReplyCode=550;
- output="failed to delete database\n";
- }
- else
- {
- ReplyCode=250;
- output="database deleted\n";
- }
+ ReplyCode=550;
+ output="failed to delete database\n";
}
else
{
- ReplyCode=550;
- output="epgfile parameter not set\n";
+ ReplyCode=250;
+ output="database deleted\n";
}
}
else
{
- return NULL;
+ ReplyCode=550;
+ output="epgfile parameter not set\n";
}
+ }
+ if (!strcasecmp(Command,"HOUS"))
+ {
+ if (!epgexecutor.Active() && !housekeeping.Active())
+ {
+ housekeeping.Start();
+ last_housetime_t=(time(NULL) / 3600)*3600;
+ ReplyCode=250;
+ output="housekeeping started\n";
+ }
+ else
+ {
+ ReplyCode=550;
+ output="system busy\n";
+ }
+ }
return output;
}
diff --git a/xmltv2vdr.h b/xmltv2vdr.h
index e06c37b..9e71dd3 100644
--- a/xmltv2vdr.h
+++ b/xmltv2vdr.h
@@ -21,7 +21,7 @@
#define UNUSED(x) x
#endif
-static const char *VERSION = "0.1.1";
+static const char *VERSION = "0.2.0pre";
static const char *DESCRIPTION = trNOOP("Imports xmltv epg into vdr");
int ioprio_set(int which, int who, int ioprio);
@@ -35,13 +35,14 @@ private:
char *epcodeset;
char *imgdir;
char *codeset;
+ int imgdelafter;
cEPGMappings epgmappings;
cTEXTMappings textmappings;
cEPGSources epgsources;
public:
-
cGlobals();
~cGlobals();
+ bool DBExists();
cEPGMappings *EPGMappings()
{
return &epgmappings;
@@ -90,6 +91,14 @@ public:
{
return imgdir;
}
+ void SetImgDelAfter(int Value)
+ {
+ imgdelafter=Value;
+ }
+ int ImgDelAfter()
+ {
+ return imgdelafter;
+ }
};
#if VDRVERSNUM < 10726 && !EPGHANDLER
@@ -180,7 +189,8 @@ public:
class cHouseKeeping : public cThread
{
private:
- const char *epgfile;
+ cGlobals *global;
+ int checkdir(const char *imgdir, int age);
public:
cHouseKeeping(cGlobals *Global);
void Stop()
@@ -244,6 +254,18 @@ public:
{
return wakeup;
}
+ void SetImgDelAfter(int Value)
+ {
+ g.SetImgDelAfter(Value);
+ }
+ int ImgDelAfter()
+ {
+ return g.ImgDelAfter();
+ }
+ const char *ImgDir()
+ {
+ return g.ImgDir();
+ }
const char *EPDir()
{
return g.EPDir();