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.
|
|
|
|
*
|
2003-05-29 11:45:13 +02:00
|
|
|
* $Id: menu.c 1.252 2003/05/29 11:43:36 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"
|
2000-10-29 13:17:22 +01:00
|
|
|
#include "eit.h"
|
2000-11-11 10:39:27 +01:00
|
|
|
#include "i18n.h"
|
2002-05-09 16:26:56 +02:00
|
|
|
#include "menuitems.h"
|
|
|
|
#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"
|
2002-10-20 12:28:55 +02:00
|
|
|
#include "timers.h"
|
2002-01-27 13:11:23 +01:00
|
|
|
#include "videodir.h"
|
2000-02-19 13:36:48 +01:00
|
|
|
|
2001-09-14 14:06:43 +02:00
|
|
|
#define MENUTIMEOUT 120 // seconds
|
2003-04-27 12:51:01 +02:00
|
|
|
#define MAXWAIT4EPGINFO 3 // seconds
|
2001-09-14 14:06:43 +02:00
|
|
|
#define MODETIMEOUT 3 // seconds
|
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
|
|
|
|
|
2002-10-19 15:33:37 +02:00
|
|
|
#define CHNUMWIDTH (numdigits(Channels.MaxNumber()) + 1)
|
2002-03-29 10:50:20 +01:00
|
|
|
|
2000-02-19 13:36:48 +01:00
|
|
|
// --- cMenuEditChanItem -----------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuEditChanItem : public cMenuEditIntItem {
|
|
|
|
protected:
|
|
|
|
virtual void Set(void);
|
|
|
|
public:
|
|
|
|
cMenuEditChanItem(const char *Name, int *Value);
|
2002-10-19 15:33:37 +02:00
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
2000-02-19 13:36:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
cMenuEditChanItem::cMenuEditChanItem(const char *Name, int *Value)
|
2000-09-09 14:57:43 +02:00
|
|
|
:cMenuEditIntItem(Name, Value, 1, Channels.MaxNumber())
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
|
|
|
Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuEditChanItem::Set(void)
|
|
|
|
{
|
|
|
|
char buf[255];
|
2000-09-09 14:57:43 +02:00
|
|
|
cChannel *channel = Channels.GetByNumber(*value);
|
2002-10-19 15:33:37 +02:00
|
|
|
snprintf(buf, sizeof(buf), "%d %s", *value, channel ? channel->Name() : "");
|
2000-02-19 13:36:48 +01:00
|
|
|
SetValue(buf);
|
|
|
|
}
|
|
|
|
|
2002-10-19 15:33:37 +02:00
|
|
|
eOSState cMenuEditChanItem::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
int delta = 1;
|
|
|
|
|
|
|
|
switch (Key) {
|
|
|
|
case kLeft|k_Repeat:
|
|
|
|
case kLeft: delta = -1;
|
|
|
|
case kRight|k_Repeat:
|
|
|
|
case kRight:
|
|
|
|
{
|
|
|
|
cChannel *channel = Channels.GetByNumber(*value + delta, delta);
|
|
|
|
if (channel) {
|
|
|
|
*value = channel->Number();
|
|
|
|
Set();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default : return cMenuEditIntItem::ProcessKey(Key);
|
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
2002-03-10 12:45:58 +01:00
|
|
|
// --- cMenuEditTranItem -----------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuEditTranItem : public cMenuEditChanItem {
|
|
|
|
private:
|
|
|
|
int number;
|
|
|
|
int transponder;
|
|
|
|
public:
|
|
|
|
cMenuEditTranItem(const char *Name, int *Value);
|
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
|
|
|
};
|
|
|
|
|
|
|
|
cMenuEditTranItem::cMenuEditTranItem(const char *Name, int *Value)
|
|
|
|
:cMenuEditChanItem(Name, Value)
|
|
|
|
{
|
|
|
|
number = 0;
|
|
|
|
transponder = *Value;
|
|
|
|
cChannel *channel = Channels.First();
|
|
|
|
while (channel) {
|
2002-10-06 10:25:42 +02:00
|
|
|
if (!channel->GroupSep() && ISTRANSPONDER(channel->Frequency(), *Value)) {
|
|
|
|
number = channel->Number();
|
2002-03-10 12:45:58 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
channel = (cChannel *)channel->Next();
|
|
|
|
}
|
|
|
|
*Value = number;
|
|
|
|
Set();
|
|
|
|
*Value = transponder;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuEditTranItem::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
*value = number;
|
|
|
|
eOSState state = cMenuEditChanItem::ProcessKey(Key);
|
|
|
|
number = *value;
|
|
|
|
cChannel *channel = Channels.GetByNumber(*value);
|
|
|
|
if (channel)
|
2002-10-06 10:25:42 +02:00
|
|
|
transponder = channel->Frequency();
|
2002-03-10 12:45:58 +01:00
|
|
|
*value = transponder;
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2000-02-19 13:36:48 +01:00
|
|
|
// --- cMenuEditDayItem ------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuEditDayItem : public cMenuEditIntItem {
|
|
|
|
protected:
|
|
|
|
static int days[];
|
|
|
|
int d;
|
|
|
|
virtual void Set(void);
|
|
|
|
public:
|
|
|
|
cMenuEditDayItem(const char *Name, int *Value);
|
2000-03-11 11:22:37 +01:00
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
2000-02-19 13:36:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
int cMenuEditDayItem::days[] ={ cTimer::ParseDay("M------"),
|
|
|
|
cTimer::ParseDay("-T-----"),
|
|
|
|
cTimer::ParseDay("--W----"),
|
|
|
|
cTimer::ParseDay("---T---"),
|
|
|
|
cTimer::ParseDay("----F--"),
|
|
|
|
cTimer::ParseDay("-----S-"),
|
|
|
|
cTimer::ParseDay("------S"),
|
|
|
|
cTimer::ParseDay("MTWTF--"),
|
|
|
|
cTimer::ParseDay("MTWTFS-"),
|
|
|
|
cTimer::ParseDay("MTWTFSS"),
|
|
|
|
cTimer::ParseDay("-----SS"),
|
|
|
|
0 };
|
|
|
|
|
|
|
|
cMenuEditDayItem::cMenuEditDayItem(const char *Name, int *Value)
|
|
|
|
:cMenuEditIntItem(Name, Value, -INT_MAX, 31)
|
|
|
|
{
|
|
|
|
d = -1;
|
|
|
|
if (*value < 0) {
|
|
|
|
int n = 0;
|
|
|
|
while (days[n]) {
|
|
|
|
if (days[n] == *value) {
|
|
|
|
d = n;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuEditDayItem::Set(void)
|
|
|
|
{
|
|
|
|
SetValue(cTimer::PrintDay(*value));
|
|
|
|
}
|
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState cMenuEditDayItem::ProcessKey(eKeys Key)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
|
|
|
switch (Key) {
|
2000-10-08 11:39:11 +02:00
|
|
|
case kLeft|k_Repeat:
|
2000-02-19 13:36:48 +01:00
|
|
|
case kLeft: if (d > 0)
|
|
|
|
*value = days[--d];
|
|
|
|
else if (d == 0) {
|
|
|
|
*value = 31;
|
|
|
|
d = -1;
|
|
|
|
}
|
|
|
|
else if (*value == 1) {
|
|
|
|
d = sizeof(days) / sizeof(int) - 2;
|
|
|
|
*value = days[d];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return cMenuEditIntItem::ProcessKey(Key);
|
|
|
|
Set();
|
|
|
|
break;
|
2000-10-08 11:39:11 +02:00
|
|
|
case kRight|k_Repeat:
|
2000-02-19 13:36:48 +01:00
|
|
|
case kRight: if (d >= 0) {
|
|
|
|
*value = days[++d];
|
|
|
|
if (*value == 0) {
|
|
|
|
*value = 1;
|
|
|
|
d = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (*value == 31) {
|
|
|
|
d = 0;
|
|
|
|
*value = days[d];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return cMenuEditIntItem::ProcessKey(Key);
|
|
|
|
Set();
|
|
|
|
break;
|
|
|
|
default : return cMenuEditIntItem::ProcessKey(Key);
|
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
2002-02-17 13:05:05 +01:00
|
|
|
// --- cMenuEditDateItem -----------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuEditDateItem : public cMenuEditItem {
|
|
|
|
protected:
|
|
|
|
time_t *value;
|
|
|
|
virtual void Set(void);
|
|
|
|
public:
|
|
|
|
cMenuEditDateItem(const char *Name, time_t *Value);
|
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
|
|
|
};
|
|
|
|
|
|
|
|
cMenuEditDateItem::cMenuEditDateItem(const char *Name, time_t *Value)
|
|
|
|
:cMenuEditItem(Name)
|
|
|
|
{
|
|
|
|
value = Value;
|
|
|
|
Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuEditDateItem::Set(void)
|
|
|
|
{
|
|
|
|
#define DATEBUFFERSIZE 32
|
|
|
|
char buf[DATEBUFFERSIZE];
|
|
|
|
if (*value) {
|
|
|
|
struct tm tm_r;
|
|
|
|
localtime_r(value, &tm_r);
|
|
|
|
strftime(buf, DATEBUFFERSIZE, "%Y-%m-%d ", &tm_r);
|
|
|
|
strcat(buf, WeekDayName(tm_r.tm_wday));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*buf = 0;
|
|
|
|
SetValue(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuEditDateItem::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?
|
|
|
|
*value -= SECSINDAY;
|
|
|
|
if (*value < time(NULL))
|
|
|
|
*value = 0;
|
|
|
|
}
|
|
|
|
else if (NORMALKEY(Key) == kRight) {
|
|
|
|
if (!*value)
|
|
|
|
*value = cTimer::SetTime(time(NULL), 0);
|
|
|
|
*value += SECSINDAY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return state;
|
|
|
|
Set();
|
|
|
|
state = osContinue;
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2000-02-19 13:36:48 +01:00
|
|
|
// --- cMenuEditTimeItem -----------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuEditTimeItem : public cMenuEditItem {
|
|
|
|
protected:
|
|
|
|
int *value;
|
|
|
|
int hh, mm;
|
|
|
|
int pos;
|
|
|
|
virtual void Set(void);
|
|
|
|
public:
|
|
|
|
cMenuEditTimeItem(const char *Name, int *Value);
|
2000-03-11 11:22:37 +01:00
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
2000-02-19 13:36:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
cMenuEditTimeItem::cMenuEditTimeItem(const char *Name, int *Value)
|
|
|
|
:cMenuEditItem(Name)
|
|
|
|
{
|
|
|
|
value = Value;
|
|
|
|
hh = *value / 100;
|
|
|
|
mm = *value % 100;
|
|
|
|
pos = 0;
|
|
|
|
Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuEditTimeItem::Set(void)
|
|
|
|
{
|
|
|
|
char buf[10];
|
2001-07-28 13:48:52 +02:00
|
|
|
switch (pos) {
|
|
|
|
case 1: snprintf(buf, sizeof(buf), "%01d-:--", hh / 10); break;
|
|
|
|
case 2: snprintf(buf, sizeof(buf), "%02d:--", hh); break;
|
|
|
|
case 3: snprintf(buf, sizeof(buf), "%02d:%01d-", hh, mm / 10); break;
|
|
|
|
default: snprintf(buf, sizeof(buf), "%02d:%02d", hh, mm);
|
|
|
|
}
|
2000-02-19 13:36:48 +01:00
|
|
|
SetValue(buf);
|
|
|
|
}
|
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState cMenuEditTimeItem::ProcessKey(eKeys Key)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState state = cMenuEditItem::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 (k0 <= Key && Key <= k9) {
|
|
|
|
if (fresh || pos > 3) {
|
|
|
|
pos = 0;
|
|
|
|
fresh = false;
|
|
|
|
}
|
|
|
|
int n = Key - k0;
|
|
|
|
switch (pos) {
|
|
|
|
case 0: if (n <= 2) {
|
|
|
|
hh = n * 10;
|
|
|
|
mm = 0;
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1: if (hh + n <= 23) {
|
|
|
|
hh += n;
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2: if (n <= 5) {
|
|
|
|
mm += n * 10;
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3: if (mm + n <= 59) {
|
|
|
|
mm += n;
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-10-08 11:39:11 +02:00
|
|
|
else if (NORMALKEY(Key) == kLeft) { // TODO might want to increase the delta if repeated quickly?
|
2000-02-19 13:36:48 +01:00
|
|
|
if (--mm < 0) {
|
|
|
|
mm = 59;
|
|
|
|
if (--hh < 0)
|
|
|
|
hh = 23;
|
|
|
|
}
|
|
|
|
fresh = true;
|
|
|
|
}
|
2000-10-08 11:39:11 +02:00
|
|
|
else if (NORMALKEY(Key) == kRight) {
|
2000-02-19 13:36:48 +01:00
|
|
|
if (++mm > 59) {
|
|
|
|
mm = 0;
|
|
|
|
if (++hh > 23)
|
|
|
|
hh = 0;
|
|
|
|
}
|
|
|
|
fresh = true;
|
|
|
|
}
|
|
|
|
else
|
2000-03-11 11:22:37 +01:00
|
|
|
return state;
|
2000-02-19 13:36:48 +01:00
|
|
|
*value = hh * 100 + mm;
|
|
|
|
Set();
|
2000-03-11 11:22:37 +01:00
|
|
|
state = osContinue;
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
2000-03-11 11:22:37 +01:00
|
|
|
return state;
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
|
2002-03-03 16:12:29 +01:00
|
|
|
// --- cMenuEditCaItem -------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuEditCaItem : public cMenuEditIntItem {
|
|
|
|
private:
|
|
|
|
const cCaDefinition *ca;
|
|
|
|
bool allowCardNr;
|
|
|
|
protected:
|
|
|
|
virtual void Set(void);
|
|
|
|
public:
|
|
|
|
cMenuEditCaItem(const char *Name, int *Value, bool AllowCardNr = false);
|
|
|
|
eOSState ProcessKey(eKeys Key);
|
|
|
|
};
|
|
|
|
|
|
|
|
cMenuEditCaItem::cMenuEditCaItem(const char *Name, int *Value, bool AllowCardNr)
|
|
|
|
:cMenuEditIntItem(Name, Value, 0)
|
|
|
|
{
|
|
|
|
ca = CaDefinitions.Get(*Value);
|
|
|
|
allowCardNr = AllowCardNr;
|
|
|
|
Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuEditCaItem::Set(void)
|
|
|
|
{
|
|
|
|
if (ca)
|
|
|
|
SetValue(ca->Description());
|
|
|
|
else
|
|
|
|
cMenuEditIntItem::Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuEditCaItem::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 (ca && ca->Prev()) {
|
|
|
|
ca = (cCaDefinition *)ca->Prev();
|
|
|
|
*value = ca->Number();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (NORMALKEY(Key) == kRight) {
|
2002-06-16 12:57:31 +02:00
|
|
|
if (ca && ca->Next() && (allowCardNr || ((cCaDefinition *)ca->Next())->Number() > MAXDEVICES)) {
|
2002-03-03 16:12:29 +01:00
|
|
|
ca = (cCaDefinition *)ca->Next();
|
|
|
|
*value = ca->Number();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
asprintf(&buffer, "%s - %s", cSource::ToString(source->Code()), source->Description());
|
|
|
|
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) {
|
|
|
|
if (source) {
|
|
|
|
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;
|
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)
|
2002-04-06 09:51:08 +02:00
|
|
|
:cOsdMenu(tr("Edit channel"), 14)
|
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;
|
2002-11-10 15:50:21 +01:00
|
|
|
if (New)
|
|
|
|
channel = NULL;
|
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();
|
|
|
|
char type = *cSource::ToString(data.source);
|
|
|
|
#define ST(s) if (strchr(s, type))
|
|
|
|
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
// Parameters for all types of sources:
|
|
|
|
Add(new cMenuEditStrItem( tr("Name"), data.name, sizeof(data.name), tr(FileNameChars)));
|
|
|
|
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));
|
2002-10-06 10:25:42 +02:00
|
|
|
Add(new cMenuEditIntItem( tr("Apid1"), &data.apid1, 0, 0x1FFF));
|
|
|
|
Add(new cMenuEditIntItem( tr("Apid2"), &data.apid2, 0, 0x1FFF));
|
|
|
|
Add(new cMenuEditIntItem( tr("Dpid1"), &data.dpid1, 0, 0x1FFF));
|
|
|
|
Add(new cMenuEditIntItem( tr("Dpid2"), &data.dpid2, 0, 0x1FFF));
|
|
|
|
Add(new cMenuEditIntItem( tr("Tpid"), &data.tpid, 0, 0x1FFF));
|
|
|
|
Add(new cMenuEditCaItem( tr("CA"), &data.ca, true));
|
|
|
|
Add(new cMenuEditIntItem( tr("Sid"), &data.sid, 0));
|
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:
|
|
|
|
ST(" S ") Add(new cMenuEditChrItem( tr("Polarization"), &data.polarization, "hv"));
|
|
|
|
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)) {
|
|
|
|
if (channel) {
|
|
|
|
*channel = data;
|
|
|
|
isyslog("edited channel %d %s", channel->Number(), data.ToText());
|
|
|
|
state = osBack;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
channel = new cChannel;
|
|
|
|
*channel = data;
|
|
|
|
Channels.Add(channel);
|
|
|
|
Channels.ReNumber();
|
|
|
|
isyslog("added channel %d %s", channel->Number(), data.ToText());
|
|
|
|
state = osUser1;
|
|
|
|
}
|
|
|
|
Channels.Save();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Interface->Error(tr("Channel settings are not unique!"));
|
|
|
|
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 {
|
|
|
|
private:
|
|
|
|
cChannel *channel;
|
|
|
|
public:
|
2002-10-20 12:28:55 +02:00
|
|
|
cMenuChannelItem(cChannel *Channel);
|
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
|
|
|
};
|
|
|
|
|
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())
|
2001-07-31 15:32:02 +02:00
|
|
|
SetColor(clrCyan, clrBackground);
|
2000-02-19 13:36:48 +01:00
|
|
|
Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuChannelItem::Set(void)
|
|
|
|
{
|
|
|
|
char *buffer = NULL;
|
2002-10-06 10:25:42 +02:00
|
|
|
if (!channel->GroupSep())
|
|
|
|
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 ---------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuChannels : public cOsdMenu {
|
2002-10-20 12:28:55 +02:00
|
|
|
private:
|
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:
|
|
|
|
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);
|
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
|
|
|
{
|
2002-11-29 14:19:08 +01:00
|
|
|
for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
|
|
|
|
if (!channel->GroupSep() || *channel->Name())
|
|
|
|
Add(new cMenuChannelItem(channel), channel->Number() == cDevice::CurrentChannel());
|
|
|
|
}
|
2000-11-11 10:39:27 +01:00
|
|
|
SetHelp(tr("Edit"), tr("New"), tr("Delete"), tr("Mark"));
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
Channels.Save();
|
|
|
|
for (cMenuChannelItem *ci = (cMenuChannelItem *)First(); ci; ci = (cMenuChannelItem *)ci->Next())
|
|
|
|
ci->Set();
|
|
|
|
Timers.Save(); // channel numbering has changed!
|
|
|
|
Display();
|
|
|
|
}
|
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState cMenuChannels::Switch(void)
|
|
|
|
{
|
2002-12-22 12:49:10 +01:00
|
|
|
cChannel *ch = GetChannel(Current());
|
2000-03-11 11:22:37 +01:00
|
|
|
if (ch)
|
2002-09-04 17:26:02 +02:00
|
|
|
cDevice::PrimaryDevice()->SwitchChannel(ch, true);
|
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;
|
2002-11-10 15:50:21 +01:00
|
|
|
return AddSubMenu(new cMenuEditChannel(Channels.Get(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
|
|
|
{
|
2000-03-11 11:22:37 +01:00
|
|
|
if (Count() > 0) {
|
|
|
|
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:
|
2002-10-20 12:28:55 +02:00
|
|
|
for (cTimer *ti = Timers.First(); ti; ti = Timers.Next(ti)) {
|
|
|
|
if (ti->Channel() == channel) {
|
2000-11-11 10:39:27 +01:00
|
|
|
Interface->Error(tr("Channel is being used by a timer!"));
|
2000-03-11 11:22:37 +01:00
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
}
|
2000-12-28 12:57:16 +01:00
|
|
|
if (Interface->Confirm(tr("Delete channel?"))) {
|
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);
|
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)
|
|
|
|
{
|
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);
|
|
|
|
}
|
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) {
|
|
|
|
case kOk: return Switch();
|
|
|
|
case kRed: return Edit();
|
|
|
|
case kGreen: return New();
|
2002-11-10 16:07:58 +01:00
|
|
|
case kYellow: return Delete();
|
2002-11-10 15:50:21 +01:00
|
|
|
case kBlue: Mark(); break;
|
|
|
|
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-11 16:38:41 +01:00
|
|
|
class cMenuText : public cOsdMenu {
|
2000-07-24 16:43:04 +02:00
|
|
|
public:
|
2000-11-18 15:46:00 +01:00
|
|
|
cMenuText(const char *Title, const char *Text, eDvbFont Font = fontOsd);
|
2000-07-24 16:43:04 +02:00
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
|
|
|
};
|
|
|
|
|
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
|
|
|
{
|
2001-07-27 11:51:42 +02:00
|
|
|
Add(new cMenuTextItem(Text, 1, 2, Setup.OSDwidth - 2, MAXOSDITEMS, clrWhite, clrBackground, Font));
|
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
|
|
|
{
|
|
|
|
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 --------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuEditTimer : public cOsdMenu {
|
|
|
|
private:
|
|
|
|
cTimer *timer;
|
|
|
|
cTimer data;
|
2002-10-20 12:28:55 +02:00
|
|
|
int channel;
|
2003-05-25 13:58:21 +02:00
|
|
|
bool deleteIfCancelled;
|
2002-02-17 13:05:05 +01:00
|
|
|
cMenuEditDateItem *firstday;
|
|
|
|
void SetFirstDayItem(void);
|
2000-02-19 13:36:48 +01:00
|
|
|
public:
|
2000-04-15 17:38:11 +02:00
|
|
|
cMenuEditTimer(int Index, bool New = false);
|
2003-02-09 13:14:44 +01:00
|
|
|
virtual ~cMenuEditTimer();
|
2000-03-11 11:22:37 +01:00
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
2000-02-19 13:36:48 +01:00
|
|
|
};
|
|
|
|
|
2000-04-15 17:38:11 +02:00
|
|
|
cMenuEditTimer::cMenuEditTimer(int Index, 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;
|
2000-02-19 13:36:48 +01:00
|
|
|
timer = Timers.Get(Index);
|
2003-05-25 13:58:21 +02:00
|
|
|
deleteIfCancelled = New;
|
2000-02-19 13:36:48 +01:00
|
|
|
if (timer) {
|
|
|
|
data = *timer;
|
2000-04-15 17:38:11 +02:00
|
|
|
if (New)
|
|
|
|
data.active = 1;
|
2002-10-20 12:28:55 +02:00
|
|
|
channel = data.Channel()->Number();
|
2000-11-11 10:39:27 +01:00
|
|
|
Add(new cMenuEditBoolItem(tr("Active"), &data.active));
|
2002-10-20 12:28:55 +02:00
|
|
|
Add(new cMenuEditChanItem(tr("Channel"), &channel));
|
2001-06-02 10:47:40 +02:00
|
|
|
Add(new cMenuEditDayItem( tr("Day"), &data.day));
|
|
|
|
Add(new cMenuEditTimeItem(tr("Start"), &data.start));
|
|
|
|
Add(new cMenuEditTimeItem(tr("Stop"), &data.stop));
|
|
|
|
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-05-25 13:58:21 +02:00
|
|
|
if (timer && deleteIfCancelled) {
|
|
|
|
int Index = timer->Index();
|
|
|
|
Timers.Del(timer);
|
|
|
|
Timers.Save();
|
|
|
|
isyslog("timer %d deleted", Index + 1);
|
|
|
|
}
|
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()) {
|
|
|
|
Add(firstday = new cMenuEditDateItem(tr("First day"), &data.firstday));
|
|
|
|
Display();
|
|
|
|
}
|
|
|
|
else if (firstday && data.IsSingleEvent()) {
|
|
|
|
Del(firstday->Index());
|
|
|
|
firstday = NULL;
|
|
|
|
data.firstday = 0;
|
|
|
|
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) {
|
2002-10-20 12:28:55 +02:00
|
|
|
case kOk: {
|
|
|
|
cChannel *ch = Channels.GetByNumber(channel);
|
|
|
|
if (ch)
|
|
|
|
data.channel = ch;
|
|
|
|
else {
|
|
|
|
Interface->Error(tr("*** Invalid Channel ***"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!*data.file)
|
|
|
|
strcpy(data.file, data.Channel()->Name());
|
|
|
|
if (timer && memcmp(timer, &data, sizeof(data)) != 0) {
|
|
|
|
*timer = data;
|
|
|
|
if (timer->active)
|
|
|
|
timer->active = 1; // allows external programs to mark active timers with values > 1 and recognize if the user has modified them
|
|
|
|
Timers.Save();
|
|
|
|
isyslog("timer %d modified (%s)", timer->Index() + 1, timer->active ? "active" : "inactive");
|
|
|
|
}
|
2003-05-25 13:58:21 +02:00
|
|
|
deleteIfCancelled = 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);
|
|
|
|
virtual bool operator< (const cListObject &ListObject);
|
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();
|
|
|
|
}
|
|
|
|
|
2001-08-26 14:17:20 +02:00
|
|
|
bool cMenuTimerItem::operator< (const cListObject &ListObject)
|
|
|
|
{
|
|
|
|
return *timer < *((cMenuTimerItem *)&ListObject)->timer;
|
|
|
|
}
|
|
|
|
|
2000-02-19 13:36:48 +01:00
|
|
|
void cMenuTimerItem::Set(void)
|
|
|
|
{
|
|
|
|
char *buffer = NULL;
|
2000-03-11 11:22:37 +01:00
|
|
|
asprintf(&buffer, "%c\t%d\t%s\t%02d:%02d\t%02d:%02d\t%s",
|
2002-10-20 12:28:55 +02:00
|
|
|
!timer->Active() ? ' ' : timer->FirstDay() ? '!' : timer->Recording() ? '#' : '>',
|
|
|
|
timer->Channel()->Number(),
|
|
|
|
timer->PrintDay(timer->Day()),
|
|
|
|
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:
|
|
|
|
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);
|
2000-03-11 11:22:37 +01:00
|
|
|
virtual void Move(int From, int To);
|
2000-07-24 16:43:04 +02:00
|
|
|
eOSState Summary(void);
|
2001-08-26 14:17:20 +02:00
|
|
|
cTimer *CurrentTimer(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
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
cTimer *timer;
|
|
|
|
|
|
|
|
while ((timer = Timers.Get(i)) != NULL) {
|
2001-08-26 14:17:20 +02:00
|
|
|
Add(new cMenuTimerItem(timer));
|
2000-02-19 13:36:48 +01:00
|
|
|
i++;
|
|
|
|
}
|
2001-08-26 14:17:20 +02:00
|
|
|
if (Setup.SortTimers)
|
|
|
|
Sort();
|
2002-02-17 13:05:05 +01:00
|
|
|
SetHelp(tr("Edit"), tr("New"), tr("Delete"), Setup.SortTimers ? tr("On/Off") : tr("Mark"));
|
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
|
|
|
}
|
|
|
|
|
2002-02-17 13:05:05 +01:00
|
|
|
eOSState cMenuTimers::OnOff(void)
|
2000-03-11 11:22:37 +01:00
|
|
|
{
|
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();
|
2000-03-11 11:22:37 +01:00
|
|
|
RefreshCurrent();
|
|
|
|
DisplayCurrent(true);
|
2002-10-20 12:28:55 +02:00
|
|
|
if (timer->FirstDay())
|
2002-05-13 16:35:49 +02:00
|
|
|
isyslog("timer %d first day set to %s", timer->Index() + 1, timer->PrintFirstDay());
|
2002-02-17 13:05:05 +01:00
|
|
|
else
|
2002-10-20 12:28:55 +02:00
|
|
|
isyslog("timer %d %sactivated", timer->Index() + 1, timer->Active() ? "" : "de");
|
2000-03-11 11:22:37 +01:00
|
|
|
Timers.Save();
|
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuTimers::Edit(void)
|
|
|
|
{
|
|
|
|
if (HasSubMenu() || Count() == 0)
|
|
|
|
return osContinue;
|
2002-05-13 16:35:49 +02:00
|
|
|
isyslog("editing timer %d", CurrentTimer()->Index() + 1);
|
2001-08-26 14:17:20 +02:00
|
|
|
return AddSubMenu(new cMenuEditTimer(CurrentTimer()->Index()));
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuTimers::New(void)
|
|
|
|
{
|
|
|
|
if (HasSubMenu())
|
|
|
|
return osContinue;
|
|
|
|
cTimer *timer = new cTimer;
|
|
|
|
Timers.Add(timer);
|
2001-08-26 14:17:20 +02:00
|
|
|
Add(new cMenuTimerItem(timer), true);
|
2000-03-11 11:22:37 +01:00
|
|
|
Timers.Save();
|
2002-05-13 16:35:49 +02:00
|
|
|
isyslog("timer %d added", timer->Index() + 1);
|
2001-08-26 14:17:20 +02:00
|
|
|
return AddSubMenu(new cMenuEditTimer(timer->Index(), 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
|
|
|
}
|
2003-05-25 14:14:32 +02:00
|
|
|
int Index = ti->Index();
|
|
|
|
Timers.Del(ti);
|
|
|
|
cOsdMenu::Del(Current());
|
|
|
|
Timers.Save();
|
|
|
|
Display();
|
|
|
|
isyslog("timer %d deleted", Index + 1);
|
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 cMenuTimers::Move(int From, int To)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2000-03-11 11:22:37 +01:00
|
|
|
Timers.Move(From, To);
|
|
|
|
cOsdMenu::Move(From, To);
|
|
|
|
Timers.Save();
|
|
|
|
Display();
|
2002-05-13 16:35:49 +02:00
|
|
|
isyslog("timer %d moved to %d", From + 1, To + 1);
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
2000-02-19 13:36:48 +01:00
|
|
|
|
2000-07-24 16:43:04 +02:00
|
|
|
eOSState cMenuTimers::Summary(void)
|
|
|
|
{
|
|
|
|
if (HasSubMenu() || Count() == 0)
|
|
|
|
return osContinue;
|
2001-08-26 14:17:20 +02:00
|
|
|
cTimer *ti = CurrentTimer();
|
2002-10-20 12:28:55 +02:00
|
|
|
if (ti && !isempty(ti->Summary()))
|
|
|
|
return AddSubMenu(new cMenuText(tr("Summary"), ti->Summary()));
|
2000-07-24 16:43:04 +02:00
|
|
|
return Edit(); // convenience for people not using the Summary feature ;-)
|
|
|
|
}
|
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
eOSState cMenuTimers::ProcessKey(eKeys Key)
|
|
|
|
{
|
2003-05-25 13:58:21 +02:00
|
|
|
cTimer *ti = HasSubMenu() ? CurrentTimer() : NULL;
|
|
|
|
int TimerNumber = ti ? ti->Index() : -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) {
|
2000-07-24 16:43:04 +02:00
|
|
|
case kOk: return Summary();
|
2000-03-11 11:22:37 +01:00
|
|
|
case kRed: return Edit();
|
|
|
|
case kGreen: return New();
|
2002-11-10 16:07:58 +01:00
|
|
|
case kYellow: return Delete();
|
2002-02-17 13:05:05 +01:00
|
|
|
case kBlue: if (Setup.SortTimers)
|
|
|
|
OnOff();
|
|
|
|
else
|
2001-08-26 14:17:20 +02:00
|
|
|
Mark();
|
|
|
|
break;
|
2000-02-19 13:36:48 +01:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
2003-05-25 13:58:21 +02:00
|
|
|
if (TimerNumber >= 0 && !HasSubMenu() && !Timers.Get(TimerNumber)) {
|
|
|
|
// a newly created timer wasn't confirmed with Ok
|
|
|
|
cOsdMenu::Del(Current());
|
|
|
|
Display();
|
|
|
|
}
|
2000-03-11 11:22:37 +01:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2000-10-29 13:17:22 +01:00
|
|
|
// --- cMenuEvent ------------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuEvent : public cOsdMenu {
|
|
|
|
private:
|
|
|
|
const cEventInfo *eventInfo;
|
|
|
|
public:
|
|
|
|
cMenuEvent(const cEventInfo *EventInfo, bool CanSwitch = false);
|
2000-11-01 15:41:33 +01:00
|
|
|
cMenuEvent(bool Now);
|
2000-11-01 11:45:05 +01:00
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
2000-10-29 13:17:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
cMenuEvent::cMenuEvent(const cEventInfo *EventInfo, bool CanSwitch)
|
2000-11-11 10:39:27 +01:00
|
|
|
:cOsdMenu(tr("Event"))
|
2000-10-29 13:17:22 +01:00
|
|
|
{
|
|
|
|
eventInfo = EventInfo;
|
2000-11-01 11:45:05 +01:00
|
|
|
if (eventInfo) {
|
2002-11-24 14:48:38 +01:00
|
|
|
cChannel *channel = Channels.GetByChannelID(eventInfo->GetChannelID(), true);
|
2000-11-01 11:45:05 +01:00
|
|
|
if (channel) {
|
|
|
|
char *buffer;
|
2002-10-06 10:25:42 +02:00
|
|
|
asprintf(&buffer, "%-17.*s\t%.*s %s - %s", 17, channel->Name(), 5, eventInfo->GetDate(), eventInfo->GetTimeString(), eventInfo->GetEndTimeString());
|
2000-11-01 11:45:05 +01:00
|
|
|
SetTitle(buffer, false);
|
2002-08-11 13:32:23 +02:00
|
|
|
free(buffer);
|
2000-11-01 11:45:05 +01:00
|
|
|
int Line = 2;
|
|
|
|
cMenuTextItem *item;
|
2000-11-18 14:13:26 +01:00
|
|
|
const char *Title = eventInfo->GetTitle();
|
|
|
|
const char *Subtitle = eventInfo->GetSubtitle();
|
|
|
|
const char *ExtendedDescription = eventInfo->GetExtendedDescription();
|
|
|
|
if (!isempty(Title)) {
|
2001-07-27 11:51:42 +02:00
|
|
|
Add(item = new cMenuTextItem(Title, 1, Line, Setup.OSDwidth - 2, -1, clrCyan));
|
2000-11-01 11:45:05 +01:00
|
|
|
Line += item->Height() + 1;
|
|
|
|
}
|
2000-11-18 14:13:26 +01:00
|
|
|
if (!isempty(Subtitle)) {
|
2001-07-27 11:51:42 +02:00
|
|
|
Add(item = new cMenuTextItem(Subtitle, 1, Line, Setup.OSDwidth - 2, -1, clrYellow));
|
2000-11-01 11:45:05 +01:00
|
|
|
Line += item->Height() + 1;
|
|
|
|
}
|
2000-11-18 14:13:26 +01:00
|
|
|
if (!isempty(ExtendedDescription))
|
2001-07-27 11:51:42 +02:00
|
|
|
Add(new cMenuTextItem(ExtendedDescription, 1, Line, Setup.OSDwidth - 2, Height() - Line - 2, clrCyan), true);
|
2000-11-11 10:39:27 +01:00
|
|
|
SetHelp(tr("Record"), NULL, NULL, CanSwitch ? tr("Switch") : NULL);
|
2000-11-01 11:45:05 +01:00
|
|
|
}
|
2000-10-29 13:17:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-01 11:45:05 +01:00
|
|
|
eOSState cMenuEvent::ProcessKey(eKeys Key)
|
2000-10-29 13:17:22 +01:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuWhatsOnItem ------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuWhatsOnItem : public cOsdItem {
|
|
|
|
public:
|
|
|
|
const cEventInfo *eventInfo;
|
|
|
|
cMenuWhatsOnItem(const cEventInfo *EventInfo);
|
|
|
|
};
|
|
|
|
|
|
|
|
cMenuWhatsOnItem::cMenuWhatsOnItem(const cEventInfo *EventInfo)
|
|
|
|
{
|
|
|
|
eventInfo = EventInfo;
|
|
|
|
char *buffer = NULL;
|
|
|
|
cChannel *channel = Channels.GetByNumber(eventInfo->GetChannelNumber());
|
2002-10-06 10:25:42 +02:00
|
|
|
asprintf(&buffer, "%d\t%.*s\t%.*s\t%s", eventInfo->GetChannelNumber(), 6, channel ? channel->Name() : "???", 5, eventInfo->GetTimeString(), eventInfo->GetTitle());
|
2000-10-29 13:17:22 +01:00
|
|
|
SetText(buffer, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuWhatsOn ----------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuWhatsOn : public cOsdMenu {
|
|
|
|
private:
|
|
|
|
eOSState Record(void);
|
|
|
|
eOSState Switch(void);
|
2001-02-10 15:37:21 +01:00
|
|
|
static int currentChannel;
|
2000-11-12 16:48:50 +01:00
|
|
|
static const cEventInfo *scheduleEventInfo;
|
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; }
|
2000-11-12 16:48:50 +01:00
|
|
|
static const cEventInfo *ScheduleEventInfo(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;
|
2000-11-12 16:48:50 +01:00
|
|
|
const cEventInfo *cMenuWhatsOn::scheduleEventInfo = NULL;
|
|
|
|
|
2000-10-29 13:17:22 +01:00
|
|
|
static int CompareEventChannel(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
return (int)( (*(const cEventInfo **)p1)->GetChannelNumber() - (*(const cEventInfo **)p2)->GetChannelNumber());
|
|
|
|
}
|
|
|
|
|
2001-02-10 15:37:21 +01:00
|
|
|
cMenuWhatsOn::cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentChannelNr)
|
2002-03-29 10:50:20 +01:00
|
|
|
:cOsdMenu(Now ? tr("What's on now?") : tr("What's on next?"), CHNUMWIDTH, 7, 6)
|
2000-10-29 13:17:22 +01:00
|
|
|
{
|
|
|
|
const cSchedule *Schedule = Schedules->First();
|
|
|
|
const cEventInfo **pArray = NULL;
|
|
|
|
int num = 0;
|
|
|
|
|
|
|
|
while (Schedule) {
|
|
|
|
pArray = (const cEventInfo **)realloc(pArray, (num + 1) * sizeof(cEventInfo *));
|
|
|
|
|
|
|
|
pArray[num] = Now ? Schedule->GetPresentEvent() : Schedule->GetFollowingEvent();
|
|
|
|
if (pArray[num]) {
|
2002-11-24 14:48:38 +01:00
|
|
|
cChannel *channel = Channels.GetByChannelID(pArray[num]->GetChannelID(), true);
|
2000-10-29 13:17:22 +01:00
|
|
|
if (channel) {
|
2002-10-06 10:25:42 +02:00
|
|
|
pArray[num]->SetChannelNumber(channel->Number());
|
2000-10-29 13:17:22 +01:00
|
|
|
num++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Schedule = (const cSchedule *)Schedules->Next(Schedule);
|
|
|
|
}
|
|
|
|
|
|
|
|
qsort(pArray, num, sizeof(cEventInfo *), CompareEventChannel);
|
|
|
|
|
|
|
|
for (int a = 0; a < num; a++)
|
2001-02-10 15:37:21 +01:00
|
|
|
Add(new cMenuWhatsOnItem(pArray[a]), pArray[a]->GetChannelNumber() == CurrentChannelNr);
|
2000-10-29 13:17:22 +01:00
|
|
|
|
2001-02-10 15:37:21 +01:00
|
|
|
currentChannel = CurrentChannelNr;
|
2002-08-11 13:32:23 +02:00
|
|
|
free(pArray);
|
2002-03-08 16:11:34 +01:00
|
|
|
SetHelp(tr("Record"), Now ? tr("Next") : tr("Now"), tr("Button$Schedule"), tr("Switch"));
|
2000-10-29 13:17:22 +01:00
|
|
|
}
|
|
|
|
|
2000-11-12 16:48:50 +01:00
|
|
|
const cEventInfo *cMenuWhatsOn::ScheduleEventInfo(void)
|
|
|
|
{
|
|
|
|
const cEventInfo *ei = scheduleEventInfo;
|
|
|
|
scheduleEventInfo = NULL;
|
|
|
|
return ei;
|
|
|
|
}
|
|
|
|
|
2000-10-29 13:17:22 +01:00
|
|
|
eOSState cMenuWhatsOn::Switch(void)
|
|
|
|
{
|
|
|
|
cMenuWhatsOnItem *item = (cMenuWhatsOnItem *)Get(Current());
|
|
|
|
if (item) {
|
2002-11-24 14:48:38 +01:00
|
|
|
cChannel *channel = Channels.GetByChannelID(item->eventInfo->GetChannelID(), 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;
|
|
|
|
}
|
2000-11-11 10:39:27 +01:00
|
|
|
Interface->Error(tr("Can't switch channel!"));
|
2000-10-29 13:17:22 +01:00
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuWhatsOn::Record(void)
|
|
|
|
{
|
|
|
|
cMenuWhatsOnItem *item = (cMenuWhatsOnItem *)Get(Current());
|
2001-06-02 10:47:40 +02:00
|
|
|
if (item) {
|
2000-10-29 13:17:22 +01:00
|
|
|
cTimer *timer = new cTimer(item->eventInfo);
|
2000-11-11 12:55:10 +01:00
|
|
|
cTimer *t = Timers.GetTimer(timer);
|
|
|
|
if (!t) {
|
|
|
|
Timers.Add(timer);
|
|
|
|
Timers.Save();
|
2002-05-13 16:35:49 +02:00
|
|
|
isyslog("timer %d added", timer->Index() + 1);
|
2000-11-11 12:55:10 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
delete timer;
|
|
|
|
timer = t;
|
|
|
|
}
|
2003-05-25 13:58:21 +02:00
|
|
|
return AddSubMenu(new cMenuEditTimer(timer->Index(), !t));
|
2000-10-29 13:17:22 +01:00
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuWhatsOn::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
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: {
|
2000-11-12 16:48:50 +01:00
|
|
|
cMenuWhatsOnItem *mi = (cMenuWhatsOnItem *)Get(Current());
|
2001-02-10 15:37:21 +01:00
|
|
|
if (mi) {
|
2000-11-12 16:48:50 +01:00
|
|
|
scheduleEventInfo = mi->eventInfo;
|
2001-02-10 15:37:21 +01:00
|
|
|
currentChannel = mi->eventInfo->GetChannelNumber();
|
|
|
|
}
|
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())
|
|
|
|
return AddSubMenu(new cMenuEvent(((cMenuWhatsOnItem *)Get(Current()))->eventInfo, true));
|
|
|
|
break;
|
2000-10-29 13:17:22 +01:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuScheduleItem -----------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuScheduleItem : public cOsdItem {
|
|
|
|
public:
|
|
|
|
const cEventInfo *eventInfo;
|
|
|
|
cMenuScheduleItem(const cEventInfo *EventInfo);
|
|
|
|
};
|
|
|
|
|
|
|
|
cMenuScheduleItem::cMenuScheduleItem(const cEventInfo *EventInfo)
|
|
|
|
{
|
|
|
|
eventInfo = EventInfo;
|
|
|
|
char *buffer = NULL;
|
|
|
|
asprintf(&buffer, "%.*s\t%.*s\t%s", 5, eventInfo->GetDate(), 5, eventInfo->GetTimeString(), eventInfo->GetTitle());
|
|
|
|
SetText(buffer, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuSchedule ---------------------------------------------------------
|
|
|
|
|
|
|
|
class cMenuSchedule : public cOsdMenu {
|
|
|
|
private:
|
2002-02-23 13:55:57 +01:00
|
|
|
cMutexLock mutexLock;
|
2000-10-29 13:17:22 +01:00
|
|
|
const cSchedules *schedules;
|
|
|
|
bool now, next;
|
2000-11-26 16:18:52 +01:00
|
|
|
int otherChannel;
|
2000-10-29 13:17:22 +01:00
|
|
|
eOSState Record(void);
|
2000-11-26 16:18:52 +01:00
|
|
|
eOSState Switch(void);
|
2000-11-12 16:48:50 +01:00
|
|
|
void PrepareSchedule(cChannel *Channel);
|
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)
|
2000-11-11 10:39:27 +01:00
|
|
|
:cOsdMenu("", 6, 6)
|
2000-10-29 13:17:22 +01:00
|
|
|
{
|
|
|
|
now = next = false;
|
2000-11-26 16:18:52 +01:00
|
|
|
otherChannel = 0;
|
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());
|
2002-02-23 13:55:57 +01:00
|
|
|
schedules = cSIProcessor::Schedules(mutexLock);
|
2000-11-12 16:48:50 +01:00
|
|
|
PrepareSchedule(channel);
|
2000-11-11 10:39:27 +01:00
|
|
|
SetHelp(tr("Record"), tr("Now"), tr("Next"));
|
2000-10-29 13:17:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-02 20:59:05 +02:00
|
|
|
cMenuSchedule::~cMenuSchedule()
|
|
|
|
{
|
|
|
|
cMenuWhatsOn::ScheduleEventInfo(); // makes sure any posted data is cleared
|
|
|
|
}
|
|
|
|
|
2000-10-29 13:17:22 +01:00
|
|
|
static int CompareEventTime(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
return (int)((*(cEventInfo **)p1)->GetTime() - (*(cEventInfo **)p2)->GetTime());
|
|
|
|
}
|
|
|
|
|
2000-11-12 16:48:50 +01:00
|
|
|
void cMenuSchedule::PrepareSchedule(cChannel *Channel)
|
2000-10-29 13:17:22 +01:00
|
|
|
{
|
2000-11-12 16:48:50 +01:00
|
|
|
Clear();
|
|
|
|
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);
|
2000-10-29 13:17:22 +01:00
|
|
|
if (schedules) {
|
2002-11-10 15:50:21 +01:00
|
|
|
const cSchedule *Schedule = schedules->GetSchedule(Channel->GetChannelID());
|
2000-10-29 13:17:22 +01:00
|
|
|
int num = Schedule->NumEvents();
|
2002-08-11 13:32:23 +02:00
|
|
|
const cEventInfo **pArray = MALLOC(const cEventInfo *, num);
|
2000-10-29 13:17:22 +01:00
|
|
|
if (pArray) {
|
|
|
|
time_t now = time(NULL);
|
|
|
|
int numreal = 0;
|
|
|
|
for (int a = 0; a < num; a++) {
|
|
|
|
const cEventInfo *EventInfo = Schedule->GetEventNumber(a);
|
|
|
|
if (EventInfo->GetTime() + EventInfo->GetDuration() > now)
|
|
|
|
pArray[numreal++] = EventInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
qsort(pArray, numreal, sizeof(cEventInfo *), CompareEventTime);
|
|
|
|
|
|
|
|
for (int a = 0; a < numreal; a++)
|
|
|
|
Add(new cMenuScheduleItem(pArray[a]));
|
2002-08-11 13:32:23 +02:00
|
|
|
free(pArray);
|
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) {
|
2000-10-29 13:17:22 +01:00
|
|
|
cTimer *timer = new cTimer(item->eventInfo);
|
2000-11-11 12:55:10 +01:00
|
|
|
cTimer *t = Timers.GetTimer(timer);
|
|
|
|
if (!t) {
|
|
|
|
Timers.Add(timer);
|
|
|
|
Timers.Save();
|
2002-05-13 16:35:49 +02:00
|
|
|
isyslog("timer %d added", timer->Index() + 1);
|
2000-11-11 12:55:10 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
delete timer;
|
|
|
|
timer = t;
|
|
|
|
}
|
2003-05-25 13:58:21 +02:00
|
|
|
return AddSubMenu(new cMenuEditTimer(timer->Index(), !t));
|
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;
|
|
|
|
}
|
|
|
|
Interface->Error(tr("Can't switch channel!"));
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
2000-10-29 13:17:22 +01:00
|
|
|
eOSState cMenuSchedule::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
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-03-18 10:16:56 +01:00
|
|
|
case kGreen: if (schedules) {
|
|
|
|
if (!now && !next) {
|
|
|
|
int ChannelNr = 0;
|
|
|
|
if (Count()) {
|
2002-11-24 14:48:38 +01:00
|
|
|
cChannel *channel = Channels.GetByChannelID(((cMenuScheduleItem *)Get(Current()))->eventInfo->GetChannelID(), 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;
|
|
|
|
case kBlue: if (Count())
|
|
|
|
return Switch();
|
|
|
|
break;
|
2000-11-01 15:50:00 +01:00
|
|
|
case kOk: if (Count())
|
2000-11-26 16:18:52 +01:00
|
|
|
return AddSubMenu(new cMenuEvent(((cMenuScheduleItem *)Get(Current()))->eventInfo, otherChannel));
|
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;
|
2000-11-12 16:48:50 +01:00
|
|
|
const cEventInfo *ei = cMenuWhatsOn::ScheduleEventInfo();
|
|
|
|
if (ei) {
|
2002-11-24 14:48:38 +01:00
|
|
|
cChannel *channel = Channels.GetByChannelID(ei->GetChannelID(), true);
|
2000-11-12 16:48:50 +01:00
|
|
|
if (channel) {
|
|
|
|
PrepareSchedule(channel);
|
2002-10-06 10:25:42 +02:00
|
|
|
if (channel->Number() != cDevice::CurrentChannel()) {
|
|
|
|
otherChannel = channel->Number();
|
2000-11-26 16:18:52 +01:00
|
|
|
SetHelp(tr("Record"), tr("Now"), tr("Next"), tr("Switch"));
|
|
|
|
}
|
2000-11-12 16:48:50 +01:00
|
|
|
Display();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
int i = 0;
|
|
|
|
cCommand *command;
|
|
|
|
|
|
|
|
while ((command = commands->Get(i)) != NULL) {
|
|
|
|
Add(new cOsdItem(hk(command->Title())));
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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());
|
|
|
|
Interface->Status(buffer);
|
|
|
|
Interface->Flush();
|
|
|
|
free(buffer);
|
|
|
|
const char *Result = command->Execute(parameters);
|
|
|
|
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) {
|
|
|
|
case kOk: return Execute();
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2003-01-06 14:44:27 +01:00
|
|
|
// --- cMenuCam --------------------------------------------------------------
|
|
|
|
|
|
|
|
cMenuCam::cMenuCam(cCiMenu *CiMenu)
|
|
|
|
:cOsdMenu("")
|
|
|
|
{
|
|
|
|
ciMenu = CiMenu;
|
|
|
|
selected = false;
|
|
|
|
if (ciMenu->Selectable())
|
|
|
|
SetHasHotkeys();
|
|
|
|
SetTitle(ciMenu->TitleText() ? ciMenu->TitleText() : "CAM");
|
|
|
|
for (int i = 0; i < ciMenu->NumEntries(); i++)
|
|
|
|
Add(new cOsdItem(hk(ciMenu->Entry(i))));
|
|
|
|
//XXX implement a clean way of displaying this:
|
|
|
|
Add(new cOsdItem(ciMenu->SubTitleText()));
|
|
|
|
Add(new cOsdItem(ciMenu->BottomText()));
|
|
|
|
Display();
|
2003-02-09 11:54:22 +01:00
|
|
|
dsyslog("CAM: Menu - %s", ciMenu->TitleText());
|
2003-01-06 14:44:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cMenuCam::~cMenuCam()
|
|
|
|
{
|
|
|
|
if (!selected)
|
|
|
|
ciMenu->Cancel();
|
|
|
|
delete ciMenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuCam::Select(void)
|
|
|
|
{
|
|
|
|
if (ciMenu->Selectable()) {
|
|
|
|
ciMenu->Select(Current());
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuCamEnquiry -------------------------------------------------------
|
|
|
|
|
|
|
|
//XXX this is just quick and dirty - make this a separate display object
|
|
|
|
cMenuCamEnquiry::cMenuCamEnquiry(cCiEnquiry *CiEnquiry)
|
2003-01-19 14:59:46 +01:00
|
|
|
:cOsdMenu("", 10)
|
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;
|
|
|
|
SetTitle(ciEnquiry->Text() ? ciEnquiry->Text() : "CAM");
|
2003-01-19 14:59:46 +01:00
|
|
|
Add(new cMenuEditNumItem("Input", input, Length, ciEnquiry->Blind()));
|
2003-01-06 14:44:27 +01:00
|
|
|
Display();
|
|
|
|
}
|
|
|
|
|
|
|
|
cMenuCamEnquiry::~cMenuCamEnquiry()
|
|
|
|
{
|
|
|
|
if (!replied)
|
|
|
|
ciEnquiry->Cancel();
|
2003-01-19 14:59:46 +01:00
|
|
|
free(input);
|
2003-01-06 14:44:27 +01:00
|
|
|
delete ciEnquiry;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuCamEnquiry::Reply(void)
|
|
|
|
{
|
2003-01-19 14:59:46 +01:00
|
|
|
//XXX check length???
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
cRecordings cMenuRecordings::Recordings;
|
|
|
|
int cMenuRecordings::helpKeys = -1;
|
|
|
|
|
|
|
|
cMenuRecordings::cMenuRecordings(const char *Base, int Level, bool OpenSubMenus)
|
|
|
|
:cOsdMenu(Base ? Base : tr("Recordings"), 6, 6)
|
|
|
|
{
|
|
|
|
base = Base ? strdup(Base) : NULL;
|
|
|
|
level = Setup.RecordingDirs ? Level : -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
|
2002-01-27 15:55:31 +01:00
|
|
|
if (!Base) {
|
|
|
|
Interface->Status(tr("scanning recordings..."));
|
|
|
|
Interface->Flush();
|
|
|
|
}
|
2002-01-20 14:05:28 +01:00
|
|
|
if (Base || Recordings.Load()) {
|
|
|
|
const char *LastReplayed = cReplayControl::LastReplayed();
|
|
|
|
cMenuRecordingItem *LastItem = NULL;
|
|
|
|
char *LastItemText = NULL;
|
|
|
|
for (cRecording *recording = Recordings.First(); recording; recording = Recordings.Next(recording)) {
|
2002-02-01 15:11:39 +01:00
|
|
|
if (!Base || (strstr(recording->Name(), Base) == recording->Name() && recording->Name()[strlen(Base)] == '~')) {
|
2002-01-20 14:05:28 +01:00
|
|
|
cMenuRecordingItem *Item = new cMenuRecordingItem(recording, level);
|
|
|
|
if (*Item->Text() && (!LastItem || strcmp(Item->Text(), LastItemText) != 0)) {
|
|
|
|
Add(Item);
|
|
|
|
LastItem = Item;
|
2002-08-11 13:32:23 +02:00
|
|
|
free(LastItemText);
|
2002-01-20 14:05:28 +01:00
|
|
|
LastItemText = strdup(LastItem->Text()); // must use a copy because of the counters!
|
|
|
|
}
|
|
|
|
else
|
|
|
|
delete Item;
|
|
|
|
if (LastItem) {
|
|
|
|
if (LastReplayed && strcmp(LastReplayed, recording->FileName()) == 0)
|
|
|
|
SetCurrent(LastItem);
|
|
|
|
if (LastItem->IsDirectory())
|
|
|
|
LastItem->IncrementCounter(recording->IsNew());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-08-11 13:32:23 +02:00
|
|
|
free(LastItemText);
|
2002-01-20 14:05:28 +01:00
|
|
|
if (Current() < 0)
|
|
|
|
SetCurrent(First());
|
|
|
|
else if (OpenSubMenus && Open(true))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
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());
|
|
|
|
int NewHelpKeys = helpKeys;
|
|
|
|
if (ri) {
|
|
|
|
if (ri->IsDirectory())
|
|
|
|
NewHelpKeys = 1;
|
|
|
|
else {
|
|
|
|
NewHelpKeys = 2;
|
|
|
|
cRecording *recording = GetRecording(ri);
|
|
|
|
if (recording && recording->Summary())
|
|
|
|
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;
|
|
|
|
case 1: SetHelp(tr("Open")); break;
|
|
|
|
case 2:
|
2002-10-13 12:14:49 +02:00
|
|
|
case 3: SetHelp(RecordingCommands.Count() ? tr("Commands") : tr("Play"), tr("Rewind"), tr("Delete"), NewHelpKeys == 3 ? tr("Summary") : NULL);
|
2002-01-20 14:05:28 +01:00
|
|
|
}
|
|
|
|
helpKeys = NewHelpKeys;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cRecording *cMenuRecordings::GetRecording(cMenuRecordingItem *Item)
|
|
|
|
{
|
|
|
|
cRecording *recording = Recordings.GetByName(Item->FileName());
|
|
|
|
if (!recording)
|
|
|
|
Interface->Error(tr("Error while accessing recording!"));
|
|
|
|
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()) {
|
|
|
|
int Index = timer->Index();
|
|
|
|
Timers.Del(timer);
|
|
|
|
isyslog("timer %d deleted", Index + 1);
|
|
|
|
}
|
2002-02-23 09:33:04 +01:00
|
|
|
Timers.Save();
|
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());
|
|
|
|
cOsdMenu::Del(Current());
|
|
|
|
Recordings.Del(recording);
|
|
|
|
Display();
|
|
|
|
if (!Count())
|
|
|
|
return osBack;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Interface->Error(tr("Error while deleting recording!"));
|
|
|
|
}
|
|
|
|
}
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
2000-07-24 16:43:04 +02:00
|
|
|
eOSState cMenuRecordings::Summary(void)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
if (recording && recording->Summary() && *recording->Summary())
|
|
|
|
return AddSubMenu(new cMenuText(tr("Summary"), recording->Summary()));
|
|
|
|
}
|
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;
|
|
|
|
asprintf(¶meter, "'%s'", recording->FileName());
|
|
|
|
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();
|
2000-07-24 16:43:04 +02:00
|
|
|
case kBlue: return Summary();
|
2002-10-13 12:14:49 +02:00
|
|
|
case k1...k9: return Commands(Key);
|
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:
|
|
|
|
virtual void Set(void);
|
|
|
|
public:
|
|
|
|
cMenuSetupOSD(void) { Set(); }
|
2002-05-11 13:44:58 +02:00
|
|
|
virtual eOSState ProcessKey(eKeys Key);
|
2002-03-16 10:03:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
void cMenuSetupOSD::Set(void)
|
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()));
|
2002-03-17 14:11:22 +01:00
|
|
|
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));
|
2002-03-17 14:11:22 +01:00
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.OSD$Channel info position"), &data.ChannelInfoPos, tr("bottom"), tr("top")));
|
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.OSD$Info on channel switch"), &data.ShowInfoOnChSwitch));
|
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.OSD$Scroll pages"), &data.MenuScrollPage));
|
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.OSD$Sort timers"), &data.SortTimers));
|
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.OSD$Recording directories"), &data.RecordingDirs));
|
2002-03-16 10:03:04 +01:00
|
|
|
}
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
eOSState cMenuSetupOSD::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
int osdLanguage = data.OSDLanguage;
|
|
|
|
eOSState state = cMenuSetupBase::ProcessKey(Key);
|
|
|
|
|
|
|
|
if (data.OSDLanguage != osdLanguage) {
|
|
|
|
int OriginalOSDLanguage = Setup.OSDLanguage;
|
|
|
|
Setup.OSDLanguage = data.OSDLanguage;
|
|
|
|
Set();
|
|
|
|
Display();
|
|
|
|
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 {
|
2002-03-16 10:03:04 +01:00
|
|
|
public:
|
2002-05-11 13:44:58 +02:00
|
|
|
cMenuSetupEPG(void);
|
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
|
|
|
{
|
2002-05-11 13:44:58 +02:00
|
|
|
SetSection(tr("EPG"));
|
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));
|
|
|
|
Add(new cMenuEditBoolItem(tr("Setup.EPG$Set system time"), &data.SetSystemTime));
|
2002-03-17 14:24:11 +01:00
|
|
|
Add(new cMenuEditTranItem(tr("Setup.EPG$Use time from transponder"), &data.TimeTransponder));
|
2002-03-16 10:03:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// --- cMenuSetupDVB ---------------------------------------------------------
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
class cMenuSetupDVB : public cMenuSetupBase {
|
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
|
|
|
{
|
2002-05-11 13:44:58 +02:00
|
|
|
SetSection(tr("DVB"));
|
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"));
|
2002-03-16 10:03:04 +01:00
|
|
|
}
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
eOSState cMenuSetupDVB::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
int oldPrimaryDVB = Setup.PrimaryDVB;
|
2002-10-12 09:13:05 +02:00
|
|
|
bool oldVideoFormat = Setup.VideoFormat;
|
2002-05-11 13:44:58 +02:00
|
|
|
eOSState state = cMenuSetupBase::ProcessKey(Key);
|
|
|
|
|
|
|
|
if (state == osBack && Key == kOk) {
|
2002-10-12 09:13:05 +02:00
|
|
|
if (Setup.PrimaryDVB != oldPrimaryDVB)
|
2002-05-11 13:44:58 +02:00
|
|
|
state = osSwitchDvb;
|
2002-10-12 09:13:05 +02:00
|
|
|
if (Setup.VideoFormat != oldVideoFormat)
|
2002-08-04 14:57:29 +02:00
|
|
|
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 -------------------------------------------------------
|
|
|
|
|
2002-05-11 13:44:58 +02:00
|
|
|
class cMenuSetupCICAM : public cMenuSetupBase {
|
2003-01-06 14:44:27 +01:00
|
|
|
private:
|
|
|
|
int helpKeys;
|
|
|
|
void SetHelpKeys(void);
|
2003-02-09 11:54:22 +01:00
|
|
|
cCiHandler *GetCurrentCiHandler(int *Slot = NULL);
|
2003-01-06 14:44:27 +01:00
|
|
|
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
|
|
|
{
|
2003-01-06 14:44:27 +01:00
|
|
|
helpKeys = -1;
|
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++) {
|
2002-03-16 10:03:04 +01:00
|
|
|
for (int i = 0; i < 2; i++) {
|
|
|
|
char buffer[32];
|
2002-03-17 14:11:22 +01:00
|
|
|
snprintf(buffer, sizeof(buffer), "%s%d %d", tr("Setup.CICAM$CICAM DVB"), d + 1, i + 1);
|
2002-03-16 10:03:04 +01:00
|
|
|
Add(new cMenuEditCaItem(buffer, &data.CaCaps[d][i]));
|
|
|
|
}
|
|
|
|
}
|
2003-01-06 14:44:27 +01:00
|
|
|
SetHelpKeys();
|
|
|
|
}
|
|
|
|
|
2003-02-09 11:54:22 +01:00
|
|
|
cCiHandler *cMenuSetupCICAM::GetCurrentCiHandler(int *Slot)
|
2003-01-06 14:44:27 +01:00
|
|
|
{
|
|
|
|
cDevice *Device = cDevice::GetDevice(Current() / 2);
|
2003-02-09 11:54:22 +01:00
|
|
|
if (Slot)
|
|
|
|
*Slot = Current() % 2;
|
2003-01-06 14:44:27 +01:00
|
|
|
return Device ? Device->CiHandler() : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cMenuSetupCICAM::SetHelpKeys(void)
|
|
|
|
{
|
|
|
|
int NewHelpKeys = helpKeys;
|
|
|
|
NewHelpKeys = GetCurrentCiHandler() ? 1 : 0;
|
|
|
|
if (NewHelpKeys != helpKeys) {
|
|
|
|
switch (NewHelpKeys) {
|
|
|
|
case 0: SetHelp(NULL); break;
|
|
|
|
case 1: SetHelp(tr("Menu"), tr("Reset"));
|
|
|
|
}
|
|
|
|
helpKeys = NewHelpKeys;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuSetupCICAM::Menu(void)
|
|
|
|
{
|
2003-02-09 11:54:22 +01:00
|
|
|
int Slot = 0;
|
|
|
|
cCiHandler *CiHandler = GetCurrentCiHandler(&Slot);
|
|
|
|
if (CiHandler && CiHandler->EnterMenu(Slot))
|
2003-01-06 14:44:27 +01:00
|
|
|
return osEnd; // the CAM menu will be executed explicitly from the main loop
|
|
|
|
else
|
|
|
|
Interface->Error(tr("Can't open CAM menu!"));
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cMenuSetupCICAM::Reset(void)
|
|
|
|
{
|
2003-02-09 11:54:22 +01:00
|
|
|
int Slot = 0;
|
|
|
|
cCiHandler *CiHandler = GetCurrentCiHandler(&Slot);
|
|
|
|
if (CiHandler && CiHandler->Reset(Slot)) {
|
2003-01-06 14:44:27 +01:00
|
|
|
Interface->Info(tr("CAM has been reset"));
|
2003-02-09 11:54:22 +01:00
|
|
|
return osEnd;
|
|
|
|
}
|
2003-01-06 14:44:27 +01:00
|
|
|
else
|
|
|
|
Interface->Error(tr("Can't reset CAM!"));
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (state == osBack && Key == kOk)
|
2002-06-16 12:57:31 +02:00
|
|
|
cDevice::SetCaCaps();
|
2003-01-06 14:44:27 +01:00
|
|
|
else if (state == osUnknown) {
|
|
|
|
switch (Key) {
|
|
|
|
case kRed: if (helpKeys == 1)
|
|
|
|
return Menu();
|
|
|
|
break;
|
|
|
|
case kGreen: if (helpKeys == 1)
|
|
|
|
return Reset();
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Key != kNone)
|
|
|
|
SetHelpKeys();
|
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));
|
|
|
|
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 cMenuEditBoolItem(tr("Setup.Recording$Record Dolby Digital"), &data.RecordDolbyDigital));
|
|
|
|
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 {
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// --- 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));
|
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);
|
|
|
|
}
|
|
|
|
Interface->Info(tr("This plugin has no setup parameters!"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
if (Interface->Confirm(cRecordControls::Active() ? tr("Recording - restart anyway?") : tr("Really restart?"))) {
|
|
|
|
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 ")
|
2001-10-28 16:32:34 +01:00
|
|
|
#define ON_PRIMARY_INTERFACE tr("on primary interface")
|
2000-05-01 16:29:46 +02:00
|
|
|
|
2002-11-24 10:45:39 +01:00
|
|
|
cOsdObject *cMenuMain::pluginOsdObject = NULL;
|
|
|
|
|
2002-12-01 10:48:08 +01:00
|
|
|
cMenuMain::cMenuMain(bool Replaying, eOSState State, const char *Plugin)
|
2002-03-16 10:03:04 +01:00
|
|
|
:cOsdMenu("")
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2002-03-08 16:11:34 +01:00
|
|
|
replaying = Replaying;
|
2002-12-01 10:48:08 +01:00
|
|
|
Set(Plugin);
|
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-12-01 10:48:08 +01:00
|
|
|
case osPlugin: break; // the actual work is done in Set()
|
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;
|
|
|
|
}
|
|
|
|
|
2002-12-01 10:48:08 +01:00
|
|
|
void cMenuMain::Set(const char *Plugin)
|
2002-03-16 10:03:04 +01:00
|
|
|
{
|
|
|
|
Clear();
|
2002-03-16 10:09:54 +01:00
|
|
|
//SetTitle("VDR"); // this is done below, including disk usage
|
2002-03-16 10:03:04 +01:00
|
|
|
SetHasHotkeys();
|
2001-10-28 16:32:34 +01:00
|
|
|
|
2002-01-27 13:11:23 +01:00
|
|
|
// Title with disk usage:
|
|
|
|
|
2002-02-09 14:42:56 +01:00
|
|
|
#define MB_PER_MINUTE 25.75 // this is just an estimate!
|
2002-01-27 13:11:23 +01:00
|
|
|
|
|
|
|
char buffer[40];
|
|
|
|
int FreeMB;
|
|
|
|
int Percent = VideoDiskSpace(&FreeMB);
|
2002-02-09 14:42:56 +01:00
|
|
|
int Minutes = int(double(FreeMB) / MB_PER_MINUTE);
|
|
|
|
int Hours = Minutes / 60;
|
|
|
|
Minutes %= 60;
|
2002-03-22 14:39:45 +01:00
|
|
|
snprintf(buffer, sizeof(buffer), "%s - %s %d%% - %2d:%02d %s", tr("VDR"), tr("Disk"), Percent, Hours, Minutes, tr("free"));
|
2002-01-27 13:11:23 +01:00
|
|
|
SetTitle(buffer);
|
|
|
|
|
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)
|
2002-12-01 10:48:08 +01:00
|
|
|
Add(new cMenuPluginItem(hk(item), i), Plugin && strcmp(Plugin, p->Name()) == 0);
|
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
|
|
|
|
|
|
|
// Replay control:
|
|
|
|
|
2002-03-08 16:11:34 +01:00
|
|
|
if (replaying)
|
2001-08-05 12:47:14 +02:00
|
|
|
Add(new cOsdItem(tr(" Stop replaying"), osStopReplay));
|
2001-10-28 16:32:34 +01:00
|
|
|
|
|
|
|
// Record control:
|
|
|
|
|
|
|
|
if (cRecordControls::StopPrimary()) {
|
|
|
|
char *buffer = NULL;
|
|
|
|
asprintf(&buffer, "%s%s", STOP_RECORDING, ON_PRIMARY_INTERFACE);
|
|
|
|
Add(new cOsdItem(buffer, osStopRecord));
|
2002-08-11 13:32:23 +02:00
|
|
|
free(buffer);
|
2001-10-28 16:32:34 +01:00
|
|
|
}
|
|
|
|
|
2000-05-01 16:29:46 +02:00
|
|
|
const char *s = NULL;
|
|
|
|
while ((s = cRecordControls::GetInstantId(s)) != NULL) {
|
|
|
|
char *buffer = NULL;
|
|
|
|
asprintf(&buffer, "%s%s", STOP_RECORDING, s);
|
2001-08-05 12:47:14 +02:00
|
|
|
Add(new cOsdItem(buffer, osStopRecord));
|
2002-08-11 13:32:23 +02:00
|
|
|
free(buffer);
|
2000-05-01 16:29:46 +02:00
|
|
|
}
|
2001-10-28 16:32:34 +01:00
|
|
|
|
|
|
|
// Editing control:
|
|
|
|
|
2002-06-22 10:11:59 +02:00
|
|
|
if (cCutter::Active())
|
2001-08-12 12:42:37 +02:00
|
|
|
Add(new cOsdItem(tr(" Cancel editing"), osCancelEdit));
|
2001-10-28 16:32:34 +01:00
|
|
|
|
|
|
|
// Color buttons:
|
|
|
|
|
2003-05-03 16:08:44 +02:00
|
|
|
SetHelp(!replaying ? tr("Record") : NULL, cDevice::PrimaryDevice()->NumAudioTracks() > 1 ? tr("Language") : NULL, replaying ? NULL : tr("Pause"), replaying ? tr("Button$Stop") : cReplayControl::LastReplayed() ? tr("Resume") : NULL);
|
2000-04-30 10:22:13 +02:00
|
|
|
Display();
|
2000-05-01 16:29:46 +02:00
|
|
|
lastActivity = time(NULL);
|
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) {
|
2001-10-28 16:32:34 +01:00
|
|
|
const char *s = item->Text() + strlen(STOP_RECORDING);
|
|
|
|
if (strcmp(s, ON_PRIMARY_INTERFACE) == 0)
|
|
|
|
cRecordControls::StopPrimary(true);
|
|
|
|
else
|
|
|
|
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) {
|
2002-10-12 14:29:46 +02:00
|
|
|
int CurrentAudioTrack = -1;
|
|
|
|
const char **AudioTracks = cDevice::PrimaryDevice()->GetAudioTracks(&CurrentAudioTrack);
|
|
|
|
if (AudioTracks) {
|
|
|
|
const char **at = &AudioTracks[CurrentAudioTrack];
|
|
|
|
if (!*++at)
|
|
|
|
at = AudioTracks;
|
2001-08-03 14:18:08 +02:00
|
|
|
Interface->Clear();
|
2002-10-12 14:29:46 +02:00
|
|
|
cDevice::PrimaryDevice()->SetAudioTrack(at - AudioTracks);
|
|
|
|
//XXX Interface->Info(*at);
|
2001-08-03 14:18:08 +02:00
|
|
|
state = osEnd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
2002-03-16 10:03:04 +01:00
|
|
|
if (Key != kNone) {
|
2000-05-01 16:29:46 +02:00
|
|
|
lastActivity = time(NULL);
|
2002-03-16 10:03:04 +01:00
|
|
|
if (Setup.OSDLanguage != osdLanguage) {
|
|
|
|
Set();
|
|
|
|
if (!HasSubMenu())
|
|
|
|
Display();
|
|
|
|
}
|
|
|
|
}
|
2000-05-01 16:29:46 +02:00
|
|
|
else if (time(NULL) - lastActivity > MENUTIMEOUT)
|
|
|
|
state = osEnd;
|
2000-03-11 11:22:37 +01:00
|
|
|
return state;
|
2000-02-19 13:36:48 +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-11-01 15:41:33 +01:00
|
|
|
#define INFOTIMEOUT 5000 //ms
|
2000-09-10 14:56:18 +02:00
|
|
|
|
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
|
|
|
{
|
2001-09-08 14:39:09 +02:00
|
|
|
group = -1;
|
|
|
|
withInfo = !Switched || Setup.ShowInfoOnChSwitch;
|
2002-02-10 11:58:17 +01:00
|
|
|
int EpgLines = withInfo ? 5 : 1;
|
2000-11-01 15:41:33 +01:00
|
|
|
lines = 0;
|
2002-09-29 13:40:45 +02:00
|
|
|
number = 0;
|
2001-09-08 14:39:09 +02:00
|
|
|
cChannel *channel = Channels.GetByNumber(Number);
|
2002-02-10 11:58:17 +01:00
|
|
|
Interface->Open(Setup.OSDwidth, Setup.ChannelInfoPos ? EpgLines : -EpgLines);
|
2000-11-01 15:41:33 +01:00
|
|
|
if (channel) {
|
|
|
|
DisplayChannel(channel);
|
|
|
|
DisplayInfo();
|
|
|
|
}
|
|
|
|
lastTime = time_ms();
|
|
|
|
}
|
|
|
|
|
|
|
|
cDisplayChannel::cDisplayChannel(eKeys FirstKey)
|
2002-05-18 12:41:18 +02:00
|
|
|
:cOsdObject(true)
|
2000-09-10 14:56:18 +02:00
|
|
|
{
|
2001-09-08 14:39:09 +02:00
|
|
|
group = -1;
|
2002-10-27 14:32:06 +01:00
|
|
|
lines = 0;
|
2000-09-10 14:56:18 +02:00
|
|
|
number = 0;
|
|
|
|
lastTime = time_ms();
|
2003-05-29 11:45:13 +02:00
|
|
|
withInfo = Setup.ShowInfoOnChSwitch;
|
|
|
|
int EpgLines = withInfo ? 5 : 1;
|
2002-02-10 11:58:17 +01:00
|
|
|
Interface->Open(Setup.OSDwidth, Setup.ChannelInfoPos ? EpgLines : -EpgLines);
|
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
|
|
|
{
|
2000-10-08 12:24:30 +02:00
|
|
|
Interface->Close();
|
2000-09-10 14:56:18 +02:00
|
|
|
}
|
|
|
|
|
2000-11-01 15:41:33 +01:00
|
|
|
void cDisplayChannel::DisplayChannel(const cChannel *Channel)
|
|
|
|
{
|
2001-01-13 13:08:43 +01:00
|
|
|
int BufSize = Width() + 1;
|
|
|
|
char buffer[BufSize];
|
2002-10-19 15:33:37 +02:00
|
|
|
*buffer = 0;
|
|
|
|
if (Channel) {
|
2002-11-01 12:18:45 +01:00
|
|
|
if (Channel->GroupSep())
|
2002-10-19 15:33:37 +02:00
|
|
|
snprintf(buffer, BufSize, "%s", Channel->Name());
|
2002-11-01 12:18:45 +01:00
|
|
|
else
|
|
|
|
snprintf(buffer, BufSize, "%d%s %s", Channel->Number(), number ? "-" : "", Channel->Name());
|
2002-10-19 15:33:37 +02:00
|
|
|
}
|
|
|
|
else if (number)
|
|
|
|
snprintf(buffer, BufSize, "%d-", number);
|
2001-01-13 13:08:43 +01:00
|
|
|
else
|
2002-10-19 15:33:37 +02:00
|
|
|
snprintf(buffer, BufSize, "%s", tr("*** Invalid Channel ***"));
|
2001-07-27 11:51:42 +02:00
|
|
|
Interface->Fill(0, 0, Setup.OSDwidth, 1, clrBackground);
|
2001-01-13 13:08:43 +01:00
|
|
|
Interface->Write(0, 0, buffer);
|
2001-08-25 13:27:26 +02:00
|
|
|
const char *date = DayDateTime();
|
|
|
|
Interface->Write(-strlen(date), 0, date);
|
2002-06-16 13:26:00 +02:00
|
|
|
cStatus::MsgOsdChannel(buffer);
|
2000-11-01 15:41:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayChannel::DisplayInfo(void)
|
|
|
|
{
|
|
|
|
if (withInfo) {
|
|
|
|
const cEventInfo *Present = NULL, *Following = NULL;
|
2002-02-23 13:55:57 +01:00
|
|
|
cMutexLock MutexLock;
|
|
|
|
const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock);
|
2000-11-01 15:41:33 +01:00
|
|
|
if (Schedules) {
|
|
|
|
const cSchedule *Schedule = Schedules->GetSchedule();
|
|
|
|
if (Schedule) {
|
|
|
|
const char *PresentTitle = NULL, *PresentSubtitle = NULL, *FollowingTitle = NULL, *FollowingSubtitle = NULL;
|
|
|
|
int Lines = 0;
|
|
|
|
if ((Present = Schedule->GetPresentEvent()) != NULL) {
|
|
|
|
PresentTitle = Present->GetTitle();
|
|
|
|
if (!isempty(PresentTitle))
|
|
|
|
Lines++;
|
|
|
|
PresentSubtitle = Present->GetSubtitle();
|
|
|
|
if (!isempty(PresentSubtitle))
|
|
|
|
Lines++;
|
|
|
|
}
|
|
|
|
if ((Following = Schedule->GetFollowingEvent()) != NULL) {
|
|
|
|
FollowingTitle = Following->GetTitle();
|
|
|
|
if (!isempty(FollowingTitle))
|
|
|
|
Lines++;
|
|
|
|
FollowingSubtitle = Following->GetSubtitle();
|
|
|
|
if (!isempty(FollowingSubtitle))
|
|
|
|
Lines++;
|
|
|
|
}
|
|
|
|
if (Lines > lines) {
|
|
|
|
const int t = 6;
|
|
|
|
int l = 1;
|
2001-07-27 11:51:42 +02:00
|
|
|
Interface->Fill(0, 1, Setup.OSDwidth, Lines, clrBackground);
|
2000-11-01 15:41:33 +01:00
|
|
|
if (!isempty(PresentTitle)) {
|
|
|
|
Interface->Write(0, l, Present->GetTimeString(), clrYellow, clrBackground);
|
|
|
|
Interface->Write(t, l, PresentTitle, clrCyan, clrBackground);
|
|
|
|
l++;
|
|
|
|
}
|
|
|
|
if (!isempty(PresentSubtitle)) {
|
|
|
|
Interface->Write(t, l, PresentSubtitle, clrCyan, clrBackground);
|
|
|
|
l++;
|
|
|
|
}
|
|
|
|
if (!isempty(FollowingTitle)) {
|
|
|
|
Interface->Write(0, l, Following->GetTimeString(), clrYellow, clrBackground);
|
|
|
|
Interface->Write(t, l, FollowingTitle, clrCyan, clrBackground);
|
|
|
|
l++;
|
|
|
|
}
|
|
|
|
if (!isempty(FollowingSubtitle)) {
|
|
|
|
Interface->Write(t, l, FollowingSubtitle, clrCyan, clrBackground);
|
|
|
|
}
|
|
|
|
Interface->Flush();
|
|
|
|
lines = Lines;
|
|
|
|
lastTime = time_ms();
|
2002-06-16 13:26:00 +02:00
|
|
|
cStatus::MsgOsdProgramme(Present ? Present->GetTime() : 0, PresentTitle, PresentSubtitle, Following ? Following->GetTime() : 0, FollowingTitle, FollowingSubtitle);
|
2000-11-01 15:41:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-27 14:32:06 +01:00
|
|
|
void cDisplayChannel::Refresh(void)
|
|
|
|
{
|
|
|
|
Interface->Clear();
|
|
|
|
DisplayChannel(Channels.GetByNumber(cDevice::CurrentChannel()));
|
|
|
|
lastTime = time_ms();
|
|
|
|
lines = 0;
|
|
|
|
}
|
|
|
|
|
2000-11-01 15:41:33 +01:00
|
|
|
eOSState cDisplayChannel::ProcessKey(eKeys Key)
|
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:
|
2000-09-10 14:56:18 +02:00
|
|
|
if (number >= 0) {
|
|
|
|
number = number * 10 + Key - k0;
|
2000-11-01 15:41:33 +01:00
|
|
|
if (number > 0) {
|
|
|
|
cChannel *channel = Channels.GetByNumber(number);
|
|
|
|
DisplayChannel(channel);
|
|
|
|
lastTime = time_ms();
|
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:
|
|
|
|
withInfo = false;
|
|
|
|
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;
|
2001-10-27 13:48:20 +02:00
|
|
|
if (NORMALKEY(Key) == kRight)
|
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;
|
|
|
|
cChannel *channel = Channels.Get(group);
|
|
|
|
if (channel) {
|
|
|
|
Interface->Clear();
|
|
|
|
DisplayChannel(channel);
|
2002-10-06 10:25:42 +02:00
|
|
|
if (!channel->GroupSep())
|
2001-09-08 14:39:09 +02:00
|
|
|
group = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lastTime = time_ms();
|
|
|
|
break;
|
2002-10-27 14:32:06 +01:00
|
|
|
case kUp|k_Repeat:
|
|
|
|
case kUp:
|
|
|
|
case kDown|k_Repeat:
|
|
|
|
case kDown:
|
|
|
|
cDevice::SwitchChannel(NORMALKEY(Key) == kUp ? 1 : -1);
|
|
|
|
// no break here
|
|
|
|
case kChanUp|k_Repeat:
|
|
|
|
case kChanUp:
|
|
|
|
case kChanDn|k_Repeat:
|
|
|
|
case kChanDn:
|
|
|
|
Refresh();
|
|
|
|
break;
|
2000-09-10 14:56:18 +02:00
|
|
|
case kNone:
|
2000-11-01 15:41:33 +01:00
|
|
|
if (number && time_ms() - lastTime > DIRECTCHANNELTIMEOUT) {
|
2002-10-19 15:33:37 +02:00
|
|
|
if (Channels.GetByNumber(number))
|
|
|
|
Channels.SwitchTo(number);
|
|
|
|
else {
|
|
|
|
number = 0;
|
|
|
|
DisplayChannel(NULL);
|
|
|
|
lastTime = time_ms();
|
|
|
|
return osContinue;
|
|
|
|
}
|
2000-11-01 15:41:33 +01:00
|
|
|
return osEnd;
|
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;
|
2001-09-08 14:39:09 +02:00
|
|
|
case kOk: if (group >= 0)
|
2002-10-06 10:25:42 +02:00
|
|
|
Channels.SwitchTo(Channels.Get(Channels.GetNextNormal(group))->Number());
|
2000-11-01 15:41:33 +01:00
|
|
|
return osEnd;
|
2002-10-27 14:32:06 +01:00
|
|
|
default: if ((Key & (k_Repeat | k_Release)) == 0) {
|
2002-09-29 13:40:45 +02:00
|
|
|
cRemote::Put(Key);
|
2001-10-27 13:48:20 +02:00
|
|
|
return osEnd;
|
|
|
|
}
|
2000-09-10 14:56:18 +02:00
|
|
|
};
|
2000-11-01 15:41:33 +01:00
|
|
|
if (time_ms() - lastTime < INFOTIMEOUT) {
|
|
|
|
DisplayInfo();
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
return osEnd;
|
2000-09-10 14:56:18 +02:00
|
|
|
}
|
|
|
|
|
2002-03-09 17:11:49 +01:00
|
|
|
// --- cVolumeBar ------------------------------------------------------------
|
|
|
|
|
|
|
|
class cVolumeBar : public cBitmap {
|
|
|
|
public:
|
|
|
|
cVolumeBar(int Width, int Height, int Current, int Total, const char *Prompt = NULL);
|
|
|
|
};
|
|
|
|
|
|
|
|
cVolumeBar::cVolumeBar(int Width, int Height, int Current, int Total, const char *Prompt)
|
|
|
|
:cBitmap(Width, Height, 2)
|
|
|
|
{
|
|
|
|
int l = Prompt ? cBitmap::Width(Prompt) : 0;
|
|
|
|
int p = (Width - l) * Current / Total;
|
|
|
|
Text(0, 0, Prompt, clrGreen);
|
|
|
|
Fill(l, 0, p, Height - 1, clrGreen);
|
|
|
|
Fill(l + p, 0, Width - 1, Height - 1, clrWhite);
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- cDisplayVolume --------------------------------------------------------
|
|
|
|
|
|
|
|
#define VOLUMETIMEOUT 1000 //ms
|
|
|
|
#define MUTETIMEOUT 5000 //ms
|
|
|
|
|
|
|
|
cDisplayVolume *cDisplayVolume::displayVolume = NULL;
|
|
|
|
|
|
|
|
cDisplayVolume::cDisplayVolume(void)
|
2002-05-18 12:41:18 +02:00
|
|
|
:cOsdObject(true)
|
2002-03-09 17:11:49 +01:00
|
|
|
{
|
|
|
|
displayVolume = this;
|
2002-06-16 12:57:31 +02:00
|
|
|
timeout = time_ms() + (cDevice::PrimaryDevice()->IsMute() ? MUTETIMEOUT : VOLUMETIMEOUT);
|
2002-03-09 17:11:49 +01:00
|
|
|
Interface->Open(Setup.OSDwidth, -1);
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
cDisplayVolume::~cDisplayVolume()
|
|
|
|
{
|
|
|
|
Interface->Close();
|
|
|
|
displayVolume = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayVolume::Show(void)
|
|
|
|
{
|
2002-06-16 12:57:31 +02:00
|
|
|
cDevice *device = cDevice::PrimaryDevice();
|
|
|
|
if (device->IsMute()) {
|
2002-03-09 17:11:49 +01:00
|
|
|
Interface->Fill(0, 0, Width(), 1, clrTransparent);
|
|
|
|
Interface->Write(0, 0, tr("Mute"), clrGreen);
|
|
|
|
}
|
|
|
|
else {
|
2002-06-16 12:57:31 +02:00
|
|
|
int Current = cDevice::CurrentVolume();
|
2002-03-09 17:11:49 +01:00
|
|
|
int Total = MAXVOLUME;
|
|
|
|
const char *Prompt = tr("Volume ");
|
|
|
|
#ifdef DEBUG_OSD
|
|
|
|
int l = strlen(Prompt);
|
|
|
|
int p = int(double(Width() - l) * Current / Total + 0.5);
|
|
|
|
Interface->Write(0, 0, Prompt, clrGreen);
|
|
|
|
Interface->Fill(l, 0, p, 1, clrGreen);
|
|
|
|
Interface->Fill(l + p, 0, Width() - l - p, 1, clrWhite);
|
|
|
|
#else
|
2002-05-18 14:03:22 +02:00
|
|
|
cVolumeBar VolumeBar(Width() * cOsd::CellWidth(), cOsd::LineHeight(), Current, Total, Prompt);
|
2002-03-09 17:11:49 +01:00
|
|
|
Interface->SetBitmap(0, 0, VolumeBar);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cDisplayVolume *cDisplayVolume::Create(void)
|
|
|
|
{
|
|
|
|
if (!displayVolume)
|
|
|
|
new cDisplayVolume;
|
|
|
|
return displayVolume;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayVolume::Process(eKeys Key)
|
|
|
|
{
|
|
|
|
if (displayVolume)
|
|
|
|
displayVolume->ProcessKey(Key);
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cDisplayVolume::ProcessKey(eKeys Key)
|
|
|
|
{
|
|
|
|
switch (Key) {
|
|
|
|
case kVolUp|k_Repeat:
|
|
|
|
case kVolUp:
|
|
|
|
case kVolDn|k_Repeat:
|
|
|
|
case kVolDn:
|
|
|
|
Show();
|
|
|
|
timeout = time_ms() + VOLUMETIMEOUT;
|
|
|
|
break;
|
|
|
|
case kMute:
|
2002-06-16 12:57:31 +02:00
|
|
|
if (cDevice::PrimaryDevice()->IsMute()) {
|
2002-03-09 17:11:49 +01:00
|
|
|
Show();
|
|
|
|
timeout = time_ms() + MUTETIMEOUT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
timeout = 0;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return time_ms() < timeout ? osContinue : osEnd;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2001-08-19 14:45:31 +02:00
|
|
|
eventInfo = 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);
|
|
|
|
Timers.Save();
|
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);
|
2002-06-16 12:57:31 +02:00
|
|
|
|
|
|
|
const char *Title = NULL;
|
|
|
|
const char *Subtitle = NULL;
|
|
|
|
const char *Summary = NULL;
|
|
|
|
if (GetEventInfo()) {
|
|
|
|
Title = eventInfo->GetTitle();
|
|
|
|
Subtitle = eventInfo->GetSubtitle();
|
|
|
|
Summary = eventInfo->GetExtendedDescription();
|
|
|
|
dsyslog("Title: '%s' Subtitle: '%s'", Title, Subtitle);
|
|
|
|
}
|
|
|
|
cRecording Recording(timer, Title, Subtitle, Summary);
|
|
|
|
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);
|
|
|
|
Timers.Save();
|
|
|
|
}
|
|
|
|
timer = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
cRecordingUserCommand::InvokeCommand(RUC_BEFORERECORDING, fileName);
|
2002-10-20 12:28:55 +02:00
|
|
|
const cChannel *ch = timer->Channel();
|
|
|
|
recorder = new cRecorder(fileName, ch->Ca(), timer->Priority(), ch->Vpid(), ch->Apid1(), ch->Apid2(), ch->Dpid1(), ch->Dpid2());
|
2002-06-22 13:45:53 +02:00
|
|
|
if (device->AttachReceiver(recorder)) {
|
2002-06-16 12:57:31 +02:00
|
|
|
Recording.WriteSummary();
|
2002-07-14 11:03:30 +02:00
|
|
|
cStatus::MsgRecording(device, Recording.Name());
|
2003-04-21 14:57:13 +02:00
|
|
|
if (!Timer && !cReplayControl::LastReplayed()) // an instant recording, maybe from cRecordControls::PauseLiveVideo()
|
|
|
|
cReplayControl::SetRecording(fileName, Recording.Name());
|
2001-06-02 10:47:40 +02:00
|
|
|
}
|
|
|
|
else
|
2002-06-16 12:57:31 +02:00
|
|
|
DELETENULL(recorder);
|
2000-04-30 10:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cRecordControl::~cRecordControl()
|
|
|
|
{
|
2000-04-30 11:15:16 +02:00
|
|
|
Stop(true);
|
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
|
|
|
|
|
2001-08-19 14:45:31 +02:00
|
|
|
bool cRecordControl::GetEventInfo(void)
|
|
|
|
{
|
2002-10-20 12:28:55 +02:00
|
|
|
const cChannel *channel = timer->Channel();
|
|
|
|
time_t Time = timer->Active() == taActInst ? 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++) {
|
|
|
|
{
|
2002-02-23 13:55:57 +01:00
|
|
|
cMutexLock MutexLock;
|
|
|
|
const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock);
|
2001-08-19 14:45:31 +02:00
|
|
|
if (Schedules) {
|
2002-11-10 15:50:21 +01:00
|
|
|
const cSchedule *Schedule = Schedules->GetSchedule(channel->GetChannelID());
|
2001-08-19 14:45:31 +02:00
|
|
|
if (Schedule) {
|
2001-10-28 13:53:44 +01:00
|
|
|
eventInfo = Schedule->GetEventAround(Time);
|
2001-08-19 14:45:31 +02:00
|
|
|
if (eventInfo) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2000-04-30 11:15:16 +02:00
|
|
|
void cRecordControl::Stop(bool KeepInstant)
|
|
|
|
{
|
|
|
|
if (timer) {
|
2002-06-16 12:57:31 +02:00
|
|
|
DELETENULL(recorder);
|
2000-04-30 11:15:16 +02:00
|
|
|
timer->SetRecording(false);
|
2002-08-25 10:59:49 +02:00
|
|
|
if ((IsInstant() && !KeepInstant) || (timer->IsSingleEvent() && timer->StopTime() <= time(NULL))) {
|
2002-05-13 16:35:49 +02:00
|
|
|
isyslog("deleting timer %d", timer->Index() + 1);
|
2000-04-30 11:15:16 +02:00
|
|
|
Timers.Del(timer);
|
|
|
|
Timers.Save();
|
|
|
|
}
|
|
|
|
timer = NULL;
|
2002-09-29 13:40:45 +02:00
|
|
|
cStatus::MsgRecording(device, NULL);
|
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 };
|
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
|
|
|
{
|
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) {
|
2002-09-06 14:10:17 +02:00
|
|
|
if (NeedsDetachReceivers)
|
2002-06-16 12:57:31 +02:00
|
|
|
Stop(device);
|
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
|
|
|
}
|
|
|
|
for (int i = 0; i < MAXRECORDCONTROLS; i++) {
|
2000-05-01 16:29:46 +02:00
|
|
|
if (!RecordControls[i]) {
|
2003-05-11 14:10:00 +02:00
|
|
|
RecordControls[i] = new cRecordControl(device, Timer, Pause);
|
2000-05-01 16:29:46 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-10-20 12:28:55 +02: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);
|
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)
|
|
|
|
{
|
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();
|
|
|
|
if (id && strcmp(id, InstantId) == 0)
|
|
|
|
RecordControls[i]->Stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
void cRecordControls::Stop(cDevice *Device)
|
2000-11-12 14:06:53 +01:00
|
|
|
{
|
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]) {
|
2002-06-16 12:57:31 +02:00
|
|
|
if (RecordControls[i]->Uses(Device)) {
|
|
|
|
isyslog("stopping recording on DVB device %d due to higher priority", Device->CardIndex() + 1);
|
2001-01-13 13:08:43 +01:00
|
|
|
RecordControls[i]->Stop(true);
|
2000-11-12 14:06:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-28 16:32:34 +01:00
|
|
|
bool cRecordControls::StopPrimary(bool DoIt)
|
|
|
|
{
|
2002-06-16 12:57:31 +02:00
|
|
|
if (cDevice::PrimaryDevice()->Receiving()) {
|
2002-09-04 17:26:02 +02:00
|
|
|
//XXX+ disabled for the moment - might become obsolete with DVB_DRIVER_VERSION >= 2002090101
|
|
|
|
cDevice *device = NULL;//XXX cDevice::GetDevice(cDevice::PrimaryDevice()->Ca(), 0);
|
2002-06-16 12:57:31 +02:00
|
|
|
if (device) {
|
2001-10-28 16:32:34 +01:00
|
|
|
if (DoIt)
|
2002-06-16 12:57:31 +02:00
|
|
|
Stop(cDevice::PrimaryDevice());
|
2001-10-28 16:32:34 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2003-04-21 14:57:13 +02:00
|
|
|
bool cRecordControls::PauseLiveVideo(void)
|
|
|
|
{
|
|
|
|
Interface->Open(Setup.OSDwidth, -1);
|
|
|
|
Interface->Status(tr("Pausing live video..."));
|
|
|
|
Interface->Flush();
|
|
|
|
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
|
|
|
|
Interface->Close();
|
|
|
|
rc->ProcessKey(kPause); // pause, allowing replay mode display
|
2003-05-29 09:47:31 +02:00
|
|
|
sleep(3); // allow recorded file to fill up enough to continue replaying
|
2003-04-21 14:57:13 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
Interface->Close();
|
|
|
|
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]) {
|
2001-09-01 15:04:14 +02:00
|
|
|
if (!RecordControls[i]->Process(t))
|
2000-05-01 16:29:46 +02:00
|
|
|
DELETENULL(RecordControls[i]);
|
|
|
|
}
|
|
|
|
}
|
2000-04-30 10:22:13 +02: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]);
|
|
|
|
}
|
|
|
|
|
2000-12-28 12:57:16 +01:00
|
|
|
// --- cProgressBar ----------------------------------------------------------
|
|
|
|
|
|
|
|
class cProgressBar : public cBitmap {
|
|
|
|
protected:
|
|
|
|
int total;
|
|
|
|
int Pos(int p) { return p * width / total; }
|
|
|
|
void Mark(int x, bool Start, bool Current);
|
|
|
|
public:
|
|
|
|
cProgressBar(int Width, int Height, int Current, int Total, const cMarks &Marks);
|
|
|
|
};
|
|
|
|
|
|
|
|
cProgressBar::cProgressBar(int Width, int Height, int Current, int Total, const cMarks &Marks)
|
2001-07-22 12:33:45 +02:00
|
|
|
:cBitmap(Width, Height, 2)
|
2000-12-28 12:57:16 +01:00
|
|
|
{
|
|
|
|
total = Total;
|
|
|
|
if (total > 0) {
|
|
|
|
int p = Pos(Current);
|
|
|
|
Fill(0, 0, p, Height - 1, clrGreen);
|
|
|
|
Fill(p + 1, 0, Width - 1, Height - 1, clrWhite);
|
|
|
|
bool Start = true;
|
|
|
|
for (const cMark *m = Marks.First(); m; m = Marks.Next(m)) {
|
|
|
|
int p1 = Pos(m->position);
|
|
|
|
if (Start) {
|
|
|
|
const cMark *m2 = Marks.Next(m);
|
|
|
|
int p2 = Pos(m2 ? m2->position : total);
|
|
|
|
int h = Height / 3;
|
|
|
|
Fill(p1, h, p2, Height - h, clrRed);
|
|
|
|
}
|
|
|
|
Mark(p1, Start, m->position == Current);
|
|
|
|
Start = !Start;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cProgressBar::Mark(int x, bool Start, bool Current)
|
|
|
|
{
|
|
|
|
Fill(x, 0, x, height - 1, clrBlack);
|
|
|
|
const int d = height / (Current ? 3 : 9);
|
|
|
|
for (int i = 0; i < d; i++) {
|
|
|
|
int h = Start ? i : height - 1 - i;
|
|
|
|
Fill(x - d + i, h, x + d - i, h, Current ? clrRed : clrBlack);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2001-09-14 14:06:43 +02:00
|
|
|
visible = modeOnly = shown = displayFrames = false;
|
2001-07-28 13:16:23 +02:00
|
|
|
lastCurrent = lastTotal = -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);
|
|
|
|
cStatus::MsgReplaying(this, Recording.Name());
|
2000-04-29 15:57:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cReplayControl::~cReplayControl()
|
|
|
|
{
|
|
|
|
Hide();
|
2002-06-16 13:26:00 +02:00
|
|
|
cStatus::MsgReplaying(this, NULL);
|
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) {
|
2000-10-08 12:24:30 +02:00
|
|
|
Interface->Close();
|
2001-09-21 16:07:22 +02:00
|
|
|
needsFastResponse = visible = false;
|
2001-10-28 10:21:01 +01:00
|
|
|
modeOnly = 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::DisplayAtBottom(const char *s)
|
2001-09-14 14:06:43 +02:00
|
|
|
{
|
2001-09-14 15:10:12 +02:00
|
|
|
if (s) {
|
2002-05-18 14:03:22 +02:00
|
|
|
int w = cOsd::WidthInCells(s);
|
2001-09-14 15:10:12 +02:00
|
|
|
int d = max(Width() - w, 0) / 2;
|
2002-03-16 11:38:27 +01:00
|
|
|
if (modeOnly) //XXX remove when displaying replay mode differently
|
|
|
|
Interface->Fill(0, -1, Interface->Width(), 1, clrTransparent); //XXX remove when displaying replay mode differently
|
2001-09-14 15:10:12 +02:00
|
|
|
Interface->Write(d, -1, s);
|
|
|
|
Interface->Flush();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Interface->Fill(12, 2, Width() - 22, 1, clrBackground);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cReplayControl::ShowMode(void)
|
|
|
|
{
|
|
|
|
if (Setup.ShowReplayMode && !timeSearchActive) {
|
2001-09-14 14:06:43 +02:00
|
|
|
bool Play, Forward;
|
|
|
|
int Speed;
|
2002-06-16 12:57:31 +02:00
|
|
|
if (GetReplayMode(Play, Forward, Speed)) {
|
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
|
|
|
// open small display
|
2002-03-16 11:38:27 +01:00
|
|
|
/*XXX change when displaying replay mode differently
|
2001-09-14 14:06:43 +02:00
|
|
|
Interface->Open(9, -1);
|
|
|
|
Interface->Clear();
|
2002-03-16 11:38:27 +01:00
|
|
|
XXX*/
|
|
|
|
Interface->Open(0, -1); //XXX remove when displaying replay mode differently
|
2001-09-14 14:06:43 +02:00
|
|
|
visible = modeOnly = true;
|
|
|
|
}
|
|
|
|
|
2001-09-21 16:24:06 +02:00
|
|
|
if (modeOnly && !timeoutShow && NormalPlay)
|
2001-09-21 16:01:45 +02:00
|
|
|
timeoutShow = time(NULL) + MODETIMEOUT;
|
2001-09-14 14:06:43 +02:00
|
|
|
const char *Mode;
|
|
|
|
if (Speed == -1) Mode = Play ? " > " : " || ";
|
|
|
|
else if (Play) Mode = Forward ? " X>> " : " <<X ";
|
|
|
|
else Mode = Forward ? " X|> " : " <|X ";
|
|
|
|
char buf[16];
|
|
|
|
strn0cpy(buf, Mode, sizeof(buf));
|
|
|
|
char *p = strchr(buf, 'X');
|
|
|
|
if (p)
|
|
|
|
*p = Speed > 0 ? '1' + Speed - 1 : ' ';
|
|
|
|
|
|
|
|
eDvbFont OldFont = Interface->SetFont(fontFix);
|
2001-09-14 15:10:12 +02:00
|
|
|
DisplayAtBottom(buf);
|
2001-09-14 14:06:43 +02:00
|
|
|
Interface->SetFont(OldFont);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
Interface->Open(Setup.OSDwidth, -3);
|
|
|
|
needsFastResponse = visible = true;
|
|
|
|
}
|
2000-12-09 11:13:00 +01:00
|
|
|
if (Initial) {
|
|
|
|
Interface->Clear();
|
|
|
|
if (title)
|
|
|
|
Interface->Write(0, 0, 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) {
|
|
|
|
Interface->Write(-7, 2, IndexToHMSF(Total));
|
2001-08-04 08:08:44 +02:00
|
|
|
if (!Initial)
|
|
|
|
Interface->Flush();
|
2001-07-28 13:16:23 +02:00
|
|
|
}
|
2001-08-04 08:08:44 +02:00
|
|
|
if (Current != lastCurrent || Total != lastTotal) {
|
2000-12-09 11:13:00 +01:00
|
|
|
#ifdef DEBUG_OSD
|
2001-07-28 13:16:23 +02:00
|
|
|
int p = Width() * Current / Total;
|
|
|
|
Interface->Fill(0, 1, p, 1, clrGreen);
|
|
|
|
Interface->Fill(p, 1, Width() - p, 1, clrWhite);
|
2000-12-09 11:13:00 +01:00
|
|
|
#else
|
2002-05-18 14:03:22 +02:00
|
|
|
cProgressBar ProgressBar(Width() * cOsd::CellWidth(), cOsd::LineHeight(), Current, Total, marks);
|
|
|
|
Interface->SetBitmap(0, cOsd::LineHeight(), ProgressBar);
|
2001-08-04 08:08:44 +02:00
|
|
|
if (!Initial)
|
|
|
|
Interface->Flush();
|
2000-12-09 11:13:00 +01:00
|
|
|
#endif
|
2001-07-28 13:16:23 +02:00
|
|
|
Interface->Write(0, 2, IndexToHMSF(Current, displayFrames));
|
|
|
|
Interface->Flush();
|
|
|
|
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);
|
2001-09-14 15:10:12 +02:00
|
|
|
DisplayAtBottom(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:
|
2002-03-31 15:26:18 +02:00
|
|
|
Seconds = min(Total - STAY_SECONDS_OFF_END, Seconds);
|
2002-10-27 14:32:06 +01:00
|
|
|
Goto(Seconds * FRAMESPERSEC, Key == kDown || Key == kPause);
|
2001-08-11 14:30:21 +02:00
|
|
|
timeSearchActive = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
timeSearchActive = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!timeSearchActive) {
|
|
|
|
if (timeSearchHide)
|
|
|
|
Hide();
|
|
|
|
else
|
2001-09-14 15:10:12 +02:00
|
|
|
DisplayAtBottom();
|
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);
|
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);
|
|
|
|
if (m)
|
2002-06-16 12:57:31 +02:00
|
|
|
Goto(m->position, true);
|
2001-07-22 13:46:07 +02:00
|
|
|
}
|
|
|
|
displayFrames = true;
|
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())
|
|
|
|
Interface->Error(tr("No editing marks defined!"));
|
|
|
|
else if (!cCutter::Start(fileName))
|
2001-10-27 12:04:36 +02:00
|
|
|
Interface->Error(tr("Can't start editing process!"));
|
|
|
|
else
|
|
|
|
Interface->Info(tr("Editing process started"));
|
|
|
|
}
|
2000-12-28 12:57:16 +01:00
|
|
|
else
|
2001-10-27 12:04:36 +02:00
|
|
|
Interface->Error(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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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:
|
|
|
|
//XXX should we do this only when the ProgressDisplay is on???
|
|
|
|
case kMarkToggle: MarkToggle(); break;
|
|
|
|
case kMarkJumpBack: MarkJump(false); break;
|
|
|
|
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();
|
2001-07-22 13:46:07 +02:00
|
|
|
if (DisplayedFrames && !displayFrames)
|
2001-08-11 15:08:14 +02:00
|
|
|
Interface->Fill(0, 2, 11, 1, clrBackground);
|
2000-04-29 15:57:42 +02:00
|
|
|
return osContinue;
|
2000-04-23 15:38:16 +02:00
|
|
|
}
|
|
|
|
|