void CPVREpg::AddEntry(const CPVREpgInfoTag &tag) { CPVREpgInfoTagPtr newTag; CPVRChannelPtr channel; { CSingleLock lock(m_critSection); std::map<CDateTime, CPVREpgInfoTagPtr>::iterator itr = m_tags.find(tag.StartAsUTC()); if (itr != m_tags.end()) newTag = itr->second; else { newTag.reset(new CPVREpgInfoTag(this, m_pvrChannel, m_strName, m_pvrChannel ? m_pvrChannel->IconPath() : "")); m_tags.insert(make_pair(tag.StartAsUTC(), newTag)); } channel = m_pvrChannel; } if (newTag) { newTag->Update(tag); newTag->SetChannel(channel); newTag->SetEpg(this); newTag->SetTimer(CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(newTag)); newTag->SetRecording(CServiceBroker::GetPVRManager().Recordings()->GetRecordingForEpgTag(newTag)); } }
bool CPVREpg::UpdateEntry(const CPVREpgInfoTagPtr &tag, bool bUpdateDatabase) { CPVREpgInfoTagPtr infoTag; { CSingleLock lock(m_critSection); std::map<CDateTime, CPVREpgInfoTagPtr>::iterator it = m_tags.find(tag->StartAsUTC()); bool bNewTag(false); if (it != m_tags.end()) { infoTag = it->second; } else { infoTag.reset(new CPVREpgInfoTag(this, m_pvrChannel, m_strName, m_pvrChannel ? m_pvrChannel->IconPath() : "")); infoTag->SetUniqueBroadcastID(tag->UniqueBroadcastID()); m_tags.insert(std::make_pair(tag->StartAsUTC(), infoTag)); bNewTag = true; } infoTag->Update(*tag, bNewTag); infoTag->SetEpg(this); infoTag->SetChannel(m_pvrChannel); if (bUpdateDatabase) m_changedTags.insert(std::make_pair(infoTag->UniqueBroadcastID(), infoTag)); } infoTag->SetTimer(CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(infoTag)); infoTag->SetRecording(CServiceBroker::GetPVRManager().Recordings()->GetRecordingForEpgTag(infoTag)); return true; }
void CPVRRecordings::UpdateFromClient(const CPVRRecordingPtr &tag) { CSingleLock lock(m_critSection); if (tag->IsDeleted()) { if (tag->IsRadio()) m_bDeletedRadioRecordings = true; else m_bDeletedTVRecordings = true; } CPVRRecordingPtr newTag = GetById(tag->m_iClientId, tag->m_strRecordingId); if (newTag) { newTag->Update(*tag); } else { newTag = CPVRRecordingPtr(new CPVRRecording); newTag->Update(*tag); if (newTag->BroadcastUid() != EPG_TAG_INVALID_UID) { const CPVRChannelPtr channel(newTag->Channel()); if (channel) { const CPVREpgInfoTagPtr epgTag = CServiceBroker::GetPVRManager().EpgContainer().GetTagById(channel, newTag->BroadcastUid()); if (epgTag) epgTag->SetRecording(newTag); } } newTag->m_iRecordingId = ++m_iLastId; m_recordings.insert(std::make_pair(CPVRRecordingUid(newTag->m_iClientId, newTag->m_strRecordingId), newTag)); if (newTag->IsRadio()) ++m_iRadioRecordings; else ++m_iTVRecordings; } }