Exemplo n.º 1
0
CDateTime CEpg::GetLastScanTime(void)
{
  CDateTime lastScanTime;
  {
    CSingleLock lock(m_critSection);

    if (!m_lastScanTime.IsValid())
    {
      if (!CSettings::GetInstance().GetBool(CSettings::SETTING_EPG_IGNOREDBFORCLIENT))
      {
        CEpgDatabase *database = g_EpgContainer.GetDatabase();
        CDateTime dtReturn; dtReturn.SetValid(false);

        if (database && database->IsOpen())
          database->GetLastEpgScanTime(m_iEpgID, &m_lastScanTime);
      }

      if (!m_lastScanTime.IsValid())
      {
        m_lastScanTime.SetDateTime(1970, 1, 1, 0, 0, 0);
        assert(m_lastScanTime.IsValid());
      }
    }
    lastScanTime = m_lastScanTime;
  }

  return m_lastScanTime;
}
Exemplo n.º 2
0
CDateTime CEpg::GetLastScanTime(void)
{
  CDateTime lastScanTime;
  {
    CSingleLock lock(m_critSection);

    if (!m_lastScanTime.IsValid())
    {
      if (!CSettings::Get().GetBool("epg.ignoredbforclient"))
      {
        CEpgDatabase *database = g_EpgContainer.GetDatabase();
        CDateTime dtReturn; dtReturn.SetValid(false);

        if (database && database->IsOpen())
          database->GetLastEpgScanTime(m_iEpgID, &m_lastScanTime);
      }

      if (!m_lastScanTime.IsValid())
      {
        m_lastScanTime.SetDateTime(0, 0, 0, 0, 0, 0);
        m_lastScanTime.SetValid(true);
      }
    }
    lastScanTime = m_lastScanTime;
  }

  return m_lastScanTime;
}
Exemplo n.º 3
0
const CDateTime &CEpg::GetLastScanTime(void)
{
  CSingleLock lock(m_critSection);

  if (!m_lastScanTime.IsValid())
  {
    if (!g_guiSettings.GetBool("epg.ignoredbforclient"))
    {
      CEpgDatabase *database = g_EpgContainer.GetDatabase();
      CDateTime dtReturn; dtReturn.SetValid(false);

      if (database && database->Open())
      {
        database->GetLastEpgScanTime(m_iEpgID, &m_lastScanTime);
        database->Close();
      }
    }

    if (!m_lastScanTime.IsValid())
    {
      m_lastScanTime.SetDateTime(0, 0, 0, 0, 0, 0);
      m_lastScanTime.SetValid(true);
    }
  }

  return m_lastScanTime;
}
Exemplo n.º 4
0
bool CEpg::Update(time_t start, time_t end, int iUpdateTime, bool bStoreInDb /* = true */)
{
  bool bGrabSuccess = true;
  bool bUpdate = false;
  CEpgDatabase *database = g_EpgContainer.GetDatabase();
  if (bStoreInDb && (!database || !database->Open()))
  {
    CLog::Log(LOGERROR, "Epg - %s - cannot open the database", __FUNCTION__);
    return false;
  }

  CSingleLock lock(m_critSection);

  /* get the last update time from the database */
  if (!m_lastScanTime.IsValid() && bStoreInDb)
    database->GetLastEpgScanTime(m_iEpgID, &m_lastScanTime);

  /* check if we have to update */
  time_t iNow = 0;
  time_t iLastUpdate = 0;
  CDateTime::GetCurrentDateTime().GetAsTime(iNow);
  m_lastScanTime.GetAsTime(iLastUpdate);
  bUpdate = (iNow > iLastUpdate + iUpdateTime);

  if (bUpdate)
  {
    m_bInhibitSorting = true;
    bGrabSuccess = UpdateFromScraper(start, end);
    m_bInhibitSorting = false;

    /* store the loaded EPG entries in the database */
    if (bGrabSuccess && size() > 0)
    {
      Sort();
      FixOverlappingEvents(false);

      if (bStoreInDb)
      {
        database->PersistLastEpgScanTime(m_iEpgID, true);
        database->Persist(*this, true);
        PersistTags(true);
        database->CommitInsertQueries();
      }

      m_lastScanTime = CDateTime::GetCurrentDateTime();
    }
    else
    {
      m_lastScanTime = CDateTime::GetCurrentDateTime() - CDateTimeSpan(0, 0, 0, iUpdateTime + 300); /* try again in 5 minutes */
    }
  }

  if (bStoreInDb)
    database->Close();

  return bGrabSuccess;
}