Beispiel #1
0
void CEpgContainer::InsertFromDatabase(int iEpgID, const std::string &strName, const std::string &strScraperName)
{
    // table might already have been created when pvr channels were loaded
    CEpgPtr epg = GetById(iEpgID);
    if (epg)
    {
        if (epg->Name() != strName || epg->ScraperName() != strScraperName)
        {
            // current table data differs from the info in the db
            epg->SetChanged();
            SetChanged();
        }
    }
    else
    {
        // create a new epg table
        epg.reset(new CEpg(iEpgID, strName, strScraperName, true));
        if (epg)
        {
            m_epgs.insert(std::make_pair(iEpgID, epg));
            SetChanged();
            epg->RegisterObserver(this);
        }
    }
}
Beispiel #2
0
CEpgPtr CEpgContainer::CreateChannelEpg(CPVRChannelPtr channel)
{
  if (!channel)
    return NULL;

  WaitForUpdateFinish(true);
  LoadFromDB();

  CEpgPtr epg;
  if (channel->EpgID() > 0)
    epg = GetById(channel->EpgID());

  if (!epg)
  {
    channel->SetEpgID(NextEpgId());
    epg.reset(new CEpg(channel, false));

    CSingleLock lock(m_critSection);
    m_epgs.insert(std::make_pair((unsigned int)epg->EpgID(), epg));
    SetChanged();
    epg->RegisterObserver(this);
  }

  epg->SetChannel(channel);

  {
    CSingleLock lock(m_critSection);
    m_bPreventUpdates = false;
    CDateTime::GetCurrentDateTime().GetAsUTCDateTime().GetAsTime(m_iNextEpgUpdate);
  }

  NotifyObservers(ObservableMessageEpgContainer);

  return epg;
}