bool CEpg::UpdateEntry(const CEpgInfoTag &tag, bool bUpdateDatabase /* = false */) { bool bReturn = false; /* XXX tags aren't always fetched correctly here */ CEpgInfoTag *InfoTag = (CEpgInfoTag *) this->InfoTag(tag.UniqueBroadcastID(), tag.Start()); /* create a new tag if no tag with this ID exists */ if (!InfoTag) { CSingleLock lock(m_critSection); InfoTag = CreateTag(); InfoTag->SetUniqueBroadcastID(tag.UniqueBroadcastID()); push_back(InfoTag); } InfoTag->m_Epg = this; InfoTag->Update(tag); Sort(); if (bUpdateDatabase) bReturn = InfoTag->Persist(); else bReturn = true; return bReturn; }
bool CEpg::UpdateEntry(const CEpgInfoTag &tag, bool bUpdateDatabase /* = false */, bool bSort /* = true */) { bool bReturn(false); CSingleLock lock(m_critSection); CEpgInfoTag *infoTag = GetTag(tag.UniqueBroadcastID(), tag.StartAsUTC()); /* create a new tag if no tag with this ID exists */ bool bNewTag(false); if (!infoTag) { infoTag = new CEpgInfoTag(); infoTag->SetUniqueBroadcastID(tag.UniqueBroadcastID()); push_back(infoTag); bNewTag = true; } infoTag->m_Epg = this; infoTag->Update(tag, bNewTag); if (bSort) Sort(); if (bUpdateDatabase) bReturn = infoTag->Persist(); else bReturn = true; return bReturn; }
bool CEpg::FixOverlappingEvents(bool bStore /* = true */) { bool bReturn = false; CEpgDatabase *database = NULL; if (bStore) { database = g_EpgContainer.GetDatabase(); if (!database || !database->Open()) { CLog::Log(LOGERROR, "EPG - %s - could not open the database", __FUNCTION__); return bReturn; } } bReturn = true; CEpgInfoTag *previousTag = NULL; CSingleLock lock(m_critSection); for (unsigned int ptr = 0; ptr < size(); ptr++) { /* skip the first entry or if previousTag is NULL */ if (previousTag == NULL) { previousTag = at(ptr); continue; } CEpgInfoTag *currentTag = at(ptr); /* the previous tag ends after the current tag starts. * the start time of the current tag is leading, so change the time of the previous tag */ if (previousTag->End() > currentTag->Start()) { CLog::Log(LOGDEBUG, "EPG - %s - event '%s' ends after event '%s' starts. changing the end time of '%s' to the start time of '%s': '%s'", __FUNCTION__, previousTag->Title().c_str(), currentTag->Title().c_str(), previousTag->Title().c_str(), currentTag->Title().c_str(), currentTag->Start().GetAsLocalizedDateTime(false, false).c_str()); previousTag->SetEnd(currentTag->Start()); if (bStore) bReturn = previousTag->Persist(false, false) && bReturn; } previousTag = at(ptr); } return bReturn; }