summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2000-10-08 12:24:30 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2000-10-08 12:24:30 +0200
commit19f9f9cfce5dcbd0e5b468da85163f589c1082f2 (patch)
treec829668a8323ef631fb9bc35aed5d639fe9e368d
parent605d8df72ada13ae54fd4452f43f09f94ade87d1 (diff)
downloadvdr-19f9f9cfce5dcbd0e5b468da85163f589c1082f2.tar.gz
vdr-19f9f9cfce5dcbd0e5b468da85163f589c1082f2.tar.bz2
Fixed daemon mode (RcIo and Interface no longer static)
-rw-r--r--config.c6
-rw-r--r--interface.c44
-rw-r--r--interface.h11
-rw-r--r--menu.c38
-rw-r--r--osd.c24
-rw-r--r--recording.c4
-rw-r--r--remote.h4
-rw-r--r--svdrp.c6
-rw-r--r--vdr.c23
9 files changed, 80 insertions, 80 deletions
diff --git a/config.c b/config.c
index e161efd7..5434b575 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.23 2000/09/17 09:11:59 kls Exp $
+ * $Id: config.c 1.24 2000/10/08 12:19:21 kls Exp $
*/
#include "config.h"
@@ -275,7 +275,7 @@ bool cChannel::Switch(cDvbApi *DvbApi)
}
return false;
}
- Interface.Info(DvbApi->Recording() ? "Channel locked (recording)!" : name);
+ Interface->Info(DvbApi->Recording() ? "Channel locked (recording)!" : name);
return false;
}
@@ -566,7 +566,7 @@ eKeys cChannels::ShowChannel(int Number, bool Switched, bool Group)
{
cChannel *channel = Group ? Get(Number) : GetByNumber(Number);
if (channel)
- return Interface.DisplayChannel(channel->number, channel->name, !Switched || Setup.ShowInfoOnChSwitch);
+ return Interface->DisplayChannel(channel->number, channel->name, !Switched || Setup.ShowInfoOnChSwitch);
return kNone;
}
diff --git a/interface.c b/interface.c
index 84ee101c..bb741fc2 100644
--- a/interface.c
+++ b/interface.c
@@ -4,43 +4,39 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: interface.c 1.23 2000/10/08 11:17:11 kls Exp $
+ * $Id: interface.c 1.24 2000/10/08 12:15:36 kls Exp $
*/
#include "interface.h"
#include <unistd.h>
#include "eit.h"
-#include "remote.h"
cEIT EIT;
-#if defined(REMOTE_RCU)
-cRcIoRCU RcIo("/dev/ttyS1");
-#elif defined(REMOTE_LIRC)
-cRcIoLIRC RcIo("/dev/lircd");
-#else
-cRcIoKBD RcIo;
-#endif
-
-cInterface Interface;
+cInterface *Interface = NULL;
-cInterface::cInterface(void)
+cInterface::cInterface(int SVDRPport)
{
open = 0;
cols[0] = 0;
keyFromWait = kNone;
+ rcIo = NULL;
SVDRP = NULL;
-}
-
-void cInterface::Init(int SVDRPport)
-{
- RcIo.SetCode(Keys.code, Keys.address);
+#if defined(REMOTE_RCU)
+ rcIo = new cRcIoRCU("/dev/ttyS1");
+#elif defined(REMOTE_LIRC)
+ rcIo = new cRcIoLIRC("/dev/lircd");
+#else
+ rcIo = new cRcIoKBD;
+#endif
+ rcIo->SetCode(Keys.code, Keys.address);
if (SVDRPport)
SVDRP = new cSVDRP(SVDRPport);
}
-void cInterface::Cleanup(void)
+cInterface::~cInterface()
{
+ delete rcIo;
delete SVDRP;
}
@@ -62,10 +58,10 @@ unsigned int cInterface::GetCh(bool Wait, bool *Repeat, bool *Release)
{
if (open)
cDvbApi::PrimaryDvbApi->Flush();
- if (!RcIo.InputAvailable())
+ if (!rcIo->InputAvailable())
cFile::AnyFileReady(-1, Wait ? 1000 : 0);
unsigned int Command;
- return RcIo.GetCommand(&Command, Repeat, Release) ? Command : 0;
+ return rcIo->GetCommand(&Command, Repeat, Release) ? Command : 0;
}
eKeys cInterface::GetKey(bool Wait)
@@ -245,13 +241,13 @@ void cInterface::QueryKeys(void)
break;
#else
//TODO on screen display...
- if (RcIo.DetectCode(&Code, &Address)) {
+ if (rcIo->DetectCode(&Code, &Address)) {
Keys.code = Code;
Keys.address = Address;
WriteText(1, 5, "RC code detected!");
WriteText(1, 6, "Do not press any key...");
cDvbApi::PrimaryDvbApi->Flush();
- RcIo.Flush(3000);
+ rcIo->Flush(3000);
ClearEol(0, 5);
ClearEol(0, 6);
cDvbApi::PrimaryDvbApi->Flush();
@@ -342,7 +338,7 @@ eKeys cInterface::DisplayChannel(int Number, const char *Name, bool WithInfo)
{
// Number = 0 is used for channel group display and no EIT
if (Number)
- RcIo.Number(Number);
+ rcIo->Number(Number);
if (Name && !Recording()) {
Open(MenuColumns, 5);
cDvbApi::PrimaryDvbApi->Fill(0, 0, MenuColumns, 1, clrBackground);
@@ -401,7 +397,7 @@ eKeys cInterface::DisplayChannel(int Number, const char *Name, bool WithInfo)
void cInterface::DisplayRecording(int Index, bool On)
{
- RcIo.SetPoints(1 << Index, On);
+ rcIo->SetPoints(1 << Index, On);
}
bool cInterface::Recording(void)
diff --git a/interface.h b/interface.h
index e3bce38c..8d0f8f68 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.15 2000/10/08 09:51:42 kls Exp $
+ * $Id: interface.h 1.16 2000/10/08 12:15:49 kls Exp $
*/
#ifndef __INTERFACE_H
@@ -12,6 +12,7 @@
#include "config.h"
#include "dvbapi.h"
+#include "remote.h"
#include "svdrp.h"
class cInterface {
@@ -22,14 +23,14 @@ private:
int cols[MaxCols];
eKeys keyFromWait;
cSVDRP *SVDRP;
+ cRcIoBase *rcIo;
unsigned int GetCh(bool Wait = true, bool *Repeat = NULL, bool *Release = NULL);
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(int SVDRPport = 0);
- void Cleanup(void);
+ cInterface(int SVDRPport = 0);
+ ~cInterface();
void Open(int NumCols = MenuColumns, int NumLines = MenuLines);
void Close(void);
eKeys GetKey(bool Wait = true);
@@ -51,6 +52,6 @@ public:
bool Recording(void);
};
-extern cInterface Interface;
+extern cInterface *Interface;
#endif //__INTERFACE_H
diff --git a/menu.c b/menu.c
index cc7618ba..e7baa672 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.31 2000/10/08 10:47:17 kls Exp $
+ * $Id: menu.c 1.32 2000/10/08 12:20:03 kls Exp $
*/
#include "menu.h"
@@ -641,11 +641,11 @@ eOSState cMenuChannels::Del(void)
// Check if there is a timer using this channel:
for (cTimer *ti = Timers.First(); ti; ti = (cTimer *)ti->Next()) {
if (ti->channel == DeletedChannel) {
- Interface.Error("Channel is being used by a timer!");
+ Interface->Error("Channel is being used by a timer!");
return osContinue;
}
}
- if (Interface.Confirm("Delete Channel?")) {
+ if (Interface->Confirm("Delete Channel?")) {
// Move and renumber the channels:
Channels.Del(channel);
Channels.ReNumber();
@@ -922,7 +922,7 @@ eOSState cMenuTimers::Del(void)
cTimer *ti = Timers.Get(Index);
if (ti) {
if (!ti->recording) {
- if (Interface.Confirm("Delete Timer?")) {
+ if (Interface->Confirm("Delete Timer?")) {
Timers.Del(Timers.Get(Index));
cOsdMenu::Del(Index);
Timers.Save();
@@ -931,7 +931,7 @@ eOSState cMenuTimers::Del(void)
}
}
else
- Interface.Error("Timer is recording!");
+ Interface->Error("Timer is recording!");
}
return osContinue;
}
@@ -1036,17 +1036,17 @@ eOSState cMenuRecordings::Del(void)
if (ri) {
//XXX what if this recording's file is currently in use???
//XXX if (!ti->recording) {
- if (Interface.Confirm("Delete Recording?")) {
+ if (Interface->Confirm("Delete Recording?")) {
if (ri->recording->Delete()) {
cOsdMenu::Del(Current());
Display();
}
else
- Interface.Error("Error while deleting recording!");
+ Interface->Error("Error while deleting recording!");
}
//XXX }
//XXX else
-//XXX Interface.Error("Timer is recording!");
+//XXX Interface->Error("Timer is recording!");
}
return osContinue;
}
@@ -1146,7 +1146,7 @@ eOSState cMenuMain::ProcessKey(eKeys Key)
case osTimer: return AddSubMenu(new cMenuTimers);
case osRecordings: return AddSubMenu(new cMenuRecordings);
case osSetup: return AddSubMenu(new cMenuSetup);
- case osStopRecord: if (Interface.Confirm("Stop Recording?")) {
+ case osStopRecord: if (Interface->Confirm("Stop Recording?")) {
cOsdItem *item = Get(Current());
if (item) {
cRecordControls::Stop(item->Text() + strlen(STOP_RECORDING));
@@ -1178,15 +1178,15 @@ cDirectChannelSelect::cDirectChannelSelect(eKeys FirstKey)
oldNumber = CurrentChannel;
number = 0;
lastTime = time_ms();
- Interface.Open(MenuColumns, 1);
+ Interface->Open(MenuColumns, 1);
ProcessKey(FirstKey);
}
cDirectChannelSelect::~cDirectChannelSelect()
{
if (number < 0)
- Interface.DisplayChannel(oldNumber);
- Interface.Close();
+ Interface->DisplayChannel(oldNumber);
+ Interface->Close();
}
eOSState cDirectChannelSelect::ProcessKey(eKeys Key)
@@ -1200,9 +1200,9 @@ eOSState cDirectChannelSelect::ProcessKey(eKeys Key)
int BufSize = MenuColumns + 1;
char buffer[BufSize];
snprintf(buffer, BufSize, "%d %s", number, Name);
- Interface.DisplayChannel(number);
- Interface.Clear();
- Interface.Write(0, 0, buffer);
+ Interface->DisplayChannel(number);
+ Interface->Clear();
+ Interface->Write(0, 0, buffer);
lastTime = time_ms();
if (!channel) {
number = -1;
@@ -1241,14 +1241,14 @@ cRecordControl::cRecordControl(cDvbApi *DvbApi, cTimer *Timer)
cRecording Recording(timer);
if (dvbApi->StartRecord(Recording.FileName()))
Recording.WriteSummary();
- Interface.DisplayRecording(dvbApi->Index(), true);
+ Interface->DisplayRecording(dvbApi->Index(), true);
}
cRecordControl::~cRecordControl()
{
Stop(true);
delete instantId;
- Interface.DisplayRecording(dvbApi->Index(), false);
+ Interface->DisplayRecording(dvbApi->Index(), false);
}
void cRecordControl::Stop(bool KeepInstant)
@@ -1366,7 +1366,7 @@ void cReplayControl::SetRecording(const char *FileName, const char *Title)
void cReplayControl::Show(void)
{
if (!visible) {
- Interface.Open(MenuColumns, -3);
+ Interface->Open(MenuColumns, -3);
needsFastResponse = visible = true;
shown = dvbApi->ShowProgress(true);
}
@@ -1375,7 +1375,7 @@ void cReplayControl::Show(void)
void cReplayControl::Hide(void)
{
if (visible) {
- Interface.Close();
+ Interface->Close();
needsFastResponse = visible = false;
}
}
diff --git a/osd.c b/osd.c
index 6874ba9f..75d9eade 100644
--- a/osd.c
+++ b/osd.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: osd.c 1.8 2000/10/08 10:27:04 kls Exp $
+ * $Id: osd.c 1.9 2000/10/08 12:20:34 kls Exp $
*/
#include "osd.h"
@@ -64,7 +64,7 @@ void cOsdItem::Display(int Offset, eDvbColor FgColor, eDvbColor BgColor)
if (Offset >= 0)
offset = Offset;
if (offset >= 0)
- Interface.WriteText(0, offset + 2, text, userColor ? fgColor : FgColor, userColor ? bgColor : BgColor);
+ Interface->WriteText(0, offset + 2, text, userColor ? fgColor : FgColor, userColor ? bgColor : BgColor);
}
eOSState cOsdItem::ProcessKey(eKeys Key)
@@ -88,7 +88,7 @@ cOsdMenu::cOsdMenu(char *Title, int c0, int c1, int c2, int c3, int c4)
subMenu = NULL;
helpRed = helpGreen = helpYellow = helpBlue = NULL;
status = NULL;
- Interface.Open();
+ Interface->Open();
}
cOsdMenu::~cOsdMenu()
@@ -96,8 +96,8 @@ cOsdMenu::~cOsdMenu()
delete title;
delete subMenu;
delete status;
- Interface.Clear();
- Interface.Close();
+ Interface->Clear();
+ Interface->Close();
}
void cOsdMenu::SetStatus(const char *s)
@@ -105,7 +105,7 @@ void cOsdMenu::SetStatus(const char *s)
delete status;
status = s ? strdup(s) : NULL;
if (visible)
- Interface.Status(status);
+ Interface->Status(status);
}
void cOsdMenu::SetHelp(const char *Red, const char *Green, const char *Yellow, const char *Blue)
@@ -117,7 +117,7 @@ void cOsdMenu::SetHelp(const char *Red, const char *Green, const char *Yellow, c
helpBlue = Blue;
if (visible)
Display();
- //XXX Interface.Help(helpRed, helpGreen, helpYellow, helpBlue);
+ //XXX Interface->Help(helpRed, helpGreen, helpYellow, helpBlue);
//XXX must clear unused button areas!
}
@@ -140,10 +140,10 @@ void cOsdMenu::Add(cOsdItem *Item, bool Current)
void cOsdMenu::Display(void)
{
visible = true;
- Interface.Clear();
- Interface.SetCols(cols);
- Interface.Title(title);
- Interface.Help(helpRed, helpGreen, helpYellow, helpBlue);
+ Interface->Clear();
+ Interface->SetCols(cols);
+ Interface->Title(title);
+ Interface->Help(helpRed, helpGreen, helpYellow, helpBlue);
int count = Count();
if (count > 0) {
if (current < 0)
@@ -164,7 +164,7 @@ void cOsdMenu::Display(void)
break;
}
}
- Interface.Status(status);
+ Interface->Status(status);
}
void cOsdMenu::RefreshCurrent(void)
diff --git a/recording.c b/recording.c
index 60ea4a1c..f9ab0162 100644
--- a/recording.c
+++ b/recording.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: recording.c 1.18 2000/10/03 12:39:28 kls Exp $
+ * $Id: recording.c 1.19 2000/10/08 12:20:53 kls Exp $
*/
#define _GNU_SOURCE
@@ -254,7 +254,7 @@ bool cRecordings::Load(bool Deleted)
result = Count() > 0;
}
else
- Interface.Error("Error while opening pipe!");
+ Interface->Error("Error while opening pipe!");
delete cmd;
return result;
}
diff --git a/remote.h b/remote.h
index 1e779b0b..0ea4442a 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.12 2000/10/08 11:19:17 kls Exp $
+ * $Id: remote.h 1.13 2000/10/08 12:11:34 kls Exp $
*/
#ifndef __REMOTE_H
@@ -19,9 +19,9 @@ class cRcIoBase {
protected:
time_t t;
cRcIoBase(void);
- virtual ~cRcIoBase();
public:
enum { modeH = 'h', modeB = 'b', modeS = 's' };
+ virtual ~cRcIoBase();
virtual bool SetCode(unsigned char Code, unsigned short Address) { return true; }
virtual bool SetMode(unsigned char Mode) { return true; }
virtual bool Number(int n, bool Hex = false) { return true; }
diff --git a/svdrp.c b/svdrp.c
index c9ea7c38..cf91cafb 100644
--- a/svdrp.c
+++ b/svdrp.c
@@ -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.10 2000/09/17 13:39:37 kls Exp $
+ * $Id: svdrp.c 1.11 2000/10/08 12:21:14 kls Exp $
*/
#define _GNU_SOURCE
@@ -326,7 +326,7 @@ void cSVDRP::CmdCHAN(const char *Option)
Reply(501, "Undefined channel \"%s\"", Option);
return;
}
- if (Interface.Recording()) {
+ if (Interface->Recording()) {
Reply(550, "Can't switch channel, interface is recording");
return;
}
@@ -474,7 +474,7 @@ void cSVDRP::CmdHITK(const char *Option)
if (*Option) {
eKeys k = Keys.Translate(Option);
if (k != kNone) {
- Interface.PutKey(k);
+ Interface->PutKey(k);
Reply(250, "Key \"%s\" accepted", Option);
}
else
diff --git a/vdr.c b/vdr.c
index 379b6b45..d527270e 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.37 2000/10/08 10:32:44 kls Exp $
+ * $Id: vdr.c 1.38 2000/10/08 12:24:30 kls Exp $
*/
#include <getopt.h>
@@ -161,6 +161,10 @@ int main(int argc, char *argv[])
if (!cDvbApi::Init())
abort();
+ // User interface:
+
+ Interface = new cInterface(SVDRPport);
+
// Configuration data:
if (!ConfigDirectory)
@@ -173,9 +177,8 @@ int main(int argc, char *argv[])
Keys.SetDummyValues();
#else
if (!Keys.Load(AddDirectory(ConfigDirectory, KEYS_CONF)))
- Interface.LearnKeys();
+ Interface->LearnKeys();
#endif
- Interface.Init(SVDRPport);
cDvbApi::SetPrimaryDvbApi(Setup.PrimaryDVB);
@@ -215,7 +218,7 @@ int main(int argc, char *argv[])
}
// User Input:
cOsdBase **Interact = Menu ? &Menu : (cOsdBase **)&ReplayControl;
- eKeys key = Interface.GetKey(!*Interact || !(*Interact)->NeedsFastResponse());
+ eKeys key = Interface->GetKey(!*Interact || !(*Interact)->NeedsFastResponse());
if (*Interact) {
switch ((*Interact)->ProcessKey(key)) {
case osMenu: DELETENULL(Menu);
@@ -223,7 +226,7 @@ int main(int argc, char *argv[])
break;
case osRecord: DELETENULL(Menu);
if (!cRecordControls::Start())
- Interface.Error("No free DVB device to record!");
+ Interface->Error("No free DVB device to record!");
break;
case osReplay: DELETENULL(Menu);
DELETENULL(ReplayControl);
@@ -235,7 +238,7 @@ int main(int argc, char *argv[])
break;
case osSwitchDvb:
DELETENULL(*Interact);
- Interface.Info("Switching primary DVB...");
+ Interface->Info("Switching primary DVB...");
cDvbApi::SetPrimaryDvbApi(Setup.PrimaryDVB);
break;
case osBack:
@@ -253,14 +256,14 @@ int main(int argc, char *argv[])
break;
// Direct Channel Select:
case k1 ... k9:
- if (!Interface.Recording())
+ if (!Interface->Recording())
Menu = new cDirectChannelSelect(key);
break;
// Left/Right rotates trough channel groups:
case kLeft|k_Repeat:
case kLeft:
case kRight|k_Repeat:
- case kRight: if (!Interface.Recording()) {
+ case kRight: if (!Interface->Recording()) {
int SaveGroup = CurrentGroup;
if (NORMALKEY(key) == kRight)
CurrentGroup = Channels.GetNextGroup(CurrentGroup) ;
@@ -276,7 +279,7 @@ int main(int argc, char *argv[])
case kUp|k_Repeat:
case kUp:
case kDown|k_Repeat:
- case kDown: if (!Interface.Recording()) {
+ case kDown: if (!Interface->Recording()) {
int n = CurrentChannel + (NORMALKEY(key) == kUp ? 1 : -1);
cChannel *channel = Channels.GetByNumber(n);
if (channel)
@@ -294,7 +297,7 @@ int main(int argc, char *argv[])
isyslog(LOG_INFO, "caught signal %d", Interrupted);
delete Menu;
delete ReplayControl;
- Interface.Cleanup();
+ delete Interface;
cDvbApi::Cleanup();
isyslog(LOG_INFO, "exiting");
if (SysLogLevel > 0)