diff options
author | anbr <vdr07@deltab.de> | 2010-12-21 20:36:58 +0100 |
---|---|---|
committer | anbr <vdr07@deltab.de> | 2010-12-21 20:36:58 +0100 |
commit | 10a33e14d6338ff004410413f6fe52810be43f67 (patch) | |
tree | 6f71b062e9235be1383a9e6c536fea336d400e6c /imagelist.c | |
download | vdr-plugin-dvdswitch-10a33e14d6338ff004410413f6fe52810be43f67.tar.gz vdr-plugin-dvdswitch-10a33e14d6338ff004410413f6fe52810be43f67.tar.bz2 |
release 0.1.0 from http://www.schmidtie.de/download/vdr-dvdswitch-0.1.0.tar.bz20.1.0
Diffstat (limited to 'imagelist.c')
-rw-r--r-- | imagelist.c | 203 |
1 files changed, 203 insertions, 0 deletions
diff --git a/imagelist.c b/imagelist.c new file mode 100644 index 0000000..fd387ff --- /dev/null +++ b/imagelist.c @@ -0,0 +1,203 @@ +#include "imagelist.h" + +cImageList ImageList; + +cImageList::cImageList(void) +{ + Setup = false; +} + +cImageList::~ cImageList(void) +{ +} + +void cImageList::Init(void) +{ + DEBUG("Init ImageList"); + if(!Setup) + { + Add(new cImageListItem((char*)tr("Directory with 'VIDEO_TS' Folder"), + (char*)tr("Directory"), + tDir, + "video_ts", + true)); + Add(new cImageListItem((char*)tr("File with '.iso' Extension"), + (char*)tr("Iso-Image"), + tFile, + ".iso", + true)); + } +} + +void cImageList::AddItem(char *item) +{ + DEBUG("Neues Item soll hinzugefügt werden: %s", item); + + if (!isempty(item)) + { + cTokenizer *token = new cTokenizer(item, "|"); + if(token->Count() == 5) + Add(new cImageListItem(token->GetToken(1), + token->GetToken(2), + (eFileInfo)atoi(token->GetToken(3)), + token->GetToken(4), + atoi(token->GetToken(5)))); + delete(token); + } +} + +void cImageList::AddSetup(char *value) +{ + DEBUG("Erhalte SetupString: %s",value); + + Setup = true; + Clear(); + + if(!isempty(value)) + { + cTokenizer *token = new cTokenizer(value, "@"); + for(int i = 1; i <= token->Count(); i++) + AddItem(token->GetToken(i)); + DELETENULL(token); + } +} + +char *cImageList::GetSetupString(void) +{ + DEBUG("Erstelle SetupString"); + + SString = NULL; + cImageListItem *item = First(); + + while(item) + { + DEBUG("Füge hinzu: %s", item->SaveString()); + SString += item->SaveString(); + SString += "@"; + item = Next(item); + } + + return &SString; +} + +char *cImageList::GetExtensions(void) +{ + DEBUG("Erstelle Liste aller Extensions"); + + Ext = NULL; + cImageListItem *item = First(); + + while(item) + { + DEBUG("Item ist vom Type: %i", (int) item->GetFType()); + if(item->GetFType() == tFile) + { + DEBUG("Item wird hinzugefügt: %s", item->GetValue()); + Ext += item->GetValue(); + Ext += "@"; + } + item = Next(item); + } + + return stripspace(&Ext); +} + +char *cImageList::GetHideExtensions(void) +{ + DEBUG("Erstelle Liste aller Extensions die ausgeblendet werden sollen"); + + HideExt = NULL; + cImageListItem *item = First(); + + while(item) + { + DEBUG("Item ist vom Type: %i", (int) item->GetFType()); + if(item->GetFType() == tFile && item->IsHide()) + { + DEBUG("Item wird hinzugefügt: %s", item->GetValue()); + HideExt += item->GetValue(); + HideExt += "@"; + } + item = Next(item); + } + + return stripspace(&HideExt); +} + +char *cImageList::GetDirContains(void) +{ + DEBUG("Erstelle Liste aller Verzeichnisinhalte"); + + DirIn = NULL; + cImageListItem *item = First(); + + while(item) + { + DEBUG("Item ist vom Type: %i", (int) item->GetFType()); + if(item->GetFType() == tDir) + { + DEBUG("Item wird hinzugefügt: %s", item->GetValue()); + DirIn += item->GetValue(); + DirIn += "@"; + } + item = Next(item); + } + + return stripspace(&DirIn); +} + +char *cImageList::GetShortName(char *file) +{ + DEBUG("Shortname wird gesucht: %s", file); + + Short = NULL; + cImageListItem *item = First(); + cFileInfo *info = new cFileInfo(file); + + switch(info->Type()) + { + case tDir: + while(item) + { + if(item->GetFType() == tDir && + cFileList::DirIsIn(file, item->GetValue())) + break; + item = Next(item); + } + if(item) + Short = item->GetSName(); + break; + case tFile: + while(item) + { + if(item->GetFType() == tFile && + !strcasecmp(item->GetValue(), info->Extension())) + break; + item = Next(item); + } + if(item) + Short = item->GetSName(); + break; + default: + break; + } + + return &Short; +} + +bool cImageList::IsHide(char *ext) +{ + if(!ext) + return false; + + cImageListItem *item = First(); + while(item) + { + if(item->GetFType() == tFile && + item->IsHide() && + !strcasecmp(ext, item->GetValue())) + return true; + item = Next(item); + } + return false; +} |