int CPVRTimers::Update() { CSingleLock lock(m_critSection); CLog::Log(LOGDEBUG, "PVRTimers - %s - updating timers", __FUNCTION__); int iCurSize = size(); /* clear channel timers */ for (unsigned int iTimerPtr = 0; iTimerPtr < size(); iTimerPtr++) { CPVRTimerInfoTag *timerTag = &at(iTimerPtr); if (!timerTag || !timerTag->Active()) continue; CPVREpgInfoTag *epgTag = (CPVREpgInfoTag *)timerTag->EpgInfoTag(); if (!epgTag) continue; epgTag->SetTimer(NULL); } /* clear timers */ clear(); /* get all timers from the clients */ CLIENTMAP *clients = g_PVRManager.Clients(); CLIENTMAPITR itr = clients->begin(); while (itr != clients->end()) { if (g_PVRManager.GetClientProps((*itr).second->GetID())->SupportTimers) { if ((*itr).second->GetNumTimers() > 0) { (*itr).second->GetAllTimers(this); } } itr++; } //XXX g_PVRManager.UpdateRecordingsCache(); /* set channel timers */ for (unsigned int ptr = 0; ptr < size(); ptr++) { /* get the timer tag */ CPVRTimerInfoTag *timerTag = &at(ptr); if (!timerTag || !timerTag->Active()) continue; /* try to get the channel */ CPVRChannel *channel = CPVRChannels::GetByClientFromAll(timerTag->Number(), timerTag->ClientID()); if (!channel) continue; /* try to get the EPG */ CPVREpg *epg = channel->GetEPG(); if (!epg) continue; /* try to set the timer on the epg tag that matches */ CPVREpgInfoTag *epgTag = (CPVREpgInfoTag *) epg->InfoTagBetween(timerTag->Start(), timerTag->Stop()); if (epgTag) epgTag->SetTimer(timerTag); } return size() - iCurSize; }
int CPVREpgs::GetEPGSearch(CFileItemList* results, const PVREpgSearchFilter &filter) { for (unsigned int iEpgPtr = 0; iEpgPtr < size(); iEpgPtr++) { CPVREpg *epg = at(iEpgPtr); epg->Get(results, filter); } /* filter recordings */ if (filter.m_bIgnorePresentRecordings && PVRRecordings.size() > 0) { for (unsigned int iRecordingPtr = 0; iRecordingPtr < PVRRecordings.size(); iRecordingPtr++) { for (int iResultPtr = 0; iResultPtr < results->Size(); iResultPtr++) { const CPVREpgInfoTag *epgentry = results->Get(iResultPtr)->GetEPGInfoTag(); CPVRRecordingInfoTag *recording = &PVRRecordings[iRecordingPtr]; if (epgentry) { if (epgentry->Title() != recording->Title() || epgentry->PlotOutline() != recording->PlotOutline() || epgentry->Plot() != recording->Plot()) continue; results->Remove(iResultPtr); iResultPtr--; } } } } /* filter timers */ if (filter.m_bIgnorePresentTimers && PVRTimers.size() > 0) { for (unsigned int iTimerPtr = 0; iTimerPtr < PVRTimers.size(); iTimerPtr++) { for (int iResultPtr = 0; iResultPtr < results->Size(); iResultPtr++) { const CPVREpgInfoTag *epgentry = results->Get(iResultPtr)->GetEPGInfoTag(); CPVRTimerInfoTag *timer = &PVRTimers[iTimerPtr]; if (epgentry) { if (epgentry->ChannelTag()->ChannelNumber() != timer->ChannelNumber() || epgentry->Start() < timer->Start() || epgentry->End() > timer->Stop()) continue; results->Remove(iResultPtr); iResultPtr--; } } } } /* remove duplicate entries */ if (filter.m_bPreventRepeats) { unsigned int iSize = results->Size(); for (unsigned int iResultPtr = 0; iResultPtr < iSize; iResultPtr++) { const CPVREpgInfoTag *epgentry_1 = results->Get(iResultPtr)->GetEPGInfoTag(); for (unsigned int iTagPtr = 0; iTagPtr < iSize; iTagPtr++) { const CPVREpgInfoTag *epgentry_2 = results->Get(iTagPtr)->GetEPGInfoTag(); if (iResultPtr == iTagPtr) continue; if (epgentry_1->Title() != epgentry_2->Title() || epgentry_1->Plot() != epgentry_2->Plot() || epgentry_1->PlotOutline() != epgentry_2->PlotOutline()) continue; results->Remove(iTagPtr); iSize = results->Size(); iResultPtr--; iTagPtr--; } } } return results->Size(); }