2000-02-19 13:36:48 +01:00
|
|
|
/*
|
|
|
|
* menu.c: The actual menu implementations
|
|
|
|
*
|
2000-04-24 09:46:05 +02:00
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
2000-02-19 13:36:48 +01:00
|
|
|
* how to reach the author.
|
|
|
|
*
|
2006-07-23 09:26:50 +02:00
|
|
|
* $Id: menu.c 1.443 2006/07/23 09:23:11 kls Exp $
|
2000-02-19 13:36:48 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "menu.h"
|
2002-04-13 10:52:01 +02:00
|
|
|
#include <ctype.h>
|
2000-02-19 13:36:48 +01:00
|
|
|
#include <limits.h>
|
|
|
|
#include <stdio.h>
|
2000-10-29 13:17:22 +01:00
|
|
|
#include <stdlib.h>
|
2000-02-19 13:36:48 +01:00
|
|
|
#include <string.h>
|
2002-10-06 10:25:42 +02:00
|
|
|
#include "channels.h"
|
2000-02-19 13:36:48 +01:00
|
|
|
#include "config.h"
|
2002-06-22 10:11:59 +02:00
|
|
|
#include "cutter.h"
|
2004-01-17 15:38:11 +01:00
|
|
|
#include "eitscan.h"
|
2000-11-11 10:39:27 +01:00
|
|
|
#include "i18n.h"
|
2004-05-16 10:35:36 +02:00
|
|
|
#include "interface.h"
|
2002-05-09 16:26:56 +02:00
|
|
|
#include "plugin.h"
|
2002-06-16 12:57:31 +02:00
|
|
|
#include "recording.h"
|
2002-09-29 13:40:45 +02:00
|
|
|
#include "remote.h"
|
2002-10-06 10:25:42 +02:00
|
|
|
#include "sources.h"
|
2002-05-19 15:50:11 +02:00
|
|
|
#include "status.h"
|
2004-05-16 10:35:36 +02:00
|
|
|
#include "themes.h"
|
2002-10-20 12:28:55 +02:00
|
|
|
#include "timers.h"
|
2003-08-24 14:47:34 +02:00
|
|
|
#include "transfer.h"
|
2002-01-27 13:11:23 +01:00
|
|
|
#include "videodir.h"
|
2000-02-19 13:36:48 +01:00
|
|
|
|
2003-04-27 12:51:01 +02:00
|
|
|
#define MAXWAIT4EPGINFO 3 // seconds
|
2001-09-14 14:06:43 +02:00
|
|
|
#define MODETIMEOUT 3 // seconds
|
2005-12-24 15:53:53 +01:00
|
|
|
#define DISKSPACECHEK 5 // seconds between disk space checks in the main menu
|
2006-04-16 10:29:48 +02:00
|
|
|
#define NEWTIMERLIMIT 120 // seconds until the start time of a new timer created from the Schedule menu,
|
|
|
|
// within which it will go directly into the "Edit timer" menu to allow
|
|
|
|
// further parameter settings
|
2000-05-01 16:29:46 +02:00
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
#define MAXRECORDCONTROLS (MAXDEVICES * MAXRECEIVERS)
|
2002-04-26 13:43:46 +02:00
|
|
|
#define MAXINSTANTRECTIME (24 * 60 - 1) // 23:59 hours
|
2005-10-02 14:43:56 +02:00
|
|
|
#define MAXWAITFORCAMMENU 4 // seconds to wait for the CAM menu to open
|
2006-06-24 10:22:57 +02:00
|
|
|
#define MINFREEDISK 300 // minimum free disk space (in MB) required to start recording
|
2006-01-20 16:34:56 +01:00
|
|
|
#define NODISKSPACEDELTA 300 // seconds between "Not enough disk space to start recording!" messages
|
2002-04-26 13:43:46 +02:00
|
|
|
|
2002-10-19 15:33:37 +02:00
|
|
|
#define CHNUMWIDTH (numdigits(Channels.MaxNumber()) + 1)
|
2002-03-29 10:50:20 +01:00
|
|
|
|
2002-03-03 16:12:29 +01:00
|
|
|
// --- cMenuEditCaItem -------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuEditCaItem : public cMenuEditIntItem {
|
|
|
|
protected:
|
|
|
|
virtual void Set(void);
|
|
|
|
public:
|
2006-01-07 14:10:17 +01:00
|
|
|
cMenuEditCaItem(const char *Name, int *Value);
|
2002-03-03 16:12:29 +01:00
|
|
|
eOSState ProcessKey(eKeys Key);
|
|
|
|
};
|
|
|
|
|
2006-01-07 14:10:17 +01:00
|
|
|
cMenuEditCaItem::cMenuEditCaItem(const char *Name, int *Value)
|
2002-03-03 16:12:29 +01:00
|
|
|
:cMenuEditIntItem(Name, Value, 0)
|
|
|
|
{
|
|
|
|
Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuEditCaItem::Set(void)
|
|
|
|
{
|
2006-01-07 14:10:17 +01:00
|
|
|
if (*value == CA_FTA)
|
|
|
|
SetValue(tr("Free To Air"));
|
|
|
|
else if (*value >= CA_ENCRYPTED_MIN)
|
|
|
|
SetValue(tr("encrypted"));
|
2002-03-03 16:12:29 +01:00
|
|
|
else
|
|
|
|
cMenuEditIntItem::Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuEditCaItem::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
eOSState state = cMenuEditItem::ProcessKey(Key);
|
|
|
|
|
|
|
|
if (state == osUnknown) {
|
2006-01-07 14:10:17 +01:00
|
|
|
if (NORMALKEY(Key) == kLeft && *value >= CA_ENCRYPTED_MIN)
|
|
|
|
*value = CA_FTA;
|
2002-03-03 16:12:29 +01:00
|
|
|
else
|
|
|
|
return cMenuEditIntItem::ProcessKey(Key);
|
|
|
|
Set();
|
|
|
|
state = osContinue;
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2002-10-06 10:25:42 +02:00
|
|
|
// --- cMenuEditSrcItem ------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuEditSrcItem : public cMenuEditIntItem {
|
|
|
|
private:
|
|
|
|
const cSource *source;
|
|
|
|
protected:
|
|
|
|
virtual void Set(void);
|
|
|
|
public:
|
|
|
|
cMenuEditSrcItem(const char *Name, int *Value);
|
|
|
|
eOSState ProcessKey(eKeys Key);
|
|
|
|
};
|
|
|
|
|
|
|
|
cMenuEditSrcItem::cMenuEditSrcItem(const char *Name, int *Value)
|
|
|
|
:cMenuEditIntItem(Name, Value, 0)
|
|
|
|
{
|
|
|
|
source = Sources.Get(*Value);
|
|
|
|
Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuEditSrcItem::Set(void)
|
|
|
|
{
|
|
|
|
if (source) {
|
|
|
|
char *buffer = NULL;
|
2004-12-26 12:45:22 +01:00
|
|
|
asprintf(&buffer, "%s - %s", *cSource::ToString(source->Code()), source->Description());
|
2002-10-06 10:25:42 +02:00
|
|
|
SetValue(buffer);
|
|
|
|
free(buffer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cMenuEditIntItem::Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuEditSrcItem::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
eOSState state = cMenuEditItem::ProcessKey(Key);
|
|
|
|
|
|
|
|
if (state == osUnknown) {
|
|
|
|
if (NORMALKEY(Key) == kLeft) { // TODO might want to increase the delta if repeated quickly?
|
|
|
|
if (source && source->Prev()) {
|
|
|
|
source = (cSource *)source->Prev();
|
|
|
|
*value = source->Code();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (NORMALKEY(Key) == kRight) {
|
2003-12-22 13:29:24 +01:00
|
|
|
if (source) {
|
2002-10-06 10:25:42 +02:00
|
|
|
if (source->Next())
|
|
|
|
source = (cSource *)source->Next();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
source = Sources.First();
|
|
|
|
if (source)
|
|
|
|
*value = source->Code();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return state; // we don't call cMenuEditIntItem::ProcessKey(Key) here since we don't accept numerical input
|
|
|
|
Set();
|
|
|
|
state = osContinue;
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuEditMapItem ------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuEditMapItem : public cMenuEditItem {
|
|
|
|
protected:
|
|
|
|
int *value;
|
|
|
|
const tChannelParameterMap *map;
|
|
|
|
const char *zeroString;
|
|
|
|
virtual void Set(void);
|
|
|
|
public:
|
|
|
|
cMenuEditMapItem(const char *Name, int *Value, const tChannelParameterMap *Map, const char *ZeroString = NULL);
|
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
|
|
|
};
|
|
|
|
|
|
|
|
cMenuEditMapItem::cMenuEditMapItem(const char *Name, int *Value, const tChannelParameterMap *Map, const char *ZeroString)
|
|
|
|
:cMenuEditItem(Name)
|
|
|
|
{
|
|
|
|
value = Value;
|
|
|
|
map = Map;
|
|
|
|
zeroString = ZeroString;
|
|
|
|
Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuEditMapItem::Set(void)
|
|
|
|
{
|
|
|
|
int n = MapToUser(*value, map);
|
|
|
|
if (n == 999)
|
|
|
|
SetValue(tr("auto"));
|
|
|
|
else if (n == 0 && zeroString)
|
|
|
|
SetValue(zeroString);
|
|
|
|
else if (n >= 0) {
|
|
|
|
char buf[16];
|
|
|
|
snprintf(buf, sizeof(buf), "%d", n);
|
|
|
|
SetValue(buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetValue("???");
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuEditMapItem::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
eOSState state = cMenuEditItem::ProcessKey(Key);
|
|
|
|
|
|
|
|
if (state == osUnknown) {
|
|
|
|
int newValue = *value;
|
|
|
|
int n = DriverIndex(*value, map);
|
|
|
|
if (NORMALKEY(Key) == kLeft) { // TODO might want to increase the delta if repeated quickly?
|
|
|
|
if (n-- > 0)
|
|
|
|
newValue = map[n].driverValue;
|
|
|
|
}
|
|
|
|
else if (NORMALKEY(Key) == kRight) {
|
|
|
|
if (map[++n].userValue >= 0)
|
|
|
|
newValue = map[n].driverValue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return state;
|
|
|
|
if (newValue != *value) {
|
|
|
|
*value = newValue;
|
|
|
|
Set();
|
|
|
|
}
|
|
|
|
state = osContinue;
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2000-02-19 13:36:48 +01:00
|
|
|
// --- cMenuEditChannel ------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuEditChannel : public cOsdMenu {
|
|
|
|
private:
|
|
|
|
cChannel *channel;
|
|
|
|
cChannel data;
|
2004-10-31 12:53:00 +01:00
|
|
|
char name[256];
|
2002-10-06 10:25:42 +02:00
|
|
|
void Setup(void);
|
2000-02-19 13:36:48 +01:00
|
|
|
public:
|
2002-11-10 15:50:21 +01:00
|
|
|
cMenuEditChannel(cChannel *Channel, bool New = false);
|
2000-03-11 11:22:37 +01:00
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
2000-02-19 13:36:48 +01:00
|
|
|
};
|
|
|
|
|
2002-11-10 15:50:21 +01:00
|
|
|
cMenuEditChannel::cMenuEditChannel(cChannel *Channel, bool New)
|
2005-10-09 11:23:18 +02:00
|
|
|
:cOsdMenu(tr("Edit channel"), 16)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2002-11-10 15:50:21 +01:00
|
|
|
channel = Channel;
|
2000-02-19 13:36:48 +01:00
|
|
|
if (channel) {
|
|
|
|
data = *channel;
|
2004-02-13 13:36:52 +01:00
|
|
|
if (New) {
|
2002-11-10 15:50:21 +01:00
|
|
|
channel = NULL;
|
2004-02-13 13:36:52 +01:00
|
|
|
data.nid = 0;
|
|
|
|
data.tid = 0;
|
|
|
|
data.rid = 0;
|
|
|
|
}
|
2002-10-06 10:25:42 +02:00
|
|
|
Setup();
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-06 10:25:42 +02:00
|
|
|
void cMenuEditChannel::Setup(void)
|
|
|
|
{
|
|
|
|
int current = Current();
|
2004-12-26 12:45:22 +01:00
|
|
|
char type = **cSource::ToString(data.source);
|
2002-10-06 10:25:42 +02:00
|
|
|
#define ST(s) if (strchr(s, type))
|
|
|
|
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
// Parameters for all types of sources:
|
2004-10-31 12:53:00 +01:00
|
|
|
strn0cpy(name, data.name, sizeof(name));
|
|
|
|
Add(new cMenuEditStrItem( tr("Name"), name, sizeof(name), tr(FileNameChars)));
|
2002-10-06 10:25:42 +02:00
|
|
|
Add(new cMenuEditSrcItem( tr("Source"), &data.source));
|
|
|
|
Add(new cMenuEditIntItem( tr("Frequency"), &data.frequency));
|
|
|
|
Add(new cMenuEditIntItem( tr("Vpid"), &data.vpid, 0, 0x1FFF));
|
2003-04-26 11:58:54 +02:00
|
|
|
Add(new cMenuEditIntItem( tr("Ppid"), &data.ppid, 0, 0x1FFF));
|
2004-01-25 15:32:08 +01:00
|
|
|
Add(new cMenuEditIntItem( tr("Apid1"), &data.apids[0], 0, 0x1FFF));
|
|
|
|
Add(new cMenuEditIntItem( tr("Apid2"), &data.apids[1], 0, 0x1FFF));
|
|
|
|
Add(new cMenuEditIntItem( tr("Dpid1"), &data.dpids[0], 0, 0x1FFF));
|
|
|
|
Add(new cMenuEditIntItem( tr("Dpid2"), &data.dpids[1], 0, 0x1FFF));
|
2002-10-06 10:25:42 +02:00
|
|
|
Add(new cMenuEditIntItem( tr("Tpid"), &data.tpid, 0, 0x1FFF));
|
2006-01-07 14:10:17 +01:00
|
|
|
Add(new cMenuEditCaItem( tr("CA"), &data.caids[0]));
|
2004-02-13 13:36:52 +01:00
|
|
|
Add(new cMenuEditIntItem( tr("Sid"), &data.sid, 1, 0xFFFF));
|
2002-11-24 14:48:38 +01:00
|
|
|
/* XXX not yet used
|
|
|
|
Add(new cMenuEditIntItem( tr("Nid"), &data.nid, 0));
|
|
|
|
Add(new cMenuEditIntItem( tr("Tid"), &data.tid, 0));
|
|
|
|
Add(new cMenuEditIntItem( tr("Rid"), &data.rid, 0));
|
|
|
|
XXX*/
|
2002-10-06 10:25:42 +02:00
|
|
|
// Parameters for specific types of sources:
|
2005-01-09 13:18:15 +01:00
|
|
|
ST(" S ") Add(new cMenuEditChrItem( tr("Polarization"), &data.polarization, "hvlr"));
|
2002-10-06 10:25:42 +02:00
|
|
|
ST("CS ") Add(new cMenuEditIntItem( tr("Srate"), &data.srate));
|
|
|
|
ST("CST") Add(new cMenuEditMapItem( tr("Inversion"), &data.inversion, InversionValues, tr("off")));
|
|
|
|
ST("CST") Add(new cMenuEditMapItem( tr("CoderateH"), &data.coderateH, CoderateValues, tr("none")));
|
|
|
|
ST(" T") Add(new cMenuEditMapItem( tr("CoderateL"), &data.coderateL, CoderateValues, tr("none")));
|
|
|
|
ST("C T") Add(new cMenuEditMapItem( tr("Modulation"), &data.modulation, ModulationValues, "QPSK"));
|
|
|
|
ST(" T") Add(new cMenuEditMapItem( tr("Bandwidth"), &data.bandwidth, BandwidthValues));
|
|
|
|
ST(" T") Add(new cMenuEditMapItem( tr("Transmission"), &data.transmission, TransmissionValues));
|
|
|
|
ST(" T") Add(new cMenuEditMapItem( tr("Guard"), &data.guard, GuardValues));
|
|
|
|
ST(" T") Add(new cMenuEditMapItem( tr("Hierarchy"), &data.hierarchy, HierarchyValues, tr("none")));
|
|
|
|
|
|
|
|
SetCurrent(Get(current));
|
|
|
|
Display();
|
|
|
|
}
|
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState cMenuEditChannel::ProcessKey(eKeys Key)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2002-10-06 10:25:42 +02:00
|
|
|
int oldSource = data.source;
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
2000-02-19 13:36:48 +01:00
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
if (state == osUnknown) {
|
2000-02-19 13:36:48 +01:00
|
|
|
if (Key == kOk) {
|
2002-11-10 15:50:21 +01:00
|
|
|
if (Channels.HasUniqueChannelID(&data, channel)) {
|
2004-10-31 12:53:00 +01:00
|
|
|
data.name = strcpyrealloc(data.name, name);
|
2002-11-10 15:50:21 +01:00
|
|
|
if (channel) {
|
|
|
|
*channel = data;
|
2004-12-26 12:45:22 +01:00
|
|
|
isyslog("edited channel %d %s", channel->Number(), *data.ToText());
|
2002-11-10 15:50:21 +01:00
|
|
|
state = osBack;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
channel = new cChannel;
|
|
|
|
*channel = data;
|
|
|
|
Channels.Add(channel);
|
|
|
|
Channels.ReNumber();
|
2004-12-26 12:45:22 +01:00
|
|
|
isyslog("added channel %d %s", channel->Number(), *data.ToText());
|
2002-11-10 15:50:21 +01:00
|
|
|
state = osUser1;
|
|
|
|
}
|
2004-10-17 11:50:21 +02:00
|
|
|
Channels.SetModified(true);
|
2002-11-10 15:50:21 +01:00
|
|
|
}
|
|
|
|
else {
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtError, tr("Channel settings are not unique!"));
|
2002-11-10 15:50:21 +01:00
|
|
|
state = osContinue;
|
|
|
|
}
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
}
|
2002-10-06 10:25:42 +02:00
|
|
|
if (Key != kNone && (data.source & cSource::st_Mask) != (oldSource & cSource::st_Mask))
|
|
|
|
Setup();
|
2000-03-11 11:22:37 +01:00
|
|
|
return state;
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuChannelItem ------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuChannelItem : public cOsdItem {
|
2004-11-01 13:59:58 +01:00
|
|
|
public:
|
|
|
|
enum eChannelSortMode { csmNumber, csmName, csmProvider };
|
2000-02-19 13:36:48 +01:00
|
|
|
private:
|
2004-11-01 13:59:58 +01:00
|
|
|
static eChannelSortMode sortMode;
|
2000-02-19 13:36:48 +01:00
|
|
|
cChannel *channel;
|
|
|
|
public:
|
2002-10-20 12:28:55 +02:00
|
|
|
cMenuChannelItem(cChannel *Channel);
|
2004-11-01 13:59:58 +01:00
|
|
|
static void SetSortMode(eChannelSortMode SortMode) { sortMode = SortMode; }
|
|
|
|
static void IncSortMode(void) { sortMode = eChannelSortMode((sortMode == csmProvider) ? csmNumber : sortMode + 1); }
|
2006-01-15 13:09:16 +01:00
|
|
|
static eChannelSortMode SortMode(void) { return sortMode; }
|
2004-11-01 13:59:58 +01:00
|
|
|
virtual int Compare(const cListObject &ListObject) const;
|
2000-02-19 13:36:48 +01:00
|
|
|
virtual void Set(void);
|
2002-12-22 12:49:10 +01:00
|
|
|
cChannel *Channel(void) { return channel; }
|
2000-02-19 13:36:48 +01:00
|
|
|
};
|
|
|
|
|
2004-11-01 13:59:58 +01:00
|
|
|
cMenuChannelItem::eChannelSortMode cMenuChannelItem::sortMode = csmNumber;
|
|
|
|
|
2002-10-20 12:28:55 +02:00
|
|
|
cMenuChannelItem::cMenuChannelItem(cChannel *Channel)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
|
|
|
channel = Channel;
|
2002-10-06 10:25:42 +02:00
|
|
|
if (channel->GroupSep())
|
2004-05-16 10:35:36 +02:00
|
|
|
SetSelectable(false);
|
2000-02-19 13:36:48 +01:00
|
|
|
Set();
|
|
|
|
}
|
|
|
|
|
2004-11-01 13:59:58 +01:00
|
|
|
int cMenuChannelItem::Compare(const cListObject &ListObject) const
|
|
|
|
{
|
|
|
|
cMenuChannelItem *p = (cMenuChannelItem *)&ListObject;
|
|
|
|
int r = -1;
|
|
|
|
if (sortMode == csmProvider)
|
|
|
|
r = strcoll(channel->Provider(), p->channel->Provider());
|
|
|
|
if (sortMode == csmName || r == 0)
|
|
|
|
r = strcoll(channel->Name(), p->channel->Name());
|
|
|
|
if (sortMode == csmNumber || r == 0)
|
|
|
|
r = channel->Number() - p->channel->Number();
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2000-02-19 13:36:48 +01:00
|
|
|
void cMenuChannelItem::Set(void)
|
|
|
|
{
|
|
|
|
char *buffer = NULL;
|
2004-11-01 13:59:58 +01:00
|
|
|
if (!channel->GroupSep()) {
|
|
|
|
if (sortMode == csmProvider)
|
|
|
|
asprintf(&buffer, "%d\t%s - %s", channel->Number(), channel->Provider(), channel->Name());
|
|
|
|
else
|
|
|
|
asprintf(&buffer, "%d\t%s", channel->Number(), channel->Name());
|
|
|
|
}
|
2000-09-09 14:57:43 +02:00
|
|
|
else
|
2002-10-06 10:25:42 +02:00
|
|
|
asprintf(&buffer, "---\t%s ----------------------------------------------------------------", channel->Name());
|
2000-02-19 13:36:48 +01:00
|
|
|
SetText(buffer, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuChannels ---------------------------------------------------------
|
|
|
|
|
2006-01-05 13:43:07 +01:00
|
|
|
#define CHANNELNUMBERTIMEOUT 1000 //ms
|
|
|
|
|
2000-02-19 13:36:48 +01:00
|
|
|
class cMenuChannels : public cOsdMenu {
|
2002-10-20 12:28:55 +02:00
|
|
|
private:
|
2006-01-05 13:43:07 +01:00
|
|
|
int number;
|
|
|
|
cTimeMs numberTimer;
|
2004-11-01 13:59:58 +01:00
|
|
|
void Setup(void);
|
2002-12-22 12:49:10 +01:00
|
|
|
cChannel *GetChannel(int Index);
|
2002-10-20 12:28:55 +02:00
|
|
|
void Propagate(void);
|
2000-03-11 11:22:37 +01:00
|
|
|
protected:
|
2006-01-05 13:43:07 +01:00
|
|
|
eOSState Number(eKeys Key);
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState Switch(void);
|
|
|
|
eOSState Edit(void);
|
|
|
|
eOSState New(void);
|
2002-11-10 16:07:58 +01:00
|
|
|
eOSState Delete(void);
|
2000-03-11 11:22:37 +01:00
|
|
|
virtual void Move(int From, int To);
|
2000-02-19 13:36:48 +01:00
|
|
|
public:
|
|
|
|
cMenuChannels(void);
|
2004-01-04 12:30:00 +01:00
|
|
|
~cMenuChannels();
|
2000-03-11 11:22:37 +01:00
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
2000-02-19 13:36:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
cMenuChannels::cMenuChannels(void)
|
2002-03-29 10:50:20 +01:00
|
|
|
:cOsdMenu(tr("Channels"), CHNUMWIDTH)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2006-01-05 13:43:07 +01:00
|
|
|
number = 0;
|
2004-11-01 13:59:58 +01:00
|
|
|
Setup();
|
2004-01-04 12:30:00 +01:00
|
|
|
Channels.IncBeingEdited();
|
|
|
|
}
|
|
|
|
|
|
|
|
cMenuChannels::~cMenuChannels()
|
|
|
|
{
|
|
|
|
Channels.DecBeingEdited();
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
|
2004-11-01 13:59:58 +01:00
|
|
|
void cMenuChannels::Setup(void)
|
|
|
|
{
|
|
|
|
cChannel *currentChannel = GetChannel(Current());
|
|
|
|
if (!currentChannel)
|
|
|
|
currentChannel = Channels.GetByNumber(cDevice::CurrentChannel());
|
|
|
|
cMenuChannelItem *currentItem = NULL;
|
|
|
|
Clear();
|
|
|
|
for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
|
|
|
|
if (!channel->GroupSep() || cMenuChannelItem::SortMode() == cMenuChannelItem::csmNumber && *channel->Name()) {
|
|
|
|
cMenuChannelItem *item = new cMenuChannelItem(channel);
|
|
|
|
Add(item);
|
|
|
|
if (channel == currentChannel)
|
|
|
|
currentItem = item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cMenuChannelItem::SortMode() != cMenuChannelItem::csmNumber)
|
|
|
|
Sort();
|
|
|
|
SetCurrent(currentItem);
|
2006-01-07 15:54:10 +01:00
|
|
|
SetHelp(tr("Button$Edit"), tr("Button$New"), tr("Button$Delete"), tr("Button$Mark"));
|
2004-11-01 13:59:58 +01:00
|
|
|
Display();
|
|
|
|
}
|
|
|
|
|
2002-12-22 12:49:10 +01:00
|
|
|
cChannel *cMenuChannels::GetChannel(int Index)
|
|
|
|
{
|
|
|
|
cMenuChannelItem *p = (cMenuChannelItem *)Get(Index);
|
|
|
|
return p ? (cChannel *)p->Channel() : NULL;
|
|
|
|
}
|
|
|
|
|
2002-10-20 12:28:55 +02:00
|
|
|
void cMenuChannels::Propagate(void)
|
|
|
|
{
|
|
|
|
Channels.ReNumber();
|
|
|
|
for (cMenuChannelItem *ci = (cMenuChannelItem *)First(); ci; ci = (cMenuChannelItem *)ci->Next())
|
|
|
|
ci->Set();
|
|
|
|
Display();
|
2004-10-17 11:50:21 +02:00
|
|
|
Channels.SetModified(true);
|
2002-10-20 12:28:55 +02:00
|
|
|
}
|
|
|
|
|
2006-01-05 13:43:07 +01:00
|
|
|
eOSState cMenuChannels::Number(eKeys Key)
|
|
|
|
{
|
|
|
|
if (HasSubMenu())
|
|
|
|
return osContinue;
|
|
|
|
if (numberTimer.TimedOut())
|
|
|
|
number = 0;
|
|
|
|
if (!number && Key == k0) {
|
|
|
|
cMenuChannelItem::IncSortMode();
|
|
|
|
Setup();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
number = number * 10 + Key - k0;
|
|
|
|
for (cMenuChannelItem *ci = (cMenuChannelItem *)First(); ci; ci = (cMenuChannelItem *)ci->Next()) {
|
|
|
|
if (!ci->Channel()->GroupSep() && ci->Channel()->Number() == number) {
|
|
|
|
SetCurrent(ci);
|
|
|
|
Display();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
numberTimer.Set(CHANNELNUMBERTIMEOUT);
|
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState cMenuChannels::Switch(void)
|
|
|
|
{
|
2003-07-26 10:09:38 +02:00
|
|
|
if (HasSubMenu())
|
|
|
|
return osContinue;
|
2002-12-22 12:49:10 +01:00
|
|
|
cChannel *ch = GetChannel(Current());
|
2000-03-11 11:22:37 +01:00
|
|
|
if (ch)
|
2004-02-08 14:15:01 +01:00
|
|
|
return cDevice::PrimaryDevice()->SwitchChannel(ch, true) ? osEnd : osContinue;
|
2000-03-11 11:22:37 +01:00
|
|
|
return osEnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuChannels::Edit(void)
|
|
|
|
{
|
|
|
|
if (HasSubMenu() || Count() == 0)
|
|
|
|
return osContinue;
|
2002-12-22 12:49:10 +01:00
|
|
|
cChannel *ch = GetChannel(Current());
|
2002-11-10 15:50:21 +01:00
|
|
|
if (ch)
|
|
|
|
return AddSubMenu(new cMenuEditChannel(ch));
|
2002-10-20 14:22:09 +02:00
|
|
|
return osContinue;
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuChannels::New(void)
|
|
|
|
{
|
|
|
|
if (HasSubMenu())
|
|
|
|
return osContinue;
|
2003-06-15 12:29:56 +02:00
|
|
|
return AddSubMenu(new cMenuEditChannel(GetChannel(Current()), true));
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
|
2002-11-10 16:07:58 +01:00
|
|
|
eOSState cMenuChannels::Delete(void)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2003-07-26 10:09:38 +02:00
|
|
|
if (!HasSubMenu() && Count() > 0) {
|
2006-05-28 10:48:50 +02:00
|
|
|
int CurrentChannelNr = cDevice::CurrentChannel();
|
|
|
|
cChannel *CurrentChannel = Channels.GetByNumber(CurrentChannelNr);
|
2000-03-11 11:22:37 +01:00
|
|
|
int Index = Current();
|
2002-12-22 12:49:10 +01:00
|
|
|
cChannel *channel = GetChannel(Current());
|
2002-10-06 10:25:42 +02:00
|
|
|
int DeletedChannel = channel->Number();
|
2000-03-11 11:22:37 +01:00
|
|
|
// Check if there is a timer using this channel:
|
2006-02-28 14:00:28 +01:00
|
|
|
if (channel->HasTimer()) {
|
|
|
|
Skins.Message(mtError, tr("Channel is being used by a timer!"));
|
|
|
|
return osContinue;
|
|
|
|
}
|
2000-12-28 12:57:16 +01:00
|
|
|
if (Interface->Confirm(tr("Delete channel?"))) {
|
2006-05-28 10:48:50 +02:00
|
|
|
if (CurrentChannel && channel == CurrentChannel) {
|
|
|
|
int n = Channels.GetNextNormal(CurrentChannel->Index());
|
|
|
|
if (n < 0)
|
|
|
|
n = Channels.GetPrevNormal(CurrentChannel->Index());
|
|
|
|
CurrentChannel = Channels.Get(n);
|
|
|
|
CurrentChannelNr = 0; // triggers channel switch below
|
|
|
|
}
|
2000-09-09 14:57:43 +02:00
|
|
|
Channels.Del(channel);
|
2000-03-11 11:22:37 +01:00
|
|
|
cOsdMenu::Del(Index);
|
2002-10-20 12:28:55 +02:00
|
|
|
Propagate();
|
2002-05-13 16:35:49 +02:00
|
|
|
isyslog("channel %d deleted", DeletedChannel);
|
2006-05-28 10:48:50 +02:00
|
|
|
if (CurrentChannel && CurrentChannel->Number() != CurrentChannelNr) {
|
|
|
|
if (!cDevice::PrimaryDevice()->Replaying() || cDevice::PrimaryDevice()->Transferring())
|
|
|
|
Channels.SwitchTo(CurrentChannel->Number());
|
|
|
|
else
|
|
|
|
cDevice::SetCurrentChannel(CurrentChannel);
|
|
|
|
}
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
2000-02-19 13:36:48 +01:00
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
void cMenuChannels::Move(int From, int To)
|
|
|
|
{
|
2003-08-09 10:19:33 +02:00
|
|
|
int CurrentChannelNr = cDevice::CurrentChannel();
|
|
|
|
cChannel *CurrentChannel = Channels.GetByNumber(CurrentChannelNr);
|
2002-12-22 12:49:10 +01:00
|
|
|
cChannel *FromChannel = GetChannel(From);
|
|
|
|
cChannel *ToChannel = GetChannel(To);
|
|
|
|
if (FromChannel && ToChannel) {
|
|
|
|
int FromNumber = FromChannel->Number();
|
|
|
|
int ToNumber = ToChannel->Number();
|
|
|
|
Channels.Move(FromChannel, ToChannel);
|
|
|
|
cOsdMenu::Move(From, To);
|
|
|
|
Propagate();
|
|
|
|
isyslog("channel %d moved to %d", FromNumber, ToNumber);
|
2006-05-28 09:19:30 +02:00
|
|
|
if (CurrentChannel && CurrentChannel->Number() != CurrentChannelNr) {
|
|
|
|
if (!cDevice::PrimaryDevice()->Replaying() || cDevice::PrimaryDevice()->Transferring())
|
|
|
|
Channels.SwitchTo(CurrentChannel->Number());
|
|
|
|
else
|
|
|
|
cDevice::SetCurrentChannel(CurrentChannel);
|
|
|
|
}
|
2002-12-22 12:49:10 +01:00
|
|
|
}
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuChannels::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
|
|
|
|
2002-11-10 15:50:21 +01:00
|
|
|
switch (state) {
|
|
|
|
case osUser1: {
|
|
|
|
cChannel *channel = Channels.Last();
|
|
|
|
if (channel) {
|
|
|
|
Add(new cMenuChannelItem(channel), true);
|
|
|
|
return CloseSubMenu();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (state == osUnknown) {
|
|
|
|
switch (Key) {
|
2006-01-05 13:43:07 +01:00
|
|
|
case k0 ... k9:
|
|
|
|
return Number(Key);
|
2002-11-10 15:50:21 +01:00
|
|
|
case kOk: return Switch();
|
|
|
|
case kRed: return Edit();
|
|
|
|
case kGreen: return New();
|
2002-11-10 16:07:58 +01:00
|
|
|
case kYellow: return Delete();
|
2006-01-05 15:11:04 +01:00
|
|
|
case kBlue: if (!HasSubMenu())
|
2003-07-26 10:09:38 +02:00
|
|
|
Mark();
|
|
|
|
break;
|
2002-11-10 15:50:21 +01:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-03-11 11:22:37 +01:00
|
|
|
return state;
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
|
2000-11-11 16:38:41 +01:00
|
|
|
// --- cMenuText -------------------------------------------------------------
|
2000-07-24 16:43:04 +02:00
|
|
|
|
2000-11-18 15:46:00 +01:00
|
|
|
cMenuText::cMenuText(const char *Title, const char *Text, eDvbFont Font)
|
2000-11-11 16:38:41 +01:00
|
|
|
:cOsdMenu(Title)
|
2000-07-24 16:43:04 +02:00
|
|
|
{
|
2004-05-23 09:54:06 +02:00
|
|
|
text = NULL;
|
2006-02-17 15:45:25 +01:00
|
|
|
font = Font;
|
2004-05-23 09:54:06 +02:00
|
|
|
SetText(Text);
|
|
|
|
}
|
|
|
|
|
|
|
|
cMenuText::~cMenuText()
|
|
|
|
{
|
|
|
|
free(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuText::SetText(const char *Text)
|
|
|
|
{
|
|
|
|
free(text);
|
2004-08-08 14:21:17 +02:00
|
|
|
text = Text ? strdup(Text) : NULL;
|
2004-05-16 10:35:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuText::Display(void)
|
|
|
|
{
|
|
|
|
cOsdMenu::Display();
|
2006-02-17 15:45:25 +01:00
|
|
|
DisplayMenu()->SetText(text, font == fontFix); //XXX define control character in text to choose the font???
|
2006-04-09 14:31:33 +02:00
|
|
|
if (text)
|
|
|
|
cStatus::MsgOsdTextItem(text);
|
2000-07-24 16:43:04 +02:00
|
|
|
}
|
|
|
|
|
2000-11-11 16:38:41 +01:00
|
|
|
eOSState cMenuText::ProcessKey(eKeys Key)
|
2000-07-24 16:43:04 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
switch (Key) {
|
|
|
|
case kUp|k_Repeat:
|
|
|
|
case kUp:
|
|
|
|
case kDown|k_Repeat:
|
|
|
|
case kDown:
|
|
|
|
case kLeft|k_Repeat:
|
|
|
|
case kLeft:
|
|
|
|
case kRight|k_Repeat:
|
|
|
|
case kRight:
|
|
|
|
DisplayMenu()->Scroll(NORMALKEY(Key) == kUp || NORMALKEY(Key) == kLeft, NORMALKEY(Key) == kLeft || NORMALKEY(Key) == kRight);
|
2004-05-23 11:22:47 +02:00
|
|
|
cStatus::MsgOsdTextItem(NULL, NORMALKEY(Key) == kUp);
|
2004-05-16 10:35:36 +02:00
|
|
|
return osContinue;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
2000-07-24 16:43:04 +02:00
|
|
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
|
|
|
|
2000-11-11 16:38:41 +01:00
|
|
|
if (state == osUnknown) {
|
|
|
|
switch (Key) {
|
|
|
|
case kOk: return osBack;
|
|
|
|
default: state = osContinue;
|
|
|
|
}
|
|
|
|
}
|
2000-07-24 16:43:04 +02:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2000-02-19 13:36:48 +01:00
|
|
|
// --- cMenuEditTimer --------------------------------------------------------
|
|
|
|
|
2003-06-06 15:02:37 +02:00
|
|
|
cMenuEditTimer::cMenuEditTimer(cTimer *Timer, bool New)
|
2002-04-06 09:51:08 +02:00
|
|
|
:cOsdMenu(tr("Edit timer"), 12)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2002-02-17 13:05:05 +01:00
|
|
|
firstday = NULL;
|
2003-06-06 15:02:37 +02:00
|
|
|
timer = Timer;
|
|
|
|
addIfConfirmed = New;
|
2000-02-19 13:36:48 +01:00
|
|
|
if (timer) {
|
|
|
|
data = *timer;
|
2000-04-15 17:38:11 +02:00
|
|
|
if (New)
|
2004-02-29 14:21:22 +01:00
|
|
|
data.SetFlags(tfActive);
|
2002-10-20 12:28:55 +02:00
|
|
|
channel = data.Channel()->Number();
|
2004-02-29 14:21:22 +01:00
|
|
|
Add(new cMenuEditBitItem( tr("Active"), &data.flags, tfActive));
|
2002-10-20 12:28:55 +02:00
|
|
|
Add(new cMenuEditChanItem(tr("Channel"), &channel));
|
2005-03-19 15:38:43 +01:00
|
|
|
Add(new cMenuEditDateItem(tr("Day"), &data.day, &data.weekdays));
|
2001-06-02 10:47:40 +02:00
|
|
|
Add(new cMenuEditTimeItem(tr("Start"), &data.start));
|
|
|
|
Add(new cMenuEditTimeItem(tr("Stop"), &data.stop));
|
2004-02-29 14:21:22 +01:00
|
|
|
Add(new cMenuEditBitItem( tr("VPS"), &data.flags, tfVps));
|
2001-06-02 10:47:40 +02:00
|
|
|
Add(new cMenuEditIntItem( tr("Priority"), &data.priority, 0, MAXPRIORITY));
|
|
|
|
Add(new cMenuEditIntItem( tr("Lifetime"), &data.lifetime, 0, MAXLIFETIME));
|
2002-04-16 16:11:40 +02:00
|
|
|
Add(new cMenuEditStrItem( tr("File"), data.file, sizeof(data.file), tr(FileNameChars)));
|
2002-02-17 13:05:05 +01:00
|
|
|
SetFirstDayItem();
|
|
|
|
}
|
2003-02-09 13:14:44 +01:00
|
|
|
Timers.IncBeingEdited();
|
|
|
|
}
|
|
|
|
|
|
|
|
cMenuEditTimer::~cMenuEditTimer()
|
|
|
|
{
|
2003-06-06 15:02:37 +02:00
|
|
|
if (timer && addIfConfirmed)
|
|
|
|
delete timer; // apparently it wasn't confirmed
|
2003-02-09 13:14:44 +01:00
|
|
|
Timers.DecBeingEdited();
|
2002-02-17 13:05:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuEditTimer::SetFirstDayItem(void)
|
|
|
|
{
|
|
|
|
if (!firstday && !data.IsSingleEvent()) {
|
2005-03-19 15:38:43 +01:00
|
|
|
Add(firstday = new cMenuEditDateItem(tr("First day"), &data.day));
|
2002-02-17 13:05:05 +01:00
|
|
|
Display();
|
|
|
|
}
|
|
|
|
else if (firstday && data.IsSingleEvent()) {
|
|
|
|
Del(firstday->Index());
|
|
|
|
firstday = NULL;
|
|
|
|
Display();
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState cMenuEditTimer::ProcessKey(eKeys Key)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
2000-02-19 13:36:48 +01:00
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
if (state == osUnknown) {
|
2000-11-11 12:55:10 +01:00
|
|
|
switch (Key) {
|
2003-12-22 13:29:24 +01:00
|
|
|
case kOk: {
|
2002-10-20 12:28:55 +02:00
|
|
|
cChannel *ch = Channels.GetByNumber(channel);
|
|
|
|
if (ch)
|
|
|
|
data.channel = ch;
|
|
|
|
else {
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtError, tr("*** Invalid Channel ***"));
|
2002-10-20 12:28:55 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!*data.file)
|
2004-10-31 12:53:00 +01:00
|
|
|
strcpy(data.file, data.Channel()->ShortName(true));
|
2003-06-06 15:02:37 +02:00
|
|
|
if (timer) {
|
2006-02-25 12:22:02 +01:00
|
|
|
if (memcmp(timer, &data, sizeof(data)) != 0)
|
2003-06-06 15:02:37 +02:00
|
|
|
*timer = data;
|
|
|
|
if (addIfConfirmed)
|
|
|
|
Timers.Add(timer);
|
2006-02-25 15:57:56 +01:00
|
|
|
timer->SetEventFromSchedule();
|
2006-02-28 12:36:52 +01:00
|
|
|
timer->Matches();
|
2004-10-31 10:22:32 +01:00
|
|
|
Timers.SetModified();
|
2005-03-20 15:15:42 +01:00
|
|
|
isyslog("timer %s %s (%s)", *timer->ToDescr(), addIfConfirmed ? "added" : "modified", timer->HasFlags(tfActive) ? "active" : "inactive");
|
2003-06-06 15:02:37 +02:00
|
|
|
addIfConfirmed = false;
|
2002-10-20 12:28:55 +02:00
|
|
|
}
|
|
|
|
}
|
2000-11-11 12:55:10 +01:00
|
|
|
return osBack;
|
|
|
|
case kRed:
|
|
|
|
case kGreen:
|
|
|
|
case kYellow:
|
|
|
|
case kBlue: return osContinue;
|
|
|
|
default: break;
|
|
|
|
}
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
2002-02-17 13:05:05 +01:00
|
|
|
if (Key != kNone)
|
|
|
|
SetFirstDayItem();
|
2000-03-11 11:22:37 +01:00
|
|
|
return state;
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuTimerItem --------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuTimerItem : public cOsdItem {
|
|
|
|
private:
|
|
|
|
cTimer *timer;
|
|
|
|
public:
|
2001-08-26 14:17:20 +02:00
|
|
|
cMenuTimerItem(cTimer *Timer);
|
2004-11-01 10:40:38 +01:00
|
|
|
virtual int Compare(const cListObject &ListObject) const;
|
2000-02-19 13:36:48 +01:00
|
|
|
virtual void Set(void);
|
2001-08-26 14:17:20 +02:00
|
|
|
cTimer *Timer(void) { return timer; }
|
2000-02-19 13:36:48 +01:00
|
|
|
};
|
|
|
|
|
2001-08-26 14:17:20 +02:00
|
|
|
cMenuTimerItem::cMenuTimerItem(cTimer *Timer)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
|
|
|
timer = Timer;
|
|
|
|
Set();
|
|
|
|
}
|
|
|
|
|
2004-11-01 10:40:38 +01:00
|
|
|
int cMenuTimerItem::Compare(const cListObject &ListObject) const
|
2001-08-26 14:17:20 +02:00
|
|
|
{
|
2004-11-01 10:40:38 +01:00
|
|
|
return timer->Compare(*((cMenuTimerItem *)&ListObject)->timer);
|
2001-08-26 14:17:20 +02:00
|
|
|
}
|
|
|
|
|
2000-02-19 13:36:48 +01:00
|
|
|
void cMenuTimerItem::Set(void)
|
|
|
|
{
|
2005-03-19 15:45:19 +01:00
|
|
|
cString day, name("");
|
|
|
|
if (timer->WeekDays())
|
|
|
|
day = timer->PrintDay(0, timer->WeekDays());
|
|
|
|
else if (timer->Day() - time(NULL) < 28 * SECSINDAY) {
|
|
|
|
day = itoa(timer->GetMDay(timer->Day()));
|
|
|
|
name = WeekDayName(timer->Day());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
struct tm tm_r;
|
|
|
|
time_t Day = timer->Day();
|
|
|
|
localtime_r(&Day, &tm_r);
|
|
|
|
char buffer[16];
|
|
|
|
strftime(buffer, sizeof(buffer), "%Y%m%d", &tm_r);
|
|
|
|
day = buffer;
|
|
|
|
}
|
2000-02-19 13:36:48 +01:00
|
|
|
char *buffer = NULL;
|
2004-05-22 13:23:22 +02:00
|
|
|
asprintf(&buffer, "%c\t%d\t%s%s%s\t%02d:%02d\t%02d:%02d\t%s",
|
2004-02-29 14:21:22 +01:00
|
|
|
!(timer->HasFlags(tfActive)) ? ' ' : timer->FirstDay() ? '!' : timer->Recording() ? '#' : '>',
|
2002-10-20 12:28:55 +02:00
|
|
|
timer->Channel()->Number(),
|
2005-03-19 15:45:19 +01:00
|
|
|
*name,
|
|
|
|
*name && **name ? " " : "",
|
|
|
|
*day,
|
2002-10-20 12:28:55 +02:00
|
|
|
timer->Start() / 100,
|
|
|
|
timer->Start() % 100,
|
|
|
|
timer->Stop() / 100,
|
|
|
|
timer->Stop() % 100,
|
|
|
|
timer->File());
|
2000-02-19 13:36:48 +01:00
|
|
|
SetText(buffer, false);
|
|
|
|
}
|
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
// --- cMenuTimers -----------------------------------------------------------
|
2000-02-19 13:36:48 +01:00
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
class cMenuTimers : public cOsdMenu {
|
|
|
|
private:
|
2006-02-25 14:39:29 +01:00
|
|
|
int helpKeys;
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState Edit(void);
|
|
|
|
eOSState New(void);
|
2002-11-10 16:07:58 +01:00
|
|
|
eOSState Delete(void);
|
2002-02-17 13:05:05 +01:00
|
|
|
eOSState OnOff(void);
|
2006-02-25 14:39:29 +01:00
|
|
|
eOSState Info(void);
|
2001-08-26 14:17:20 +02:00
|
|
|
cTimer *CurrentTimer(void);
|
2006-02-25 14:39:29 +01:00
|
|
|
void SetHelpKeys(void);
|
2000-02-19 13:36:48 +01:00
|
|
|
public:
|
2000-03-11 11:22:37 +01:00
|
|
|
cMenuTimers(void);
|
2003-02-09 13:14:44 +01:00
|
|
|
virtual ~cMenuTimers();
|
2000-03-11 11:22:37 +01:00
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
2000-02-19 13:36:48 +01:00
|
|
|
};
|
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
cMenuTimers::cMenuTimers(void)
|
2002-03-29 10:50:20 +01:00
|
|
|
:cOsdMenu(tr("Timers"), 2, CHNUMWIDTH, 10, 6, 6)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2006-02-25 14:39:29 +01:00
|
|
|
helpKeys = -1;
|
2006-02-28 12:36:52 +01:00
|
|
|
for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer)) {
|
|
|
|
timer->SetEventFromSchedule(); // make sure the event is current
|
2004-03-14 10:34:56 +01:00
|
|
|
Add(new cMenuTimerItem(timer));
|
2006-02-28 12:36:52 +01:00
|
|
|
}
|
2006-02-25 14:17:56 +01:00
|
|
|
Sort();
|
2006-02-25 14:39:29 +01:00
|
|
|
SetCurrent(First());
|
|
|
|
SetHelpKeys();
|
2003-02-09 13:14:44 +01:00
|
|
|
Timers.IncBeingEdited();
|
|
|
|
}
|
|
|
|
|
|
|
|
cMenuTimers::~cMenuTimers()
|
|
|
|
{
|
|
|
|
Timers.DecBeingEdited();
|
2001-08-26 14:17:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cTimer *cMenuTimers::CurrentTimer(void)
|
|
|
|
{
|
|
|
|
cMenuTimerItem *item = (cMenuTimerItem *)Get(Current());
|
|
|
|
return item ? item->Timer() : NULL;
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
|
2006-02-25 14:39:29 +01:00
|
|
|
void cMenuTimers::SetHelpKeys(void)
|
|
|
|
{
|
|
|
|
int NewHelpKeys = 0;
|
|
|
|
cTimer *timer = CurrentTimer();
|
|
|
|
if (timer) {
|
|
|
|
if (timer->Event())
|
|
|
|
NewHelpKeys = 2;
|
|
|
|
else
|
|
|
|
NewHelpKeys = 1;
|
|
|
|
}
|
|
|
|
if (NewHelpKeys != helpKeys) {
|
|
|
|
helpKeys = NewHelpKeys;
|
|
|
|
SetHelp(helpKeys > 0 ? tr("Button$On/Off") : NULL, tr("Button$New"), helpKeys > 0 ? tr("Button$Delete") : NULL, helpKeys == 2 ? tr("Button$Info") : NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-17 13:05:05 +01:00
|
|
|
eOSState cMenuTimers::OnOff(void)
|
2000-03-11 11:22:37 +01:00
|
|
|
{
|
2006-02-25 14:39:29 +01:00
|
|
|
if (HasSubMenu())
|
|
|
|
return osContinue;
|
2001-08-26 14:17:20 +02:00
|
|
|
cTimer *timer = CurrentTimer();
|
2002-02-17 13:05:05 +01:00
|
|
|
if (timer) {
|
2002-10-20 12:28:55 +02:00
|
|
|
timer->OnOff();
|
2006-02-25 15:57:56 +01:00
|
|
|
timer->SetEventFromSchedule();
|
2000-03-11 11:22:37 +01:00
|
|
|
RefreshCurrent();
|
|
|
|
DisplayCurrent(true);
|
2002-10-20 12:28:55 +02:00
|
|
|
if (timer->FirstDay())
|
2005-03-20 15:15:42 +01:00
|
|
|
isyslog("timer %s first day set to %s", *timer->ToDescr(), *timer->PrintFirstDay());
|
2002-02-17 13:05:05 +01:00
|
|
|
else
|
2005-03-20 15:15:42 +01:00
|
|
|
isyslog("timer %s %sactivated", *timer->ToDescr(), timer->HasFlags(tfActive) ? "" : "de");
|
2004-10-31 10:22:32 +01:00
|
|
|
Timers.SetModified();
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuTimers::Edit(void)
|
|
|
|
{
|
|
|
|
if (HasSubMenu() || Count() == 0)
|
|
|
|
return osContinue;
|
2005-03-20 15:15:42 +01:00
|
|
|
isyslog("editing timer %s", *CurrentTimer()->ToDescr());
|
2003-06-06 15:02:37 +02:00
|
|
|
return AddSubMenu(new cMenuEditTimer(CurrentTimer()));
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuTimers::New(void)
|
|
|
|
{
|
|
|
|
if (HasSubMenu())
|
|
|
|
return osContinue;
|
2003-06-06 15:02:37 +02:00
|
|
|
return AddSubMenu(new cMenuEditTimer(new cTimer, true));
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
|
2002-11-10 16:07:58 +01:00
|
|
|
eOSState cMenuTimers::Delete(void)
|
2000-03-11 11:22:37 +01:00
|
|
|
{
|
|
|
|
// Check if this timer is active:
|
2001-08-26 14:17:20 +02:00
|
|
|
cTimer *ti = CurrentTimer();
|
2000-03-11 11:22:37 +01:00
|
|
|
if (ti) {
|
2003-05-25 14:14:32 +02:00
|
|
|
if (Interface->Confirm(tr("Delete timer?"))) {
|
|
|
|
if (ti->Recording()) {
|
|
|
|
if (Interface->Confirm(tr("Timer still recording - really delete?"))) {
|
|
|
|
ti->Skip();
|
|
|
|
cRecordControls::Process(time(NULL));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return osContinue;
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
2005-03-20 15:15:42 +01:00
|
|
|
isyslog("deleting timer %s", *ti->ToDescr());
|
2003-05-25 14:14:32 +02:00
|
|
|
Timers.Del(ti);
|
|
|
|
cOsdMenu::Del(Current());
|
2004-10-31 10:22:32 +01:00
|
|
|
Timers.SetModified();
|
2003-05-25 14:14:32 +02:00
|
|
|
Display();
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return osContinue;
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
|
2006-02-25 14:39:29 +01:00
|
|
|
eOSState cMenuTimers::Info(void)
|
|
|
|
{
|
|
|
|
if (HasSubMenu() || Count() == 0)
|
|
|
|
return osContinue;
|
|
|
|
cTimer *ti = CurrentTimer();
|
|
|
|
if (ti && ti->Event())
|
|
|
|
return AddSubMenu(new cMenuEvent(ti->Event()));
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState cMenuTimers::ProcessKey(eKeys Key)
|
|
|
|
{
|
2003-06-06 15:02:37 +02:00
|
|
|
int TimerNumber = HasSubMenu() ? Count() : -1;
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
|
|
|
|
|
|
|
if (state == osUnknown) {
|
2000-02-19 13:36:48 +01:00
|
|
|
switch (Key) {
|
2006-02-25 12:09:22 +01:00
|
|
|
case kOk: return Edit();
|
2006-02-25 15:57:56 +01:00
|
|
|
case kRed: state = OnOff(); break; // must go through SetHelpKeys()!
|
2000-03-11 11:22:37 +01:00
|
|
|
case kGreen: return New();
|
2006-02-28 12:36:52 +01:00
|
|
|
case kYellow: state = Delete(); break;
|
2006-02-25 14:39:29 +01:00
|
|
|
case kBlue: return Info();
|
|
|
|
break;
|
2000-02-19 13:36:48 +01:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
2003-06-06 15:02:37 +02:00
|
|
|
if (TimerNumber >= 0 && !HasSubMenu() && Timers.Get(TimerNumber)) {
|
|
|
|
// a newly created timer was confirmed with Ok
|
|
|
|
Add(new cMenuTimerItem(Timers.Get(TimerNumber)), true);
|
2003-05-25 13:58:21 +02:00
|
|
|
Display();
|
|
|
|
}
|
2006-02-25 14:39:29 +01:00
|
|
|
if (Key != kNone)
|
|
|
|
SetHelpKeys();
|
2000-03-11 11:22:37 +01:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2000-10-29 13:17:22 +01:00
|
|
|
// --- cMenuEvent ------------------------------------------------------------
|
|
|
|
|
2006-02-25 14:39:29 +01:00
|
|
|
cMenuEvent::cMenuEvent(const cEvent *Event, bool CanSwitch, bool Buttons)
|
2000-11-11 10:39:27 +01:00
|
|
|
:cOsdMenu(tr("Event"))
|
2000-10-29 13:17:22 +01:00
|
|
|
{
|
2003-12-22 13:29:24 +01:00
|
|
|
event = Event;
|
|
|
|
if (event) {
|
|
|
|
cChannel *channel = Channels.GetByChannelID(event->ChannelID(), true);
|
2000-11-01 11:45:05 +01:00
|
|
|
if (channel) {
|
2004-05-16 10:35:36 +02:00
|
|
|
SetTitle(channel->Name());
|
2005-12-27 15:06:26 +01:00
|
|
|
int TimerMatch = tmNone;
|
|
|
|
Timers.GetMatch(event, &TimerMatch);
|
2006-02-25 14:39:29 +01:00
|
|
|
if (Buttons)
|
|
|
|
SetHelp(TimerMatch == tmFull ? tr("Button$Timer") : tr("Button$Record"), NULL, NULL, CanSwitch ? tr("Button$Switch") : NULL);
|
2000-11-01 11:45:05 +01:00
|
|
|
}
|
2000-10-29 13:17:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cMenuEvent::Display(void)
|
|
|
|
{
|
|
|
|
cOsdMenu::Display();
|
|
|
|
DisplayMenu()->SetEvent(event);
|
2006-04-09 14:31:33 +02:00
|
|
|
if (event->Description())
|
|
|
|
cStatus::MsgOsdTextItem(event->Description());
|
2004-05-16 10:35:36 +02:00
|
|
|
}
|
|
|
|
|
2000-11-01 11:45:05 +01:00
|
|
|
eOSState cMenuEvent::ProcessKey(eKeys Key)
|
2000-10-29 13:17:22 +01:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
switch (Key) {
|
|
|
|
case kUp|k_Repeat:
|
|
|
|
case kUp:
|
|
|
|
case kDown|k_Repeat:
|
|
|
|
case kDown:
|
|
|
|
case kLeft|k_Repeat:
|
|
|
|
case kLeft:
|
|
|
|
case kRight|k_Repeat:
|
|
|
|
case kRight:
|
|
|
|
DisplayMenu()->Scroll(NORMALKEY(Key) == kUp || NORMALKEY(Key) == kLeft, NORMALKEY(Key) == kLeft || NORMALKEY(Key) == kRight);
|
2004-05-23 11:22:47 +02:00
|
|
|
cStatus::MsgOsdTextItem(NULL, NORMALKEY(Key) == kUp);
|
2004-05-16 10:35:36 +02:00
|
|
|
return osContinue;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
2000-11-01 11:45:05 +01:00
|
|
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
2000-10-29 13:17:22 +01:00
|
|
|
|
2000-11-01 11:45:05 +01:00
|
|
|
if (state == osUnknown) {
|
|
|
|
switch (Key) {
|
2000-11-18 16:31:48 +01:00
|
|
|
case kGreen:
|
|
|
|
case kYellow: return osContinue;
|
2000-11-01 11:45:05 +01:00
|
|
|
case kOk: return osBack;
|
|
|
|
default: break;
|
|
|
|
}
|
2000-10-29 13:17:22 +01:00
|
|
|
}
|
2000-11-01 11:45:05 +01:00
|
|
|
return state;
|
2000-10-29 13:17:22 +01:00
|
|
|
}
|
|
|
|
|
2005-12-27 11:27:38 +01:00
|
|
|
// --- cMenuScheduleItem -----------------------------------------------------
|
2000-10-29 13:17:22 +01:00
|
|
|
|
2005-12-27 11:27:38 +01:00
|
|
|
class cMenuScheduleItem : public cOsdItem {
|
2006-01-15 13:09:16 +01:00
|
|
|
public:
|
|
|
|
enum eScheduleSortMode { ssmAllThis, ssmThisThis, ssmThisAll, ssmAllAll }; // "which event(s) on which channel(s)"
|
|
|
|
private:
|
|
|
|
static eScheduleSortMode sortMode;
|
2000-10-29 13:17:22 +01:00
|
|
|
public:
|
2003-12-22 13:29:24 +01:00
|
|
|
const cEvent *event;
|
2004-02-21 13:56:20 +01:00
|
|
|
const cChannel *channel;
|
2006-01-15 13:09:16 +01:00
|
|
|
bool withDate;
|
2005-12-27 11:27:38 +01:00
|
|
|
int timerMatch;
|
2006-01-15 13:09:16 +01:00
|
|
|
cMenuScheduleItem(const cEvent *Event, cChannel *Channel = NULL, bool WithDate = false);
|
|
|
|
static void SetSortMode(eScheduleSortMode SortMode) { sortMode = SortMode; }
|
|
|
|
static void IncSortMode(void) { sortMode = eScheduleSortMode((sortMode == ssmAllAll) ? ssmAllThis : sortMode + 1); }
|
|
|
|
static eScheduleSortMode SortMode(void) { return sortMode; }
|
|
|
|
virtual int Compare(const cListObject &ListObject) const;
|
2005-12-27 11:27:38 +01:00
|
|
|
bool Update(bool Force = false);
|
2006-01-15 13:09:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
cMenuScheduleItem::eScheduleSortMode cMenuScheduleItem::sortMode = ssmAllThis;
|
2000-10-29 13:17:22 +01:00
|
|
|
|
2006-01-15 13:09:16 +01:00
|
|
|
cMenuScheduleItem::cMenuScheduleItem(const cEvent *Event, cChannel *Channel, bool WithDate)
|
2000-10-29 13:17:22 +01:00
|
|
|
{
|
2003-12-22 13:29:24 +01:00
|
|
|
event = Event;
|
2004-02-21 13:56:20 +01:00
|
|
|
channel = Channel;
|
2006-01-15 13:09:16 +01:00
|
|
|
withDate = WithDate;
|
2005-12-27 11:27:38 +01:00
|
|
|
timerMatch = tmNone;
|
|
|
|
Update(true);
|
|
|
|
}
|
|
|
|
|
2006-01-15 13:09:16 +01:00
|
|
|
int cMenuScheduleItem::Compare(const cListObject &ListObject) const
|
|
|
|
{
|
|
|
|
cMenuScheduleItem *p = (cMenuScheduleItem *)&ListObject;
|
|
|
|
int r = -1;
|
|
|
|
if (sortMode != ssmAllThis)
|
|
|
|
r = strcoll(event->Title(), p->event->Title());
|
|
|
|
if (sortMode == ssmAllThis || r == 0)
|
|
|
|
r = event->StartTime() - p->event->StartTime();
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2005-12-27 11:27:38 +01:00
|
|
|
static char *TimerMatchChars = " tT";
|
|
|
|
|
|
|
|
bool cMenuScheduleItem::Update(bool Force)
|
|
|
|
{
|
|
|
|
bool result = false;
|
|
|
|
int OldTimerMatch = timerMatch;
|
|
|
|
Timers.GetMatch(event, &timerMatch);
|
|
|
|
if (Force || timerMatch != OldTimerMatch) {
|
|
|
|
char *buffer = NULL;
|
|
|
|
char t = TimerMatchChars[timerMatch];
|
|
|
|
char v = event->Vps() && (event->Vps() - event->StartTime()) ? 'V' : ' ';
|
2006-06-03 09:42:12 +02:00
|
|
|
char r = event->SeenWithin(30) && event->IsRunning() ? '*' : ' ';
|
2006-01-15 13:09:16 +01:00
|
|
|
if (channel && withDate)
|
|
|
|
asprintf(&buffer, "%d\t%.*s\t%.*s\t%s\t%c%c%c\t%s", channel->Number(), 6, channel->ShortName(true), 6, *event->GetDateString(), *event->GetTimeString(), t, v, r, event->Title());
|
|
|
|
else if (channel)
|
2005-12-27 11:27:38 +01:00
|
|
|
asprintf(&buffer, "%d\t%.*s\t%s\t%c%c%c\t%s", channel->Number(), 6, channel->ShortName(true), *event->GetTimeString(), t, v, r, event->Title());
|
|
|
|
else
|
|
|
|
asprintf(&buffer, "%.*s\t%s\t%c%c%c\t%s", 6, *event->GetDateString(), *event->GetTimeString(), t, v, r, event->Title());
|
|
|
|
SetText(buffer, false);
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
return result;
|
2000-10-29 13:17:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuWhatsOn ----------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuWhatsOn : public cOsdMenu {
|
|
|
|
private:
|
2005-12-27 15:06:26 +01:00
|
|
|
bool now;
|
|
|
|
int helpKeys;
|
2006-01-15 13:44:55 +01:00
|
|
|
int timerState;
|
2000-10-29 13:17:22 +01:00
|
|
|
eOSState Record(void);
|
|
|
|
eOSState Switch(void);
|
2001-02-10 15:37:21 +01:00
|
|
|
static int currentChannel;
|
2003-12-22 13:29:24 +01:00
|
|
|
static const cEvent *scheduleEvent;
|
2005-12-27 11:27:38 +01:00
|
|
|
bool Update(void);
|
2005-12-27 15:06:26 +01:00
|
|
|
void SetHelpKeys(void);
|
2000-10-29 13:17:22 +01:00
|
|
|
public:
|
2001-02-10 15:37:21 +01:00
|
|
|
cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentChannelNr);
|
|
|
|
static int CurrentChannel(void) { return currentChannel; }
|
|
|
|
static void SetCurrentChannel(int ChannelNr) { currentChannel = ChannelNr; }
|
2003-12-22 13:29:24 +01:00
|
|
|
static const cEvent *ScheduleEvent(void);
|
2000-10-29 13:17:22 +01:00
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
|
|
|
};
|
|
|
|
|
2001-02-10 15:37:21 +01:00
|
|
|
int cMenuWhatsOn::currentChannel = 0;
|
2003-12-22 13:29:24 +01:00
|
|
|
const cEvent *cMenuWhatsOn::scheduleEvent = NULL;
|
2000-11-12 16:48:50 +01:00
|
|
|
|
2001-02-10 15:37:21 +01:00
|
|
|
cMenuWhatsOn::cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentChannelNr)
|
2004-02-29 14:21:22 +01:00
|
|
|
:cOsdMenu(Now ? tr("What's on now?") : tr("What's on next?"), CHNUMWIDTH, 7, 6, 4)
|
2000-10-29 13:17:22 +01:00
|
|
|
{
|
2005-12-27 15:06:26 +01:00
|
|
|
now = Now;
|
|
|
|
helpKeys = -1;
|
2006-01-15 13:44:55 +01:00
|
|
|
timerState = 0;
|
|
|
|
Timers.Modified(timerState);
|
2004-02-21 13:56:20 +01:00
|
|
|
for (cChannel *Channel = Channels.First(); Channel; Channel = Channels.Next(Channel)) {
|
2004-02-22 13:43:55 +01:00
|
|
|
if (!Channel->GroupSep()) {
|
2006-01-14 15:52:40 +01:00
|
|
|
const cSchedule *Schedule = Schedules->GetSchedule(Channel);
|
2004-02-22 13:43:55 +01:00
|
|
|
if (Schedule) {
|
|
|
|
const cEvent *Event = Now ? Schedule->GetPresentEvent() : Schedule->GetFollowingEvent();
|
|
|
|
if (Event)
|
2005-12-27 11:27:38 +01:00
|
|
|
Add(new cMenuScheduleItem(Event, Channel), Channel->Number() == CurrentChannelNr);
|
2004-02-22 13:43:55 +01:00
|
|
|
}
|
2004-02-21 13:56:20 +01:00
|
|
|
}
|
|
|
|
}
|
2001-02-10 15:37:21 +01:00
|
|
|
currentChannel = CurrentChannelNr;
|
2006-04-09 12:03:31 +02:00
|
|
|
Display();
|
2005-12-27 15:06:26 +01:00
|
|
|
SetHelpKeys();
|
2000-10-29 13:17:22 +01:00
|
|
|
}
|
|
|
|
|
2005-12-27 11:27:38 +01:00
|
|
|
bool cMenuWhatsOn::Update(void)
|
|
|
|
{
|
|
|
|
bool result = false;
|
2006-01-15 13:44:55 +01:00
|
|
|
if (Timers.Modified(timerState)) {
|
|
|
|
for (cOsdItem *item = First(); item; item = Next(item)) {
|
|
|
|
if (((cMenuScheduleItem *)item)->Update())
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
}
|
2005-12-27 11:27:38 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2005-12-27 15:06:26 +01:00
|
|
|
void cMenuWhatsOn::SetHelpKeys(void)
|
|
|
|
{
|
|
|
|
cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current());
|
|
|
|
int NewHelpKeys = 0;
|
|
|
|
if (item) {
|
|
|
|
if (item->timerMatch == tmFull)
|
|
|
|
NewHelpKeys = 2;
|
|
|
|
else
|
|
|
|
NewHelpKeys = 1;
|
|
|
|
}
|
|
|
|
if (NewHelpKeys != helpKeys) {
|
2006-03-31 13:00:05 +02:00
|
|
|
const char *Red[] = { NULL, tr("Button$Record"), tr("Button$Timer") };
|
2006-01-07 15:54:10 +01:00
|
|
|
SetHelp(Red[NewHelpKeys], now ? tr("Button$Next") : tr("Button$Now"), tr("Button$Schedule"), tr("Button$Switch"));
|
2005-12-27 15:06:26 +01:00
|
|
|
helpKeys = NewHelpKeys;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
const cEvent *cMenuWhatsOn::ScheduleEvent(void)
|
2000-11-12 16:48:50 +01:00
|
|
|
{
|
2003-12-22 13:29:24 +01:00
|
|
|
const cEvent *ei = scheduleEvent;
|
|
|
|
scheduleEvent = NULL;
|
2000-11-12 16:48:50 +01:00
|
|
|
return ei;
|
|
|
|
}
|
|
|
|
|
2000-10-29 13:17:22 +01:00
|
|
|
eOSState cMenuWhatsOn::Switch(void)
|
|
|
|
{
|
2005-12-27 11:27:38 +01:00
|
|
|
cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current());
|
2000-10-29 13:17:22 +01:00
|
|
|
if (item) {
|
2003-12-22 13:29:24 +01:00
|
|
|
cChannel *channel = Channels.GetByChannelID(item->event->ChannelID(), true);
|
2002-09-04 17:26:02 +02:00
|
|
|
if (channel && cDevice::PrimaryDevice()->SwitchChannel(channel, true))
|
2000-10-29 13:17:22 +01:00
|
|
|
return osEnd;
|
|
|
|
}
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtError, tr("Can't switch channel!"));
|
2000-10-29 13:17:22 +01:00
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuWhatsOn::Record(void)
|
|
|
|
{
|
2005-12-27 11:27:38 +01:00
|
|
|
cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current());
|
2001-06-02 10:47:40 +02:00
|
|
|
if (item) {
|
2005-12-28 11:35:33 +01:00
|
|
|
if (item->timerMatch == tmFull) {
|
|
|
|
int tm = tmNone;
|
|
|
|
cTimer *timer = Timers.GetMatch(item->event, &tm);
|
|
|
|
if (timer)
|
|
|
|
return AddSubMenu(new cMenuEditTimer(timer));
|
|
|
|
}
|
2003-12-22 13:29:24 +01:00
|
|
|
cTimer *timer = new cTimer(item->event);
|
2000-11-11 12:55:10 +01:00
|
|
|
cTimer *t = Timers.GetTimer(timer);
|
2003-06-06 15:02:37 +02:00
|
|
|
if (t) {
|
2000-11-11 12:55:10 +01:00
|
|
|
delete timer;
|
|
|
|
timer = t;
|
2005-12-27 15:06:26 +01:00
|
|
|
return AddSubMenu(new cMenuEditTimer(timer));
|
|
|
|
}
|
2006-01-08 11:44:37 +01:00
|
|
|
else {
|
2005-12-27 15:06:26 +01:00
|
|
|
Timers.Add(timer);
|
|
|
|
Timers.SetModified();
|
|
|
|
isyslog("timer %s added (active)", *timer->ToDescr());
|
2006-04-16 10:29:48 +02:00
|
|
|
if (timer->Matches(0, false, NEWTIMERLIMIT))
|
|
|
|
return AddSubMenu(new cMenuEditTimer(timer));
|
2005-12-27 15:06:26 +01:00
|
|
|
if (HasSubMenu())
|
|
|
|
CloseSubMenu();
|
|
|
|
if (Update())
|
|
|
|
Display();
|
|
|
|
SetHelpKeys();
|
2000-11-11 12:55:10 +01:00
|
|
|
}
|
2000-10-29 13:17:22 +01:00
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuWhatsOn::ProcessKey(eKeys Key)
|
|
|
|
{
|
2005-12-27 11:27:38 +01:00
|
|
|
bool HadSubMenu = HasSubMenu();
|
2000-10-29 13:17:22 +01:00
|
|
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
|
|
|
|
|
|
|
if (state == osUnknown) {
|
|
|
|
switch (Key) {
|
2002-10-27 14:32:06 +01:00
|
|
|
case kRecord:
|
2000-10-29 13:17:22 +01:00
|
|
|
case kRed: return Record();
|
2001-02-10 15:37:21 +01:00
|
|
|
case kYellow: state = osBack;
|
|
|
|
// continue with kGreen
|
|
|
|
case kGreen: {
|
2005-12-27 11:27:38 +01:00
|
|
|
cMenuScheduleItem *mi = (cMenuScheduleItem *)Get(Current());
|
2001-02-10 15:37:21 +01:00
|
|
|
if (mi) {
|
2003-12-22 13:29:24 +01:00
|
|
|
scheduleEvent = mi->event;
|
2004-02-21 13:56:20 +01:00
|
|
|
currentChannel = mi->channel->Number();
|
2001-02-10 15:37:21 +01:00
|
|
|
}
|
2000-11-12 16:48:50 +01:00
|
|
|
}
|
2001-02-10 15:37:21 +01:00
|
|
|
break;
|
2000-10-29 13:17:22 +01:00
|
|
|
case kBlue: return Switch();
|
2000-11-01 15:50:00 +01:00
|
|
|
case kOk: if (Count())
|
2006-02-25 14:39:29 +01:00
|
|
|
return AddSubMenu(new cMenuEvent(((cMenuScheduleItem *)Get(Current()))->event, true, true));
|
2000-11-01 15:50:00 +01:00
|
|
|
break;
|
2000-10-29 13:17:22 +01:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
2005-12-27 15:06:26 +01:00
|
|
|
else if (!HasSubMenu()) {
|
|
|
|
if (HadSubMenu && Update())
|
|
|
|
Display();
|
|
|
|
if (Key != kNone)
|
|
|
|
SetHelpKeys();
|
|
|
|
}
|
2000-10-29 13:17:22 +01:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuSchedule ---------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuSchedule : public cOsdMenu {
|
|
|
|
private:
|
2003-12-22 13:29:24 +01:00
|
|
|
cSchedulesLock schedulesLock;
|
2000-10-29 13:17:22 +01:00
|
|
|
const cSchedules *schedules;
|
|
|
|
bool now, next;
|
2000-11-26 16:18:52 +01:00
|
|
|
int otherChannel;
|
2005-12-27 15:06:26 +01:00
|
|
|
int helpKeys;
|
2006-01-15 13:44:55 +01:00
|
|
|
int timerState;
|
2006-01-15 13:09:16 +01:00
|
|
|
eOSState Number(void);
|
2000-10-29 13:17:22 +01:00
|
|
|
eOSState Record(void);
|
2000-11-26 16:18:52 +01:00
|
|
|
eOSState Switch(void);
|
2006-01-15 13:09:16 +01:00
|
|
|
void PrepareScheduleAllThis(const cEvent *Event, const cChannel *Channel);
|
|
|
|
void PrepareScheduleThisThis(const cEvent *Event, const cChannel *Channel);
|
|
|
|
void PrepareScheduleThisAll(const cEvent *Event, const cChannel *Channel);
|
|
|
|
void PrepareScheduleAllAll(const cEvent *Event, const cChannel *Channel);
|
2005-12-27 11:27:38 +01:00
|
|
|
bool Update(void);
|
2005-12-27 15:06:26 +01:00
|
|
|
void SetHelpKeys(void);
|
2000-10-29 13:17:22 +01:00
|
|
|
public:
|
|
|
|
cMenuSchedule(void);
|
2002-04-02 20:59:05 +02:00
|
|
|
virtual ~cMenuSchedule();
|
2000-10-29 13:17:22 +01:00
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
|
|
|
};
|
|
|
|
|
|
|
|
cMenuSchedule::cMenuSchedule(void)
|
2006-01-15 13:09:16 +01:00
|
|
|
:cOsdMenu("")
|
2000-10-29 13:17:22 +01:00
|
|
|
{
|
|
|
|
now = next = false;
|
2000-11-26 16:18:52 +01:00
|
|
|
otherChannel = 0;
|
2005-12-27 15:06:26 +01:00
|
|
|
helpKeys = -1;
|
2006-01-15 13:44:55 +01:00
|
|
|
timerState = 0;
|
|
|
|
Timers.Modified(timerState);
|
2006-01-15 13:09:16 +01:00
|
|
|
cMenuScheduleItem::SetSortMode(cMenuScheduleItem::ssmAllThis);
|
2002-06-16 12:57:31 +02:00
|
|
|
cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel());
|
2000-10-29 13:17:22 +01:00
|
|
|
if (channel) {
|
2002-10-06 10:25:42 +02:00
|
|
|
cMenuWhatsOn::SetCurrentChannel(channel->Number());
|
2003-12-22 13:29:24 +01:00
|
|
|
schedules = cSchedules::Schedules(schedulesLock);
|
2006-01-15 13:09:16 +01:00
|
|
|
PrepareScheduleAllThis(NULL, channel);
|
2005-12-27 15:06:26 +01:00
|
|
|
SetHelpKeys();
|
2000-10-29 13:17:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-02 20:59:05 +02:00
|
|
|
cMenuSchedule::~cMenuSchedule()
|
|
|
|
{
|
2003-12-22 13:29:24 +01:00
|
|
|
cMenuWhatsOn::ScheduleEvent(); // makes sure any posted data is cleared
|
2002-04-02 20:59:05 +02:00
|
|
|
}
|
|
|
|
|
2006-01-15 13:09:16 +01:00
|
|
|
void cMenuSchedule::PrepareScheduleAllThis(const cEvent *Event, const cChannel *Channel)
|
2000-10-29 13:17:22 +01:00
|
|
|
{
|
2000-11-12 16:48:50 +01:00
|
|
|
Clear();
|
2006-01-15 13:09:16 +01:00
|
|
|
SetCols(7, 6, 4);
|
2000-11-12 16:48:50 +01:00
|
|
|
char *buffer = NULL;
|
2002-10-06 10:25:42 +02:00
|
|
|
asprintf(&buffer, tr("Schedule - %s"), Channel->Name());
|
2001-08-25 13:27:26 +02:00
|
|
|
SetTitle(buffer);
|
2002-08-11 13:32:23 +02:00
|
|
|
free(buffer);
|
2006-01-15 13:09:16 +01:00
|
|
|
if (schedules && Channel) {
|
|
|
|
const cSchedule *Schedule = schedules->GetSchedule(Channel);
|
|
|
|
if (Schedule) {
|
2006-01-29 14:04:37 +01:00
|
|
|
const cEvent *PresentEvent = Event ? Event : Schedule->GetPresentEvent();
|
2006-01-15 13:09:16 +01:00
|
|
|
time_t now = time(NULL) - Setup.EPGLinger * 60;
|
|
|
|
for (const cEvent *ev = Schedule->Events()->First(); ev; ev = Schedule->Events()->Next(ev)) {
|
|
|
|
if (ev->EndTime() > now || ev == PresentEvent)
|
|
|
|
Add(new cMenuScheduleItem(ev), ev == PresentEvent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuSchedule::PrepareScheduleThisThis(const cEvent *Event, const cChannel *Channel)
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
SetCols(7, 6, 4);
|
|
|
|
char *buffer = NULL;
|
|
|
|
asprintf(&buffer, tr("This event - %s"), Channel->Name());
|
|
|
|
SetTitle(buffer);
|
|
|
|
free(buffer);
|
|
|
|
if (schedules && Channel && Event) {
|
2006-01-14 15:52:40 +01:00
|
|
|
const cSchedule *Schedule = schedules->GetSchedule(Channel);
|
2004-01-04 12:30:00 +01:00
|
|
|
if (Schedule) {
|
2004-02-21 15:30:35 +01:00
|
|
|
time_t now = time(NULL) - Setup.EPGLinger * 60;
|
2006-01-15 13:09:16 +01:00
|
|
|
for (const cEvent *ev = Schedule->Events()->First(); ev; ev = Schedule->Events()->Next(ev)) {
|
|
|
|
if ((ev->EndTime() > now || ev == Event) && !strcmp(ev->Title(), Event->Title()))
|
|
|
|
Add(new cMenuScheduleItem(ev), ev == Event);
|
2004-02-21 13:56:20 +01:00
|
|
|
}
|
2000-10-29 13:17:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-15 13:09:16 +01:00
|
|
|
void cMenuSchedule::PrepareScheduleThisAll(const cEvent *Event, const cChannel *Channel)
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
SetCols(CHNUMWIDTH, 7, 7, 6, 4);
|
|
|
|
SetTitle(tr("This event - all channels"));
|
|
|
|
if (schedules && Event) {
|
|
|
|
for (cChannel *ch = Channels.First(); ch; ch = Channels.Next(ch)) {
|
|
|
|
const cSchedule *Schedule = schedules->GetSchedule(ch);
|
|
|
|
if (Schedule) {
|
|
|
|
time_t now = time(NULL) - Setup.EPGLinger * 60;
|
|
|
|
for (const cEvent *ev = Schedule->Events()->First(); ev; ev = Schedule->Events()->Next(ev)) {
|
|
|
|
if ((ev->EndTime() > now || ev == Event) && !strcmp(ev->Title(), Event->Title()))
|
|
|
|
Add(new cMenuScheduleItem(ev, ch, true), ev == Event && ch == Channel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuSchedule::PrepareScheduleAllAll(const cEvent *Event, const cChannel *Channel)
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
SetCols(CHNUMWIDTH, 7, 7, 6, 4);
|
|
|
|
SetTitle(tr("All events - all channels"));
|
|
|
|
if (schedules) {
|
|
|
|
for (cChannel *ch = Channels.First(); ch; ch = Channels.Next(ch)) {
|
|
|
|
const cSchedule *Schedule = schedules->GetSchedule(ch);
|
|
|
|
if (Schedule) {
|
|
|
|
time_t now = time(NULL) - Setup.EPGLinger * 60;
|
|
|
|
for (const cEvent *ev = Schedule->Events()->First(); ev; ev = Schedule->Events()->Next(ev)) {
|
|
|
|
if (ev->EndTime() > now || ev == Event)
|
|
|
|
Add(new cMenuScheduleItem(ev, ch, true), ev == Event && ch == Channel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-27 11:27:38 +01:00
|
|
|
bool cMenuSchedule::Update(void)
|
|
|
|
{
|
|
|
|
bool result = false;
|
2006-01-15 13:44:55 +01:00
|
|
|
if (Timers.Modified(timerState)) {
|
|
|
|
for (cOsdItem *item = First(); item; item = Next(item)) {
|
|
|
|
if (((cMenuScheduleItem *)item)->Update())
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
}
|
2005-12-27 11:27:38 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2005-12-27 15:06:26 +01:00
|
|
|
void cMenuSchedule::SetHelpKeys(void)
|
|
|
|
{
|
|
|
|
cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current());
|
|
|
|
int NewHelpKeys = 0;
|
|
|
|
if (item) {
|
|
|
|
if (item->timerMatch == tmFull)
|
|
|
|
NewHelpKeys = 2;
|
|
|
|
else
|
|
|
|
NewHelpKeys = 1;
|
|
|
|
}
|
|
|
|
if (NewHelpKeys != helpKeys) {
|
2006-03-31 13:00:05 +02:00
|
|
|
const char *Red[] = { NULL, tr("Button$Record"), tr("Button$Timer") };
|
2006-01-07 15:54:10 +01:00
|
|
|
SetHelp(Red[NewHelpKeys], tr("Button$Now"), tr("Button$Next"));
|
2005-12-27 15:06:26 +01:00
|
|
|
helpKeys = NewHelpKeys;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-15 13:09:16 +01:00
|
|
|
eOSState cMenuSchedule::Number(void)
|
|
|
|
{
|
|
|
|
cMenuScheduleItem::IncSortMode();
|
|
|
|
cMenuScheduleItem *CurrentItem = (cMenuScheduleItem *)Get(Current());
|
|
|
|
const cChannel *Channel = NULL;
|
|
|
|
const cEvent *Event = NULL;
|
|
|
|
if (CurrentItem) {
|
|
|
|
Event = CurrentItem->event;
|
|
|
|
Channel = Channels.GetByChannelID(Event->ChannelID(), true);
|
|
|
|
}
|
2006-01-27 14:11:25 +01:00
|
|
|
else
|
|
|
|
Channel = Channels.GetByNumber(cDevice::CurrentChannel());
|
2006-01-15 13:09:16 +01:00
|
|
|
switch (cMenuScheduleItem::SortMode()) {
|
|
|
|
case cMenuScheduleItem::ssmAllThis: PrepareScheduleAllThis(Event, Channel); break;
|
|
|
|
case cMenuScheduleItem::ssmThisThis: PrepareScheduleThisThis(Event, Channel); break;
|
|
|
|
case cMenuScheduleItem::ssmThisAll: PrepareScheduleThisAll(Event, Channel); break;
|
|
|
|
case cMenuScheduleItem::ssmAllAll: PrepareScheduleAllAll(Event, Channel); break;
|
|
|
|
}
|
|
|
|
CurrentItem = (cMenuScheduleItem *)Get(Current());
|
|
|
|
Sort();
|
|
|
|
SetCurrent(CurrentItem);
|
|
|
|
Display();
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
2000-10-29 13:17:22 +01:00
|
|
|
eOSState cMenuSchedule::Record(void)
|
|
|
|
{
|
|
|
|
cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current());
|
2001-06-02 10:47:40 +02:00
|
|
|
if (item) {
|
2005-12-28 11:35:33 +01:00
|
|
|
if (item->timerMatch == tmFull) {
|
|
|
|
int tm = tmNone;
|
|
|
|
cTimer *timer = Timers.GetMatch(item->event, &tm);
|
|
|
|
if (timer)
|
|
|
|
return AddSubMenu(new cMenuEditTimer(timer));
|
|
|
|
}
|
2003-12-22 13:29:24 +01:00
|
|
|
cTimer *timer = new cTimer(item->event);
|
2000-11-11 12:55:10 +01:00
|
|
|
cTimer *t = Timers.GetTimer(timer);
|
2003-06-06 15:02:37 +02:00
|
|
|
if (t) {
|
2000-11-11 12:55:10 +01:00
|
|
|
delete timer;
|
|
|
|
timer = t;
|
2005-12-27 15:06:26 +01:00
|
|
|
return AddSubMenu(new cMenuEditTimer(timer));
|
|
|
|
}
|
2006-01-08 11:44:37 +01:00
|
|
|
else {
|
2005-12-27 15:06:26 +01:00
|
|
|
Timers.Add(timer);
|
|
|
|
Timers.SetModified();
|
|
|
|
isyslog("timer %s added (active)", *timer->ToDescr());
|
2006-04-16 10:29:48 +02:00
|
|
|
if (timer->Matches(0, false, NEWTIMERLIMIT))
|
|
|
|
return AddSubMenu(new cMenuEditTimer(timer));
|
2005-12-27 15:06:26 +01:00
|
|
|
if (HasSubMenu())
|
|
|
|
CloseSubMenu();
|
|
|
|
if (Update())
|
|
|
|
Display();
|
|
|
|
SetHelpKeys();
|
2000-11-11 12:55:10 +01:00
|
|
|
}
|
2000-10-29 13:17:22 +01:00
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
2000-11-26 16:18:52 +01:00
|
|
|
eOSState cMenuSchedule::Switch(void)
|
|
|
|
{
|
|
|
|
if (otherChannel) {
|
|
|
|
if (Channels.SwitchTo(otherChannel))
|
|
|
|
return osEnd;
|
|
|
|
}
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtError, tr("Can't switch channel!"));
|
2000-11-26 16:18:52 +01:00
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
2000-10-29 13:17:22 +01:00
|
|
|
eOSState cMenuSchedule::ProcessKey(eKeys Key)
|
|
|
|
{
|
2005-12-27 11:27:38 +01:00
|
|
|
bool HadSubMenu = HasSubMenu();
|
2000-10-29 13:17:22 +01:00
|
|
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
|
|
|
|
|
|
|
if (state == osUnknown) {
|
|
|
|
switch (Key) {
|
2006-01-15 13:09:16 +01:00
|
|
|
case k0: return Number();
|
2002-10-27 14:32:06 +01:00
|
|
|
case kRecord:
|
2000-10-29 13:17:22 +01:00
|
|
|
case kRed: return Record();
|
2001-03-18 10:16:56 +01:00
|
|
|
case kGreen: if (schedules) {
|
|
|
|
if (!now && !next) {
|
|
|
|
int ChannelNr = 0;
|
|
|
|
if (Count()) {
|
2003-12-22 13:29:24 +01:00
|
|
|
cChannel *channel = Channels.GetByChannelID(((cMenuScheduleItem *)Get(Current()))->event->ChannelID(), true);
|
2001-03-18 10:16:56 +01:00
|
|
|
if (channel)
|
2002-10-06 10:25:42 +02:00
|
|
|
ChannelNr = channel->Number();
|
2001-03-18 10:16:56 +01:00
|
|
|
}
|
|
|
|
now = true;
|
|
|
|
return AddSubMenu(new cMenuWhatsOn(schedules, true, ChannelNr));
|
|
|
|
}
|
|
|
|
now = !now;
|
|
|
|
next = !next;
|
|
|
|
return AddSubMenu(new cMenuWhatsOn(schedules, now, cMenuWhatsOn::CurrentChannel()));
|
|
|
|
}
|
|
|
|
case kYellow: if (schedules)
|
|
|
|
return AddSubMenu(new cMenuWhatsOn(schedules, false, cMenuWhatsOn::CurrentChannel()));
|
|
|
|
break;
|
2006-02-05 13:32:14 +01:00
|
|
|
case kBlue: if (Count() && otherChannel)
|
2001-03-18 10:16:56 +01:00
|
|
|
return Switch();
|
|
|
|
break;
|
2000-11-01 15:50:00 +01:00
|
|
|
case kOk: if (Count())
|
2006-02-25 14:39:29 +01:00
|
|
|
return AddSubMenu(new cMenuEvent(((cMenuScheduleItem *)Get(Current()))->event, otherChannel, true));
|
2000-11-01 15:50:00 +01:00
|
|
|
break;
|
2000-10-29 13:17:22 +01:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
2000-11-12 16:48:50 +01:00
|
|
|
else if (!HasSubMenu()) {
|
2000-11-01 11:45:05 +01:00
|
|
|
now = next = false;
|
2003-12-22 13:29:24 +01:00
|
|
|
const cEvent *ei = cMenuWhatsOn::ScheduleEvent();
|
2000-11-12 16:48:50 +01:00
|
|
|
if (ei) {
|
2003-12-22 13:29:24 +01:00
|
|
|
cChannel *channel = Channels.GetByChannelID(ei->ChannelID(), true);
|
2000-11-12 16:48:50 +01:00
|
|
|
if (channel) {
|
2006-01-15 13:09:16 +01:00
|
|
|
cMenuScheduleItem::SetSortMode(cMenuScheduleItem::ssmAllThis);
|
|
|
|
PrepareScheduleAllThis(NULL, channel);
|
2002-10-06 10:25:42 +02:00
|
|
|
if (channel->Number() != cDevice::CurrentChannel()) {
|
|
|
|
otherChannel = channel->Number();
|
2006-01-07 15:54:10 +01:00
|
|
|
SetHelp(Count() ? tr("Button$Record") : NULL, tr("Button$Now"), tr("Button$Next"), tr("Button$Switch"));
|
2000-11-26 16:18:52 +01:00
|
|
|
}
|
2000-11-12 16:48:50 +01:00
|
|
|
Display();
|
|
|
|
}
|
|
|
|
}
|
2005-12-27 11:27:38 +01:00
|
|
|
else if (HadSubMenu && Update())
|
|
|
|
Display();
|
2005-12-27 15:06:26 +01:00
|
|
|
if (Key != kNone)
|
|
|
|
SetHelpKeys();
|
2000-11-12 16:48:50 +01:00
|
|
|
}
|
2000-10-29 13:17:22 +01:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2002-10-13 12:14:49 +02:00
|
|
|
// --- cMenuCommands ---------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuCommands : public cOsdMenu {
|
|
|
|
private:
|
|
|
|
cCommands *commands;
|
|
|
|
char *parameters;
|
|
|
|
eOSState Execute(void);
|
|
|
|
public:
|
|
|
|
cMenuCommands(const char *Title, cCommands *Commands, const char *Parameters = NULL);
|
|
|
|
virtual ~cMenuCommands();
|
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
|
|
|
};
|
|
|
|
|
|
|
|
cMenuCommands::cMenuCommands(const char *Title, cCommands *Commands, const char *Parameters)
|
|
|
|
:cOsdMenu(Title)
|
|
|
|
{
|
|
|
|
SetHasHotkeys();
|
|
|
|
commands = Commands;
|
|
|
|
parameters = Parameters ? strdup(Parameters) : NULL;
|
2004-03-14 10:34:56 +01:00
|
|
|
for (cCommand *command = commands->First(); command; command = commands->Next(command))
|
|
|
|
Add(new cOsdItem(hk(command->Title())));
|
2002-10-13 12:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cMenuCommands::~cMenuCommands()
|
|
|
|
{
|
|
|
|
free(parameters);
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuCommands::Execute(void)
|
|
|
|
{
|
|
|
|
cCommand *command = commands->Get(Current());
|
|
|
|
if (command) {
|
|
|
|
char *buffer = NULL;
|
|
|
|
bool confirmed = true;
|
|
|
|
if (command->Confirm()) {
|
|
|
|
asprintf(&buffer, "%s?", command->Title());
|
|
|
|
confirmed = Interface->Confirm(buffer);
|
|
|
|
free(buffer);
|
|
|
|
}
|
|
|
|
if (confirmed) {
|
|
|
|
asprintf(&buffer, "%s...", command->Title());
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtStatus, buffer);
|
2002-10-13 12:14:49 +02:00
|
|
|
free(buffer);
|
|
|
|
const char *Result = command->Execute(parameters);
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtStatus, NULL);
|
2002-10-13 12:14:49 +02:00
|
|
|
if (Result)
|
|
|
|
return AddSubMenu(new cMenuText(command->Title(), Result, fontFix));
|
|
|
|
return osEnd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuCommands::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
|
|
|
|
|
|
|
if (state == osUnknown) {
|
|
|
|
switch (Key) {
|
2005-05-16 14:45:11 +02:00
|
|
|
case kRed:
|
|
|
|
case kGreen:
|
|
|
|
case kYellow:
|
|
|
|
case kBlue: return osContinue;
|
|
|
|
case kOk: return Execute();
|
|
|
|
default: break;
|
2002-10-13 12:14:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2003-01-06 14:44:27 +01:00
|
|
|
// --- cMenuCam --------------------------------------------------------------
|
|
|
|
|
|
|
|
cMenuCam::cMenuCam(cCiMenu *CiMenu)
|
|
|
|
:cOsdMenu("")
|
|
|
|
{
|
2005-10-02 09:59:30 +02:00
|
|
|
dsyslog("CAM: Menu ------------------");
|
2003-01-06 14:44:27 +01:00
|
|
|
ciMenu = CiMenu;
|
|
|
|
selected = false;
|
2005-10-02 09:59:30 +02:00
|
|
|
offset = 0;
|
2003-01-06 14:44:27 +01:00
|
|
|
if (ciMenu->Selectable())
|
|
|
|
SetHasHotkeys();
|
2005-10-02 09:59:30 +02:00
|
|
|
SetTitle(*ciMenu->TitleText() ? ciMenu->TitleText() : "CAM");
|
2005-10-02 14:50:44 +02:00
|
|
|
dsyslog("CAM: '%s'", ciMenu->TitleText());
|
2005-10-02 09:59:30 +02:00
|
|
|
if (*ciMenu->SubTitleText()) {
|
2005-10-02 14:50:44 +02:00
|
|
|
dsyslog("CAM: '%s'", ciMenu->SubTitleText());
|
2005-10-03 11:26:07 +02:00
|
|
|
AddMultiLineItem(ciMenu->SubTitleText());
|
|
|
|
offset = Count();
|
2005-10-02 09:59:30 +02:00
|
|
|
}
|
|
|
|
for (int i = 0; i < ciMenu->NumEntries(); i++) {
|
2005-10-02 15:04:34 +02:00
|
|
|
Add(new cOsdItem(hk(ciMenu->Entry(i)), osUnknown, ciMenu->Selectable()));
|
2005-10-02 14:50:44 +02:00
|
|
|
dsyslog("CAM: '%s'", ciMenu->Entry(i));
|
2005-10-02 09:59:30 +02:00
|
|
|
}
|
|
|
|
if (*ciMenu->BottomText()) {
|
2005-10-03 11:26:07 +02:00
|
|
|
AddMultiLineItem(ciMenu->BottomText());
|
2005-10-02 14:50:44 +02:00
|
|
|
dsyslog("CAM: '%s'", ciMenu->BottomText());
|
2005-10-02 09:59:30 +02:00
|
|
|
}
|
2003-01-06 14:44:27 +01:00
|
|
|
Display();
|
|
|
|
}
|
|
|
|
|
|
|
|
cMenuCam::~cMenuCam()
|
|
|
|
{
|
|
|
|
if (!selected)
|
2005-10-02 13:54:34 +02:00
|
|
|
ciMenu->Abort();
|
2003-01-06 14:44:27 +01:00
|
|
|
delete ciMenu;
|
|
|
|
}
|
|
|
|
|
2005-10-03 11:26:07 +02:00
|
|
|
void cMenuCam::AddMultiLineItem(const char *s)
|
|
|
|
{
|
|
|
|
while (s && *s) {
|
|
|
|
const char *p = strchr(s, '\n');
|
|
|
|
int l = p ? p - s : strlen(s);
|
|
|
|
cOsdItem *item = new cOsdItem;
|
|
|
|
item->SetSelectable(false);
|
|
|
|
item->SetText(strndup(s, l), false);
|
|
|
|
Add(item);
|
|
|
|
s = p ? p + 1 : p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-06 14:44:27 +01:00
|
|
|
eOSState cMenuCam::Select(void)
|
|
|
|
{
|
|
|
|
if (ciMenu->Selectable()) {
|
2005-10-02 09:59:30 +02:00
|
|
|
ciMenu->Select(Current() - offset);
|
|
|
|
dsyslog("CAM: select %d", Current() - offset);
|
2003-01-06 14:44:27 +01:00
|
|
|
}
|
2005-10-02 13:54:34 +02:00
|
|
|
else
|
|
|
|
ciMenu->Cancel();
|
|
|
|
selected = true;
|
2003-01-06 16:13:53 +01:00
|
|
|
return osEnd;
|
2003-01-06 14:44:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuCam::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
|
|
|
|
|
|
|
if (state == osUnknown) {
|
|
|
|
switch (Key) {
|
|
|
|
case kOk: return Select();
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
2005-10-02 13:54:34 +02:00
|
|
|
else if (state == osBack) {
|
|
|
|
ciMenu->Cancel();
|
|
|
|
selected = true;
|
|
|
|
return osEnd;
|
|
|
|
}
|
2005-10-02 12:59:53 +02:00
|
|
|
if (ciMenu->HasUpdate()) {
|
2005-10-02 13:54:34 +02:00
|
|
|
selected = true;
|
2005-10-02 12:59:53 +02:00
|
|
|
return osEnd;
|
|
|
|
}
|
2003-01-06 14:44:27 +01:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuCamEnquiry -------------------------------------------------------
|
|
|
|
|
|
|
|
cMenuCamEnquiry::cMenuCamEnquiry(cCiEnquiry *CiEnquiry)
|
2005-10-03 12:27:15 +02:00
|
|
|
:cOsdMenu("", 1)
|
2003-01-06 14:44:27 +01:00
|
|
|
{
|
|
|
|
ciEnquiry = CiEnquiry;
|
2003-01-19 14:59:46 +01:00
|
|
|
int Length = ciEnquiry->ExpectedLength();
|
|
|
|
input = MALLOC(char, Length + 1);
|
|
|
|
*input = 0;
|
2003-01-06 14:44:27 +01:00
|
|
|
replied = false;
|
2005-10-03 12:27:15 +02:00
|
|
|
SetTitle("CAM");
|
|
|
|
Add(new cOsdItem(ciEnquiry->Text(), osUnknown, false));
|
|
|
|
Add(new cOsdItem("", osUnknown, false));
|
|
|
|
Add(new cMenuEditNumItem("", input, Length, ciEnquiry->Blind()));
|
2003-01-06 14:44:27 +01:00
|
|
|
Display();
|
|
|
|
}
|
|
|
|
|
|
|
|
cMenuCamEnquiry::~cMenuCamEnquiry()
|
|
|
|
{
|
|
|
|
if (!replied)
|
2005-10-03 12:58:22 +02:00
|
|
|
ciEnquiry->Abort();
|
2003-01-19 14:59:46 +01:00
|
|
|
free(input);
|
2003-01-06 14:44:27 +01:00
|
|
|
delete ciEnquiry;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuCamEnquiry::Reply(void)
|
|
|
|
{
|
2005-10-03 12:27:15 +02:00
|
|
|
if (ciEnquiry->ExpectedLength() < 0xFF && int(strlen(input)) != ciEnquiry->ExpectedLength()) {
|
|
|
|
char buffer[64];
|
|
|
|
snprintf(buffer, sizeof(buffer), tr("Please enter %d digits!"), ciEnquiry->ExpectedLength());
|
|
|
|
Skins.Message(mtError, buffer);
|
|
|
|
return osContinue;
|
|
|
|
}
|
2003-01-19 14:59:46 +01:00
|
|
|
ciEnquiry->Reply(input);
|
2003-01-06 14:44:27 +01:00
|
|
|
replied = true;
|
|
|
|
return osEnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuCamEnquiry::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
|
|
|
|
|
|
|
if (state == osUnknown) {
|
|
|
|
switch (Key) {
|
|
|
|
case kOk: return Reply();
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
2005-10-03 12:58:22 +02:00
|
|
|
else if (state == osBack) {
|
|
|
|
ciEnquiry->Cancel();
|
|
|
|
replied = true;
|
|
|
|
return osEnd;
|
|
|
|
}
|
2003-01-06 14:44:27 +01:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- CamControl ------------------------------------------------------------
|
|
|
|
|
|
|
|
cOsdObject *CamControl(void)
|
|
|
|
{
|
|
|
|
for (int d = 0; d < cDevice::NumDevices(); d++) {
|
|
|
|
cDevice *Device = cDevice::GetDevice(d);
|
|
|
|
if (Device) {
|
|
|
|
cCiHandler *CiHandler = Device->CiHandler();
|
2003-04-20 09:53:08 +02:00
|
|
|
if (CiHandler && CiHandler->HasUserIO()) {
|
2003-01-06 14:44:27 +01:00
|
|
|
cCiMenu *CiMenu = CiHandler->GetMenu();
|
|
|
|
if (CiMenu)
|
|
|
|
return new cMenuCam(CiMenu);
|
|
|
|
else {
|
|
|
|
cCiEnquiry *CiEnquiry = CiHandler->GetEnquiry();
|
|
|
|
if (CiEnquiry)
|
|
|
|
return new cMenuCamEnquiry(CiEnquiry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-05-16 14:45:11 +02:00
|
|
|
// --- cMenuRecording --------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuRecording : public cOsdMenu {
|
|
|
|
private:
|
|
|
|
const cRecording *recording;
|
2006-01-15 15:06:19 +01:00
|
|
|
bool withButtons;
|
2005-05-16 14:45:11 +02:00
|
|
|
public:
|
2006-01-15 15:06:19 +01:00
|
|
|
cMenuRecording(const cRecording *Recording, bool WithButtons = false);
|
2005-05-16 14:45:11 +02:00
|
|
|
virtual void Display(void);
|
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
|
|
|
};
|
|
|
|
|
2006-01-15 15:06:19 +01:00
|
|
|
cMenuRecording::cMenuRecording(const cRecording *Recording, bool WithButtons)
|
2005-08-14 12:06:40 +02:00
|
|
|
:cOsdMenu(tr("Recording info"))
|
2005-05-16 14:45:11 +02:00
|
|
|
{
|
|
|
|
recording = Recording;
|
2006-01-15 15:06:19 +01:00
|
|
|
withButtons = WithButtons;
|
|
|
|
if (withButtons)
|
2006-01-07 15:54:10 +01:00
|
|
|
SetHelp(tr("Button$Play"), tr("Button$Rewind"));
|
2005-05-16 14:45:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuRecording::Display(void)
|
|
|
|
{
|
|
|
|
cOsdMenu::Display();
|
|
|
|
DisplayMenu()->SetRecording(recording);
|
2006-04-09 14:31:33 +02:00
|
|
|
if (recording->Info()->Description())
|
|
|
|
cStatus::MsgOsdTextItem(recording->Info()->Description());
|
2005-05-16 14:45:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuRecording::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
switch (Key) {
|
|
|
|
case kUp|k_Repeat:
|
|
|
|
case kUp:
|
|
|
|
case kDown|k_Repeat:
|
|
|
|
case kDown:
|
|
|
|
case kLeft|k_Repeat:
|
|
|
|
case kLeft:
|
|
|
|
case kRight|k_Repeat:
|
|
|
|
case kRight:
|
|
|
|
DisplayMenu()->Scroll(NORMALKEY(Key) == kUp || NORMALKEY(Key) == kLeft, NORMALKEY(Key) == kLeft || NORMALKEY(Key) == kRight);
|
|
|
|
cStatus::MsgOsdTextItem(NULL, NORMALKEY(Key) == kUp);
|
|
|
|
return osContinue;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
|
|
|
|
|
|
|
if (state == osUnknown) {
|
|
|
|
switch (Key) {
|
2006-01-15 15:06:19 +01:00
|
|
|
case kRed: if (withButtons)
|
|
|
|
Key = kOk; // will play the recording, even if recording commands are defined
|
|
|
|
case kGreen: if (!withButtons)
|
|
|
|
break;
|
|
|
|
cRemote::Put(Key, true);
|
2005-05-16 14:45:11 +02:00
|
|
|
// continue with osBack to close the info menu and process the key
|
|
|
|
case kOk: return osBack;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
// --- cMenuRecordingItem ----------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuRecordingItem : public cOsdItem {
|
2002-01-20 14:05:28 +01:00
|
|
|
private:
|
|
|
|
char *fileName;
|
|
|
|
char *name;
|
|
|
|
int totalEntries, newEntries;
|
2000-03-11 11:22:37 +01:00
|
|
|
public:
|
2002-01-20 14:05:28 +01:00
|
|
|
cMenuRecordingItem(cRecording *Recording, int Level);
|
|
|
|
~cMenuRecordingItem();
|
|
|
|
void IncrementCounter(bool New);
|
|
|
|
const char *Name(void) { return name; }
|
|
|
|
const char *FileName(void) { return fileName; }
|
|
|
|
bool IsDirectory(void) { return name != NULL; }
|
2000-03-11 11:22:37 +01:00
|
|
|
};
|
|
|
|
|
2002-01-20 14:05:28 +01:00
|
|
|
cMenuRecordingItem::cMenuRecordingItem(cRecording *Recording, int Level)
|
2000-03-11 11:22:37 +01:00
|
|
|
{
|
2002-01-20 14:05:28 +01:00
|
|
|
fileName = strdup(Recording->FileName());
|
|
|
|
name = NULL;
|
|
|
|
totalEntries = newEntries = 0;
|
|
|
|
SetText(Recording->Title('\t', true, Level));
|
|
|
|
if (*Text() == '\t')
|
|
|
|
name = strdup(Text() + 2); // 'Text() + 2' to skip the two '\t'
|
|
|
|
}
|
|
|
|
|
|
|
|
cMenuRecordingItem::~cMenuRecordingItem()
|
|
|
|
{
|
2002-08-11 13:32:23 +02:00
|
|
|
free(fileName);
|
|
|
|
free(name);
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
|
2002-01-20 14:05:28 +01:00
|
|
|
void cMenuRecordingItem::IncrementCounter(bool New)
|
2000-03-11 11:22:37 +01:00
|
|
|
{
|
2002-01-20 14:05:28 +01:00
|
|
|
totalEntries++;
|
|
|
|
if (New)
|
|
|
|
newEntries++;
|
|
|
|
char *buffer = NULL;
|
|
|
|
asprintf(&buffer, "%d\t%d\t%s", totalEntries, newEntries, name);
|
|
|
|
SetText(buffer, false);
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuRecordings -------------------------------------------------------
|
|
|
|
|
2002-01-20 14:05:28 +01:00
|
|
|
cMenuRecordings::cMenuRecordings(const char *Base, int Level, bool OpenSubMenus)
|
2006-06-03 13:36:07 +02:00
|
|
|
:cOsdMenu(Base ? Base : tr("Recordings"), 9, 7)
|
2002-01-20 14:05:28 +01:00
|
|
|
{
|
|
|
|
base = Base ? strdup(Base) : NULL;
|
|
|
|
level = Setup.RecordingDirs ? Level : -1;
|
2005-09-25 11:00:57 +02:00
|
|
|
Recordings.StateChanged(recordingsState); // just to get the current state
|
2005-11-06 09:44:58 +01:00
|
|
|
helpKeys = -1;
|
2003-05-11 12:21:58 +02:00
|
|
|
Display(); // this keeps the higher level menus from showing up briefly when pressing 'Back' during replay
|
2005-09-25 11:00:57 +02:00
|
|
|
Set();
|
2004-06-13 20:26:51 +02:00
|
|
|
if (Current() < 0)
|
|
|
|
SetCurrent(First());
|
2005-09-25 11:00:57 +02:00
|
|
|
else if (OpenSubMenus && cReplayControl::LastReplayed() && Open(true))
|
2004-06-13 20:26:51 +02:00
|
|
|
return;
|
2005-10-01 10:11:33 +02:00
|
|
|
Display();
|
2002-01-20 14:05:28 +01:00
|
|
|
SetHelpKeys();
|
|
|
|
}
|
|
|
|
|
|
|
|
cMenuRecordings::~cMenuRecordings()
|
2000-03-11 11:22:37 +01:00
|
|
|
{
|
2002-01-26 11:09:25 +01:00
|
|
|
helpKeys = -1;
|
2002-08-11 13:32:23 +02:00
|
|
|
free(base);
|
2002-01-20 14:05:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuRecordings::SetHelpKeys(void)
|
|
|
|
{
|
|
|
|
cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current());
|
2005-11-06 09:44:58 +01:00
|
|
|
int NewHelpKeys = 0;
|
2002-01-20 14:05:28 +01:00
|
|
|
if (ri) {
|
|
|
|
if (ri->IsDirectory())
|
|
|
|
NewHelpKeys = 1;
|
|
|
|
else {
|
|
|
|
NewHelpKeys = 2;
|
|
|
|
cRecording *recording = GetRecording(ri);
|
2005-05-16 14:45:11 +02:00
|
|
|
if (recording && recording->Info()->Title())
|
2002-01-20 14:05:28 +01:00
|
|
|
NewHelpKeys = 3;
|
|
|
|
}
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
2002-01-20 14:05:28 +01:00
|
|
|
if (NewHelpKeys != helpKeys) {
|
|
|
|
switch (NewHelpKeys) {
|
|
|
|
case 0: SetHelp(NULL); break;
|
2006-01-07 15:54:10 +01:00
|
|
|
case 1: SetHelp(tr("Button$Open")); break;
|
2002-01-20 14:05:28 +01:00
|
|
|
case 2:
|
2006-02-25 14:39:29 +01:00
|
|
|
case 3: SetHelp(RecordingCommands.Count() ? tr("Commands") : tr("Button$Play"), tr("Button$Rewind"), tr("Button$Delete"), NewHelpKeys == 3 ? tr("Button$Info") : NULL);
|
2002-01-20 14:05:28 +01:00
|
|
|
}
|
|
|
|
helpKeys = NewHelpKeys;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 11:00:57 +02:00
|
|
|
void cMenuRecordings::Set(bool Refresh)
|
|
|
|
{
|
|
|
|
const char *CurrentRecording = cReplayControl::LastReplayed();
|
|
|
|
cMenuRecordingItem *LastItem = NULL;
|
|
|
|
char *LastItemText = NULL;
|
|
|
|
cThreadLock RecordingsLock(&Recordings);
|
|
|
|
if (Refresh) {
|
|
|
|
cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current());
|
|
|
|
if (ri) {
|
2005-10-01 10:13:27 +02:00
|
|
|
cRecording *Recording = Recordings.GetByName(ri->FileName());
|
2005-09-25 11:00:57 +02:00
|
|
|
if (Recording)
|
|
|
|
CurrentRecording = Recording->FileName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Clear();
|
|
|
|
Recordings.Sort();
|
|
|
|
for (cRecording *recording = Recordings.First(); recording; recording = Recordings.Next(recording)) {
|
|
|
|
if (!base || (strstr(recording->Name(), base) == recording->Name() && recording->Name()[strlen(base)] == '~')) {
|
|
|
|
cMenuRecordingItem *Item = new cMenuRecordingItem(recording, level);
|
|
|
|
if (*Item->Text() && (!LastItem || strcmp(Item->Text(), LastItemText) != 0)) {
|
|
|
|
Add(Item);
|
|
|
|
LastItem = Item;
|
|
|
|
free(LastItemText);
|
|
|
|
LastItemText = strdup(LastItem->Text()); // must use a copy because of the counters!
|
|
|
|
}
|
|
|
|
else
|
|
|
|
delete Item;
|
|
|
|
if (LastItem) {
|
|
|
|
if (CurrentRecording && strcmp(CurrentRecording, recording->FileName()) == 0)
|
|
|
|
SetCurrent(LastItem);
|
|
|
|
if (LastItem->IsDirectory())
|
|
|
|
LastItem->IncrementCounter(recording->IsNew());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(LastItemText);
|
2005-10-01 10:11:33 +02:00
|
|
|
if (Refresh)
|
|
|
|
Display();
|
2005-09-25 11:00:57 +02:00
|
|
|
}
|
|
|
|
|
2002-01-20 14:05:28 +01:00
|
|
|
cRecording *cMenuRecordings::GetRecording(cMenuRecordingItem *Item)
|
|
|
|
{
|
|
|
|
cRecording *recording = Recordings.GetByName(Item->FileName());
|
|
|
|
if (!recording)
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtError, tr("Error while accessing recording!"));
|
2002-01-20 14:05:28 +01:00
|
|
|
return recording;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cMenuRecordings::Open(bool OpenSubMenus)
|
|
|
|
{
|
|
|
|
cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current());
|
|
|
|
if (ri && ri->IsDirectory()) {
|
|
|
|
const char *t = ri->Name();
|
|
|
|
char *buffer = NULL;
|
|
|
|
if (base) {
|
|
|
|
asprintf(&buffer, "%s~%s", base, t);
|
|
|
|
t = buffer;
|
|
|
|
}
|
|
|
|
AddSubMenu(new cMenuRecordings(t, level + 1, OpenSubMenus));
|
2002-08-11 13:32:23 +02:00
|
|
|
free(buffer);
|
2002-01-20 14:05:28 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuRecordings::Play(void)
|
|
|
|
{
|
|
|
|
cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current());
|
|
|
|
if (ri) {
|
2002-01-20 14:05:28 +01:00
|
|
|
if (ri->IsDirectory())
|
|
|
|
Open();
|
|
|
|
else {
|
|
|
|
cRecording *recording = GetRecording(ri);
|
|
|
|
if (recording) {
|
|
|
|
cReplayControl::SetRecording(recording->FileName(), recording->Title());
|
|
|
|
return osReplay;
|
|
|
|
}
|
|
|
|
}
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
2001-02-11 11:04:41 +01:00
|
|
|
eOSState cMenuRecordings::Rewind(void)
|
|
|
|
{
|
2002-10-13 12:14:49 +02:00
|
|
|
if (HasSubMenu() || Count() == 0)
|
|
|
|
return osContinue;
|
2001-02-11 11:04:41 +01:00
|
|
|
cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current());
|
2002-01-20 14:05:28 +01:00
|
|
|
if (ri && !ri->IsDirectory()) {
|
2002-06-16 12:57:31 +02:00
|
|
|
cDevice::PrimaryDevice()->StopReplay(); // must do this first to be able to rewind the currently replayed recording
|
2002-01-20 14:05:28 +01:00
|
|
|
cResumeFile ResumeFile(ri->FileName());
|
2001-02-11 11:04:41 +01:00
|
|
|
ResumeFile.Delete();
|
|
|
|
return Play();
|
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
2002-10-06 10:40:27 +02:00
|
|
|
eOSState cMenuRecordings::Delete(void)
|
2000-03-11 11:22:37 +01:00
|
|
|
{
|
2002-10-13 12:14:49 +02:00
|
|
|
if (HasSubMenu() || Count() == 0)
|
|
|
|
return osContinue;
|
2000-03-11 11:22:37 +01:00
|
|
|
cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current());
|
2002-01-20 14:05:28 +01:00
|
|
|
if (ri && !ri->IsDirectory()) {
|
2002-02-17 14:29:13 +01:00
|
|
|
if (Interface->Confirm(tr("Delete recording?"))) {
|
|
|
|
cRecordControl *rc = cRecordControls::GetRecordControl(ri->FileName());
|
|
|
|
if (rc) {
|
|
|
|
if (Interface->Confirm(tr("Timer still recording - really delete?"))) {
|
|
|
|
cTimer *timer = rc->Timer();
|
|
|
|
if (timer) {
|
2002-03-31 21:24:10 +02:00
|
|
|
timer->Skip();
|
2002-02-17 14:29:13 +01:00
|
|
|
cRecordControls::Process(time(NULL));
|
2003-05-29 11:39:29 +02:00
|
|
|
if (timer->IsSingleEvent()) {
|
2005-03-20 15:15:42 +01:00
|
|
|
isyslog("deleting timer %s", *timer->ToDescr());
|
2003-05-29 11:39:29 +02:00
|
|
|
Timers.Del(timer);
|
|
|
|
}
|
2004-10-31 10:22:32 +01:00
|
|
|
Timers.SetModified();
|
2002-01-20 14:05:28 +01:00
|
|
|
}
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
2002-02-17 14:29:13 +01:00
|
|
|
else
|
|
|
|
return osContinue;
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
2002-02-17 14:29:13 +01:00
|
|
|
cRecording *recording = GetRecording(ri);
|
|
|
|
if (recording) {
|
|
|
|
if (recording->Delete()) {
|
|
|
|
cReplayControl::ClearLastReplayed(ri->FileName());
|
2005-09-25 13:49:31 +02:00
|
|
|
Recordings.DelByName(ri->FileName());
|
2002-02-17 14:29:13 +01:00
|
|
|
cOsdMenu::Del(Current());
|
2005-03-20 11:27:44 +01:00
|
|
|
SetHelpKeys();
|
2002-02-17 14:29:13 +01:00
|
|
|
Display();
|
|
|
|
if (!Count())
|
|
|
|
return osBack;
|
|
|
|
}
|
|
|
|
else
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtError, tr("Error while deleting recording!"));
|
2002-02-17 14:29:13 +01:00
|
|
|
}
|
|
|
|
}
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
2005-05-16 14:45:11 +02:00
|
|
|
eOSState cMenuRecordings::Info(void)
|
2000-07-24 16:43:04 +02:00
|
|
|
{
|
|
|
|
if (HasSubMenu() || Count() == 0)
|
|
|
|
return osContinue;
|
|
|
|
cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current());
|
2002-01-20 14:05:28 +01:00
|
|
|
if (ri && !ri->IsDirectory()) {
|
|
|
|
cRecording *recording = GetRecording(ri);
|
2005-05-16 14:45:11 +02:00
|
|
|
if (recording && recording->Info()->Title())
|
2006-01-15 15:06:19 +01:00
|
|
|
return AddSubMenu(new cMenuRecording(recording, true));
|
2002-01-20 14:05:28 +01:00
|
|
|
}
|
2000-07-24 16:43:04 +02:00
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
2002-10-13 12:14:49 +02:00
|
|
|
eOSState cMenuRecordings::Commands(eKeys Key)
|
|
|
|
{
|
|
|
|
if (HasSubMenu() || Count() == 0)
|
|
|
|
return osContinue;
|
|
|
|
cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current());
|
|
|
|
if (ri && !ri->IsDirectory()) {
|
|
|
|
cRecording *recording = GetRecording(ri);
|
|
|
|
if (recording) {
|
|
|
|
char *parameter = NULL;
|
2006-04-16 12:55:28 +02:00
|
|
|
asprintf(¶meter, "\"%s\"", *strescape(recording->FileName(), "\"$"));
|
2002-10-13 12:14:49 +02:00
|
|
|
cMenuCommands *menu;
|
|
|
|
eOSState state = AddSubMenu(menu = new cMenuCommands(tr("Recording commands"), &RecordingCommands, parameter));
|
|
|
|
free(parameter);
|
|
|
|
if (Key != kNone)
|
|
|
|
state = menu->ProcessKey(Key);
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState cMenuRecordings::ProcessKey(eKeys Key)
|
|
|
|
{
|
2002-02-10 11:36:07 +01:00
|
|
|
bool HadSubMenu = HasSubMenu();
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
|
|
|
|
|
|
|
if (state == osUnknown) {
|
|
|
|
switch (Key) {
|
2002-10-13 12:14:49 +02:00
|
|
|
case kOk: return Play();
|
|
|
|
case kRed: return (helpKeys > 1 && RecordingCommands.Count()) ? Commands() : Play();
|
2001-02-11 11:04:41 +01:00
|
|
|
case kGreen: return Rewind();
|
2002-10-06 10:40:27 +02:00
|
|
|
case kYellow: return Delete();
|
2005-05-16 14:45:11 +02:00
|
|
|
case kBlue: return Info();
|
2002-10-13 12:14:49 +02:00
|
|
|
case k1...k9: return Commands(Key);
|
2005-09-25 11:00:57 +02:00
|
|
|
case kNone: if (Recordings.StateChanged(recordingsState))
|
|
|
|
Set(true);
|
|
|
|
break;
|
2000-03-11 11:22:37 +01:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
2002-02-10 11:36:07 +01:00
|
|
|
if (Key == kYellow && HadSubMenu && !HasSubMenu()) {
|
|
|
|
// the last recording in a subdirectory was deleted, so let's go back up
|
|
|
|
cOsdMenu::Del(Current());
|
|
|
|
if (!Count())
|
|
|
|
return osBack;
|
|
|
|
Display();
|
|
|
|
}
|
2002-01-20 14:05:28 +01:00
|
|
|
if (!HasSubMenu() && Key != kNone)
|
|
|
|
SetHelpKeys();
|
2000-03-11 11:22:37 +01:00
|
|
|
return state;
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
// --- cMenuSetupBase --------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuSetupBase : public cMenuSetupPage {
|
|
|
|
protected:
|
|
|
|
cSetup data;
|
|
|
|
virtual void Store(void);
|
|
|
|
public:
|
|
|
|
cMenuSetupBase(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
cMenuSetupBase::cMenuSetupBase(void)
|
|
|
|
{
|
|
|
|
data = Setup;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuSetupBase::Store(void)
|
|
|
|
{
|
|
|
|
Setup = data;
|
|
|
|
Setup.Save();
|
|
|
|
}
|
|
|
|
|
2002-03-16 10:03:04 +01:00
|
|
|
// --- cMenuSetupOSD ---------------------------------------------------------
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
class cMenuSetupOSD : public cMenuSetupBase {
|
2002-03-16 10:03:04 +01:00
|
|
|
private:
|
2004-05-16 10:35:36 +02:00
|
|
|
const char *useSmallFontTexts[3];
|
|
|
|
int numSkins;
|
|
|
|
int originalSkinIndex;
|
|
|
|
int skinIndex;
|
|
|
|
const char **skinDescriptions;
|
|
|
|
cThemes themes;
|
|
|
|
int themeIndex;
|
2002-03-16 10:03:04 +01:00
|
|
|
virtual void Set(void);
|
|
|
|
public:
|
2004-05-16 10:35:36 +02:00
|
|
|
cMenuSetupOSD(void);
|
|
|
|
virtual ~cMenuSetupOSD();
|
2002-05-11 13:44:58 +02:00
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
2002-03-16 10:03:04 +01:00
|
|
|
};
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
cMenuSetupOSD::cMenuSetupOSD(void)
|
|
|
|
{
|
|
|
|
numSkins = Skins.Count();
|
|
|
|
skinIndex = originalSkinIndex = Skins.Current()->Index();
|
|
|
|
skinDescriptions = new const char*[numSkins];
|
|
|
|
themes.Load(Skins.Current()->Name());
|
|
|
|
themeIndex = Skins.Current()->Theme() ? themes.GetThemeIndex(Skins.Current()->Theme()->Description()) : 0;
|
|
|
|
Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
cMenuSetupOSD::~cMenuSetupOSD()
|
|
|
|
{
|
|
|
|
cFont::SetCode(I18nCharSets()[Setup.OSDLanguage]);
|
2006-05-25 12:26:09 +02:00
|
|
|
delete[] skinDescriptions;
|
2004-05-16 10:35:36 +02:00
|
|
|
}
|
|
|
|
|
2002-03-16 10:03:04 +01:00
|
|
|
void cMenuSetupOSD::Set(void)
|
2000-11-11 10:39:27 +01:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
int current = Current();
|
|
|
|
for (cSkin *Skin = Skins.First(); Skin; Skin = Skins.Next(Skin))
|
|
|
|
skinDescriptions[Skin->Index()] = Skin->Description();
|
|
|
|
useSmallFontTexts[0] = tr("never");
|
|
|
|
useSmallFontTexts[1] = tr("skin dependent");
|
|
|
|
useSmallFontTexts[2] = tr("always");
|
2000-11-11 10:39:27 +01:00
|
|
|
Clear();
|
2002-05-11 13:44:58 +02:00
|
|
|
SetSection(tr("OSD"));
|
2002-05-09 16:26:56 +02:00
|
|
|
Add(new cMenuEditStraItem(tr("Setup.OSD$Language"), &data.OSDLanguage, I18nNumLanguages, I18nLanguages()));
|
2004-05-16 10:35:36 +02:00
|
|
|
Add(new cMenuEditStraItem(tr("Setup.OSD$Skin"), &skinIndex, numSkins, skinDescriptions));
|
|
|
|
if (themes.NumThemes())
|
|
|
|
Add(new cMenuEditStraItem(tr("Setup.OSD$Theme"), &themeIndex, themes.NumThemes(), themes.Descriptions()));
|
|
|
|
Add(new cMenuEditIntItem( tr("Setup.OSD$Left"), &data.OSDLeft, 0, MAXOSDWIDTH));
|
|
|
|
Add(new cMenuEditIntItem( tr("Setup.OSD$Top"), &data.OSDTop, 0, MAXOSDHEIGHT));
|
|
|
|
Add(new cMenuEditIntItem( tr("Setup.OSD$Width"), &data.OSDWidth, MINOSDWIDTH, MAXOSDWIDTH));
|
|
|
|
Add(new cMenuEditIntItem( tr("Setup.OSD$Height"), &data.OSDHeight, MINOSDHEIGHT, MAXOSDHEIGHT));
|
2002-03-31 13:39:56 +02:00
|
|
|
Add(new cMenuEditIntItem( tr("Setup.OSD$Message time (s)"), &data.OSDMessageTime, 1, 60));
|
2004-05-16 10:35:36 +02:00
|
|
|
Add(new cMenuEditStraItem(tr("Setup.OSD$Use small font"), &data.UseSmallFont, 3, useSmallFontTexts));
|
2002-03-17 14:11:22 +01:00
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.OSD$Channel info position"), &data.ChannelInfoPos, tr("bottom"), tr("top")));
|
2005-02-05 11:40:04 +01:00
|
|
|
Add(new cMenuEditIntItem( tr("Setup.OSD$Channel info time (s)"), &data.ChannelInfoTime, 1, 60));
|
2002-03-17 14:11:22 +01:00
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.OSD$Info on channel switch"), &data.ShowInfoOnChSwitch));
|
2006-01-04 14:45:23 +01:00
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.OSD$Timeout requested channel info"), &data.TimeoutRequChInfo));
|
2002-03-17 14:11:22 +01:00
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.OSD$Scroll pages"), &data.MenuScrollPage));
|
2005-06-18 10:44:30 +02:00
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.OSD$Scroll wraps"), &data.MenuScrollWrap));
|
2006-01-13 15:45:02 +01:00
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.OSD$Menu button closes"), &data.MenuButtonCloses));
|
2002-03-17 14:11:22 +01:00
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.OSD$Recording directories"), &data.RecordingDirs));
|
2004-05-16 10:35:36 +02:00
|
|
|
SetCurrent(Get(current));
|
|
|
|
Display();
|
2002-03-16 10:03:04 +01:00
|
|
|
}
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
eOSState cMenuSetupOSD::ProcessKey(eKeys Key)
|
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
if (Key == kOk) {
|
|
|
|
if (skinIndex != originalSkinIndex) {
|
|
|
|
cSkin *Skin = Skins.Get(skinIndex);
|
|
|
|
if (Skin) {
|
|
|
|
strn0cpy(data.OSDSkin, Skin->Name(), sizeof(data.OSDSkin));
|
|
|
|
Skins.SetCurrent(Skin->Name());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (themes.NumThemes() && Skins.Current()->Theme()) {
|
|
|
|
Skins.Current()->Theme()->Load(themes.FileName(themeIndex));
|
|
|
|
strn0cpy(data.OSDTheme, themes.Name(themeIndex), sizeof(data.OSDTheme));
|
|
|
|
}
|
|
|
|
data.OSDWidth &= ~0x07; // OSD width must be a multiple of 8
|
|
|
|
}
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
int osdLanguage = data.OSDLanguage;
|
2004-05-16 10:35:36 +02:00
|
|
|
int oldSkinIndex = skinIndex;
|
2002-05-11 13:44:58 +02:00
|
|
|
eOSState state = cMenuSetupBase::ProcessKey(Key);
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
if (data.OSDLanguage != osdLanguage || skinIndex != oldSkinIndex) {
|
2002-05-11 13:44:58 +02:00
|
|
|
int OriginalOSDLanguage = Setup.OSDLanguage;
|
|
|
|
Setup.OSDLanguage = data.OSDLanguage;
|
2003-10-24 12:53:12 +02:00
|
|
|
cFont::SetCode(I18nCharSets()[Setup.OSDLanguage]);
|
2004-05-16 10:35:36 +02:00
|
|
|
|
|
|
|
cSkin *Skin = Skins.Get(skinIndex);
|
|
|
|
if (Skin) {
|
|
|
|
char *d = themes.NumThemes() ? strdup(themes.Descriptions()[themeIndex]) : NULL;
|
|
|
|
themes.Load(Skin->Name());
|
|
|
|
if (skinIndex != oldSkinIndex)
|
|
|
|
themeIndex = d ? themes.GetThemeIndex(d) : 0;
|
|
|
|
free(d);
|
|
|
|
}
|
2006-01-08 11:44:37 +01:00
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
Set();
|
|
|
|
Setup.OSDLanguage = OriginalOSDLanguage;
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2002-03-16 10:03:04 +01:00
|
|
|
// --- cMenuSetupEPG ---------------------------------------------------------
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
class cMenuSetupEPG : public cMenuSetupBase {
|
2004-01-09 15:53:59 +01:00
|
|
|
private:
|
|
|
|
int originalNumLanguages;
|
|
|
|
int numLanguages;
|
|
|
|
void Setup(void);
|
2002-03-16 10:03:04 +01:00
|
|
|
public:
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupEPG(void);
|
2004-01-09 15:53:59 +01:00
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
2002-03-16 10:03:04 +01:00
|
|
|
};
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupEPG::cMenuSetupEPG(void)
|
2002-03-16 10:03:04 +01:00
|
|
|
{
|
2004-01-09 15:53:59 +01:00
|
|
|
for (numLanguages = 0; numLanguages < I18nNumLanguages && data.EPGLanguages[numLanguages] >= 0; numLanguages++)
|
|
|
|
;
|
|
|
|
originalNumLanguages = numLanguages;
|
2002-05-11 13:44:58 +02:00
|
|
|
SetSection(tr("EPG"));
|
2006-01-07 15:54:10 +01:00
|
|
|
SetHelp(tr("Button$Scan"));
|
2004-01-09 15:53:59 +01:00
|
|
|
Setup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuSetupEPG::Setup(void)
|
|
|
|
{
|
|
|
|
int current = Current();
|
|
|
|
|
|
|
|
Clear();
|
|
|
|
|
2002-03-31 13:39:56 +02:00
|
|
|
Add(new cMenuEditIntItem( tr("Setup.EPG$EPG scan timeout (h)"), &data.EPGScanTimeout));
|
2002-03-17 14:11:22 +01:00
|
|
|
Add(new cMenuEditIntItem( tr("Setup.EPG$EPG bugfix level"), &data.EPGBugfixLevel, 0, MAXEPGBUGFIXLEVEL));
|
2004-02-21 15:30:35 +01:00
|
|
|
Add(new cMenuEditIntItem( tr("Setup.EPG$EPG linger time (min)"), &data.EPGLinger, 0));
|
2002-03-17 14:11:22 +01:00
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.EPG$Set system time"), &data.SetSystemTime));
|
2004-01-09 15:53:59 +01:00
|
|
|
if (data.SetSystemTime)
|
2004-05-16 12:58:04 +02:00
|
|
|
Add(new cMenuEditTranItem(tr("Setup.EPG$Use time from transponder"), &data.TimeTransponder, &data.TimeSource));
|
2004-01-09 15:53:59 +01:00
|
|
|
Add(new cMenuEditIntItem( tr("Setup.EPG$Preferred languages"), &numLanguages, 0, I18nNumLanguages));
|
|
|
|
for (int i = 0; i < numLanguages; i++)
|
|
|
|
Add(new cMenuEditStraItem(tr("Setup.EPG$Preferred language"), &data.EPGLanguages[i], I18nNumLanguages, I18nLanguages()));
|
|
|
|
|
|
|
|
SetCurrent(Get(current));
|
|
|
|
Display();
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuSetupEPG::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
if (Key == kOk) {
|
|
|
|
bool Modified = numLanguages != originalNumLanguages;
|
|
|
|
if (!Modified) {
|
|
|
|
for (int i = 0; i < numLanguages; i++) {
|
|
|
|
if (data.EPGLanguages[i] != ::Setup.EPGLanguages[i]) {
|
|
|
|
Modified = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Modified)
|
|
|
|
cSchedules::ResetVersions();
|
|
|
|
}
|
2004-01-11 21:42:23 +01:00
|
|
|
|
|
|
|
int oldnumLanguages = numLanguages;
|
|
|
|
int oldSetSystemTime = data.SetSystemTime;
|
|
|
|
|
|
|
|
eOSState state = cMenuSetupBase::ProcessKey(Key);
|
|
|
|
if (Key != kNone) {
|
2004-01-09 15:53:59 +01:00
|
|
|
if (numLanguages != oldnumLanguages || data.SetSystemTime != oldSetSystemTime) {
|
|
|
|
for (int i = oldnumLanguages; i < numLanguages; i++) {
|
|
|
|
data.EPGLanguages[i] = 0;
|
|
|
|
for (int l = 0; l < I18nNumLanguages; l++) {
|
|
|
|
int k;
|
|
|
|
for (k = 0; k < oldnumLanguages; k++) {
|
|
|
|
if (data.EPGLanguages[k] == l)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (k >= oldnumLanguages) {
|
|
|
|
data.EPGLanguages[i] = l;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data.EPGLanguages[numLanguages] = -1;
|
|
|
|
Setup();
|
|
|
|
}
|
2004-01-17 15:38:11 +01:00
|
|
|
if (Key == kRed) {
|
|
|
|
EITScanner.ForceScan();
|
|
|
|
return osEnd;
|
|
|
|
}
|
2004-01-09 15:53:59 +01:00
|
|
|
}
|
|
|
|
return state;
|
2002-03-16 10:03:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuSetupDVB ---------------------------------------------------------
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
class cMenuSetupDVB : public cMenuSetupBase {
|
2004-01-05 12:08:09 +01:00
|
|
|
private:
|
2005-01-05 10:48:22 +01:00
|
|
|
int originalNumAudioLanguages;
|
|
|
|
int numAudioLanguages;
|
|
|
|
void Setup(void);
|
2005-02-20 13:39:49 +01:00
|
|
|
const char *videoDisplayFormatTexts[3];
|
2006-04-15 14:18:25 +02:00
|
|
|
const char *updateChannelsTexts[6];
|
2002-03-16 10:03:04 +01:00
|
|
|
public:
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupDVB(void);
|
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
2002-03-16 10:03:04 +01:00
|
|
|
};
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupDVB::cMenuSetupDVB(void)
|
2002-03-16 10:03:04 +01:00
|
|
|
{
|
2005-01-05 10:48:22 +01:00
|
|
|
for (numAudioLanguages = 0; numAudioLanguages < I18nNumLanguages && data.AudioLanguages[numAudioLanguages] >= 0; numAudioLanguages++)
|
|
|
|
;
|
|
|
|
originalNumAudioLanguages = numAudioLanguages;
|
2005-02-20 13:39:49 +01:00
|
|
|
videoDisplayFormatTexts[0] = tr("pan&scan");
|
|
|
|
videoDisplayFormatTexts[1] = tr("letterbox");
|
|
|
|
videoDisplayFormatTexts[2] = tr("center cut out");
|
2004-01-05 12:08:09 +01:00
|
|
|
updateChannelsTexts[0] = tr("no");
|
|
|
|
updateChannelsTexts[1] = tr("names only");
|
2006-04-15 14:18:25 +02:00
|
|
|
updateChannelsTexts[2] = tr("PIDs only");
|
|
|
|
updateChannelsTexts[3] = tr("names and PIDs");
|
|
|
|
updateChannelsTexts[4] = tr("add new channels");
|
|
|
|
updateChannelsTexts[5] = tr("add new transponders");
|
2004-01-05 12:08:09 +01:00
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
SetSection(tr("DVB"));
|
2005-01-05 10:48:22 +01:00
|
|
|
Setup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuSetupDVB::Setup(void)
|
|
|
|
{
|
|
|
|
int current = Current();
|
|
|
|
|
|
|
|
Clear();
|
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
Add(new cMenuEditIntItem( tr("Setup.DVB$Primary DVB interface"), &data.PrimaryDVB, 1, cDevice::NumDevices()));
|
2002-03-17 14:11:22 +01:00
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.DVB$Video format"), &data.VideoFormat, "4:3", "16:9"));
|
2005-03-05 15:48:26 +01:00
|
|
|
if (data.VideoFormat == 0)
|
|
|
|
Add(new cMenuEditStraItem(tr("Setup.DVB$Video display format"), &data.VideoDisplayFormat, 3, videoDisplayFormatTexts));
|
2005-01-09 12:36:48 +01:00
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.DVB$Use Dolby Digital"), &data.UseDolbyDigital));
|
2006-04-15 14:18:25 +02:00
|
|
|
Add(new cMenuEditStraItem(tr("Setup.DVB$Update channels"), &data.UpdateChannels, 6, updateChannelsTexts));
|
2005-01-05 10:48:22 +01:00
|
|
|
Add(new cMenuEditIntItem( tr("Setup.DVB$Audio languages"), &numAudioLanguages, 0, I18nNumLanguages));
|
|
|
|
for (int i = 0; i < numAudioLanguages; i++)
|
2005-01-14 13:19:21 +01:00
|
|
|
Add(new cMenuEditStraItem(tr("Setup.DVB$Audio language"), &data.AudioLanguages[i], I18nNumLanguages, I18nLanguages()));
|
2005-01-05 10:48:22 +01:00
|
|
|
|
|
|
|
SetCurrent(Get(current));
|
|
|
|
Display();
|
2002-03-16 10:03:04 +01:00
|
|
|
}
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
eOSState cMenuSetupDVB::ProcessKey(eKeys Key)
|
|
|
|
{
|
2005-01-05 10:48:22 +01:00
|
|
|
int oldPrimaryDVB = ::Setup.PrimaryDVB;
|
2005-02-20 13:39:49 +01:00
|
|
|
int oldVideoDisplayFormat = ::Setup.VideoDisplayFormat;
|
2005-01-05 10:48:22 +01:00
|
|
|
bool oldVideoFormat = ::Setup.VideoFormat;
|
2005-03-05 15:48:26 +01:00
|
|
|
bool newVideoFormat = data.VideoFormat;
|
2005-01-05 10:48:22 +01:00
|
|
|
int oldnumAudioLanguages = numAudioLanguages;
|
2002-05-11 13:44:58 +02:00
|
|
|
eOSState state = cMenuSetupBase::ProcessKey(Key);
|
|
|
|
|
2005-01-05 10:48:22 +01:00
|
|
|
if (Key != kNone) {
|
2005-03-05 15:48:26 +01:00
|
|
|
bool DoSetup = data.VideoFormat != newVideoFormat;
|
2005-01-05 10:48:22 +01:00
|
|
|
if (numAudioLanguages != oldnumAudioLanguages) {
|
|
|
|
for (int i = oldnumAudioLanguages; i < numAudioLanguages; i++) {
|
|
|
|
data.AudioLanguages[i] = 0;
|
|
|
|
for (int l = 0; l < I18nNumLanguages; l++) {
|
|
|
|
int k;
|
|
|
|
for (k = 0; k < oldnumAudioLanguages; k++) {
|
|
|
|
if (data.AudioLanguages[k] == l)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (k >= oldnumAudioLanguages) {
|
|
|
|
data.AudioLanguages[i] = l;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data.AudioLanguages[numAudioLanguages] = -1;
|
2005-03-05 15:48:26 +01:00
|
|
|
DoSetup = true;
|
2005-01-05 10:48:22 +01:00
|
|
|
}
|
2005-03-05 15:48:26 +01:00
|
|
|
if (DoSetup)
|
|
|
|
Setup();
|
2005-01-05 10:48:22 +01:00
|
|
|
}
|
2002-05-11 13:44:58 +02:00
|
|
|
if (state == osBack && Key == kOk) {
|
2005-01-05 10:48:22 +01:00
|
|
|
if (::Setup.PrimaryDVB != oldPrimaryDVB)
|
2002-05-11 13:44:58 +02:00
|
|
|
state = osSwitchDvb;
|
2005-02-20 13:39:49 +01:00
|
|
|
if (::Setup.VideoDisplayFormat != oldVideoDisplayFormat)
|
|
|
|
cDevice::PrimaryDevice()->SetVideoDisplayFormat(eVideoDisplayFormat(::Setup.VideoDisplayFormat));
|
2005-01-05 10:48:22 +01:00
|
|
|
if (::Setup.VideoFormat != oldVideoFormat)
|
|
|
|
cDevice::PrimaryDevice()->SetVideoFormat(::Setup.VideoFormat);
|
2002-05-11 13:44:58 +02:00
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2002-03-16 10:03:04 +01:00
|
|
|
// --- cMenuSetupLNB ---------------------------------------------------------
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
class cMenuSetupLNB : public cMenuSetupBase {
|
2002-10-06 10:25:42 +02:00
|
|
|
private:
|
|
|
|
void Setup(void);
|
2002-03-16 10:03:04 +01:00
|
|
|
public:
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupLNB(void);
|
2002-10-06 10:25:42 +02:00
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
2002-03-16 10:03:04 +01:00
|
|
|
};
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupLNB::cMenuSetupLNB(void)
|
2002-03-16 10:03:04 +01:00
|
|
|
{
|
2002-05-11 13:44:58 +02:00
|
|
|
SetSection(tr("LNB"));
|
2002-10-06 10:25:42 +02:00
|
|
|
Setup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuSetupLNB::Setup(void)
|
|
|
|
{
|
|
|
|
int current = Current();
|
|
|
|
|
|
|
|
Clear();
|
|
|
|
|
2002-03-31 13:39:56 +02:00
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.LNB$Use DiSEqC"), &data.DiSEqC));
|
2002-10-06 10:25:42 +02:00
|
|
|
if (!data.DiSEqC) {
|
|
|
|
Add(new cMenuEditIntItem( tr("Setup.LNB$SLOF (MHz)"), &data.LnbSLOF));
|
|
|
|
Add(new cMenuEditIntItem( tr("Setup.LNB$Low LNB frequency (MHz)"), &data.LnbFrequLo));
|
|
|
|
Add(new cMenuEditIntItem( tr("Setup.LNB$High LNB frequency (MHz)"), &data.LnbFrequHi));
|
|
|
|
}
|
|
|
|
|
|
|
|
SetCurrent(Get(current));
|
|
|
|
Display();
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuSetupLNB::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
int oldDiSEqC = data.DiSEqC;
|
|
|
|
eOSState state = cMenuSetupBase::ProcessKey(Key);
|
|
|
|
|
|
|
|
if (Key != kNone && data.DiSEqC != oldDiSEqC)
|
|
|
|
Setup();
|
|
|
|
return state;
|
2002-03-16 10:03:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuSetupCICAM -------------------------------------------------------
|
|
|
|
|
2005-08-26 12:49:26 +02:00
|
|
|
class cMenuSetupCICAMItem : public cOsdItem {
|
|
|
|
private:
|
|
|
|
cCiHandler *ciHandler;
|
|
|
|
int slot;
|
|
|
|
public:
|
|
|
|
cMenuSetupCICAMItem(int Device, cCiHandler *CiHandler, int Slot);
|
|
|
|
cCiHandler *CiHandler(void) { return ciHandler; }
|
|
|
|
int Slot(void) { return slot; }
|
|
|
|
};
|
|
|
|
|
|
|
|
cMenuSetupCICAMItem::cMenuSetupCICAMItem(int Device, cCiHandler *CiHandler, int Slot)
|
|
|
|
{
|
|
|
|
ciHandler = CiHandler;
|
|
|
|
slot = Slot;
|
|
|
|
char buffer[32];
|
|
|
|
const char *CamName = CiHandler->GetCamName(slot);
|
|
|
|
snprintf(buffer, sizeof(buffer), "%s%d %d\t%s", tr("Setup.CICAM$CICAM DVB"), Device + 1, slot + 1, CamName ? CamName : "-");
|
|
|
|
SetText(buffer);
|
|
|
|
}
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
class cMenuSetupCICAM : public cMenuSetupBase {
|
2003-01-06 14:44:27 +01:00
|
|
|
private:
|
|
|
|
eOSState Menu(void);
|
|
|
|
eOSState Reset(void);
|
2002-03-16 10:03:04 +01:00
|
|
|
public:
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupCICAM(void);
|
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
2002-03-16 10:03:04 +01:00
|
|
|
};
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupCICAM::cMenuSetupCICAM(void)
|
2002-03-16 10:03:04 +01:00
|
|
|
{
|
2002-05-11 13:44:58 +02:00
|
|
|
SetSection(tr("CICAM"));
|
2002-06-16 12:57:31 +02:00
|
|
|
for (int d = 0; d < cDevice::NumDevices(); d++) {
|
2004-02-08 15:11:07 +01:00
|
|
|
cDevice *Device = cDevice::GetDevice(d);
|
2005-08-26 12:49:26 +02:00
|
|
|
if (Device) {
|
|
|
|
cCiHandler *CiHandler = Device->CiHandler();
|
|
|
|
if (CiHandler) {
|
|
|
|
for (int Slot = 0; Slot < CiHandler->NumSlots(); Slot++)
|
|
|
|
Add(new cMenuSetupCICAMItem(Device->CardIndex(), CiHandler, Slot));
|
|
|
|
}
|
|
|
|
}
|
2002-03-16 10:03:04 +01:00
|
|
|
}
|
2006-01-07 15:54:10 +01:00
|
|
|
SetHelp(tr("Button$Menu"), tr("Button$Reset"));
|
2003-01-06 14:44:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuSetupCICAM::Menu(void)
|
|
|
|
{
|
2005-08-26 12:49:26 +02:00
|
|
|
cMenuSetupCICAMItem *item = (cMenuSetupCICAMItem *)Get(Current());
|
|
|
|
if (item) {
|
2005-10-02 14:43:56 +02:00
|
|
|
if (item->CiHandler()->EnterMenu(item->Slot())) {
|
|
|
|
Skins.Message(mtWarning, tr("Opening CAM menu..."));
|
|
|
|
time_t t = time(NULL);
|
|
|
|
while (time(NULL) - t < MAXWAITFORCAMMENU && !item->CiHandler()->HasUserIO())
|
|
|
|
item->CiHandler()->Process();
|
2005-08-26 12:49:26 +02:00
|
|
|
return osEnd; // the CAM menu will be executed explicitly from the main loop
|
2005-10-02 14:43:56 +02:00
|
|
|
}
|
2005-08-26 12:49:26 +02:00
|
|
|
else
|
|
|
|
Skins.Message(mtError, tr("Can't open CAM menu!"));
|
|
|
|
}
|
2003-01-06 14:44:27 +01:00
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuSetupCICAM::Reset(void)
|
|
|
|
{
|
2005-08-26 12:49:26 +02:00
|
|
|
cMenuSetupCICAMItem *item = (cMenuSetupCICAMItem *)Get(Current());
|
|
|
|
if (item) {
|
2005-10-02 10:20:19 +02:00
|
|
|
Skins.Message(mtWarning, tr("Resetting CAM..."));
|
2005-08-26 12:49:26 +02:00
|
|
|
if (item->CiHandler()->Reset(item->Slot())) {
|
|
|
|
Skins.Message(mtInfo, tr("CAM has been reset"));
|
|
|
|
return osEnd;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Skins.Message(mtError, tr("Can't reset CAM!"));
|
2003-02-09 11:54:22 +01:00
|
|
|
}
|
2003-01-06 14:44:27 +01:00
|
|
|
return osContinue;
|
2002-03-16 10:03:04 +01:00
|
|
|
}
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
eOSState cMenuSetupCICAM::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
eOSState state = cMenuSetupBase::ProcessKey(Key);
|
|
|
|
|
2004-02-08 15:11:07 +01:00
|
|
|
if (state == osUnknown) {
|
2003-01-06 14:44:27 +01:00
|
|
|
switch (Key) {
|
2005-08-26 12:49:26 +02:00
|
|
|
case kRed: return Menu();
|
|
|
|
case kGreen: return Reset();
|
2003-01-06 14:44:27 +01:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
2002-05-11 13:44:58 +02:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2002-03-16 10:03:04 +01:00
|
|
|
// --- cMenuSetupRecord ------------------------------------------------------
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
class cMenuSetupRecord : public cMenuSetupBase {
|
2002-03-16 10:03:04 +01:00
|
|
|
public:
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupRecord(void);
|
2002-03-16 10:03:04 +01:00
|
|
|
};
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupRecord::cMenuSetupRecord(void)
|
2002-03-16 10:03:04 +01:00
|
|
|
{
|
2002-05-11 13:44:58 +02:00
|
|
|
SetSection(tr("Recording"));
|
2002-03-31 13:39:56 +02:00
|
|
|
Add(new cMenuEditIntItem( tr("Setup.Recording$Margin at start (min)"), &data.MarginStart));
|
|
|
|
Add(new cMenuEditIntItem( tr("Setup.Recording$Margin at stop (min)"), &data.MarginStop));
|
|
|
|
Add(new cMenuEditIntItem( tr("Setup.Recording$Primary limit"), &data.PrimaryLimit, 0, MAXPRIORITY));
|
|
|
|
Add(new cMenuEditIntItem( tr("Setup.Recording$Default priority"), &data.DefaultPriority, 0, MAXPRIORITY));
|
|
|
|
Add(new cMenuEditIntItem( tr("Setup.Recording$Default lifetime (d)"), &data.DefaultLifetime, 0, MAXLIFETIME));
|
2003-05-11 14:10:00 +02:00
|
|
|
Add(new cMenuEditIntItem( tr("Setup.Recording$Pause priority"), &data.PausePriority, 0, MAXPRIORITY));
|
|
|
|
Add(new cMenuEditIntItem( tr("Setup.Recording$Pause lifetime (d)"), &data.PauseLifetime, 0, MAXLIFETIME));
|
2002-03-31 13:39:56 +02:00
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.Recording$Use episode name"), &data.UseSubtitle));
|
2004-02-29 14:21:22 +01:00
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.Recording$Use VPS"), &data.UseVps));
|
|
|
|
Add(new cMenuEditIntItem( tr("Setup.Recording$VPS margin (s)"), &data.VpsMargin, 0));
|
2002-03-31 13:39:56 +02:00
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.Recording$Mark instant recording"), &data.MarkInstantRecord));
|
2002-04-16 16:11:40 +02:00
|
|
|
Add(new cMenuEditStrItem( tr("Setup.Recording$Name instant recording"), data.NameInstantRecord, sizeof(data.NameInstantRecord), tr(FileNameChars)));
|
2002-04-26 13:43:46 +02:00
|
|
|
Add(new cMenuEditIntItem( tr("Setup.Recording$Instant rec. time (min)"), &data.InstantRecordTime, 1, MAXINSTANTRECTIME));
|
2002-03-31 13:39:56 +02:00
|
|
|
Add(new cMenuEditIntItem( tr("Setup.Recording$Max. video file size (MB)"), &data.MaxVideoFileSize, MINVIDEOFILESIZE, MAXVIDEOFILESIZE));
|
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.Recording$Split edited files"), &data.SplitEditedFiles));
|
2002-03-16 10:03:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuSetupReplay ------------------------------------------------------
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
class cMenuSetupReplay : public cMenuSetupBase {
|
2005-09-25 11:35:56 +02:00
|
|
|
protected:
|
|
|
|
virtual void Store(void);
|
2002-03-16 10:03:04 +01:00
|
|
|
public:
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupReplay(void);
|
2002-03-16 10:03:04 +01:00
|
|
|
};
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupReplay::cMenuSetupReplay(void)
|
2002-03-16 10:03:04 +01:00
|
|
|
{
|
2002-05-11 13:44:58 +02:00
|
|
|
SetSection(tr("Replay"));
|
2002-03-17 14:11:22 +01:00
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.Replay$Multi speed mode"), &data.MultiSpeedMode));
|
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.Replay$Show replay mode"), &data.ShowReplayMode));
|
2003-04-12 10:06:21 +02:00
|
|
|
Add(new cMenuEditIntItem(tr("Setup.Replay$Resume ID"), &data.ResumeID, 0, 99));
|
2002-03-16 10:03:04 +01:00
|
|
|
}
|
|
|
|
|
2005-09-25 11:35:56 +02:00
|
|
|
void cMenuSetupReplay::Store(void)
|
|
|
|
{
|
|
|
|
if (Setup.ResumeID != data.ResumeID)
|
|
|
|
Recordings.ResetResume();
|
|
|
|
cMenuSetupBase::Store();
|
|
|
|
}
|
|
|
|
|
2002-03-16 10:03:04 +01:00
|
|
|
// --- cMenuSetupMisc --------------------------------------------------------
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
class cMenuSetupMisc : public cMenuSetupBase {
|
2002-03-16 10:03:04 +01:00
|
|
|
public:
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupMisc(void);
|
2002-03-16 10:03:04 +01:00
|
|
|
};
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupMisc::cMenuSetupMisc(void)
|
2002-03-16 10:03:04 +01:00
|
|
|
{
|
2002-05-11 13:44:58 +02:00
|
|
|
SetSection(tr("Miscellaneous"));
|
2002-03-31 13:39:56 +02:00
|
|
|
Add(new cMenuEditIntItem( tr("Setup.Miscellaneous$Min. event timeout (min)"), &data.MinEventTimeout));
|
|
|
|
Add(new cMenuEditIntItem( tr("Setup.Miscellaneous$Min. user inactivity (min)"), &data.MinUserInactivity));
|
2002-05-01 14:57:12 +02:00
|
|
|
Add(new cMenuEditIntItem( tr("Setup.Miscellaneous$SVDRP timeout (s)"), &data.SVDRPTimeout));
|
2003-08-17 08:58:02 +02:00
|
|
|
Add(new cMenuEditIntItem( tr("Setup.Miscellaneous$Zap timeout (s)"), &data.ZapTimeout));
|
2006-04-09 13:26:56 +02:00
|
|
|
Add(new cMenuEditChanItem(tr("Setup.Miscellaneous$Initial channel"), &data.InitialChannel, tr("Setup.Miscellaneous$as before")));
|
|
|
|
Add(new cMenuEditIntItem( tr("Setup.Miscellaneous$Initial volume"), &data.InitialVolume, -1, 255, tr("Setup.Miscellaneous$as before")));
|
2002-03-16 10:03:04 +01:00
|
|
|
}
|
|
|
|
|
2002-05-09 16:26:56 +02:00
|
|
|
// --- cMenuSetupPluginItem --------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuSetupPluginItem : public cOsdItem {
|
|
|
|
private:
|
|
|
|
int pluginIndex;
|
|
|
|
public:
|
|
|
|
cMenuSetupPluginItem(const char *Name, int Index);
|
|
|
|
int PluginIndex(void) { return pluginIndex; }
|
|
|
|
};
|
|
|
|
|
|
|
|
cMenuSetupPluginItem::cMenuSetupPluginItem(const char *Name, int Index)
|
|
|
|
:cOsdItem(Name)
|
|
|
|
{
|
|
|
|
pluginIndex = Index;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuSetupPlugins -----------------------------------------------------
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
class cMenuSetupPlugins : public cMenuSetupBase {
|
2002-05-09 16:26:56 +02:00
|
|
|
public:
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupPlugins(void);
|
2002-05-09 16:26:56 +02:00
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
|
|
|
};
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupPlugins::cMenuSetupPlugins(void)
|
2002-05-09 16:26:56 +02:00
|
|
|
{
|
2002-05-11 13:44:58 +02:00
|
|
|
SetSection(tr("Plugins"));
|
2002-05-09 16:26:56 +02:00
|
|
|
SetHasHotkeys();
|
|
|
|
for (int i = 0; ; i++) {
|
|
|
|
cPlugin *p = cPluginManager::GetPlugin(i);
|
|
|
|
if (p) {
|
|
|
|
char *buffer = NULL;
|
|
|
|
asprintf(&buffer, "%s (%s) - %s", p->Name(), p->Version(), p->Description());
|
|
|
|
Add(new cMenuSetupPluginItem(hk(buffer), i));
|
2002-08-11 13:32:23 +02:00
|
|
|
free(buffer);
|
2002-05-09 16:26:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuSetupPlugins::ProcessKey(eKeys Key)
|
|
|
|
{
|
2002-05-11 13:44:58 +02:00
|
|
|
eOSState state = HasSubMenu() ? cMenuSetupBase::ProcessKey(Key) : cOsdMenu::ProcessKey(Key);
|
|
|
|
|
|
|
|
if (Key == kOk) {
|
|
|
|
if (state == osUnknown) {
|
|
|
|
cMenuSetupPluginItem *item = (cMenuSetupPluginItem *)Get(Current());
|
|
|
|
if (item) {
|
|
|
|
cPlugin *p = cPluginManager::GetPlugin(item->PluginIndex());
|
|
|
|
if (p) {
|
|
|
|
cMenuSetupPage *menu = p->SetupMenu();
|
|
|
|
if (menu) {
|
|
|
|
menu->SetPlugin(p);
|
|
|
|
return AddSubMenu(menu);
|
|
|
|
}
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtInfo, tr("This plugin has no setup parameters!"));
|
2002-05-11 13:44:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (state == osContinue)
|
|
|
|
Store();
|
2002-05-09 16:26:56 +02:00
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2002-03-16 10:03:04 +01:00
|
|
|
// --- cMenuSetup ------------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuSetup : public cOsdMenu {
|
|
|
|
private:
|
|
|
|
virtual void Set(void);
|
2002-03-17 12:04:35 +01:00
|
|
|
eOSState Restart(void);
|
2002-03-16 10:03:04 +01:00
|
|
|
public:
|
|
|
|
cMenuSetup(void);
|
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
|
|
|
};
|
|
|
|
|
|
|
|
cMenuSetup::cMenuSetup(void)
|
|
|
|
:cOsdMenu("")
|
|
|
|
{
|
|
|
|
Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuSetup::Set(void)
|
|
|
|
{
|
|
|
|
Clear();
|
2002-05-09 16:26:56 +02:00
|
|
|
char buffer[64];
|
|
|
|
snprintf(buffer, sizeof(buffer), "%s - VDR %s", tr("Setup"), VDRVERSION);
|
|
|
|
SetTitle(buffer);
|
2002-03-16 10:03:04 +01:00
|
|
|
SetHasHotkeys();
|
|
|
|
Add(new cOsdItem(hk(tr("OSD")), osUser1));
|
|
|
|
Add(new cOsdItem(hk(tr("EPG")), osUser2));
|
|
|
|
Add(new cOsdItem(hk(tr("DVB")), osUser3));
|
|
|
|
Add(new cOsdItem(hk(tr("LNB")), osUser4));
|
|
|
|
Add(new cOsdItem(hk(tr("CICAM")), osUser5));
|
|
|
|
Add(new cOsdItem(hk(tr("Recording")), osUser6));
|
|
|
|
Add(new cOsdItem(hk(tr("Replay")), osUser7));
|
|
|
|
Add(new cOsdItem(hk(tr("Miscellaneous")), osUser8));
|
2002-05-09 16:26:56 +02:00
|
|
|
if (cPluginManager::HasPlugins())
|
|
|
|
Add(new cOsdItem(hk(tr("Plugins")), osUser9));
|
|
|
|
Add(new cOsdItem(hk(tr("Restart")), osUser10));
|
2002-03-17 12:04:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuSetup::Restart(void)
|
|
|
|
{
|
2006-04-15 11:18:36 +02:00
|
|
|
if (Interface->Confirm(tr("Really restart?"))
|
|
|
|
&& (!cRecordControls::Active() || Interface->Confirm(tr("Recording - restart anyway?")))
|
2006-04-28 12:53:07 +02:00
|
|
|
&& !cPluginManager::Active(tr("restart anyway?"))) {
|
2002-03-17 12:04:35 +01:00
|
|
|
cThread::EmergencyExit(true);
|
|
|
|
return osEnd;
|
|
|
|
}
|
|
|
|
return osContinue;
|
2000-09-10 10:51:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuSetup::ProcessKey(eKeys Key)
|
|
|
|
{
|
2002-03-16 10:03:04 +01:00
|
|
|
int osdLanguage = Setup.OSDLanguage;
|
2000-09-10 10:51:58 +02:00
|
|
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
|
|
|
|
2002-03-16 10:03:04 +01:00
|
|
|
switch (state) {
|
|
|
|
case osUser1: return AddSubMenu(new cMenuSetupOSD);
|
|
|
|
case osUser2: return AddSubMenu(new cMenuSetupEPG);
|
|
|
|
case osUser3: return AddSubMenu(new cMenuSetupDVB);
|
|
|
|
case osUser4: return AddSubMenu(new cMenuSetupLNB);
|
|
|
|
case osUser5: return AddSubMenu(new cMenuSetupCICAM);
|
|
|
|
case osUser6: return AddSubMenu(new cMenuSetupRecord);
|
|
|
|
case osUser7: return AddSubMenu(new cMenuSetupReplay);
|
|
|
|
case osUser8: return AddSubMenu(new cMenuSetupMisc);
|
2002-05-09 16:26:56 +02:00
|
|
|
case osUser9: return AddSubMenu(new cMenuSetupPlugins);
|
|
|
|
case osUser10: return Restart();
|
2002-03-16 10:03:04 +01:00
|
|
|
default: ;
|
|
|
|
}
|
|
|
|
if (Setup.OSDLanguage != osdLanguage) {
|
2000-11-11 10:39:27 +01:00
|
|
|
Set();
|
2002-03-16 10:03:04 +01:00
|
|
|
if (!HasSubMenu())
|
|
|
|
Display();
|
2000-11-11 10:39:27 +01:00
|
|
|
}
|
2000-09-10 10:51:58 +02:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2002-05-09 16:26:56 +02:00
|
|
|
// --- cMenuPluginItem -------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuPluginItem : public cOsdItem {
|
|
|
|
private:
|
|
|
|
int pluginIndex;
|
|
|
|
public:
|
|
|
|
cMenuPluginItem(const char *Name, int Index);
|
|
|
|
int PluginIndex(void) { return pluginIndex; }
|
|
|
|
};
|
|
|
|
|
|
|
|
cMenuPluginItem::cMenuPluginItem(const char *Name, int Index)
|
|
|
|
:cOsdItem(Name, osPlugin)
|
|
|
|
{
|
|
|
|
pluginIndex = Index;
|
|
|
|
}
|
|
|
|
|
2000-02-19 13:36:48 +01:00
|
|
|
// --- cMenuMain -------------------------------------------------------------
|
|
|
|
|
2001-03-04 11:42:20 +01:00
|
|
|
#define STOP_RECORDING tr(" Stop recording ")
|
2000-05-01 16:29:46 +02:00
|
|
|
|
2002-11-24 10:45:39 +01:00
|
|
|
cOsdObject *cMenuMain::pluginOsdObject = NULL;
|
|
|
|
|
2005-12-24 15:53:53 +01:00
|
|
|
cMenuMain::cMenuMain(eOSState State)
|
2002-03-16 10:03:04 +01:00
|
|
|
:cOsdMenu("")
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2005-12-24 15:53:53 +01:00
|
|
|
lastDiskSpaceCheck = 0;
|
|
|
|
lastFreeMB = 0;
|
|
|
|
replaying = false;
|
|
|
|
stopReplayItem = NULL;
|
|
|
|
cancelEditingItem = NULL;
|
|
|
|
stopRecordingItem = NULL;
|
|
|
|
recordControlsState = 0;
|
2005-09-03 11:33:43 +02:00
|
|
|
Set();
|
2002-03-16 10:03:04 +01:00
|
|
|
|
|
|
|
// Initial submenus:
|
|
|
|
|
|
|
|
switch (State) {
|
2002-10-27 14:32:06 +01:00
|
|
|
case osSchedule: AddSubMenu(new cMenuSchedule); break;
|
|
|
|
case osChannels: AddSubMenu(new cMenuChannels); break;
|
|
|
|
case osTimers: AddSubMenu(new cMenuTimers); break;
|
2002-03-16 10:03:04 +01:00
|
|
|
case osRecordings: AddSubMenu(new cMenuRecordings(NULL, 0, true)); break;
|
2002-10-27 14:32:06 +01:00
|
|
|
case osSetup: AddSubMenu(new cMenuSetup); break;
|
|
|
|
case osCommands: AddSubMenu(new cMenuCommands(tr("Commands"), &Commands)); break;
|
2002-03-16 10:03:04 +01:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-24 10:45:39 +01:00
|
|
|
cOsdObject *cMenuMain::PluginOsdObject(void)
|
|
|
|
{
|
|
|
|
cOsdObject *o = pluginOsdObject;
|
|
|
|
pluginOsdObject = NULL;
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2005-09-03 11:33:43 +02:00
|
|
|
void cMenuMain::Set(void)
|
2002-03-16 10:03:04 +01:00
|
|
|
{
|
|
|
|
Clear();
|
2005-12-24 15:53:53 +01:00
|
|
|
SetTitle("VDR");
|
2002-03-16 10:03:04 +01:00
|
|
|
SetHasHotkeys();
|
2001-10-28 16:32:34 +01:00
|
|
|
|
|
|
|
// Basic menu items:
|
|
|
|
|
2001-08-03 14:18:08 +02:00
|
|
|
Add(new cOsdItem(hk(tr("Schedule")), osSchedule));
|
|
|
|
Add(new cOsdItem(hk(tr("Channels")), osChannels));
|
|
|
|
Add(new cOsdItem(hk(tr("Timers")), osTimers));
|
|
|
|
Add(new cOsdItem(hk(tr("Recordings")), osRecordings));
|
2002-05-09 16:26:56 +02:00
|
|
|
|
|
|
|
// Plugins:
|
|
|
|
|
|
|
|
for (int i = 0; ; i++) {
|
|
|
|
cPlugin *p = cPluginManager::GetPlugin(i);
|
|
|
|
if (p) {
|
|
|
|
const char *item = p->MainMenuEntry();
|
|
|
|
if (item)
|
2005-09-03 11:33:43 +02:00
|
|
|
Add(new cMenuPluginItem(hk(item), i));
|
2002-05-09 16:26:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// More basic menu items:
|
|
|
|
|
2001-08-03 14:18:08 +02:00
|
|
|
Add(new cOsdItem(hk(tr("Setup")), osSetup));
|
2000-11-11 16:38:41 +01:00
|
|
|
if (Commands.Count())
|
2001-08-03 14:18:08 +02:00
|
|
|
Add(new cOsdItem(hk(tr("Commands")), osCommands));
|
2001-10-28 16:32:34 +01:00
|
|
|
|
2005-12-24 15:53:53 +01:00
|
|
|
Update(true);
|
|
|
|
|
|
|
|
Display();
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MB_PER_MINUTE 25.75 // this is just an estimate!
|
|
|
|
|
|
|
|
bool cMenuMain::Update(bool Force)
|
|
|
|
{
|
|
|
|
bool result = false;
|
|
|
|
|
|
|
|
// Title with disk usage:
|
|
|
|
if (Force || time(NULL) - lastDiskSpaceCheck > DISKSPACECHEK) {
|
|
|
|
int FreeMB;
|
|
|
|
int Percent = VideoDiskSpace(&FreeMB);
|
|
|
|
if (Force || FreeMB != lastFreeMB) {
|
|
|
|
int Minutes = int(double(FreeMB) / MB_PER_MINUTE);
|
|
|
|
int Hours = Minutes / 60;
|
|
|
|
Minutes %= 60;
|
|
|
|
char buffer[40];
|
|
|
|
snprintf(buffer, sizeof(buffer), "%s - %s %d%% - %2d:%02d %s", tr("VDR"), tr("Disk"), Percent, Hours, Minutes, tr("free"));
|
|
|
|
//XXX -> skin function!!!
|
|
|
|
SetTitle(buffer);
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
lastDiskSpaceCheck = time(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NewReplaying = cControl::Control() != NULL;
|
|
|
|
if (Force || NewReplaying != replaying) {
|
|
|
|
replaying = NewReplaying;
|
|
|
|
// Replay control:
|
|
|
|
if (replaying && !stopReplayItem)
|
|
|
|
Add(stopReplayItem = new cOsdItem(tr(" Stop replaying"), osStopReplay));
|
|
|
|
else if (stopReplayItem && !replaying) {
|
|
|
|
Del(stopReplayItem->Index());
|
|
|
|
stopReplayItem = NULL;
|
2000-05-01 16:29:46 +02:00
|
|
|
}
|
2005-12-24 15:53:53 +01:00
|
|
|
// Color buttons:
|
2006-01-07 15:54:10 +01:00
|
|
|
SetHelp(!replaying ? tr("Button$Record") : NULL, tr("Button$Audio"), replaying ? NULL : tr("Button$Pause"), replaying ? tr("Button$Stop") : cReplayControl::LastReplayed() ? tr("Button$Resume") : NULL);
|
2005-12-24 15:53:53 +01:00
|
|
|
result = true;
|
|
|
|
}
|
2001-10-28 16:32:34 +01:00
|
|
|
|
|
|
|
// Editing control:
|
2005-12-24 15:53:53 +01:00
|
|
|
bool CutterActive = cCutter::Active();
|
|
|
|
if (CutterActive && !cancelEditingItem) {
|
|
|
|
Add(cancelEditingItem = new cOsdItem(tr(" Cancel editing"), osCancelEdit));
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
else if (cancelEditingItem && !CutterActive) {
|
|
|
|
Del(cancelEditingItem->Index());
|
|
|
|
cancelEditingItem = NULL;
|
|
|
|
result = true;
|
|
|
|
}
|
2001-10-28 16:32:34 +01:00
|
|
|
|
2005-12-24 15:53:53 +01:00
|
|
|
// Record control:
|
|
|
|
if (cRecordControls::StateChanged(recordControlsState)) {
|
|
|
|
while (stopRecordingItem) {
|
|
|
|
cOsdItem *it = Next(stopRecordingItem);
|
|
|
|
Del(stopRecordingItem->Index());
|
|
|
|
stopRecordingItem = it;
|
|
|
|
}
|
|
|
|
const char *s = NULL;
|
|
|
|
while ((s = cRecordControls::GetInstantId(s)) != NULL) {
|
|
|
|
char *buffer = NULL;
|
|
|
|
asprintf(&buffer, "%s%s", STOP_RECORDING, s);
|
|
|
|
cOsdItem *item = new cOsdItem(osStopRecord);
|
|
|
|
item->SetText(buffer, false);
|
|
|
|
Add(item);
|
|
|
|
if (!stopRecordingItem)
|
|
|
|
stopRecordingItem = item;
|
|
|
|
}
|
|
|
|
result = true;
|
|
|
|
}
|
2001-10-28 16:32:34 +01:00
|
|
|
|
2005-12-24 15:53:53 +01:00
|
|
|
return result;
|
2001-08-03 14:18:08 +02:00
|
|
|
}
|
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState cMenuMain::ProcessKey(eKeys Key)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2003-04-26 13:53:50 +02:00
|
|
|
bool HadSubMenu = HasSubMenu();
|
2002-03-16 10:03:04 +01:00
|
|
|
int osdLanguage = Setup.OSDLanguage;
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
2003-04-26 13:53:50 +02:00
|
|
|
HadSubMenu |= HasSubMenu();
|
2000-02-19 13:36:48 +01:00
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
switch (state) {
|
2000-10-29 13:17:22 +01:00
|
|
|
case osSchedule: return AddSubMenu(new cMenuSchedule);
|
2000-03-11 11:22:37 +01:00
|
|
|
case osChannels: return AddSubMenu(new cMenuChannels);
|
2000-11-11 10:39:27 +01:00
|
|
|
case osTimers: return AddSubMenu(new cMenuTimers);
|
2000-03-11 11:22:37 +01:00
|
|
|
case osRecordings: return AddSubMenu(new cMenuRecordings);
|
2000-09-10 10:51:58 +02:00
|
|
|
case osSetup: return AddSubMenu(new cMenuSetup);
|
2002-10-13 12:14:49 +02:00
|
|
|
case osCommands: return AddSubMenu(new cMenuCommands(tr("Commands"), &Commands));
|
2000-12-28 12:57:16 +01:00
|
|
|
case osStopRecord: if (Interface->Confirm(tr("Stop recording?"))) {
|
2000-05-01 16:29:46 +02:00
|
|
|
cOsdItem *item = Get(Current());
|
|
|
|
if (item) {
|
2005-12-28 12:36:27 +01:00
|
|
|
cRecordControls::Stop(item->Text() + strlen(STOP_RECORDING));
|
2000-05-01 16:29:46 +02:00
|
|
|
return osEnd;
|
|
|
|
}
|
|
|
|
}
|
2000-12-28 12:57:16 +01:00
|
|
|
break;
|
|
|
|
case osCancelEdit: if (Interface->Confirm(tr("Cancel editing?"))) {
|
2002-06-22 10:11:59 +02:00
|
|
|
cCutter::Stop();
|
2000-12-28 12:57:16 +01:00
|
|
|
return osEnd;
|
|
|
|
}
|
|
|
|
break;
|
2002-05-09 16:26:56 +02:00
|
|
|
case osPlugin: {
|
|
|
|
cMenuPluginItem *item = (cMenuPluginItem *)Get(Current());
|
|
|
|
if (item) {
|
|
|
|
cPlugin *p = cPluginManager::GetPlugin(item->PluginIndex());
|
|
|
|
if (p) {
|
2002-11-24 10:45:39 +01:00
|
|
|
cOsdObject *menu = p->MainMenuAction();
|
|
|
|
if (menu) {
|
|
|
|
if (menu->IsMenu())
|
|
|
|
return AddSubMenu((cOsdMenu *)menu);
|
|
|
|
else {
|
|
|
|
pluginOsdObject = menu;
|
|
|
|
return osPlugin;
|
|
|
|
}
|
|
|
|
}
|
2002-05-09 16:26:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
state = osEnd;
|
|
|
|
}
|
|
|
|
break;
|
2000-05-27 16:10:47 +02:00
|
|
|
default: switch (Key) {
|
2002-10-27 14:32:06 +01:00
|
|
|
case kRecord:
|
2003-04-26 13:53:50 +02:00
|
|
|
case kRed: if (!HadSubMenu)
|
2003-05-03 16:08:44 +02:00
|
|
|
state = replaying ? osContinue : osRecord;
|
2001-08-03 14:18:08 +02:00
|
|
|
break;
|
2003-04-26 13:53:50 +02:00
|
|
|
case kGreen: if (!HadSubMenu) {
|
2005-01-23 19:27:43 +01:00
|
|
|
cRemote::Put(kAudio, true);
|
|
|
|
state = osEnd;
|
2001-08-03 14:18:08 +02:00
|
|
|
}
|
|
|
|
break;
|
2003-04-26 13:53:50 +02:00
|
|
|
case kYellow: if (!HadSubMenu)
|
2003-05-03 16:08:44 +02:00
|
|
|
state = replaying ? osContinue : osPause;
|
2003-04-21 14:57:13 +02:00
|
|
|
break;
|
2003-04-26 13:53:50 +02:00
|
|
|
case kBlue: if (!HadSubMenu)
|
2002-10-06 14:11:59 +02:00
|
|
|
state = replaying ? osStopReplay : cReplayControl::LastReplayed() ? osReplay : osContinue;
|
2001-08-03 14:18:08 +02:00
|
|
|
break;
|
|
|
|
default: break;
|
2000-05-27 16:10:47 +02:00
|
|
|
}
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
2005-12-26 15:44:27 +01:00
|
|
|
if (!HasSubMenu() && Update(HadSubMenu))
|
2005-12-24 15:53:53 +01:00
|
|
|
Display();
|
2002-03-16 10:03:04 +01:00
|
|
|
if (Key != kNone) {
|
|
|
|
if (Setup.OSDLanguage != osdLanguage) {
|
|
|
|
Set();
|
|
|
|
if (!HasSubMenu())
|
|
|
|
Display();
|
|
|
|
}
|
|
|
|
}
|
2000-03-11 11:22:37 +01:00
|
|
|
return state;
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
|
2005-01-08 10:15:30 +01:00
|
|
|
// --- SetTrackDescriptions --------------------------------------------------
|
|
|
|
|
2006-01-29 11:15:08 +01:00
|
|
|
static void SetTrackDescriptions(int LiveChannel)
|
2005-01-08 10:15:30 +01:00
|
|
|
{
|
|
|
|
cDevice::PrimaryDevice()->ClrAvailableTracks(true);
|
2005-05-16 14:45:11 +02:00
|
|
|
const cComponents *Components = NULL;
|
|
|
|
cSchedulesLock SchedulesLock;
|
2006-01-29 11:15:08 +01:00
|
|
|
if (LiveChannel) {
|
|
|
|
cChannel *Channel = Channels.GetByNumber(LiveChannel);
|
2005-05-16 14:45:11 +02:00
|
|
|
if (Channel) {
|
|
|
|
const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock);
|
|
|
|
if (Schedules) {
|
2006-01-14 15:52:40 +01:00
|
|
|
const cSchedule *Schedule = Schedules->GetSchedule(Channel);
|
2005-05-16 14:45:11 +02:00
|
|
|
if (Schedule) {
|
2006-01-29 14:04:37 +01:00
|
|
|
const cEvent *Present = Schedule->GetPresentEvent();
|
2005-05-16 14:45:11 +02:00
|
|
|
if (Present)
|
|
|
|
Components = Present->Components();
|
2005-01-08 10:15:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-05-16 14:45:11 +02:00
|
|
|
else if (cReplayControl::LastReplayed()) {
|
2005-09-25 11:00:57 +02:00
|
|
|
cThreadLock RecordingsLock(&Recordings);
|
2005-05-16 14:45:11 +02:00
|
|
|
cRecording *Recording = Recordings.GetByName(cReplayControl::LastReplayed());
|
|
|
|
if (Recording)
|
|
|
|
Components = Recording->Info()->Components();
|
|
|
|
}
|
|
|
|
if (Components) {
|
|
|
|
int indexAudio = 0;
|
|
|
|
int indexDolby = 0;
|
|
|
|
for (int i = 0; i < Components->NumComponents(); i++) {
|
|
|
|
const tComponent *p = Components->Component(i);
|
|
|
|
if (p->stream == 2) {
|
|
|
|
if (p->type == 0x05)
|
2006-02-19 10:18:28 +01:00
|
|
|
cDevice::PrimaryDevice()->SetAvailableTrack(ttDolby, indexDolby++, 0, LiveChannel ? NULL : p->language, p->description);
|
2005-05-16 14:45:11 +02:00
|
|
|
else
|
2006-02-19 10:18:28 +01:00
|
|
|
cDevice::PrimaryDevice()->SetAvailableTrack(ttAudio, indexAudio++, 0, LiveChannel ? NULL : p->language, p->description);
|
2005-05-16 14:45:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-01-08 10:15:30 +01:00
|
|
|
}
|
|
|
|
|
2000-11-01 15:41:33 +01:00
|
|
|
// --- cDisplayChannel -------------------------------------------------------
|
2000-09-10 14:56:18 +02:00
|
|
|
|
2001-07-12 14:19:43 +02:00
|
|
|
#define DIRECTCHANNELTIMEOUT 1000 //ms
|
2000-09-10 14:56:18 +02:00
|
|
|
|
2006-01-22 14:27:53 +01:00
|
|
|
cDisplayChannel *cDisplayChannel::currentDisplayChannel = NULL;
|
|
|
|
|
2001-09-08 14:39:09 +02:00
|
|
|
cDisplayChannel::cDisplayChannel(int Number, bool Switched)
|
2002-05-18 12:41:18 +02:00
|
|
|
:cOsdObject(true)
|
2000-11-01 15:41:33 +01:00
|
|
|
{
|
2006-01-22 14:27:53 +01:00
|
|
|
currentDisplayChannel = this;
|
2001-09-08 14:39:09 +02:00
|
|
|
group = -1;
|
|
|
|
withInfo = !Switched || Setup.ShowInfoOnChSwitch;
|
2004-05-16 10:35:36 +02:00
|
|
|
displayChannel = Skins.Current()->DisplayChannel(withInfo);
|
2002-09-29 13:40:45 +02:00
|
|
|
number = 0;
|
2006-01-04 14:45:23 +01:00
|
|
|
timeout = Switched || Setup.TimeoutRequChInfo;
|
2003-12-22 13:29:24 +01:00
|
|
|
channel = Channels.GetByNumber(Number);
|
2004-05-16 10:35:36 +02:00
|
|
|
lastPresent = lastFollowing = NULL;
|
2000-11-01 15:41:33 +01:00
|
|
|
if (channel) {
|
2003-12-22 13:29:24 +01:00
|
|
|
DisplayChannel();
|
2000-11-01 15:41:33 +01:00
|
|
|
DisplayInfo();
|
2004-05-16 10:35:36 +02:00
|
|
|
displayChannel->Flush();
|
2000-11-01 15:41:33 +01:00
|
|
|
}
|
2006-01-22 14:49:54 +01:00
|
|
|
lastTime.Set();
|
2000-11-01 15:41:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cDisplayChannel::cDisplayChannel(eKeys FirstKey)
|
2002-05-18 12:41:18 +02:00
|
|
|
:cOsdObject(true)
|
2000-09-10 14:56:18 +02:00
|
|
|
{
|
2006-01-22 14:27:53 +01:00
|
|
|
currentDisplayChannel = this;
|
2001-09-08 14:39:09 +02:00
|
|
|
group = -1;
|
2000-09-10 14:56:18 +02:00
|
|
|
number = 0;
|
2006-01-22 14:27:53 +01:00
|
|
|
timeout = true;
|
2004-05-16 10:35:36 +02:00
|
|
|
lastPresent = lastFollowing = NULL;
|
2006-01-22 14:49:54 +01:00
|
|
|
lastTime.Set();
|
2003-05-29 11:45:13 +02:00
|
|
|
withInfo = Setup.ShowInfoOnChSwitch;
|
2004-05-16 10:35:36 +02:00
|
|
|
displayChannel = Skins.Current()->DisplayChannel(withInfo);
|
2006-01-22 14:27:53 +01:00
|
|
|
channel = Channels.GetByNumber(cDevice::CurrentChannel());
|
2000-09-10 14:56:18 +02:00
|
|
|
ProcessKey(FirstKey);
|
|
|
|
}
|
|
|
|
|
2000-11-01 15:41:33 +01:00
|
|
|
cDisplayChannel::~cDisplayChannel()
|
2000-09-10 14:56:18 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
delete displayChannel;
|
2004-05-23 10:35:59 +02:00
|
|
|
cStatus::MsgOsdClear();
|
2006-01-22 14:27:53 +01:00
|
|
|
currentDisplayChannel = NULL;
|
2000-09-10 14:56:18 +02:00
|
|
|
}
|
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
void cDisplayChannel::DisplayChannel(void)
|
2000-11-01 15:41:33 +01:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
displayChannel->SetChannel(channel, number);
|
|
|
|
cStatus::MsgOsdChannel(ChannelString(channel, number));
|
|
|
|
lastPresent = lastFollowing = NULL;
|
2000-11-01 15:41:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayChannel::DisplayInfo(void)
|
|
|
|
{
|
2003-12-22 13:29:24 +01:00
|
|
|
if (withInfo && channel) {
|
|
|
|
cSchedulesLock SchedulesLock;
|
|
|
|
const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock);
|
2000-11-01 15:41:33 +01:00
|
|
|
if (Schedules) {
|
2006-01-14 15:52:40 +01:00
|
|
|
const cSchedule *Schedule = Schedules->GetSchedule(channel);
|
2000-11-01 15:41:33 +01:00
|
|
|
if (Schedule) {
|
2006-01-29 14:04:37 +01:00
|
|
|
const cEvent *Present = Schedule->GetPresentEvent();
|
|
|
|
const cEvent *Following = Schedule->GetFollowingEvent();
|
2004-05-16 10:35:36 +02:00
|
|
|
if (Present != lastPresent || Following != lastFollowing) {
|
2006-01-29 11:15:08 +01:00
|
|
|
SetTrackDescriptions(channel->Number());
|
2004-05-16 10:35:36 +02:00
|
|
|
displayChannel->SetEvents(Present, Following);
|
|
|
|
cStatus::MsgOsdProgramme(Present ? Present->StartTime() : 0, Present ? Present->Title() : NULL, Present ? Present->ShortText() : NULL, Following ? Following->StartTime() : 0, Following ? Following->Title() : NULL, Following ? Following->ShortText() : NULL);
|
|
|
|
lastPresent = Present;
|
|
|
|
lastFollowing = Following;
|
2000-11-01 15:41:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-27 14:32:06 +01:00
|
|
|
void cDisplayChannel::Refresh(void)
|
|
|
|
{
|
2003-12-22 13:29:24 +01:00
|
|
|
DisplayChannel();
|
2004-05-16 10:35:36 +02:00
|
|
|
displayChannel->SetEvents(NULL, NULL);
|
2006-01-22 14:27:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cChannel *cDisplayChannel::NextAvailableChannel(cChannel *Channel, int Direction)
|
|
|
|
{
|
|
|
|
if (Direction) {
|
|
|
|
while (Channel) {
|
|
|
|
Channel = Direction > 0 ? Channels.Next(Channel) : Channels.Prev(Channel);
|
2006-02-03 13:27:40 +01:00
|
|
|
if (Channel && !Channel->GroupSep() && (cDevice::PrimaryDevice()->ProvidesChannel(Channel, Setup.PrimaryLimit) || cDevice::GetDevice(Channel, 0)))
|
2006-01-22 14:27:53 +01:00
|
|
|
return Channel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
2002-10-27 14:32:06 +01:00
|
|
|
}
|
|
|
|
|
2000-11-01 15:41:33 +01:00
|
|
|
eOSState cDisplayChannel::ProcessKey(eKeys Key)
|
2000-09-10 14:56:18 +02:00
|
|
|
{
|
2006-01-22 14:27:53 +01:00
|
|
|
cChannel *NewChannel = NULL;
|
|
|
|
if (Key != kNone)
|
|
|
|
lastTime.Set();
|
2000-09-10 14:56:18 +02:00
|
|
|
switch (Key) {
|
2000-11-01 15:41:33 +01:00
|
|
|
case k0:
|
|
|
|
if (number == 0) {
|
|
|
|
// keep the "Toggle channels" function working
|
2002-09-29 13:40:45 +02:00
|
|
|
cRemote::Put(Key);
|
2000-11-01 15:41:33 +01:00
|
|
|
return osEnd;
|
|
|
|
}
|
|
|
|
case k1 ... k9:
|
2006-07-23 09:26:50 +02:00
|
|
|
group = -1;
|
2000-09-10 14:56:18 +02:00
|
|
|
if (number >= 0) {
|
2006-02-18 12:47:01 +01:00
|
|
|
if (number > Channels.MaxNumber())
|
|
|
|
number = Key - k0;
|
|
|
|
else
|
|
|
|
number = number * 10 + Key - k0;
|
2006-01-22 14:27:53 +01:00
|
|
|
channel = Channels.GetByNumber(number);
|
2006-02-24 14:56:18 +01:00
|
|
|
Refresh();
|
2006-01-22 14:27:53 +01:00
|
|
|
withInfo = false;
|
|
|
|
// Lets see if there can be any useful further input:
|
|
|
|
int n = channel ? number * 10 : 0;
|
2006-01-22 14:38:54 +01:00
|
|
|
int m = 10;
|
2006-01-22 14:27:53 +01:00
|
|
|
cChannel *ch = channel;
|
|
|
|
while (ch && (ch = Channels.Next(ch)) != NULL) {
|
|
|
|
if (!ch->GroupSep()) {
|
2006-01-22 14:38:54 +01:00
|
|
|
if (n <= ch->Number() && ch->Number() < n + m) {
|
2006-01-22 14:27:53 +01:00
|
|
|
n = 0;
|
|
|
|
break;
|
2003-06-13 14:44:31 +02:00
|
|
|
}
|
2006-01-22 14:38:54 +01:00
|
|
|
if (ch->Number() > n) {
|
2006-01-22 14:27:53 +01:00
|
|
|
n *= 10;
|
2006-01-22 14:38:54 +01:00
|
|
|
m *= 10;
|
|
|
|
}
|
2003-06-13 14:44:31 +02:00
|
|
|
}
|
|
|
|
}
|
2006-01-22 14:27:53 +01:00
|
|
|
if (n > 0) {
|
|
|
|
// This channel is the only one that fits the input, so let's take it right away:
|
|
|
|
NewChannel = channel;
|
|
|
|
withInfo = true;
|
|
|
|
number = 0;
|
2006-02-24 14:55:20 +01:00
|
|
|
Refresh();
|
2000-09-10 14:56:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2001-10-27 13:48:20 +02:00
|
|
|
case kLeft|k_Repeat:
|
2001-09-08 14:39:09 +02:00
|
|
|
case kLeft:
|
2001-10-27 13:48:20 +02:00
|
|
|
case kRight|k_Repeat:
|
2001-09-08 14:39:09 +02:00
|
|
|
case kRight:
|
2006-04-15 13:46:55 +02:00
|
|
|
case kNext|k_Repeat:
|
|
|
|
case kNext:
|
|
|
|
case kPrev|k_Repeat:
|
|
|
|
case kPrev:
|
2001-09-08 14:39:09 +02:00
|
|
|
withInfo = false;
|
2005-08-14 15:03:31 +02:00
|
|
|
number = 0;
|
2001-09-08 14:39:09 +02:00
|
|
|
if (group < 0) {
|
2002-06-16 12:57:31 +02:00
|
|
|
cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel());
|
2001-09-08 14:39:09 +02:00
|
|
|
if (channel)
|
|
|
|
group = channel->Index();
|
|
|
|
}
|
|
|
|
if (group >= 0) {
|
|
|
|
int SaveGroup = group;
|
2006-04-15 13:46:55 +02:00
|
|
|
if (NORMALKEY(Key) == kRight || NORMALKEY(Key) == kNext)
|
2001-09-08 14:39:09 +02:00
|
|
|
group = Channels.GetNextGroup(group) ;
|
|
|
|
else
|
|
|
|
group = Channels.GetPrevGroup(group < 1 ? 1 : group);
|
|
|
|
if (group < 0)
|
|
|
|
group = SaveGroup;
|
2003-12-22 13:29:24 +01:00
|
|
|
channel = Channels.Get(group);
|
2001-09-08 14:39:09 +02:00
|
|
|
if (channel) {
|
2006-02-24 14:56:18 +01:00
|
|
|
Refresh();
|
2002-10-06 10:25:42 +02:00
|
|
|
if (!channel->GroupSep())
|
2001-09-08 14:39:09 +02:00
|
|
|
group = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2002-10-27 14:32:06 +01:00
|
|
|
case kUp|k_Repeat:
|
|
|
|
case kUp:
|
|
|
|
case kDown|k_Repeat:
|
|
|
|
case kDown:
|
|
|
|
case kChanUp|k_Repeat:
|
|
|
|
case kChanUp:
|
|
|
|
case kChanDn|k_Repeat:
|
2006-01-22 14:27:53 +01:00
|
|
|
case kChanDn: {
|
|
|
|
eKeys k = NORMALKEY(Key);
|
|
|
|
cChannel *ch = NextAvailableChannel(channel, (k == kUp || k == kChanUp) ? 1 : -1);
|
|
|
|
if (ch)
|
|
|
|
channel = ch;
|
2006-01-28 12:43:26 +01:00
|
|
|
else if (channel && channel->Number() != cDevice::CurrentChannel())
|
|
|
|
Key = k; // immediately switches channel when hitting the beginning/end of the channel list with k_Repeat
|
2006-01-22 14:27:53 +01:00
|
|
|
}
|
|
|
|
// no break here
|
|
|
|
case kUp|k_Release:
|
|
|
|
case kDown|k_Release:
|
|
|
|
case kChanUp|k_Release:
|
|
|
|
case kChanDn|k_Release:
|
2006-04-15 13:46:55 +02:00
|
|
|
case kNext|k_Release:
|
|
|
|
case kPrev|k_Release:
|
2006-01-28 12:43:26 +01:00
|
|
|
if (!(Key & k_Repeat) && channel && channel->Number() != cDevice::CurrentChannel())
|
2006-01-22 14:27:53 +01:00
|
|
|
NewChannel = channel;
|
2003-10-03 14:38:49 +02:00
|
|
|
withInfo = true;
|
2003-06-12 20:37:14 +02:00
|
|
|
group = -1;
|
2005-08-14 15:03:31 +02:00
|
|
|
number = 0;
|
2002-10-27 14:32:06 +01:00
|
|
|
Refresh();
|
|
|
|
break;
|
2000-09-10 14:56:18 +02:00
|
|
|
case kNone:
|
2004-12-19 18:08:09 +01:00
|
|
|
if (number && lastTime.Elapsed() > DIRECTCHANNELTIMEOUT) {
|
2006-01-22 14:27:53 +01:00
|
|
|
channel = Channels.GetByNumber(number);
|
|
|
|
if (channel)
|
|
|
|
NewChannel = channel;
|
|
|
|
withInfo = true;
|
|
|
|
number = 0;
|
|
|
|
Refresh();
|
|
|
|
lastTime.Set();
|
2000-09-10 14:56:18 +02:00
|
|
|
}
|
2000-11-01 15:41:33 +01:00
|
|
|
break;
|
|
|
|
//TODO
|
|
|
|
//XXX case kGreen: return osEventNow;
|
|
|
|
//XXX case kYellow: return osEventNext;
|
2006-01-22 14:27:53 +01:00
|
|
|
case kOk:
|
|
|
|
if (group >= 0) {
|
|
|
|
channel = Channels.Get(Channels.GetNextNormal(group));
|
|
|
|
if (channel)
|
|
|
|
NewChannel = channel;
|
|
|
|
withInfo = true;
|
|
|
|
group = -1;
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
else if (number > 0) {
|
|
|
|
channel = Channels.GetByNumber(number);
|
|
|
|
if (channel)
|
|
|
|
NewChannel = channel;
|
|
|
|
withInfo = true;
|
|
|
|
number = 0;
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return osEnd;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if ((Key & (k_Repeat | k_Release)) == 0) {
|
|
|
|
cRemote::Put(Key);
|
|
|
|
return osEnd;
|
|
|
|
}
|
2000-09-10 14:56:18 +02:00
|
|
|
};
|
2006-01-04 14:45:23 +01:00
|
|
|
if (!timeout || lastTime.Elapsed() < (uint64)(Setup.ChannelInfoTime * 1000)) {
|
2006-01-22 16:06:39 +01:00
|
|
|
if (Key == kNone && !number && group < 0 && !NewChannel && channel && channel->Number() != cDevice::CurrentChannel()) {
|
|
|
|
// makes sure a channel switch through the SVDRP CHAN command is displayed
|
|
|
|
channel = Channels.GetByNumber(cDevice::CurrentChannel());
|
|
|
|
Refresh();
|
|
|
|
lastTime.Set();
|
|
|
|
}
|
2000-11-01 15:41:33 +01:00
|
|
|
DisplayInfo();
|
2004-05-16 10:35:36 +02:00
|
|
|
displayChannel->Flush();
|
2006-01-22 16:06:39 +01:00
|
|
|
if (NewChannel) {
|
2006-01-29 11:15:08 +01:00
|
|
|
SetTrackDescriptions(NewChannel->Number()); // to make them immediately visible in the channel display
|
2006-01-22 14:27:53 +01:00
|
|
|
Channels.SwitchTo(NewChannel->Number());
|
2006-01-29 11:15:08 +01:00
|
|
|
SetTrackDescriptions(NewChannel->Number()); // switching the channel has cleared them
|
2006-01-22 16:06:39 +01:00
|
|
|
channel = NewChannel;
|
|
|
|
}
|
2000-11-01 15:41:33 +01:00
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
return osEnd;
|
2000-09-10 14:56:18 +02:00
|
|
|
}
|
|
|
|
|
2002-03-09 17:11:49 +01:00
|
|
|
// --- cDisplayVolume --------------------------------------------------------
|
|
|
|
|
|
|
|
#define VOLUMETIMEOUT 1000 //ms
|
|
|
|
#define MUTETIMEOUT 5000 //ms
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
cDisplayVolume *cDisplayVolume::currentDisplayVolume = NULL;
|
2002-03-09 17:11:49 +01:00
|
|
|
|
|
|
|
cDisplayVolume::cDisplayVolume(void)
|
2002-05-18 12:41:18 +02:00
|
|
|
:cOsdObject(true)
|
2002-03-09 17:11:49 +01:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
currentDisplayVolume = this;
|
2004-12-19 18:08:09 +01:00
|
|
|
timeout.Set(cDevice::PrimaryDevice()->IsMute() ? MUTETIMEOUT : VOLUMETIMEOUT);
|
2004-05-16 10:35:36 +02:00
|
|
|
displayVolume = Skins.Current()->DisplayVolume();
|
2002-03-09 17:11:49 +01:00
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
cDisplayVolume::~cDisplayVolume()
|
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
delete displayVolume;
|
|
|
|
currentDisplayVolume = NULL;
|
2002-03-09 17:11:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayVolume::Show(void)
|
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
displayVolume->SetVolume(cDevice::CurrentVolume(), MAXVOLUME, cDevice::PrimaryDevice()->IsMute());
|
2002-03-09 17:11:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cDisplayVolume *cDisplayVolume::Create(void)
|
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
if (!currentDisplayVolume)
|
2002-03-09 17:11:49 +01:00
|
|
|
new cDisplayVolume;
|
2004-05-16 10:35:36 +02:00
|
|
|
return currentDisplayVolume;
|
2002-03-09 17:11:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayVolume::Process(eKeys Key)
|
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
if (currentDisplayVolume)
|
|
|
|
currentDisplayVolume->ProcessKey(Key);
|
2002-03-09 17:11:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cDisplayVolume::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
switch (Key) {
|
|
|
|
case kVolUp|k_Repeat:
|
|
|
|
case kVolUp:
|
|
|
|
case kVolDn|k_Repeat:
|
|
|
|
case kVolDn:
|
|
|
|
Show();
|
2004-12-19 18:08:09 +01:00
|
|
|
timeout.Set(VOLUMETIMEOUT);
|
2002-03-09 17:11:49 +01:00
|
|
|
break;
|
|
|
|
case kMute:
|
2002-06-16 12:57:31 +02:00
|
|
|
if (cDevice::PrimaryDevice()->IsMute()) {
|
2002-03-09 17:11:49 +01:00
|
|
|
Show();
|
2004-12-19 18:08:09 +01:00
|
|
|
timeout.Set(MUTETIMEOUT);
|
2002-03-09 17:11:49 +01:00
|
|
|
}
|
|
|
|
else
|
2004-12-19 18:08:09 +01:00
|
|
|
timeout.Set();
|
2002-03-09 17:11:49 +01:00
|
|
|
break;
|
|
|
|
case kNone: break;
|
|
|
|
default: if ((Key & k_Release) == 0) {
|
2002-09-29 13:40:45 +02:00
|
|
|
cRemote::Put(Key);
|
2002-03-09 17:11:49 +01:00
|
|
|
return osEnd;
|
|
|
|
}
|
|
|
|
}
|
2004-12-19 18:08:09 +01:00
|
|
|
return timeout.TimedOut() ? osEnd : osContinue;
|
2002-03-09 17:11:49 +01:00
|
|
|
}
|
|
|
|
|
2005-01-02 15:11:44 +01:00
|
|
|
// --- cDisplayTracks --------------------------------------------------------
|
|
|
|
|
|
|
|
#define TRACKTIMEOUT 5000 //ms
|
|
|
|
|
|
|
|
cDisplayTracks *cDisplayTracks::currentDisplayTracks = NULL;
|
|
|
|
|
|
|
|
cDisplayTracks::cDisplayTracks(void)
|
|
|
|
:cOsdObject(true)
|
|
|
|
{
|
2005-02-06 11:33:13 +01:00
|
|
|
cDevice::PrimaryDevice()->EnsureAudioTrack();
|
2006-02-04 14:58:24 +01:00
|
|
|
SetTrackDescriptions(!cDevice::PrimaryDevice()->Replaying() || cDevice::PrimaryDevice()->Transferring() ? cDevice::CurrentChannel() : 0);
|
2005-01-02 15:11:44 +01:00
|
|
|
currentDisplayTracks = this;
|
|
|
|
numTracks = track = 0;
|
2005-01-09 12:08:34 +01:00
|
|
|
audioChannel = cDevice::PrimaryDevice()->GetAudioChannel();
|
2005-01-02 15:11:44 +01:00
|
|
|
eTrackType CurrentAudioTrack = cDevice::PrimaryDevice()->GetCurrentAudioTrack();
|
|
|
|
for (int i = ttAudioFirst; i <= ttDolbyLast; i++) {
|
|
|
|
const tTrackId *TrackId = cDevice::PrimaryDevice()->GetTrack(eTrackType(i));
|
|
|
|
if (TrackId && TrackId->id) {
|
|
|
|
types[numTracks] = eTrackType(i);
|
2005-01-04 11:11:16 +01:00
|
|
|
descriptions[numTracks] = strdup(*TrackId->description ? TrackId->description : *TrackId->language ? TrackId->language : *itoa(i));
|
2005-01-02 15:11:44 +01:00
|
|
|
if (i == CurrentAudioTrack)
|
|
|
|
track = numTracks;
|
|
|
|
numTracks++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
timeout.Set(TRACKTIMEOUT);
|
2006-01-07 15:54:10 +01:00
|
|
|
displayTracks = Skins.Current()->DisplayTracks(tr("Button$Audio"), numTracks, descriptions);
|
2005-01-02 15:11:44 +01:00
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
cDisplayTracks::~cDisplayTracks()
|
|
|
|
{
|
|
|
|
delete displayTracks;
|
|
|
|
currentDisplayTracks = NULL;
|
|
|
|
for (int i = 0; i < numTracks; i++)
|
|
|
|
free(descriptions[i]);
|
|
|
|
cStatus::MsgOsdClear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayTracks::Show(void)
|
|
|
|
{
|
2005-01-09 12:08:34 +01:00
|
|
|
int ac = IS_AUDIO_TRACK(types[track]) ? audioChannel : -1;
|
2005-01-02 15:11:44 +01:00
|
|
|
displayTracks->SetTrack(track, descriptions);
|
2005-01-09 12:08:34 +01:00
|
|
|
displayTracks->SetAudioChannel(ac);
|
2005-01-02 15:11:44 +01:00
|
|
|
displayTracks->Flush();
|
|
|
|
cStatus::MsgSetAudioTrack(track, descriptions);
|
2005-01-09 12:08:34 +01:00
|
|
|
cStatus::MsgSetAudioChannel(ac);
|
2005-01-02 15:11:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cDisplayTracks *cDisplayTracks::Create(void)
|
|
|
|
{
|
2005-01-04 13:40:38 +01:00
|
|
|
if (cDevice::PrimaryDevice()->NumAudioTracks() > 0) {
|
|
|
|
if (!currentDisplayTracks)
|
|
|
|
new cDisplayTracks;
|
|
|
|
return currentDisplayTracks;
|
|
|
|
}
|
|
|
|
Skins.Message(mtWarning, tr("No audio available!"));
|
|
|
|
return NULL;
|
2005-01-02 15:11:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayTracks::Process(eKeys Key)
|
|
|
|
{
|
|
|
|
if (currentDisplayTracks)
|
|
|
|
currentDisplayTracks->ProcessKey(Key);
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cDisplayTracks::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
int oldTrack = track;
|
2005-01-09 12:08:34 +01:00
|
|
|
int oldAudioChannel = audioChannel;
|
2005-01-02 15:11:44 +01:00
|
|
|
switch (Key) {
|
|
|
|
case kUp|k_Repeat:
|
|
|
|
case kUp:
|
|
|
|
case kDown|k_Repeat:
|
|
|
|
case kDown:
|
|
|
|
if (NORMALKEY(Key) == kUp && track > 0)
|
|
|
|
track--;
|
|
|
|
else if (NORMALKEY(Key) == kDown && track < numTracks - 1)
|
|
|
|
track++;
|
|
|
|
timeout.Set(TRACKTIMEOUT);
|
|
|
|
break;
|
2005-01-06 13:50:17 +01:00
|
|
|
case kLeft|k_Repeat:
|
|
|
|
case kLeft:
|
|
|
|
case kRight|k_Repeat:
|
2005-01-09 12:08:34 +01:00
|
|
|
case kRight: if (IS_AUDIO_TRACK(types[track])) {
|
|
|
|
static int ac[] = { 1, 0, 2 };
|
|
|
|
audioChannel = ac[cDevice::PrimaryDevice()->GetAudioChannel()];
|
|
|
|
if (NORMALKEY(Key) == kLeft && audioChannel > 0)
|
|
|
|
audioChannel--;
|
|
|
|
else if (NORMALKEY(Key) == kRight && audioChannel < 2)
|
|
|
|
audioChannel++;
|
|
|
|
audioChannel = ac[audioChannel];
|
|
|
|
timeout.Set(TRACKTIMEOUT);
|
|
|
|
}
|
2005-01-06 13:50:17 +01:00
|
|
|
break;
|
2005-02-27 14:12:03 +01:00
|
|
|
case kAudio|k_Repeat:
|
2005-01-02 15:11:44 +01:00
|
|
|
case kAudio:
|
|
|
|
if (++track >= numTracks)
|
|
|
|
track = 0;
|
|
|
|
timeout.Set(TRACKTIMEOUT);
|
|
|
|
break;
|
2005-01-04 12:52:17 +01:00
|
|
|
case kOk:
|
|
|
|
if (track != cDevice::PrimaryDevice()->GetCurrentAudioTrack())
|
|
|
|
oldTrack = -1; // make sure we explicitly switch to that track
|
|
|
|
timeout.Set();
|
|
|
|
break;
|
2005-01-02 15:11:44 +01:00
|
|
|
case kNone: break;
|
2005-01-06 13:50:17 +01:00
|
|
|
default: if ((Key & k_Release) == 0)
|
|
|
|
return osEnd;
|
2005-01-02 15:11:44 +01:00
|
|
|
}
|
2005-01-09 12:08:34 +01:00
|
|
|
if (track != oldTrack || audioChannel != oldAudioChannel)
|
2005-01-02 15:11:44 +01:00
|
|
|
Show();
|
2005-01-09 12:08:34 +01:00
|
|
|
if (track != oldTrack) {
|
2005-01-02 15:11:44 +01:00
|
|
|
cDevice::PrimaryDevice()->SetCurrentAudioTrack(types[track]);
|
2005-01-08 13:53:30 +01:00
|
|
|
Setup.CurrentDolby = IS_DOLBY_TRACK(types[track]);
|
2005-01-02 15:11:44 +01:00
|
|
|
}
|
2005-01-09 12:08:34 +01:00
|
|
|
if (audioChannel != oldAudioChannel)
|
|
|
|
cDevice::PrimaryDevice()->SetAudioChannel(audioChannel);
|
2005-01-02 15:11:44 +01:00
|
|
|
return timeout.TimedOut() ? osEnd : osContinue;
|
|
|
|
}
|
|
|
|
|
2000-04-30 10:22:13 +02:00
|
|
|
// --- cRecordControl --------------------------------------------------------
|
|
|
|
|
2003-05-11 16:10:06 +02:00
|
|
|
cRecordControl::cRecordControl(cDevice *Device, cTimer *Timer, bool Pause)
|
2000-04-30 10:22:13 +02:00
|
|
|
{
|
2005-05-16 14:45:11 +02:00
|
|
|
// We're going to manipulate an event here, so we need to prevent
|
|
|
|
// others from modifying any EPG data:
|
|
|
|
cSchedulesLock SchedulesLock;
|
|
|
|
cSchedules::Schedules(SchedulesLock);
|
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
event = NULL;
|
2000-05-01 16:29:46 +02:00
|
|
|
instantId = NULL;
|
2001-09-23 14:02:11 +02:00
|
|
|
fileName = NULL;
|
2002-06-16 12:57:31 +02:00
|
|
|
recorder = NULL;
|
|
|
|
device = Device;
|
|
|
|
if (!device) device = cDevice::PrimaryDevice();//XXX
|
2000-04-30 10:22:13 +02:00
|
|
|
timer = Timer;
|
|
|
|
if (!timer) {
|
2003-05-11 14:10:00 +02:00
|
|
|
timer = new cTimer(true, Pause);
|
2000-04-30 10:22:13 +02:00
|
|
|
Timers.Add(timer);
|
2004-10-31 10:22:32 +01:00
|
|
|
Timers.SetModified();
|
2002-10-20 12:28:55 +02:00
|
|
|
asprintf(&instantId, cDevice::NumDevices() > 1 ? "%s - %d" : "%s", timer->Channel()->Name(), device->CardIndex() + 1);
|
2000-04-30 10:22:13 +02:00
|
|
|
}
|
2001-08-11 15:48:54 +02:00
|
|
|
timer->SetPending(true);
|
2000-04-30 10:22:13 +02:00
|
|
|
timer->SetRecording(true);
|
2004-02-29 14:21:22 +01:00
|
|
|
event = timer->Event();
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2005-05-16 14:45:11 +02:00
|
|
|
if (event || GetEvent())
|
|
|
|
dsyslog("Title: '%s' Subtitle: '%s'", event->Title(), event->ShortText());
|
|
|
|
cRecording Recording(timer, event);
|
2002-06-16 12:57:31 +02:00
|
|
|
fileName = strdup(Recording.FileName());
|
2003-05-25 12:56:26 +02:00
|
|
|
|
|
|
|
// crude attempt to avoid duplicate recordings:
|
|
|
|
if (cRecordControls::GetRecordControl(fileName)) {
|
|
|
|
isyslog("already recording: '%s'", fileName);
|
|
|
|
if (Timer) {
|
|
|
|
timer->SetPending(false);
|
|
|
|
timer->SetRecording(false);
|
|
|
|
timer->OnOff();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Timers.Del(timer);
|
2004-10-31 10:22:32 +01:00
|
|
|
Timers.SetModified();
|
2003-08-16 10:41:21 +02:00
|
|
|
if (!cReplayControl::LastReplayed()) // an instant recording, maybe from cRecordControls::PauseLiveVideo()
|
|
|
|
cReplayControl::SetRecording(fileName, Recording.Name());
|
2003-05-25 12:56:26 +02:00
|
|
|
}
|
|
|
|
timer = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
cRecordingUserCommand::InvokeCommand(RUC_BEFORERECORDING, fileName);
|
2003-08-02 13:23:58 +02:00
|
|
|
isyslog("record %s", fileName);
|
|
|
|
if (MakeDirs(fileName, true)) {
|
|
|
|
const cChannel *ch = timer->Channel();
|
2005-01-16 14:40:47 +01:00
|
|
|
recorder = new cRecorder(fileName, ch->Ca(), timer->Priority(), ch->Vpid(), ch->Apids(), ch->Dpids(), ch->Spids());
|
2003-08-02 13:23:58 +02:00
|
|
|
if (device->AttachReceiver(recorder)) {
|
2005-05-16 14:45:11 +02:00
|
|
|
Recording.WriteInfo();
|
2005-12-31 15:20:19 +01:00
|
|
|
cStatus::MsgRecording(device, Recording.Name(), Recording.FileName(), true);
|
2003-08-02 13:23:58 +02:00
|
|
|
if (!Timer && !cReplayControl::LastReplayed()) // an instant recording, maybe from cRecordControls::PauseLiveVideo()
|
|
|
|
cReplayControl::SetRecording(fileName, Recording.Name());
|
2004-06-13 20:26:51 +02:00
|
|
|
Recordings.AddByName(fileName);
|
2004-11-20 11:00:26 +01:00
|
|
|
return;
|
2003-08-02 13:23:58 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
DELETENULL(recorder);
|
2001-06-02 10:47:40 +02:00
|
|
|
}
|
2004-11-20 11:00:26 +01:00
|
|
|
if (!Timer) {
|
|
|
|
Timers.Del(timer);
|
|
|
|
Timers.SetModified();
|
|
|
|
timer = NULL;
|
|
|
|
}
|
2000-04-30 10:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cRecordControl::~cRecordControl()
|
|
|
|
{
|
2005-03-20 11:19:36 +01:00
|
|
|
Stop();
|
2002-08-11 13:32:23 +02:00
|
|
|
free(instantId);
|
|
|
|
free(fileName);
|
2000-04-30 11:15:16 +02:00
|
|
|
}
|
|
|
|
|
2002-02-17 16:03:49 +01:00
|
|
|
#define INSTANT_REC_EPG_LOOKAHEAD 300 // seconds to look into the EPG data for an instant recording
|
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
bool cRecordControl::GetEvent(void)
|
2001-08-19 14:45:31 +02:00
|
|
|
{
|
2002-10-20 12:28:55 +02:00
|
|
|
const cChannel *channel = timer->Channel();
|
2004-02-29 14:21:22 +01:00
|
|
|
time_t Time = timer->HasFlags(tfInstant) ? timer->StartTime() + INSTANT_REC_EPG_LOOKAHEAD : timer->StartTime() + (timer->StopTime() - timer->StartTime()) / 2;
|
2001-08-19 14:45:31 +02:00
|
|
|
for (int seconds = 0; seconds <= MAXWAIT4EPGINFO; seconds++) {
|
|
|
|
{
|
2003-12-22 13:29:24 +01:00
|
|
|
cSchedulesLock SchedulesLock;
|
|
|
|
const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock);
|
2001-08-19 14:45:31 +02:00
|
|
|
if (Schedules) {
|
2006-01-14 15:52:40 +01:00
|
|
|
const cSchedule *Schedule = Schedules->GetSchedule(channel);
|
2001-08-19 14:45:31 +02:00
|
|
|
if (Schedule) {
|
2003-12-22 13:29:24 +01:00
|
|
|
event = Schedule->GetEventAround(Time);
|
|
|
|
if (event) {
|
2001-08-19 14:45:31 +02:00
|
|
|
if (seconds > 0)
|
2002-05-13 16:35:49 +02:00
|
|
|
dsyslog("got EPG info after %d seconds", seconds);
|
2001-08-19 14:45:31 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (seconds == 0)
|
2002-05-13 16:35:49 +02:00
|
|
|
dsyslog("waiting for EPG info...");
|
2001-08-19 14:45:31 +02:00
|
|
|
sleep(1);
|
|
|
|
}
|
2002-05-13 16:35:49 +02:00
|
|
|
dsyslog("no EPG info available");
|
2001-08-19 14:45:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-03-20 11:19:36 +01:00
|
|
|
void cRecordControl::Stop(void)
|
2000-04-30 11:15:16 +02:00
|
|
|
{
|
|
|
|
if (timer) {
|
2002-06-16 12:57:31 +02:00
|
|
|
DELETENULL(recorder);
|
2000-04-30 11:15:16 +02:00
|
|
|
timer->SetRecording(false);
|
|
|
|
timer = NULL;
|
2005-12-31 15:20:19 +01:00
|
|
|
cStatus::MsgRecording(device, NULL, fileName, false);
|
2001-09-23 14:02:11 +02:00
|
|
|
cRecordingUserCommand::InvokeCommand(RUC_AFTERRECORDING, fileName);
|
2000-04-30 10:22:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-01 15:04:14 +02:00
|
|
|
bool cRecordControl::Process(time_t t)
|
2000-04-30 10:22:13 +02:00
|
|
|
{
|
2002-06-16 12:57:31 +02:00
|
|
|
if (!recorder || !timer || !timer->Matches(t))
|
2000-05-01 16:29:46 +02:00
|
|
|
return false;
|
2002-10-20 12:28:55 +02:00
|
|
|
AssertFreeDiskSpace(timer->Priority());
|
2000-05-01 16:29:46 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- cRecordControls -------------------------------------------------------
|
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
cRecordControl *cRecordControls::RecordControls[MAXRECORDCONTROLS] = { NULL };
|
2005-12-24 15:53:53 +01:00
|
|
|
int cRecordControls::state = 0;
|
2000-05-01 16:29:46 +02:00
|
|
|
|
2003-05-11 14:10:00 +02:00
|
|
|
bool cRecordControls::Start(cTimer *Timer, bool Pause)
|
2000-05-01 16:29:46 +02:00
|
|
|
{
|
2006-01-20 16:34:56 +01:00
|
|
|
static time_t LastNoDiskSpaceMessage = 0;
|
|
|
|
int FreeMB = 0;
|
2006-01-21 10:02:19 +01:00
|
|
|
if (Timer) {
|
|
|
|
AssertFreeDiskSpace(Timer->Priority(), !Timer->Pending());
|
|
|
|
Timer->SetPending(true);
|
|
|
|
}
|
2006-01-20 16:34:56 +01:00
|
|
|
VideoDiskSpace(&FreeMB);
|
|
|
|
if (FreeMB < MINFREEDISK) {
|
|
|
|
if (!Timer || time(NULL) - LastNoDiskSpaceMessage > NODISKSPACEDELTA) {
|
|
|
|
isyslog("not enough disk space to start recording%s%s", Timer ? " timer " : "", Timer ? *Timer->ToDescr() : "");
|
|
|
|
Skins.Message(mtWarning, tr("Not enough disk space to start recording!"));
|
|
|
|
LastNoDiskSpaceMessage = time(NULL);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
LastNoDiskSpaceMessage = 0;
|
|
|
|
|
2005-12-24 15:53:53 +01:00
|
|
|
ChangeState();
|
2002-10-20 12:28:55 +02:00
|
|
|
int ch = Timer ? Timer->Channel()->Number() : cDevice::CurrentChannel();
|
2000-09-09 14:57:43 +02:00
|
|
|
cChannel *channel = Channels.GetByNumber(ch);
|
2000-05-01 16:29:46 +02:00
|
|
|
|
|
|
|
if (channel) {
|
2002-09-06 14:10:17 +02:00
|
|
|
bool NeedsDetachReceivers = false;
|
2003-05-11 14:10:00 +02:00
|
|
|
int Priority = Timer ? Timer->Priority() : Pause ? Setup.PausePriority : Setup.DefaultPriority;
|
|
|
|
cDevice *device = cDevice::GetDevice(channel, Priority, &NeedsDetachReceivers);
|
2002-06-16 12:57:31 +02:00
|
|
|
if (device) {
|
2003-08-16 13:24:23 +02:00
|
|
|
if (NeedsDetachReceivers) {
|
2002-06-16 12:57:31 +02:00
|
|
|
Stop(device);
|
2003-08-24 14:47:34 +02:00
|
|
|
if (device == cTransferControl::ReceiverDevice())
|
2003-08-16 13:24:23 +02:00
|
|
|
cControl::Shutdown(); // in case this device was used for Transfer Mode
|
|
|
|
}
|
2004-03-07 09:40:51 +01:00
|
|
|
dsyslog("switching device %d to channel %d", device->DeviceNumber() + 1, channel->Number());
|
2002-09-06 14:10:17 +02:00
|
|
|
if (!device->SwitchChannel(channel, false)) {
|
|
|
|
cThread::EmergencyExit(true);
|
|
|
|
return false;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
2004-02-29 14:21:22 +01:00
|
|
|
if (!Timer || Timer->Matches()) {
|
|
|
|
for (int i = 0; i < MAXRECORDCONTROLS; i++) {
|
|
|
|
if (!RecordControls[i]) {
|
|
|
|
RecordControls[i] = new cRecordControl(device, Timer, Pause);
|
2004-11-20 11:00:26 +01:00
|
|
|
return RecordControls[i]->Process(time(NULL));
|
2004-02-29 14:21:22 +01:00
|
|
|
}
|
2000-05-01 16:29:46 +02:00
|
|
|
}
|
2004-02-29 14:21:22 +01:00
|
|
|
}
|
2000-05-01 16:29:46 +02:00
|
|
|
}
|
2006-01-20 16:34:56 +01:00
|
|
|
else if (!Timer || (Timer->Priority() >= Setup.PrimaryLimit && !Timer->Pending())) {
|
2002-05-13 16:35:49 +02:00
|
|
|
isyslog("no free DVB device to record channel %d!", ch);
|
2006-01-20 16:34:56 +01:00
|
|
|
Skins.Message(mtError, tr("No free DVB device to record!"));
|
|
|
|
}
|
2000-05-01 16:29:46 +02:00
|
|
|
}
|
|
|
|
else
|
2002-05-13 16:35:49 +02:00
|
|
|
esyslog("ERROR: channel %d not defined!", ch);
|
2000-05-01 16:29:46 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cRecordControls::Stop(const char *InstantId)
|
|
|
|
{
|
2005-12-24 15:53:53 +01:00
|
|
|
ChangeState();
|
2002-06-16 12:57:31 +02:00
|
|
|
for (int i = 0; i < MAXRECORDCONTROLS; i++) {
|
2000-05-01 16:29:46 +02:00
|
|
|
if (RecordControls[i]) {
|
|
|
|
const char *id = RecordControls[i]->InstantId();
|
2005-03-20 11:19:36 +01:00
|
|
|
if (id && strcmp(id, InstantId) == 0) {
|
|
|
|
cTimer *timer = RecordControls[i]->Timer();
|
2000-05-01 16:29:46 +02:00
|
|
|
RecordControls[i]->Stop();
|
2005-03-20 11:19:36 +01:00
|
|
|
if (timer) {
|
2005-03-20 15:15:42 +01:00
|
|
|
isyslog("deleting timer %s", *timer->ToDescr());
|
2005-03-20 11:19:36 +01:00
|
|
|
Timers.Del(timer);
|
|
|
|
Timers.SetModified();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2000-05-01 16:29:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
void cRecordControls::Stop(cDevice *Device)
|
2000-11-12 14:06:53 +01:00
|
|
|
{
|
2005-12-24 15:53:53 +01:00
|
|
|
ChangeState();
|
2002-06-16 12:57:31 +02:00
|
|
|
for (int i = 0; i < MAXRECORDCONTROLS; i++) {
|
2000-11-12 14:06:53 +01:00
|
|
|
if (RecordControls[i]) {
|
2004-02-15 14:31:53 +01:00
|
|
|
if (RecordControls[i]->Device() == Device) {
|
2002-06-16 12:57:31 +02:00
|
|
|
isyslog("stopping recording on DVB device %d due to higher priority", Device->CardIndex() + 1);
|
2005-03-20 11:19:36 +01:00
|
|
|
RecordControls[i]->Stop();
|
2000-11-12 14:06:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-21 14:57:13 +02:00
|
|
|
bool cRecordControls::PauseLiveVideo(void)
|
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtStatus, tr("Pausing live video..."));
|
2003-04-21 14:57:13 +02:00
|
|
|
cReplayControl::SetRecording(NULL, NULL); // make sure the new cRecordControl will set cReplayControl::LastReplayed()
|
2003-05-11 14:10:00 +02:00
|
|
|
if (Start(NULL, true)) {
|
2003-04-21 14:57:13 +02:00
|
|
|
sleep(2); // allow recorded file to fill up enough to start replaying
|
|
|
|
cReplayControl *rc = new cReplayControl;
|
|
|
|
cControl::Launch(rc);
|
|
|
|
cControl::Attach();
|
|
|
|
sleep(1); // allow device to replay some frames, so we have a picture
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtStatus, NULL);
|
2003-04-21 14:57:13 +02:00
|
|
|
rc->ProcessKey(kPause); // pause, allowing replay mode display
|
|
|
|
return true;
|
|
|
|
}
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtStatus, NULL);
|
2003-04-21 14:57:13 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2000-05-01 16:29:46 +02:00
|
|
|
const char *cRecordControls::GetInstantId(const char *LastInstantId)
|
|
|
|
{
|
2002-06-16 12:57:31 +02:00
|
|
|
for (int i = 0; i < MAXRECORDCONTROLS; i++) {
|
2000-05-01 16:29:46 +02:00
|
|
|
if (RecordControls[i]) {
|
|
|
|
if (!LastInstantId && RecordControls[i]->InstantId())
|
|
|
|
return RecordControls[i]->InstantId();
|
|
|
|
if (LastInstantId && LastInstantId == RecordControls[i]->InstantId())
|
|
|
|
LastInstantId = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2002-02-17 14:29:13 +01:00
|
|
|
cRecordControl *cRecordControls::GetRecordControl(const char *FileName)
|
|
|
|
{
|
2002-06-16 12:57:31 +02:00
|
|
|
for (int i = 0; i < MAXRECORDCONTROLS; i++) {
|
2002-02-17 14:29:13 +01:00
|
|
|
if (RecordControls[i] && strcmp(RecordControls[i]->FileName(), FileName) == 0)
|
|
|
|
return RecordControls[i];
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-01 15:04:14 +02:00
|
|
|
void cRecordControls::Process(time_t t)
|
2000-05-01 16:29:46 +02:00
|
|
|
{
|
2002-06-16 12:57:31 +02:00
|
|
|
for (int i = 0; i < MAXRECORDCONTROLS; i++) {
|
2000-05-01 16:29:46 +02:00
|
|
|
if (RecordControls[i]) {
|
2005-12-24 15:53:53 +01:00
|
|
|
if (!RecordControls[i]->Process(t)) {
|
2000-05-01 16:29:46 +02:00
|
|
|
DELETENULL(RecordControls[i]);
|
2005-12-24 15:53:53 +01:00
|
|
|
ChangeState();
|
|
|
|
}
|
2000-05-01 16:29:46 +02:00
|
|
|
}
|
|
|
|
}
|
2000-04-30 10:22:13 +02:00
|
|
|
}
|
|
|
|
|
2004-01-04 12:30:00 +01:00
|
|
|
void cRecordControls::ChannelDataModified(cChannel *Channel)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < MAXRECORDCONTROLS; i++) {
|
|
|
|
if (RecordControls[i]) {
|
|
|
|
if (RecordControls[i]->Timer() && RecordControls[i]->Timer()->Channel() == Channel) {
|
2004-02-15 14:31:53 +01:00
|
|
|
if (RecordControls[i]->Device()->ProvidesTransponder(Channel)) { // avoids retune on devices that don't really access the transponder
|
|
|
|
isyslog("stopping recording due to modification of channel %d", Channel->Number());
|
2005-03-20 11:19:36 +01:00
|
|
|
RecordControls[i]->Stop();
|
2004-02-15 14:31:53 +01:00
|
|
|
// This will restart the recording, maybe even from a different
|
|
|
|
// device in case conditional access has changed.
|
2005-12-24 15:53:53 +01:00
|
|
|
ChangeState();
|
2004-02-15 14:31:53 +01:00
|
|
|
}
|
2004-01-04 12:30:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-04 12:36:32 +01:00
|
|
|
bool cRecordControls::Active(void)
|
|
|
|
{
|
2002-06-16 12:57:31 +02:00
|
|
|
for (int i = 0; i < MAXRECORDCONTROLS; i++) {
|
2001-02-04 12:36:32 +01:00
|
|
|
if (RecordControls[i])
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
void cRecordControls::Shutdown(void)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < MAXRECORDCONTROLS; i++)
|
|
|
|
DELETENULL(RecordControls[i]);
|
2005-12-24 15:53:53 +01:00
|
|
|
ChangeState();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cRecordControls::StateChanged(int &State)
|
|
|
|
{
|
|
|
|
int NewState = state;
|
|
|
|
bool Result = State != NewState;
|
|
|
|
State = state;
|
|
|
|
return Result;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
2000-04-29 15:57:42 +02:00
|
|
|
// --- cReplayControl --------------------------------------------------------
|
|
|
|
|
|
|
|
char *cReplayControl::fileName = NULL;
|
|
|
|
char *cReplayControl::title = NULL;
|
|
|
|
|
|
|
|
cReplayControl::cReplayControl(void)
|
2002-06-23 11:23:34 +02:00
|
|
|
:cDvbPlayerControl(fileName)
|
2000-04-29 15:57:42 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
displayReplay = NULL;
|
2001-09-14 14:06:43 +02:00
|
|
|
visible = modeOnly = shown = displayFrames = false;
|
2001-07-28 13:16:23 +02:00
|
|
|
lastCurrent = lastTotal = -1;
|
2004-05-16 10:35:36 +02:00
|
|
|
lastPlay = lastForward = false;
|
|
|
|
lastSpeed = -1;
|
2001-07-28 14:06:36 +02:00
|
|
|
timeoutShow = 0;
|
2001-08-11 14:30:21 +02:00
|
|
|
timeSearchActive = false;
|
2002-06-23 11:23:34 +02:00
|
|
|
marks.Load(fileName);
|
2002-07-14 11:03:30 +02:00
|
|
|
cRecording Recording(fileName);
|
2005-12-31 15:20:19 +01:00
|
|
|
cStatus::MsgReplaying(this, Recording.Name(), Recording.FileName(), true);
|
2006-04-14 14:47:01 +02:00
|
|
|
SetTrackDescriptions(false);
|
2000-04-29 15:57:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cReplayControl::~cReplayControl()
|
|
|
|
{
|
|
|
|
Hide();
|
2005-12-31 15:20:19 +01:00
|
|
|
cStatus::MsgReplaying(this, NULL, fileName, false);
|
2002-06-16 12:57:31 +02:00
|
|
|
Stop();
|
2000-04-29 15:57:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cReplayControl::SetRecording(const char *FileName, const char *Title)
|
|
|
|
{
|
2002-08-11 13:32:23 +02:00
|
|
|
free(fileName);
|
|
|
|
free(title);
|
2000-04-29 15:57:42 +02:00
|
|
|
fileName = FileName ? strdup(FileName) : NULL;
|
|
|
|
title = Title ? strdup(Title) : NULL;
|
|
|
|
}
|
2000-04-23 15:38:16 +02:00
|
|
|
|
2000-10-08 15:08:26 +02:00
|
|
|
const char *cReplayControl::LastReplayed(void)
|
|
|
|
{
|
|
|
|
return fileName;
|
|
|
|
}
|
|
|
|
|
2000-10-08 15:41:30 +02:00
|
|
|
void cReplayControl::ClearLastReplayed(const char *FileName)
|
|
|
|
{
|
|
|
|
if (fileName && FileName && strcmp(fileName, FileName) == 0) {
|
2002-08-11 13:32:23 +02:00
|
|
|
free(fileName);
|
2000-10-08 15:41:30 +02:00
|
|
|
fileName = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-24 16:41:35 +02:00
|
|
|
void cReplayControl::ShowTimed(int Seconds)
|
2000-04-23 15:38:16 +02:00
|
|
|
{
|
2001-09-21 16:18:51 +02:00
|
|
|
if (modeOnly)
|
|
|
|
Hide();
|
2000-04-29 15:57:42 +02:00
|
|
|
if (!visible) {
|
2000-12-09 11:13:00 +01:00
|
|
|
shown = ShowProgress(true);
|
2001-09-21 16:01:45 +02:00
|
|
|
timeoutShow = (shown && Seconds > 0) ? time(NULL) + Seconds : 0;
|
2000-04-29 15:57:42 +02:00
|
|
|
}
|
2000-04-23 15:38:16 +02:00
|
|
|
}
|
|
|
|
|
2003-05-24 16:41:35 +02:00
|
|
|
void cReplayControl::Show(void)
|
|
|
|
{
|
|
|
|
ShowTimed();
|
|
|
|
}
|
|
|
|
|
2000-04-29 15:57:42 +02:00
|
|
|
void cReplayControl::Hide(void)
|
2000-04-23 15:38:16 +02:00
|
|
|
{
|
2000-04-29 15:57:42 +02:00
|
|
|
if (visible) {
|
2004-05-16 10:35:36 +02:00
|
|
|
delete displayReplay;
|
|
|
|
displayReplay = NULL;
|
2001-09-21 16:07:22 +02:00
|
|
|
needsFastResponse = visible = false;
|
2001-10-28 10:21:01 +01:00
|
|
|
modeOnly = false;
|
2004-05-16 10:35:36 +02:00
|
|
|
lastPlay = lastForward = false;
|
|
|
|
lastSpeed = -1;
|
2004-10-16 16:12:02 +02:00
|
|
|
timeSearchActive = false;
|
2000-04-29 15:57:42 +02:00
|
|
|
}
|
2000-04-23 15:38:16 +02:00
|
|
|
}
|
|
|
|
|
2001-09-14 15:10:12 +02:00
|
|
|
void cReplayControl::ShowMode(void)
|
|
|
|
{
|
2004-10-16 10:26:34 +02:00
|
|
|
if (visible || Setup.ShowReplayMode && !cOsd::IsOpen()) {
|
2001-09-14 14:06:43 +02:00
|
|
|
bool Play, Forward;
|
|
|
|
int Speed;
|
2004-05-16 10:35:36 +02:00
|
|
|
if (GetReplayMode(Play, Forward, Speed) && (!visible || Play != lastPlay || Forward != lastForward || Speed != lastSpeed)) {
|
2001-09-21 16:24:06 +02:00
|
|
|
bool NormalPlay = (Play && Speed == -1);
|
2001-09-14 14:06:43 +02:00
|
|
|
|
|
|
|
if (!visible) {
|
2001-09-21 16:24:06 +02:00
|
|
|
if (NormalPlay)
|
|
|
|
return; // no need to do indicate ">" unless there was a different mode displayed before
|
2001-09-14 14:06:43 +02:00
|
|
|
visible = modeOnly = true;
|
2004-05-16 10:35:36 +02:00
|
|
|
displayReplay = Skins.Current()->DisplayReplay(modeOnly);
|
2001-09-14 14:06:43 +02:00
|
|
|
}
|
|
|
|
|
2001-09-21 16:24:06 +02:00
|
|
|
if (modeOnly && !timeoutShow && NormalPlay)
|
2001-09-21 16:01:45 +02:00
|
|
|
timeoutShow = time(NULL) + MODETIMEOUT;
|
2004-05-16 10:35:36 +02:00
|
|
|
displayReplay->SetMode(Play, Forward, Speed);
|
|
|
|
lastPlay = Play;
|
|
|
|
lastForward = Forward;
|
|
|
|
lastSpeed = Speed;
|
2001-09-14 14:06:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-09 11:13:00 +01:00
|
|
|
bool cReplayControl::ShowProgress(bool Initial)
|
|
|
|
{
|
|
|
|
int Current, Total;
|
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
if (GetIndex(Current, Total) && Total > 0) {
|
2001-08-07 16:39:18 +02:00
|
|
|
if (!visible) {
|
2004-05-16 10:35:36 +02:00
|
|
|
displayReplay = Skins.Current()->DisplayReplay(modeOnly);
|
|
|
|
displayReplay->SetMarks(&marks);
|
2001-08-07 16:39:18 +02:00
|
|
|
needsFastResponse = visible = true;
|
|
|
|
}
|
2000-12-09 11:13:00 +01:00
|
|
|
if (Initial) {
|
|
|
|
if (title)
|
2004-05-16 10:35:36 +02:00
|
|
|
displayReplay->SetTitle(title);
|
2001-07-28 16:32:40 +02:00
|
|
|
lastCurrent = lastTotal = -1;
|
2000-12-09 11:13:00 +01:00
|
|
|
}
|
2001-07-28 13:16:23 +02:00
|
|
|
if (Total != lastTotal) {
|
2004-05-16 10:35:36 +02:00
|
|
|
displayReplay->SetTotal(IndexToHMSF(Total));
|
2001-08-04 08:08:44 +02:00
|
|
|
if (!Initial)
|
2004-05-16 10:35:36 +02:00
|
|
|
displayReplay->Flush();
|
2001-07-28 13:16:23 +02:00
|
|
|
}
|
2001-08-04 08:08:44 +02:00
|
|
|
if (Current != lastCurrent || Total != lastTotal) {
|
2004-05-16 10:35:36 +02:00
|
|
|
displayReplay->SetProgress(Current, Total);
|
2001-08-04 08:08:44 +02:00
|
|
|
if (!Initial)
|
2004-05-16 10:35:36 +02:00
|
|
|
displayReplay->Flush();
|
|
|
|
displayReplay->SetCurrent(IndexToHMSF(Current, displayFrames));
|
|
|
|
displayReplay->Flush();
|
2001-07-28 13:16:23 +02:00
|
|
|
lastCurrent = Current;
|
|
|
|
}
|
2001-08-04 08:08:44 +02:00
|
|
|
lastTotal = Total;
|
2001-09-14 14:06:43 +02:00
|
|
|
ShowMode();
|
2000-12-09 11:13:00 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2001-08-11 14:30:21 +02:00
|
|
|
void cReplayControl::TimeSearchDisplay(void)
|
|
|
|
{
|
|
|
|
char buf[64];
|
|
|
|
strcpy(buf, tr("Jump: "));
|
2002-03-31 15:26:18 +02:00
|
|
|
int len = strlen(buf);
|
|
|
|
char h10 = '0' + (timeSearchTime >> 24);
|
|
|
|
char h1 = '0' + ((timeSearchTime & 0x00FF0000) >> 16);
|
|
|
|
char m10 = '0' + ((timeSearchTime & 0x0000FF00) >> 8);
|
|
|
|
char m1 = '0' + (timeSearchTime & 0x000000FF);
|
|
|
|
char ch10 = timeSearchPos > 3 ? h10 : '-';
|
|
|
|
char ch1 = timeSearchPos > 2 ? h1 : '-';
|
|
|
|
char cm10 = timeSearchPos > 1 ? m10 : '-';
|
|
|
|
char cm1 = timeSearchPos > 0 ? m1 : '-';
|
|
|
|
sprintf(buf + len, "%c%c:%c%c", ch10, ch1, cm10, cm1);
|
2004-05-16 10:35:36 +02:00
|
|
|
displayReplay->SetJump(buf);
|
2001-08-11 14:30:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cReplayControl::TimeSearchProcess(eKeys Key)
|
|
|
|
{
|
2002-03-31 15:26:18 +02:00
|
|
|
#define STAY_SECONDS_OFF_END 10
|
|
|
|
int Seconds = (timeSearchTime >> 24) * 36000 + ((timeSearchTime & 0x00FF0000) >> 16) * 3600 + ((timeSearchTime & 0x0000FF00) >> 8) * 600 + (timeSearchTime & 0x000000FF) * 60;
|
|
|
|
int Current = (lastCurrent / FRAMESPERSEC);
|
|
|
|
int Total = (lastTotal / FRAMESPERSEC);
|
2001-08-11 14:30:21 +02:00
|
|
|
switch (Key) {
|
|
|
|
case k0 ... k9:
|
2002-03-31 15:26:18 +02:00
|
|
|
if (timeSearchPos < 4) {
|
|
|
|
timeSearchTime <<= 8;
|
|
|
|
timeSearchTime |= Key - k0;
|
|
|
|
timeSearchPos++;
|
|
|
|
TimeSearchDisplay();
|
|
|
|
}
|
2001-08-11 14:30:21 +02:00
|
|
|
break;
|
2002-10-27 14:32:06 +01:00
|
|
|
case kFastRew:
|
2001-08-11 14:30:21 +02:00
|
|
|
case kLeft:
|
2002-10-27 14:32:06 +01:00
|
|
|
case kFastFwd:
|
2002-03-31 15:26:18 +02:00
|
|
|
case kRight: {
|
2002-10-27 14:32:06 +01:00
|
|
|
int dir = ((Key == kRight || Key == kFastFwd) ? 1 : -1);
|
2002-03-31 15:26:18 +02:00
|
|
|
if (dir > 0)
|
|
|
|
Seconds = min(Total - Current - STAY_SECONDS_OFF_END, Seconds);
|
2002-06-16 12:57:31 +02:00
|
|
|
SkipSeconds(Seconds * dir);
|
2001-08-11 14:30:21 +02:00
|
|
|
timeSearchActive = false;
|
2002-03-31 15:26:18 +02:00
|
|
|
}
|
2001-08-11 14:30:21 +02:00
|
|
|
break;
|
2002-10-27 14:32:06 +01:00
|
|
|
case kPlay:
|
2001-08-11 14:30:21 +02:00
|
|
|
case kUp:
|
2002-10-27 14:32:06 +01:00
|
|
|
case kPause:
|
2001-08-11 14:30:21 +02:00
|
|
|
case kDown:
|
2006-02-25 10:29:37 +01:00
|
|
|
case kOk:
|
2002-03-31 15:26:18 +02:00
|
|
|
Seconds = min(Total - STAY_SECONDS_OFF_END, Seconds);
|
2006-02-25 10:29:37 +01:00
|
|
|
Goto(Seconds * FRAMESPERSEC, Key == kDown || Key == kPause || Key == kOk);
|
2001-08-11 14:30:21 +02:00
|
|
|
timeSearchActive = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
timeSearchActive = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!timeSearchActive) {
|
|
|
|
if (timeSearchHide)
|
|
|
|
Hide();
|
|
|
|
else
|
2004-05-16 10:35:36 +02:00
|
|
|
displayReplay->SetJump(NULL);
|
2001-09-14 14:06:43 +02:00
|
|
|
ShowMode();
|
2001-08-11 14:30:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cReplayControl::TimeSearch(void)
|
|
|
|
{
|
2002-03-31 15:26:18 +02:00
|
|
|
timeSearchTime = timeSearchPos = 0;
|
2001-08-11 14:30:21 +02:00
|
|
|
timeSearchHide = false;
|
2001-09-15 10:36:31 +02:00
|
|
|
if (modeOnly)
|
|
|
|
Hide();
|
2001-08-11 14:30:21 +02:00
|
|
|
if (!visible) {
|
|
|
|
Show();
|
|
|
|
if (visible)
|
|
|
|
timeSearchHide = true;
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
2002-04-20 09:23:02 +02:00
|
|
|
timeoutShow = 0;
|
2001-08-11 14:30:21 +02:00
|
|
|
TimeSearchDisplay();
|
|
|
|
timeSearchActive = true;
|
|
|
|
}
|
|
|
|
|
2000-12-28 12:57:16 +01:00
|
|
|
void cReplayControl::MarkToggle(void)
|
|
|
|
{
|
|
|
|
int Current, Total;
|
2002-06-16 12:57:31 +02:00
|
|
|
if (GetIndex(Current, Total, true)) {
|
2000-12-28 12:57:16 +01:00
|
|
|
cMark *m = marks.Get(Current);
|
2001-08-11 15:08:14 +02:00
|
|
|
lastCurrent = -1; // triggers redisplay
|
2000-12-28 12:57:16 +01:00
|
|
|
if (m)
|
|
|
|
marks.Del(m);
|
2001-07-28 14:06:36 +02:00
|
|
|
else {
|
2000-12-28 12:57:16 +01:00
|
|
|
marks.Add(Current);
|
2003-05-24 16:41:35 +02:00
|
|
|
ShowTimed(2);
|
2003-09-06 10:35:24 +02:00
|
|
|
bool Play, Forward;
|
|
|
|
int Speed;
|
|
|
|
if (GetReplayMode(Play, Forward, Speed) && !Play)
|
|
|
|
Goto(Current, true);
|
2001-07-28 14:06:36 +02:00
|
|
|
}
|
2000-12-28 12:57:16 +01:00
|
|
|
marks.Save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cReplayControl::MarkJump(bool Forward)
|
|
|
|
{
|
2001-07-22 13:46:07 +02:00
|
|
|
if (marks.Count()) {
|
|
|
|
int Current, Total;
|
2002-06-16 12:57:31 +02:00
|
|
|
if (GetIndex(Current, Total)) {
|
2001-07-22 13:46:07 +02:00
|
|
|
cMark *m = Forward ? marks.GetNext(Current) : marks.GetPrev(Current);
|
2005-08-14 13:01:27 +02:00
|
|
|
if (m) {
|
2002-06-16 12:57:31 +02:00
|
|
|
Goto(m->position, true);
|
2005-08-14 13:01:27 +02:00
|
|
|
displayFrames = true;
|
|
|
|
}
|
2001-07-22 13:46:07 +02:00
|
|
|
}
|
2000-12-28 12:57:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cReplayControl::MarkMove(bool Forward)
|
|
|
|
{
|
|
|
|
int Current, Total;
|
2002-06-16 12:57:31 +02:00
|
|
|
if (GetIndex(Current, Total)) {
|
2000-12-28 12:57:16 +01:00
|
|
|
cMark *m = marks.Get(Current);
|
|
|
|
if (m) {
|
2001-07-22 13:46:07 +02:00
|
|
|
displayFrames = true;
|
2002-06-16 12:57:31 +02:00
|
|
|
int p = SkipFrames(Forward ? 1 : -1);
|
2000-12-28 12:57:16 +01:00
|
|
|
cMark *m2;
|
|
|
|
if (Forward) {
|
|
|
|
if ((m2 = marks.Next(m)) != NULL && m2->position <= p)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if ((m2 = marks.Prev(m)) != NULL && m2->position >= p)
|
|
|
|
return;
|
|
|
|
}
|
2002-06-16 12:57:31 +02:00
|
|
|
Goto(m->position = p, true);
|
2000-12-28 12:57:16 +01:00
|
|
|
marks.Save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cReplayControl::EditCut(void)
|
|
|
|
{
|
2001-10-27 12:04:36 +02:00
|
|
|
if (fileName) {
|
|
|
|
Hide();
|
2002-06-22 10:11:59 +02:00
|
|
|
if (!cCutter::Active()) {
|
2003-05-16 12:46:15 +02:00
|
|
|
if (!marks.Count())
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtError, tr("No editing marks defined!"));
|
2003-05-16 12:46:15 +02:00
|
|
|
else if (!cCutter::Start(fileName))
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtError, tr("Can't start editing process!"));
|
2001-10-27 12:04:36 +02:00
|
|
|
else
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtInfo, tr("Editing process started"));
|
2001-10-27 12:04:36 +02:00
|
|
|
}
|
2000-12-28 12:57:16 +01:00
|
|
|
else
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtError, tr("Editing process already active!"));
|
2001-10-28 10:21:01 +01:00
|
|
|
ShowMode();
|
2000-12-28 12:57:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cReplayControl::EditTest(void)
|
|
|
|
{
|
|
|
|
int Current, Total;
|
2002-06-16 12:57:31 +02:00
|
|
|
if (GetIndex(Current, Total)) {
|
2000-12-28 12:57:16 +01:00
|
|
|
cMark *m = marks.Get(Current);
|
|
|
|
if (!m)
|
|
|
|
m = marks.GetNext(Current);
|
|
|
|
if (m) {
|
|
|
|
if ((m->Index() & 0x01) != 0)
|
|
|
|
m = marks.Next(m);
|
|
|
|
if (m) {
|
2002-06-16 12:57:31 +02:00
|
|
|
Goto(m->position - SecondsToFrames(3));
|
|
|
|
Play();
|
2000-12-28 12:57:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-06 12:53:28 +01:00
|
|
|
cOsdObject *cReplayControl::GetInfo(void)
|
|
|
|
{
|
|
|
|
cRecording *Recording = Recordings.GetByName(cReplayControl::LastReplayed());
|
|
|
|
if (Recording)
|
2006-01-15 15:06:19 +01:00
|
|
|
return new cMenuRecording(Recording, false);
|
2006-01-06 12:53:28 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2000-04-29 15:57:42 +02:00
|
|
|
eOSState cReplayControl::ProcessKey(eKeys Key)
|
2000-04-23 15:38:16 +02:00
|
|
|
{
|
2002-06-16 12:57:31 +02:00
|
|
|
if (!Active())
|
2000-04-29 15:57:42 +02:00
|
|
|
return osEnd;
|
2001-07-28 14:06:36 +02:00
|
|
|
if (visible) {
|
|
|
|
if (timeoutShow && time(NULL) > timeoutShow) {
|
|
|
|
Hide();
|
2001-10-28 10:21:01 +01:00
|
|
|
ShowMode();
|
2001-07-28 14:06:36 +02:00
|
|
|
timeoutShow = 0;
|
|
|
|
}
|
2002-03-31 10:57:28 +02:00
|
|
|
else if (modeOnly)
|
|
|
|
ShowMode();
|
2002-04-16 16:11:40 +02:00
|
|
|
else
|
2001-07-28 14:06:36 +02:00
|
|
|
shown = ShowProgress(!shown) || shown;
|
|
|
|
}
|
2001-07-22 13:46:07 +02:00
|
|
|
bool DisplayedFrames = displayFrames;
|
|
|
|
displayFrames = false;
|
2001-08-11 14:30:21 +02:00
|
|
|
if (timeSearchActive && Key != kNone) {
|
|
|
|
TimeSearchProcess(Key);
|
|
|
|
return osContinue;
|
|
|
|
}
|
2001-09-14 14:06:43 +02:00
|
|
|
bool DoShowMode = true;
|
2000-04-23 15:38:16 +02:00
|
|
|
switch (Key) {
|
2000-12-28 12:57:16 +01:00
|
|
|
// Positioning:
|
2002-10-27 14:32:06 +01:00
|
|
|
case kPlay:
|
2002-06-16 12:57:31 +02:00
|
|
|
case kUp: Play(); break;
|
2002-10-27 14:32:06 +01:00
|
|
|
case kPause:
|
2002-06-16 12:57:31 +02:00
|
|
|
case kDown: Pause(); break;
|
2002-10-27 14:32:06 +01:00
|
|
|
case kFastRew|k_Release:
|
2000-10-08 11:39:11 +02:00
|
|
|
case kLeft|k_Release:
|
2001-09-09 12:52:41 +02:00
|
|
|
if (Setup.MultiSpeedMode) break;
|
2002-10-27 14:32:06 +01:00
|
|
|
case kFastRew:
|
2002-06-16 12:57:31 +02:00
|
|
|
case kLeft: Backward(); break;
|
2002-10-27 14:32:06 +01:00
|
|
|
case kFastFwd|k_Release:
|
2000-10-08 11:39:11 +02:00
|
|
|
case kRight|k_Release:
|
2001-09-09 12:52:41 +02:00
|
|
|
if (Setup.MultiSpeedMode) break;
|
2002-10-27 14:32:06 +01:00
|
|
|
case kFastFwd:
|
2002-06-16 12:57:31 +02:00
|
|
|
case kRight: Forward(); break;
|
2001-08-11 14:30:21 +02:00
|
|
|
case kRed: TimeSearch(); break;
|
2000-10-08 11:39:11 +02:00
|
|
|
case kGreen|k_Repeat:
|
2002-06-16 12:57:31 +02:00
|
|
|
case kGreen: SkipSeconds(-60); break;
|
2000-10-08 11:39:11 +02:00
|
|
|
case kYellow|k_Repeat:
|
2002-06-16 12:57:31 +02:00
|
|
|
case kYellow: SkipSeconds( 60); break;
|
2002-10-27 14:32:06 +01:00
|
|
|
case kStop:
|
2000-12-28 12:57:16 +01:00
|
|
|
case kBlue: Hide();
|
2002-06-16 12:57:31 +02:00
|
|
|
Stop();
|
2000-12-28 12:57:16 +01:00
|
|
|
return osEnd;
|
2001-07-22 13:46:07 +02:00
|
|
|
default: {
|
2001-09-14 14:06:43 +02:00
|
|
|
DoShowMode = false;
|
2001-07-22 13:46:07 +02:00
|
|
|
switch (Key) {
|
|
|
|
// Editing:
|
|
|
|
case kMarkToggle: MarkToggle(); break;
|
2006-04-15 13:46:55 +02:00
|
|
|
case kPrev|k_Repeat:
|
|
|
|
case kPrev:
|
2003-09-14 10:53:06 +02:00
|
|
|
case kMarkJumpBack|k_Repeat:
|
2001-07-22 13:46:07 +02:00
|
|
|
case kMarkJumpBack: MarkJump(false); break;
|
2006-04-15 13:46:55 +02:00
|
|
|
case kNext|k_Repeat:
|
|
|
|
case kNext:
|
2003-09-14 10:53:06 +02:00
|
|
|
case kMarkJumpForward|k_Repeat:
|
2001-07-22 13:46:07 +02:00
|
|
|
case kMarkJumpForward: MarkJump(true); break;
|
|
|
|
case kMarkMoveBack|k_Repeat:
|
|
|
|
case kMarkMoveBack: MarkMove(false); break;
|
|
|
|
case kMarkMoveForward|k_Repeat:
|
|
|
|
case kMarkMoveForward: MarkMove(true); break;
|
|
|
|
case kEditCut: EditCut(); break;
|
|
|
|
case kEditTest: EditTest(); break;
|
|
|
|
default: {
|
|
|
|
displayFrames = DisplayedFrames;
|
|
|
|
switch (Key) {
|
|
|
|
// Menu control:
|
2001-10-28 10:21:01 +01:00
|
|
|
case kOk: if (visible && !modeOnly) {
|
2001-09-21 16:18:51 +02:00
|
|
|
Hide();
|
2001-10-28 10:21:01 +01:00
|
|
|
DoShowMode = true;
|
|
|
|
}
|
2001-09-21 16:18:51 +02:00
|
|
|
else
|
|
|
|
Show();
|
|
|
|
break;
|
2002-02-24 14:07:21 +01:00
|
|
|
case kBack: return osRecordings;
|
2001-07-22 13:46:07 +02:00
|
|
|
default: return osUnknown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-04-23 15:38:16 +02:00
|
|
|
}
|
2001-09-14 14:06:43 +02:00
|
|
|
if (DoShowMode)
|
|
|
|
ShowMode();
|
2000-04-29 15:57:42 +02:00
|
|
|
return osContinue;
|
2000-04-23 15:38:16 +02:00
|
|
|
}
|