summaryrefslogtreecommitdiff
path: root/vdr.c
diff options
context:
space:
mode:
Diffstat (limited to 'vdr.c')
-rw-r--r--vdr.c194
1 files changed, 117 insertions, 77 deletions
diff --git a/vdr.c b/vdr.c
index beeee88..41d2047 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.127 2002/10/13 12:13:19 kls Exp $
+ * $Id: vdr.c 1.130 2002/10/27 15:20:56 kls Exp $
*/
#include <getopt.h>
@@ -47,6 +47,7 @@
#include "rcu.h"
#include "recording.h"
#include "sources.h"
+#include "timers.h"
#include "tools.h"
#include "videodir.h"
@@ -323,6 +324,7 @@ int main(int argc, char *argv[])
SVDRPhosts.Load(AddDirectory(ConfigDirectory, "svdrphosts.conf"), true);
CaDefinitions.Load(AddDirectory(ConfigDirectory, "ca.conf"), true);
Keys.Load(AddDirectory(ConfigDirectory, "remote.conf"));
+ KeyMacros.Load(AddDirectory(ConfigDirectory, "keymacros.conf"), true);
// DVB interfaces:
@@ -455,6 +457,26 @@ int main(int argc, char *argv[])
Menu = new cMenuMain(cControl::Control());
Temp = NULL;
break;
+ #define DirectMainFunction(function)\
+ DELETENULL(Menu);\
+ if (cControl::Control())\
+ cControl::Control()->Hide();\
+ Menu = new cMenuMain(cControl::Control(), function);\
+ Temp = NULL;
+ case kSchedule: DirectMainFunction(osSchedule); break;
+ case kChannels: DirectMainFunction(osChannels); break;
+ case kTimers: DirectMainFunction(osTimers); break;
+ case kRecordings: DirectMainFunction(osRecordings); break;
+ case kSetup: DirectMainFunction(osSetup); break;
+ case kCommands: DirectMainFunction(osCommands); break;
+ case kUser1 ... kUser9: cRemote::PutMacro(key); break;
+ // Channel up/down:
+ case kChanUp|k_Repeat:
+ case kChanUp:
+ case kChanDn|k_Repeat:
+ case kChanDn:
+ cDevice::SwitchChannel(NORMALKEY(key) == kChanUp ? 1 : -1);
+ break;
// Volume Control:
case kVolUp|k_Repeat:
case kVolUp:
@@ -486,81 +508,99 @@ int main(int argc, char *argv[])
}
LastActivity = 1; // not 0, see below!
break;
- default:
- if (Interact) {
- switch (Interact->ProcessKey(key)) {
- case osRecord: DELETENULL(Menu);
- Temp = NULL;
- if (!cRecordControls::Start())
- Interface->Error(tr("No free DVB device to record!"));
- break;
- case osRecordings:
- DELETENULL(Menu);
- cControl::Shutdown();
- Temp = NULL;
- Menu = new cMenuMain(false, osRecordings);
- break;
- case osReplay: DELETENULL(Menu);
- cControl::Shutdown();
- Temp = NULL;
- cControl::Launch(new cReplayControl);
- break;
- case osStopReplay:
- DELETENULL(Menu);
- cControl::Shutdown();
- Temp = NULL;
- break;
- case osSwitchDvb:
- DELETENULL(Menu);
- cControl::Shutdown();
- Temp = NULL;
- Interface->Info(tr("Switching primary DVB..."));
- cDevice::SetPrimaryDevice(Setup.PrimaryDVB);
- break;
- case osBack:
- case osEnd: if (Interact == Menu)
- DELETENULL(Menu);
- else
- cControl::Shutdown();
- Temp = NULL;
- break;
- default: ;
- }
- }
- else {
- // Key functions in "normal" viewing mode:
- switch (key) {
- // Toggle channels:
- case k0: {
- int CurrentChannel = cDevice::CurrentChannel();
- Channels.SwitchTo(PreviousChannel);
- PreviousChannel = CurrentChannel;
- break;
- }
- // Direct Channel Select:
- case k1 ... k9:
- Menu = new cDisplayChannel(key);
- break;
- // Left/Right rotates trough channel groups:
- case kLeft|k_Repeat:
- case kLeft:
- case kRight|k_Repeat:
- case kRight:
- Menu = new cDisplayChannel(NORMALKEY(key));
- break;
- // Up/Down Channel Select:
- case kUp|k_Repeat:
- case kUp:
- case kDown|k_Repeat:
- case kDown:
- cDevice::SwitchChannel(NORMALKEY(key) == kUp ? 1 : -1);
- break;
- // Viewing Control:
- case kOk: LastChannel = -1; break; // forces channel display
- default: break;
- }
- }
+ default: break;
}
+ Interact = Menu ? Menu : cControl::Control(); // might have been closed in the mean time
+ if (Interact) {
+ eOSState state = Interact->ProcessKey(key);
+ if (state == osUnknown && ISMODELESSKEY(key) && cControl::Control() && Interact != cControl::Control())
+ state = cControl::Control()->ProcessKey(key);
+ switch (state) {
+ case osRecord: DELETENULL(Menu);
+ Temp = NULL;
+ if (cRecordControls::Start())
+ Interface->Info(tr("Recording"));
+ else
+ Interface->Error(tr("No free DVB device to record!"));
+ break;
+ case osRecordings:
+ DELETENULL(Menu);
+ cControl::Shutdown();
+ Temp = NULL;
+ Menu = new cMenuMain(false, osRecordings);
+ break;
+ case osReplay: DELETENULL(Menu);
+ cControl::Shutdown();
+ Temp = NULL;
+ cControl::Launch(new cReplayControl);
+ break;
+ case osStopReplay:
+ DELETENULL(Menu);
+ cControl::Shutdown();
+ Temp = NULL;
+ break;
+ case osSwitchDvb:
+ DELETENULL(Menu);
+ cControl::Shutdown();
+ Temp = NULL;
+ Interface->Info(tr("Switching primary DVB..."));
+ cDevice::SetPrimaryDevice(Setup.PrimaryDVB);
+ break;
+ case osBack:
+ case osEnd: if (Interact == Menu)
+ DELETENULL(Menu);
+ else
+ cControl::Shutdown();
+ Temp = NULL;
+ break;
+ default: ;
+ }
+ }
+ else {
+ // Key functions in "normal" viewing mode:
+ switch (key) {
+ // Toggle channels:
+ case k0: {
+ int CurrentChannel = cDevice::CurrentChannel();
+ Channels.SwitchTo(PreviousChannel);
+ PreviousChannel = CurrentChannel;
+ break;
+ }
+ // Direct Channel Select:
+ case k1 ... k9:
+ Menu = new cDisplayChannel(key);
+ break;
+ // Left/Right rotates trough channel groups:
+ case kLeft|k_Repeat:
+ case kLeft:
+ case kRight|k_Repeat:
+ case kRight:
+ Menu = new cDisplayChannel(NORMALKEY(key));
+ break;
+ // Up/Down Channel Select:
+ case kUp|k_Repeat:
+ case kUp:
+ case kDown|k_Repeat:
+ case kDown:
+ cDevice::SwitchChannel(NORMALKEY(key) == kUp ? 1 : -1);
+ break;
+ // Viewing Control:
+ case kOk: LastChannel = -1; break; // forces channel display
+ // Instant recording:
+ case kRecord:
+ if (cRecordControls::Start())
+ Interface->Info(tr("Recording"));
+ else
+ Interface->Error(tr("No free DVB device to record!"));
+ break;
+ // Key macros:
+ case kRed:
+ case kGreen:
+ case kYellow:
+ case kBlue: cRemote::PutMacro(key); break;
+ default: break;
+ }
+ }
if (!Menu) {
EITScanner.Process();
if (!cCutter::Active() && cCutter::Ended()) {
@@ -603,8 +643,8 @@ int main(int argc, char *argv[])
if (WatchdogTimeout > 0)
signal(SIGALRM, SIG_IGN);
if (Interface->Confirm(tr("Press any key to cancel shutdown"), UserShutdown ? 5 : SHUTDOWNWAIT, true)) {
- int Channel = timer ? timer->channel : 0;
- const char *File = timer ? timer->file : "";
+ int Channel = timer ? timer->Channel()->Number() : 0;
+ const char *File = timer ? timer->File() : "";
char *cmd;
asprintf(&cmd, "%s %ld %ld %d \"%s\" %d", Shutdown, Next, Delta, Channel, strescape(File, "\"$"), UserShutdown);
isyslog("executing '%s'", cmd);