diff options
author | Martin Prochnow <nordlicht@martins-kabuff.de> | 2006-05-29 16:02:12 +0200 |
---|---|---|
committer | Andreas Mair <andreas@vdr-developer.org> | 2006-05-29 16:02:12 +0200 |
commit | 40d2369b12da350f684f5364a00c3501a6c038e6 (patch) | |
tree | 26355fcd63be09e46416bd903d2d6b7936791a1a | |
parent | 47a981960f1d0b6d0d8cbe3bdc15f2b9e8665731 (diff) | |
download | vdr-plugin-extrecmenu-40d2369b12da350f684f5364a00c3501a6c038e6.tar.gz vdr-plugin-extrecmenu-40d2369b12da350f684f5364a00c3501a6c038e6.tar.bz2 |
Version 0.11v0.11
- added czech translation; thanks to Vladimír Bárta
- added missing dialog for video dvds
- added more meaningful error messages
- avoid empty names and names starting with . or .. while editing
- free space display in title bar is now updated immediately
- switched off editing of recordings and directories while a cut is in progress
- switched off resume by 'Play' or 'Menu'->'Blue' for archive dvd recordings
- changed back the behaviour if replay ends; plugin has to open to unmount archive dvds
- removed setup option "While opening jump to last replayed recording"; its implemention interfers with the following one
- after renaming a recording, the selection bar now stays at this renamed list entry
- the parameters 'move' and 'rename' for the '-r'-option of VDR have now the following format: move/rename oldname newname
- fixed hopefully all problems in connection with renaming and moving directories
- plugins closes if there are no recordings - fixed
-rw-r--r-- | HISTORY | 22 | ||||
-rw-r--r-- | extrecmenu.c | 5 | ||||
-rw-r--r-- | extrecmenu.h | 2 | ||||
-rw-r--r-- | i18n.c | 558 | ||||
-rw-r--r-- | mymenueditrecording.c | 160 | ||||
-rw-r--r-- | mymenurecordings.c | 157 | ||||
-rw-r--r-- | mymenurecordings.h | 10 | ||||
-rw-r--r-- | mymenusetup.c | 13 | ||||
-rw-r--r-- | mymenusetup.h | 3 | ||||
-rw-r--r-- | myreplaycontrol.c | 9 | ||||
-rw-r--r-- | myreplaycontrol.h | 2 | ||||
-rwxr-xr-x | scripts/dvdarchive.sh | 83 | ||||
-rw-r--r-- | tools.c | 79 | ||||
-rw-r--r-- | tools.h | 2 |
14 files changed, 891 insertions, 214 deletions
@@ -1,6 +1,26 @@ VDR Plugin 'extrecmenu' Revision History ---------------------------------------- +2006-28-05: Version 0.11 +- added czech translation; thanks to Vladimír Bárta +- added missing dialog for video dvds +- added more meaningful error messages +- avoid empty names and names starting with . or .. while editing +- free space display in title bar is now updated immediately +- switched off editing of recordings and directories while a cut is in progress +- switched off resume by 'Play' or 'Menu'->'Blue' for archive dvd recordings +- changed back the behaviour if replay ends; plugin has to open to unmount + archive dvds +- removed setup option "While opening jump to last replayed recording"; its + implemention interfers with the following one +- after renaming a recording, the selection bar now stays at this renamed list + entry +- the parameters 'move' and 'rename' for the '-r'-option of VDR have now the + following format: move/rename oldname newname +- fixed hopefully all problems in connection with renaming and moving + directories +- plugins closes if there are no recordings - fixed + 2006-02-05: Version 0.10 - made changes to Makefile for APIVERSION (VDR >= 1.3.47) - changed myReplayControl; suggested by Thomas Günther @@ -16,7 +36,7 @@ VDR Plugin 'extrecmenu' Revision History - switched off editing of details (priority and lifetime) or archive dvd recordings to avoid trouble with the dir name that identifies it on the media - added option to mark last replayed recording while opening the plugin -- added possibilty to include video dvd's into the recordings hierarchy; see +- added possibilty to include video dvds into the recordings hierarchy; see README - introduced new parameters for the '-r'-option if VDR: move, rename and delete diff --git a/extrecmenu.c b/extrecmenu.c index 01388b5..9c83f6e 100644 --- a/extrecmenu.c +++ b/extrecmenu.c @@ -87,10 +87,7 @@ bool cPluginExtrecmenu::SetupParse(const char *Name, const char *Value) if(!strcasecmp(Name,"SortRecords")) mysetup.SortRecords=atoi(Value); else - if(!strcasecmp(Name,"JumpRec")) - mysetup.JumpRec=atoi(Value); - else - return false; + return false; return true; } diff --git a/extrecmenu.h b/extrecmenu.h index 542886c..662481c 100644 --- a/extrecmenu.h +++ b/extrecmenu.h @@ -1,6 +1,6 @@ #include <vdr/plugin.h> -static const char *VERSION = "0.10"; +static const char *VERSION = "0.11"; static const char *DESCRIPTION = "Extended recordings menu"; static const char *MAINMENUENTRY = "ExtRecMenu"; @@ -14,6 +14,18 @@ const tI18nPhrase Phrases[] = { "Menu enregistrement étandu", "", "Laajennettu tallennevalikko", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Rozšířené menu nahrávek", }, { "Button$Open", "Öffnen", @@ -24,6 +36,18 @@ const tI18nPhrase Phrases[] = { "Ouvrir", "", "Avaa", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Otevřít", }, { "Button$Cancel", "Abbrechen", @@ -34,6 +58,18 @@ const tI18nPhrase Phrases[] = { "Interrompre", "", "Peruuta", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Zrušit", }, { "Button$Play", "Wiedergabe", @@ -44,6 +80,18 @@ const tI18nPhrase Phrases[] = { "Montrer", "", "Toista", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Přehrát", }, { "Button$Commands", "Befehle", @@ -54,6 +102,18 @@ const tI18nPhrase Phrases[] = { "Commande", "", "Komennot", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Příkazy", }, { "Button$Rewind", "Anfang", @@ -64,6 +124,18 @@ const tI18nPhrase Phrases[] = { "Début", "", "Alkuun", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Na začátek", }, { "Button$Create", "Anlegen", @@ -74,6 +146,18 @@ const tI18nPhrase Phrases[] = { "Créer", "", "Luo", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Vytvořit", }, { "Button$Edit", "Editieren", @@ -84,6 +168,18 @@ const tI18nPhrase Phrases[] = { "Éditer", "", "Muokkaa", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Editovat", }, { "Button$Rename", "Umbenennen", @@ -94,6 +190,18 @@ const tI18nPhrase Phrases[] = { "Renommer", "", "Nimeä", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Přejmenovat", }, { "Button$Move", "Verschieben", @@ -104,6 +212,18 @@ const tI18nPhrase Phrases[] = { "Déplacer", "", "Siirrä", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Přesunout", }, { "Button$Delete", "Löschen", @@ -114,6 +234,18 @@ const tI18nPhrase Phrases[] = { "Effacer", "", "Poista", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Smazat", }, { "Button$Info", "Info", @@ -124,6 +256,18 @@ const tI18nPhrase Phrases[] = { "Info", "", "Tiedot", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Info", }, { "New folder", "Neues Verzeichnis", @@ -134,6 +278,18 @@ const tI18nPhrase Phrases[] = { "Nouveau dossier", "", "Uusi kansio", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Nový adresář", }, { "Rename", "Umbenennen", @@ -144,6 +300,18 @@ const tI18nPhrase Phrases[] = { "Renommer", "", "Nimeä", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Přejmenovat", }, { "Show recording date", "Zeige Aufnahmedatum", @@ -154,6 +322,18 @@ const tI18nPhrase Phrases[] = { "Afiicher la date d'enregistrement", "", "Näytä tallenteen päiväys", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Zobrazit datum nahrávky", }, { "Show recording time", "Zeige Aufnahmezeit", @@ -164,6 +344,18 @@ const tI18nPhrase Phrases[] = { "Afficher l'heure d'enregistrement", "", "Näytä tallenteen ajankohta", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Zobrazit čas nahrávky", }, { "Show recording length", "Zeige Aufnahmelänge", @@ -174,6 +366,18 @@ const tI18nPhrase Phrases[] = { "Afficher la longeur de l'enregistrement", "", "Näytä tallenteen kesto", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Zobrazit délku nahrávky", }, { "Hide main menu entry", "Hauptmenüeintrag ausblenden", @@ -184,6 +388,18 @@ const tI18nPhrase Phrases[] = { "Menu Enregistrement étandu invisible", "", "Piilota valinta päävalikosta", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Skrýt položku v hlavním menu", }, { "Replace original recordings menu", "Originales Aufzeichnungsmenü ersetzen", @@ -194,6 +410,18 @@ const tI18nPhrase Phrases[] = { "Remplacer le nenu original Enregistrement", "", "Korvaa alkuperäinen 'Tallenteet'-valikko", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Nahradit originální menu nahrávek", }, { "Show alternative to new marker", "Alternative zu Neu-Marker anzeigen", @@ -203,7 +431,19 @@ const tI18nPhrase Phrases[] = { "", "", "", + "Käytä vaihtoehtoista uuden tallenteen merkintää", + "", + "", "", + "", + "", + "", + "", + "", + "", + "", + "", + "Zobrazit alternativu k novým značkám", }, { "Please insert DVD %s", "Bitte DVD %s einlegen", @@ -214,6 +454,18 @@ const tI18nPhrase Phrases[] = { "Mettez le DVD %s dans le lecteur", "", "Laita DVD %s asemaan", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Vložte prosím DVD %s", }, { "Error while mounting DVD!", "Fehler beim Einhängen der DVD!", @@ -224,6 +476,18 @@ const tI18nPhrase Phrases[] = { "Erreur lors du montage du DVD!", "", "DVD:n avaaminen epäonnistui!", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Chyba během připojování DVD!", }, { "Recording not found on DVD!", "Aufzeichnung auf DVD nicht gefunden!", @@ -234,16 +498,40 @@ const tI18nPhrase Phrases[] = { "Il n'y a pas d'enregistrement sur le DVD!", "", "Tallennetta ei löydy DVD:ltä!", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Nahrávka nebyla na DVD nalezena!", }, - { "Show dvd number", - "DVD-Nummer anzeigen", + { "Show dvd id", + "DVD-ID anzeigen", + "", + "", + "", + "", + "", "", + "Näytä DVD:n tunniste", "", "", "", - "Afficher le numéro des DVD", "", - "Näytä DVD:n numero", + "", + "", + "", + "", + "", + "", + "", + "Zobrazit identifikátor DVD", }, { "Script 'dvdarchive.sh' not found!", "Skript 'dvdarchive.sh' wurde nicht gefunden!", @@ -254,6 +542,18 @@ const tI18nPhrase Phrases[] = { "Impossible de trouver le script 'dvdarchive.sh'!", "", "'dvdarchive.sh'-skriptiä ei löydetä!", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Skript 'dvdarchive.sh' nebyl nalezen!", }, { "[base dir]", "[Stammverzeichnis]", @@ -264,6 +564,18 @@ const tI18nPhrase Phrases[] = { "[Dossier racine]", "", "[juurihakemisto]", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "[základní adresář]", }, { "No DVD in drive!", "Keine DVD im Laufwerk!", @@ -274,6 +586,18 @@ const tI18nPhrase Phrases[] = { "Pas de DVD dans le lecteur!", "", "Asemassa ei ole DVD-levyä!", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "V jednotce není DVD!", }, { "Error while linking [0-9]*.vdr!", "Fehler beim Anlegen der Symlinks [0-9]*.vdr!", @@ -284,6 +608,18 @@ const tI18nPhrase Phrases[] = { "Erreur lors de la création des racourcis [0-9]*.vdr!", "", "Tiedostojen [0-9]*.vdr linkittäminen epäonnistui!", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Chyba při spojování [0-9]*.vdr!", }, { "sudo or mount --bind / umount error (vfat system)", "sudo oder mount --bind / umount Fehler (VFAT-System)", @@ -293,7 +629,19 @@ const tI18nPhrase Phrases[] = { "", "", "", + "Sudo tai mount --bind / umount -komento epäonnistui (VFAT)!", + "", + "", + "", + "", + "", + "", + "", + "", + "", "", + "", + "sudo nebo mount --bind / umount selhal (VFAT-systém)", }, { "Show \"new recordings column\"", "\"Neue-Aufzeichnungen-Spalte\" anzeigen", @@ -304,6 +652,18 @@ const tI18nPhrase Phrases[] = { "\"Colone nouveaux enregistrements\" Afficher", "", "Näytä \"uudet tallenteet\"-sarake", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Zobrazit \"sloupec nová nahrávka\"", }, { "Sort recordings by", "Aufnahme sortieren nach", @@ -314,6 +674,18 @@ const tI18nPhrase Phrases[] = { "Trier enregistrements par", "", "Järjestä tallenteet", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Řadit nahrávky podle", }, { "alphabet for main-, flexible for subdirectories", "Alphabet für Haupt-, flexibel für Unterverzeichnisse", @@ -324,6 +696,18 @@ const tI18nPhrase Phrases[] = { "Alphabet pour les dossiers, flexible pour les sous-dossiers", "", "juurihakemisto aakkosittain", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "abecedy pro hlavní, flex. pro podadresáře", }, { "date for main-, flexible for subdirectories", "Datum für Haupt, flexibel für Unterverzeichnisse", @@ -334,6 +718,18 @@ const tI18nPhrase Phrases[] = { "Date pour les dossiers, flexible pour les sous-dossiers", "", "juurihakemisto päivämäärän mukaan", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "datumu pro hlavní, flex pro podadresáře", }, { "alphabet for all directories", "Alphabet für alle Verzeichnisse", @@ -344,6 +740,18 @@ const tI18nPhrase Phrases[] = { "Alphabet pour tous les dossiers", "", "kaikki aakkosittain", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "abecedy pro všechny adresáře", }, { "date for all directories", "Datum für alle Verzeichnisse", @@ -354,6 +762,18 @@ const tI18nPhrase Phrases[] = { "Date pour tous les dossiers", "", "kaikki päivämäärän mukaan", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "datumu pro všechny adresáře", }, { "Details", "Details", @@ -364,9 +784,6 @@ const tI18nPhrase Phrases[] = { "Détails", "", "Lisätiedot", - }, - { "While opening jump to last replayed recording", - "Zuletzt abgespielte Aufnahme beim Öffnen anspringen", "", "", "", @@ -374,6 +791,11 @@ const tI18nPhrase Phrases[] = { "", "", "", + "", + "", + "", + "", + "Detaily", }, { "DVD plugin is not installed!", "Das DVD-Plugin ist nicht installiert!", @@ -381,9 +803,131 @@ const tI18nPhrase Phrases[] = { "", "", "", + "Le plugin DVD n'est pas installé!", + "", + "DVD-laajennosta ei löydy!", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Modul DVD není nainstalován!", + }, + { "Rename/Move failed!", + "Umbenennen/Verschieben fehlgeschlagen!", + "", + "", + "", + "", + "Renommer/déplacer ŕ échoué!", + "", + "Nimeäminen/siirto epäonnistui!", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Přejmenování/Přesun selhal!", + }, + { "Creating directories failed!", + "Verzeichnisse anlegen fehlgeschlagen!", + "", + "", + "", + "", + "Echecs lors de la création du dossier!", + "", + "Hakemiston luonti epäonnistui!", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Selhalo vytvoření adresáře!", + }, + { "Invalid filename!", + "Ungültiger Dateiname!", + "", + "", + "", + "", + "Nom de fichiers n'est pas valide'", + "", + "Virheellinen tiedoston nimi!", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Chybné jméno souboru!", + }, + { "Editing not allowed while cutting!", + "Editieren während des Schneidens nicht erlaubt!", + "", + "", + "", + "", + "Editer pendant la découpe n'est pas possible!", + "", + "Muokkaus leikkauksen aikana ei ole sallittu!", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Je spuštěn střih - Editovat nyní nelze!", + }, + { "Moving into own sub-directory not allowed!", + "Verschieben in eigenes Unterverzeichnis nicht erlaubt!", + "", + "", + "", + "", + "Déplacer dans le sous-dossier propre, n'est pas possible!", + "", + "Siirto omaan alihakemistoon ei ole sallittu!", + "", + "", + "", + "", + "", + "", + "", + "", "", "", "", + "Přesun do vlastního podadresáře není povolen!", }, { NULL } }; diff --git a/mymenueditrecording.c b/mymenueditrecording.c index a7f3c3f..e50c302 100644 --- a/mymenueditrecording.c +++ b/mymenueditrecording.c @@ -8,7 +8,7 @@ #include "mymenurecordings.h" #include "tools.h" -bool clearall; +bool myMenuMoveRecording::clearall=false; char newname[128]; // --- myMenuRenameRecording -------------------------------------------------- @@ -64,49 +64,30 @@ eOSState myMenuRenameRecording::ProcessKey(eKeys Key) char *oldname=NULL; char *newname=NULL; + if(strchr(name,'.')==name||!strlen(name)) + { + Skins.Message(mtError,tr("Invalid filename!")); + cRemote::Put(kRight); + return osContinue; + } + if(isdir) asprintf(&oldname,"%s%s%s/%s",VideoDirectory,path[0]?"/":"",dirbase?ExchangeChars(dirbase,true):"",ExchangeChars(dirname,true)); else oldname=strdup(recording->FileName()); asprintf(&newname,"%s%s%s/%s%s",VideoDirectory,path[0]?"/":"",ExchangeChars(path,true),ExchangeChars(name,true),isdir?"":strrchr(recording->FileName(),'/')); - - if(strcmp(oldname,newname)) + + if(MoveRename(oldname,newname,isdir?NULL:recording,false)) { - if(MakeDirs(newname,true)==false) - { - Skins.Message(mtError,"Error while accessing recording!"); - state=osContinue; - } - else - { - isyslog("[extrecmenu] moving %s to %s",oldname,newname); - - if(rename(oldname,newname)==-1) - { - esyslog("[extrecmenu] error while moving: %s",strerror(errno)); - Skins.Message(mtError,tr("Error while accessing recording!")); - state=osContinue; - } - else - { - cRecordingUserCommand::InvokeCommand("rename",newname); - if(isdir) - Recordings.Update(true); - else - { - free(newname); - asprintf(&newname,"%s%s%s/%s%s",VideoDirectory,path[0]?"/":"",path,name,strrchr(recording->FileName(),'/')); - Recordings.AddByName(newname); - Recordings.Del(recording,false); - } - menurecordings->Set(true); - state=osBack; - } - } + state=osBack; + menurecordings->Set(true,isdir?NULL:newname); } else - state=osBack; + { + cRemote::Put(kRight); + state=osContinue; + } free(oldname); free(newname); @@ -142,8 +123,17 @@ eOSState myMenuNewName::ProcessKey(eKeys Key) { if(Key==kOk) { - strn0cpy(newname,name,sizeof(newname)); - state=osBack; + if(strchr(name,'.')==name||!strlen(name)) + { + Skins.Message(mtError,tr("Invalid filename!")); + cRemote::Put(kRight); + state=osContinue; + } + else + { + strn0cpy(newname,name,sizeof(newname)); + state=osBack; + } } if(Key==kBack) state=osBack; @@ -242,9 +232,8 @@ void myMenuMoveRecording::Set() if(lastitemtext&&!strcmp(lastitemtext,item->Text())) // same text { if(lastitem&&lastitem->Level()<item->Level()) // if level of the previous item is lower, set it to the new value - { lastitem->SetLevel(item->Level()); - } + delete item; } else @@ -287,70 +276,62 @@ eOSState myMenuMoveRecording::MoveRec() char *oldname=NULL; char *newname=NULL; char *dir=NULL; - char *p=NULL; eOSState state=osContinue; - myMenuMoveRecordingItem *item=(myMenuMoveRecordingItem*)Get(Current()); - if(dirname) asprintf(&oldname,"%s%s%s/%s",VideoDirectory,dirbase?"/":"",dirbase?ExchangeChars(dirbase,true):"",ExchangeChars(dirname,true)); else oldname=strdup(recording->FileName()); - p=strrchr(oldname,'/'); - if(p&&!dirname) - *p=0; - + myMenuMoveRecordingItem *item=(myMenuMoveRecordingItem*)Get(Current()); if(item) { if(strcmp(tr("[base dir]"),item->Text())) { - asprintf(&dir,"%s%s%s",base?base:"",base?"~":"",item->Text()); - ExchangeChars(dir,true); + if(dirname) + asprintf(&dir,"%s%s%s",base?base:"",base?"~":"",item->Text()); + else + { + char *p=strrchr(recording->Name(),'~'); + asprintf(&dir,"%s%s%s~%s",base?base:"",base?"~":"",item->Text(),p?p+1:recording->Name()); + } + } + else + { + if(!dirname) + { + char *p=strrchr(recording->Name(),'~'); + asprintf(&dir,"%s",p?++p:recording->Name()); + } } } else { - asprintf(&dir,"%s",base); - ExchangeChars(dir,true); + if(dirname) + asprintf(&dir,"%s",base); + else + { + char *p=strrchr(recording->Name(),'~'); + asprintf(&dir,"%s~%s",base,p?p:recording->Name()); + } } + if(dir) + ExchangeChars(dir,true); - asprintf(&newname,"%s%s%s/%s",VideoDirectory,dir?"/":"",dir?dir:"",strrchr(oldname,'/')+1); + asprintf(&newname,"%s%s%s%s",VideoDirectory,dir?"/":"",dir?dir:"",strrchr(dirname?oldname:recording->FileName(),'/')); - if(MakeDirs(newname,true)==false) + if(MoveRename(oldname,newname,dirname?NULL:recording,true)) { - Skins.Message(mtError,"Error while accessing recording!"); - state=osContinue; - } - else - { - isyslog("[extrecmenu] moving %s to %s",oldname,newname); - if(rename(oldname,newname)==-1) - { - esyslog("[extrecmenu] error while moving: %s",strerror(errno)); - Skins.Message(mtError,"Error while accessing recording!"); - state=osContinue; - } - else - { - cRecordingUserCommand::InvokeCommand("move",newname); - if(dirname) - Recordings.Update(true); - else - { - free(newname); - asprintf(&newname,"%s%s%s/%s%s",VideoDirectory,dir?"/":"",dir?dir:"",strrchr(oldname,'/')+1,strrchr(recording->FileName(),'/')); - Recordings.AddByName(newname); - Recordings.Del(recording,false); - } - clearall=true; - state=osBack; - } + clearall=true; + state=osBack; + menurecordings->Set(true); } + free(oldname); free(newname); free(dir); + return state; } @@ -412,26 +393,13 @@ eOSState myMenuRecordingDetails::ProcessKey(eKeys Key) sprintf(newname+strlen(newname)-9,"%02d.%02d.rec",priority,lifetime); - if(strcmp(oldname,newname)) + if(MoveRename(oldname,newname,recording,false)) { - isyslog("[extrecmenu] moving %s to %s",oldname,newname); - - if(rename(oldname,newname)==-1) - { - esyslog("[extrecmenu] error while moving: %s",strerror(errno)); - Skins.Message(mtError,tr("Error while accessing recording!")); - state=osContinue; - } - else - { - Recordings.AddByName(newname); - Recordings.Del(recording,false); - menurecordings->Set(true); - state=osBack; - } + state=osBack; + menurecordings->Set(true,newname); } else - state=osBack; + state=osContinue; free(oldname); free(newname); diff --git a/mymenurecordings.c b/mymenurecordings.c index 5279e01..0b9e5e1 100644 --- a/mymenurecordings.c +++ b/mymenurecordings.c @@ -6,6 +6,7 @@ #include <vdr/videodir.h> #include <vdr/status.h> #include <vdr/plugin.h> +#include <vdr/cutter.h> #include "myreplaycontrol.h" #include "mymenurecordings.h" #include "mymenusetup.h" @@ -120,6 +121,7 @@ myMenuRecordingsItem::myMenuRecordingsItem(cRecording *Recording,int Level) name=strdup(title+2); } else + { if(Level==level) // recording entries { s=strrchr(Recording->Name(),'~'); @@ -181,7 +183,7 @@ myMenuRecordingsItem::myMenuRecordingsItem(cRecording *Recording,int Level) } // determine if the dvd is a video dvd char tmp[BUFSIZ]; - if(fgets(tmp,sizeof(tmp),f)&&!strncmp(tmp,"0000",4)) + if(fgets(tmp,sizeof(tmp),f)) isvideodvd=true; fclose(f); @@ -217,10 +219,11 @@ myMenuRecordingsItem::myMenuRecordingsItem(cRecording *Recording,int Level) asprintf(&id,"%s %s %s",recdate,rectime,Recording->Name()); } else + { if(Level>level) // any other - { title=""; - } + } + } SetText(title); } @@ -251,7 +254,8 @@ void myMenuRecordingsItem::IncrementCounter(bool IsNew) } // --- myMenuRecordings ------------------------------------------------------- -#define MB_PER_MINUTE 25.75 // this is just an estimate! +bool myMenuRecordings::golastreplayed=false; +bool myMenuRecordings::wasdvd; myMenuRecordings::myMenuRecordings(const char *Base,int Level):cOsdMenu(Base?Base:"") { @@ -263,14 +267,6 @@ myMenuRecordings::myMenuRecordings(const char *Base,int Level):cOsdMenu(Base?Bas PatchFont(fontSml); else PatchFont(fontOsd); - - // show free disc space at title bar - int freemb; - VideoDiskSpace(&freemb); - int minutes=int(double(freemb)/MB_PER_MINUTE); - char buffer[40]; - snprintf(buffer,sizeof(buffer),"%s - %2d:%02d %s",tr("Recordings"),minutes/60,minutes%60,tr("free")); - SetTitle(buffer); } // set tabs if(mysetup.ShowRecDate&&mysetup.ShowRecTime&&!mysetup.ShowRecLength) // recording date and time are shown, recording length not @@ -296,7 +292,7 @@ myMenuRecordings::myMenuRecordings(const char *Base,int Level):cOsdMenu(Base?Bas Display(); - if(mysetup.wasdvd&&!cControl::Control()) + if(wasdvd&&!cControl::Control()) { char *cmd=NULL; asprintf(&cmd,"dvdarchive.sh umount \"%s\"",*strescape(myReplayControl::LastReplayed(),"'\\\"$")); @@ -311,11 +307,11 @@ myMenuRecordings::myMenuRecordings(const char *Base,int Level):cOsdMenu(Base?Bas isyslog("[extrecmenu] dvdarchive.sh returns %d",result); free(cmd); - mysetup.wasdvd=false; + wasdvd=false; } Set(); - if(myReplayControl::LastReplayed()&&myReplayControl::jumprec) + if(myReplayControl::LastReplayed()) Open(); Display(); @@ -335,6 +331,16 @@ myMenuRecordings::~myMenuRecordings() } } +void myMenuRecordings::SetFreeSpaceTitle() +{ + int freemb; + VideoDiskSpace(&freemb); + int minutes=int(double(freemb)/MB_PER_MINUTE); + char buffer[40]; + snprintf(buffer,sizeof(buffer),"%s - %2d:%02d %s",tr("Recordings"),minutes/60,minutes%60,tr("free")); + SetTitle(buffer); +} + void myMenuRecordings::SetHelpKeys() { if(!HasSubMenu()) @@ -368,12 +374,28 @@ void myMenuRecordings::SetHelpKeys() } // create the menu list -void myMenuRecordings::Set(bool Refresh) +void myMenuRecordings::Set(bool Refresh,char *current) { - const char *lastreplayed=myReplayControl::LastReplayed(); + const char *lastreplayed=current?current:myReplayControl::LastReplayed(); + + if(level==0) + SetFreeSpaceTitle(); cThreadLock RecordingsLock(&Recordings); + + if(Refresh&&!current) + { + myMenuRecordingsItem *item=(myMenuRecordingsItem*)Get(Current()); + if(item) + { + cRecording *recording=Recordings.GetByName(item->FileName()); + if(recording) + lastreplayed=recording->FileName(); + } + } + Clear(); + // create my own recordings list from VDR's myRecList *list=new myRecList(); for(cRecording *recording=Recordings.First();recording;recording=Recordings.Next(recording)) @@ -406,11 +428,16 @@ void myMenuRecordings::Set(bool Refresh) { if(lastitem->IsDirectory()) lastitem->IncrementCounter(recording->IsNew()); - if(lastreplayed&&!strcmp(lastreplayed,recording->FileName())&&myReplayControl::jumprec) + if(lastreplayed&&!strcmp(lastreplayed,recording->FileName())) { - SetCurrent(lastitem); - if(recitem&&!recitem->IsDirectory()&&!cControl::Control()&&!mysetup.JumpRec) - myReplayControl::jumprec=false; + if(golastreplayed||Refresh) + { + SetCurrent(lastitem); + if(recitem&&!recitem->IsDirectory()) + golastreplayed=false; + } + if(recitem&&!recitem->IsDirectory()&&recitem->IsDVD()&&!cControl::Control()) + cReplayControl::ClearLastReplayed(cReplayControl::LastReplayed()); } } } @@ -468,30 +495,32 @@ eOSState myMenuRecordings::Play() cRecording *recording=GetRecording(item); if(recording) { - if(item->IsVideoDVD()) - { - cPlugin *plugin=cPluginManager::GetPlugin("dvd"); - if(plugin) - { - cOsdObject *osd=plugin->MainMenuAction(); - delete osd; - osd=NULL; - return osEnd; - } - else - { - Skins.Message(mtError,tr("DVD plugin is not installed!")); - return osContinue; - } - } - else + if(item->IsDVD()) { - if(item->IsDVD()) + asprintf(&msg,tr("Please insert DVD %s"),item->DvdNr()); + if(Interface->Confirm(msg)) { - asprintf(&msg,tr("Please insert DVD %s"),item->DvdNr()); - if(Interface->Confirm(msg)) + free(msg); + // recording is a video dvd + if(item->IsVideoDVD()) + { + cPlugin *plugin=cPluginManager::GetPlugin("dvd"); + if(plugin) + { + cOsdObject *osd=plugin->MainMenuAction(); + delete osd; + osd=NULL; + return osEnd; + } + else + { + Skins.Message(mtError,tr("DVD plugin is not installed!")); + return osContinue; + } + } + // recording is a archive dvd + else { - free(msg); strcpy(path,recording->FileName()); name=strrchr(path,'/')+1; asprintf(&msg,"dvdarchive.sh mount \"%s\" '%s'",*strescape(path,"'"),*strescape(name,"'\\\"$")); @@ -517,20 +546,20 @@ eOSState myMenuRecordings::Play() Skins.Message(mtError,tr("Script 'dvdarchive.sh' not found!")); return osContinue; } - mysetup.wasdvd=true; - } - else - { - free(msg); - return osContinue; + wasdvd=true; } } - myReplayControl::jumprec=true; - myReplayControl::SetRecording(recording->FileName(),recording->Title()); - cControl::Shutdown(); // stop running playbacks - cControl::Launch(new myReplayControl); // start playback - return osEnd; // close plugin + else + { + free(msg); + return osContinue; + } } + golastreplayed=true; + myReplayControl::SetRecording(recording->FileName(),recording->Title()); + cControl::Shutdown(); // stop running playbacks + cControl::Launch(new myReplayControl); // start playback + return osEnd; // close plugin } } } @@ -654,7 +683,7 @@ eOSState myMenuRecordings::MoveRec() myMenuRecordingsItem *item=(myMenuRecordingsItem*)Get(Current()); if(item) { - clearall=false; + myMenuMoveRecording::clearall=false; if(item->IsDirectory()) return AddSubMenu(new myMenuMoveRecording(this,NULL,base,item->Name())); else @@ -736,6 +765,7 @@ eOSState myMenuRecordings::ProcessKey(eKeys Key) else { bool hadsubmenu=HasSubMenu(); + state=cOsdMenu::ProcessKey(Key); if(state==osUnknown) { @@ -744,7 +774,10 @@ eOSState myMenuRecordings::ProcessKey(eKeys Key) case kOk: return Play(); case kRed: return (helpkeys>1&&RecordingCommands.Count())?Commands():Play(); case kGreen: return Rewind(); - case kYellow: { + case kYellow: if(cCutter::Active()) + Skins.Message(mtError,tr("Editing not allowed while cutting!")); + else + { myMenuRecordingsItem *item=(myMenuRecordingsItem*)Get(Current()); if(!HasSubMenu()&&item) { @@ -752,23 +785,23 @@ eOSState myMenuRecordings::ProcessKey(eKeys Key) if(item->IsDirectory()) SetHelp(tr("Button$Rename"),tr("Button$Move")); else - SetHelp(tr("Button$Rename"),tr("Button$Move"),tr("Button$Delete"),!item->IsDVD()?tr("Details"):NULL); + SetHelp(tr("Button$Rename"),tr("Button$Move"),tr("Button$Delete"),(!item->IsDVD())?tr("Details"):NULL); } - break; } + break; case kBlue: return Info(); case k1...k9: return Commands(Key); default: break; } } - // refresh list after submenu has closed - if(hadsubmenu&&!HasSubMenu()&&Recordings.StateChanged(recordingsstate)) - Set(true); - // go back if list is empty - if(!Count()) + if(!Count()&&level>0) state=osBack; + // update menu list after sub menu has closed + if(hadsubmenu&&!HasSubMenu()||Recordings.StateChanged(recordingsstate)||cCutter::Active()) + Set(true); + if(!HasSubMenu()&&Key!=kNone); SetHelpKeys(); } diff --git a/mymenurecordings.h b/mymenurecordings.h index c7d8830..8f17f69 100644 --- a/mymenurecordings.h +++ b/mymenurecordings.h @@ -1,4 +1,4 @@ -extern bool clearall; // needed for myMenuMoveRecording +#define MB_PER_MINUTE 25.75 // this is just an estimate! // --- myMenuRecordingsItem --------------------------------------------------- class myMenuRecordingsItem:public cOsdItem @@ -31,11 +31,14 @@ class myMenuRecordings:public cOsdMenu { private: bool edit; + static bool wasdvd; + static bool golastreplayed; int level,helpkeys; int recordingsstate; char *base; bool Open(); void SetHelpKeys(); + void SetFreeSpaceTitle(); cRecording *GetRecording(myMenuRecordingsItem *Item); eOSState Play(); eOSState Rewind(); @@ -48,7 +51,7 @@ class myMenuRecordings:public cOsdMenu public: myMenuRecordings(const char *Base=NULL,int Level=0); ~myMenuRecordings(); - void Set(bool Refresh=false); + void Set(bool Refresh=false,char *current=NULL); virtual eOSState ProcessKey(eKeys Key); }; @@ -83,8 +86,9 @@ class myMenuMoveRecording:public cOsdMenu eOSState Create(); public: myMenuMoveRecording(myMenuRecordings *MenuRecordings,cRecording *Recording,const char *DirBase,const char *DirName,const char *Base=NULL,int Level=0); - myMenuMoveRecording::~myMenuMoveRecording(); + ~myMenuMoveRecording(); virtual eOSState ProcessKey(eKeys Key); + static bool clearall; }; // --- myMenuRecordingDetails ------------------------------------------------- diff --git a/mymenusetup.c b/mymenusetup.c index ccbf76a..4af1ca9 100644 --- a/mymenusetup.c +++ b/mymenusetup.c @@ -16,8 +16,6 @@ mySetup::mySetup() mysetup.ShowRecLength=0; mysetup.ShowNewRecs=1; mysetup.SortRecords=0; - mysetup.JumpRec=1; - mysetup.wasdvd=false; } mySetup mysetup; @@ -38,18 +36,16 @@ myMenuSetup::myMenuSetup() showdvdnr=mysetup.ShowDvdNr; shownewrecs=mysetup.ShowNewRecs; sortrecords=mysetup.SortRecords; - jumprec=mysetup.JumpRec; + Add(new cMenuEditBoolItem(tr("Hide main menu entry"),&hidemainmenuentry)); + Add(new cMenuEditBoolItem(tr("Replace original recordings menu"),&replaceorgrecmenu)); Add(new cMenuEditBoolItem(tr("Show recording date"),&showrecdate)); Add(new cMenuEditBoolItem(tr("Show recording time"),&showrectime)); Add(new cMenuEditBoolItem(tr("Show recording length"),&showreclength)); Add(new cMenuEditBoolItem(tr("Show \"new recordings column\""),&shownewrecs)); - Add(new cMenuEditStraItem(tr("Sort recordings by"),&sortrecords,4,sortrecordstext)); Add(new cMenuEditBoolItem(tr("Show alternative to new marker"),&patchnew)); - Add(new cMenuEditBoolItem(tr("Show dvd number"),&showdvdnr)); - Add(new cMenuEditBoolItem(tr("Hide main menu entry"),&hidemainmenuentry)); - Add(new cMenuEditBoolItem(tr("Replace original recordings menu"),&replaceorgrecmenu)); - Add(new cMenuEditBoolItem(tr("While opening jump to last replayed recording"),&jumprec)); + Add(new cMenuEditBoolItem(tr("Show dvd id"),&showdvdnr)); + Add(new cMenuEditStraItem(tr("Sort recordings by"),&sortrecords,4,sortrecordstext)); } void myMenuSetup::Store() @@ -63,5 +59,4 @@ void myMenuSetup::Store() SetupStore("ShowRecLength",mysetup.ShowRecLength=showreclength); SetupStore("ShowNewRecs",mysetup.ShowNewRecs=shownewrecs); SetupStore("SortRecords",mysetup.SortRecords=sortrecords); - SetupStore("JumpRec",mysetup.JumpRec=jumprec); } diff --git a/mymenusetup.h b/mymenusetup.h index 164de87..ccae3ee 100644 --- a/mymenusetup.h +++ b/mymenusetup.h @@ -13,8 +13,6 @@ class mySetup int ShowDvdNr; int ShowNewRecs; int SortRecords; - int JumpRec; - bool wasdvd; // needed for dvdarchive-patch functionality }; extern mySetup mysetup; @@ -32,7 +30,6 @@ class myMenuSetup:public cMenuSetupPage int showdvdnr; int shownewrecs; int sortrecords; - int jumprec; protected: virtual void Store(); public: diff --git a/myreplaycontrol.c b/myreplaycontrol.c index 65c9dd5..bdfb123 100644 --- a/myreplaycontrol.c +++ b/myreplaycontrol.c @@ -5,16 +5,17 @@ #include <vdr/interface.h> #include <vdr/status.h> #include "myreplaycontrol.h" +#include "mymenusetup.h" -bool myReplayControl::jumprec=true; +myReplayControl::~myReplayControl() +{ + cRemote::CallPlugin("extrecmenu"); +} eOSState myReplayControl::ProcessKey(eKeys Key) { if(Key==kBack) - { - cRemote::CallPlugin("extrecmenu"); return osEnd; - } return cReplayControl::ProcessKey(Key); } diff --git a/myreplaycontrol.h b/myreplaycontrol.h index 78d0008..01980ac 100644 --- a/myreplaycontrol.h +++ b/myreplaycontrol.h @@ -4,5 +4,5 @@ class myReplayControl:public cReplayControl { public: eOSState ProcessKey(eKeys Key); - static bool jumprec; + ~myReplayControl(); }; diff --git a/scripts/dvdarchive.sh b/scripts/dvdarchive.sh index cf545ee..c4cf157 100755 --- a/scripts/dvdarchive.sh +++ b/scripts/dvdarchive.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Version 1.9 2006-04-28 +# Version 2.0 2006-05-03 # # Author: Mike Constabel # VDR-Portal: vejoun @@ -41,6 +41,10 @@ # the script will create a length.vdr for you. # # 6. +# If something went wrong, set DEBUG=1 and send me the file which is defined in $DEBUGLOG. +# Use VDR-Portal or EMail. +# +# 7. # Exitcodes: # # exit 0 - no error @@ -52,6 +56,10 @@ # # HISTORY: # -------- +# 2.0 - more logging +# - check if mountpoint and device exists +# - Debug Log in file $DEBUGLOG if $DEBUG is 1, for easier error reporting +# # 1.9 - use "sudo mount --bind" for mounting if filesystem is vfat # - automatic fallback to 'sudo' and 'mount --bind' if filesystem is vfat # - mounting more failure tolerant @@ -62,7 +70,8 @@ # - on mount, if already mounted try to umount first # - logging per syslog, see $SYSLOG # - +# CONFIGURATION +# ------------- #<Configuration> # Mountpoint, the same as in fstab @@ -75,22 +84,30 @@ EJECTWRONG=0 EJECTUMOUNT=0 # Log warnings/errors in syslog. 1 = yes, 0 = no. -SYSLOG=0 +SYSLOG=1 # Create a length.vdr after mounting the dvd for the played recording. 1 = yes, 0 = no. # Only for non-vfat and with index.vdr only on dvd. GETLENGTH=0 -#</Configuration> +# Put debug infos in file $DEBUGLOG. Only if $DEBUG=1. +DEBUG=0 +DEBUGLOG="/tmp/dvdarchive.sh-debug.log" +#</Configuration> +# # No changes needed after this mark +# Remove trailing slash MOUNTPOINT=${MOUNTPOINT/%\/} -DEVICE="$(awk '( $1 !~ /^#/ ) && ( $2 == "'$MOUNTPOINT'" ) { printf("%s", $1); exit; }' /etc/fstab)" # dvd-device, used by isodetect if exists +# determine dvd-device, used by eject and isodetect if exists +DEVICE="$(awk '( $1 !~ /^#/ ) && ( $2 == "'$MOUNTPOINT'" ) { printf("%s", $1); exit; }' /etc/fstab)" +ACTION="$1" REC="$2" NAME="$3" +# function to print help call() { echo -e "\nScript $0 needs three parameters for mount and two for umount. The first must be mount or umount, the second is the full path.\n" echo -e "Only for mounting the script needs a third parameter, the last part of the recording path.\n" @@ -99,8 +116,13 @@ call() { echo -e "For more information read the MANUAL part inside this script.\n" } +# function to log messages log() { - case $1 in + case "$1" in + info) + echo -e "INFO: $2" + [ $SYSLOG -eq 1 ] && logger -t "$0" "INFO: $2" + ;; warning) echo -e "WARNING: $2" [ $SYSLOG -eq 1 ] && logger -t "$0" "WARNING: $2" @@ -108,15 +130,29 @@ log() { error) echo -e "ERROR: $2" [ $SYSLOG -eq 1 ] && logger -t "$0" "ERROR: $2" + if [ $DEBUG -eq 1 ]; then + echo "-------" >> $DEBUGLOG + echo -e "Parameters: $ACTION $REC $NAME\n" >> $DEBUGLOG + echo -e "ERROR: $2\n\nMountpoint: $MOUNTPOINT\nDevice: $DEVICE\n" >> $DEBUGLOG + echo -e "Filesystem: $(stat -f -c %T "$REC")\n" >> $DEBUGLOG + mount >> $DEBUGLOG + echo >> $DEBUGLOG + cat /proc/mounts >> $DEBUGLOG + echo >> $DEBUGLOG + sudo -l >> $DEBUGLOG + fi ;; esac } -[ "$1" = "mount" -o "$1" = "umount" ] || { call; exit 10; } -[ -z "$2" ] && { call; exit 10; } -[ "$1" = mount -a -z "$3" ] && { call; exit 10; } +# Some checks before doing something +[ "$ACTION" = "mount" -o "$ACTION" = "umount" ] || { call; exit 10; } +[ -z "$REC" ] && { call; exit 10; } +[ "$ACTION" = mount -a -z "$NAME" ] && { call; exit 10; } +[ ! -d "$MOUNTPOINT" ] && { log error "Mountpoint $MOUNTPOINT doesn't exist"; exit 10; } +[ ! -e "$DEVICE" ] && { log error "Device $DEVICE doesn't exist"; exit 10; } -case "$1" in +case "$ACTION" in mount) # check if dvd is in drive, only if isodetect exists if [ -n "$(which isodetect)" -a -n "$DEVICE" ]; then @@ -131,12 +167,12 @@ mount) if mount | egrep -q " $MOUNTPOINT "; then # check if dvd is in use if mount | egrep -q "^$MOUNTPOINT"; then - log error "dvd in use" + log error "dvd in use (at: check if dvd is in use)" exit 1 fi # if already mountet, try to umount log warning "dvd already mounted, try to umount" - umount "$MOUNTPOINT" || { log error "dvd umount error"; exit 1; } + umount "$MOUNTPOINT" || { log error "dvd umount error (at: dvd already mounted, try to umount)"; exit 1; } # unlink broken existing links for LINK in "${REC}/"*.vdr; do if [ -L "$LINK" -a ! -s "$LINK" ]; then @@ -145,13 +181,13 @@ mount) done fi # mount dvd - mount "$MOUNTPOINT" || { log error "dvd mount error"; exit 1; } + mount "$MOUNTPOINT" || { log error "dvd mount error (at: mount dvd)"; exit 1; } # is mounted, find recording on dvd DIR="$(find "${MOUNTPOINT}/" -name "$NAME")" # if not found, umount if [ -z "$DIR" ]; then log error "wrong dvd in drive / recording not found on dvd" - umount "$MOUNTPOINT" || { log error "dvd umount error"; exit 1; } + umount "$MOUNTPOINT" || { log error "dvd umount error (at: wrong dvd in drive / recording not found on dvd)"; exit 1; } # If wanted, eject dvd [ $EJECTWRONG -eq 1 ] && { eject "$DEVICE"; } exit 3 @@ -160,7 +196,7 @@ mount) if [ "$(stat -f -c %T "$REC")" != "vfat" ]; then # link index.vdr if not exist if [ ! -e "${REC}/index.vdr" ]; then - cp -s "${DIR}/index.vdr" "${REC}/" + cp -s "${DIR}/index.vdr" "${REC}/" || { log error "could not link index.vdr (at: link index.vdr from dvd to disk)"; } fi # link [0-9]*.vdr files cp -s "${DIR}"/[0-9]*.vdr "${REC}/" @@ -168,7 +204,7 @@ mount) if [ $? -ne 0 ]; then log error "error while linking [0-9]*.vdr" # umount dvd bevor unlinking - umount "$MOUNTPOINT" || { log error "dvd umount error"; exit 1; } + umount "$MOUNTPOINT" || { log error "dvd umount error (at: error while linking)"; exit 1; } # unlink broken links for LINK in "${REC}/"*.vdr; do if [ -L "$LINK" -a ! -s "$LINK" ]; then @@ -184,25 +220,26 @@ mount) else if [ ! "$(sudo -l | egrep "\(root\) NOPASSWD: /bin/mount")" -o ! "$(sudo -l | egrep "\(root\) NOPASSWD: /bin/umount")" ]; then log error "you must configure sudo and allow $(whoami) to use mount/umount!" - umount "$MOUNTPOINT" || { log error "dvd umount error"; exit 1; } + log info "$(sudo -l)" + umount "$MOUNTPOINT" || { log error "dvd umount error (at: you must configure sudo)"; exit 1; } exit 5 fi # mount recording sudo mount --bind "$DIR" "$REC" if [ $? -ne 0 ]; then log error "sudo mount --bind $DIR $REC" - umount "$MOUNTPOINT" || { log error "dvd umount error"; exit 1; } + umount "$MOUNTPOINT" || { log error "dvd umount error (at: sudo mount --bind)"; exit 1; } exit 5 fi fi ;; umount) # check if dvd is mounted - mount | egrep -q " $MOUNTPOINT " || { log error "dvd not mounted"; exit 1; } + mount | egrep -q " $MOUNTPOINT " || { log error "dvd not mounted (at: check if dvd is mounted)"; exit 1; } # check if video partition is vfat if [ "$(stat -f -c %T "$REC")" != "vfat" ]; then # is mounted, umount dvd bevor unlinking - umount "$MOUNTPOINT" || { log error "dvd umount error"; exit 1; } + umount "$MOUNTPOINT" || { log error "dvd umount error (at: is mounted, umount dvd bevor unlinking)"; exit 1; } # unlink broken links for LINK in "${REC}/"*.vdr; do if [ -L "$LINK" -a ! -s "$LINK" ]; then @@ -212,15 +249,15 @@ umount) else # umount recording sudo umount "$REC" || { log error "sudo umount $REC"; exit 5; } - # umount dvd - umount "$MOUNTPOINT" || { log error "dvd umount error"; exit 1; } + # umount dvd at umount + umount "$MOUNTPOINT" || { log error "dvd umount error (at: umount dvd at umount)"; exit 1; } fi # If wanted, eject dvd [ $EJECTUMOUNT -eq 1 ] && { eject "$DEVICE"; } ;; *) # Output help - log error "\nWrong action." + log error "\nWrong action $ACTION." call ;; esac @@ -7,6 +7,85 @@ #include "tools.h" #include "mymenusetup.h" +// creates the necassery directories and renames the given old name to the new name +bool MoveRename(const char *OldName,const char *NewName,cRecording *Recording,bool Move) +{ + char *buf=NULL; + + // is OldName different to NewName + if(!strcmp(OldName,NewName)) + return true; + + // move/rename a recording + if(Recording) + { + if(!MakeDirs(NewName,true)) + { + Skins.Message(mtError,tr("Creating directories failed!")); + return false; + } + isyslog("[extrecmenu] moving %s to %s",OldName,NewName); + + if(rename(OldName,NewName)==-1) + { + Skins.Message(mtError,tr("Rename/Move failed!")); + return false; + } + + // set user command for '-r'-option of VDR + asprintf(&buf,"%s \"%s\"",Move?"move":"rename",*strescape(OldName,"'\\\"$")); + cRecordingUserCommand::InvokeCommand(buf,NewName); + free(buf); + + // update recordings list + Recordings.AddByName(NewName); + Recordings.Del(Recording); + } + // move/rename a directory + else + { + // is the new path within the old? + asprintf(&buf,"%s/",OldName); // we have to append a / to make sure that we search for a directory + printf("%s\n%s\n",buf,NewName); + if(!strncmp(buf,NewName,strlen(buf))) + { + Skins.Message(mtError,tr("Moving into own sub-directory not allowed!")); + free(buf); + return false; + } + free(buf); + + // build my own recordings list + myRecList *list=new myRecList(); + for(cRecording *recording=Recordings.First();recording;recording=Recordings.Next(recording)) + list->Add(new myRecListItem(recording)); + + myRecListItem *item=list->First(); + while(item) + { + // find recordings within the path of OldName + if(!strncmp(OldName,item->recording->FileName(),strlen(OldName))) + { + buf=strdup(OldName+strlen(VideoDirectory)+1); + ExchangeChars(buf,false); + + // exclude recordings with the same name as OldName + if(strcmp(item->recording->Name(),buf)) + { + free(buf); + asprintf(&buf,"%s%s",NewName,item->recording->FileName()+strlen(OldName)); + // move/rename the recording + MoveRename(item->recording->FileName(),buf,item->recording,Move); + } + free(buf); + } + item=list->Next(item); + } + delete list; + } + return true; +} + // --- myRecListItem ---------------------------------------------------------- myRecListItem::myRecListItem(cRecording *Recording) { @@ -1,3 +1,5 @@ +bool MoveRename(const char *OldName,const char *NewName,cRecording *Recording,bool Move); + class myRecListItem:public cListObject { private: |