summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranbr <vdr07@deltab.de>2010-12-21 21:15:43 +0100
committeranbr <vdr07@deltab.de>2010-12-21 21:15:43 +0100
commitdc368dc785849f14cbfec927dcdea886d075bbb1 (patch)
treee03e742b69a8bec5d3026e4f5cd4df4c570a5e7a
parent00b415857ebabfc81fca30caa049a35d9b19e10b (diff)
downloadvdr-plugin-dvdswitch-dc368dc785849f14cbfec927dcdea886d075bbb1.tar.gz
vdr-plugin-dvdswitch-dc368dc785849f14cbfec927dcdea886d075bbb1.tar.bz2
Use Make.global - Make sure that necessary options are included
Translate debug messages, remove some messages Fix some gcc warning around asprintf, realpath
-rw-r--r--Makefile4
-rw-r--r--commands.c148
-rw-r--r--commands.h92
-rw-r--r--dvdlist.c3
-rw-r--r--dvdplugin.c26
-rw-r--r--dvdswitch.c24
-rw-r--r--helpers.c54
-rw-r--r--helpers.h4
-rw-r--r--imagelist-item.c18
-rw-r--r--imagelist-item.h3
-rw-r--r--imagelist.c22
-rw-r--r--menu-item.c4
-rw-r--r--menu.c53
-rw-r--r--po/de_DE.po12
-rw-r--r--setup-itypes.c5
-rw-r--r--setup.c4
-rw-r--r--tools.c116
17 files changed, 340 insertions, 252 deletions
diff --git a/Makefile b/Makefile
index 8e0a14e..9d6aabb 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,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
diff --git a/commands.c b/commands.c
index 7c9d54f..347d3c5 100644
--- a/commands.c
+++ b/commands.c
@@ -13,9 +13,9 @@
eOSState cCMD::Play(cMainMenuItem *item)
{
if(item)
- dsyslog("Play Image %s, %i", item->FileName(), item->Type());
+ isyslog("dvdswitch: play %s, %i", item->FileName(), item->Type());
else
- dsyslog("Play Image: Kein Image angegeben");
+ esyslog("dvdswitch: play - none item defined");
if(!item || item->Type() == iDevice)
cDVDPlugin::Start();
@@ -28,12 +28,12 @@ eOSState cCMD::Play(cMainMenuItem *item)
eOSState cCMD::Eject(bool close)
{
char *cmd = NULL;
- asprintf(&cmd, "eject %s %s", close ? "-t" : "", DVDSwitchSetup.DVDLinkOrg);
- dsyslog("Eject: %i - %s", close, cmd);
- int rc = system(cmd);
- dsyslog("Eject-Rückgabe: %i", rc);
- free(cmd);
-
+ if(0 < asprintf(&cmd, "eject %s %s", close ? "-t" : "", DVDSwitchSetup.DVDLinkOrg)) {
+ isyslog("dvdswitch: eject media: %i - %s", close, cmd);
+ int rc = system(cmd);
+ dsyslog("dvdswitch: result of eject media: %i", rc);
+ free(cmd);
+ }
return osContinue;
}
@@ -170,7 +170,6 @@ cCMDDir::cCMDDir(cImageList &imagelist, cMainMenu *osdobject, bool select, char
: cOsdMenu(tr("Directory Management"))
, ImageList(imagelist)
{
- dsyslog("Verzeichnis Management");
ImageDir(DVDSwitchSetup.ImageDir);
CurrentDir(DVDSwitchSetup.ImageDir);
ParentDir(DVDSwitchSetup.ImageDir);
@@ -213,7 +212,6 @@ void cCMDDir::SetHelp(void)
void cCMDDir::Build(char *dir)
{
- dsyslog("Erstelle Verzeichnisliste %s", dir);
if(!dir)
dir = CurrentDir();
@@ -261,7 +259,7 @@ eOSState cCMDDir::ProcessKey(eKeys Key)
info = new cFileInfo(mItem->FileName());
if(!info->isExecutable() || !info->isReadable())
{
- esyslog("Can't access to directory!");
+ esyslog("dvdswitch: Can't access to directory!");
DELETENULL(info);
OsdMsg(mtError,tr("No rights to change inside this directory!"));
return osContinue;
@@ -283,14 +281,14 @@ eOSState cCMDDir::ProcessKey(eKeys Key)
case kYellow:
if(mItem->Type() == iDir && Interface->Confirm(tr("Really delete?")))
{
- dsyslog("Confirm delete directory");
+ dsyslog("dvdswitch: Confirm delete directory");
if(cFileCMD::DirIsEmpty(mItem->FileName()) ||
(!cFileCMD::DirIsEmpty(mItem->FileName()) && Interface->Confirm(tr("Directory not empty! However delete?"))))
{
cFileDelThread *del = new cFileDelThread(mItem->FileName());
if(del->OK())
{
- dsyslog("Start delete directory");
+ dsyslog("dvdswitch: Start delete directory");
del->Start();
Build();
OsdObject->SetState(mmsReInit);
@@ -306,11 +304,11 @@ eOSState cCMDDir::ProcessKey(eKeys Key)
{
if(Select)
{
- dsyslog("Directory selected: %s", mItem->FileName());
+ dsyslog("dvdswitch: Directory selected: %s", mItem->FileName());
info = new cFileInfo(mItem->FileName());
if(!info->isExecutable() || !info->isReadable())
{
- esyslog("Can't access to directory!");
+ esyslog("dvdswitch: Can't access to directory!");
OsdMsg(mtError,tr("No rights to change inside this directory!"));
}
else
@@ -363,11 +361,10 @@ eOSState cCMDDir::ProcessKey(eKeys Key)
eOSState cCMDDir::New(void)
{
- dsyslog("Directory: Create");
cFileInfo *info = new cFileInfo(CurrentDir());
if(!info->isWriteable())
{
- esyslog("Can't create directory, missing rights for %s", CurrentDir());
+ esyslog("dvdswitch: Can't create directory, missing rights for %s", CurrentDir());
OsdMsg(mtError,tr("Missing rights to create directory!"));
}
else
@@ -401,26 +398,27 @@ eOSState cCMDDir::New(eKeys Key)
if(!isempty(Dir))
{
char *buffer = NULL;
- asprintf(&buffer, "%s/%s", CurrentDir(), stripspace(Dir));
- dsyslog("Create new directory: %s", buffer);
- cFileInfo *info = new cFileInfo(buffer);
- if(info->isExists())
- {
- esyslog("Directory still exists");
- OsdMsg(mtWarning,tr("Directory exists"));
+ if(0 < asprintf(&buffer, "%s/%s", CurrentDir(), stripspace(Dir))) {
+ dsyslog("dvdswitch: Create new directory: %s", buffer);
+ cFileInfo *info = new cFileInfo(buffer);
+ if(info->isExists())
+ {
+ isyslog("dvdswitch: Directory still exists");
+ OsdMsg(mtWarning,tr("Directory exists"));
+ FREENULL(buffer);
+ DELETENULL(info);
+ return osContinue;
+ }
+ if(cFileCMD::Mkdir(buffer))
+ {
+ dsyslog("dvdswitch: Directory successfully created");
+ LastSelDir(buffer);
+ if(!Select)
+ OsdObject->SetState(mmsReInit);
+ }
FREENULL(buffer);
DELETENULL(info);
- return osContinue;
- }
- if(cFileCMD::Mkdir(buffer))
- {
- dsyslog("Directory successfully created");
- LastSelDir(buffer);
- if(!Select)
- OsdObject->SetState(mmsReInit);
}
- FREENULL(buffer);
- DELETENULL(info);
}
case kBack:
State = csNone;
@@ -436,7 +434,6 @@ eOSState cCMDDir::New(eKeys Key)
eOSState cCMDDir::Edit(cMainMenuItem *mItem)
{
- dsyslog("Directory edit: %s", mItem->FileName());
cFileInfo *info = new cFileInfo(mItem->FileName());
if(!info->isWriteable())
{
@@ -444,7 +441,7 @@ eOSState cCMDDir::Edit(cMainMenuItem *mItem)
info = new cFileInfo(CurrentDir());
if(!info->isWriteable())
{
- esyslog("Missing proper rights to rename");
+ esyslog("dvdswitch: Missing proper rights to rename");
OsdMsg(mtError,tr("Missing rights to rename!"));
DELETENULL(info);
return osContinue;
@@ -464,7 +461,7 @@ eOSState cCMDDir::Edit(cMainMenuItem *mItem)
{
if(!strcasecmp(mItem->FileName(), LastSelDir()))
{
- dsyslog("Directory: Edit: Item found: %s", mItem->FileName());
+ dsyslog("dvdswitch: Directory: Edit: Item found: %s", mItem->FileName());
Ins(new cMenuEditStrItem(tr("Rename:"), Dir, MaxFileName, tr(" abcdefghijklmnopqrstuvwxyz0123456789-_.#~")),
true,
mItem);
@@ -490,25 +487,26 @@ eOSState cCMDDir::Edit(eKeys Key)
if(!isempty(Dir))
{
char *buffer = NULL;
- asprintf(&buffer, "%s/%s", CurrentDir(), stripspace(Dir));
- dsyslog("Directory: Edit: OK: %s", buffer);
- cFileInfo *info = new cFileInfo(buffer);
- if(info->isExists())
- {
- dsyslog("Directory: Edit: exists");
- OsdMsg(mtWarning,tr("Directory exists"));
+ if(0 < asprintf(&buffer, "%s/%s", CurrentDir(), stripspace(Dir))) {
+ dsyslog("dvdswitch: Directory: Edit: OK: %s", buffer);
+ cFileInfo *info = new cFileInfo(buffer);
+ if(info->isExists())
+ {
+ isyslog("dvdswitch: Directory: Edit: exists");
+ OsdMsg(mtWarning,tr("Directory exists"));
+ FREENULL(buffer);
+ DELETENULL(info);
+ return osUnknown;
+ }
+ if(cFileCMD::Rn(LastSelDir(), buffer))
+ {
+ dsyslog("dvdswitch: Directory: Edit: Rename OK");
+ LastSelDir(buffer);
+ OsdObject->SetState(mmsReInit);
+ }
FREENULL(buffer);
DELETENULL(info);
- return osUnknown;
}
- if(cFileCMD::Rn(LastSelDir(), buffer))
- {
- dsyslog("Directory: Edit: Rename OK");
- LastSelDir(buffer);
- OsdObject->SetState(mmsReInit);
- }
- FREENULL(buffer);
- DELETENULL(info);
}
case kBack:
State = csNone;
@@ -528,7 +526,6 @@ cCMDMove::cCMDMove(cImageList &imagelist, const char *file, cMainMenu *osdobject
: cOsdMenu(tr("Move"))
, ImageList(imagelist)
{
- dsyslog("Directory: Move: %s", file);
File = file ? strdup(file) : NULL;
OsdObject = osdobject;
Dir = dir;
@@ -549,7 +546,6 @@ void cCMDMove::SetHelp(void)
void cCMDMove::Build(char *dir)
{
- dsyslog("Directory: Move: create list: %s", dir);
if(!dir)
dir = CurrentDir();
@@ -603,11 +599,11 @@ eOSState cCMDMove::ProcessKey(eKeys Key)
Build();
break;
case kBlue:
- dsyslog("Directory: Move to: %s", CurrentDir());
+ dsyslog("dvdswitch: Directory: Move to: %s", CurrentDir());
move = new cFileMoveThread(File, CurrentDir());
if(move->OK())
{
- dsyslog("Directory: Move successful");
+ dsyslog("dvdswitch: Directory: Move successful");
move->Start();
cCondWait::SleepMs(1 * 500);
OsdObject->SetState(mmsReInit);
@@ -629,7 +625,6 @@ eOSState cCMDMove::ProcessKey(eKeys Key)
cCMDImage::cCMDImage(cMainMenu *osdobject)
{
- dsyslog("CMDImage");
File = NULL;
strcpy(NewFile, "\0");
OsdObject = osdobject;
@@ -643,7 +638,6 @@ cCMDImage::~cCMDImage(void)
char* cCMDImage::Rename(const char *file)
{
- dsyslog("CMDImage Rename");
if(file)
{
FREENULL(File);
@@ -655,7 +649,7 @@ char* cCMDImage::Rename(const char *file)
eOSState cCMDImage::Delete(const char *file)
{
- dsyslog("Remove dvd image '%s'", file);
+ dsyslog("dvdswitch: Remove dvd image '%s'", file);
if(file)
{
if(Interface->Confirm(tr("Really delete?")))
@@ -663,7 +657,7 @@ eOSState cCMDImage::Delete(const char *file)
cFileDelThread *del = new cFileDelThread(file);
if(del->OK())
{
- dsyslog("löschen OK");
+ dsyslog("dvdswitch: Confirm deletion of dvd image");
del->Start();
OsdObject->SetState(mmsReInitCur);
}
@@ -677,20 +671,20 @@ eOSState cCMDImage::Delete(const char *file)
eOSState cCMDImage::Burn(const char *file)
{
- dsyslog("Write dvd image '%s'", file);
+ dsyslog("dvdswitch: Write dvd image '%s'", file);
cFileInfo *info = new cFileInfo(DVDSwitchSetup.DVDWriteScript);
if(!info->isExists())
{
- esyslog("Missing script to write dvd");
+ esyslog("dvdswitch: Missing script to write dvd");
DELETENULL(info);
OsdMsg(mtError,tr("Specified Writescript not exist!"));
return osContinue;
}
if(!info->isExecutable())
{
- esyslog("Can't execute script to write dvd");
+ esyslog("dvdswitch: Can't execute script to write dvd");
DELETENULL(info);
OsdMsg(mtError,tr("Cannot execute Writescript!"));
return osContinue;
@@ -702,7 +696,7 @@ eOSState cCMDImage::Burn(const char *file)
if(Interface->Confirm(tr("Burn Now?")))
{
- dsyslog("Start Burn-Thread");
+ dsyslog("dvdswitch: Start Burn-Thread");
cCMDImageBurnThread *burn = new cCMDImageBurnThread(file, info->Type());
burn->Start();
}
@@ -716,20 +710,20 @@ cCMDImageRead::cCMDImageRead(cImageList &imagelist)
: cOsdMenu(tr("Read DVD"), 14)
, ImageList(imagelist)
{
- dsyslog("Read DVD Image");
+ dsyslog("dvdswitch: Read DVD Image");
cFileInfo *info = new cFileInfo(DVDSwitchSetup.DVDReadScript);
if(!info->isExists())
{
- esyslog("Missing script to read dvd");
+ esyslog("dvdswitch: Missing script to read dvd");
DELETENULL(info);
OsdMsg(mtError,tr("Specified Readscript not exist!"));
cRemote::Put(kBack);
}
else if(!info->isExecutable())
{
- esyslog("Can't execute script to write dvd");
+ esyslog("dvdswitch: Can't execute script to write dvd");
DELETENULL(info);
OsdMsg(mtError,tr("Cannot execute Readscript!"));
cRemote::Put(kBack);
@@ -753,7 +747,7 @@ cCMDImageRead::cCMDImageRead(cImageList &imagelist)
cCMDImageRead::~cCMDImageRead(void)
{
- dsyslog("Read DVD Image stopped");
+ dsyslog("dvdswitch: Read DVD Image stopped");
}
void cCMDImageRead::SetHelp(void)
@@ -817,14 +811,20 @@ eOSState cCMDImageRead::ProcessKey(eKeys Key)
buffer = strdup(DVDSwitchSetup.ImageDir);
else
{
- if(DVDSwitchSetup.ImageDir[strlen(DVDSwitchSetup.ImageDir)-1] == '/')
- asprintf(&buffer, "%s%s", DVDSwitchSetup.ImageDir, Dir);
- else
- asprintf(&buffer, "%s/%s", DVDSwitchSetup.ImageDir, Dir);
+ if(DVDSwitchSetup.ImageDir[strlen(DVDSwitchSetup.ImageDir)-1] == '/') {
+ if(0 >= asprintf(&buffer, "%s%s", DVDSwitchSetup.ImageDir, Dir)) {
+ return osBack;
+ }
+ }
+ else {
+ if(0 >= asprintf(&buffer, "%s/%s", DVDSwitchSetup.ImageDir, Dir)) {
+ return osBack;
+ }
+ }
}
if(buffer[strlen(buffer)-1] == '/')
buffer[strlen(buffer)-1] = '\0';
- dsyslog("ReadThread wird gestartet");
+ dsyslog("dvdswitch: Thread to read image are started");
cCMDImageReadThread *read = new cCMDImageReadThread(File, buffer, ImgType, ImageList);
FREENULL(buffer);
read->Start();
diff --git a/commands.h b/commands.h
index 6871815..3457b3b 100644
--- a/commands.h
+++ b/commands.h
@@ -153,48 +153,49 @@ class cCMDImageReadThread : public cThread
int step = 0;
cTokenizer *token = NULL;
char buffer[MaxFileName];
- realpath(DVDSwitchSetup.DVDLinkOrg, buffer);
+ if(realpath(DVDSwitchSetup.DVDLinkOrg, buffer)) {
+ while(!mountpoint && step < 2) {
+ step++;
+ if(0 < asprintf(&cmd,
+ "cat /etc/fstab | grep -e \"%s\" | grep -e \"^[^#]\"",
+ step == 1 ? DVDSwitchSetup.DVDLinkOrg : buffer)) {
+ dsyslog("ReadThread call: %s", cmd);
- while(!mountpoint && step < 2)
- {
- step++;
- asprintf(&cmd,
- "cat /etc/fstab | grep -e \"%s\" | grep -e \"^[^#]\"",
- step == 1 ? DVDSwitchSetup.DVDLinkOrg : buffer);
- dsyslog("ReadThread call: %s", cmd);
-
- FILE *p = popen(cmd, "r");
- if(p)
- {
+ FILE *p = popen(cmd, "r");
+ if(p)
+ {
#if VDRVERSNUM >= 10318
- cReadLine rl;
- output = rl.Read(p);
+ cReadLine rl;
+ output = rl.Read(p);
#else
- output = readline(p);
+ output = readline(p);
#endif
- pclose(p);
+ pclose(p);
+ }
+ token = new cTokenizer(output, " ");
+ if(token->Count() > 1) {
+ char* s = strdup(token->GetToken(2));
+ mountpoint = stripspace(s);
+ }
+ DELETENULL(token);
+ }
+ FREENULL(cmd);
}
- token = new cTokenizer(output, " ");
- if(token->Count() > 1) {
- char* s = strdup(token->GetToken(2));
- mountpoint = stripspace(s);
+ if(0 < asprintf(&cmd,
+ "'%s' '%s' '%s' '%s' '%s' '%s'",
+ DVDSwitchSetup.DVDReadScript,
+ Dir,
+ File,
+ buffer,
+ mountpoint,
+ (FileType == tFile) ? "IMAGE" : "DIR")) {
+ dsyslog("ReadThread call: %s", cmd);
+ int rc = system(cmd);
+ dsyslog("ReadThread return value: %i", rc);
+ FREENULL(cmd);
}
- DELETENULL(token);
+ FREENULL(mountpoint);
}
- FREENULL(cmd);
- asprintf(&cmd,
- "'%s' '%s' '%s' '%s' '%s' '%s'",
- DVDSwitchSetup.DVDReadScript,
- Dir,
- File,
- buffer,
- mountpoint,
- (FileType == tFile) ? "IMAGE" : "DIR");
- dsyslog("ReadThread call: %s", cmd);
- int rc = system(cmd);
- dsyslog("ReadThread return value: %i", rc);
- FREENULL(cmd);
- FREENULL(mountpoint);
}
delete(this);
};
@@ -209,8 +210,10 @@ class cCMDImageReadThread : public cThread
cImageListItem *item = ImageList.Get(imgtype);
if(imgtype >= 0 && file && dir)
{
- if(item->GetFType() == tFile)
- asprintf(&File, "%s%s", file, item->GetValue());
+ if(item->GetFType() == tFile) {
+ if(0 >= asprintf(&File, "%s%s", file, item->GetValue()))
+ return;
+ }
else
File = strdup(file);
Dir = strdup(dir);
@@ -237,17 +240,18 @@ class cCMDImageBurnThread : public cThread
{
dsyslog("BurnThread executed");
char *cmd;
- asprintf(&cmd,
+ if(0 < asprintf(&cmd,
"'%s' '%s' '%s'",
DVDSwitchSetup.DVDWriteScript,
File,
- FileType == tFile ? "IMAGE" : "DIR");
- dsyslog("BurnThread call: %s", cmd);
- int rc = system(cmd);
- dsyslog("BurnThread return value: %i", rc);
- FREENULL(cmd);
+ FileType == tFile ? "IMAGE" : "DIR")) {
+ dsyslog("BurnThread call: %s", cmd);
+ int rc = system(cmd);
+ dsyslog("BurnThread return value: %i", rc);
+ FREENULL(cmd);
+ }
}
- delete(this);
+ delete(this);
};
public:
cCMDImageBurnThread(const char *file, eFileInfo type)
diff --git a/dvdlist.c b/dvdlist.c
index d5d4da7..90f9f51 100644
--- a/dvdlist.c
+++ b/dvdlist.c
@@ -4,8 +4,6 @@
bool cDVDList::Create(const char *dir, const char *exts, const char *dirs, eFileList smode, bool sub)
{
- dsyslog("DVDList: %s, %s", exts, dirs);
-
Clear();
FREENULL(DVDExts);
FREENULL(DVDDirs);
@@ -21,7 +19,6 @@ bool cDVDList::Create(const char *dir, const char *exts, const char *dirs, eFile
bool cDVDList::Load(const char *dir, eFileList smode, bool sub)
{
- dsyslog("DVDList: Load");
bool ret = false;
int i = 0;
diff --git a/dvdplugin.c b/dvdplugin.c
index 5a613f4..4412e0a 100644
--- a/dvdplugin.c
+++ b/dvdplugin.c
@@ -8,13 +8,13 @@
cDVDPluginThread::cDVDPluginThread(char *image)
:cThread("DVDPluginThread")
{
- dsyslog("Create new DVD Thread");
+ dsyslog("dvdswitch: Create new DVD Thread");
Image = image ? strdup(image) : NULL;
}
cDVDPluginThread::~cDVDPluginThread(void)
{
- dsyslog("DVD Thread stopped");
+ dsyslog("dvdswitch: DVD Thread stopped");
free(Image);
Cancel();
@@ -22,7 +22,7 @@ cDVDPluginThread::~cDVDPluginThread(void)
void cDVDPluginThread::Action(void)
{
- dsyslog("DVD Thread started");
+ dsyslog("dvdswitch: DVD Thread started");
if(Image)
cDVDPlugin::ChangeLink(Image);
@@ -32,11 +32,11 @@ void cDVDPluginThread::Action(void)
if(plugin)
{
plugin->MainMenuAction();
- dsyslog("DVD MainMenuAction called");
+ dsyslog("dvdswitch: DVD MainMenuAction called");
}
#else
cRemote::CallPlugin("dvd");
- dsyslog("DVD Plugin called");
+ dsyslog("dvdswitch: DVD Plugin called");
#endif
cCondWait::SleepMs(2 * 1000);
@@ -47,12 +47,12 @@ void cDVDPluginThread::Action(void)
cCondWait::SleepMs(5 * 1000);
control = cControl::Control();
}
- dsyslog("DVD control closed");
+ dsyslog("dvdswitch: DVD control closed");
if(Image)
cDVDPlugin::ChangeLink(DVDSwitchSetup.DVDLinkOrg);
- dsyslog("DVD Thread closed");
+ dsyslog("dvdswitch: DVD Thread closed");
cDVDPlugin::Exit();
}
@@ -62,13 +62,13 @@ cDVDPluginThread *cDVDPlugin::thread = NULL;
void cDVDPlugin::DetectDevice(void)
{
- dsyslog("Scan nach DVD Device");
+ dsyslog("dvdswitch: Scan for DVD Device");
char *cmd = NULL;
char *output = NULL;
char *dvd = NULL;
if(0 < asprintf(&cmd, "ps -p %i -o cmd --no-header", getpid())) {
- dsyslog("Commando: %s", cmd);
+ dsyslog("dvdswitch: Command: %s", cmd);
FILE *p = popen(cmd, "r");
if(p)
@@ -108,13 +108,13 @@ void cDVDPlugin::DetectDevice(void)
if(dvd)
{
- isyslog("Used DVD Device: %s", dvd);
+ isyslog("dvdswitch: Used DVD Device: %s", dvd);
DVDSwitchSetup.SetDVDDevice(dvd);
free(dvd);
}
else
{
- isyslog("Use Default-DVD Device /dev/dvd");
+ isyslog("dvdswitch: Use Default-DVD Device /dev/dvd");
DVDSwitchSetup.SetDVDDevice("/dev/dvd");
}
@@ -167,9 +167,9 @@ void cDVDPlugin::ChangeLink(char *target)
int rc = 0;
if(0 < asprintf(&cmd, LINK, target, DVDSwitchSetup.DVDLink)) {
- dsyslog("Change link: %s", cmd);
+ dsyslog("dvdswitch: Change link: %s", cmd);
rc = system(cmd);
- dsyslog("Change link got: %i", rc);
+ dsyslog("dvdswitch: Change link got: %i", rc);
free(cmd);
}
}
diff --git a/dvdswitch.c b/dvdswitch.c
index 34e9e59..7afa524 100644
--- a/dvdswitch.c
+++ b/dvdswitch.c
@@ -19,7 +19,7 @@
#error "VDR-1.6.0 API version or greater is required!"
#endif
-static const char *VERSION = "0.1.5";
+static const char *VERSION = "0.1.6";
static const char *DESCRIPTION = tr("Allowed to play DVD-Images");
//static const char *MAINMENUENTRY = tr("DVDSwitch");
@@ -66,12 +66,12 @@ const char *cPluginDvdswitch::CommandLineHelp(void)
{
//12345678901234567890123456789012345678901234567890123456789012345678901234567890|
return
- " -r SCRIPT, --readscript=SCRIPT SCRIPT = scriptname with path for reading"
- " DVD as a ISO Image File"
- " -w SCRIPT, --writescript=SCRIPT SCRIPT = scriptname with path to writing"
- " selected DVD Image"
- " -i PATH, --imagedir=PATH Path to DVD-Images. This Option can set"
- " in SetupMenu optional";
+ " -r SCRIPT, --readscript=SCRIPT SCRIPT = scriptname with path for reading\n"
+ " DVD as a ISO Image File\n"
+ " -w SCRIPT, --writescript=SCRIPT SCRIPT = scriptname with path to writing\n"
+ " selected DVD Image\n"
+ " -i PATH, --imagedir=PATH Path to DVD-Images. This Option can set\n"
+ " in SetupMenu optional\n";
}
bool cPluginDvdswitch::ProcessArgs(int argc, char *argv[])
@@ -112,7 +112,7 @@ bool cPluginDvdswitch::ProcessArgs(int argc, char *argv[])
bool cPluginDvdswitch::Initialize(void)
{
// Initialize any background activities the plugin shall perform.
- dsyslog("Initialize plugin");
+ dsyslog("dvdswitch: Initialize plugin");
DVDSwitchSetup.SetConfDir(ConfigDirectory(Name()));
cDVDPlugin::Init();
@@ -181,18 +181,18 @@ cString cPluginDvdswitch::SVDRPCommand(const char *Command, const char *Option,
bool cPluginDvdswitch::CheckError(void)
{
- dsyslog("Check ImageDir");
+ dsyslog("dvdswitch: Check ImageDir");
if(!DirectoryOk(DVDSwitchSetup.ImageDir))
{
- esyslog("Image Directory '%s' not readable", DVDSwitchSetup.ImageDir);
+ esyslog("dvdswitch: Image Directory '%s' not readable", DVDSwitchSetup.ImageDir);
OsdMsg(mtError,tr("Image Directory not readable or not exist"));
return true;
}
- dsyslog("Check DVD Plugin");
+ dsyslog("dvdswitch: Check DVD Plugin");
if(!cPluginManager::GetPlugin("dvd"))
{
- esyslog("DVD-Plugin not found! Function deactivated!");
+ esyslog("dvdswitch: DVD-Plugin not found! Function deactivated!");
OsdMsg(mtInfo,tr("DVD-Plugin not found! Function deactivated!"));
} else
DVDSwitchSetup.DVDPluginExist = true;
diff --git a/helpers.c b/helpers.c
index 59850fc..729a173 100644
--- a/helpers.c
+++ b/helpers.c
@@ -1,4 +1,5 @@
#include "helpers.h"
+#include <dirent.h>
// --- OSD Message Helpers -----------------------------------
@@ -22,6 +23,29 @@ void OsdMsg(eMessageType Type, const char *Msg)
#endif
}
+void OSDErrorNumMsg(int err, const char* szDef)
+{
+ char szErr[128];
+ int nErr = err;
+ szErr[sizeof(szErr)-1] = '\0';
+ if(0 != strerror_r(nErr,szErr,sizeof(szErr)-1)) {
+ szErr[0] = '\0';
+ }
+ esyslog(szErr[0] != '\0'?szErr:szDef);
+ OsdMsg(mtError, szErr[0] != '\0'?szErr:szDef);
+}
+
+void SysLogErrorNumMsg(int err, const char* szDef)
+{
+ char szErr[128];
+ int nErr = err;
+ szErr[sizeof(szErr)-1] = '\0';
+ if(0 != strerror_r(nErr,szErr,sizeof(szErr)-1)) {
+ szErr[0] = '\0';
+ }
+ esyslog(szErr[0] != '\0'?szErr:szDef);
+}
+
void ChangeChars(char *name, char *chars)
{
char seek;
@@ -70,7 +94,6 @@ bool RegIMatch(const char *string, const char *pattern)
void cTokenizer::Tokenize(bool trim)
{
Clear();
- dsyslog("String wird in Token zerlegt");
char *buffer = NULL;
char *token = NULL;
char *tok_pointer;
@@ -83,7 +106,6 @@ void cTokenizer::Tokenize(bool trim)
token;
token = strtok_r(NULL, Delim, &tok_pointer))
{
- dsyslog("Token gefunden: %s", token);
if(!trim)
Add(new cToken(token));
else
@@ -97,7 +119,6 @@ void cTokenizer::Tokenize(bool trim)
cFileInfo::cFileInfo(const char *file)
{
- dsyslog("FileInfo: %s", file);
File = (file && !isempty(file)) ? strdup(file) : NULL;
if(File && File[strlen(File) - 1] == '/')
@@ -129,8 +150,6 @@ char *cFileInfo::Path(void)
strn0cpy(buffer, File, len);
}
- dsyslog("FileInfo: Pfad: %s", buffer);
-
return buffer;
}
@@ -145,10 +164,7 @@ char *cFileInfo::FileName(void)
buffer = strdup(p);
}
- dsyslog("FileInfo: FileName: %s", buffer);
-
return buffer;
-
}
char *cFileInfo::FileNameWithoutExt(void)
@@ -175,8 +191,6 @@ char *cFileInfo::FileNameWithoutExt(void)
free(ext);
free(filename);
- dsyslog("FileInfo: FileNameWithoutExt: %s", buffer);
-
return buffer;
}
@@ -193,8 +207,6 @@ char *cFileInfo::Extension(bool withPoint)
buffer = strdup(p);
}
- dsyslog("FileInfo: Extension: %s", buffer);
-
return buffer;
}
@@ -503,22 +515,22 @@ bool cFileList::Read(const char *dir, bool withsub)
bool ret = false;
char *buffer = NULL;
- struct dirent *DirData = NULL;
+ struct dirent *e;
cReadDir Dir(dir);
if(Dir.Ok())
{
- while((DirData = Dir.Next()) != NULL)
+ while((e = Dir.Next()) != NULL)
{
- if(CheckIncludes(dir, DirData->d_name) &&
- !CheckExcludes(dir, DirData->d_name) &&
- CheckType(dir, DirData->d_name, Type))
- SortIn(dir, DirData->d_name);
+ if(CheckIncludes(dir, e->d_name) &&
+ !CheckExcludes(dir, e->d_name) &&
+ CheckType(dir, e->d_name, Type))
+ SortIn(dir, e->d_name);
if(withsub &&
- CheckType(dir, DirData->d_name, tDir) &&
- !RegIMatch(DirData->d_name, "^\\.{1,2}$"))
+ CheckType(dir, e->d_name, tDir) &&
+ !RegIMatch(e->d_name, "^\\.{1,2}$"))
{
- if(0 < asprintf(&buffer, "%s/%s", dir, DirData->d_name)) {
+ if(0 < asprintf(&buffer, "%s/%s", dir, e->d_name)) {
Read(buffer, withsub);
FREENULL(buffer);
}
diff --git a/helpers.h b/helpers.h
index 9935593..951f38a 100644
--- a/helpers.h
+++ b/helpers.h
@@ -16,6 +16,8 @@
#define FREENULL(p) (free(p), p = NULL)
void OsdMsg(eMessageType Type, const char *Msg);
+void OSDErrorNumMsg(int err, const char* szDef);
+void SysLogErrorNumMsg(int err, const char* szDef);
void ChangeChars(char *name, char *chars);
void StrRepeat(const char *input, int count, char *dest);
bool RegIMatch(const char *string,const char *pattern);
@@ -157,7 +159,7 @@ class cFileCMD
public:
static bool Del(const char *file);
static bool Mkdir(const char *dir) { return MakeDirs(dir, true); }
- static bool Rn(const char *oldfile, const char *newfile) { return !rename(oldfile, newfile); }
+ static bool Rn(const char *oldfile, const char *newfile) { return 0 == rename(oldfile, newfile); }
static bool DirIsEmpty(const char *file);
};
diff --git a/imagelist-item.c b/imagelist-item.c
index 04b1b78..1c766f8 100644
--- a/imagelist-item.c
+++ b/imagelist-item.c
@@ -8,8 +8,6 @@ cImageListItem::cImageListItem(const char *lname, const char *sname, eFileInfo t
SString = NULL;
Edit(lname, sname, type, value, hide);
-
- debug();
}
cImageListItem::~ cImageListItem(void)
@@ -22,9 +20,6 @@ cImageListItem::~ cImageListItem(void)
void cImageListItem::Edit(const char *lname, const char *sname, eFileInfo type, const char *value, bool hide)
{
- dsyslog("New/Edit ImageListItem");
- debug();
-
free(LName);
free(SName);
free(Value);
@@ -44,17 +39,4 @@ void cImageListItem::Edit(const char *lname, const char *sname, eFileInfo type,
HideExt = hide;
MakeSetupString();
-
- debug();
-}
-
-void cImageListItem::debug(void)
-{
- dsyslog("Items:");
- dsyslog(" LongName: %s", LName);
- dsyslog(" ShortName: %s", SName);
- dsyslog(" FileType: %i", (int)fType);
- dsyslog(" Value: %s", Value);
- dsyslog(" Hide: %s", HideExt ? "TRUE" : "FALSE");
- dsyslog(" SaveString: %s", SString);
}
diff --git a/imagelist-item.h b/imagelist-item.h
index 1b2e874..a1070e4 100644
--- a/imagelist-item.h
+++ b/imagelist-item.h
@@ -19,11 +19,10 @@ class cImageListItem : public cListObject
{
FREENULL(SString);
if(0 < asprintf(&SString, "%s|%s|%i|%s|%i", LName, SName, (int)fType, Value, HideExt)) {
- dsyslog("...%s", SString);
+ dsyslog("dvdswitch: ...%s", SString);
}
};
- void debug(void);
public:
cImageListItem(const char *lname, const char *sname, eFileInfo type,const char *value, bool hide);
~cImageListItem(void);
diff --git a/imagelist.c b/imagelist.c
index c605b32..fe82e1a 100644
--- a/imagelist.c
+++ b/imagelist.c
@@ -13,7 +13,6 @@ cImageList::~ cImageList(void)
void cImageList::Init(void)
{
- dsyslog("Init ImageList");
if(!Setup)
{
Add(new cImageListItem(tr("Directory with 'VIDEO_TS' Folder"),
@@ -31,8 +30,6 @@ void cImageList::Init(void)
void cImageList::AddItem(const char *item)
{
- dsyslog("Neues Item soll hinzugefügt werden: %s", item);
-
if (!isempty(item))
{
cTokenizer *token = new cTokenizer(item, "|");
@@ -48,8 +45,6 @@ void cImageList::AddItem(const char *item)
void cImageList::AddSetup(const char *value)
{
- dsyslog("Erhalte SetupString: %s",value);
-
Setup = true;
Clear();
@@ -64,14 +59,11 @@ void cImageList::AddSetup(const char *value)
char *cImageList::GetSetupString(void)
{
- dsyslog("Erstelle SetupString");
-
SString = NULL;
cImageListItem *item = First();
while(item)
{
- dsyslog("Füge hinzu: %s", item->SaveString());
SString += item->SaveString();
SString += "@";
item = Next(item);
@@ -82,17 +74,13 @@ char *cImageList::GetSetupString(void)
char *cImageList::GetExtensions(void)
{
- dsyslog("Erstelle Liste aller Extensions");
-
Ext = NULL;
cImageListItem *item = First();
while(item)
{
- dsyslog("Item ist vom Type: %i", (int) item->GetFType());
if(item->GetFType() == tFile)
{
- dsyslog("Item wird hinzugefügt: %s", item->GetValue());
Ext += item->GetValue();
Ext += "@";
}
@@ -104,17 +92,13 @@ char *cImageList::GetExtensions(void)
char *cImageList::GetHideExtensions(void)
{
- dsyslog("Erstelle Liste aller Extensions die ausgeblendet werden sollen");
-
HideExt = NULL;
cImageListItem *item = First();
while(item)
{
- dsyslog("Item ist vom Type: %i", (int) item->GetFType());
if(item->GetFType() == tFile && item->IsHide())
{
- dsyslog("Item wird hinzugefügt: %s", item->GetValue());
HideExt += item->GetValue();
HideExt += "@";
}
@@ -126,17 +110,13 @@ char *cImageList::GetHideExtensions(void)
char *cImageList::GetDirContains(void)
{
- dsyslog("Erstelle Liste aller Verzeichnisinhalte");
-
DirIn = NULL;
cImageListItem *item = First();
while(item)
{
- dsyslog("Item ist vom Type: %i", (int) item->GetFType());
if(item->GetFType() == tDir)
{
- dsyslog("Item wird hinzugefügt: %s", item->GetValue());
DirIn += item->GetValue();
DirIn += "@";
}
@@ -148,8 +128,6 @@ char *cImageList::GetDirContains(void)
char *cImageList::GetShortName(const char *file)
{
- dsyslog("Shortname wird gesucht: %s", file);
-
Short = NULL;
cImageListItem *item = First();
cFileInfo *info = new cFileInfo(file);
diff --git a/menu-item.c b/menu-item.c
index 5e7b7c9..4b228f1 100644
--- a/menu-item.c
+++ b/menu-item.c
@@ -8,8 +8,6 @@
cMainMenuItem::cMainMenuItem(eMainMenuItem itype, cImageList &ImageList, const char *file)
{
- dsyslog("Neues MainMenuItem: %i, %s", (int)itype, file);
-
iType = itype;
File = file ? strdup(file) : NULL;
@@ -18,8 +16,6 @@ cMainMenuItem::cMainMenuItem(eMainMenuItem itype, cImageList &ImageList, const c
SetText(OSD, true);
if(iType == iCat)
SetSelectable(false);
-
- dsyslog("OSDName: %s", OSD);
}
cMainMenuItem::~ cMainMenuItem()
diff --git a/menu.c b/menu.c
index 8540212..62cc9fd 100644
--- a/menu.c
+++ b/menu.c
@@ -45,12 +45,13 @@ void cMainMenu::SetMenuTitle(void)
{
int mByte = FreeDiskSpaceMB(DVDSwitchSetup.ImageDir);
double gByte = (double)((int)((double)mByte / 1024 * 10)) / 10;
- asprintf(&title,
+ if(0 >= asprintf(&title,
"%s - %4.1f GB (DVD5: %i / DVD9: %i)",
DVDSwitchSetup.MenuName,
gByte,
(int)(gByte / 4.7),
- (int)(gByte / 8.5));
+ (int)(gByte / 8.5)))
+ return;
} else
title = DVDSwitchSetup.MenuName ? strdup(DVDSwitchSetup.MenuName) : NULL;
@@ -60,8 +61,6 @@ void cMainMenu::SetMenuTitle(void)
void cMainMenu::Build(const char *dir)
{
- dsyslog("Build MainMenu von %s", dir);
-
SetMenuTitle();
if(!DVDSwitchSetup.HideImgSizeCol)
SetCols(DVDSwitchSetup.CountTypCol, 10);
@@ -85,8 +84,6 @@ void cMainMenu::Build(const char *dir)
break;
}
- dsyslog("First Selectable ist: %i", FirstSelectable);
-
if(FirstSelectable >= 0)
{
cMainMenuItem *mmItem = (cMainMenuItem*)Get(FirstSelectable);
@@ -101,14 +98,11 @@ void cMainMenu::Build(const char *dir)
void cMainMenu::BuildDisp0(const char *dir)
{
- dsyslog("Bilde Menu nach DisplayMode 0");
-
cDVDList *DVDList = new cDVDList;
cMainMenuItem *mItem = NULL;
if(DVDSwitchSetup.DisplayDVDDevice)
{
- dsyslog("Füge Eintrag für das DVD-Device hinzu");
Add(new cMainMenuItem(iDevice,ImageList));
if(!MainMenuOptions.getLastSelectItemName() && MainMenuOptions.LastSelectItemType() == iDevice)
FirstSelectable = 0;
@@ -120,7 +114,6 @@ void cMainMenu::BuildDisp0(const char *dir)
(eFileList)DVDSwitchSetup.SortMode,
true))
{
- dsyslog("DVDList erstellt");
cDVDListItem *item = DVDList->First();
while(item)
{
@@ -156,7 +149,6 @@ void cMainMenu::BuildDisp1(const char *dir)
case 0: // Image-Type
if(DVDSwitchSetup.DisplayDVDDevice)
{
- dsyslog("Füge Eintrag für das DVD-Device hinzu");
Add(new cMainMenuItem(iCat, ImageList, dir));
Add(new cMainMenuItem(iDevice, ImageList));
if(!MainMenuOptions.getLastSelectItemName() && MainMenuOptions.LastSelectItemType() == iDevice)
@@ -201,7 +193,6 @@ void cMainMenu::BuildDisp1(const char *dir)
Add(new cMainMenuItem(iCat, ImageList, dir));
if(DVDSwitchSetup.DisplayDVDDevice)
{
- dsyslog("Füge Eintrag für das DVD-Device hinzu");
Add(new cMainMenuItem(iDevice, ImageList));
if(!MainMenuOptions.getLastSelectItemName() && MainMenuOptions.LastSelectItemType() == iDevice)
FirstSelectable = 1;
@@ -257,7 +248,6 @@ void cMainMenu::BuildDisp1(const char *dir)
case 2: // FileType
if(DVDSwitchSetup.DisplayDVDDevice)
{
- dsyslog("Füge Eintrag für das DVD-Device hinzu");
Add(new cMainMenuItem(iCat, ImageList, dir));
Add(new cMainMenuItem(iDevice, ImageList));
if(!MainMenuOptions.getLastSelectItemName() && MainMenuOptions.LastSelectItemType() == iDevice)
@@ -312,7 +302,6 @@ void cMainMenu::BuildDisp1(const char *dir)
break;
}
- dsyslog("Ermittle FirstSelectable");
mItem = (cMainMenuItem*)First();
if(mItem && FirstSelectable < 0)
{
@@ -338,7 +327,6 @@ void cMainMenu::BuildDisp2(const char *dir)
if(DVDSwitchSetup.DisplayDVDDevice && !strcasecmp(dir, MainMenuOptions.ImageDir()))
{
- dsyslog("Füge Eintrag für das DVD-Device hinzu");
Add(new cMainMenuItem(iDevice, ImageList));
if(!MainMenuOptions.getLastSelectItemName() && MainMenuOptions.LastSelectItemType() == iDevice)
{
@@ -530,28 +518,31 @@ eOSState cMainMenu::ProcessKey(eKeys Key)
DVDSwitchSetup.HideTypeCol = CMDImg->tmpHideTypeCol;
if(!isempty(CMDImg->NewFile))
{
+ int iRet = 0;
char *buffer = NULL;
char *buffer2 = NULL;
cFileInfo *info = new cFileInfo(CMDImg->Rename());
if(ImageList.IsHide(info->Extension()))
{
buffer2 = strdup(info->Extension());
- asprintf(&buffer, "%s/%s%s", info->Path(), stripspace(CMDImg->NewFile), buffer2);
+ iRet = asprintf(&buffer, "%s/%s%s", info->Path(), stripspace(CMDImg->NewFile), buffer2);
}
else
- asprintf(&buffer, "%s/%s", info->Path(), stripspace(CMDImg->NewFile));
+ iRet = asprintf(&buffer, "%s/%s", info->Path(), stripspace(CMDImg->NewFile));
DELETENULL(info);
- info = new cFileInfo(buffer);
- if(!info->isExists())
- {
- if(cFileCMD::Rn(CMDImg->Rename(), buffer))
- MainMenuOptions.setLastSelectItemName(buffer);
+ if(iRet > 0) {
+ info = new cFileInfo(buffer);
+ if(!info->isExists())
+ {
+ if(cFileCMD::Rn(CMDImg->Rename(), buffer))
+ MainMenuOptions.setLastSelectItemName(buffer);
+ }
+ else
+ OsdMsg(mtWarning,tr("File exists in Directory"));
+ FREENULL(buffer);
+ DELETENULL(info);
}
- else
- OsdMsg(mtWarning,tr("File exists in Directory"));
- FREENULL(buffer);
FREENULL(buffer2);
- DELETENULL(info);
}
DELETENULL(CMDImg);
Build(MainMenuOptions.CurrentDir());
@@ -927,7 +918,8 @@ char *cMainMenu::CreateOSDName(eMainMenuItem itype, cImageList &ImageList, const
switch(itype)
{
case iCat:
- asprintf(&reg, "^%s", MainMenuOptions.ImageDir());
+ if(0 >= asprintf(&reg, "^%s", MainMenuOptions.ImageDir()))
+ break;
if(!RegIMatch(file, reg))
buffer = file;
else
@@ -985,9 +977,10 @@ char *cMainMenu::CreateOSDName(eMainMenuItem itype, cImageList &ImageList, const
if(DVDSwitchSetup.HideImgSizeCol)
{
char *size = NULL;
- asprintf(&size, "(%03.1f)\t", info->SizeGByte(1));
- tmpOSD += size;
- free(size);
+ if(0 < asprintf(&size, "(%03.1f)\t", info->SizeGByte(1))) {
+ tmpOSD += size;
+ free(size);
+ }
}
tmpOSD += &buffer;
diff --git a/po/de_DE.po b/po/de_DE.po
index 7b4c20c..709fb2c 100644
--- a/po/de_DE.po
+++ b/po/de_DE.po
@@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: vdr-dvdswitch-plugin 0.1.4\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-10-03 15:57+0200\n"
+"POT-Creation-Date: 2010-12-21 13:09+0100\n"
"PO-Revision-Date: 2009-10-03 14:03+0200\n"
"Last-Translator:\n"
"Language-Team: <vdr@linuxtv.org>\n"
+"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-15\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -393,3 +394,12 @@ msgstr "'Verzeichnis enthält' darf nicht leer sein!"
msgid "'File Extension' must not empty!"
msgstr "'Datei Erweiterung' darf nicht leer sein!"
+
+msgid "No rights to delete image"
+msgstr ""
+
+msgid "Operation failed"
+msgstr ""
+
+msgid "No rights to move image"
+msgstr ""
diff --git a/setup-itypes.c b/setup-itypes.c
index f7638b1..5395674 100644
--- a/setup-itypes.c
+++ b/setup-itypes.c
@@ -6,7 +6,6 @@ cMenuSetupDSITypes::cMenuSetupDSITypes(cImageList &imagelist, bool select, int*
: cOsdMenu(tr("Imagetypes"))
, ImageList(imagelist)
{
- dsyslog("Ermitlle ersten Setup-Eintrag");
cSetupLine *item = Setup.First();
Select = select;
RetIndex = retindex;
@@ -113,17 +112,13 @@ eOSState cMenuSetupDSITypes::ProcessKey(eKeys Key)
{
if(SetupLine)
{
- dsyslog("Lösche SetupLine");
Setup.Del(SetupLine);
}
- dsyslog("Hole SetupString");
if(ImageList.GetSetupString())
SetupLine = new cSetupLine("ImageTypes", ImageList.GetSetupString(), "dvdswitch");
else
SetupLine = new cSetupLine("ImageTypes", "", "dvdswitch");
- dsyslog("neue SetupLine erstellt");
Setup.Add(SetupLine);
- dsyslog("neue SetupLine hinzugefügt");
return osBack;
}
break;
diff --git a/setup.c b/setup.c
index 1ff4bf5..8634299 100644
--- a/setup.c
+++ b/setup.c
@@ -26,7 +26,7 @@ cDVDSwitchSetup::cDVDSwitchSetup(void)
HideTypeCol = 0;
CountTypCol = 35;
HideImgSizeCol = 0;
- asprintf(&CatLineChars, "%s", "-_.:#+*!%<>");
+ CatLineChars = strdup("-_.:#+*!%<>");
CatLineChar = CatLineChars[0];
CharCountBeforeCat = 3;
SpacesBeforeAfterCat = 1;
@@ -400,7 +400,7 @@ eOSState cMenuSetupDVDSwitch::ProcessKey(eKeys Key)
void cMenuSetupDVDSwitch::Store(void)
{
- dsyslog("STORE Setup");
+ dsyslog("dvdswitch: store setup");
DVDSwitchSetup = data;
diff --git a/tools.c b/tools.c
index f027a8f..4334ab2 100644
--- a/tools.c
+++ b/tools.c
@@ -27,3 +27,119 @@ cDirList::cDirList(cImageList &ImageList)
delete(token);
}
+cFileDelThread::cFileDelThread(const char *file)
+{
+ File = NULL;
+ Ok = false;
+
+ errno = 0;
+ if(!RightCheck(file))
+ OSDErrorNumMsg(errno,tr("No rights to delete image"));
+ else
+ {
+ if(file)
+ {
+ if(0 < asprintf(&File, "%s.sdel", file)) {
+ dsyslog("dvdswitch: Prepare delete (rename %s to %s)",file, File);
+ if(cFileCMD::Rn(file, File))
+ Ok = true;
+ else
+ OSDErrorNumMsg(errno,tr("Operation failed"));
+ }
+ }
+ }
+}
+
+cFileDelThread::~cFileDelThread(void)
+{
+ free(File);
+}
+
+bool cFileDelThread::RightCheck(const char *value)
+{
+ bool ret = false;
+ if(value)
+ {
+ cFileInfo *info = new cFileInfo(value);
+ ret = info->isWriteable();
+ DELETENULL(info);
+ }
+ return ret;
+}
+
+void cFileDelThread::Action(void)
+{
+ if(File) {
+ dsyslog("dvdswitch: Execute remove %s",File);
+ errno = 0;
+ if(!cFileCMD::Del(File))
+ SysLogErrorNumMsg(errno,"Operation file remove failed");
+ }
+ delete(this);
+};
+
+cFileMoveThread::cFileMoveThread(const char *file, char *dest)
+{
+ FileName = NULL;
+ File = NULL;
+ Dest = NULL;
+ Ok = false;
+
+ errno = 0;
+ if(!RightCheck(file) || !RightCheck(dest))
+ OSDErrorNumMsg(errno,tr("No rights to move image"));
+ else
+ {
+ if(file)
+ {
+ cFileInfo *info = new cFileInfo(file);
+ FileName = strdup(info->FileName());
+ DELETENULL(info);
+ if(0 < asprintf(&File, "%s.smove", file)) {
+ dsyslog("dvdswitch: Prepare move %s to %s",file, File);
+ if(cFileCMD::Rn(file, File))
+ Ok = true;
+ else
+ OSDErrorNumMsg(errno,tr("Operation failed"));
+ }
+ }
+ Dest = dest ? strdup(dest) : NULL;
+ }
+}
+
+cFileMoveThread::~cFileMoveThread(void)
+{
+ free(FileName);
+ free(File);
+ free(Dest);
+}
+
+bool cFileMoveThread::RightCheck(const char *value)
+{
+ bool ret = false;
+ if(value)
+ {
+ cFileInfo *info = new cFileInfo(value);
+ ret = info->isWriteable();
+ DELETENULL(info);
+ }
+ return ret;
+}
+
+void cFileMoveThread::Action(void)
+{
+ if(FileName && File && Dest)
+ {
+ char *buffer = NULL;
+ if(0 < asprintf(&buffer, "%s/%s", Dest, FileName)) {
+ dsyslog("dvdswitch: Execute move %s to %s",File, buffer);
+ errno = 0;
+ if(!cFileCMD::Rn(File, buffer))
+ SysLogErrorNumMsg(errno,"Operation file remove failed");
+ free(buffer);
+ }
+ }
+ delete(this);
+}
+
+