void CPVRTimers::Unload() { CSingleLock lock(m_critSection); CEpgContainer *epg = &g_EpgContainer; if (epg) epg->UnregisterObserver(this); for (unsigned int iTimerPtr = 0; iTimerPtr < size(); iTimerPtr++) delete at(iTimerPtr); clear(); }
int CEpgDatabase::Get(CEpgContainer &container) { int iReturn(-1); std::string strQuery = PrepareSQL("SELECT idEpg, sName, sScraperName FROM epg;"); if (ResultQuery(strQuery)) { iReturn = 0; try { while (!m_pDS->eof()) { int iEpgID = m_pDS->fv("idEpg").get_asInt(); std::string strName = m_pDS->fv("sName").get_asString().c_str(); std::string strScraperName = m_pDS->fv("sScraperName").get_asString().c_str(); container.InsertFromDatabase(iEpgID, strName, strScraperName); ++iReturn; m_pDS->next(); } m_pDS->close(); } catch (...) { CLog::Log(LOGERROR, "%s - couldn't load EPG data from the database", __FUNCTION__); } } return iReturn; }
void CPVRTimers::Unload() { CSingleLock lock(m_critSection); CEpgContainer *epg = &g_EpgContainer; if (epg) epg->UnregisterObserver(this); for (map<CDateTime, vector<CPVRTimerInfoTag *>* >::iterator it = m_tags.begin(); it != m_tags.end(); it++) { vector<CPVRTimerInfoTag*> *timers = it->second; for (unsigned int iTagPtr = 0; iTagPtr < timers->size(); iTagPtr++) delete timers->at(iTagPtr); delete it->second; } m_tags.clear(); }
int CEpgDatabase::Get(CEpgContainer &container) { int iReturn(-1); CSingleLock lock(m_critSection); CStdString strQuery = FormatSQL("SELECT idEpg, sName, sScraperName FROM epg;"); if (ResultQuery(strQuery)) { iReturn = 0; try { while (!m_pDS->eof()) { int iEpgID = m_pDS->fv("idEpg").get_asInt(); CStdString strName = m_pDS->fv("sName").get_asString().c_str(); CStdString strScraperName = m_pDS->fv("sScraperName").get_asString().c_str(); CEpg newEpg(iEpgID, strName, strScraperName, true); if (container.UpdateEntry(newEpg)) ++iReturn; else { CLog::Log(LOGERROR, "%s - deleting EPG table %d from the database", __FUNCTION__, iEpgID); CStdString strWhereClause = FormatSQL("idEpg = %u", iEpgID); DeleteValues("lastepgscan", strWhereClause); DeleteValues("epgtags", strWhereClause); DeleteValues("epg", strWhereClause); } m_pDS->next(); } m_pDS->close(); } catch (...) { CLog::Log(LOGERROR, "%s - couldn't load EPG data from the database", __FUNCTION__); } } return iReturn; }