const CStdString &CPVREpgInfoTag::Icon(void) const { if (m_strIconPath.IsEmpty() && m_Epg) { CPVREpg *pvrEpg = (CPVREpg *) m_Epg; if (pvrEpg->Channel()) return pvrEpg->Channel()->IconPath(); } return m_strIconPath; }
void CPVREpgs::Clear(bool bClearDb /* = false */) { /* remove all pointers to epg tables on timers */ for (unsigned int iTimerPtr = 0; iTimerPtr < PVRTimers.size(); iTimerPtr++) PVRTimers[iTimerPtr].SetEpgInfoTag(NULL); /* clear all epg tables and remove pointers to epg tables on channels */ for (unsigned int iEpgPtr = 0; iEpgPtr < size(); iEpgPtr++) { CPVREpg *epg = at(iEpgPtr); epg->Clear(); CPVRChannel *channel = (CPVRChannel *) epg->Channel(); if (channel) channel->m_EPG = NULL; } /* remove all EPG tables */ clear(); /* clear the database entries */ if (bClearDb) { CPVRDatabase *database = g_PVRManager.GetTVDatabase(); database->Open(); database->EraseEpg(); database->Close(); } m_iLastEpgUpdate = 0; m_bDatabaseLoaded = false; }
bool CPVREpgs::LoadFromDb(bool bShowProgress /* = false */) { if (m_bDatabaseLoaded) return m_bDatabaseLoaded; CPVRDatabase *database = g_PVRManager.GetTVDatabase(); /* show the progress bar */ CGUIDialogPVRUpdateProgressBar *scanner = NULL; if (bShowProgress) { scanner = (CGUIDialogPVRUpdateProgressBar *)g_windowManager.GetWindow(WINDOW_DIALOG_EPG_SCAN); scanner->Show(); scanner->SetHeader(g_localizeStrings.Get(19004)); } /* open the database */ database->Open(); /* load all EPG tables */ bool bLoaded = false; unsigned int iSize = size(); for (unsigned int iEpgPtr = 0; iEpgPtr < iSize; iEpgPtr++) { CPVREpg *epg = at(iEpgPtr); CPVRChannel *channel = epg->Channel(); if (epg->LoadFromDb()) { if (channel) channel->UpdateEPGPointers(); bLoaded = true; } if (bShowProgress) { /* update the progress bar */ if (channel) scanner->SetTitle(channel->ChannelName()); scanner->SetProgress(iEpgPtr, iSize); scanner->UpdateState(); } } /* close the database */ database->Close(); if (bShowProgress) scanner->Close(); m_bDatabaseLoaded = bLoaded; return bLoaded; }
bool CPVREpgs::UpdateEPG(bool bShowProgress /* = false */) { long iStartTime = CTimeUtils::GetTimeMS(); int iEpgCount = size(); CPVRDatabase *database = g_PVRManager.GetTVDatabase(); bool bUpdateSuccess = true; CGUIDialogPVRUpdateProgressBar *scanner = NULL; /* set start and end time */ time_t start; time_t end; CDateTime::GetCurrentDateTime().GetAsTime(start); // NOTE: XBMC stores the EPG times as local time end = start; start -= m_iLingerTime; if (!m_bDatabaseLoaded) { CLog::Log(LOGNOTICE, "PVREpgs - %s - loading initial EPG entries for %i tables from clients", __FUNCTION__, iEpgCount); end += 60 * 60 * 3; // load 3 hours } else { CLog::Log(LOGNOTICE, "PVREpgs - %s - starting EPG update for %i tables (update time = %d)", __FUNCTION__, iEpgCount, m_iUpdateTime); end += m_iDisplayTime; } /* show the progress bar */ if (bShowProgress) { scanner = (CGUIDialogPVRUpdateProgressBar *)g_windowManager.GetWindow(WINDOW_DIALOG_EPG_SCAN); scanner->Show(); scanner->SetHeader(g_localizeStrings.Get(19004)); } /* open the database */ database->Open(); /* update all EPG tables */ for (unsigned int iEpgPtr = 0; iEpgPtr < size(); iEpgPtr++) { /* interrupt the update on exit */ if (m_bStop) { bUpdateSuccess = false; break; } CPVREpg *epg = at(iEpgPtr); bUpdateSuccess = epg->Update(start, end, !m_bIgnoreDbForClient) && bUpdateSuccess; if (bShowProgress) { /* update the progress bar */ scanner->SetProgress(iEpgPtr, iEpgCount); scanner->SetTitle(epg->Channel()->ChannelName()); scanner->UpdateState(); } } /* update the last scan time if the update was successful and if we did a full update */ if (bUpdateSuccess && m_bDatabaseLoaded) { database->UpdateLastEpgScanTime(); CDateTime::GetCurrentDateTime().GetAsTime(m_iLastEpgUpdate); } database->Close(); if (!m_bDatabaseLoaded) { UpdateAllChannelEPGPointers(); m_bDatabaseLoaded = true; } if (bShowProgress) scanner->Close(); long lUpdateTime = CTimeUtils::GetTimeMS() - iStartTime; CLog::Log(LOGINFO, "PVREpgs - %s - finished updating the EPG after %li.%li seconds", __FUNCTION__, lUpdateTime / 1000, lUpdateTime % 1000); return bUpdateSuccess; }