diff options
-rw-r--r-- | HISTORY | 23 | ||||
-rw-r--r-- | Makefile | 42 | ||||
-rw-r--r-- | README | 20 | ||||
-rw-r--r-- | i18n.c | 1057 | ||||
-rw-r--r-- | menudispkey.c | 113 | ||||
-rw-r--r-- | menudispkey.h | 38 | ||||
-rw-r--r-- | menunoselectitem.h | 6 | ||||
-rw-r--r-- | menusetup.c | 222 | ||||
-rw-r--r-- | menusetup.h | 11 | ||||
-rw-r--r-- | menuundelete.c | 802 | ||||
-rw-r--r-- | menuundelete.h | 43 | ||||
-rw-r--r-- | undelete.c | 871 | ||||
-rw-r--r-- | undelete.h | 134 | ||||
-rw-r--r-- | vdrtools.c | 63 | ||||
-rw-r--r-- | vdrtools.h | 28 |
15 files changed, 2816 insertions, 657 deletions
@@ -8,6 +8,27 @@ VDR Plugin 'playlist' Revision History 2004-10-10: Version 0.0.2 * Bug fixes -- TriggerUpdate for VDR > 1.3.11 (thanks to Brougs78@vdrportal.de) +- TriggerUpdate for VDR >= 1.3.11 (thanks to Brougs78@vdrportal.de) - Update counter in listviews - Confirm options + +2004-11-08: Version 0.0.3 + +- Update for VDR >= 1.3.15 + +2005-11-16: Version 0.0.4 + +* Bug fix purge/salvage deleted recording while purge/salvage a directory with the same name +- Update for VDR >= 1.3.36 +- Remove empty directorys in background +- Support control with svdrp +- User can change the hotkeys +- new function "purge all" (for Olaf Henkel) +- new function "salvage all" + +2005-11-17: Version 0.0.5 + +- Add Remove empty directorys after 10min at svdrp-purge +- Fix select a line with a numeric-key +- Fix switch hotkeys with the same key +- Add missing display of assigned keys @@ -1,7 +1,7 @@ # # Makefile for a Video Disk Recorder plugin # -# $Id: Makefile 1.8 2002/12/13 14:54:14 kls Exp $ +# $Id: Makefile 0.4 2005/11/07 16:47:18 hflor Exp $ # The official name of this plugin. # This name will be used in the '-P...' option of VDR to load the plugin. @@ -16,11 +16,7 @@ VERSION = $(shell grep 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ pri ### The C++ compiler and options: CXX ?= g++ -CXXFLAGS ?= -O2 -Wall -Woverloaded-virtual - -### Allow user defined options to overwrite defaults: - --include $(VDRDIR)/Make.config +CXXFLAGS ?= -fPIC -O2 -Wall -Woverloaded-virtual ### The directory environment: @@ -29,13 +25,15 @@ VDRDIR = ../../.. LIBDIR = ../../lib TMPDIR = /tmp +### Allow user defined options to overwrite defaults: + +-include $(VDRDIR)/Make.config + ### The version number of VDR (taken from VDR's "config.h"): VDRVERSION = $(shell grep 'define VDRVERSION ' $(VDRDIR)/config.h | awk '{ print $$3 }' | sed -e 's/"//g') VDRVERSNUM = $(shell grep 'define VDRVERSNUM ' $(VDRDIR)/config.h | awk '{ print $$3 }' | sed -e 's/"//g') -### DEFINES += -DVDRVERSNUM=$(VDRVERSNUM) - ### The name of the distribution archive: ARCHIVE = $(PLUGIN)-$(VERSION) @@ -45,35 +43,33 @@ PACKAGE = vdr-$(ARCHIVE) INCLUDES += -I$(VDRDIR)/include -I$(DVBDIR)/include -DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -DEFINES += -D_GNU_SOURCE - -### Test Elchi +DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -#ELCHIVERSION = $(shell grep 'define ELCHIAIOVERSION ' $(VDRDIR)/config.h | awk '{ print $$3 }' | sed -e 's/"//g') +### Test SVDRP +ifeq ($(shell grep -q ReplyCode $(VDRDIR)/plugin.h ; echo $$?),0) + DEFINES += -DHAVE_SVDRP +endif +### Test Elchi ifeq ($(shell test -f $(VDRDIR)/theme.h ; echo $$?),0) DEFINES += -DHAVE_ELCHI endif ### Test wareagle-patch - ifeq ($(shell test -f $(VDRDIR)/iconpatch.h ; echo $$?),0) DEFINES += -DHAVE_ICONPATCH endif #for more debug lines -DEFINES += -DUND_Debug1 -DEFINES += -DUND_Debug2 -DEFINES += -DUND_Debug3 -CXXFLAGS += -g +#DEFINES += -DUND_Debug1 # +#DEFINES += -DUND_Debug2 # log all functions with parameters +#DEFINES += -DUND_Debug3 # log all ProcessKey calls without kNone ### The object files (add further files here): -OBJS = $(PLUGIN).o menuundelete.o menusetup.o i18n.o vdrtools.o - -ifeq ($(shell test $(VDRVERSNUM) -lt 10307 ; echo $$?),0) - OBJS += menuitemtext.o +OBJS = $(PLUGIN).o i18n.o menuundelete.o menusetup.o vdrtools.o menueditkeys.o menudispkey.o +ifeq ($(shell test $(VDRVERSNUM) -lt 10308 ; echo $$?),0) + OBJS += menutext.o endif ### Implicit rules: @@ -98,7 +94,7 @@ libvdr-$(PLUGIN).so: $(OBJS) $(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@ @cp $@ $(LIBDIR)/$@.$(VDRVERSION) -dist: clean +dist: clean @-rm -rf $(TMPDIR)/$(ARCHIVE) @mkdir $(TMPDIR)/$(ARCHIVE) @cp -a * $(TMPDIR)/$(ARCHIVE) @@ -1,13 +1,12 @@ This is a "plugin" for the Video Disk Recorder (VDR). -Written by: Hardy Flor <HFlor@web.de> +Written by: Hardy Flor <HFlor@web.de> -Project's homepage (vdr): www.cadsoft.de/people/kls/vdr -Project's homepage (playlist): www.fast-info.de/vdr/undelete +Project's homepage: www.fast-info.de/vdr/undelete See the file COPYING for license information. -undelete-plugin version 0.0.2 +undelete-plugin version 0.0.5 This plugin allow the undelete from deleted recordings for a short time @@ -18,9 +17,12 @@ Handling: You can build the list from plugin-setup (by 'Display deleted recordings now') or is the mainmenuentry visible from then mainmenu. -red - open a directory (if a directory selected) -green - salvage a recording -yellow - purge a recording -blue - show summary (if a recording with summary selected) +The keys for purge and salvage can you change in the setup of plugin -back - close the menu +control with SVDRP is also allow: + +PLUG undelte LSTD [ <number> ] List deleted recordings +PLUG undelte SIZED [ -h ] Caclulate the size of deleted recordings +PLUG undelte RMDIR Start remove empty directory +PLUG undelte PURGE ALL | <number> purge the selected deleted recording +PLUG undelte SALVAGE ALL | <number> salvage the selected deleted recording @@ -3,14 +3,14 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: i18n.c 0.2 2004/10/10 12:23:20 hflor Exp $ + * $Id: i18n.c 0.5 2005/11/17 21:05:05 hflor Exp $ */ #include "i18n.h" const tI18nPhrase Phrases[] = { - { " -m --visible_in_mainmenu Show the plugin in the mainmenu\n -M --hide_in_mainmenu Hide the plugin in the mainmenu\n You can start the Plugin in the setupmenu\n -n Name --mainmenu_name=Name Select Name for entry in the mainmenu\n (set also -m)\n -c --confirm_del_rec show confirmation for delete recording\n -C --not_confirm_del_rec delete recording without confirmation\n -d --confirm_del_dir show confirmation for delete directory\n -D --not_confirm_del_dir delete directory without confirmation\n -s --confirm_undel_rec show confirmation for undelete recording\n -S --not_confirm_undel_rec undelete recording without confirmation\n -t --confirm_undel_dir show confirmation for undelete directory\n -T --not_confirm_undel_dir undelete directory without confirmation\n -v --verbose Enable more logging\n -V --noverbose Disable more loggig\n --nosetup_commandline Hide the 'Preferr Command Line Parameter'\n form setup-menu\n @config-file Read also parameters from this file\n note: recording means deleted recordings (there not show in VDR)", - " -m --visible_in_mainmenu Plugin wird im Hautmenü angezeigt\n -M --hide_in_mainmenu kein Eintrag im Hauptmenü für das Plugin\n es kann über das Setup-Menü gestartet werden\n -n Name --mainmenu_name=Name Name für den Eintrag im Hauptmenü\n (diese Option setzt auch -m)\n -c --confirm_del_rec Bestätigung für das Löschen von Aufnahmen\n -C --not_confirm_del_rec keine Bestätigung (löschen Aufnahmen)\n -d --confirm_del_dir Bestätigung beim Löschen von Verzeichnissen\n -D --not_confirm_del_dir keine Bestätigung (löschen Verzeichnissen)\n -s --confirm_undel_rec Bestätigung Wiederherstellung von Aufnahmen\n -S --not_confirm_undel_rec keine Best. Wiederherstellung von Aufnahmen\n -t --confirm_undel_dir Bestätigung Wiederherstellung von Verzei.\n -T --not_confirm_undel_dir keine Best. Wiederherstellung von Verzei.\n -v --verbose erweiterte Protokollierung aktivieren\n -V --noverbose keine erweiterte Protokollierung\n --nosetup_commandline Option 'Kommandozeile hat Vorrang'\n im Setup-Menü verbergen\n @config-file Komandozeilenoptionen auch aus der angegebenen\n Datei lesen\n\n Hinweis: Mit Aufnahmen sind hier die gelöschten Aufnahmen gemeint", + { "Deleted Recordings", + "Gelöschte Aufnahmen", "",// TODO Slovenski "",// TODO Italiano "",// TODO Nederlands @@ -26,9 +26,9 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, - - { "Undelete", - "Wiederherst.", + // Debug_mode + { "DeleteLine", + "Zeile löschen", "",// TODO Slovenski "",// TODO Italiano "",// TODO Nederlands @@ -44,8 +44,9 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, - { "Deleted Recordings", - "Gelöschte Aufnahmen", + // Debug_mode + { "HelpKeys", + "Hilfstasten", "",// TODO Slovenski "",// TODO Italiano "",// TODO Nederlands @@ -61,8 +62,8 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, - { "undelete for recordings", - "Wiederherstellung gelöschter Aufnahmen", + { " -m --visible_in_mainmenu Show the plugin in the mainmenu\n -M --hide_in_mainmenu Hide the plugin in the mainmenu\n You can start the Plugin in the setupmenu\n -n Name --mainmenu_name=Name Select Name for entry in the mainmenu\n (set also -m)\n -c --confirm_purge_rec show confirmation for purge recording\n -C --not_confirm_purge_rec purge recording without confirmation\n -d --confirm_purge_dir show confirmation for purge directory\n -D --not_confirm_purge_dir purge directory without confirmation\n -e --confirm_purge_all show confirmation for purge all function\n -E --not_confirm_purge_all purge all function without confirmation\n -s --confirm_salvage_rec show confirmation for salvage recording\n -S --not_confirm_salvage_rec salvage recording without confirmation\n -t --confirm_salvage_dir show confirmation for salvage directory\n -T --not_confirm_salvage_dir salvage directory without confirmation\n -u --confirm_salvage_all show confirmation for salvage all function\n -U --not_confirm_salvage_all salvage all function without confirmation\n -v --verbose Enable more logging\n -V --noverbose Disable more loggig\n --nosetup_commandline Hide the 'Preferr Command Line Parameter'\n form setup-menu\n @config-file Read also parameters from this file\n note: recording means deleted recordings (there not show in VDR)", + " -m --visible_in_mainmenu Plugin wird im Hautmenü angezeigt\n -M --hide_in_mainmenu kein Eintrag im Hauptmenü für das Plugin\n es kann über das Setup-Menü gestartet werden\n -n Name --mainmenu_name=Name Name für den Eintrag im Hauptmenü\n (diese Option setzt auch -m)\n -c --confirm_purge_rec Bestätigung für das Löschen von Aufnahmen\n -C --not_confirm_purge_rec keine Bestätigung (löschen Aufnahmen)\n -d --confirm_purge_dir Bestätigung beim Löschen von Verzeichnissen\n -D --not_confirm_purge_dir keine Bestätigung (löschen Verzeichnissen)\n -e --confirm_purge_all Bestätigung beim \"alles Löschen\"\n -E --not_confirm_purge_all \"alles Löschen\" ohne Bestätigung\n -s --confirm_salvage_rec Bestätigung Wiederherstellung von Aufnahmen\n -S --not_confirm_salvage_rec keine Best. Wiederherstellung von Aufnahmen\n -t --confirm_salvage_dir Bestätigung Wiederherstellung von Verzei.\n -T --not_confirm_salvage_dir keine Best. Wiederherstellung von Verzei.\n -u --confirm_salvage_all Bestätigung beim \"alles Wiederherstellen\"\n -U --not_confirm_salvage_all \"alles Wiederherstellen\" ohne Bestätigung\n -v --verbose erweiterte Protokollierung aktivieren\n -V --noverbose keine erweiterte Protokollierung\n --nosetup_commandline Option 'Kommandozeile hat Vorrang'\n im Setup-Menü verbergen\n @config-file Komandozeilenoptionen auch aus der angegebenen\n Datei lesen\n\n Hinweis: Mit Aufnahmen sind hier die gelöschten Aufnahmen gemeint", "",// TODO Slovenski "",// TODO Italiano "",// TODO Nederlands @@ -78,7 +79,8 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, - { "DelRec", + // Debug_mode + { "Purge", "Löschung", "",// TODO Slovenski "",// TODO Italiano @@ -95,8 +97,9 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, - { "HelpKeys", - "Hilfstasten", + // Debug_mode + { "Salvage", + "Wiederherstellung", "",// TODO Slovenski "",// TODO Italiano "",// TODO Nederlands @@ -112,8 +115,8 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, - { "UnDelRec", - "Wiederherstellung", + { "undelete for recordings", + "Wiederherstellung gelöschter Aufnahmen", "",// TODO Slovenski "",// TODO Italiano "",// TODO Nederlands @@ -129,6 +132,7 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, + // Debug_mode { "unknow", "unbekannt", "",// TODO Slovenski @@ -146,6 +150,584 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, + { "Choise$Blue (1)", + "Blau (1)", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$Blue (2)", + "Blau (2)", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$bottom", + "unten", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$Display keys", + "Tastenanzeige", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$Green (1)", + "Grün (1)", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$Green (2)", + "Grün (2)", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$none", + "ohne", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$open", + "Öffnen", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$open/summary", + "Öffnen/Inhalt", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$purge", + "löschen", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$purge all", + "alle löschen", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$Red (1)", + "Rot (1)", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$Red (2)", + "Rot (2)", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$salvage", + "wiederherst.", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$salvage all", + "alle wiederh.", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$summary", + "Inhalt", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$switch hotkeys to 1", + "Tastenbel. 1", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$switch hotkeys to 2", + "Tastenbel. 2", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$top", + "oben", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$top and bottom", + "oben & unten", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$User1", + "Benutzer 1", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$User2", + "Benutzer 2", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$User3", + "Benutzer 3", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$User4", + "Benutzer 4", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$User5", + "Benutzer 5", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$User6", + "Benutzer 6", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$User7", + "Benutzer 7", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$User8", + "Benutzer 8", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$User9", + "Benutzer 9", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$Yellow (1)", + "Gelb (1)", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Choise$Yellow (2)", + "Gelb (2)", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Display$<--1", + "<--1", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Display$2-->", + "2-->", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Display$disp. keys", + "Tastenanzeige", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, { "Display$please wait ...", "bitte warten ...", "",// TODO Slovenski @@ -180,8 +762,110 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, - { "Display$remove empty directories...", - "Entferne leere Verzeichnisse...", + { "Display$purge", + "Löschen", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Display$purge all", + "alle Löschen", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Display$Purge all records ...", + "Alle Aufnahmen endgültig löschen ...", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Display$Salavge all records ...", + "Alle Aufnahmen wiederherstellen ...", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Display$salvage", + "Wiederherst.", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Display$salvage all", + "alle Wieder.", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Error$Key for funtion %s and %s identical.", + "Tasten von %s und %s sind gleich.", "",// TODO Slovenski "",// TODO Italiano "",// TODO Nederlands @@ -214,6 +898,74 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, + { "Help$key\tfunction", + "Taste\tFunktion", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Help$numerickey", + "Numerntaste", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Help$OK", + "OK", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Menu$assigned keys", + "Zugewiesene Tasten", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, { "Menu$Undelete recordings", "Aufnahmen wiederherstellen", "",// TODO Slovenski @@ -231,7 +983,24 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, - { "Question$Delete recording definitive?", + { "Question$Purge all recordings?", + "Alle Aufnahmen endgültig löschen?", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Question$Purge recording?", "Aufnahme endgültig löschen?", "",// TODO Slovenski "",// TODO Italiano @@ -248,7 +1017,7 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, - { "Question$Delete recordings in diretory definitive?", + { "Question$Purge recordings in diretory?", "Aufnahmen in Verzeichnis endgültig löschen?", "",// TODO Slovenski "",// TODO Italiano @@ -265,7 +1034,24 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, - { "Question$Undelete recording?", + { "Question$Salvage all recordings?", + "Alle Aufnahmen wiederherstellen?", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Question$Salvage recording?", "Aufnahme wiederherstellen?", "",// TODO Slovenski "",// TODO Italiano @@ -282,7 +1068,7 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, - { "Question$Undelete recordings in directory?", + { "Question$Salvage recordings in directory?", "Aufnahmen in Verzeichnis wiederherstellen?", "",// TODO Slovenski "",// TODO Italiano @@ -299,7 +1085,58 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, - { "Setup$Confirm delete deleted recordings", + { "Setup$ ** Spezial handled keys **", + " ** Spezialtasten **", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Setup$Change assigned functionkeys", + "Ändern der Tastenbelegung", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Setup$Confirm purge all deleted recordings", + "Bestätigung alles löschen", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Setup$Confirm purge deleted recordings", "Aufnahme löschen bestätigen", "",// TODO Slovenski "",// TODO Italiano @@ -316,7 +1153,7 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, - { "Setup$Confirm delete directories", + { "Setup$Confirm purge directories", "Verzeichnisse löschen bestätigen", "",// TODO Slovenski "",// TODO Italiano @@ -333,7 +1170,24 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, - { "Setup$Confirm undelete deleted recordings", + { "Setup$Confirm salvage all deleted recordings", + "Bestätigung alles wiederherst.", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Setup$Confirm salvage deleted recordings", "Wiederherstellung Aufn. bestätigen", "",// TODO Slovenski "",// TODO Italiano @@ -350,7 +1204,7 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, - { "Setup$Confirm undelete directories", + { "Setup$Confirm salvage directories", "Wiederherstellung Verz. bestätigen", "",// TODO Slovenski "",// TODO Italiano @@ -367,6 +1221,40 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, + { "Setup$ Display bottom purge ex lines", + " Anzahl Einträge für Darstellung", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Setup$ Display bottom salvage ex lines", + " Anzahl Einträge für Darstellung", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, { "Setup$Display deleted recordings now", "Gelöschte Aufnahmen jetzt anzeigen", "",// TODO Slovenski @@ -384,6 +1272,40 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, + { "Setup$ inward lines", + " Innenliegende Zeilen", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Setup$ Key for function-%s", + " Taste für Funktion-%s", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, { "Setup$ Name for Mainmenu", " Eintragname im Hauptmenü", "",// TODO Slovenski @@ -401,6 +1323,40 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, + { "Setup$ Numerickey select the entry and", + " Auswahl mit Nummern und", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Setup$ OK-key function", + " Funktion der OK-Taste", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, { "Setup$Preferr Command Line Parameter", "Kommandozeile hat Vorrang", "",// TODO Slovenski @@ -418,6 +1374,57 @@ const tI18nPhrase Phrases[] = { "",// TODO Magyar "",// TODO Català }, + { "Setup$Purgeline position", + "Löschzeilenposition", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Setup$Salvageline position", + "Wiederherstellungszeilenposition", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, + { "Setup$Select", + "Auswahl", + "",// TODO Slovenski + "",// TODO Italiano + "",// TODO Nederlands + "",// TODO Português + "",// TODO Français + "",// TODO Norsk + "",// TODO suomi + "",// TODO Polski + "",// TODO Español + "",// TODO Ellinika + "",// TODO Svenska + "",// TODO Romaneste + "",// TODO Magyar + "",// TODO Català + }, { "Setup$Verbose Log Mode", "Ausführliche Protokollierung", "",// TODO Slovenski diff --git a/menudispkey.c b/menudispkey.c new file mode 100644 index 0000000..f416e74 --- /dev/null +++ b/menudispkey.c @@ -0,0 +1,113 @@ +/* + * autotimeredit: A plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + * $Id: menueditkeys.c 0.5 2005/11/17 21:05:05 hflor Exp $ + */ + +#include "menudispkey.h" +#include "undelete.h" +#include "menunoselectitem.h" +#include "menusetup.h" +#include "i18n.h" +#include <vdr/osd.h> +#include <vdr/osdbase.h> +#include <typeinfo> + +// --- cMenuDispKeyItem ----------------------------------------------------- + +cMenuDispKeyItem::cMenuDispKeyItem(const char *Key, const char *FunctionName, int Function) +{ + function = Function; + char *temp; + asprintf(&temp, "%s\t%s", Key, FunctionName); + SetText(temp, false); +} + +// --- cMenuDispKey ----------------------------------------------------- + +cMenuDispKey::cMenuDispKey(void) +:cOsdMenu(tr("Menu$assigned keys"), 15) +{ +#ifdef UND_Debug + objID = ++cMenuDispKey_nextID; +#endif + d2syslog("cMenuDispKey::cMenuDispKey", "%s", ""); + Set(); + SetHelpKeys(); +} + +cMenuDispKey::~cMenuDispKey() +{ + d2syslog("cMenuDispKey::~cMenuDispKey", "%s", ""); +} + + +void cMenuDispKey::SetHelpKeys(void) +{ + const char *helptext[4] = { NULL, NULL, NULL, NULL }; + helptext[0] = tr("Edit"); + d2syslog("cMenuDispKey::SetHelpKeys", "red=%s green=%s yellow=%s blue=%s", helptext[0] ? helptext[0] : "(NULL)", helptext[1] ? helptext[1] : "(NULL)", helptext[2] ? helptext[2] : "(NULL)", helptext[3] ? helptext[3] : "(NULL)"); + SetHelp(helptext[0], helptext[1], helptext[2], helptext[3]); +} + +void cMenuDispKey::Set(void) +{ + int current = Current(); + d2syslog("cMenuDispKey::Set", "Current=%d", current); + Clear(); + + Add(new cMenuOsdNoSelectItem(tr("Help$key\tfunction"))); + for (int i = 1; i < MaxFunctionName; i++) + { + if (functionkey[i].u > 0) + Add(new cMenuDispKeyItem(KeysName[functionkey[i].u], FunctionName[i], i)); + if (okkey.u == i) + Add(new cMenuDispKeyItem(tr("Help$OK"), FunctionName[i], i)); + if (numkey.u == i) + Add(new cMenuDispKeyItem(tr("Help$numerickey"), FunctionName[i], i)); + } + d1listlog("cMenuDispKey::Set"); + d2syslog("cMenuDispKey::Set", "Count=%d", Count()); + SetCurrent(Get(current)); + Display(); +} + +eOSState cMenuDispKey::ProcessKey(eKeys Key) +{ + bool hSubMenu = HasSubMenu(); + cOsdItem *item = NULL; + int function = 99; // dummy function for display change key in setupmenu + + d3ProcessKey1("cMenuDispKey::ProcessKey"); + eOSState state = cOsdMenu::ProcessKey(Key); + d3ProcessKey2("cMenuDispKey::ProcessKey"); + + if (hSubMenu && !HasSubMenu()) + Set(); + + switch (state) + { + case osUnknown: switch (Key) + { + case kRed: item = Get(Current()); + if (item && typeid(*item) == typeid(cMenuDispKeyItem)) + function = ((cMenuDispKeyItem *)item)->Function(); + { + cMenuSetupPage *menu = new cMenuSetupUndelete(function); + if (menu) + { + menu->SetPlugin(plugin); + state = AddSubMenu(menu); + } + } + break; + default: break; + } + break; + default: break; + } + d3ProcessKey3("cMenuDispKey::ProcessKey"); + return state; +} diff --git a/menudispkey.h b/menudispkey.h new file mode 100644 index 0000000..9a595ad --- /dev/null +++ b/menudispkey.h @@ -0,0 +1,38 @@ +/* + * autotimeredit: A plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + * $Id: menudispkey.h 0.5 2005/11/17 21:05:05 hflor Exp $ + */ + +#ifndef __MENUDISPKEY_H +#define __MENUDISPKEY_H + +#include "vdrtools.h" +#include <vdr/menuitems.h> + +// --- cMenuDispKeyItem ----------------------------------------------------- + +class cMenuDispKeyItem : public cOsdItem { +private: + int function; +public: + cMenuDispKeyItem(const char *Key, const char *FunctionName, int Function); + int Function(void) { return function; } + }; + +class cMenuDispKey : public cOsdMenu { +private: + void SetHelpKeys(void); + void Set(void); +public: +#ifdef UND_Debug + int objID; +#endif + cMenuDispKey(void); + ~cMenuDispKey(void); + virtual eOSState ProcessKey(eKeys Key); + }; + +#endif //__MENUDISPKEY_H diff --git a/menunoselectitem.h b/menunoselectitem.h index 1a43127..854708c 100644 --- a/menunoselectitem.h +++ b/menunoselectitem.h @@ -3,13 +3,17 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: menunoselectitem.h 0.4 2005/11/16 18:39:18 hflor Exp $ + * $Id: menunoselectitem.h 0.5 2005/11/17 21:05:05 hflor Exp $ */ #ifndef __MENUNOSELECTITEM_H #define __MENUNOSELECTITEM_H #include <vdr/osd.h> +#include <vdr/config.h> +#ifdef HAVE_ELCHI + #include <vdr/theme.h> +#endif // --- cMenuOsdNoSelectItem ----------------------------------------------------- diff --git a/menusetup.c b/menusetup.c index ddf9613..dd98538 100644 --- a/menusetup.c +++ b/menusetup.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: menusetup.c 0.2 2004/10/10 12:23:20 hflor Exp $ + * $Id: menusetup.c 0.5 2005/11/17 21:05:05 hflor Exp $ */ #include "menusetup.h" @@ -11,14 +11,19 @@ #include "menuundelete.h" #include "i18n.h" #include "vdrtools.h" +#include "menueditkeys.h" +#include "menunoselectitem.h" #include <vdr/plugin.h> +#include <vdr/interface.h> +#include <typeinfo> // --- cMenuSetupUndelete ------------------------------------------------------- -cMenuSetupUndelete::cMenuSetupUndelete(void) +cMenuSetupUndelete::cMenuSetupUndelete(int FunctionToChange) { -#ifdef PL_Debug2 - dsyslog("%s: cMenuSetupUndelete::cMenuSetupUndelete", plugin_name); +#ifdef UND_Debug + objID = ++cMenuSetupUndelete_nextID; + d2syslog("cMenuSetupUndelete::cMenuSetupUndelete", "%s", ""); #endif store = false; @@ -27,25 +32,36 @@ cMenuSetupUndelete::cMenuSetupUndelete(void) // var pos7 StoreValue (commandline_preference); - StoreValue (confirmdel); - StoreValue (confirmdeldir); - StoreValue (confirmundel); - StoreValue (confirmundeldir); + StoreValue (confirmpurge); + StoreValue (confirmpurgedir); + StoreValue (confirmpurgeall); + StoreValue (confirmsalvage); + StoreValue (confirmsalvagedir); + StoreValue (confirmsalvageall); + StoreValue (firstsalvage); + for (int i = 2; i < MaxFunctionName; i++) + StoreValue (functionkey[i]); StoreValueFile (mainmenu_name); StoreValue (mainmenu_visible); + StoreValue (numkey); + StoreValue (okkey); + for (int i = 0; i < 2; i++) + { + StoreValue (functionline_b_e[i]); + StoreValue (functionline_num[i]); + } StoreValue (verbose); #undef StoreValue #undef StoreValueFile - Set(); + show_setupfunction = FunctionToChange > 0; + Set(FunctionToChange); } cMenuSetupUndelete::~cMenuSetupUndelete(void) { -#ifdef PL_Debug2 - dsyslog("%s: cMenuSetupUndelete::~cMenuSetupUndelete store=%s", plugin_name, store ? "true" : "false"); -#endif + d2syslog("cMenuSetupUndelete::~cMenuSetupUndelete", "store=%s", store ? "true" : "false"); if (!store) { @@ -54,12 +70,24 @@ cMenuSetupUndelete::~cMenuSetupUndelete(void) // var pos8 RestoreValue (commandline_preference); - RestoreValue (confirmdel); - RestoreValue (confirmdeldir); - RestoreValue (confirmundel); - RestoreValue (confirmundeldir); + RestoreValue (confirmpurge); + RestoreValue (confirmpurgedir); + RestoreValue (confirmpurgeall); + RestoreValue (confirmsalvage); + RestoreValue (confirmsalvagedir); + RestoreValue (confirmsalvageall); + RestoreValue (firstsalvage); + for (int i = 2; i < MaxFunctionName; i++) + RestoreValue (functionkey[i]); RestoreValueFile (mainmenu_name); RestoreValue (mainmenu_visible); + RestoreValue (numkey); + RestoreValue (okkey); + for (int i = 0; i < 2; i++) + { + RestoreValue (functionline_b_e[i]); + RestoreValue (functionline_num[i]); + } RestoreValue (verbose); #undef RestoreValue @@ -69,21 +97,37 @@ cMenuSetupUndelete::~cMenuSetupUndelete(void) void cMenuSetupUndelete::Store(void) { -#ifdef PL_Debug2 - dsyslog("%s: cMenuSetupUndelete::Store", plugin_name); -#endif + d2syslog("cMenuSetupUndelete::Store", "%s", ""); #define SaveValue(T, N) if (T.u != T.o) SetupStore(N, T.u); #define SaveValueFile(T, N) if (strcmp(T.u, T.o)) SetupStore(N, T.u); // var pos9 SaveValue (commandline_preference, "commandline"); - SaveValue (confirmdel, "confdel"); - SaveValue (confirmdeldir, "confdeldir"); - SaveValue (confirmundel, "confundel"); - SaveValue (confirmundeldir, "confundeldir"); + SaveValue (confirmpurge, "confpurge1"); + SaveValue (confirmpurgedir, "confpurge2"); + SaveValue (confirmpurgeall, "confpurge3"); + SaveValue (confirmsalvage, "confsalvage1"); + SaveValue (confirmsalvagedir, "confsalvage2"); + SaveValue (confirmsalvageall, "confsalvage3"); + SaveValue (firstsalvage, "firstsalvage"); + SaveValue (functionkey[2], "functionkey02"); + SaveValue (functionkey[3], "functionkey03"); + SaveValue (functionkey[4], "functionkey04"); + SaveValue (functionkey[5], "functionkey05"); + SaveValue (functionkey[6], "functionkey06"); + SaveValue (functionkey[7], "functionkey07"); + SaveValue (functionkey[8], "functionkey08"); + SaveValue (functionkey[9], "functionkey09"); + SaveValue (functionkey[10], "functionkey10"); SaveValueFile (mainmenu_name, "name"); SaveValue (mainmenu_visible, "visible"); + SaveValue (numkey, "numkey"); + SaveValue (okkey, "okkey"); + SaveValue (functionline_b_e[0], "purgebe"); + SaveValue (functionline_num[0], "purgenum"); + SaveValue (functionline_b_e[1], "salvagebe"); + SaveValue (functionline_num[1], "salvagenum"); SaveValue (verbose, "verbose"); #undef SaveValue @@ -92,12 +136,10 @@ void cMenuSetupUndelete::Store(void) store = true; } -void cMenuSetupUndelete::Set(void) +void cMenuSetupUndelete::Set(int FunctionToSelect) { -#ifdef PL_Debug2 - dsyslog("%s: cMenuSetupUndelete::Set Current=%d", plugin_name, Current()); -#endif int current = Current(); + d2syslog("cMenuSetupUndelete::Set", "Current=%d", current); Clear(); #define DisplayLine(T) !T.h && (!commandline_preference.u || !T.c) @@ -109,61 +151,123 @@ void cMenuSetupUndelete::Set(void) Add(new cMenuEditBoolItem(tr("Setup$Visible in Mainmenu"), &mainmenu_visible.u)); if (DisplayLine(mainmenu_name) && mainmenu_visible.u) Add(new cMenuEditStrItem (tr("Setup$ Name for Mainmenu"), mainmenu_name.u, sizeof(mainmenu_name.u), tr(FileNameChars))); - if (DisplayLine(confirmdel)) - Add(new cMenuEditBoolItem(tr("Setup$Confirm delete deleted recordings"), &confirmdel.u)); - if (DisplayLine(confirmdeldir)) - Add(new cMenuEditBoolItem(tr("Setup$Confirm delete directories"), &confirmdeldir.u)); - if (DisplayLine(confirmundel)) - Add(new cMenuEditBoolItem(tr("Setup$Confirm undelete deleted recordings"), &confirmundel.u)); - if (DisplayLine(confirmundeldir)) - Add(new cMenuEditBoolItem(tr("Setup$Confirm undelete directories"), &confirmundeldir.u)); + if (DisplayLine(confirmpurge)) + Add(new cMenuEditBoolItem(tr("Setup$Confirm purge deleted recordings"), &confirmpurge.u)); + if (DisplayLine(confirmpurgedir)) + Add(new cMenuEditBoolItem(tr("Setup$Confirm purge directories"), &confirmpurgedir.u)); + if (DisplayLine(confirmpurgeall)) + Add(new cMenuEditBoolItem(tr("Setup$Confirm purge all deleted recordings"), &confirmpurgeall.u)); + if (DisplayLine(confirmsalvage)) + Add(new cMenuEditBoolItem(tr("Setup$Confirm salvage deleted recordings"), &confirmsalvage.u)); + if (DisplayLine(confirmsalvagedir)) + Add(new cMenuEditBoolItem(tr("Setup$Confirm salvage directories"), &confirmsalvagedir.u)); + if (DisplayLine(confirmsalvageall)) + Add(new cMenuEditBoolItem(tr("Setup$Confirm salvage all deleted recordings"), &confirmsalvageall.u)); + if (DisplayLine(functionline_b_e[0])) + Add(new cMenuEditStraItem(tr("Setup$Purgeline position"), &functionline_b_e[0].u, 4, FunctionLine)); + if (DisplayLine(functionline_num[0]) && functionline_b_e[0].u == 0x3) + Add(new cMenuEditIntItem (tr("Setup$ Display bottom purge ex lines"), &functionline_num[0].u, 1, 200)); + if (DisplayLine(functionline_b_e[1])) + Add(new cMenuEditStraItem(tr("Setup$Salvageline position"), &functionline_b_e[1].u, 4, FunctionLine)); + if (DisplayLine(functionline_num[1]) && functionline_b_e[1].u == 0x3) + Add(new cMenuEditIntItem (tr("Setup$ Display bottom salvage ex lines"), &functionline_num[1].u, 1, 200)); + if ((DisplayLine(functionline_b_e[0]) || DisplayLine(functionline_b_e[1])) && DisplayLine(firstsalvage) && ((functionline_b_e[0].u & functionline_b_e[1].u & 0x1) != 0x0 || (functionline_b_e[0].u & functionline_b_e[1].u & 0x2) != 0x0)) + Add(new cMenuEditBoolItem(tr("Setup$ inward lines"), &firstsalvage.u, tr("Choise$purge"), tr("Choise$salvage"))); + if (FunctionToSelect > 0) + current = Count(); // pre select this line for display + Add(new cMenuEditBoolItem(tr("Setup$Change assigned functionkeys"), &show_setupfunction)); + if (show_setupfunction) + { + for (int i = 2; i < MaxFunctionName; i++) + { + if (FunctionToSelect == i) + current = Count(); + char *name = NULL; + asprintf(&name, tr("Setup$ Key for function-%s"), FunctionName[i]); + Add(new cMenuEditKeysItem(name, &functionkey[i].u)); + free(name); + } + Add(new cMenuOsdNoSelectItem(tr("Setup$ ** Spezial handled keys **"))); + if (FunctionToSelect == 1 && okkey.u == 1) + current = Count(); + Add(new cMenuEditStraItem(tr("Setup$ OK-key function"), &okkey.u, MaxFunctionName, FunctionName)); + if (FunctionToSelect == 1 && numkey.u == 1) + current = Count(); + Add(new cMenuEditStraItem(tr("Setup$ Numerickey select the entry and"), &numkey.u, 4, FunctionName)); + } if (DisplayLine(verbose)) Add(new cMenuEditBoolItem(tr("Setup$Verbose Log Mode"), &verbose.u)); #undef DisplayLine -#ifdef PL_Debug2 - dsyslog("%s: Count=%d", plugin_name, Count()); -#endif + d2syslog("cMenuSetupUndelete::Set", "Count=%d", Count()); SetCurrent(Get(current)); + Display(); } eOSState cMenuSetupUndelete::ProcessKey(eKeys Key) { -#ifdef PL_Debug3 - bool noneKey = Key == kNone; - if (!noneKey) - dsyslog("%s: cMenuSetupUndelete::ProcessKey Key=%s", plugin_name, KeyName(Key)); -#endif + d3ProcessKey1("cMenuSetupUndelete::ProcessKey"); + static bool oldhelpkeys; + bool helpkeys; int m_commandline_preference = commandline_preference.u; int m_mainmenu_visible = mainmenu_visible.u; + int m_show_setupfunction = show_setupfunction; + int m_purge_b_e = functionline_b_e[0].u; + int m_salvage_b_e = functionline_b_e[1].u; - eOSState state = cMenuSetupPage::ProcessKey(Key); -#ifdef PL_Debug3 - if (!noneKey || (state != osUnknown && state != osContinue)) + eOSState state = osUnknown; + + if (Key == kOk) { - dsyslog("%s: cMenuSetupUndelete::ProcessKey OSState=%s", plugin_name, OSStateName(state)); - noneKey = false; + int function1 = 0; + int function2 = 0; + for (int i = 2; i < MaxFunctionName; i++) + if (functionkey[i].u) + for (int j = i + 1; j < MaxFunctionName; j++) + if (functionkey[j].u && functionkey[i].u == functionkey[j].u && (i != 6 || j != 7) && (i != 8 || j != 9)) + { + function1 = i; + function2 = j; + i = j = MaxFunctionName; + } + if (function1) + { + show_setupfunction = true; + Set(function2); + char *info = NULL; + asprintf(&info, tr("Error$Key for funtion %s and %s identical."), FunctionName[function1], FunctionName[function2]); + INFO(info); + free(info); + state = osContinue; + } } -#endif - if (m_commandline_preference != commandline_preference.u || m_mainmenu_visible != mainmenu_visible.u) - { + if (state == osUnknown) + state = cMenuSetupPage::ProcessKey(Key); + d3ProcessKey2("cMenuSetupUndelete::ProcessKey"); + + if (m_commandline_preference != commandline_preference.u || m_mainmenu_visible != mainmenu_visible.u || m_show_setupfunction != show_setupfunction || m_purge_b_e != functionline_b_e[0].u || m_salvage_b_e != functionline_b_e[1].u) Set(); - Display(); + + helpkeys = typeid(*Get(Current())) == typeid(cMenuEditKeysItem); + if (oldhelpkeys != helpkeys) + { + oldhelpkeys = helpkeys; + if (helpkeys) + SetHelp(tr("Setup$Select"), tr("Setup$Select"), tr("Setup$Select"), tr("Setup$Select")); + else + SetHelp(NULL, NULL, NULL, NULL); } switch (state) { - case osUser1: state = AddSubMenu(new cMenuUndelete); - break; - default: break; + case osUser1: state = AddSubMenu(new cMenuUndelete); + break; + default: break; } -#ifdef PL_Debug3 - if (!noneKey || (state != osUnknown && state != osContinue)) - dsyslog("%s: cMenuSetupUndelete::ProcessKey returned OSState=%s", plugin_name, OSStateName(state)); -#endif + d3ProcessKey3("cMenuSetupUndelete::ProcessKey"); return state; } diff --git a/menusetup.h b/menusetup.h index 3d052b4..a669559 100644 --- a/menusetup.h +++ b/menusetup.h @@ -3,12 +3,13 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: menusetup.h 0.2 0.1 2004/10/08 02:03:31 hflor Exp $ + * $Id: menusetup.h 0.5 2005/11/17 21:05:05 hflor Exp $ */ #ifndef __MENUSETUP_H #define __MENUSETUP_H +#include "vdrtools.h" #include <vdr/menu.h> #include <vdr/menuitems.h> @@ -16,13 +17,17 @@ class cMenuSetupUndelete : public cMenuSetupPage { private: + int show_setupfunction; int store; protected: virtual void Store(void); public: - cMenuSetupUndelete(void); +#ifdef UND_Debug + int objID; +#endif + cMenuSetupUndelete(int FunctionToChange = 0); virtual ~cMenuSetupUndelete(void); - virtual void Set(void); + virtual void Set(int FunctionToSelect = 0); virtual eOSState ProcessKey(eKeys Key); }; diff --git a/menuundelete.c b/menuundelete.c index 8164b5d..ec8abc6 100644 --- a/menuundelete.c +++ b/menuundelete.c @@ -3,33 +3,32 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: menuundelete.c 0.3 2005/10/04 12:35:20 hflor Exp $ + * $Id: menuundelete.c 0.5 2005/11/17 21:05:05 hflor Exp $ */ #include "menuundelete.h" #if VDRVERSNUM < 10307 -#include "menuitemtext.h" + #include "menutext.h" #endif #include "undelete.h" +#include "menudispkey.h" #include "i18n.h" #include "vdrtools.h" #include <vdr/interface.h> #include <vdr/videodir.h> #include <vdr/remote.h> -#include <vdr/recording.h> #ifdef HAVE_ICONPATCH -#include <vdr/iconpatch.h> -#endif - -#ifndef RECEXT -#define RECEXT ".rec" -#define DELEXT ".del" + #include <vdr/iconpatch.h> #endif +#include <typeinfo> // --- cMenuRecordingSelectItem -------------------------------------------------------- cMenuRecordingSelectItem::cMenuRecordingSelectItem(cRecording *Recording, int Level) { +#ifdef UND_Debug + objID = ++cMenuRecordingSelectItem_nextID; +#endif filename = strdup(Recording->FileName()); totalEntries = newEntries = 0; start = Recording->start; @@ -39,20 +38,27 @@ cMenuRecordingSelectItem::cMenuRecordingSelectItem(cRecording *Recording, int Le else name = strdup(Recording->Name()); level = Level; -#ifdef UND_Debug2 - dsyslog("%s: cMenuRecordingSelectItem::cMenuRecordingSelectItem FileName=%s Level=%d Name=%s", plugin_name, filename, level, name); -#endif + d2syslog("cMenuRecordingSelectItem::cMenuRecordingSelectItem", "FileName=%s Level=%d Name=%s", filename, level, name); } cMenuRecordingSelectItem::~cMenuRecordingSelectItem() { -#ifdef UND_Debug2 - dsyslog("%s: cMenuRecordingSelectItem::~cMenuRecordingSelectItem FileName=%s Name=%s", plugin_name, filename, name); -#endif - FREENULL(filename); - FREENULL(name); + d2syslog("cMenuRecordingSelectItem::~cMenuRecordingSelectItem", "FileName=%s Name=%s", filename, name); + freenull(filename); + freenull(name); } +#if VDRVERSNUM >= 10315 +int cMenuRecordingSelectItem::compare(const cListObject &ListObject) const +{ + cMenuRecordingSelectItem *temp = (cMenuRecordingSelectItem *)&ListObject; + if (isdir != temp->isdir) + return isdir ? -1 : 1; + if (isdir) + return strcasecmp(name, temp->name); + return start == temp->start ? 0 : start < temp->start ? -1 : 1; +} +#else bool cMenuRecordingSelectItem::operator< (const cListObject &ListObject) { cMenuRecordingSelectItem *temp = (cMenuRecordingSelectItem *)&ListObject; @@ -62,6 +68,7 @@ bool cMenuRecordingSelectItem::operator< (const cListObject &ListObject) return strcasecmp(name, temp->name) < 0; return start < temp->start; } +#endif void cMenuRecordingSelectItem::IncrementCounter(bool New) { @@ -71,16 +78,12 @@ void cMenuRecordingSelectItem::IncrementCounter(bool New) char *buffer = NULL; asprintf(&buffer, "%d\t%d\t%s", totalEntries, newEntries, name); SetText(buffer, false); -#ifdef UND_Debug2 - dsyslog("%s: cMenuRecordingSelectItem::IncrementCounter FileName=%s New=%s Buffer=%s", plugin_name, filename, New ? "true" : "false", buffer); -#endif + d2syslog("cMenuRecordingSelectItem::IncrementCounter", "FileName=%s New=%s Buffer=%s", filename, New ? "true" : "false", buffer); } void cMenuRecordingSelectItem::RefreshCounter(void) { -#ifdef UND_Debug2 - dsyslog("%s: cMenuRecordingSelectItem::RefeshCounter FileName=%s", plugin_name, filename); -#endif + d2syslog("cMenuRecordingSelectItem::RefeshCounter", "FileName=%s", filename); if (isdir) { char *dirname = DirName(); @@ -89,20 +92,22 @@ void cMenuRecordingSelectItem::RefreshCounter(void) totalEntries = 0; newEntries = 0; for (cRecording *recording = DeletedRecordings.First(); recording; recording = DeletedRecordings.Next(recording)) - if (strncmp(recording->FileName(), dirname, strlen(dirname)) == 0) - IncrementCounter(recording->IsNew()); + if (!strncmp(recording->FileName(), dirname, strlen(dirname))) + if (strchr(recording->FileName() + strlen(dirname), '/')) + IncrementCounter(recording->IsNew()); free(dirname); } } } -char *cMenuRecordingSelectItem::DirName(void) +char *cMenuRecordingSelectItem::DirName(bool Parent) { - if (isdir) + char *temp = NULL; + if (isdir || Parent) { - char *temp = strdup(filename); + temp = strdup(filename); char *last = temp + strlen(VideoDirectory) + 1; - for (int i = level; *last && i >= 0; i--) + for (int i = level; *last && i >= Parent ? -1 : 0; i--) { last = strchr(last, '/'); if (!last) @@ -111,31 +116,29 @@ char *cMenuRecordingSelectItem::DirName(void) } if (last) *last = 0; - return temp; - } else - return NULL; + } + d2syslog("cMenuRecordingSelectItem::DirName", "Level=%d Parent=%s DirName=%s", level, Parent ? "yes" : "no", temp ? temp : "(NULL)"); + return temp; } // --- cMenuRecordingSelect -------------------------------------------------------- -cMenuRecordingSelect::cMenuRecordingSelect(const char *Base, int Level, bool OpenSubMenus) +cMenuRecordingSelect::cMenuRecordingSelect(const char *Base, int Level) +#if VDRVERSNUM >= 10307 +:cOsdMenu(Base ? Base : tr("Deleted Recordings"), 9, 6, 6) +#else :cOsdMenu(Base ? Base : tr("Deleted Recordings"), 6, 6, 6) -{ -#ifdef UND_Debug2 - dsyslog("%s: cMenuRecordingSelect::cMenuRecordingSelect Base=%s Level=%d OpenSubMenus=%s", plugin_name, Base, Level, OpenSubMenus ? "true" : "false"); #endif -#if VDRVERSNUM < 10307 -#ifdef HAVE_ELCHI - Interface->Status(tr("Display$prepare recording display..."), Setup.Theme == themeVanilla ? clrBlack : (eDvbColor)fginfofont, Setup.Theme == themeVanilla ? clrCyan : clrInfoLine); -#else - Interface->Status(tr("Display$prepare recording display...")); +{ +#ifdef UND_Debug + objID = ++cMenuRecordingSelect_nextID; #endif - Interface->Flush(); -#else + d2syslog("cMenuRecordingSelect::cMenuRecordingSelect", "Base=%s Level=%d", Base, Level); STATUS(tr("Display$prepare recording display...")); -#endif base = Base ? strdup(Base) : NULL; level = Level; + top_line[0] = top_line[1] = bottom_line[0] = bottom_line[1] = false; + Display(); cMenuRecordingSelectItem *LastItem = NULL; char *LastItemText = NULL; @@ -144,11 +147,11 @@ cMenuRecordingSelect::cMenuRecordingSelect(const char *Base, int Level, bool Ope if (!Base || (strstr(recording->Name(), Base) == recording->Name() && recording->Name()[strlen(Base)] == '~')) { cMenuRecordingSelectItem *Item = new cMenuRecordingSelectItem(recording, level); - if (*Item->Text() && (!LastItem || strcmp(Item->Text(), LastItemText) != 0)) + if (*Item->Text() && (!LastItem || strcmp(Item->Text(), LastItemText))) { Add(Item); LastItem = Item; - FREENULL(LastItemText); + freenull(LastItemText); LastItemText = strdup(LastItem->Text()); } else delete Item; @@ -159,232 +162,400 @@ cMenuRecordingSelect::cMenuRecordingSelect(const char *Base, int Level, bool Ope } } } - free(LastItemText); - LastItem = Current() < 0 ? NULL : (cMenuRecordingSelectItem *)Get(Current()); + freenull(LastItemText); Sort(); - if (LastItem) - { - SetCurrent(LastItem); - if (OpenSubMenus && Open(true) == osContinue) - return; - } else - SetCurrent(First()); + AddFunctionLines(); + d1listlog("cMenuRecordingSelect::cMenuRecordingSelect"); + SetCurrent(First()); SetHelpKeys(); } cMenuRecordingSelect::~cMenuRecordingSelect() { -#ifdef UND_Debug2 - dsyslog("%s: cMenuRecordingSelect::~cMenuRecordingSelect Base=%s Level=%d", plugin_name, base, level); -#endif - FREENULL(base); + d2syslog("cMenuRecordingSelect::~cMenuRecordingSelect", "Base=%s Level=%d", base, level); + freenull(base); } -void cMenuRecordingSelect::SetHelpKeys(void) +bool cMenuRecordingSelect::IsMenuRecordingSelectItem(cOsdItem *Item) { -#ifdef UND_Debug2 - dsyslog("%s: cMenuRecordingSelect::SetHelpKeys", plugin_name); -#endif - - cMenuRecordingSelectItem *ri = (cMenuRecordingSelectItem *)Get(Current()); - if (ri) - { - if (ri->IsDirectory()) - SetHelp(tr("Open"), tr("Undelete"), tr("Delete"), NULL); - else - { - cRecording *recording = GetRecording(ri); -#if VDRVERSNUM >= 10325 - SetHelp(NULL, tr("Undelete"), tr("Delete"), (recording && recording->Info()->Title() && *recording->Info()->Title()) ? tr("Summary") : NULL); -#else - SetHelp(NULL, tr("Undelete"), tr("Delete"), (recording && recording->Summary() && *recording->Summary()) ? tr("Summary") : NULL); -#endif - } - } else + if (Item) { - SetHelp(NULL); + d1syslog("cMenuRecordingSelect::IsMenuRecordingSelectItem", "Type(Item)=%s Text(Item)=%s", typeid(*Item).name(), Item->Text()); + return typeid(*Item) == typeid(cMenuRecordingSelectItem); } + d1syslog("cMenuRecordingSelect::IsMenuRecordingSelectItem", "Item=%s", "(NULL)"); + return false; } -cRecording *cMenuRecordingSelect::GetRecording(cMenuRecordingSelectItem *Item) +bool cMenuRecordingSelect::IsDirectory(cOsdItem *Item) { - cRecording *recording = DeletedRecordings.GetByName(Item->FileName()); - if (!recording) - ERROR(tr("Error while accessing recording!")); - return recording; + if (IsMenuRecordingSelectItem(Item)) + return ((cMenuRecordingSelectItem *)Item)->IsDirectory(); + return false; } -eOSState cMenuRecordingSelect::Open(bool OpenSubMenus) +bool cMenuRecordingSelect::IsRecording(cOsdItem *Item) { - cMenuRecordingSelectItem *ri = (cMenuRecordingSelectItem *)Get(Current()); - if (ri) - { - if (ri->IsDirectory()) - { - const char *t = ri->Name(); - char *buffer = NULL; - if (base) - { - asprintf(&buffer, "%s~%s", base, t); - t = buffer; - } - AddSubMenu(new cMenuRecordingSelect(t, level + 1, OpenSubMenus)); - FREENULL(buffer); - return osContinue; - } - } - return osUnknown; + if (IsMenuRecordingSelectItem(Item)) + return !((cMenuRecordingSelectItem *)Item)->IsDirectory(); + return false; } -eOSState cMenuRecordingSelect::UnDelete(void) +bool cMenuRecordingSelect::IsReady(void) { - if (HasSubMenu() || Count() == 0) - return osContinue; if (WorkFilename) - { esyslog("%s: Error previous jobs not completed (%s)", plugin_name, WorkFilename); - return osContinue; - } - cMenuRecordingSelectItem *ri = (cMenuRecordingSelectItem *)Get(Current()); - if (ri && ((!ri->IsDirectory() && (!confirmundel.u || Interface->Confirm(tr("Question$Undelete recording?")))) || (ri->IsDirectory() && (!confirmundeldir.u || Interface->Confirm(tr("Question$Undelete recordings in directory?")))))) + return !WorkFilename; +} + +cRecording *cMenuRecordingSelect::GetRecording(cOsdItem *Item) +{ + if (IsRecording(Item)) { - if (ri->IsDirectory()) - WorkFilename = ri->DirName(); // WorkFilename is NULL see up - else - WorkFilename = strdup(ri->FileName()); - cRemote::Put((eKeys)kUnDelRec); - cOsdMenu::Del(Current()); - Display(); - if (!Count()) - return osBack; - } - return osContinue; + cRecording *recording = DeletedRecordings.GetByName(((cMenuRecordingSelectItem *)Item)->FileName()); + if (!recording) + ERROR(tr("Error while accessing recording!")); + return recording; + } else + return NULL; } -eOSState cMenuRecordingSelect::Delete(void) +void cMenuRecordingSelect::AddFunctionLines(void) { - if (HasSubMenu() || Count() == 0) - return osContinue; - if (WorkFilename) + d1syslog("cMenuRecordingSelect::AddFunctionLines", "Count=%d purge=%s lines=%d salvage=%s lines=%d", Count(), FunctionLine[functionline_b_e[0].u], functionline_num[0].u, FunctionLine[functionline_b_e[1].u], functionline_num[1].u); + for (int i = 0; i < 2; i++) { - esyslog("%s: Error previous jobs not completed (%s)", plugin_name, WorkFilename); - return osContinue; + if (functionline_b_e[i].u != 0x0 && Count()) + { + if (functionline_b_e[i].u & 0x1) + top_line[i] = true; + if ((functionline_b_e[i].u & 0x2) && (!top_line[i] || Count() >= functionline_num[i].u)) + bottom_line[i] = true; + } } - cMenuRecordingSelectItem *ri = (cMenuRecordingSelectItem *)Get(Current()); - if (ri && ((!ri->IsDirectory() && (!confirmdel.u || Interface->Confirm(tr("Question$Delete recording definitive?")))) || (ri->IsDirectory() && (!confirmdeldir.u || Interface->Confirm(tr("Question$Delete recordings in diretory definitive?")))))) + if (firstsalvage.u) + { + if (top_line[0]) + Ins(new cOsdItem(tr("Display$Purge all records ..."), osUser2)); + if (top_line[1]) + Ins(new cOsdItem(tr("Display$Salavge all records ..."), osUser3)); + if (bottom_line[0]) + Add(new cOsdItem(tr("Display$Purge all records ..."), osUser2)); + if (bottom_line[1]) + Add(new cOsdItem(tr("Display$Salavge all records ..."), osUser3)); + } else { - if (ri->IsDirectory()) - WorkFilename = ri->DirName(); // WorkFilename is NULL see up - else - WorkFilename = strdup(ri->FileName()); - cRemote::Put((eKeys)kDelRec); - cOsdMenu::Del(Current()); - Display(); - if (!Count()) - return osBack; + if (top_line[1]) + Ins(new cOsdItem(tr("Display$Salavge all records ..."), osUser3)); + if (top_line[0]) + Ins(new cOsdItem(tr("Display$Purge all records ..."), osUser2)); + if (bottom_line[1]) + Add(new cOsdItem(tr("Display$Salavge all records ..."), osUser3)); + if (bottom_line[0]) + Add(new cOsdItem(tr("Display$Purge all records ..."), osUser2)); } - return osContinue; + d1syslog("cMenuRecordingSelect::AddFunctionLines", "new top(purge)=%s top(salavge)=%s bottom(purge)=%s bottom(salvage)=%s", top_line[0] ? "yes" : "no", top_line[1] ? "yes" : "no", bottom_line[0] ? "yes" : "no", bottom_line[1] ? "yes" : "no"); } -eOSState cMenuRecordingSelect::Summary(void) +void cMenuRecordingSelect::DelFunctionLines(void) { - if (HasSubMenu() || Count() == 0) - return osContinue; - cMenuRecordingSelectItem *ri = (cMenuRecordingSelectItem *)Get(Current()); - if (ri && !ri->IsDirectory()) + if (top_line[0] || top_line[1]) + Del(0); + if (top_line[0] && top_line[1]) + Del(0); + if (bottom_line[0] || bottom_line[1]) + Del(Count() - 1); + if (bottom_line[0] && bottom_line[1]) + Del(Count() - 1); + top_line[0] = top_line[1] = bottom_line[0] = bottom_line[1] = false; +} + +void cMenuRecordingSelect::SetHelpKeys(void) +{ + const char *helptext[4] = { NULL, NULL, NULL, NULL }; + cOsdItem *item = Get(Current()); + + for (int i = 2; i < MaxFunctionName; i++) { - cRecording *recording = GetRecording(ri); -#if VDRVERSNUM >= 10325 - if (recording && recording->Info()->Title() && *recording->Info()->Title()) -#else - if (recording && recording->Summary() && *recording->Summary()) -#endif -#if VDRVERSNUM >= 10307 + bool functionavailable = false; + switch (i) + { + case 2: + case 3: functionavailable = IsMenuRecordingSelectItem(item); + break; + case 4: + case 5: functionavailable = Count(); + break; + case 6: functionavailable = IsDirectory(item); + break; + case 7: if (IsRecording(item)) + { + cRecording *recording = GetRecording(item); #if VDRVERSNUM >= 10325 - return AddSubMenu(new cMenuText(tr("Summary"), recording->Info()->Title())); -#else - return AddSubMenu(new cMenuText(tr("Summary"), recording->Summary())); -#endif -#else + functionavailable = (recording && recording->Info() && recording->Info()->Description() && *recording->Info()->Description()); +#else + functionavailable = (recording && recording->Summary() && *recording->Summary()); +#endif + } + break; + case 8: functionavailable = KeyState != 1 || functionkey[8].u != functionkey[9].u; + break; + case 9: functionavailable = KeyState != 2 || functionkey[8].u != functionkey[9].u; + break; + case 10: functionavailable = true; + break; + } + if (functionavailable) + switch (functionkey[i].u) + { + case 1: + case 3: + case 5: + case 7: if (KeyState == 1) + helptext[functionkey[i].u >> 1] = FunctionHotKey[i]; + break; + case 2: + case 4: + case 6: + case 8: if (KeyState == 2) + helptext[(functionkey[i].u - 1) >> 1] = FunctionHotKey[i]; + break; + } + } + SetHelp(helptext[0], helptext[1], helptext[2], helptext[3]); + d2syslog("cMenuRecordingSelect::SetHelpKeys", "KeyState=%d Item=%s red=%s green=%s yellow=%s blue=%s", KeyState, item ? item->Text() : "(NULL)", helptext[0] ? helptext[0] : "(NULL)", helptext[1] ? helptext[1] : "(NULL)", helptext[2] ? helptext[2] : "(NULL)", helptext[3] ? helptext[3] : "(NULL)"); +} + +eOSState cMenuRecordingSelect::FunctionCall(int FunctionNumber) +{ + eOSState state = osUnknown; + cOsdItem *item = Get(Current()); + d2syslog("cMenuRecordingSelect::FunctionCall", "FunctionNumber=%d HasSubMenu=%s Item=%s", FunctionNumber, HasSubMenu() ? "yes" : "no", item ? item->Text() : "(NULL)"); + cMenuRecordingSelectItem *ri = NULL; + cRecording *recording = NULL; + if (!item || HasSubMenu()) + return osContinue; + switch (FunctionNumber) + { + // open/summary + case 1: if (IsDirectory(item)) + state = FunctionCall(6); + else if (IsRecording(item)) + state = FunctionCall(7); + break; + + // purge + case 2: state = osContinue; + if (IsMenuRecordingSelectItem(item) && IsReady()) + { + ri = (cMenuRecordingSelectItem *)item; + if ((!ri->IsDirectory() && (!confirmpurge.u || Interface->Confirm(tr("Question$Purge recording?")))) || (ri->IsDirectory() && (!confirmpurgedir.u || Interface->Confirm(tr("Question$Purge recordings in diretory?"))))) + { + cRemote::Put((eKeys)kPurgeRec); + if (ri->IsDirectory()) + WorkFilename = ri->DirName(); // WorkFilename is NULL see IsReady() + else + WorkFilename = strdup(ri->FileName()); + } + } + break; + + // salvage + case 3: state = osContinue; + if (IsMenuRecordingSelectItem(item) && IsReady()) + { + ri = (cMenuRecordingSelectItem *)item; + if ((!ri->IsDirectory() && (!confirmsalvage.u || Interface->Confirm(tr("Question$Salvage recording?")))) || (ri->IsDirectory() && (!confirmsalvagedir.u || Interface->Confirm(tr("Question$Salvage recordings in directory?"))))) + { + cRemote::Put((eKeys)kSalvageRec); + if (ri->IsDirectory()) + WorkFilename = ri->DirName(); // WorkFilename is NULL see IsReady() + else + WorkFilename = strdup(ri->FileName()); + } + } + break; + + // purge all + case 4: state = osContinue; + if (IsReady() && (!confirmpurgeall.u || Interface->Confirm(tr("Question$Purge all recordings?")))) + { + cRemote::Put((eKeys)kPurgeRec); + for (item = First(); !WorkFilename && item; item = Next(item)) + if (IsMenuRecordingSelectItem(item)) + WorkFilename = ((cMenuRecordingSelectItem *)item)->DirName(true); + Clear(); + top_line[0] = top_line[1] = bottom_line[0] = bottom_line[1] = false; + } + break; + + // salvage all + case 5: state = osContinue; + if (IsReady() && (!confirmsalvageall.u || Interface->Confirm(tr("Question$Salvage all recordings?")))) + { + cRemote::Put((eKeys)kSalvageRec); + for (item = First(); !WorkFilename && item; item = Next(item)) + if (IsMenuRecordingSelectItem(item)) + WorkFilename = ((cMenuRecordingSelectItem *)item)->DirName(true); + Clear(); + top_line[0] = top_line[1] = bottom_line[0] = bottom_line[1] = false; + } + break; + + // open + case 6: if (IsDirectory(item)) + { + ri = (cMenuRecordingSelectItem *)item; + const char *t = ri->Name(); + char *buffer = NULL; + if (base) + { + asprintf(&buffer, "%s~%s", base, t); + t = buffer; + } + state = AddSubMenu(new cMenuRecordingSelect(t, level + 1)); + freenull(buffer); + } + break; + + // summary + case 7: recording = GetRecording(item); #if VDRVERSNUM >= 10325 - return AddSubMenu(new cMenuItemText(tr("Summary"), recording->Info()->Title())); -#else - return AddSubMenu(new cMenuItemText(tr("Summary"), recording->Summary())); -#endif -#endif + if (recording && recording->Info() && recording->Info()->Description() && *recording->Info()->Description()) + state = AddSubMenu(new cMenuText(tr("Summary"), recording->Info()->Description())); +#else + if (recording && recording->Summary() && *recording->Summary()) + state = AddSubMenu(new cMenuText(tr("Summary"), recording->Summary())); +#endif + break; + + // switch hotkeys to 1 + case 8: if (functionkey[8].u == functionkey[9].u && KeyState == 1) + KeyState = 2; + else + KeyState = 1; + cRemote::Put((eKeys)kHelpKeys); + state = osContinue; + break; + + // switch hotkeys to 2 + case 9: KeyState = 2; + cRemote::Put((eKeys)kHelpKeys); + state = osContinue; + break; + + // Choise$Display keys + case 10: state = AddSubMenu(new cMenuDispKey()); + break; } - return osContinue; + d2syslog("cMenuRecordingSelect::FunctionCall", "FunctionNumber=%d returned OSState=%s WorkFilename=%s KeyState=%d", FunctionNumber, OSStateName(state), WorkFilename ? WorkFilename : "(NULL)", KeyState); + return state; } eOSState cMenuRecordingSelect::ProcessKey(eKeys Key) { -#ifdef UND_Debug3 - bool noneKey = Key == kNone; - if (!noneKey) - dsyslog("%s: cMenuRecordingSelect::ProcessKey Key=%s", plugin_name, KeyName(Key)); -#endif bool hSubMenu = HasSubMenu(); + cOsdItem *item = NULL; + int keynumber; + d3ProcessKey1("cMenuRecordingSelect::ProcessKey"); eOSState state = cOsdMenu::ProcessKey(Key); -#ifdef UND_Debug3 - if (!noneKey || (state != osUnknown && state != osContinue)) - { - dsyslog("%s: cMenuRecordingSelect::ProcessKey OSState=%s", plugin_name, OSStateName(state)); - noneKey = false; - } -#endif - + d3ProcessKey2("cMenuRecordingSelect::ProcessKey"); if (hSubMenu && !HasSubMenu()) { - if (Key == kYellow || Key == kGreen) - { - cOsdMenu::Del(Current()); - if (!Count()) - state = osBack; - } if (state == osContinue) { - for (cMenuRecordingSelectItem *ri = (cMenuRecordingSelectItem *)First(); ri; ri = (cMenuRecordingSelectItem *)Next(ri)) - ri->RefreshCounter(); + for (item = First(); item; item = Next(item)) + if (IsDirectory(item)) + ((cMenuRecordingSelectItem *)item)->RefreshCounter(); Display(); } } switch (state) { - case osUnknown: switch (Key) - { - case kBack: state = osBack; - case kOk: - case kRed: state = Open(); - break; - case kGreen: state = UnDelete(); - break; - case kYellow: state = Delete(); - break; - case kBlue: state = Summary(); - break; - default: break; - } - break; - default: break; + case osUnknown: keynumber = KeyState - 2; // KeyState is 1 or 2 + switch (Key) + { + case kBlue: keynumber += 2; // no break! + case kYellow: keynumber += 2; // no break! + case kGreen: keynumber += 2; // no break! + case kRed: keynumber += 2; // keynumber red=1/2 green=3/4 yellow=5/6 blue=7/8 + break; + case k0...k9: keynumber = Key - k0 + 9; + break; + case kUser1...kUser9: keynumber = Key - kUser1 + 19; + break; + case kOk: state = FunctionCall(okkey.u); + break; + case kDelLine: + if (Count()) + Del(Current()); + item = Get(Current()); + if (item && !IsMenuRecordingSelectItem(item)) + { + item = Prev(item); + if (!IsMenuRecordingSelectItem(item)) + item = NULL; + } + DelFunctionLines(); + AddFunctionLines(); + if (item) + SetCurrent(item); + if (Count()) + { + Display(); + state = osContinue; + cRemote::Put((eKeys)kHelpKeys); + } else + { + state = osBack; + cRemote::Put((eKeys)kDelLine); + } + break; + default: break; + } + if (keynumber > 0) + for (int i = 0; i < MaxFunctionName && state == osUnknown; i++) + if (functionkey[i].u == keynumber) + state = FunctionCall(i); + if (state == osUnknown && Key >= k0 && Key <= k9) + { + item = Get((Key == k0 ? 10 : Key - k0) + (top_line[0] ? 1 : 0) + (top_line[1] ? 1 : 0) - 1); + if (IsMenuRecordingSelectItem(item)) + { + SetCurrent(item); + Display(); + state = FunctionCall(numkey.u); + } + } + break; + case osUser2: state = FunctionCall(4); + break; + case osUser3: state = FunctionCall(5); + break; + default: break; } if (!HasSubMenu() && Key != kNone && !WorkFilename) { SetHelpKeys(); - cMenuRecordingSelectItem *ri = (cMenuRecordingSelectItem *)Get(Current()); - if (ri) + item = Get(Current()); + if (IsDirectory(item)) { - ri->RefreshCounter(); + ((cMenuRecordingSelectItem *)item)->RefreshCounter(); RefreshCurrent(); } } -#ifdef UND_Debug3 - if (!noneKey || (state != osUnknown && state != osContinue)) - dsyslog("%s: cMenuRecordingSelect::ProcessKey returned OSState=%s", plugin_name, OSStateName(state)); +#ifdef UND_Debug1 + if (state != osUnknown && !HasSubMenu()) + { + d1syslog("cMenuRecordingSelect::ProcessKey", "base=%s", base ? base : "(NULL)"); + d1listlog("cMenuRecordingSelect::ProcessKey"); + } #endif + d3ProcessKey3("cMenuRecordingSelect::ProcessKey"); return state; } @@ -393,50 +564,22 @@ eOSState cMenuRecordingSelect::ProcessKey(eKeys Key) cMenuUndelete::cMenuUndelete(void) :cOsdMenu(tr("Deleted Recordings"), 6, 6) { -#ifdef UND_Debug2 - dsyslog("%s: cMenuUndelete::cMenuUndelete", plugin_name); -#endif -#if VDRVERSNUM < 10307 -#ifdef HAVE_ELCHI - Interface->Status(tr("Display$prepare recording display..."), Setup.Theme == themeVanilla ? clrBlack : (eDvbColor)fginfofont, Setup.Theme == themeVanilla ? clrCyan : clrInfoLine); -#else - Interface->Status(tr("Display$prepare recording display...")); -#endif - Interface->Flush(); -#else - STATUS(tr("Display$prepare recording display...")); -#endif -#if VDRVERSNUM >= 10311 - DeletedRecordings.Load(); -#else - DeletedRecordings.Load(true); +#ifdef UND_Debug + objID = ++cMenuUndelete_nextID; #endif - AddSubMenu(new cMenuRecordingSelect); + d2syslog("cMenuUndelete::cMenuUndelete", "%s", ""); + MenuIsOpen = true; PurgeRecording = false; SalvageRecording = false; + FillMenu(); } cMenuUndelete::~cMenuUndelete() { -#ifdef UND_Debug2 - dsyslog("%s: cMenuUndelete::~cMenuUndelete", plugin_name); -#endif - if (PurgeRecording) - { -#if VDRVERSNUM < 10307 -#ifdef HAVE_ELCHI - Interface->Status(tr("Display$remove empty directories..."), Setup.Theme == themeVanilla ? clrBlack : (eDvbColor)fginfofont, Setup.Theme == themeVanilla ? clrCyan : clrInfoLine); -#else - Interface->Status(tr("Display$remove empty directories...")); -#endif - Interface->Flush(); -#else - STATUS(tr("Display$remove empty directories...")); -#endif - RemoveEmptyVideoDirectories(); - } + d2syslog("cMenuUndelete::~cMenuUndelete", "%s", ""); + if (PurgeRecording && !oRemoveThread.ActiveWithCancel()) + oRemoveThread.Start(); DeletedRecordings.Clear(); - #if VDRVERSNUM >= 10311 if (SalvageRecording) #if VDRVERSNUM >= 10333 @@ -445,121 +588,120 @@ cMenuUndelete::~cMenuUndelete() Recordings.TriggerUpdate(); #endif #endif + MenuIsOpen = false; } -eOSState cMenuUndelete::ProcessKey(eKeys Key) +void cMenuUndelete::FillMenu(void) { -#ifdef UND_Debug3 - bool noneKey = Key == kNone; - if (!noneKey) - dsyslog("%s: cMenuUndelete::ProcessKey Key=%s", plugin_name, KeyName(Key)); + STATUS(tr("Display$prepare recording display...")); + DeletedRecordings.Clear(); +#if VDRVERSNUM >= 10311 + DeletedRecordings.Load(); +#else + DeletedRecordings.Load(true); #endif + DeletedRecordings.Sort(); + KeyState = 1; + AddSubMenu(new cMenuRecordingSelect); +} +eOSState cMenuUndelete::ProcessKey(eKeys Key) +{ + d3ProcessKey1("cMenuUndelete::ProcessKey"); eOSState state = cOsdMenu::ProcessKey(Key); + d3ProcessKey2("cMenuUndelete::ProcessKey"); #ifdef UND_Debug3 - if (!noneKey || (state != osUnknown && state != osContinue)) - { - dsyslog("%s: cMenuUndelete::ProcessKey OSState=%s", plugin_name, OSStateName(state)); - noneKey = false; - } + if (!noneKey || state != osUnknown) + d3syslog("cMenuUndelete::ProcessKey", "WorkFilename=%s", WorkFilename ? WorkFilename : "(NULL)"); #endif if (state == osUnknown) { cRecording *recording = NULL; + bool processerror = false; bool processrecording = false; - if (WorkFilename && (Key == kDelRec || Key == kUnDelRec)) - { -#if VDRVERSNUM < 10307 -#ifdef HAVE_ELCHI - Interface->Status(tr("Display$please wait ..."), Setup.Theme == themeVanilla ? clrBlack : (eDvbColor)fginfofont, Setup.Theme == themeVanilla ? clrCyan : clrInfoLine); -#else - Interface->Status(tr("Display$please wait ...")); -#endif - Interface->Flush(); -#else + if (WorkFilename && (Key == kPurgeRec || Key == kSalvageRec)) STATUS(tr("Display$please wait ...")); -#endif - } switch (Key) { - case kUnDelRec: state = osContinue; - if (WorkFilename) - { - for (recording = DeletedRecordings.First(); recording; recording = DeletedRecordings.Next(recording)) - if (strncmp(recording->FileName(), WorkFilename, strlen(WorkFilename)) == 0) - { - if (verbose.u) - isyslog("%s: undelete recording=%s", plugin_name, recording->FileName()); - char *NewName = strdup(recording->FileName()); - char *ext = strrchr(NewName, '.'); - if (strcmp(ext, DELEXT) == 0) + case kPurgeRec: state = osContinue; + if (WorkFilename) + { + for (recording = DeletedRecordings.First(); recording; recording = DeletedRecordings.Next(recording)) + if (!strncmp(recording->FileName(), WorkFilename, strlen(WorkFilename)) && (*(WorkFilename + strlen(WorkFilename) - 1) != '/' || strchr(recording->FileName() + strlen(WorkFilename), '/'))) { - strncpy(ext, RECEXT, strlen(ext)); - if (access(NewName, F_OK) == 0) + if (verbose.u) + isyslog("%s: purge deleted recording (%s)", plugin_name, recording->FileName()); + if (!RemoveVideoFile(recording->FileName())) { - ERROR(tr("Error$Recording with the same name exists!")); - if (verbose.u) - isyslog("%s: Recording with the same name exists!", plugin_name); - } else + esyslog("%s: Error while remove deleted recording (%s)", plugin_name, recording->FileName()); + processerror = true; + } + PurgeRecording = true; + cRemote::Put(Key); + DeletedRecordings.Del(recording); + processrecording = true; + break; + } + } + break; + case kSalvageRec: state = osContinue; + if (WorkFilename) + { + for (recording = DeletedRecordings.First(); recording; recording = DeletedRecordings.Next(recording)) + if (!strncmp(recording->FileName(), WorkFilename, strlen(WorkFilename)) && (*(WorkFilename + strlen(WorkFilename) - 1) != '/' || strchr(recording->FileName() + strlen(WorkFilename), '/'))) + { + if (verbose.u) + isyslog("%s: undelete recording (%s)", plugin_name, recording->FileName()); + char *NewName = strdup(recording->FileName()); + char *ext = strrchr(NewName, '.'); + if (!strcmp(ext, DELEXT)) { - if (!RenameVideoFile(recording->FileName(), NewName)) - esyslog("%s: Error while rename deleted recording (%s) to (%s)", plugin_name, recording->FileName(), NewName); - SalvageRecording = true; + strncpy(ext, RECEXT, strlen(ext)); + if (!access(NewName, F_OK)) + { + if (verbose.u) + isyslog("%s: Recording with the same name exists (%s)", plugin_name, NewName); + ERROR(tr("Error$Recording with the same name exists!")); + processerror = true; + } else + { + if (!RenameVideoFile(recording->FileName(), NewName)) + { + esyslog("%s: Error while rename deleted recording (%s) to (%s)", plugin_name, recording->FileName(), NewName); + processerror = true; + } + SalvageRecording = true; + } } + free(NewName); + cRemote::Put(Key); + DeletedRecordings.Del(recording); + processrecording = true; + break; } - free(NewName); - cRemote::Put((eKeys)kUnDelRec); - DeletedRecordings.Del(recording); - processrecording = true; - break; - } - } - break; - case kDelRec: state = osContinue; - if (WorkFilename) - { - for (recording = DeletedRecordings.First(); recording; recording = DeletedRecordings.Next(recording)) - if (strncmp(recording->FileName(), WorkFilename, strlen(WorkFilename)) == 0) - { - if (verbose.u) - isyslog("%s: purge deleted recording=%s", plugin_name, recording->FileName()); - if (!RemoveVideoFile(recording->FileName())) - esyslog("%s: Error while remove deleted recording (%s)", plugin_name, recording->FileName()); - PurgeRecording = true; - cRemote::Put((eKeys)kDelRec); - DeletedRecordings.Del(recording); - processrecording = true; - break; - } - } - break; - case kHelpKeys: if (!HasSubMenu()) - state = osBack; - default: break; + } + break; + case kHelpKeys: if (!HasSubMenu()) + state = osBack; + default: break; } - if (WorkFilename && !processrecording) + if (WorkFilename && (!processrecording || processerror)) { - FREENULL(WorkFilename); // restore Helpkeys in cMenuRecordingSelect::ProcessKey -#if VDRVERSNUM < 10307 -#ifdef HAVE_ELCHI - Interface->Status(NULL, Setup.Theme == themeVanilla ? clrBlack : (eDvbColor)fginfofont, Setup.Theme == themeVanilla ? clrCyan : clrInfoLine); -#else - Interface->Status(NULL); -#endif - Interface->Flush(); -#else + freenull(WorkFilename); + if (processerror) + { + CloseSubMenu(); + Clear(); + FillMenu(); + } else + cRemote::Put((eKeys)kDelLine); STATUS(NULL); -#endif - cRemote::Put((eKeys)kHelpKeys); } } if (!WorkFilename && !HasSubMenu()) state = osBack; -#ifdef UND_Debug3 - if (!noneKey || (state != osUnknown && state != osContinue)) - dsyslog("%s: cMenuUndelete::ProcessKey returned OSState=%s", plugin_name, OSStateName(state)); -#endif + d3ProcessKey3("cMenuUndelete::ProcessKey"); return state; } diff --git a/menuundelete.h b/menuundelete.h index 9373d37..47db6b4 100644 --- a/menuundelete.h +++ b/menuundelete.h @@ -3,14 +3,21 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: menuundelete.h 0.2 2004/10/10 12:23:20 hflor Exp $ + * $Id: menuundelete.h 0.4 2005/11/16 18:39:18 hflor Exp $ */ #ifndef __MENUUNDELETE_H #define __MENUUNDELETE_H +#include "vdrtools.h" #include <vdr/menu.h> #include <vdr/menuitems.h> +#include <vdr/recording.h> + +#ifndef RECEXT + #define RECEXT ".rec" + #define DELEXT ".del" +#endif // --- cMenuRecordingSelectItem -------------------------------------------------------- @@ -24,13 +31,20 @@ private: int totalEntries; int newEntries; public: +#ifdef UND_Debug + int objID; +#endif cMenuRecordingSelectItem(cRecording *Recording, int Level); ~cMenuRecordingSelectItem(void); +#if VDRVERSNUM >= 10315 + virtual int compare(const cListObject &ListObject) const; +#else virtual bool operator< (const cListObject &ListObject); +#endif void IncrementCounter(bool New); void RefreshCounter(void); const char *FileName(void) { return filename; } - char *DirName(void); + char *DirName(bool Parent = false); const char *Name(void) { return name; } bool IsDirectory(void) { return isdir; } }; @@ -41,14 +55,23 @@ class cMenuRecordingSelect : public cOsdMenu { private: char *base; int level; + bool top_line[2]; + bool bottom_line[2]; + + bool IsMenuRecordingSelectItem(cOsdItem *Item); + bool IsDirectory(cOsdItem *Item); + bool IsRecording(cOsdItem *Item); + bool IsReady(void); + cRecording *GetRecording(cOsdItem *Item); + void AddFunctionLines(void); + void DelFunctionLines(void); void SetHelpKeys(void); - cRecording *GetRecording(cMenuRecordingSelectItem *Item); - eOSState Open(bool OpenSubMenus = false); - eOSState UnDelete(void); - eOSState Delete(void); - eOSState Summary(void); + eOSState FunctionCall(int FunctionNumber); public: - cMenuRecordingSelect(const char *Base = NULL, int Level = 0, bool OpenSubMenus = false); +#ifdef UND_Debug + int objID; +#endif + cMenuRecordingSelect(const char *Base = NULL, int Level = 0); ~cMenuRecordingSelect(void); virtual eOSState ProcessKey(eKeys Key); }; @@ -57,7 +80,11 @@ public: class cMenuUndelete : public cOsdMenu { private: + void FillMenu(void); public: +#ifdef UND_Debug + int objID; +#endif cMenuUndelete(void); ~cMenuUndelete(void); virtual eOSState ProcessKey(eKeys Key); @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: undelete.c 0.3 2005/10/04 14:35:20 hflor Exp $ + * $Id: undelete.c 0.5 2005/11/17 21:05:05 hflor Exp $ */ #include "undelete.h" @@ -14,8 +14,9 @@ #include <getopt.h> #include <ctype.h> #include <vdr/recording.h> +#include <vdr/videodir.h> -static const char *VERSION = "0.0.3"; +static const char *VERSION = "0.0.5"; static const char *DESCRIPTION = "undelete for recordings"; // Global variables that control the overall behaviour: @@ -23,15 +24,37 @@ static const char *DESCRIPTION = "undelete for recordings"; // var pos2 tParamFile undeleteconfigfile = { false, false, false, "undelete.conf", "undelete.conf" }; tParamInt commandline_preference = { false, false, false, true }; -tParamInt confirmdel = { false, false, false, true }; -tParamInt confirmdeldir = { false, false, false, true }; -tParamInt confirmundel = { false, false, false, true }; -tParamInt confirmundeldir = { false, false, false, true }; -tParamFile mainmenu_name = { false, false, false, "Undelete recordings" }; +tParamInt confirmpurge = { false, false, false, true }; +tParamInt confirmpurgedir = { false, false, false, true }; +tParamInt confirmpurgeall = { false, false, false, true }; +tParamInt confirmsalvage = { false, false, false, true }; +tParamInt confirmsalvagedir = { false, false, false, true }; +tParamInt confirmsalvageall = { false, false, false, true }; +tParamInt firstsalvage = { false, false, false, true }; +tParamInt functionkey[MaxFunctionName] = { + { false, false, false }, + { false, false, false }, + { false, false, false, 5 }, + { false, false, false, 3 }, + { false, false, false, 0 }, + { false, false, false, 0 }, + { false, false, false, 1 }, + { false, false, false, 7 }, + { false, false, false, 0 }, + { false, false, false, 0 }, + { false, false, false, 9 }}; +tParamFile mainmenu_name = { false, false, false }; tParamInt mainmenu_visible = { false, false, false, false }; +tParamInt okkey = { false, false, false, 1 }; +tParamInt numkey = { false, false, false, 0 }; +tParamInt functionline_b_e[2] ={{ false, false, false, false }, + { false, false, false, false }}; +tParamInt functionline_num[2] ={{ false, false, false, 14 }, + { false, false, false, 14 }}; tParamInt verbose = { false, false, false, false, true }; char plugin_name[MaxFileName] = "Undelete"; +cPlugin *plugin = NULL; bool PurgeRecording = false; bool SalvageRecording = false; #if VDRVERSNUM >= 10311 @@ -39,41 +62,89 @@ cRecordings DeletedRecordings(true); #else cRecordings DeletedRecordings; #endif +bool MenuIsOpen = false; +char *SVDRP_Process = NULL; char *WorkFilename = NULL; +time_t NextRemoveThreadStart = 0; +int KeyState = 0; + +const char *FunctionLine[4]; +const char *FunctionName[MaxFunctionName]; +const char *FunctionHotKey[MaxFunctionName]; +const char *KeysName[MaxKeysName]; + +cRemoveThread oRemoveThread; + +#ifdef UND_Debug +int cMenuRecordingSelectItem_nextID = 0; +int cMenuRecordingSelect_nextID = 0; +int cMenuUndelete_nextID = 0; +int cMenuSetupUndelete_nextID = 0; +int cMenuDispKey_nextID = 0; +#endif void DisplaySetings(void) { #define WriteSource(T) plugin_name, T.r ? 'r' : ' ', T.c ? 'c' : ' ' #define IsDefault(T) WriteSource(T), T.u == T.d ? '*' : ' ' + #define IsDefaultS(T) T.r ? 'r' : ' ', T.c ? 'c' : ' ', T.u == T.d ? '*' : ' ' #define IsDefaultFile(T) WriteSource(T), strcmp(T.u, T.d) ? ' ' : '*' #define BoolValue(T) IsDefault(T), T.u ? "yes" : "no" // var pos3 if (verbose.u) { - isyslog("%s: commandline_preference = [ %c%c%c ] %s", BoolValue(commandline_preference)); - isyslog("%s: mainmenu_visible = [ %c%c%c ] %s", BoolValue(mainmenu_visible)); + isyslog("%s: commandline_preference = [ %c%c%c ] %s", BoolValue(commandline_preference)); + isyslog("%s: mainmenu_visible = [ %c%c%c ] %s", BoolValue(mainmenu_visible)); if (mainmenu_visible.u) - isyslog("%s: mainmenu_name = [ %c%c%c ] %s", IsDefaultFile(mainmenu_name), mainmenu_name.u); - isyslog("%s: confirm undelete = [ %c%c%c ] %s", BoolValue(confirmundel)); - isyslog("%s: confirm undelete directory = [ %c%c%c ] %s", BoolValue(confirmundeldir)); - isyslog("%s: confirm delete = [ %c%c%c ] %s", BoolValue(confirmdel)); - isyslog("%s: confirm delete directory = [ %c%c%c ] %s", BoolValue(confirmdeldir)); - isyslog("%s: verbose = [ %c%c%c ] %s", BoolValue(verbose)); + isyslog("%s: mainmenu_name = [ %c%c%c ] %s", IsDefaultFile(mainmenu_name), mainmenu_name.u); + isyslog("%s: confirm purge = [ %c%c%c ] %s", BoolValue(confirmpurge)); + isyslog("%s: confirm purge directory = [ %c%c%c ] %s", BoolValue(confirmpurgedir)); + isyslog("%s: confirm purge all = [ %c%c%c ] %s", BoolValue(confirmpurgeall)); + isyslog("%s: confirm salvage = [ %c%c%c ] %s", BoolValue(confirmsalvage)); + isyslog("%s: confirm salvage directory = [ %c%c%c ] %s", BoolValue(confirmsalvagedir)); + isyslog("%s: confirm salvage all = [ %c%c%c ] %s", BoolValue(confirmsalvageall)); + isyslog("%s: purge lines in list = [ %c%c%c ] %s", IsDefault(functionline_b_e[0]), FunctionLine[functionline_b_e[0].u]); + if (functionline_b_e[0].u == 0x3) + isyslog("%s: num entry for display = [ %c%c%c ] %d", IsDefault(functionline_num[0]), functionline_num[0].u); + isyslog("%s: salvage lines in list = [ %c%c%c ] %s", IsDefault(functionline_b_e[1]), FunctionLine[functionline_b_e[1].u]); + if (functionline_b_e[1].u == 0x3) + isyslog("%s: num entry for display = [ %c%c%c ] %d", IsDefault(functionline_num[1]), functionline_num[1].u); + if ((functionline_b_e[0].u & functionline_b_e[1].u & 0x1) != 0x0 || (functionline_b_e[0].u & functionline_b_e[1].u & 0x2) != 0x0) + isyslog("%s: inward lines = [ %c%c%c ] %s", IsDefault(firstsalvage), firstsalvage.u ? tr("Choise$salvage") : tr("Choise$purge")); + for (int i = 2; i < MaxFunctionName; i++) + isyslog("%s: key for %-20s = [ %c%c%c ] %s", plugin_name, FunctionName[i], IsDefaultS(functionkey[i]), KeysName[functionkey[i].u]); + isyslog("%s: spec. function for OK-key = [ %c%c%c ] %s", IsDefault(okkey), FunctionName[okkey.u]); + isyslog("%s: spec. function for numerics = [ %c%c%c ] %s", IsDefault(numkey), FunctionName[numkey.u]); + isyslog("%s: verbose = [ %c%c%c ] %s", BoolValue(verbose)); } #ifdef UND_Debug1 if (!verbose.u) { - dsyslog("%s: commandline_preference = [ %c%c%c ] %s", BoolValue(commandline_preference)); - dsyslog("%s: mainmenu_visible = [ %c%c%c ] %s", BoolValue(mainmenu_visible)); + dsyslog("%s: commandline_preference = [ %c%c%c ] %s", BoolValue(commandline_preference)); + dsyslog("%s: mainmenu_visible = [ %c%c%c ] %s", BoolValue(mainmenu_visible)); if (mainmenu_visible.u) - dsyslog("%s: mainmenu_name = [ %c%c%c ] %s", IsDefaultFile(mainmenu_name), mainmenu_name.u); - dsyslog("%s: confirm undelete = [ %c%c%c ] %s", BoolValue(confirmundel)); - dsyslog("%s: confirm undelete directory = [ %c%c%c ] %s", BoolValue(confirmundeldir)); - dsyslog("%s: confirm delete = [ %c%c%c ] %s", BoolValue(confirmdel)); - dsyslog("%s: confirm delete directory = [ %c%c%c ] %s", BoolValue(confirmdeldir)); - dsyslog("%s: verbose = [ %c%c%c ] %s", BoolValue(verbose)); + dsyslog("%s: mainmenu_name = [ %c%c%c ] %s", IsDefaultFile(mainmenu_name), mainmenu_name.u); + dsyslog("%s: confirm purge = [ %c%c%c ] %s", BoolValue(confirmpurge)); + dsyslog("%s: confirm purge directory = [ %c%c%c ] %s", BoolValue(confirmpurgedir)); + dsyslog("%s: confirm purge all = [ %c%c%c ] %s", BoolValue(confirmpurgeall)); + dsyslog("%s: confirm salvage = [ %c%c%c ] %s", BoolValue(confirmsalvage)); + dsyslog("%s: confirm salvage directory = [ %c%c%c ] %s", BoolValue(confirmsalvagedir)); + dsyslog("%s: confirm salvage all = [ %c%c%c ] %s", BoolValue(confirmsalvageall)); + dsyslog("%s: purge lines in list = [ %c%c%c ] %s", IsDefault(functionline_b_e[0]), FunctionLine[functionline_b_e[0].u]); + if (functionline_b_e[0].u == 0x3) + dsyslog("%s: num entry for display = [ %c%c%c ] %d", IsDefault(functionline_num[0]), functionline_num[0].u); + dsyslog("%s: salvage lines in list = [ %c%c%c ] %s", IsDefault(functionline_b_e[1]), FunctionLine[functionline_b_e[1].u]); + if (functionline_b_e[1].u == 0x3) + dsyslog("%s: num entry for display = [ %c%c%c ] %d", IsDefault(functionline_num[1]), functionline_num[1].u); + if ((functionline_b_e[0].u & functionline_b_e[1].u & 0x1) != 0x0 || (functionline_b_e[0].u & functionline_b_e[1].u & 0x2) != 0x0) + dsyslog("%s: inward lines = [ %c%c%c ] %s", IsDefault(firstsalvage), firstsalvage.u ? tr("Choise$salvage") : tr("Choise$purge")); + for (int i = 2; i < MaxFunctionName; i++) + dsyslog("%s: key for %-20s = [ %c%c%c ] %s", plugin_name, FunctionName[i], IsDefaultS(functionkey[i]), KeysName[functionkey[i].u]); + dsyslog("%s: spec. function for OK-key = [ %c%c%c ] %s", IsDefault(okkey), FunctionName[okkey.u]); + dsyslog("%s: spec. function for numerics = [ %c%c%c ] %s", IsDefault(numkey), FunctionName[numkey.u]); + dsyslog("%s: verbose = [ %c%c%c ] %s", BoolValue(verbose)); } #endif @@ -85,9 +156,7 @@ void DisplaySetings(void) void ExpandEnvironment(tParamFile *FileStruc) { -#ifdef UND_Debug2 - dsyslog("%s: ExpandEnvironment text=%s", plugin_name, FileStruc->u); -#endif + d2syslogi("ExpandEnvironment", "text=%s", FileStruc->u); char *s; char *p; strn0cpy(FileStruc->e, FileStruc->u, sizeof(FileStruc->e)); @@ -106,7 +175,7 @@ void ExpandEnvironment(tParamFile *FileStruc) char *buffer = NULL; asprintf(&buffer, "%s%s%s", FileStruc->e, e, p); strn0cpy(FileStruc->e, buffer, sizeof(FileStruc->e)); - FREENULL(buffer); + freenull(buffer); } else { esyslog("%s: environmentvariable '%s' not found path=%s", plugin_name, s, FileStruc->u); @@ -120,46 +189,143 @@ void ExpandEnvironment(tParamFile *FileStruc) } while ((p = strstr(FileStruc->e, "//"))) strcpy(p, p + 1); -#ifdef UND_Debug2 - dsyslog("%s: ExpandEnvironment return=%s", plugin_name, FileStruc->e); -#endif + d2syslogi("ExpandEnvironment", "return=%s", FileStruc->e); } // --- cPluginUndelete ---------------------------------------------------------- +class cPluginUndelete : public cPlugin { +private: + // Add any member variables or functions you may need here. + int OSDLanguage; + void TestAndSetOSDLanguage(void); + bool ProcessArg(int argc, char *argv[]); +#ifdef UND_Debug + int objID; +#endif + +public: + cPluginUndelete(void); + virtual ~cPluginUndelete(); + virtual const char *Version(void) { return VERSION; } + virtual const char *Description(void) { return tr(DESCRIPTION); } + virtual const char *CommandLineHelp(void); + virtual bool ProcessArgs(int argc, char *argv[]); + virtual bool Start(void); + virtual void Housekeeping(void); + + virtual const char *MainMenuEntry(void) { return (mainmenu_visible.u) ? mainmenu_name.u : NULL; } + virtual cOsdObject *MainMenuAction(void) { TestAndSetOSDLanguage(); return new cMenuUndelete; } + + virtual cMenuSetupPage *SetupMenu(void) { TestAndSetOSDLanguage(); return new cMenuSetupUndelete; } + virtual bool SetupParse(const char *Name, const char *Value); + +#ifdef HAVE_SVDRP + virtual const char **SVDRPHelpPages(void); + virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode); +#endif + }; + cPluginUndelete::cPluginUndelete(void) { -#ifdef UND_Debug1 - dsyslog("%s: cPluginUndelete::cPluginUndelete", plugin_name); +#ifdef UND_Debug + objID = 1; + d2syslog("cPluginUndelete::cPluginUndelete", "%s", ""); #endif // Initialize any member variables here. // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT! + plugin = this; } cPluginUndelete::~cPluginUndelete() { -#ifdef UND_Debug1 - dsyslog("%s: cPluginUndelete::~cPluginUndelete", plugin_name); -#endif + d2syslog("cPluginUndelete::~cPluginUndelete", "%s", ""); + plugin = NULL; + freenull(SVDRP_Process); + freenull(WorkFilename); // Clean up after yourself! } +void cPluginUndelete::TestAndSetOSDLanguage(void) +{ + d2syslog("cPluginUndelete::TestAndSetOSDLanguage", "OSDLanguage=%d", Setup.OSDLanguage); + if (OSDLanguage != Setup.OSDLanguage) { + OSDLanguage = Setup.OSDLanguage; + FunctionLine[0] = tr("Choise$none"); + FunctionLine[1] = tr("Choise$top"); + FunctionLine[2] = tr("Choise$bottom"); + FunctionLine[3] = tr("Choise$top and bottom"); + FunctionName[0] = tr("Choise$none"); + FunctionName[1] = tr("Choise$open/summary"); + FunctionName[2] = tr("Choise$purge"); + FunctionName[3] = tr("Choise$salvage"); + FunctionName[4] = tr("Choise$purge all"); + FunctionName[5] = tr("Choise$salvage all"); + FunctionName[6] = tr("Choise$open"); + FunctionName[7] = tr("Choise$summary"); + FunctionName[8] = tr("Choise$switch hotkeys to 1"); + FunctionName[9] = tr("Choise$switch hotkeys to 2"); + FunctionName[10] = tr("Choise$Display keys"); + FunctionHotKey[2] = tr("Display$purge"); + FunctionHotKey[3] = tr("Display$salvage"); + FunctionHotKey[4] = tr("Display$purge all"); + FunctionHotKey[5] = tr("Display$salvage all"); + FunctionHotKey[6] = tr("Open"); + FunctionHotKey[7] = tr("Summary"); + FunctionHotKey[8] = tr("Display$<--1"); + FunctionHotKey[9] = tr("Display$2-->"); + FunctionHotKey[10] = tr("Display$disp. keys"); + KeysName[0] = tr("Choise$none"); + KeysName[1] = tr("Choise$Red (1)"); + KeysName[2] = tr("Choise$Red (2)"); + KeysName[3] = tr("Choise$Green (1)"); + KeysName[4] = tr("Choise$Green (2)"); + KeysName[5] = tr("Choise$Yellow (1)"); + KeysName[6] = tr("Choise$Yellow (2)"); + KeysName[7] = tr("Choise$Blue (1)"); + KeysName[8] = tr("Choise$Blue (2)"); + KeysName[9] = "0"; + KeysName[10] = "1"; + KeysName[11] = "2"; + KeysName[12] = "3"; + KeysName[13] = "4"; + KeysName[14] = "5"; + KeysName[15] = "6"; + KeysName[16] = "7"; + KeysName[17] = "8"; + KeysName[18] = "9"; + KeysName[19] = tr("Choise$User1"); + KeysName[20] = tr("Choise$User2"); + KeysName[21] = tr("Choise$User3"); + KeysName[22] = tr("Choise$User4"); + KeysName[23] = tr("Choise$User5"); + KeysName[24] = tr("Choise$User6"); + KeysName[25] = tr("Choise$User7"); + KeysName[26] = tr("Choise$User8"); + KeysName[27] = tr("Choise$User9"); + } +} + bool cPluginUndelete::ProcessArg(int argc, char *argv[]) { int c; static struct option long_options[] = { - { "confirm_del_rec", no_argument, NULL, 'c' }, - { "not_confirm_del_rec", no_argument, NULL, 'C' }, - { "confirm_del_dir", no_argument, NULL, 'd' }, - { "not_confirm_del_dir", no_argument, NULL, 'D' }, + { "confirm_purge_rec", no_argument, NULL, 'c' }, + { "not_confirm_purge_rec", no_argument, NULL, 'C' }, + { "confirm_purge_dir", no_argument, NULL, 'd' }, + { "not_confirm_purge_dir", no_argument, NULL, 'D' }, + { "confirm_purge_all", no_argument, NULL, 'e' }, + { "not_confirm_purge_all", no_argument, NULL, 'E' }, { "visible_in_mainmenu", no_argument, NULL, 'm' }, { "hide_in_mainmenu", no_argument, NULL, 'M' }, { "mainmenu_name", required_argument, NULL, 'n' }, - { "confirm_undel_rec", no_argument, NULL, 's' }, - { "not_confirm_undel_rec", no_argument, NULL, 'S' }, - { "confirm_undel_dir", no_argument, NULL, 't' }, - { "not_confirm_undel_dir", no_argument, NULL, 'T' }, + { "confirm_salvage_rec", no_argument, NULL, 's' }, + { "not_confirm_salvage_rec", no_argument, NULL, 'S' }, + { "confirm_salvage_dir", no_argument, NULL, 't' }, + { "not_confirm_salvage_dir", no_argument, NULL, 'T' }, + { "confirm_salvage_all", no_argument, NULL, 'u' }, + { "not_confirm_salvage_all", no_argument, NULL, 'U' }, { "verbose", no_argument, NULL, 'v' }, { "noverbose", no_argument, NULL, 'V' }, { "nosetup_commandline", no_argument, NULL, 1 }, @@ -183,13 +349,17 @@ bool cPluginUndelete::ProcessArg(int argc, char *argv[]) { case 1: commandline_preference.h = true; break; - case 'c': Setvalue(confirmdel) = true; + case 'c': Setvalue(confirmpurge) = true; + break; + case 'C': Setvalue(confirmpurge) = false; break; - case 'C': Setvalue(confirmdel) = false; + case 'd': Setvalue(confirmpurgedir) = true; break; - case 'd': Setvalue(confirmdeldir) = true; + case 'D': Setvalue(confirmpurgedir) = false; break; - case 'D': Setvalue(confirmdeldir) = false; + case 'e': Setvalue(confirmpurgeall) = true; + break; + case 'E': Setvalue(confirmpurgeall) = false; break; case 'm': Setvalue(mainmenu_visible) = true; break; @@ -198,13 +368,17 @@ bool cPluginUndelete::ProcessArg(int argc, char *argv[]) case 'n': SetvalueFile(mainmenu_name); Setvalue(mainmenu_visible) = true; break; - case 's': Setvalue(confirmundel) = true; + case 's': Setvalue(confirmsalvage) = true; + break; + case 'S': Setvalue(confirmsalvage) = false; + break; + case 't': Setvalue(confirmsalvagedir) = true; break; - case 'S': Setvalue(confirmundel) = false; + case 'T': Setvalue(confirmsalvagedir) = false; break; - case 't': Setvalue(confirmundeldir) = true; + case 'u': Setvalue(confirmsalvageall) = true; break; - case 'T': Setvalue(confirmundeldir) = false; + case 'U': Setvalue(confirmsalvageall) = false; break; case 'v': Setvalue(verbose) = true; break; @@ -225,62 +399,60 @@ bool cPluginUndelete::ProcessArg(int argc, char *argv[]) return optind >= argc; } -const char *cPluginUndelete::Version(void) -{ - return VERSION; -} - -const char *cPluginUndelete::Description(void) -{ - return tr(DESCRIPTION); -} - const char *cPluginUndelete::CommandLineHelp(void) { // Return a string that describes all known command line options. column 80 --> | - return tr(" -m --visible_in_mainmenu Show the plugin in the mainmenu\n" - " -M --hide_in_mainmenu Hide the plugin in the mainmenu\n" - " You can start the Plugin in the setupmenu\n" - " -n Name --mainmenu_name=Name Select Name for entry in the mainmenu\n" - " (set also -m)\n" - " -c --confirm_del_rec show confirmation for delete recording\n" - " -C --not_confirm_del_rec delete recording without confirmation\n" - " -d --confirm_del_dir show confirmation for delete directory\n" - " -D --not_confirm_del_dir delete directory without confirmation\n" - " -s --confirm_undel_rec show confirmation for undelete recording\n" - " -S --not_confirm_undel_rec undelete recording without confirmation\n" - " -t --confirm_undel_dir show confirmation for undelete directory\n" - " -T --not_confirm_undel_dir undelete directory without confirmation\n" - " -v --verbose Enable more logging\n" - " -V --noverbose Disable more loggig\n" - " --nosetup_commandline Hide the 'Preferr Command Line Parameter'\n" - " form setup-menu\n" - " @config-file Read also parameters from this file" + return tr(" -m --visible_in_mainmenu Show the plugin in the mainmenu\n" + " -M --hide_in_mainmenu Hide the plugin in the mainmenu\n" + " You can start the Plugin in the setupmenu\n" + " -n Name --mainmenu_name=Name Select Name for entry in the mainmenu\n" + " (set also -m)\n" + " -c --confirm_purge_rec show confirmation for purge recording\n" + " -C --not_confirm_purge_rec purge recording without confirmation\n" + " -d --confirm_purge_dir show confirmation for purge directory\n" + " -D --not_confirm_purge_dir purge directory without confirmation\n" + " -e --confirm_purge_all show confirmation for purge all function\n" + " -E --not_confirm_purge_all purge all function without confirmation\n" + " -s --confirm_salvage_rec show confirmation for salvage recording\n" + " -S --not_confirm_salvage_rec salvage recording without confirmation\n" + " -t --confirm_salvage_dir show confirmation for salvage directory\n" + " -T --not_confirm_salvage_dir salvage directory without confirmation\n" + " -u --confirm_salvage_all show confirmation for salvage all function\n" + " -U --not_confirm_salvage_all salvage all function without confirmation\n" + " -v --verbose Enable more logging\n" + " -V --noverbose Disable more loggig\n" + " --nosetup_commandline Hide the 'Preferr Command Line Parameter'\n" + " form setup-menu\n" + " @config-file Read also parameters from this file" "\n" " note: recording means deleted recordings (there not show in VDR)"); /* only for translation: - " -m --visible_in_mainmenu Plugin wird im Hautmenü angezeigt\n" - " -M --hide_in_mainmenu kein Eintrag im Hauptmenü für das Plugin\n" - " es kann über das Setup-Menü gestartet werden\n" - " -n Name --mainmenu_name=Name Name für den Eintrag im Hauptmenü\n" - " (diese Option setzt auch -m)\n" - " -c --confirm_del_rec Bestätigung für das Löschen von Aufnahmen\n" - " -C --not_confirm_del_rec keine Bestätigung (löschen Aufnahmen)\n" - " -d --confirm_del_dir Bestätigung beim Löschen von Verzeichnissen\n" - " -D --not_confirm_del_dir keine Bestätigung (löschen Verzeichnissen)\n" - " -s --confirm_undel_rec Bestätigung Wiederherstellung von Aufnahmen\n" - " -S --not_confirm_undel_rec keine Best. Wiederherstellung von Aufnahmen\n" - " -t --confirm_undel_dir Bestätigung Wiederherstellung von Verzei.\n" - " -T --not_confirm_undel_dir keine Best. Wiederherstellung von Verzei.\n" - " -v --verbose erweiterte Protokollierung aktivieren\n" - " -V --noverbose keine erweiterte Protokollierung\n" - " --nosetup_commandline Option 'Kommandozeile hat Vorrang'\n" - " im Setup-Menü verbergen\n" - " @config-file Komandozeilenoptionen auch aus der angegebenen\n" - " Datei lesen\n" - "\n" - " Hinweis: Mit Aufnahmen sind hier die gelöschten Aufnahmen gemeint" + " -m --visible_in_mainmenu Plugin wird im Hautmenü angezeigt\n" + " -M --hide_in_mainmenu kein Eintrag im Hauptmenü für das Plugin\n" + " es kann über das Setup-Menü gestartet werden\n" + " -n Name --mainmenu_name=Name Name für den Eintrag im Hauptmenü\n" + " (diese Option setzt auch -m)\n" + " -c --confirm_purge_rec Bestätigung für das Löschen von Aufnahmen\n" + " -C --not_confirm_purge_rec keine Bestätigung (löschen Aufnahmen)\n" + " -d --confirm_purge_dir Bestätigung beim Löschen von Verzeichnissen\n" + " -D --not_confirm_purge_dir keine Bestätigung (löschen Verzeichnissen)\n" + " -e --confirm_purge_all Bestätigung beim "alles Löschen"\n" + " -E --not_confirm_purge_all "alles Löschen" ohne Bestätigung\n" + " -s --confirm_salvage_rec Bestätigung Wiederherstellung von Aufnahmen\n" + " -S --not_confirm_salvage_rec keine Best. Wiederherstellung von Aufnahmen\n" + " -t --confirm_salvage_dir Bestätigung Wiederherstellung von Verzei.\n" + " -T --not_confirm_salvage_dir keine Best. Wiederherstellung von Verzei.\n" + " -u --confirm_salvage_all Bestätigung beim "alles Wiederherstellen"\n" + " -U --not_confirm_salvage_all "alles Wiederherstellen" ohne Bestätigung\n" + " -v --verbose erweiterte Protokollierung aktivieren\n" + " -V --noverbose keine erweiterte Protokollierung\n" + " --nosetup_commandline Option 'Kommandozeile hat Vorrang'\n" + " im Setup-Menü verbergen\n" + " @config-file Komandozeilenoptionen auch aus der angegebenen\n" + " Datei lesen\n" + "\n" + " Hinweis: Mit Aufnahmen sind hier die gelöschten Aufnahmen gemeint" */ // free: a b e f g h i j k l o p q r u w x y z } @@ -295,46 +467,40 @@ bool cPluginUndelete::Start(void) { // Start any background activities the plugin shall perform. RegisterI18n(Phrases); + TestAndSetOSDLanguage(); -#ifdef UND_Debug1 - dsyslog("%s: cPluginUndelete::Start undeleteconfigfile=%s", plugin_name, undeleteconfigfile.u); -#endif + d1syslog("cPluginUndelete::Start", "undeleteconfigfile=%s", undeleteconfigfile.u); char *p; - char *q = strdup(ConfigDirectory("")); + char *q = strdup(ConfigDirectory()); asprintf(&p, "%s%s%s", q, *(q + strlen(q) - 1) == '/' ? "" : "/", undeleteconfigfile.u); if (!access(undeleteconfigfile.u, F_OK) && !access(undeleteconfigfile.u, R_OK) || !access(p, F_OK) && !access(p, R_OK)) { #define MAXARGS 100 int fargc = 1; char *fargv[MAXARGS]; - char buffer[MAXPARSEBUFFER]; + cReadLine ReadLine; bool done; FILE *f; if (!access(undeleteconfigfile.u, F_OK)) { f = fopen(undeleteconfigfile.u, "r"); -#ifdef UND_Debug1 - dsyslog("%s: cPluginUndelete::Start open undeleteconfigfile=%s", plugin_name, undeleteconfigfile.u); -#endif + d1syslog("cPluginUndelete::Start", "open undeleteconfigfile=%s", undeleteconfigfile.u); } else { f = fopen(p, "r"); -#ifdef UND_Debug1 - dsyslog("%s: cPluginUndelete::Start open undeleteconfigfile=%s", plugin_name, p); -#endif + d1syslog("cPluginUndelete::Start", "open undeleteconfigfile=%s", p); } free(p); free(q); if (!f) { - esyslog("%s: ERROR: cannot open config file: [%s]%s", plugin_name, ConfigDirectory(""), undeleteconfigfile.u); + esyslog("%s: ERROR: cannot open config file: [%s]%s", plugin_name, ConfigDirectory(), undeleteconfigfile.u); return false; } - while (fgets(buffer, sizeof(buffer), f) > 0) + while ((p = compactspace(ReadLine.Read(f))) != NULL) { - p = skipspace(stripspace(buffer)); q = NULL; done = false; while (!done) @@ -386,7 +552,7 @@ bool cPluginUndelete::Start(void) if (fargc > 1) if (!ProcessArg(fargc, fargv)) { - esyslog("%s: ERROR: cannot parse config file: [%s]%s", plugin_name, ConfigDirectory(""), undeleteconfigfile.u); + esyslog("%s: ERROR: cannot parse config file: [%s]%s", plugin_name, ConfigDirectory(), undeleteconfigfile.u); return false; } while(fargc) free(fargv[--fargc]); @@ -396,10 +562,10 @@ bool cPluginUndelete::Start(void) free(q); if (strcmp(undeleteconfigfile.u, undeleteconfigfile.d)) { - esyslog("%s: ERROR: config file not found: [%s]%s", plugin_name, ConfigDirectory(""), undeleteconfigfile.u); + esyslog("%s: ERROR: config file not found: [%s]%s", plugin_name, ConfigDirectory(), undeleteconfigfile.u); return false; } else if (verbose.u) - isyslog("%s: INFO: config file not found: [%s]%s", plugin_name, ConfigDirectory(""), undeleteconfigfile.u); + isyslog("%s: INFO: config file not found: [%s]%s", plugin_name, ConfigDirectory(), undeleteconfigfile.u); } strn0cpy(mainmenu_name.d, tr("Menu$Undelete recordings"), sizeof(mainmenu_name.d)); @@ -417,12 +583,24 @@ bool cPluginUndelete::Start(void) // var pos5 SetParamFile (undeleteconfigfile); - SetParam (confirmdel); - SetParam (confirmdeldir); - SetParam (confirmundel); - SetParam (confirmundeldir); + SetParam (confirmpurge); + SetParam (confirmpurgedir); + SetParam (confirmpurgeall); + SetParam (confirmsalvage); + SetParam (confirmsalvagedir); + SetParam (confirmsalvageall); + SetParam (firstsalvage); + for (int i = 2; i < MaxFunctionName; i++) + SetParam (functionkey[i]); SetParamFile (mainmenu_name); SetParam (mainmenu_visible); + SetParam (numkey); + SetParam (okkey); + for (int i = 0; i < 2; i++) + { + SetParam (functionline_b_e[i]); + SetParam (functionline_num[i]); + } SetParam (verbose); #undef SetParam @@ -434,52 +612,443 @@ bool cPluginUndelete::Start(void) return true; } -const char *cPluginUndelete::MainMenuEntry(void) -{ - return mainmenu_visible.u ? mainmenu_name.u : NULL; -} - -cOsdObject *cPluginUndelete::MainMenuAction(void) +void cPluginUndelete::Housekeeping(void) { -#ifdef UND_Debug1 - dsyslog("%s: cPluginUndelete::MainMenuAction", plugin_name); -#endif - return new cMenuUndelete; -} - -cMenuSetupPage *cPluginUndelete::SetupMenu(void) -{ -#ifdef UND_Debug1 - dsyslog("%s: cPluginUndelete::SetupMenu", plugin_name); -#endif - return new cMenuSetupUndelete; + d2syslog("cPluginUndelete::Housekeeping", "NextRemoveThreadStart=%d (%d)", (int)NextRemoveThreadStart, (int)(NextRemoveThreadStart > 0 ? NextRemoveThreadStart - time(NULL) : 0)); + if (NextRemoveThreadStart > 0 && NextRemoveThreadStart <= time(NULL)) + { + if (oRemoveThread.ActiveWithCancel()) + oRemoveThread.Start(); + NextRemoveThreadStart = 0; + } } - bool cPluginUndelete::SetupParse(const char *Name, const char *Value) { #define SetParam(T) { T.r = true; T.s = strtol(Value, NULL, 0); } - #define SetParamFile(T) { T.r = true; strn0cpy(T.s, Value, sizeof(T.s)); } + #define SetParamChar(T) { T.r = true; strn0cpy(T.s, Value, sizeof(T.s)); } // Parse your own setup parameters and store their values. dsyslog("%s: Setupparameter %s=%s", plugin_name, Name, Value); // var pos6 - - if (!strcasecmp(Name, "commandline")) SetParam (commandline_preference) - else if (!strcasecmp(Name, "confdel")) SetParam (confirmdel) - else if (!strcasecmp(Name, "confdeldir")) SetParam (confirmdeldir) - else if (!strcasecmp(Name, "confundel")) SetParam (confirmundel) - else if (!strcasecmp(Name, "confundeldir")) SetParam (confirmundeldir) - else if (!strcasecmp(Name, "name")) SetParamFile (mainmenu_name) - else if (!strcasecmp(Name, "visible")) SetParam (mainmenu_visible) - else if (!strcasecmp(Name, "verbose")) SetParam (verbose) + if (!strcasecmp(Name, "commandline")) SetParam (commandline_preference) + else if (!strcasecmp(Name, "confpurge1")) SetParam (confirmpurge) + else if (!strcasecmp(Name, "confpurge2")) SetParam (confirmpurgedir) + else if (!strcasecmp(Name, "confpurge3")) SetParam (confirmpurgeall) + else if (!strcasecmp(Name, "confsalvage1")) SetParam (confirmsalvage) + else if (!strcasecmp(Name, "confsalvage2")) SetParam (confirmsalvagedir) + else if (!strcasecmp(Name, "confsalvage3")) SetParam (confirmsalvageall) + else if (!strcasecmp(Name, "firstsalvage")) SetParam (firstsalvage) + else if (!strcasecmp(Name, "functionkey02")) SetParam (functionkey[2]) + else if (!strcasecmp(Name, "functionkey03")) SetParam (functionkey[3]) + else if (!strcasecmp(Name, "functionkey04")) SetParam (functionkey[4]) + else if (!strcasecmp(Name, "functionkey05")) SetParam (functionkey[5]) + else if (!strcasecmp(Name, "functionkey06")) SetParam (functionkey[6]) + else if (!strcasecmp(Name, "functionkey07")) SetParam (functionkey[7]) + else if (!strcasecmp(Name, "functionkey08")) SetParam (functionkey[8]) + else if (!strcasecmp(Name, "functionkey09")) SetParam (functionkey[9]) + else if (!strcasecmp(Name, "functionkey10")) SetParam (functionkey[10]) + else if (!strcasecmp(Name, "name")) SetParamChar (mainmenu_name) + else if (!strcasecmp(Name, "visible")) SetParam (mainmenu_visible) + else if (!strcasecmp(Name, "numkey")) SetParam (numkey) + else if (!strcasecmp(Name, "okkey")) SetParam (okkey) + else if (!strcasecmp(Name, "purgebe")) SetParam (functionline_b_e[0]) + else if (!strcasecmp(Name, "purgenum")) SetParam (functionline_num[0]) + else if (!strcasecmp(Name, "salvagebe")) SetParam (functionline_b_e[1]) + else if (!strcasecmp(Name, "salvagenum")) SetParam (functionline_num[1]) + else if (!strcasecmp(Name, "verbose")) SetParam (verbose) else return false; return true; #undef SetParam #undef SetParamChar - #undef SetParamFile +} + +#ifdef HAVE_SVDRP +const char **cPluginUndelete::SVDRPHelpPages(void) +{ + static const char *HelpPages[] = { + "LSTD [ <number> ]\n" + " List deleted recordings. Without option, all deleted recordings are\n" + " listed.\n" + " Otherwise the information for the given deleted recording is listed.", + "SIZED [ -h ]\n" + " Caclulate the size of deleted recordings. Result is in Bytes or\n" + " with option -h in human readable format.", + "RMDIR\n" + " Start remove empty directory in the background", + "PURGE ALL | <number>\n" + " purge the selected deleted recording (number see LSTD)", + "SALVAGE ALL | <number>\n" + " salvage the selected deleted recording (number see LSTD)", + NULL + }; + return HelpPages; +} + +cString cPluginUndelete::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode) +{ +#define CMD(c) (strcasecmp(Command, c) == 0) + + d1syslog("cPluginUndelete::SVDRPCommand", "Command=%s Option=%s ReplyCode=%d MenuIsOpen=%s", Command ? Command : "(NULL)", Option ? Option : "(NULL)", ReplyCode, MenuIsOpen ? "yes" : "no"); + if (MenuIsOpen) + { + ReplyCode = 554; + return "OSD-Menu is currently open"; + } + if CMD("LSTD") + { + ReplyCode = 550; + if (*Option) + { + if (isnumber(Option)) + { + cRecording *recording = DeletedRecordings.Get(atoi(Option) - 1); + if (recording) + { +#if VDRVERSNUM >= 10325 + const char *summary = NULL; + if (recording->Info()) + summary = recording->Info()->Description(); +#else + const char *summary = recording->Summary(); +#endif + if (summary && *summary) + { + ReplyCode = 902; + return summary; + } else + return "no summary availabe"; + } else + return cString::sprintf("deleted recording \"%s\" not found%s", Option, DeletedRecordings.Count() ? "" : " (use LSTD before get summary)"); + } else + { + ReplyCode = 501; + return cString::sprintf("Error in deleted recording number \"%s\"", Option); + } + } else + { + // list deleted recordings +#if VDRVERSNUM >= 10311 + DeletedRecordings.Load(); +#else + DeletedRecordings.Load(true); +#endif + DeletedRecordings.Sort(); + freenull(SVDRP_Process); + char *list = NULL; + for (cRecording *recording = DeletedRecordings.First(); recording; recording = DeletedRecordings.Next(recording)) + { + char *newline; + asprintf(&newline, "%s%d %s\n", list ? list : "", recording->Index() + 1, recording->Title(' ', true, -1)); + freenull(list); + list = newline; + } + if (list) + { + ReplyCode = 901; + return cString(list, true); + } else + return "No deleted recordings available"; + } + } else if CMD("SIZED") + { + long long llsize = 0; + if (DeletedRecordings.Count()) + { + for (cRecording *recording = DeletedRecordings.First(); recording; recording = DeletedRecordings.Next(recording)) + { + char *process = NULL; + if (SVDRP_Process) + { + char *temp; + asprintf(&temp, "#%d#", recording->Index() + 1); + process = strstr(SVDRP_Process, temp); + free(temp); + } + if (!process) + GetVDRSize(recording->FileName(), llsize); + } + } else + { +#if VDRVERSNUM >= 10311 + DeletedRecordings.Load(); +#else + DeletedRecordings.Load(true); +#endif + for (cRecording *recording = DeletedRecordings.First(); recording; recording = DeletedRecordings.Next(recording)) + GetVDRSize(recording->FileName(), llsize); + DeletedRecordings.Clear(); + } + if (*Option) + if (strcasecmp(Option, "-h")) + { + ReplyCode = 501; + return cString::sprintf("Error in parameter \"%s\" (only -h allow)", Option); + } else + { + float llsizetmp = llsize; + const char* strUnit[5] = { tr("Bytes"), "KB", "MB", "GB", "TB" }; + int Unit; + for(Unit = 0; (llsizetmp > 1024) && (Unit < 5); Unit++) + llsizetmp /= 1024; + int decimalplaces = Unit < 2 ? 0 : Unit > 2 ? 2 : 1; + ReplyCode = 904; + return cString::sprintf("size of deleted recordings are %1.*f %s", decimalplaces, llsizetmp, strUnit[Unit]); + } + else + { + ReplyCode = 903; + return cString::sprintf("%lld bytes in deleted recordings", llsize); + } + } else if CMD("RMDIR") + { + NextRemoveThreadStart = 0; + if (oRemoveThread.ActiveWithCancel()) + { + ReplyCode = 554; + return "thread for remove empty directory alredy active"; + } else + { + oRemoveThread.Start(); + ReplyCode = 905; + return "thread for remove empty directory is started"; + } + } else if CMD("PURGE") + { + ReplyCode = 550; + if (*Option) + { + if (isnumber(Option)) + { + int recnumber = atoi(Option); + char *process = NULL; + if (SVDRP_Process) + { + char *temp; + asprintf(&temp, "#%d#", recnumber); + process = strstr(SVDRP_Process, temp); + free(temp); + } + if (process) + return cString::sprintf("deleted recording \"%s\" is already %s", Option, *--process == 'P' ? "purged" : "salvaged"); + else + { + cRecording *recording = DeletedRecordings.Get(recnumber - 1); + if (recording) + { + if (verbose.u) + isyslog("%s: purge deleted recording (%s)", plugin_name, recording->FileName()); + if (!RemoveVideoFile(recording->FileName())) + { + esyslog("%s: Error while remove deleted recording (%s)", plugin_name, recording->FileName()); + return cString::sprintf("error while purge the deleted recording \"%s\" [%s]", Option, recording->Title()); + } + NextRemoveThreadStart = time(NULL) + 600; + char *temp; + asprintf(&temp, "%sP#%d#", SVDRP_Process ? SVDRP_Process : "", recnumber); + freenull(SVDRP_Process); + SVDRP_Process = temp; + ReplyCode = 906; + return cString::sprintf("purge of deleted recording \"%s\" [%s] is successful", Option, recording->Title()); + } else + return cString::sprintf("deleted recording \"%s\" not found%s", Option, DeletedRecordings.Count() ? "" : " (use LSTD before purge)"); + } + } else if (!strcasecmp(Option, "ALL")) + { + if (!DeletedRecordings.Count()) + { +#if VDRVERSNUM >= 10311 + DeletedRecordings.Load(); +#else + DeletedRecordings.Load(true); +#endif + DeletedRecordings.Sort(); + freenull(SVDRP_Process); + if (!DeletedRecordings.Count()) + return "No deleted recordings available"; + } + int replycode = 0; + char *list = NULL; + for (cRecording *recording = DeletedRecordings.First(); recording; recording = DeletedRecordings.Next(recording)) + { + replycode = 0; + cString reply = SVDRPCommand("purge", (const char *)cString::sprintf("%d", recording->Index() + 1), replycode); + if (replycode < 900) + { + char *newline; + asprintf(&newline, "%s%s\n", list ? list : "", (const char *)reply); + freenull(list); + list = newline; + } + } + if (!oRemoveThread.ActiveWithCancel()) + oRemoveThread.Start(); + DeletedRecordings.Clear(); + freenull(SVDRP_Process); +#if VDRVERSNUM >= 10311 + DeletedRecordings.Load(); +#else + DeletedRecordings.Load(true); +#endif + bool recordingsavailable = DeletedRecordings.Count(); + DeletedRecordings.Clear(); + if (recordingsavailable) + return cString::sprintf("%snot all deleted recordings are purged (see lstd)", list ? (const char *)cString(list, true) : ""); + else if (list) + { + ReplyCode = 907; + return cString::sprintf("%swarings while purge deleted recordings", (const char *)cString(list, true)); + } else + { + ReplyCode = 908; + return "all deleted recordings are purged and thread for remove empty directory is started"; + } + } else + { + ReplyCode = 501; + return cString::sprintf("Error in deleted recording number \"%s\"", Option); + } + } else + { + ReplyCode = 501; + return "number of deleted recoding for purge missing"; + } + } else if CMD("SALVAGE") + { + ReplyCode = 550; + if (*Option) + { + if (isnumber(Option)) + { + int recnumber = atoi(Option); + char *process = NULL; + if (SVDRP_Process) + { + char *temp; + asprintf(&temp, "#%d#", recnumber); + process = strstr(SVDRP_Process, temp); + free(temp); + } + if (process) + return cString::sprintf("deleted recording \"%s\" is already %s", Option, *--process == 'P' ? "purged" : "salvaged"); + else + { + cRecording *recording = DeletedRecordings.Get(recnumber - 1); + if (recording) + { + if (verbose.u) + isyslog("%s: undelete recording (%s)", plugin_name, recording->FileName()); + cString NewName = recording->FileName(); + char *ext = strrchr(NewName, '.'); + if (!strcmp(ext, DELEXT)) + { + strncpy(ext, RECEXT, strlen(ext)); + if (!access(NewName, F_OK)) + { + if (verbose.u) + isyslog("%s: Recording with the same name exists (%s)", plugin_name, (const char *)NewName); + return cString::sprintf("recording with the same name exists \"%s\" [%s]", Option, recording->Title()); + } else + { + if (!RenameVideoFile(recording->FileName(), (const char *)NewName)) + { + esyslog("%s: Error while rename deleted recording (%s) to (%s)", plugin_name, recording->FileName(), (const char *)NewName); + return cString::sprintf("error while rename deleted recording \"%s\" [%s]", Option, recording->Title()); + } + } + } + char *temp; + asprintf(&temp, "%sS#%d#", SVDRP_Process ? SVDRP_Process : "", recnumber); + freenull(SVDRP_Process); + SVDRP_Process = temp; + ReplyCode = 909; + return cString::sprintf("salvage of deleted recording \"%s\" [%s] is successful", Option, recording->Title()); + } else + return cString::sprintf("deleted recording \"%s\" not found%s", Option, DeletedRecordings.Count() ? "" : " (use LSTD before salvage)"); + } + } else if (!strcasecmp(Option, "ALL")) + { + if (!DeletedRecordings.Count()) + { +#if VDRVERSNUM >= 10311 + DeletedRecordings.Load(); +#else + DeletedRecordings.Load(true); +#endif + DeletedRecordings.Sort(); + freenull(SVDRP_Process); + if (!DeletedRecordings.Count()) + return "No deleted recordings available"; + } + int replycode = 0; + char *list = NULL; + for (cRecording *recording = DeletedRecordings.First(); recording; recording = DeletedRecordings.Next(recording)) + { + replycode = 0; + cString reply = SVDRPCommand("salvage", (const char *)cString::sprintf("%d", recording->Index() + 1), replycode); + if (replycode < 900) + { + char *newline; + asprintf(&newline, "%s%s\n", list ? list : "", (const char *)reply); + freenull(list); + list = newline; + } + } + DeletedRecordings.Clear(); + freenull(SVDRP_Process); +#if VDRVERSNUM >= 10311 + DeletedRecordings.Load(); +#else + DeletedRecordings.Load(true); +#endif + bool recordingsavailable = DeletedRecordings.Count(); + DeletedRecordings.Clear(); + if (recordingsavailable) + return cString::sprintf("%snot all deleted recordings are salvaged (see lstd)", list ? (const char *)cString(list, true) : ""); + else if (list) + { + ReplyCode = 910; + return cString::sprintf("%swarings while salvage deleted recordings", (const char *)cString(list, true)); + } else + { + ReplyCode = 911; + return "all deleted recordings are salvaged"; + } + } else + { + ReplyCode = 501; + return cString::sprintf("Error in deleted recording number \"%s\"", Option); + } + } else + { + ReplyCode = 501; + return "number of deleted recoding for purge missing"; + } + } + return NULL; +#undef CMD +} +#endif + +void cRemoveThread::Action(void) +{ + d1syslogi("cRemoveThread::Action", "RemoveEmptyVideoDirectories thread started (pid=%d)", getpid()); + RemoveEmptyVideoDirectories(); + d1syslogi("cRemoveThread::Action", "RemoveEmptyVideoDirectories thread ended (pid=%d)", getpid()); +} + +bool cRemoveThread::ActiveWithCancel(void) +{ +#if VDRVERSNUM >= 10318 + return Active(); +#else + if (Active()) + return true; + Cancel(1); // reset the var "running" to restart the thread, fixed in 1.3.18 + return false; +#endif } VDRPLUGINCREATOR(cPluginUndelete); // Don't touch this! @@ -3,33 +3,86 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: undelete.h 0.2 2004/10/10 12:23:20 hflor Exp $ + * $Id: undelete.h 0.5 2005/11/17 21:05:05 hflor Exp $ */ #ifndef __UNDELETE_H #define __UNDELETE_H +#include "vdrtools.h" #include <vdr/config.h> #include <vdr/recording.h> #include <vdr/plugin.h> -#define FREENULL(T) { if (T) { free(T); T = NULL; } } -#if VDRVERSNUM >= 10307 -#define MAXOSDTEXTWIDTH 45 -#define AKTOSDTEXTWIDTH 45 -#define ERROR(E) Skins.Message(mtError, E) -#define INFO(I) Skins.Message(mtInfo, I) -#define STATUS(S) Skins.Message(mtStatus, S) +#define freenull(T) { if (T) { free(T); T = NULL; } } +#if VDRVERSNUM > 10307 + #define MAXOSDTEXTWIDTH 45 + #define AKTOSDTEXTWIDTH 45 + #define ERROR(E) Skins.Message(mtError, E) + #define INFO(I) Skins.Message(mtInfo, I) + #define STATUS(S) Skins.Message(mtStatus, S) +#elif VDRVERSNUM == 10307 + #error "cMenuText is in VDR 1.3.7 not in menu.h" #else -#define MAXOSDTEXTWIDTH MAXOSDWIDTH -#define AKTOSDTEXTWIDTH Setup.OSDwidth -#define ERROR(E) Interface->Error(E) -#define INFO(I) Interface->Info(I) + #define MAXOSDTEXTWIDTH MAXOSDWIDTH + #define AKTOSDTEXTWIDTH Setup.OSDwidth + #define ERROR(E) Interface->Error(E) + #define INFO(I) Interface->Info(I) + #ifdef HAVE_ELCHI + #define STATUS(S) { Interface->Status(S, Setup.Theme == themeVanilla ? clrBlack : (eDvbColor)fginfofont, Setup.Theme == themeVanilla ? clrCyan : clrInfoLine); Interface->Flush(); } + #else + #define STATUS(S) { Interface->Status(S); Interface->Flush(); } + #endif #endif -#define kUnDelRec (kNone + 110) -#define kDelRec (kNone + 111) -#define kHelpKeys (kNone + 112) +#ifdef UND_Debug +extern int cMenuRecordingSelectItem_nextID; +extern int cMenuRecordingSelect_nextID; +extern int cMenuUndelete_nextID; +extern int cMenuSetupUndelete_nextID; +extern int cMenuDispKey_nextID; +#endif + +#ifdef UND_Debug1 + #define d1syslog(p, t, a...) dsyslog("%s: %-50s ID=%05d " t, plugin_name, p, objID, a) + #define d1syslogi(p, t, a...) dsyslog("%s: %-50s " t, plugin_name, p, a) + #define d1listlog(p) for (cOsdItem *item = First(); item; item = Next(item)) \ + d1syslog(p, "Index=%02d Osditem=%s", item->Index() + 1, item->Text()) +#else + #define d1syslog(p, t, a...) {} + #define d1syslogi(p, t, a...) {} + #define d1listlog(p) {} +#endif +#ifdef UND_Debug2 + #define d2syslog(p, t, a...) dsyslog("%s: %-50s ID=%05d " t, plugin_name, p, objID, a) + #define d2syslogi(p, t, a...) dsyslog("%s: %-50s " t, plugin_name, p, a) +#else + #define d2syslog(p, t, a...) {} + #define d2syslogi(p, t, a...) {} +#endif +#ifdef UND_Debug3 + #define d3syslog(p, t, a...) dsyslog("%s: %-50s ID=%05d " t, plugin_name, p, objID, a) + #define d3ProcessKey1(p) bool noneKey = Key == kNone; \ + if (!noneKey) \ + d3syslog(p, "Key=%s", KeyName(Key)) + #define d3ProcessKey2(p) if (!noneKey || (state != osUnknown && state != osContinue)) \ + { \ + d3syslog(p, "OSState=%s", OSStateName(state)); \ + noneKey = false; \ + } + #define d3ProcessKey3(p) if (!noneKey || (state != osUnknown && state != osContinue)) \ + d3syslog(p, "returned OSState=%s", OSStateName(state)) +#else + #define d3syslog(p, t, a...) {} + #define d3ProcessKey1(p) {} + #define d3ProcessKey2(p) {} + #define d3ProcessKey3(p) {} +#endif + +#define kSalvageRec (kNone + 110) +#define kPurgeRec (kNone + 111) +#define kDelLine (kNone + 112) +#define kHelpKeys (kNone + 113) // Global variables that control the overall behaviour: @@ -65,43 +118,48 @@ struct tParamFile { }; // var pos1 - extern tParamInt commandline_preference; -extern tParamInt confirmdel; -extern tParamInt confirmdeldir; -extern tParamInt confirmundel; -extern tParamInt confirmundeldir; +extern tParamInt confirmpurge; +extern tParamInt confirmpurgedir; +extern tParamInt confirmpurgeall; +extern tParamInt confirmsalvage; +extern tParamInt confirmsalvagedir; +extern tParamInt confirmsalvageall; +extern tParamInt firstsalvage; +extern tParamInt functionkey[]; extern tParamFile mainmenu_name; extern tParamInt mainmenu_visible; +extern tParamInt numkey; +extern tParamInt okkey; +extern tParamInt functionline_b_e[]; +extern tParamInt functionline_num[]; extern tParamInt verbose; extern char plugin_name[]; +extern cPlugin *plugin; extern bool PurgeRecording; extern bool SalvageRecording; extern cRecordings DeletedRecordings; +extern bool MenuIsOpen; +extern char *SVDRP_Process; extern char *WorkFilename; +extern int KeyState; +extern const char *FunctionLine[]; +#define MaxFunctionName 11 +extern const char *FunctionName[]; +extern const char *FunctionHotKey[]; +#define MaxKeysName 28 +extern const char *KeysName[]; void ExpandEnvironment(tParamFile *FileStruc); -// --- cPluginUndelete ---------------------------------------------------------- - -class cPluginUndelete : public cPlugin { -private: - // Add any member variables or functions you may need here. - bool ProcessArg(int argc, char *argv[]); - +class cRemoveThread : public cThread { +protected: + virtual void Action(void); public: - cPluginUndelete(void); - virtual ~cPluginUndelete(); - virtual const char *Version(void); - virtual const char *Description(void); - virtual const char *CommandLineHelp(void); - virtual bool ProcessArgs(int argc, char *argv[]); - virtual bool Start(void); - virtual const char *MainMenuEntry(void); - virtual cOsdObject *MainMenuAction(void); - virtual cMenuSetupPage *SetupMenu(void); - virtual bool SetupParse(const char *Name, const char *Value); + bool ActiveWithCancel(void); }; +extern cRemoveThread oRemoveThread; + #endif //__UNDELETE_H @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: vdrtools.c 0.1 2004/10/08 02:03:31 hflor Exp $ + * $Id: vdrtools.c 0.4 2005/11/16 18:39:18 hflor Exp $ */ #include "vdrtools.h" @@ -12,6 +12,57 @@ #include <vdr/menu.h> #include <vdr/interface.h> +#if VDRVERSNUM < 10318 +// --- cReadLine ------------------------------------------------------------- + +cReadLine::cReadLine(void) +{ + size = 0; + buffer = NULL; +} + +cReadLine::~cReadLine() +{ + free(buffer); +} + +char *cReadLine::Read(FILE *f) +{ + int n = getline(&buffer, &size, f); + if (n > 0) { + n--; + if (buffer[n] == '\n') + buffer[n] = 0; + return buffer; + } + return NULL; +} +#endif + +#ifdef HAVE_SVDRP +bool GetVDRSize(const char *dir, long long &llSize) +{ + bool bRet = false; + struct stat fileinfo; + cPipe pipe; + if (pipe.Open((const char *)cString::sprintf("find '%s' -follow -type f", dir), "r")) + { + cReadLine ReadLine; + char *s; + while ((s = ReadLine.Read(pipe)) != NULL) + { + if (stat(s, &fileinfo) != -1) + { + llSize += (long long)fileinfo.st_size; + bRet = true; + } + } + pipe.Close(); + } + return bRet; +} +#endif + char *SkipQuote(char *s) { char c = *s; @@ -68,7 +119,7 @@ char *ExchangeChars(char *s, bool ToFileSystem) return s; } -#ifdef UND_Debug1 +#ifdef UND_Debug const char *KeyName(eKeys Key) { switch (RAWKEY(Key)) @@ -123,8 +174,9 @@ const char *KeyName(eKeys Key) case kUser9: return tr("User9"); break; case kNone: return tr("none"); break; case kKbd: return tr("Kbd"); break; - case kUnDelRec: return tr("UnDelRec"); break; - case kDelRec: return tr("DelRec"); break; + case kSalvageRec: return tr("Salvage"); break; + case kPurgeRec: return tr("Purge"); break; + case kDelLine: return tr("DeleteLine"); break; case kHelpKeys: return tr("HelpKeys"); break; default: return tr("unknow"); break; } @@ -163,9 +215,6 @@ const char *OSStateName(eOSState OSState) case osUser8: return "osUser8"; case osUser9: return "osUser9"; case osUser10: return "osUser10"; -#if VDRVERSNUM < 10307 - case osUser11: return "osUser11"; -#endif default: return "unknow"; } return ""; @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: vdrtools.h 0.1 2004/10/08 02:03:31 hflor Exp $ + * $Id: vdrtools.h 0.4 2005/11/16 18:39:18 hflor Exp $ */ #ifndef __VDRTOOLS_H @@ -13,13 +13,37 @@ #include <vdr/osd.h> #include <vdr/osdbase.h> +#if VDRVERSNUM < 10318 +class cReadLine { +private: + size_t size; + char *buffer; +public: + cReadLine(void); + ~cReadLine(); + char *Read(FILE *f); + }; +#endif + +#ifdef HAVE_SVDRP +bool GetVDRSize(const char *dir, long long &llSize); +#endif char *SkipQuote(char *s); char *ExchangeChars(char *s, bool ToFileSystem); #ifdef UND_Debug1 + #define UND_Debug +#endif +#ifdef UND_Debug2 + #define UND_Debug +#endif +#ifdef UND_Debug3 + #define UND_Debug +#endif + +#ifdef UND_Debug const char *KeyName(eKeys Key); const char *OSStateName(eOSState OSState); #endif - #endif //__VDRTOOLS_H |