summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2002-10-13 09:03:53 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2002-10-13 09:03:53 +0200
commite58fa67e6c53dc8ad061a2941b9984a0c1185a8f (patch)
tree1b0e139b036885c17195a78869d5ff6ccef80dfb
parentfadc2565d468afca10448600033b73af1ef74978 (diff)
downloadvdr-e58fa67e6c53dc8ad061a2941b9984a0c1185a8f.tar.gz
vdr-e58fa67e6c53dc8ad061a2941b9984a0c1185a8f.tar.bz2
Implemented '?' handling for commands.conf
-rw-r--r--HISTORY5
-rw-r--r--config.c12
-rw-r--r--config.h4
-rw-r--r--menu.c24
-rw-r--r--vdr.518
5 files changed, 44 insertions, 19 deletions
diff --git a/HISTORY b/HISTORY
index 71872b43..3f2372f8 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1150,7 +1150,7 @@ Video Disk Recorder Revision History
to their appropriate system locations and creates the /video directory if
it doesn't exist yet.
- Automatic hotkey assignment is now suppressed if the first entry in
- commands.conf starts with a digit in the range '1'...'9', followed by a blank.
+ 'commands.conf' starts with a digit in the range '1'...'9', followed by a blank.
- Fixed a bug in switching back the replay mode display in time shift mode
(thanks to Achim Lange for reporting this one).
- Fixed a bug in the "First day" timer parameter for timers that record over
@@ -1599,3 +1599,6 @@ Video Disk Recorder Revision History
- Reactivated full handling of second audio PID (even in 'Transfer Mode').
- Fixed a crash when closing down with remote control plugins (thanks to Oliver
Endriss helping to debug this one).
+- Commands in the file 'commands.conf' can now have a '?' at the end of their
+ title, which will result in a confirmation prompt before executing the
+ command.
diff --git a/config.c b/config.c
index 24c14389..ad9282be 100644
--- a/config.c
+++ b/config.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: config.c 1.107 2002/10/03 10:06:55 kls Exp $
+ * $Id: config.c 1.108 2002/10/13 08:52:25 kls Exp $
*/
#include "config.h"
@@ -360,6 +360,7 @@ char *cCommand::result = NULL;
cCommand::cCommand(void)
{
title = command = NULL;
+ confirm = false;
}
cCommand::~cCommand()
@@ -374,9 +375,14 @@ bool cCommand::Parse(const char *s)
if (p) {
int l = p - s;
if (l > 0) {
- title = new char[l + 1];
- strn0cpy(title, s, l + 1);
+ title = MALLOC(char, l + 1);
+ stripspace(strn0cpy(title, s, l + 1));
if (!isempty(title)) {
+ int l = strlen(title);
+ if (l > 1 && title[l - 1] == '?') {
+ confirm = true;
+ title[l - 1] = 0;
+ }
command = stripspace(strdup(skipspace(p + 1)));
return !isempty(command);
}
diff --git a/config.h b/config.h
index 83ef9c00..a24f71a3 100644
--- a/config.h
+++ b/config.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: config.h 1.132 2002/10/06 16:03:01 kls Exp $
+ * $Id: config.h 1.133 2002/10/13 08:35:49 kls Exp $
*/
#ifndef __CONFIG_H
@@ -87,12 +87,14 @@ class cCommand : public cListObject {
private:
char *title;
char *command;
+ bool confirm;
static char *result;
public:
cCommand(void);
virtual ~cCommand();
bool Parse(const char *s);
const char *Title(void) { return title; }
+ bool Confirm(void) { return confirm; }
const char *Execute(void);
};
diff --git a/menu.c b/menu.c
index 5ea8663b..786e1398 100644
--- a/menu.c
+++ b/menu.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menu.c 1.214 2002/10/12 13:34:56 kls Exp $
+ * $Id: menu.c 1.215 2002/10/13 08:44:33 kls Exp $
*/
#include "menu.h"
@@ -2079,13 +2079,21 @@ eOSState cMenuCommands::Execute(void)
cCommand *command = Commands.Get(Current());
if (command) {
char *buffer = NULL;
- asprintf(&buffer, "%s...", command->Title());
- Interface->Status(buffer);
- Interface->Flush();
- free(buffer);
- const char *Result = command->Execute();
- if (Result)
- return AddSubMenu(new cMenuText(command->Title(), Result, fontFix));
+ bool confirmed = true;
+ if (command->Confirm()) {
+ asprintf(&buffer, "%s?", command->Title());
+ confirmed = Interface->Confirm(buffer);
+ free(buffer);
+ }
+ if (confirmed) {
+ asprintf(&buffer, "%s...", command->Title());
+ Interface->Status(buffer);
+ Interface->Flush();
+ free(buffer);
+ const char *Result = command->Execute();
+ if (Result)
+ return AddSubMenu(new cMenuText(command->Title(), Result, fontFix));
+ }
}
return osContinue;
}
diff --git a/vdr.5 b/vdr.5
index 8d6acfbc..b36422fa 100644
--- a/vdr.5
+++ b/vdr.5
@@ -8,7 +8,7 @@
.\" License as specified in the file COPYING that comes with the
.\" vdr distribution.
.\"
-.\" $Id: vdr.5 1.6 2002/10/06 08:56:01 kls Exp $
+.\" $Id: vdr.5 1.7 2002/10/13 09:03:53 kls Exp $
.\"
.TH vdr 5 "7 Sep 2002" "1.2.0" "Video Disk Recorder Files"
.SH NAME
@@ -322,7 +322,10 @@ Each line contains one command definition in the following format:
where \fBtitle\fR is the string that will be displayed in the "Commands" menu,
and \fBcommand\fR is the actual command string that will be executed when this
option is selected. The delimiting ':' may be surrounded by any number of
-white space characters.
+white space characters. If \fBtitle\fR ends with the character '?', there will
+be a confirmation prompt before actually executing the command. This can be
+used for commands that might have serious results (like deleting files etc)
+to make sure they are not executed inadvertently.
By default the menu entries in the "Commands" menu will be numbered '1'...'9'
to make them selectable by pressing the corresponding number key. If you want
@@ -337,16 +340,19 @@ In order to avoid error messages to the console, every command should have
Examples:
-Check for new mail: /usr/local/bin/checkmail 2>&1
+Check for new mail?: /usr/local/bin/checkmail 2>&1
.br
-CPU status : /usr/local/bin/cpustatus 2>&1
+CPU status: /usr/local/bin/cpustatus 2>&1
.br
-Disk space : df -h | grep '/video' | awk '{ print 100 - $5 "% free"; }'
+Disk space: df -h | grep '/video' | awk '{ print 100 - $5 "% free"; }'
.br
-Calendar : date;echo;cal
+Calendar: date;echo;cal
Note that the commands 'checkmail' and 'cpustatus' are only \fBexamples\fR!
Don't send emails to the author asking where to find these ;-)
+.br
+The '?' at the end of the "Check for new mail?" entry will prompt the user
+whether this command shall really be executed.
.SS SVDRP HOSTS
The file \fIsvdrphosts.conf\fR contains the IP numbers of all hosts that are
allowed to access the SVDRP port.