2019-07-11 11:07:13 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "services/epgsearch.h"
|
|
|
|
#include "services/remotetimers.h"
|
|
|
|
|
|
|
|
#include "tools.h"
|
|
|
|
#include "setup.h"
|
|
|
|
|
|
|
|
#include "tvguideosd.h"
|
|
|
|
|
|
|
|
cTvGuideOsd::cTvGuideOsd(void) {
|
|
|
|
detailView = NULL;
|
|
|
|
detailViewActive = false;
|
|
|
|
activeGrid = NULL;
|
|
|
|
timeLine = NULL;
|
|
|
|
recMenuView = NULL;
|
|
|
|
channelJumper = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
cTvGuideOsd::~cTvGuideOsd() {
|
2019-07-11 14:34:31 +02:00
|
|
|
delete timeManager;
|
2019-07-11 11:07:13 +02:00
|
|
|
columns.Clear();
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.displayStatusHeader) {
|
2019-07-11 11:07:13 +02:00
|
|
|
delete statusHeader;
|
|
|
|
}
|
|
|
|
if (detailView)
|
|
|
|
delete detailView;
|
|
|
|
delete timeLine;
|
|
|
|
delete channelGroups;
|
|
|
|
delete footer;
|
|
|
|
delete recMenuView;
|
|
|
|
if (channelJumper)
|
|
|
|
delete channelJumper;
|
|
|
|
osdManager.deleteOsd();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::Show(void) {
|
|
|
|
int start = cTimeMs::Now();
|
|
|
|
bool ok = false;
|
|
|
|
ok = osdManager.setOsd();
|
|
|
|
if (ok) {
|
2019-07-11 11:28:11 +02:00
|
|
|
bool themeChanged = config.LoadTheme();
|
|
|
|
config.SetStyle();
|
|
|
|
config.setDynamicValues();
|
2019-07-11 11:07:13 +02:00
|
|
|
bool geoChanged = geoManager.SetGeometry(cOsd::OsdWidth(), cOsd::OsdHeight());
|
|
|
|
if (themeChanged || geoChanged) {
|
|
|
|
fontManager.DeleteFonts();
|
|
|
|
fontManager.SetFonts();
|
|
|
|
imgCache.Clear();
|
|
|
|
imgCache.CreateCache();
|
|
|
|
}
|
|
|
|
osdManager.setBackground();
|
2019-07-11 14:34:31 +02:00
|
|
|
timeManager = new cTimeManager();
|
|
|
|
timeManager->Now();
|
2019-07-11 11:07:13 +02:00
|
|
|
SwitchTimers.Load(AddDirectory(cPlugin::ConfigDirectory("epgsearch"), "epgsearchswitchtimers.conf"));
|
|
|
|
recMenuView = new cRecMenuView();
|
|
|
|
pRemoteTimers = cPluginManager::CallFirstService("RemoteTimers::RefreshTimers-v1.0", NULL);
|
|
|
|
if (pRemoteTimers) {
|
|
|
|
isyslog("tvguide: remotetimers-plugin is available");
|
|
|
|
}
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.useRemoteTimers && pRemoteTimers) {
|
2019-07-11 11:07:13 +02:00
|
|
|
cString errorMsg;
|
|
|
|
if (!pRemoteTimers->Service("RemoteTimers::RefreshTimers-v1.0", &errorMsg)) {
|
|
|
|
esyslog("tvguide: %s", *errorMsg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
drawOsd();
|
|
|
|
}
|
|
|
|
esyslog("tvguide: Rendering took %d ms", int(cTimeMs::Now()-start));
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::drawOsd() {
|
|
|
|
cPixmap::Lock();
|
2019-07-11 11:28:11 +02:00
|
|
|
int numBack = config.numGrids / 2;
|
2019-07-11 11:07:13 +02:00
|
|
|
int offset = 0;
|
|
|
|
const cChannel *newStartChannel;
|
|
|
|
#if VDRVERSNUM >= 20301
|
|
|
|
{
|
|
|
|
LOCK_CHANNELS_READ;
|
|
|
|
const cChannel *startChannel = Channels->GetByNumber(cDevice::CurrentChannel());
|
|
|
|
#else
|
|
|
|
cChannel *startChannel = Channels.GetByNumber(cDevice::CurrentChannel());
|
|
|
|
#endif
|
|
|
|
newStartChannel = startChannel;
|
|
|
|
#if VDRVERSNUM >= 20301
|
|
|
|
for (; newStartChannel ; newStartChannel = Channels->Prev(newStartChannel)) {
|
|
|
|
#else
|
|
|
|
for (; newStartChannel ; newStartChannel = Channels.Prev(newStartChannel)) {
|
|
|
|
#endif
|
|
|
|
if (newStartChannel && !newStartChannel->GroupSep()) {
|
|
|
|
offset++;
|
|
|
|
}
|
|
|
|
if (offset == numBack)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!newStartChannel)
|
|
|
|
#if VDRVERSNUM >= 20301
|
|
|
|
newStartChannel = Channels->First();
|
|
|
|
} //LOCK_CHANNELS_READ
|
|
|
|
#else
|
|
|
|
newStartChannel = Channels.First();
|
|
|
|
#endif
|
|
|
|
offset--;
|
|
|
|
if (offset < 0)
|
|
|
|
offset = 0;
|
|
|
|
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.displayStatusHeader) {
|
2019-07-11 11:07:13 +02:00
|
|
|
statusHeader = new cStatusHeader();
|
|
|
|
statusHeader->Draw();
|
|
|
|
statusHeader->ScaleVideo();
|
|
|
|
}
|
2019-07-11 14:34:31 +02:00
|
|
|
timeLine = new cTimeLine(timeManager);
|
2020-01-06 14:09:56 +01:00
|
|
|
timeLine->DrawDateViewer();
|
|
|
|
timeLine->DrawTimeline();
|
|
|
|
timeLine->DrawClock();
|
2019-07-11 11:07:13 +02:00
|
|
|
channelGroups = new cChannelGroups();
|
|
|
|
channelGroups->ReadChannelGroups();
|
|
|
|
footer = new cFooter(channelGroups);
|
|
|
|
recMenuView->SetFooter(footer);
|
|
|
|
footer->drawRedButton();
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.channelJumpMode == eNumJump) {
|
2019-07-11 11:07:13 +02:00
|
|
|
footer->drawGreenButton();
|
|
|
|
footer->drawYellowButton();
|
|
|
|
}
|
|
|
|
footer->drawBlueButton(false);
|
|
|
|
osdManager.flush();
|
|
|
|
readChannels(newStartChannel);
|
|
|
|
drawGridsChannelJump(offset);
|
|
|
|
osdManager.flush();
|
|
|
|
cPixmap::Unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::readChannels(const cChannel *channelStart) {
|
|
|
|
int i=0;
|
|
|
|
bool foundEnough = false;
|
|
|
|
columns.Clear();
|
|
|
|
if (!channelStart)
|
|
|
|
return;
|
|
|
|
#if VDRVERSNUM >= 20301
|
|
|
|
const cChannels *channels;
|
|
|
|
{
|
|
|
|
LOCK_CHANNELS_READ;
|
|
|
|
channels = Channels;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
cChannels *channels = &Channels;
|
|
|
|
#endif
|
|
|
|
for (const cChannel *channel = channelStart; channel; channel = channels->Next(channel)) {
|
|
|
|
if (!channel->GroupSep()) {
|
|
|
|
if (channelGroups->IsInLastGroup(channel)) {
|
|
|
|
break;
|
|
|
|
}
|
2019-07-11 14:34:31 +02:00
|
|
|
cChannelEpg *column = new cChannelEpg(i, channel, timeManager);
|
2019-07-11 11:07:13 +02:00
|
|
|
if (column->readGrids()) {
|
|
|
|
columns.Add(column);
|
|
|
|
i++;
|
|
|
|
} else {
|
|
|
|
delete column;
|
|
|
|
}
|
|
|
|
}
|
2019-07-11 11:28:11 +02:00
|
|
|
if (i == config.numGrids) {
|
2019-07-11 11:07:13 +02:00
|
|
|
foundEnough = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!foundEnough) {
|
|
|
|
int numCurrent = columns.Count();
|
2019-07-11 11:28:11 +02:00
|
|
|
int numBack = config.numGrids - numCurrent;
|
2019-07-11 11:07:13 +02:00
|
|
|
int newChannelNumber = columns.First()->getChannel()->Number() - numBack;
|
|
|
|
const cChannel *newStart = channels->GetByNumber(newChannelNumber);
|
|
|
|
readChannels(newStart);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::drawGridsChannelJump(int offset) {
|
|
|
|
if (columns.Count() == 0)
|
|
|
|
return;
|
|
|
|
activeGrid = columns.Get(offset)->getActive();
|
|
|
|
if (activeGrid)
|
|
|
|
activeGrid->SetActive();
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.displayStatusHeader) {
|
2019-07-11 11:07:13 +02:00
|
|
|
statusHeader->DrawInfoText(activeGrid);
|
|
|
|
}
|
2019-07-11 11:28:11 +02:00
|
|
|
if (activeGrid && (config.channelJumpMode == eGroupJump)) {
|
2019-07-11 11:07:13 +02:00
|
|
|
footer->UpdateGroupButtons(activeGrid->column->getChannel());
|
|
|
|
}
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.displayChannelGroups) {
|
2019-07-11 11:07:13 +02:00
|
|
|
channelGroups->DrawChannelGroups(columns.First()->getChannel(), columns.Last()->getChannel());
|
|
|
|
}
|
2019-07-11 12:06:18 +02:00
|
|
|
for (cChannelEpg *column = columns.First(); column; column = columns.Next(column)) {
|
2019-07-11 11:07:13 +02:00
|
|
|
column->createHeader();
|
|
|
|
column->drawGrids();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-03 11:30:41 +01:00
|
|
|
void cTvGuideOsd::drawGridsTimeJump(bool last) {
|
2019-07-11 11:07:13 +02:00
|
|
|
if (columns.Count() == 0)
|
|
|
|
return;
|
2019-07-11 12:06:18 +02:00
|
|
|
cChannelEpg *colActive = NULL;
|
2019-07-11 11:07:13 +02:00
|
|
|
if (activeGrid) {
|
|
|
|
colActive = activeGrid->column;
|
|
|
|
} else {
|
|
|
|
colActive = columns.First();
|
|
|
|
}
|
2019-07-11 12:06:18 +02:00
|
|
|
for (cChannelEpg *column = columns.First(); column; column = columns.Next(column)) {
|
2019-07-11 11:07:13 +02:00
|
|
|
column->clearGrids();
|
|
|
|
column->readGrids();
|
|
|
|
column->drawGrids();
|
|
|
|
}
|
2019-11-03 11:30:41 +01:00
|
|
|
activeGrid = colActive->getActive(last);
|
2019-07-11 11:07:13 +02:00
|
|
|
if (activeGrid) {
|
|
|
|
activeGrid->SetActive();
|
|
|
|
activeGrid->Draw();
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.displayStatusHeader) {
|
2019-07-11 11:07:13 +02:00
|
|
|
statusHeader->DrawInfoText(activeGrid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-11 15:06:07 +02:00
|
|
|
void cTvGuideOsd::setNextActiveGrid(cGridElement *next) {
|
2019-07-11 11:07:13 +02:00
|
|
|
if (!next || !activeGrid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
activeGrid->SetInActive();
|
|
|
|
activeGrid->Draw();
|
|
|
|
activeGrid = next;
|
|
|
|
activeGrid->SetActive();
|
|
|
|
activeGrid->Draw();
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.displayStatusHeader) {
|
2019-07-11 11:07:13 +02:00
|
|
|
statusHeader->DrawInfoText(activeGrid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::channelForward() {
|
2019-07-11 12:06:18 +02:00
|
|
|
cChannelEpg *colRight = columns.Next(activeGrid->column);
|
2019-07-11 11:07:13 +02:00
|
|
|
bool colAdded = false;
|
|
|
|
if (!colRight) {
|
|
|
|
const cChannel *channelRight = activeGrid->column->getChannel();
|
|
|
|
const cChannels *channels;
|
|
|
|
#if VDRVERSNUM >= 20301
|
|
|
|
{
|
|
|
|
LOCK_CHANNELS_READ;
|
|
|
|
channels = Channels;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
channels = &Channels;
|
|
|
|
#endif
|
|
|
|
while (channelRight = channels->Next(channelRight)) {
|
|
|
|
if (!channelRight->GroupSep()) {
|
|
|
|
if (channelGroups->IsInLastGroup(channelRight)) {
|
|
|
|
break;
|
|
|
|
}
|
2019-07-11 14:34:31 +02:00
|
|
|
colRight = new cChannelEpg(config.numGrids - 1, channelRight, timeManager);
|
2019-07-11 11:07:13 +02:00
|
|
|
if (colRight->readGrids()) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
delete colRight;
|
|
|
|
colRight = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (colRight) {
|
|
|
|
colAdded = true;
|
2019-07-11 11:28:11 +02:00
|
|
|
if (columns.Count() == config.numGrids) {
|
2019-07-11 12:06:18 +02:00
|
|
|
cChannelEpg *cFirst = columns.First();
|
2019-07-11 11:07:13 +02:00
|
|
|
columns.Del(cFirst);
|
|
|
|
}
|
2019-07-11 12:06:18 +02:00
|
|
|
for (cChannelEpg *column = columns.First(); column; column = columns.Next(column)) {
|
2019-07-11 11:07:13 +02:00
|
|
|
column->SetNum(column->GetNum() - 1);
|
|
|
|
column->drawHeader();
|
|
|
|
column->drawGrids();
|
|
|
|
}
|
|
|
|
columns.Add(colRight);
|
|
|
|
colRight->createHeader();
|
|
|
|
colRight->drawGrids();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (colRight) {
|
2019-07-11 15:06:07 +02:00
|
|
|
cGridElement *right = colRight->getNeighbor(activeGrid);
|
2019-07-11 11:07:13 +02:00
|
|
|
if (right) {
|
|
|
|
setNextActiveGrid(right);
|
|
|
|
}
|
|
|
|
}
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.displayChannelGroups && colAdded) {
|
2019-07-11 11:07:13 +02:00
|
|
|
channelGroups->DrawChannelGroups(columns.First()->getChannel(), columns.Last()->getChannel());
|
|
|
|
}
|
2019-07-11 11:28:11 +02:00
|
|
|
if (activeGrid && (config.channelJumpMode == eGroupJump)) {
|
2019-07-11 11:07:13 +02:00
|
|
|
footer->UpdateGroupButtons(activeGrid->column->getChannel());
|
|
|
|
}
|
|
|
|
osdManager.flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::channelBack() {
|
2019-07-11 12:06:18 +02:00
|
|
|
cChannelEpg *colLeft = columns.Prev(activeGrid->column);
|
2019-07-11 11:07:13 +02:00
|
|
|
bool colAdded = false;
|
|
|
|
if (!colLeft) {
|
|
|
|
const cChannel *channelLeft = activeGrid->column->getChannel();
|
|
|
|
const cChannels *channels;
|
|
|
|
#if VDRVERSNUM >= 20301
|
|
|
|
{
|
|
|
|
LOCK_CHANNELS_READ;
|
|
|
|
channels = Channels;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
channels = &Channels;
|
|
|
|
#endif
|
|
|
|
while (channelLeft = channels->Prev(channelLeft)) {
|
|
|
|
if (!channelLeft->GroupSep()) {
|
2019-07-11 14:34:31 +02:00
|
|
|
colLeft = new cChannelEpg(0, channelLeft, timeManager);
|
2019-07-11 11:07:13 +02:00
|
|
|
if (colLeft->readGrids()) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
delete colLeft;
|
|
|
|
colLeft = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (colLeft) {
|
|
|
|
colAdded = true;
|
2019-07-11 11:28:11 +02:00
|
|
|
if (columns.Count() == config.numGrids) {
|
2019-07-11 12:06:18 +02:00
|
|
|
cChannelEpg *cLast = columns.Last();
|
2019-07-11 11:07:13 +02:00
|
|
|
columns.Del(cLast);
|
|
|
|
}
|
2019-07-11 12:06:18 +02:00
|
|
|
for (cChannelEpg *column = columns.First(); column; column = columns.Next(column)) {
|
2019-07-11 11:07:13 +02:00
|
|
|
column->SetNum(column->GetNum() + 1);
|
|
|
|
column->drawHeader();
|
|
|
|
column->drawGrids();
|
|
|
|
}
|
|
|
|
columns.Ins(colLeft, columns.First());
|
|
|
|
colLeft->createHeader();
|
|
|
|
colLeft->drawGrids();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (colLeft) {
|
2019-07-11 15:06:07 +02:00
|
|
|
cGridElement *left = colLeft->getNeighbor(activeGrid);
|
2019-07-11 11:07:13 +02:00
|
|
|
if (left) {
|
|
|
|
setNextActiveGrid(left);
|
|
|
|
}
|
|
|
|
}
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.displayChannelGroups && colAdded) {
|
2019-07-11 11:07:13 +02:00
|
|
|
channelGroups->DrawChannelGroups(columns.First()->getChannel(), columns.Last()->getChannel());
|
|
|
|
}
|
|
|
|
|
2019-07-11 11:28:11 +02:00
|
|
|
if (activeGrid && (config.channelJumpMode == eGroupJump)) {
|
2019-07-11 11:07:13 +02:00
|
|
|
footer->UpdateGroupButtons(activeGrid->column->getChannel());
|
|
|
|
}
|
|
|
|
osdManager.flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::timeForward() {
|
|
|
|
bool actionDone = false;
|
2019-10-13 12:16:34 +02:00
|
|
|
if ((timeManager->GetEnd() - activeGrid->EndTime())/60 < 30 ) {
|
2019-07-11 11:07:13 +02:00
|
|
|
ScrollForward();
|
|
|
|
actionDone = true;
|
|
|
|
}
|
2019-07-11 15:06:07 +02:00
|
|
|
cGridElement *next = activeGrid->column->getNext(activeGrid);
|
2019-07-11 11:07:13 +02:00
|
|
|
if (next) {
|
2019-07-11 14:34:31 +02:00
|
|
|
if ( (next->EndTime() < timeManager->GetEnd())
|
|
|
|
|| ( (timeManager->GetEnd() - next->StartTime())/60 > 30 ) ) {
|
2019-07-11 11:07:13 +02:00
|
|
|
setNextActiveGrid(next);
|
|
|
|
actionDone = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!actionDone) {
|
|
|
|
ScrollForward();
|
|
|
|
}
|
|
|
|
osdManager.flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::ScrollForward() {
|
2019-07-11 14:34:31 +02:00
|
|
|
timeManager->AddStep(config.stepMinutes);
|
2019-11-03 11:30:41 +01:00
|
|
|
if (config.useHWAccel) {
|
|
|
|
drawGridsTimeJump(true);
|
2020-01-06 14:09:56 +01:00
|
|
|
timeLine->DrawDateViewer();
|
|
|
|
timeLine->DrawClock();
|
|
|
|
timeLine->DrawTimeline();
|
2019-11-03 11:30:41 +01:00
|
|
|
} else {
|
2020-01-06 14:09:56 +01:00
|
|
|
timeLine->DrawDateViewer();
|
|
|
|
timeLine->DrawTimeline();
|
2019-11-03 11:30:41 +01:00
|
|
|
for (cChannelEpg *column = columns.First(); column; column = columns.Next(column)) {
|
|
|
|
column->AddNewGridsAtEnd();
|
|
|
|
column->ClearOutdatedStart();
|
|
|
|
column->drawGrids();
|
|
|
|
}
|
2019-07-11 11:07:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::timeBack() {
|
|
|
|
bool actionDone = false;
|
2019-10-13 12:16:34 +02:00
|
|
|
if ((activeGrid->StartTime() - timeManager->GetStart())/60 < 30 ) {
|
2019-07-11 11:07:13 +02:00
|
|
|
ScrollBack();
|
|
|
|
actionDone = true;
|
|
|
|
}
|
2019-07-11 15:06:07 +02:00
|
|
|
cGridElement *prev = activeGrid->column->getPrev(activeGrid);
|
2019-07-11 11:07:13 +02:00
|
|
|
if (prev) {
|
2019-07-11 14:34:31 +02:00
|
|
|
if ( (prev->StartTime() > timeManager->GetStart())
|
|
|
|
|| ( (prev->EndTime() - timeManager->GetStart())/60 > 30 )
|
2019-07-11 11:07:13 +02:00
|
|
|
|| ( prev->isFirst()) ) {
|
|
|
|
setNextActiveGrid(prev);
|
|
|
|
actionDone = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!actionDone) {
|
|
|
|
ScrollBack();
|
|
|
|
}
|
|
|
|
osdManager.flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::ScrollBack() {
|
2020-01-06 12:51:49 +01:00
|
|
|
timeManager->DelStep(config.stepMinutes);
|
2019-11-03 11:30:41 +01:00
|
|
|
if (config.useHWAccel) {
|
|
|
|
drawGridsTimeJump();
|
2020-01-06 14:09:56 +01:00
|
|
|
timeLine->DrawDateViewer();
|
|
|
|
timeLine->DrawClock();
|
|
|
|
timeLine->DrawTimeline();
|
2019-11-03 11:30:41 +01:00
|
|
|
} else {
|
2020-01-06 14:09:56 +01:00
|
|
|
timeLine->DrawDateViewer();
|
|
|
|
timeLine->DrawTimeline();
|
2019-11-03 11:30:41 +01:00
|
|
|
for (cChannelEpg *column = columns.First(); column; column = columns.Next(column)) {
|
|
|
|
column->AddNewGridsAtStart();
|
|
|
|
column->ClearOutdatedEnd();
|
|
|
|
column->drawGrids();
|
|
|
|
}
|
|
|
|
}
|
2019-07-11 11:07:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::processKeyUp() {
|
|
|
|
if (!activeGrid) {
|
|
|
|
return;
|
|
|
|
}
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.displayMode == eVertical) {
|
2019-07-11 11:07:13 +02:00
|
|
|
timeBack();
|
2019-07-11 11:28:11 +02:00
|
|
|
} else if (config.displayMode == eHorizontal) {
|
2019-07-11 11:07:13 +02:00
|
|
|
channelBack();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::processKeyDown() {
|
|
|
|
if (!activeGrid) {
|
|
|
|
return;
|
|
|
|
}
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.displayMode == eVertical) {
|
2019-07-11 11:07:13 +02:00
|
|
|
timeForward();
|
2019-07-11 11:28:11 +02:00
|
|
|
} else if (config.displayMode == eHorizontal) {
|
2019-07-11 11:07:13 +02:00
|
|
|
channelForward();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::processKeyLeft() {
|
|
|
|
if (activeGrid == NULL)
|
|
|
|
return;
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.displayMode == eVertical) {
|
2019-07-11 11:07:13 +02:00
|
|
|
channelBack();
|
2019-07-11 11:28:11 +02:00
|
|
|
} else if (config.displayMode == eHorizontal) {
|
2019-07-11 11:07:13 +02:00
|
|
|
timeBack();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::processKeyRight() {
|
|
|
|
if (activeGrid == NULL)
|
|
|
|
return;
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.displayMode == eVertical) {
|
2019-07-11 11:07:13 +02:00
|
|
|
channelForward();
|
2019-07-11 11:28:11 +02:00
|
|
|
} else if (config.displayMode == eHorizontal) {
|
2019-07-11 11:07:13 +02:00
|
|
|
timeForward();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::processKeyRed() {
|
|
|
|
if ((activeGrid == NULL) || activeGrid->isDummy())
|
|
|
|
return;
|
|
|
|
recMenuView->Start(activeGrid->GetEvent());
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::processKeyGreen() {
|
|
|
|
if (activeGrid == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const cChannel *currentChannel = activeGrid->column->getChannel();
|
|
|
|
const cChannel *firstChannel = columns.First()->getChannel();
|
|
|
|
int currentCol = activeGrid->column->GetNum();
|
|
|
|
const cChannel *prev = NULL;
|
|
|
|
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.channelJumpMode == eGroupJump) {
|
2019-07-11 11:07:13 +02:00
|
|
|
int prevNum = channelGroups->GetPrevGroupChannelNumber(currentChannel);
|
|
|
|
if (prevNum) {
|
|
|
|
#if VDRVERSNUM >= 20301
|
|
|
|
LOCK_CHANNELS_READ;
|
|
|
|
prev = Channels->GetByNumber(prevNum);
|
|
|
|
#else
|
|
|
|
prev = Channels.GetByNumber(prevNum);
|
|
|
|
#endif
|
|
|
|
}
|
2019-07-11 11:28:11 +02:00
|
|
|
} else if (config.channelJumpMode == eNumJump) {
|
|
|
|
int i = config.jumpChannels + 1;
|
2019-07-11 11:07:13 +02:00
|
|
|
#if VDRVERSNUM >= 20301
|
|
|
|
LOCK_CHANNELS_READ;
|
|
|
|
for (const cChannel *channel = firstChannel; channel; channel = Channels->Prev(channel)) {
|
|
|
|
#else
|
|
|
|
for (const cChannel *channel = firstChannel; channel; channel = Channels.Prev(channel)) {
|
|
|
|
#endif
|
|
|
|
if (!channel->GroupSep()) {
|
|
|
|
prev = channel;
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
if (i == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (prev) {
|
|
|
|
readChannels(prev);
|
|
|
|
if (columns.Count() > 0) {
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.channelJumpMode == eGroupJump)
|
2019-07-11 11:07:13 +02:00
|
|
|
drawGridsChannelJump();
|
|
|
|
else
|
|
|
|
drawGridsChannelJump(currentCol);
|
|
|
|
}
|
|
|
|
osdManager.flush();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::processKeyYellow() {
|
|
|
|
if (activeGrid == NULL)
|
|
|
|
return;
|
|
|
|
const cChannel *currentChannel = activeGrid->column->getChannel();
|
|
|
|
int currentCol = activeGrid->column->GetNum();
|
|
|
|
const cChannel *firstChannel = columns.First()->getChannel();
|
|
|
|
const cChannel *next = NULL;
|
|
|
|
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.channelJumpMode == eGroupJump) {
|
2019-07-11 11:07:13 +02:00
|
|
|
int nextNum = channelGroups->GetNextGroupChannelNumber(currentChannel);
|
|
|
|
if (nextNum) {
|
|
|
|
#if VDRVERSNUM >= 20301
|
|
|
|
LOCK_CHANNELS_READ;
|
|
|
|
next = Channels->GetByNumber(nextNum);
|
|
|
|
#else
|
|
|
|
next = Channels.GetByNumber(nextNum);
|
|
|
|
#endif
|
|
|
|
}
|
2019-07-11 11:28:11 +02:00
|
|
|
} else if (config.channelJumpMode == eNumJump) {
|
2019-07-11 11:07:13 +02:00
|
|
|
int i=0;
|
|
|
|
#if VDRVERSNUM >= 20301
|
|
|
|
LOCK_CHANNELS_READ;
|
|
|
|
for (const cChannel *channel = firstChannel; channel; channel = Channels->Next(channel)) {
|
|
|
|
#else
|
|
|
|
for (const cChannel *channel = firstChannel; channel; channel = Channels.Next(channel)) {
|
|
|
|
#endif
|
|
|
|
if (channelGroups->IsInLastGroup(channel)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!channel->GroupSep()) {
|
|
|
|
next = channel;
|
|
|
|
i++;
|
|
|
|
}
|
2019-07-11 11:28:11 +02:00
|
|
|
if (i == (config.jumpChannels+1)) {
|
2019-07-11 11:07:13 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (next) {
|
|
|
|
readChannels(next);
|
|
|
|
if (columns.Count() > 0) {
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.channelJumpMode == eGroupJump)
|
2019-07-11 11:07:13 +02:00
|
|
|
drawGridsChannelJump();
|
|
|
|
else
|
|
|
|
drawGridsChannelJump(currentCol);
|
|
|
|
}
|
|
|
|
osdManager.flush();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cTvGuideOsd::processKeyBlue(bool *alreadyUnlocked) {
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.blueKeyMode == eBlueKeySwitch) {
|
2019-07-11 11:07:13 +02:00
|
|
|
return ChannelSwitch(alreadyUnlocked);
|
2019-07-11 11:28:11 +02:00
|
|
|
} else if (config.blueKeyMode == eBlueKeyEPG) {
|
2019-07-11 11:07:13 +02:00
|
|
|
DetailedEPG();
|
2019-07-11 11:28:11 +02:00
|
|
|
} else if (config.blueKeyMode == eBlueKeyFavorites) {
|
2019-07-11 11:07:13 +02:00
|
|
|
recMenuView->StartFavorites();
|
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cTvGuideOsd::processKeyOk(bool *alreadyUnlocked) {
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.blueKeyMode == eBlueKeySwitch) {
|
2019-07-11 11:07:13 +02:00
|
|
|
DetailedEPG();
|
2019-07-11 11:28:11 +02:00
|
|
|
} else if (config.blueKeyMode == eBlueKeyEPG) {
|
2019-07-11 11:07:13 +02:00
|
|
|
return ChannelSwitch(alreadyUnlocked);
|
2019-07-11 11:28:11 +02:00
|
|
|
} else if (config.blueKeyMode == eBlueKeyFavorites) {
|
2019-07-11 11:07:13 +02:00
|
|
|
DetailedEPG();
|
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cTvGuideOsd::ChannelSwitch(bool *alreadyUnlocked) {
|
|
|
|
if (activeGrid == NULL)
|
|
|
|
return osContinue;
|
|
|
|
const cChannel *currentChannel = activeGrid->column->getChannel();
|
|
|
|
if (currentChannel) {
|
|
|
|
cPixmap::Unlock();
|
|
|
|
*alreadyUnlocked = true;
|
|
|
|
cDevice::PrimaryDevice()->SwitchChannel(currentChannel, true);
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.closeOnSwitch) {
|
2019-07-11 11:07:13 +02:00
|
|
|
if (detailView) {
|
|
|
|
delete detailView;
|
|
|
|
detailView = NULL;
|
|
|
|
detailViewActive = false;
|
|
|
|
}
|
|
|
|
return osEnd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::DetailedEPG() {
|
|
|
|
if (!activeGrid->isDummy()) {
|
|
|
|
detailViewActive = true;
|
|
|
|
detailView = new cDetailView(activeGrid->GetEvent(), footer);
|
|
|
|
footer->SetDetailedViewMode();
|
|
|
|
osdManager.flush();
|
|
|
|
detailView->Start();
|
|
|
|
osdManager.flush();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::processNumKey(int numKey) {
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.numkeyMode == 0) {
|
2019-07-11 11:07:13 +02:00
|
|
|
//timely jumps with 1,3,4,6,7,9
|
|
|
|
TimeJump(numKey);
|
|
|
|
} else {
|
|
|
|
//jump to specific channel
|
|
|
|
ChannelJump(numKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::TimeJump(int mode) {
|
|
|
|
switch (mode) {
|
|
|
|
case 1: {
|
2020-01-09 14:06:59 +01:00
|
|
|
timeManager->DelStep(((config.displayMode == eVertical) ? config.bigStepHours : config.bigStepHoursHorizontal) * 60);
|
2020-01-06 12:51:49 +01:00
|
|
|
}
|
2019-07-11 11:07:13 +02:00
|
|
|
break;
|
|
|
|
case 3: {
|
2020-01-09 14:06:59 +01:00
|
|
|
timeManager->AddStep(((config.displayMode == eVertical) ? config.bigStepHours : config.bigStepHoursHorizontal) * 60);
|
2020-01-06 12:51:49 +01:00
|
|
|
}
|
2019-07-11 11:07:13 +02:00
|
|
|
break;
|
|
|
|
case 4: {
|
2020-01-09 14:06:59 +01:00
|
|
|
timeManager->DelStep(((config.displayMode == eVertical) ? config.hugeStepHours : config.hugeStepHoursHorizontal) * 60);
|
2020-01-06 12:51:49 +01:00
|
|
|
}
|
2019-07-11 11:07:13 +02:00
|
|
|
break;
|
|
|
|
case 6: {
|
2020-01-09 14:06:59 +01:00
|
|
|
timeManager->AddStep(((config.displayMode == eVertical) ? config.hugeStepHours : config.hugeStepHoursHorizontal) * 60);
|
2020-01-06 12:51:49 +01:00
|
|
|
}
|
2019-07-11 11:07:13 +02:00
|
|
|
break;
|
|
|
|
case 7: {
|
2019-07-11 14:34:31 +02:00
|
|
|
cTimeManager primeChecker;
|
2019-07-11 11:07:13 +02:00
|
|
|
primeChecker.Now();
|
2019-07-11 14:34:31 +02:00
|
|
|
time_t prevPrime = primeChecker.getPrevPrimetime(timeManager->GetStart());
|
2019-07-11 11:07:13 +02:00
|
|
|
if (primeChecker.tooFarInPast(prevPrime))
|
|
|
|
return;
|
2019-07-11 14:34:31 +02:00
|
|
|
timeManager->SetTime(prevPrime);
|
2020-01-06 12:51:49 +01:00
|
|
|
}
|
2019-07-11 11:07:13 +02:00
|
|
|
break;
|
|
|
|
case 9: {
|
2019-07-11 14:34:31 +02:00
|
|
|
cTimeManager primeChecker;
|
|
|
|
time_t nextPrime = primeChecker.getNextPrimetime(timeManager->GetStart());
|
|
|
|
timeManager->SetTime(nextPrime);
|
2020-01-06 12:51:49 +01:00
|
|
|
}
|
2019-07-11 11:07:13 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
drawGridsTimeJump();
|
2020-01-06 14:09:56 +01:00
|
|
|
timeLine->DrawDateViewer();
|
|
|
|
timeLine->DrawClock();
|
|
|
|
timeLine->DrawTimeline();
|
2019-07-11 11:07:13 +02:00
|
|
|
osdManager.flush();
|
|
|
|
}
|
|
|
|
|
2019-07-11 14:14:51 +02:00
|
|
|
int cTvGuideOsd::GetLastValidChannel(void) {
|
|
|
|
return channelGroups->GetLastValidChannel();
|
|
|
|
}
|
|
|
|
|
2019-07-11 11:07:13 +02:00
|
|
|
void cTvGuideOsd::ChannelJump(int num) {
|
|
|
|
if (!channelJumper) {
|
2019-07-11 14:14:51 +02:00
|
|
|
int lastValidChannel = GetLastValidChannel();
|
|
|
|
channelJumper = new cChannelJump(channelGroups, lastValidChannel);
|
2019-07-11 11:07:13 +02:00
|
|
|
}
|
|
|
|
channelJumper->Set(num);
|
|
|
|
channelJumper->DrawText();
|
|
|
|
osdManager.flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::CheckTimeout(void) {
|
|
|
|
if (!channelJumper)
|
|
|
|
return;
|
|
|
|
if (channelJumper->TimeOut()) {
|
|
|
|
int newChannelNum = channelJumper->GetChannel();
|
|
|
|
delete channelJumper;
|
|
|
|
channelJumper = NULL;
|
|
|
|
const cChannel *newChannel;
|
|
|
|
#if VDRVERSNUM >= 20301
|
|
|
|
{
|
|
|
|
LOCK_CHANNELS_READ;
|
|
|
|
newChannel = Channels->GetByNumber(newChannelNum);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
newChannel = Channels.GetByNumber(newChannelNum);
|
|
|
|
#endif
|
|
|
|
if (newChannel) {
|
|
|
|
readChannels(newChannel);
|
|
|
|
if (columns.Count() > 0) {
|
|
|
|
drawGridsChannelJump();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
osdManager.flush();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::SetTimers() {
|
2019-07-11 12:06:18 +02:00
|
|
|
for (cChannelEpg *column = columns.First(); column; column = columns.Next(column)) {
|
2019-07-11 11:07:13 +02:00
|
|
|
column->SetTimers();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cTvGuideOsd::ProcessKey(eKeys Key) {
|
|
|
|
eOSState state = osContinue;
|
|
|
|
cPixmap::Lock();
|
|
|
|
bool alreadyUnlocked = false;
|
|
|
|
if (recMenuView->isActive()) {
|
|
|
|
state = recMenuView->ProcessKey(Key);
|
|
|
|
if (state == osEnd) {
|
|
|
|
SetTimers();
|
|
|
|
osdManager.flush();
|
|
|
|
}
|
|
|
|
state = osContinue;
|
|
|
|
} else if (detailViewActive) {
|
|
|
|
if ((Key & ~k_Repeat) == kRed) {
|
|
|
|
delete detailView;
|
|
|
|
detailView = NULL;
|
|
|
|
detailViewActive = false;
|
|
|
|
processKeyRed();
|
|
|
|
} else if ((Key & ~k_Repeat) == kBlue) {
|
|
|
|
delete detailView;
|
|
|
|
detailView = NULL;
|
|
|
|
detailViewActive = false;
|
2019-07-11 11:28:11 +02:00
|
|
|
if ((config.blueKeyMode == eBlueKeySwitch) || (config.blueKeyMode == eBlueKeyFavorites)) {
|
2019-07-11 11:07:13 +02:00
|
|
|
state = ChannelSwitch(&alreadyUnlocked);
|
|
|
|
} else {
|
|
|
|
osdManager.flush();
|
|
|
|
state = osContinue;
|
|
|
|
}
|
2019-07-11 11:28:11 +02:00
|
|
|
} else if ((Key & ~k_Repeat) == kOk && (config.blueKeyMode == eBlueKeyEPG)) {
|
2019-07-11 11:07:13 +02:00
|
|
|
delete detailView;
|
|
|
|
detailView = NULL;
|
|
|
|
detailViewActive = false;
|
|
|
|
state = ChannelSwitch(&alreadyUnlocked);
|
|
|
|
} else {
|
|
|
|
state = detailView->ProcessKey(Key);
|
|
|
|
if (state == osEnd) {
|
|
|
|
delete detailView;
|
|
|
|
detailView = NULL;
|
|
|
|
detailViewActive = false;
|
|
|
|
osdManager.flush();
|
|
|
|
state = osContinue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (Key & ~k_Repeat) {
|
|
|
|
case kUp: processKeyUp(); break;
|
|
|
|
case kDown: processKeyDown(); break;
|
|
|
|
case kLeft: processKeyLeft(); break;
|
|
|
|
case kRight: processKeyRight(); break;
|
|
|
|
case kRed: processKeyRed(); break;
|
|
|
|
case kGreen: processKeyGreen(); break;
|
|
|
|
case kYellow: processKeyYellow(); break;
|
|
|
|
case kBlue: state = processKeyBlue(&alreadyUnlocked); break;
|
|
|
|
case kOk: state = processKeyOk(&alreadyUnlocked); break;
|
2020-01-06 12:51:49 +01:00
|
|
|
case kBack: state = osEnd; break;
|
2019-07-11 11:07:13 +02:00
|
|
|
case k0 ... k9: processNumKey(Key - k0); break;
|
2020-01-06 12:51:49 +01:00
|
|
|
case kFastRew: TimeJump(1); break; // Doesnt work, if used from timeshiftmode
|
|
|
|
case kFastFwd: TimeJump(3); break;
|
|
|
|
case kPrev: TimeJump(4); break;
|
|
|
|
case kNext: TimeJump(6); break;
|
2019-07-11 11:07:13 +02:00
|
|
|
case kNone: if (channelJumper) CheckTimeout(); break;
|
|
|
|
default: break;
|
|
|
|
}
|
2020-01-06 14:09:56 +01:00
|
|
|
if (timeLine->DrawClock()) {
|
2019-10-13 12:16:34 +02:00
|
|
|
osdManager.flush();
|
2020-01-06 14:09:56 +01:00
|
|
|
}
|
2019-07-11 11:07:13 +02:00
|
|
|
}
|
|
|
|
if (!alreadyUnlocked) {
|
|
|
|
cPixmap::Unlock();
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTvGuideOsd::dump() {
|
|
|
|
esyslog("tvguide: ------Dumping Content---------");
|
|
|
|
activeGrid->debug();
|
|
|
|
// int i=1;
|
2019-07-11 12:06:18 +02:00
|
|
|
for (cChannelEpg *col = columns.First(); col; col = columns.Next(col)) {
|
2019-07-11 11:07:13 +02:00
|
|
|
col->dumpGrids();
|
|
|
|
}
|
|
|
|
}
|