From 0d85a30e61e662affc1d12a4c1ca71d8b7a8e94b Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Tue, 19 Sep 2000 17:48:42 +0200 Subject: [PATCH] Fixed 'confirm' dialog --- HISTORY | 3 ++- interface.c | 17 ++++++++++++++--- interface.h | 7 +++++-- remote.c | 26 +++++++++++++------------- remote.h | 10 +++++----- vdr.c | 10 +++------- 6 files changed, 42 insertions(+), 31 deletions(-) diff --git a/HISTORY b/HISTORY index f229860f..e91dae48 100644 --- a/HISTORY +++ b/HISTORY @@ -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-17: Version 0.64 +2000-09-19: Version 0.64 - NOTE: If you are using DVB driver version 0.7 you need to load the dvb.o module with option outstream=0, so your insmod statement should read @@ -200,3 +200,4 @@ Video Disk Recorder Revision History now silently removed. - Fixed a buffer overflow in EIT parsing. - Added a security warning regarding SVDRP to the INSTALL file. +- Fixed 'confirm' dialog. diff --git a/interface.c b/interface.c index 95efe90f..3d01238b 100644 --- a/interface.c +++ b/interface.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: interface.c 1.18 2000/09/18 17:22:09 kls Exp $ + * $Id: interface.c 1.19 2000/09/19 17:41:23 kls Exp $ */ #include "interface.h" @@ -29,11 +29,19 @@ cInterface::cInterface(void) open = 0; cols[0] = 0; keyFromWait = kNone; + SVDRP = NULL; } -void cInterface::Init(void) +void cInterface::Init(int SVDRPport) { RcIo.SetCode(Keys.code, Keys.address); + if (SVDRPport) + SVDRP = new cSVDRP(SVDRPport); +} + +void cInterface::Cleanup(void) +{ + delete SVDRP; } void cInterface::Open(int NumCols, int NumLines) @@ -61,6 +69,8 @@ unsigned int cInterface::GetCh(bool Wait) eKeys cInterface::GetKey(bool Wait) { + if (SVDRP) + SVDRP->Process(); eKeys Key = keyFromWait != kNone ? keyFromWait : Keys.Get(GetCh(Wait)); keyFromWait = kNone; return Key; @@ -74,6 +84,7 @@ void cInterface::PutKey(eKeys Key) eKeys cInterface::Wait(int Seconds, bool KeepChar) { eKeys Key = kNone; + RcIo.Flush(500); if (cFile::AnyFileReady(-1, Seconds * 1000)) Key = GetKey(); if (KeepChar) @@ -223,7 +234,7 @@ void cInterface::QueryKeys(void) Keys.address = Address; WriteText(1, 5, "RC code detected!"); WriteText(1, 6, "Do not press any key..."); - RcIo.Flush(3); + RcIo.Flush(3000); ClearEol(0, 5); ClearEol(0, 6); break; diff --git a/interface.h b/interface.h index e4f7c852..8f7f1b8d 100644 --- a/interface.h +++ b/interface.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: interface.h 1.12 2000/09/17 09:19:43 kls Exp $ + * $Id: interface.h 1.13 2000/09/18 22:29:31 kls Exp $ */ #ifndef __INTERFACE_H @@ -12,6 +12,7 @@ #include "config.h" #include "dvbapi.h" +#include "svdrp.h" class cInterface { public: @@ -20,13 +21,15 @@ private: int open; int cols[MaxCols]; eKeys keyFromWait; + cSVDRP *SVDRP; unsigned int GetCh(bool Wait = true); void QueryKeys(void); void HelpButton(int Index, const char *Text, eDvbColor FgColor, eDvbColor BgColor); eKeys Wait(int Seconds = 1, bool KeepChar = false); public: cInterface(void); - void Init(void); + void Init(int SVDRPport = 0); + void Cleanup(void); void Open(int NumCols = MenuColumns, int NumLines = MenuLines); void Close(void); eKeys GetKey(bool Wait = true); diff --git a/remote.c b/remote.c index 7858a2b2..46565a80 100644 --- a/remote.c +++ b/remote.c @@ -6,7 +6,7 @@ * * Ported to LIRC by Carsten Koch 2000-06-16. * - * $Id: remote.c 1.12 2000/09/16 16:42:30 kls Exp $ + * $Id: remote.c 1.13 2000/09/19 17:40:52 kls Exp $ */ #include "remote.h" @@ -56,15 +56,15 @@ cRcIoKBD::~cRcIoKBD() { } -void cRcIoKBD::Flush(int WaitSeconds) +void cRcIoKBD::Flush(int WaitMs) { - time_t t0 = time(NULL); + int t0 = time_ms(); timeout(10); for (;;) { while (getch() > 0) - t0 = time(NULL); - if (time(NULL) - t0 >= WaitSeconds) + t0 = time_ms(); + if (time_ms() - t0 >= WaitMs) break; } } @@ -172,14 +172,14 @@ bool cRcIoRCU::SetMode(unsigned char Mode) return SendCommand(mode); } -void cRcIoRCU::Flush(int WaitSeconds) +void cRcIoRCU::Flush(int WaitMs) { - time_t t0 = time(NULL); + int t0 = time_ms(); for (;;) { while (ReceiveByte(false) >= 0) - t0 = time(NULL); - if (time(NULL) - t0 >= WaitSeconds) + t0 = time_ms(); + if (time_ms() - t0 >= WaitMs) break; } } @@ -381,17 +381,17 @@ const char *cRcIoLIRC::ReceiveString(void) return NULL; } -void cRcIoLIRC::Flush(int WaitSeconds) +void cRcIoLIRC::Flush(int WaitMs) { char buf[LIRC_BUFFER_SIZE]; - time_t t0 = time(NULL); + int t0 = time_ms(); for (;;) { while (InputAvailable(false)) { read(f, buf, sizeof(buf)); - t0 = time(NULL); + t0 = time_ms(); } - if (time(NULL) - t0 >= WaitSeconds) + if (time_ms() - t0 >= WaitMs) break; } } diff --git a/remote.h b/remote.h index 9346b485..03f91555 100644 --- a/remote.h +++ b/remote.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: remote.h 1.8 2000/09/16 14:01:14 kls Exp $ + * $Id: remote.h 1.9 2000/09/19 17:39:36 kls Exp $ */ #ifndef __REMOTE_H @@ -29,7 +29,7 @@ public: virtual void SetPoints(unsigned char Dp, bool On) {} virtual bool String(char *s) { return true; } virtual bool DetectCode(unsigned char *Code, unsigned short *Address) { return true; } - virtual void Flush(int WaitSeconds = 0) {} + virtual void Flush(int WaitMs = 0) {} virtual bool InputAvailable(bool Wait = false) = 0; virtual bool GetCommand(unsigned int *Command, unsigned short *Address = NULL) = 0; }; @@ -42,7 +42,7 @@ private: public: cRcIoKBD(void); virtual ~cRcIoKBD(); - virtual void Flush(int WaitSeconds = 0); + virtual void Flush(int WaitMs = 0); virtual bool InputAvailable(bool Wait = false); virtual bool GetCommand(unsigned int *Command, unsigned short *Address = NULL); }; @@ -69,7 +69,7 @@ public: virtual void SetPoints(unsigned char Dp, bool On); virtual bool String(char *s); virtual bool DetectCode(unsigned char *Code, unsigned short *Address); - virtual void Flush(int WaitSeconds = 0); + virtual void Flush(int WaitMs = 0); virtual bool InputAvailable(bool Wait = false); virtual bool GetCommand(unsigned int *Command, unsigned short *Address = NULL); }; @@ -85,7 +85,7 @@ private: public: cRcIoLIRC(char *DeviceName); virtual ~cRcIoLIRC(); - virtual void Flush(int WaitSeconds = 0); + virtual void Flush(int WaitMs = 0); virtual bool InputAvailable(bool Wait = false); virtual bool GetCommand(unsigned int *Command, unsigned short *Address = NULL); }; diff --git a/vdr.c b/vdr.c index 2ab32c17..14cf8068 100644 --- a/vdr.c +++ b/vdr.c @@ -22,7 +22,7 @@ * * The project's page is at http://www.cadsoft.de/people/kls/vdr * - * $Id: vdr.c 1.33 2000/09/17 14:15:24 kls Exp $ + * $Id: vdr.c 1.34 2000/09/18 22:29:56 kls Exp $ */ #include @@ -34,7 +34,6 @@ #include "interface.h" #include "menu.h" #include "recording.h" -#include "svdrp.h" #include "tools.h" #include "videodir.h" @@ -176,7 +175,7 @@ int main(int argc, char *argv[]) if (!Keys.Load(AddDirectory(ConfigDirectory, KEYS_CONF))) Interface.LearnKeys(); #endif - Interface.Init(); + Interface.Init(SVDRPport); cDvbApi::SetPrimaryDvbApi(Setup.PrimaryDVB); @@ -191,7 +190,6 @@ int main(int argc, char *argv[]) // Main program loop: - cSVDRP *SVDRP = SVDRPport ? new cSVDRP(SVDRPport) : NULL; cOsdBase *Menu = NULL; cReplayControl *ReplayControl = NULL; int LastChannel = -1; @@ -281,13 +279,11 @@ int main(int argc, char *argv[]) default: break; } } - if (SVDRP) - SVDRP->Process();//TODO lock menu vs. SVDRP? } isyslog(LOG_INFO, "caught signal %d", Interrupted); delete Menu; delete ReplayControl; - delete SVDRP; + Interface.Cleanup(); cDvbApi::Cleanup(); isyslog(LOG_INFO, "exiting"); if (SysLogLevel > 0)