Skip to content

Commit

Permalink
repaired GetEventById
Browse files Browse the repository at this point in the history
  • Loading branch information
flensrocker committed Jan 28, 2015
1 parent 1858f75 commit c658267
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void TimersResponder::createOrUpdateTimer(ostream& out, cxxtools::http::Request&
int minpre = q.getBodyAsInt("minpre");
int minpost = q.getBodyAsInt("minpost");
if (eventid >= 0 && chan != NULL) {
cEvent* event = VdrExtension::GetEventById((tEventID)eventid, chan);
const cEvent* event = VdrExtension::GetEventById((tEventID)eventid, chan);

if (event == NULL) {
reply.httpReturn(407, "eventid invalid");
Expand Down
16 changes: 7 additions & 9 deletions tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,20 +699,18 @@ int VdrExtension::RecordingLengthInSeconds(cRecording* recording)
return -1;
}

cEvent* VdrExtension::GetEventById(tEventID eventID, cChannel* channel)
const cEvent* VdrExtension::GetEventById(tEventID eventID, cChannel* channel)
{
cSchedulesLock MutexLock;
const cSchedules *Schedules = cSchedules::Schedules(MutexLock);

if ( !Schedules ) return NULL;
if (!Schedules)
return NULL;

const cSchedule *Schedule = Schedules->GetSchedule(channel->GetChannelID());
if (Schedule)
return Schedule->GetEvent(eventID);

for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
const cSchedule *Schedule = Schedules->GetSchedule(channel->GetChannelID());
if (Schedule) {
cEvent* event = (cEvent*)Schedule->GetEvent(eventID);
if ( event != NULL && (channel == NULL || strcmp(channel->GetChannelID().ToString(), event->ChannelID().ToString()) == 0 ) ) return event;
}
}
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class VdrExtension
static std::vector< cTimer* > SortedTimers();
static bool CompareTimers(cTimer* timer1, cTimer* timer2);
static int RecordingLengthInSeconds(cRecording* recording);
static cEvent* GetEventById(tEventID eventID, cChannel* channel = NULL);
static const cEvent* GetEventById(tEventID eventID, cChannel* channel);
static std::string getRelativeVideoPath(cRecording* recording);
static cEvent* getCurrentEventOnChannel(cChannel* channel);
static std::string getVideoDiskSpace();
Expand Down

0 comments on commit c658267

Please sign in to comment.