Implemented SVDRP command 'HITK'

This commit is contained in:
Klaus Schmidinger 2000-09-17 09:36:50 +02:00
parent 4716cfb5a1
commit 27046cf8a9
8 changed files with 97 additions and 52 deletions

View File

@ -18,6 +18,7 @@ Heino Goldenstein <heino.goldenstein@microplex.de>
Guido Fiala <gfiala@s.netic.de>
for implementing slow forward/back
for implementing the SVDRP command 'HITK'
Robert Schneider <Robert.Schneider@lotus.com>
for implementing EIT support for displaying the current/next info

View File

@ -168,7 +168,7 @@ Video Disk Recorder Revision History
entered so far together with the name of that channel are displayed on the
OSD (suggested by Martin Hammerschmid).
2000-09-16: Version 0.64
2000-09-17: Version 0.64
- Video files now have the 'group read' bit set.
- Fixed handling errors in 'readstring()'.
@ -182,3 +182,7 @@ Video Disk Recorder Revision History
response time on user actions. As a consequence the EIT data may sometimes
not be displayed, but this will change later when cEIT runs as a separate
thread.
- The new SVDRP command 'HITK' can be used to 'hit' a remote control key.
Establish an SVDRP connection and enter HITK without a parameter for a list
of all valid key names.

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: config.c 1.22 2000/09/10 15:07:15 kls Exp $
* $Id: config.c 1.23 2000/09/17 09:11:59 kls Exp $
*/
#include "config.h"
@ -155,14 +155,22 @@ eKeys cKeys::Get(unsigned int Code)
return kNone;
}
eKeys cKeys::Translate(const char *Command)
{
if (Command) {
const tKey *k = keys;
while ((k->type != kNone) && strcasecmp(k->name, Command) != 0)
k++;
return k->type;
}
return kNone;
}
unsigned int cKeys::Encode(const char *Command)
{
if (Command != NULL) {
const tKey *k = keys;
while ((k->type != kNone) && strcmp(k->name, Command) != 0)
k++;
return k->code;
}
eKeys k = Translate(Command);
if (k != kNone)
return keys[k].code;
return 0;
}

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: config.h 1.20 2000/09/15 13:25:51 kls Exp $
* $Id: config.h 1.21 2000/09/17 09:08:13 kls Exp $
*/
#ifndef __CONFIG_H
@ -55,6 +55,7 @@ public:
void SetDummyValues(void);
bool Load(const char *FileName = NULL);
bool Save(void);
eKeys Translate(const char *Command);
unsigned int Encode(const char *Command);
eKeys Get(unsigned int Code);
void Set(eKeys Key, unsigned int Code);

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: interface.c 1.16 2000/09/17 08:21:45 kls Exp $
* $Id: interface.c 1.17 2000/09/17 09:25:30 kls Exp $
*/
#include "interface.h"
@ -66,6 +66,11 @@ eKeys cInterface::GetKey(bool Wait)
return Key;
}
void cInterface::PutKey(eKeys Key)
{
keyFromWait = Key;
}
eKeys cInterface::Wait(int Seconds, bool KeepChar)
{
int t0 = time_ms() + Seconds * 1000;

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: interface.h 1.11 2000/09/10 10:35:46 kls Exp $
* $Id: interface.h 1.12 2000/09/17 09:19:43 kls Exp $
*/
#ifndef __INTERFACE_H
@ -30,6 +30,7 @@ public:
void Open(int NumCols = MenuColumns, int NumLines = MenuLines);
void Close(void);
eKeys GetKey(bool Wait = true);
void PutKey(eKeys Key);
void Clear(void);
void ClearEol(int x, int y, eDvbColor Color = clrBackground);
void SetCols(int *c);

78
svdrp.c
View File

@ -10,7 +10,7 @@
* and interact with the Video Disk Recorder - or write a full featured
* graphical interface that sits on top of an SVDRP connection.
*
* $Id: svdrp.c 1.7 2000/09/16 13:34:28 kls Exp $
* $Id: svdrp.c 1.8 2000/09/17 09:24:52 kls Exp $
*/
#define _GNU_SOURCE
@ -122,6 +122,9 @@ const char *HelpPages[] = {
" Delete timer.",
"HELP [ <topic> ]\n"
" The HELP command gives help info.",
"HITK [ <key> ]\n"
" Hit the given remote control key. Without option a list of all\n"
" valid key names is given.",
"LSTC [ <number> | <name> ]\n"
" List channels. Without option, all channels are listed. Otherwise\n"
" only the given channel is listed. If a name is given, all channels\n"
@ -272,7 +275,7 @@ void cSVDRP::Reply(int Code, const char *fmt, ...)
}
}
void cSVDRP::CmdChan(const char *Option)
void cSVDRP::CmdCHAN(const char *Option)
{
if (*Option) {
int n = -1;
@ -329,13 +332,13 @@ void cSVDRP::CmdChan(const char *Option)
Reply(550, "Unable to find channel \"%d\"", CurrentChannel);
}
void cSVDRP::CmdDelc(const char *Option)
void cSVDRP::CmdDELC(const char *Option)
{
//TODO combine this with menu action (timers must be updated)
Reply(502, "DELC not yet implemented");
}
void cSVDRP::CmdDelt(const char *Option)
void cSVDRP::CmdDELT(const char *Option)
{
if (*Option) {
if (isnumber(Option)) {
@ -360,7 +363,7 @@ void cSVDRP::CmdDelt(const char *Option)
Reply(501, "Missing timer number");
}
void cSVDRP::CmdHelp(const char *Option)
void cSVDRP::CmdHELP(const char *Option)
{
if (*Option) {
const char *hp = GetHelpPage(Option);
@ -388,7 +391,27 @@ void cSVDRP::CmdHelp(const char *Option)
Reply(214, "End of HELP info");
}
void cSVDRP::CmdLstc(const char *Option)
void cSVDRP::CmdHITK(const char *Option)
{
if (*Option) {
eKeys k = Keys.Translate(Option);
if (k != kNone) {
Interface.PutKey(k);
Reply(250, "Key \"%s\" accepted", Option);
}
else
Reply(504, "Unknown key: \"%s\"", Option);
}
else {
Reply(-214, "Valid <key> names for the HITK command:");
for (int i = 0; i < kNone; i++) {
Reply(-214, " %s", Keys.keys[i].name);
}
Reply(214, "End of key list");
}
}
void cSVDRP::CmdLSTC(const char *Option)
{
if (*Option) {
if (isnumber(Option)) {
@ -431,7 +454,7 @@ void cSVDRP::CmdLstc(const char *Option)
}
}
void cSVDRP::CmdLstt(const char *Option)
void cSVDRP::CmdLSTT(const char *Option)
{
if (*Option) {
if (isnumber(Option)) {
@ -455,7 +478,7 @@ void cSVDRP::CmdLstt(const char *Option)
}
}
void cSVDRP::CmdModc(const char *Option)
void cSVDRP::CmdMODC(const char *Option)
{
if (*Option) {
char *tail;
@ -484,7 +507,7 @@ void cSVDRP::CmdModc(const char *Option)
Reply(501, "Missing channel settings");
}
void cSVDRP::CmdModt(const char *Option)
void cSVDRP::CmdMODT(const char *Option)
{
if (*Option) {
char *tail;
@ -517,19 +540,19 @@ void cSVDRP::CmdModt(const char *Option)
Reply(501, "Missing timer settings");
}
void cSVDRP::CmdMovc(const char *Option)
void cSVDRP::CmdMOVC(const char *Option)
{
//TODO combine this with menu action (timers must be updated)
Reply(502, "MOVC not yet implemented");
}
void cSVDRP::CmdMovt(const char *Option)
void cSVDRP::CmdMOVT(const char *Option)
{
//TODO combine this with menu action
Reply(502, "MOVT not yet implemented");
}
void cSVDRP::CmdNewc(const char *Option)
void cSVDRP::CmdNEWC(const char *Option)
{
if (*Option) {
cChannel *channel = new cChannel;
@ -547,7 +570,7 @@ void cSVDRP::CmdNewc(const char *Option)
Reply(501, "Missing channel settings");
}
void cSVDRP::CmdNewt(const char *Option)
void cSVDRP::CmdNEWT(const char *Option)
{
if (*Option) {
cTimer *timer = new cTimer;
@ -571,7 +594,7 @@ void cSVDRP::CmdNewt(const char *Option)
Reply(501, "Missing timer settings");
}
void cSVDRP::CmdUpdt(const char *Option)
void cSVDRP::CmdUPDT(const char *Option)
{
if (*Option) {
cTimer *timer = new cTimer;
@ -610,19 +633,20 @@ void cSVDRP::Execute(char *Cmd)
while (*s && !isspace(*s))
s++;
*s++ = 0;
if (CMD("CHAN")) CmdChan(s);
else if (CMD("DELC")) CmdDelc(s);
else if (CMD("DELT")) CmdDelt(s);
else if (CMD("HELP")) CmdHelp(s);
else if (CMD("LSTC")) CmdLstc(s);
else if (CMD("LSTT")) CmdLstt(s);
else if (CMD("MODC")) CmdModc(s);
else if (CMD("MODT")) CmdModt(s);
else if (CMD("MOVC")) CmdMovc(s);
else if (CMD("MOVT")) CmdMovt(s);
else if (CMD("NEWC")) CmdNewc(s);
else if (CMD("NEWT")) CmdNewt(s);
else if (CMD("UPDT")) CmdUpdt(s);
if (CMD("CHAN")) CmdCHAN(s);
else if (CMD("DELC")) CmdDELC(s);
else if (CMD("DELT")) CmdDELT(s);
else if (CMD("HELP")) CmdHELP(s);
else if (CMD("HITK")) CmdHITK(s);
else if (CMD("LSTC")) CmdLSTC(s);
else if (CMD("LSTT")) CmdLSTT(s);
else if (CMD("MODC")) CmdMODC(s);
else if (CMD("MODT")) CmdMODT(s);
else if (CMD("MOVC")) CmdMOVC(s);
else if (CMD("MOVT")) CmdMOVT(s);
else if (CMD("NEWC")) CmdNEWC(s);
else if (CMD("NEWT")) CmdNEWT(s);
else if (CMD("UPDT")) CmdUPDT(s);
else if (CMD("QUIT")
|| CMD("\x04")) Close();
else Reply(500, "Command unrecognized: \"%s\"", Cmd);

29
svdrp.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: svdrp.h 1.3 2000/09/16 11:48:36 kls Exp $
* $Id: svdrp.h 1.4 2000/09/17 08:52:51 kls Exp $
*/
#ifndef __SVDRP_H
@ -32,19 +32,20 @@ private:
void Close(void);
bool Send(const char *s, int length = -1);
void Reply(int Code, const char *fmt, ...);
void CmdChan(const char *Option);
void CmdDelc(const char *Option);
void CmdDelt(const char *Option);
void CmdHelp(const char *Option);
void CmdLstc(const char *Option);
void CmdLstt(const char *Option);
void CmdModc(const char *Option);
void CmdModt(const char *Option);
void CmdMovc(const char *Option);
void CmdMovt(const char *Option);
void CmdNewc(const char *Option);
void CmdNewt(const char *Option);
void CmdUpdt(const char *Option);
void CmdCHAN(const char *Option);
void CmdDELC(const char *Option);
void CmdDELT(const char *Option);
void CmdHELP(const char *Option);
void CmdHITK(const char *Option);
void CmdLSTC(const char *Option);
void CmdLSTT(const char *Option);
void CmdMODC(const char *Option);
void CmdMODT(const char *Option);
void CmdMOVC(const char *Option);
void CmdMOVT(const char *Option);
void CmdNEWC(const char *Option);
void CmdNEWT(const char *Option);
void CmdUPDT(const char *Option);
void Execute(char *Cmd);
public:
cSVDRP(int Port);