diff options
Diffstat (limited to 'menu.c')
-rw-r--r-- | menu.c | 190 |
1 files changed, 96 insertions, 94 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 1.274 2003/10/19 15:13:05 kls Exp $ + * $Id: menu.c 1.275 2003/12/22 10:05:14 kls Exp $ */ #include "menu.h" @@ -16,7 +16,6 @@ #include "channels.h" #include "config.h" #include "cutter.h" -#include "eit.h" #include "i18n.h" #include "menuitems.h" #include "plugin.h" @@ -69,7 +68,7 @@ eOSState cMenuEditChanItem::ProcessKey(eKeys Key) case kLeft|k_Repeat: case kLeft: delta = -1; case kRight|k_Repeat: - case kRight: + case kRight: { cChannel *channel = Channels.GetByNumber(*value + delta, delta); if (channel) { @@ -458,7 +457,7 @@ eOSState cMenuEditSrcItem::ProcessKey(eKeys Key) } } else if (NORMALKEY(Key) == kRight) { - if (source) { + if (source) { if (source->Next()) source = (cSource *)source->Next(); } @@ -904,7 +903,7 @@ eOSState cMenuEditTimer::ProcessKey(eKeys Key) if (state == osUnknown) { switch (Key) { - case kOk: { + case kOk: { cChannel *ch = Channels.GetByNumber(channel); if (ch) data.channel = ch; @@ -1128,29 +1127,29 @@ eOSState cMenuTimers::ProcessKey(eKeys Key) class cMenuEvent : public cOsdMenu { private: - const cEventInfo *eventInfo; + const cEvent *event; public: - cMenuEvent(const cEventInfo *EventInfo, bool CanSwitch = false); + cMenuEvent(const cEvent *Event, bool CanSwitch = false); cMenuEvent(bool Now); virtual eOSState ProcessKey(eKeys Key); }; -cMenuEvent::cMenuEvent(const cEventInfo *EventInfo, bool CanSwitch) +cMenuEvent::cMenuEvent(const cEvent *Event, bool CanSwitch) :cOsdMenu(tr("Event")) { - eventInfo = EventInfo; - if (eventInfo) { - cChannel *channel = Channels.GetByChannelID(eventInfo->GetChannelID(), true); + event = Event; + if (event) { + cChannel *channel = Channels.GetByChannelID(event->ChannelID(), true); if (channel) { char *buffer; - asprintf(&buffer, "%-17.*s\t%.*s %s - %s", 17, channel->Name(), 5, eventInfo->GetDate(), eventInfo->GetTimeString(), eventInfo->GetEndTimeString()); + asprintf(&buffer, "%-17.*s\t%.*s %s - %s", 17, channel->Name(), 5, event->GetDateString(), event->GetTimeString(), event->GetEndTimeString()); SetTitle(buffer, false); free(buffer); int Line = 2; cMenuTextItem *item; - const char *Title = eventInfo->GetTitle(); - const char *Subtitle = eventInfo->GetSubtitle(); - const char *ExtendedDescription = eventInfo->GetExtendedDescription(); + const char *Title = event->Title(); + const char *Subtitle = event->ShortText(); + const char *ExtendedDescription = event->Description(); if (!isempty(Title)) { Add(item = new cMenuTextItem(Title, 1, Line, Setup.OSDwidth - 2, -1, clrCyan)); Line += item->Height() + 1; @@ -1185,16 +1184,16 @@ eOSState cMenuEvent::ProcessKey(eKeys Key) class cMenuWhatsOnItem : public cOsdItem { public: - const cEventInfo *eventInfo; - cMenuWhatsOnItem(const cEventInfo *EventInfo); + const cEvent *event; + cMenuWhatsOnItem(const cEvent *Event); }; -cMenuWhatsOnItem::cMenuWhatsOnItem(const cEventInfo *EventInfo) +cMenuWhatsOnItem::cMenuWhatsOnItem(const cEvent *Event) { - eventInfo = EventInfo; + event = Event; char *buffer = NULL; - cChannel *channel = Channels.GetByNumber(eventInfo->GetChannelNumber()); - asprintf(&buffer, "%d\t%.*s\t%.*s\t%s", eventInfo->GetChannelNumber(), 6, channel ? channel->Name() : "???", 5, eventInfo->GetTimeString(), eventInfo->GetTitle()); + cChannel *channel = Channels.GetByNumber(event->ChannelNumber()); + asprintf(&buffer, "%d\t%.*s\t%.*s\t%s", event->ChannelNumber(), 6, channel ? channel->Name() : "???", 5, event->GetTimeString(), event->Title()); SetText(buffer, false); } @@ -1205,36 +1204,36 @@ private: eOSState Record(void); eOSState Switch(void); static int currentChannel; - static const cEventInfo *scheduleEventInfo; + static const cEvent *scheduleEvent; public: cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentChannelNr); static int CurrentChannel(void) { return currentChannel; } static void SetCurrentChannel(int ChannelNr) { currentChannel = ChannelNr; } - static const cEventInfo *ScheduleEventInfo(void); + static const cEvent *ScheduleEvent(void); virtual eOSState ProcessKey(eKeys Key); }; int cMenuWhatsOn::currentChannel = 0; -const cEventInfo *cMenuWhatsOn::scheduleEventInfo = NULL; +const cEvent *cMenuWhatsOn::scheduleEvent = NULL; static int CompareEventChannel(const void *p1, const void *p2) { - return (int)( (*(const cEventInfo **)p1)->GetChannelNumber() - (*(const cEventInfo **)p2)->GetChannelNumber()); + return (int)( (*(const cEvent **)p1)->ChannelNumber() - (*(const cEvent **)p2)->ChannelNumber()); } cMenuWhatsOn::cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentChannelNr) :cOsdMenu(Now ? tr("What's on now?") : tr("What's on next?"), CHNUMWIDTH, 7, 6) { const cSchedule *Schedule = Schedules->First(); - const cEventInfo **pArray = NULL; + const cEvent **pArray = NULL; int num = 0; while (Schedule) { - pArray = (const cEventInfo **)realloc(pArray, (num + 1) * sizeof(cEventInfo *)); + pArray = (const cEvent **)realloc(pArray, (num + 1) * sizeof(cEvent *)); pArray[num] = Now ? Schedule->GetPresentEvent() : Schedule->GetFollowingEvent(); if (pArray[num]) { - cChannel *channel = Channels.GetByChannelID(pArray[num]->GetChannelID(), true); + cChannel *channel = Channels.GetByChannelID(pArray[num]->ChannelID(), true); if (channel) { pArray[num]->SetChannelNumber(channel->Number()); num++; @@ -1243,20 +1242,20 @@ cMenuWhatsOn::cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentCha Schedule = (const cSchedule *)Schedules->Next(Schedule); } - qsort(pArray, num, sizeof(cEventInfo *), CompareEventChannel); + qsort(pArray, num, sizeof(cEvent *), CompareEventChannel); for (int a = 0; a < num; a++) - Add(new cMenuWhatsOnItem(pArray[a]), pArray[a]->GetChannelNumber() == CurrentChannelNr); + Add(new cMenuWhatsOnItem(pArray[a]), pArray[a]->ChannelNumber() == CurrentChannelNr); currentChannel = CurrentChannelNr; free(pArray); SetHelp(Count() ? tr("Record") : NULL, Now ? tr("Next") : tr("Now"), tr("Button$Schedule"), tr("Switch")); } -const cEventInfo *cMenuWhatsOn::ScheduleEventInfo(void) +const cEvent *cMenuWhatsOn::ScheduleEvent(void) { - const cEventInfo *ei = scheduleEventInfo; - scheduleEventInfo = NULL; + const cEvent *ei = scheduleEvent; + scheduleEvent = NULL; return ei; } @@ -1264,7 +1263,7 @@ eOSState cMenuWhatsOn::Switch(void) { cMenuWhatsOnItem *item = (cMenuWhatsOnItem *)Get(Current()); if (item) { - cChannel *channel = Channels.GetByChannelID(item->eventInfo->GetChannelID(), true); + cChannel *channel = Channels.GetByChannelID(item->event->ChannelID(), true); if (channel && cDevice::PrimaryDevice()->SwitchChannel(channel, true)) return osEnd; } @@ -1276,7 +1275,7 @@ eOSState cMenuWhatsOn::Record(void) { cMenuWhatsOnItem *item = (cMenuWhatsOnItem *)Get(Current()); if (item) { - cTimer *timer = new cTimer(item->eventInfo); + cTimer *timer = new cTimer(item->event); cTimer *t = Timers.GetTimer(timer); if (t) { delete timer; @@ -1300,14 +1299,14 @@ eOSState cMenuWhatsOn::ProcessKey(eKeys Key) case kGreen: { cMenuWhatsOnItem *mi = (cMenuWhatsOnItem *)Get(Current()); if (mi) { - scheduleEventInfo = mi->eventInfo; - currentChannel = mi->eventInfo->GetChannelNumber(); + scheduleEvent = mi->event; + currentChannel = mi->event->ChannelNumber(); } } break; case kBlue: return Switch(); case kOk: if (Count()) - return AddSubMenu(new cMenuEvent(((cMenuWhatsOnItem *)Get(Current()))->eventInfo, true)); + return AddSubMenu(new cMenuEvent(((cMenuWhatsOnItem *)Get(Current()))->event, true)); break; default: break; } @@ -1319,15 +1318,15 @@ eOSState cMenuWhatsOn::ProcessKey(eKeys Key) class cMenuScheduleItem : public cOsdItem { public: - const cEventInfo *eventInfo; - cMenuScheduleItem(const cEventInfo *EventInfo); + const cEvent *event; + cMenuScheduleItem(const cEvent *Event); }; -cMenuScheduleItem::cMenuScheduleItem(const cEventInfo *EventInfo) +cMenuScheduleItem::cMenuScheduleItem(const cEvent *Event) { - eventInfo = EventInfo; + event = Event; char *buffer = NULL; - asprintf(&buffer, "%.*s\t%.*s\t%s", 5, eventInfo->GetDate(), 5, eventInfo->GetTimeString(), eventInfo->GetTitle()); + asprintf(&buffer, "%.*s\t%.*s\t%s", 5, event->GetDateString(), 5, event->GetTimeString(), event->Title()); SetText(buffer, false); } @@ -1335,7 +1334,7 @@ cMenuScheduleItem::cMenuScheduleItem(const cEventInfo *EventInfo) class cMenuSchedule : public cOsdMenu { private: - cMutexLock mutexLock; + cSchedulesLock schedulesLock; const cSchedules *schedules; bool now, next; int otherChannel; @@ -1356,7 +1355,7 @@ cMenuSchedule::cMenuSchedule(void) cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel()); if (channel) { cMenuWhatsOn::SetCurrentChannel(channel->Number()); - schedules = cSIProcessor::Schedules(mutexLock); + schedules = cSchedules::Schedules(schedulesLock); PrepareSchedule(channel); SetHelp(Count() ? tr("Record") : NULL, tr("Now"), tr("Next")); } @@ -1364,12 +1363,12 @@ cMenuSchedule::cMenuSchedule(void) cMenuSchedule::~cMenuSchedule() { - cMenuWhatsOn::ScheduleEventInfo(); // makes sure any posted data is cleared + cMenuWhatsOn::ScheduleEvent(); // makes sure any posted data is cleared } static int CompareEventTime(const void *p1, const void *p2) { - return (int)((*(cEventInfo **)p1)->GetTime() - (*(cEventInfo **)p2)->GetTime()); + return (int)((*(cEvent **)p1)->StartTime() - (*(cEvent **)p2)->StartTime()); } void cMenuSchedule::PrepareSchedule(cChannel *Channel) @@ -1382,17 +1381,17 @@ void cMenuSchedule::PrepareSchedule(cChannel *Channel) if (schedules) { const cSchedule *Schedule = schedules->GetSchedule(Channel->GetChannelID()); int num = Schedule->NumEvents(); - const cEventInfo **pArray = MALLOC(const cEventInfo *, num); + const cEvent **pArray = MALLOC(const cEvent *, num); 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; + const cEvent *Event = Schedule->GetEventNumber(a); + if (Event->StartTime() + Event->Duration() > now) + pArray[numreal++] = Event; } - qsort(pArray, numreal, sizeof(cEventInfo *), CompareEventTime); + qsort(pArray, numreal, sizeof(cEvent *), CompareEventTime); for (int a = 0; a < numreal; a++) Add(new cMenuScheduleItem(pArray[a])); @@ -1405,7 +1404,7 @@ eOSState cMenuSchedule::Record(void) { cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current()); if (item) { - cTimer *timer = new cTimer(item->eventInfo); + cTimer *timer = new cTimer(item->event); cTimer *t = Timers.GetTimer(timer); if (t) { delete timer; @@ -1438,7 +1437,7 @@ eOSState cMenuSchedule::ProcessKey(eKeys Key) if (!now && !next) { int ChannelNr = 0; if (Count()) { - cChannel *channel = Channels.GetByChannelID(((cMenuScheduleItem *)Get(Current()))->eventInfo->GetChannelID(), true); + cChannel *channel = Channels.GetByChannelID(((cMenuScheduleItem *)Get(Current()))->event->ChannelID(), true); if (channel) ChannelNr = channel->Number(); } @@ -1456,16 +1455,16 @@ eOSState cMenuSchedule::ProcessKey(eKeys Key) return Switch(); break; case kOk: if (Count()) - return AddSubMenu(new cMenuEvent(((cMenuScheduleItem *)Get(Current()))->eventInfo, otherChannel)); + return AddSubMenu(new cMenuEvent(((cMenuScheduleItem *)Get(Current()))->event, otherChannel)); break; default: break; } } else if (!HasSubMenu()) { now = next = false; - const cEventInfo *ei = cMenuWhatsOn::ScheduleEventInfo(); + const cEvent *ei = cMenuWhatsOn::ScheduleEvent(); if (ei) { - cChannel *channel = Channels.GetByChannelID(ei->GetChannelID(), true); + cChannel *channel = Channels.GetByChannelID(ei->ChannelID(), true); if (channel) { PrepareSchedule(channel); if (channel->Number() != cDevice::CurrentChannel()) { @@ -2633,10 +2632,10 @@ cDisplayChannel::cDisplayChannel(int Number, bool Switched) int EpgLines = withInfo ? 5 : 1; lines = 0; number = 0; - cChannel *channel = Channels.GetByNumber(Number); + channel = Channels.GetByNumber(Number); Interface->Open(Setup.OSDwidth, Setup.ChannelInfoPos ? EpgLines : -EpgLines); if (channel) { - DisplayChannel(channel); + DisplayChannel(); DisplayInfo(); } lastTime = time_ms(); @@ -2660,16 +2659,16 @@ cDisplayChannel::~cDisplayChannel() Interface->Close(); } -void cDisplayChannel::DisplayChannel(const cChannel *Channel) +void cDisplayChannel::DisplayChannel(void) { int BufSize = Width() + 1; char buffer[BufSize]; *buffer = 0; - if (Channel) { - if (Channel->GroupSep()) - snprintf(buffer, BufSize, "%s", Channel->Name()); + if (channel) { + if (channel->GroupSep()) + snprintf(buffer, BufSize, "%s", channel->Name()); else - snprintf(buffer, BufSize, "%d%s %s", Channel->Number(), number ? "-" : "", Channel->Name()); + snprintf(buffer, BufSize, "%d%s %s", channel->Number(), number ? "-" : "", channel->Name()); } else if (number) snprintf(buffer, BufSize, "%d-", number); @@ -2684,28 +2683,28 @@ void cDisplayChannel::DisplayChannel(const cChannel *Channel) void cDisplayChannel::DisplayInfo(void) { - if (withInfo) { - const cEventInfo *Present = NULL, *Following = NULL; - cMutexLock MutexLock; - const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock); + if (withInfo && channel) { + const cEvent *Present = NULL, *Following = NULL; + cSchedulesLock SchedulesLock; + const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock); if (Schedules) { - const cSchedule *Schedule = Schedules->GetSchedule(); + const cSchedule *Schedule = Schedules->GetSchedule(channel->GetChannelID()); if (Schedule) { const char *PresentTitle = NULL, *PresentSubtitle = NULL, *FollowingTitle = NULL, *FollowingSubtitle = NULL; int Lines = 0; if ((Present = Schedule->GetPresentEvent()) != NULL) { - PresentTitle = Present->GetTitle(); + PresentTitle = Present->Title(); if (!isempty(PresentTitle)) Lines++; - PresentSubtitle = Present->GetSubtitle(); + PresentSubtitle = Present->ShortText(); if (!isempty(PresentSubtitle)) Lines++; } if ((Following = Schedule->GetFollowingEvent()) != NULL) { - FollowingTitle = Following->GetTitle(); + FollowingTitle = Following->Title(); if (!isempty(FollowingTitle)) Lines++; - FollowingSubtitle = Following->GetSubtitle(); + FollowingSubtitle = Following->ShortText(); if (!isempty(FollowingSubtitle)) Lines++; } @@ -2733,7 +2732,7 @@ void cDisplayChannel::DisplayInfo(void) Interface->Flush(); lines = Lines; lastTime = time_ms(); - cStatus::MsgOsdProgramme(Present ? Present->GetTime() : 0, PresentTitle, PresentSubtitle, Following ? Following->GetTime() : 0, FollowingTitle, FollowingSubtitle); + cStatus::MsgOsdProgramme(Present ? Present->StartTime() : 0, PresentTitle, PresentSubtitle, Following ? Following->StartTime() : 0, FollowingTitle, FollowingSubtitle); } } } @@ -2743,7 +2742,8 @@ void cDisplayChannel::DisplayInfo(void) void cDisplayChannel::Refresh(void) { Interface->Clear(); - DisplayChannel(Channels.GetByNumber(cDevice::CurrentChannel())); + channel = Channels.GetByNumber(cDevice::CurrentChannel()); + DisplayChannel(); lastTime = time_ms(); lines = 0; } @@ -2761,20 +2761,21 @@ eOSState cDisplayChannel::ProcessKey(eKeys Key) if (number >= 0) { number = number * 10 + Key - k0; if (number > 0) { - cChannel *channel = Channels.GetByNumber(number); + channel = Channels.GetByNumber(number); Interface->Clear(); withInfo = false; - DisplayChannel(channel); + DisplayChannel(); lastTime = time_ms(); // Lets see if there can be any useful further input: int n = channel ? number * 10 : 0; - while (channel && (channel = Channels.Next(channel)) != NULL) { - if (!channel->GroupSep()) { - if (n <= channel->Number() && channel->Number() <= n + 9) { + cChannel *ch = channel; + while (ch && (ch = Channels.Next(ch)) != NULL) { + if (!ch->GroupSep()) { + if (n <= ch->Number() && ch->Number() <= n + 9) { n = 0; break; } - if (channel->Number() > n) + if (ch->Number() > n) n *= 10; } } @@ -2805,10 +2806,10 @@ eOSState cDisplayChannel::ProcessKey(eKeys Key) group = Channels.GetPrevGroup(group < 1 ? 1 : group); if (group < 0) group = SaveGroup; - cChannel *channel = Channels.Get(group); + channel = Channels.Get(group); if (channel) { Interface->Clear(); - DisplayChannel(channel); + DisplayChannel(); if (!channel->GroupSep()) group = -1; } @@ -2835,7 +2836,8 @@ eOSState cDisplayChannel::ProcessKey(eKeys Key) Channels.SwitchTo(number); else { number = 0; - DisplayChannel(NULL); + channel = NULL; + DisplayChannel(); lastTime = time_ms(); return osContinue; } @@ -2967,7 +2969,7 @@ eOSState cDisplayVolume::ProcessKey(eKeys Key) cRecordControl::cRecordControl(cDevice *Device, cTimer *Timer, bool Pause) { - eventInfo = NULL; + event = NULL; instantId = NULL; fileName = NULL; recorder = NULL; @@ -2986,10 +2988,10 @@ cRecordControl::cRecordControl(cDevice *Device, cTimer *Timer, bool Pause) const char *Title = NULL; const char *Subtitle = NULL; const char *Summary = NULL; - if (GetEventInfo()) { - Title = eventInfo->GetTitle(); - Subtitle = eventInfo->GetSubtitle(); - Summary = eventInfo->GetExtendedDescription(); + if (GetEvent()) { + Title = event->Title(); + Subtitle = event->ShortText(); + Summary = event->Description(); dsyslog("Title: '%s' Subtitle: '%s'", Title, Subtitle); } cRecording Recording(timer, Title, Subtitle, Summary); @@ -3038,19 +3040,19 @@ cRecordControl::~cRecordControl() #define INSTANT_REC_EPG_LOOKAHEAD 300 // seconds to look into the EPG data for an instant recording -bool cRecordControl::GetEventInfo(void) +bool cRecordControl::GetEvent(void) { const cChannel *channel = timer->Channel(); time_t Time = timer->Active() == taActInst ? timer->StartTime() + INSTANT_REC_EPG_LOOKAHEAD : timer->StartTime() + (timer->StopTime() - timer->StartTime()) / 2; for (int seconds = 0; seconds <= MAXWAIT4EPGINFO; seconds++) { { - cMutexLock MutexLock; - const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock); + cSchedulesLock SchedulesLock; + const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock); if (Schedules) { const cSchedule *Schedule = Schedules->GetSchedule(channel->GetChannelID()); if (Schedule) { - eventInfo = Schedule->GetEventAround(Time); - if (eventInfo) { + event = Schedule->GetEventAround(Time); + if (event) { if (seconds > 0) dsyslog("got EPG info after %d seconds", seconds); return true; |