Ejemplo n.º 1
0
bool CEpg::UpdateEntry(const CEpgInfoTag &tag, bool bUpdateDatabase /* = false */, bool bSort /* = true */)
{
  CEpgInfoTagPtr infoTag;
  bool bReturn(false);
  {
    CSingleLock lock(m_critSection);
    map<CDateTime, CEpgInfoTagPtr>::iterator it = m_tags.find(tag.StartAsUTC());
    bool bNewTag(false);
    if (it != m_tags.end())
    {
      infoTag = it->second;
    }
    else
    {
      /* create a new tag if no tag with this ID exists */
      infoTag = CEpgInfoTagPtr(new CEpgInfoTag(this, m_pvrChannel, m_strName, m_pvrChannel ? m_pvrChannel->IconPath() : StringUtils::EmptyString));
      infoTag->SetUniqueBroadcastID(tag.UniqueBroadcastID());
      m_tags.insert(make_pair(tag.StartAsUTC(), infoTag));
      bNewTag = true;
    }

    infoTag->Update(tag, bNewTag);
    infoTag->m_epg          = this;
    infoTag->m_pvrChannel   = m_pvrChannel;
  }

  if (bUpdateDatabase)
    bReturn = infoTag->Persist();
  else
    bReturn = true;

  return bReturn;
}