counterpart to undelete?

Message ID 427F1732.3090305@errror.org
State New
Headers

Commit Message

Patrick Cernko May 9, 2005, 7:54 a.m. UTC
  Rainer Zocholl wrote:
> Hello
> 
> is there a plugin that allows to edit the "keep" time
> (and priority) of an existing recording?
> 
> Most timers are set to "7 days", but 
> I sometimes would like to keep an existing record for longer.
> Today i was some few hours too late to edit via shell.
> 

I use the rename-patch for a long time. It also has the capability to
change the life-time and priority.

Sorry, but since there is only a very old page
(http://vdr.sjur.de/rename.html) for the patch, I maintain it myself but
together with another useful patch for me, the recordinglength-patch. If
you don't like it, you can fully disable it in the Recordings-setup.

@Klaus: I wanted to ask you for integration of these to small
improvements since a long time, but always forget it again. What do you
think about an integration until vdr-1.4 is released?
  

Comments

Darren Salt May 9, 2005, 7:35 p.m. UTC | #1
I demand that Patrick Cernko may or may not have written...

[snip]
> @Klaus: I wanted to ask you for integration of these to small
> improvements since a long time, but always forget it again. What do you
> think about an integration until vdr-1.4 is released?

Er... surely you'd want that in 1.4?
  
Klaus Schmidinger May 9, 2005, 8:41 p.m. UTC | #2
Patrick Cernko wrote:
> ...
> @Klaus: I wanted to ask you for integration of these to small
> improvements since a long time, but always forget it again. What do you
> think about an integration until vdr-1.4 is released?

There will only be a few more changes until 1.4, but renaming recordings
will most likely not be amoung them.

Klaus
  
Sean Carlos May 9, 2005, 9:33 p.m. UTC | #3
Darren Salt wrote:

>I demand that Patrick Cernko may or may not have written...
>
>[snip]
>  
>
>>@Klaus: I wanted to ask you for integration of these to small
>>improvements since a long time, but always forget it again. What do you
>>think about an integration until vdr-1.4 is released?
>>    
>>
>
>Er... surely you'd want that in 1.4?
>
>  
>
Let's not be too hard now :-) ... certain English words cause a lot of 
grief for non-English mother tongue speakers (and too often native 
speakers alike).

So for example, when you see the use of the word "actual", you should 
engage alternate filters to see if "current" is what is really meant. 
This is true at least for most romance languages + German.

The same filter should engage when a German speaker uses "until". If I 
remember correctly, this is a translation of "bis" which in this context 
in English should probably be "before" or "with" the vdr 1.4 release.

- Sean
  
Patrick Cernko May 10, 2005, 6:17 a.m. UTC | #4
Klaus Schmidinger wrote:
> Patrick Cernko wrote:
> 
>> ...
>> @Klaus: I wanted to ask you for integration of these to small
>> improvements since a long time, but always forget it again. What do you
>> think about an integration until vdr-1.4 is released?
> 

@Darren: Sean is absolutly right: stupid german-english translation
fault. I wanted to have it integrated BEFORE vdr-1.4 release!

> 
> There will only be a few more changes until 1.4, but renaming recordings
> will most likely not be amoung them.
> 

Damn, I was too late. Anyway, nice to see vdr-1.4 coming soon. Maybe you
could integrate it in the next devel branch!

CU/all
  
Nicolas Huillard May 10, 2005, 8:42 a.m. UTC | #5
Klaus Schmidinger wrote:
>There will only be a few more changes until 1.4, but renaming recordings
>will most likely not be amoung them.

Is there some kind of deadline, planned date or something like that, for 
submitting translation patches ?
  
Klaus Schmidinger May 10, 2005, 3:24 p.m. UTC | #6
Nicolas Huillard wrote:
> Klaus Schmidinger wrote:
> 
>> There will only be a few more changes until 1.4, but renaming recordings
>> will most likely not be amoung them.
> 
> 
> Is there some kind of deadline, planned date or something like that, for 
> submitting translation patches ?

You can provide translations any time.

I'll issue a final call for translations before version 1.4 gets out.

Klaus
  

Patch

diff -Naur vdr-1.3.18.orig/config.c vdr-1.3.18/config.c
--- vdr-1.3.18.orig/config.c	2005-01-09 13:14:58.000000000 +0100
+++ vdr-1.3.18/config.c	2005-01-11 08:25:13.000000000 +0100
@@ -299,6 +299,9 @@ 
   CurrentChannel = -1;
   CurrentVolume = MAXVOLUME;
   CurrentDolby = 0;
+  ShowRecDate = 1;
+  ShowRecTime = 1;
+  ShowRecLength = 0;
 }
 
 cSetup& cSetup::operator= (const cSetup &s)
@@ -454,6 +457,9 @@ 
   else if (!strcasecmp(Name, "CurrentChannel"))      CurrentChannel     = atoi(Value);
   else if (!strcasecmp(Name, "CurrentVolume"))       CurrentVolume      = atoi(Value);
   else if (!strcasecmp(Name, "CurrentDolby"))        CurrentDolby       = atoi(Value);
+  else if (!strcasecmp(Name, "ShowRecDate"))         ShowRecDate        = atoi(Value);
+  else if (!strcasecmp(Name, "ShowRecTime"))         ShowRecTime        = atoi(Value);
+  else if (!strcasecmp(Name, "ShowRecLength"))       ShowRecLength      = atoi(Value);
   else
      return false;
   return true;
@@ -516,6 +522,9 @@ 
   Store("CurrentChannel",     CurrentChannel);
   Store("CurrentVolume",      CurrentVolume);
   Store("CurrentDolby",       CurrentDolby);
+  Store("ShowRecDate",        ShowRecDate);
+  Store("ShowRecTime",        ShowRecTime);
+  Store("ShowRecLength",      ShowRecLength);
 
   Sort();
 
diff -Naur vdr-1.3.18.orig/config.h vdr-1.3.18/config.h
--- vdr-1.3.18.orig/config.h	2005-01-09 13:14:33.000000000 +0100
+++ vdr-1.3.18/config.h	2005-01-11 08:25:40.000000000 +0100
@@ -253,6 +253,7 @@ 
   int CurrentChannel;
   int CurrentVolume;
   int CurrentDolby;
+  int ShowRecDate, ShowRecTime, ShowRecLength;
   int __EndData__;
   cSetup(void);
   cSetup& operator= (const cSetup &s);
diff -Naur vdr-1.3.18.orig/i18n.c vdr-1.3.18/i18n.c
--- vdr-1.3.18.orig/i18n.c	2005-01-09 13:17:44.000000000 +0100
+++ vdr-1.3.18/i18n.c	2005-01-11 08:23:32.000000000 +0100
@@ -3640,6 +3640,63 @@ 
     "Tükelda redigeeritud faile",
     "Opdel redigerede filer",
   },
+  { "Setup.Recording$Show Date",
+    "Aufnahmedatum anzeigen",
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "Näytä tallenteen päiväys",
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "¿ÞÚÐ×ëÒÐâì ÔÐâã",
+    "",//TODO
+  },
+  { "Setup.Recording$Show Time",
+    "AufnahmeZeit anzeigen",
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "Näytä tallenteen ajankohta",
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "¿ÞÚÐ×ëÒÐâì ÒàÕÜï ×ÐßØáØ",
+    "",//TODO
+  },
+  { "Setup.Recording$Show Length",
+    "Länge der Aufnahme anzeigen",
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "Näytä tallenteen kesto",
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "¿ÞÚÐ×ëÒÐâì ßàÞÔÞÛÖØâÕÛìÝÞáâì ×ÐßØáØ",
+    "",//TODO
+  },
   { "Setup.Replay$Multi speed mode",
     "MultiSpeed Modus",
     "Rezim z vec hitrostmi",
@@ -5157,6 +5214,25 @@ 
     "ST:TNG konsool",
     "ST:TNG konsol",
   },
+  { "Rename recording",
+    "Aufzeichnung umbenennen",
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "Nimeä tallenne",
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "",//TODO
+    "¿ÕàÕØÜÕÝÞÒÐâì ×ÐßØáì",
+    "",// TODO
+  },
   { NULL }
   };
 
diff -Naur vdr-1.3.18.orig/menu.c vdr-1.3.18/menu.c
--- vdr-1.3.18.orig/menu.c	2005-01-11 08:22:15.000000000 +0100
+++ vdr-1.3.18/menu.c	2005-01-11 08:27:26.000000000 +0100
@@ -969,7 +969,7 @@ 
   char t = Timers.GetMatch(Event, &TimerMatch) ? (TimerMatch == tmFull) ? 'T' : 't' : ' ';
   char v = event->Vps() && (event->Vps() - event->StartTime()) ? 'V' : ' ';
   char r = event->IsRunning() ? '*' : ' ';
-  asprintf(&buffer, "%d\t%.*s\t%s\t%c%c%c\t%s", channel->Number(), 6, channel->ShortName(true), *event->GetTimeString(), t, v, r, event->Title());
+  asprintf(&buffer, "%.*s\t%.*s\t%c%c%c\t%s", 10, channel->ShortName(), 5, *event->GetTimeString(), t, v, r, event->Title());
   SetText(buffer, false);
 }
 
@@ -993,7 +993,7 @@ 
 const cEvent *cMenuWhatsOn::scheduleEvent = NULL;
 
 cMenuWhatsOn::cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentChannelNr)
-:cOsdMenu(Now ? tr("What's on now?") : tr("What's on next?"), CHNUMWIDTH, 7, 6, 4)
+:cOsdMenu(Now ? tr("What's on now?") : tr("What's on next?"), 12, 6, 4)
 {
   for (cChannel *Channel = Channels.First(); Channel; Channel = Channels.Next(Channel)) {
       if (!Channel->GroupSep()) {
@@ -1459,12 +1459,62 @@ 
   SetText(buffer, false);
 }
 
+// --- cMenuRenameRecording --------------------------------------------------
+
+class cMenuRenameRecording : public cOsdMenu {
+private:
+  int lifetime;
+  int priority;
+  char name[MaxFileName];
+  cRecording *recording;
+public:
+  cMenuRenameRecording(cRecording *Recording);
+  ~cMenuRenameRecording();
+  virtual eOSState ProcessKey(eKeys Key);
+  };
+
+cMenuRenameRecording::cMenuRenameRecording(cRecording *Recording)
+:cOsdMenu(tr("Rename recording"), 12)
+{
+  recording = Recording;
+  priority = recording->priority;
+  lifetime = recording->lifetime;
+  strncpy(name, recording->Name(), sizeof(name));
+
+  Add(new cMenuEditStrItem(tr("Name"),      name,     sizeof(name), tr(FileNameChars)));
+  Add(new cMenuEditIntItem(tr("Priority"), &priority, 0,            MAXPRIORITY      ));
+  Add(new cMenuEditIntItem(tr("Lifetime"), &lifetime, 0,            MAXLIFETIME      ));
+}
+
+cMenuRenameRecording::~cMenuRenameRecording()
+{
+}
+
+eOSState cMenuRenameRecording::ProcessKey(eKeys Key)
+{
+  eOSState state = cOsdMenu::ProcessKey(Key);
+
+  if (state == osUnknown) {
+     if (Key == kOk) {
+        if (recording->Rename(name, &priority, &lifetime))
+          {
+            Recordings.Load();
+            return osRecordings;
+          }
+        else
+           Skins.Message(mtError, tr("Error while accessing recording!"));
+        }
+     return osContinue;
+     }
+  return state;
+}
+
 // --- cMenuRecordings -------------------------------------------------------
 
 int cMenuRecordings::helpKeys = -1;
 
 cMenuRecordings::cMenuRecordings(const char *Base, int Level, bool OpenSubMenus)
-:cOsdMenu(Base ? Base : tr("Recordings"), 6, 6)
+:cOsdMenu(Base ? Base : tr("Recordings"), 6, 6, 6)
 {
   base = Base ? strdup(Base) : NULL;
   level = Setup.RecordingDirs ? Level : -1;
@@ -1665,6 +1715,19 @@ 
   return osContinue;
 }
 
+eOSState cMenuRecordings::Rename(void)
+{
+  if (HasSubMenu() || Count() == 0)
+     return osContinue;
+  cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current());
+  if (ri && !ri->IsDirectory()) {
+     cRecording *recording = GetRecording(ri);
+     if (recording)
+        return AddSubMenu(new cMenuRenameRecording(recording));
+     }
+  return osContinue;
+}
+
 eOSState cMenuRecordings::ProcessKey(eKeys Key)
 {
   bool HadSubMenu = HasSubMenu();
@@ -1677,6 +1740,7 @@ 
        case kGreen:  return Rewind();
        case kYellow: return Delete();
        case kBlue:   return Summary();
+       case k0:      return Rename();
        case k1...k9: return Commands(Key);
        default: break;
        }
@@ -2156,6 +2220,9 @@ 
   Add(new cMenuEditIntItem( tr("Setup.Recording$Instant rec. time (min)"),   &data.InstantRecordTime, 1, MAXINSTANTRECTIME));
   Add(new cMenuEditIntItem( tr("Setup.Recording$Max. video file size (MB)"), &data.MaxVideoFileSize, MINVIDEOFILESIZE, MAXVIDEOFILESIZE));
   Add(new cMenuEditBoolItem(tr("Setup.Recording$Split edited files"),        &data.SplitEditedFiles));
+  Add(new cMenuEditBoolItem(tr("Setup.Recording$Show Date"),                 &data.ShowRecDate));
+  Add(new cMenuEditBoolItem(tr("Setup.Recording$Show Time"),                 &data.ShowRecTime));
+  Add(new cMenuEditBoolItem(tr("Setup.Recording$Show Length"),               &data.ShowRecLength));
 }
 
 // --- cMenuSetupReplay ------------------------------------------------------
diff -Naur vdr-1.3.18.orig/menu.h vdr-1.3.18/menu.h
--- vdr-1.3.18.orig/menu.h	2005-01-08 16:48:57.000000000 +0100
+++ vdr-1.3.18/menu.h	2005-01-11 08:23:33.000000000 +0100
@@ -135,6 +135,7 @@ 
   eOSState Delete(void);
   eOSState Summary(void);
   eOSState Commands(eKeys Key = kNone);
+  eOSState Rename(void);
 public:
   cMenuRecordings(const char *Base = NULL, int Level = 0, bool OpenSubMenus = false);
   ~cMenuRecordings();
diff -Naur vdr-1.3.18.orig/recording.c vdr-1.3.18/recording.c
--- vdr-1.3.18.orig/recording.c	2005-01-11 08:14:19.000000000 +0100
+++ vdr-1.3.18/recording.c	2005-01-11 08:23:33.000000000 +0100
@@ -47,6 +47,7 @@ 
 #define RESUMEFILESUFFIX  "/resume%s%s.vdr"
 #define SUMMARYFILESUFFIX "/summary.vdr"
 #define MARKSFILESUFFIX   "/marks.vdr"
+#define INDEXFILESUFFIX   "/index.vdr"
 
 #define MINDISKSPACE 1024 // MB
 
@@ -490,7 +491,7 @@ 
   return fileName;
 }
 
-const char *cRecording::Title(char Delimiter, bool NewIndicator, int Level) const
+const char *cRecording::Title(char Delimiter, bool NewIndicator, int Level, bool Original) const
 {
   char New = NewIndicator && IsNew() ? '*' : ' ';
   free(titleBuffer);
@@ -503,6 +504,7 @@ 
         s++;
      else
         s = name;
+     if (Original) {
      asprintf(&titleBuffer, "%02d.%02d%c%02d:%02d%c%c%s",
                             t->tm_mday,
                             t->tm_mon + 1,
@@ -512,6 +514,57 @@ 
                             New,
                             Delimiter,
                             s);
+        }
+     else {
+        struct tIndex { int offset; uchar type; uchar number; short reserved; };
+        tIndex *index;
+        char RecLength[20] = "";
+        char RecDate[5] = "";
+        char RecTime[5] = "";
+        char RecDelimiter[1] = "";
+        if (Setup.ShowRecLength) {
+           char *filename = NULL;
+           int last = -1;
+           index = NULL;
+           if (FileName()) {
+              filename = MALLOC(char, strlen(FileName()) + strlen(INDEXFILESUFFIX) + 1);
+              if (filename) {
+                 strcpy(filename, FileName());
+                 char *pFileExt = filename + strlen(filename);
+                 strcpy(pFileExt, INDEXFILESUFFIX);
+                 int delta = 0;
+                 if (access(filename, R_OK) == 0) {
+                    struct stat buf;
+                    if (stat(filename, &buf) == 0) {
+                       delta = buf.st_size % sizeof(tIndex);
+                       if (delta) {
+                          delta = sizeof(tIndex) - delta;
+                          esyslog("ERROR: invalid file size (%ld) in '%s'", buf.st_size, filename);
+                          }
+                       last = (buf.st_size + delta) / sizeof(tIndex) - 1;
+                       char hour[2] = ""; char min[3] = "";
+                       sprintf(RecLength, "%s", (const char*) IndexToHMSF(last, true));
+                       sprintf(hour, "%c", RecLength[0]);
+                       sprintf(min, "%c%c", RecLength[2], RecLength[3]);	  
+                       sprintf(RecLength, "%3d'", (atoi(hour) * 60) + atoi(min));
+                       }
+                    }
+                 }
+              }
+           }
+        sprintf(RecDate,"%02d.%02d", t->tm_mday, t->tm_mon + 1);
+        sprintf(RecTime,"%02d:%02d", t->tm_hour, t->tm_min);
+        sprintf(RecDelimiter,"%c", Delimiter);
+        asprintf(&titleBuffer, "%s%s%s%c%s%s%s%s",
+                               (Setup.ShowRecDate ? RecDate                               : ""),
+                               (Setup.ShowRecDate ? Setup.ShowRecTime ? RecDelimiter : "" : ""),
+                               (Setup.ShowRecTime ? RecTime                               : ""),
+                               New,
+                               (Setup.ShowRecTime   ? RecDelimiter : Setup.ShowRecDate ? RecDelimiter : ""),
+                               (Setup.ShowRecLength ? RecLength    : ""),
+                               (Setup.ShowRecLength ? RecDelimiter : ""),
+                               s);
+        }
      // let's not display a trailing '~':
      stripspace(titleBuffer);
      s = &titleBuffer[strlen(titleBuffer) - 1];
@@ -616,6 +669,32 @@ 
   return RemoveVideoFile(FileName());
 }
 
+bool cRecording::Rename(char *newName, int *newPriority, int *newLifetime)
+{
+  bool result = true;
+  char *newFileName;
+  struct tm tm_r;
+  struct tm *t = localtime_r(&start, &tm_r);
+  asprintf(&newFileName, NAMEFORMAT, VideoDirectory, ExchangeChars(newName, true), t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, *newPriority, *newLifetime);
+  if (strcmp(FileName(), newFileName)) {
+     if (access(newFileName, F_OK) == 0) {
+        isyslog("recording %s already exists", newFileName);
+        }
+     else {
+        isyslog("renaming recording %s to %s", FileName(), newFileName);
+        result = MakeDirs(newFileName, true);
+        if (result)
+           result = RenameVideoFile(FileName(), newFileName);
+        if (result) {
+           free(fileName);
+           fileName = strdup(newFileName);
+           }
+        }
+     }
+  free(newFileName);
+  return result;
+}
+
 // --- cRecordings -----------------------------------------------------------
 
 cRecordings Recordings;
@@ -823,8 +902,6 @@ 
 
 #define INDEXFILESUFFIX     "/index.vdr"
 
-#define INDEXFILESUFFIX     "/index.vdr"
-
 // The number of frames to stay off the end in case of time shift:
 #define INDEXSAFETYLIMIT 150 // frames
 
diff -Naur vdr-1.3.18.orig/recording.h vdr-1.3.18/recording.h
--- vdr-1.3.18.orig/recording.h	2005-01-11 08:22:15.000000000 +0100
+++ vdr-1.3.18/recording.h	2005-01-11 08:23:33.000000000 +0100
@@ -53,7 +53,7 @@ 
   virtual int Compare(const cListObject &ListObject) const;
   const char *Name(void) const { return name; }
   const char *FileName(void) const;
-  const char *Title(char Delimiter = ' ', bool NewIndicator = false, int Level = -1) const;
+  const char *Title(char Delimiter = ' ', bool NewIndicator = false, int Level = -1, bool Original = false) const;
   const char *Summary(void) const { return summary; }
   const char *PrefixFileName(char Prefix);
   int HierarchyLevels(void) const;
@@ -66,6 +66,9 @@ 
   bool Remove(void);
        // Actually removes the file from the disk
        // Returns false in case of error
+  bool Rename(char *newName, int *newPriority, int *newLifetime);
+       // Changes the file name
+       // Returns false in case of error
   };
 
 class cRecordings : public cList<cRecording> {
diff -Naur vdr-1.3.18.orig/svdrp.c vdr-1.3.18/svdrp.c
--- vdr-1.3.18.orig/svdrp.c	2004-12-26 13:23:55.000000000 +0100
+++ vdr-1.3.18/svdrp.c	2005-01-11 08:23:33.000000000 +0100
@@ -816,7 +816,7 @@ 
   else if (recordings) {
      cRecording *recording = Recordings.First();
      while (recording) {
-           Reply(recording == Recordings.Last() ? 250 : -250, "%d %s", recording->Index() + 1, recording->Title(' ', true));
+           Reply(recording == Recordings.Last() ? 250 : -250, "%d %s", recording->Index() + 1, recording->Title(' ', true, -1, true));
            recording = Recordings.Next(recording);
            }
      }
diff -Naur vdr-1.3.18.orig/tools.c vdr-1.3.18/tools.c
--- vdr-1.3.18.orig/tools.c	2005-01-04 12:06:45.000000000 +0100
+++ vdr-1.3.18/tools.c	2005-01-11 08:28:43.000000000 +0100
@@ -532,7 +532,7 @@ 
      time(&t);
   struct tm tm_r;
   tm *tm = localtime_r(&t, &tm_r);
-  snprintf(buffer, sizeof(buffer), "%s %2d.%02d %02d:%02d", *WeekDayName(tm->tm_wday), tm->tm_mday, tm->tm_mon + 1, tm->tm_hour, tm->tm_min);
+  snprintf(buffer, sizeof(buffer), "%s %02d.%02d %02d:%02d", *WeekDayName(tm->tm_wday), tm->tm_mday, tm->tm_mon + 1, tm->tm_hour, tm->tm_min);
   return buffer;
 }