bool CTextureDatabase::GetCachedTexture(const CStdString &url, CStdString &cacheFile, CStdString &imageHash) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; CStdString sql = PrepareSQL("select id, cachedurl, lasthashcheck, imagehash from texture where url='%s'", url.c_str()); m_pDS->query(sql.c_str()); if (!m_pDS->eof()) { // have some information int textureID = m_pDS->fv(0).get_asInt(); cacheFile = m_pDS->fv(1).get_asString(); CDateTime lastCheck; lastCheck.SetFromDBDateTime(m_pDS->fv(2).get_asString()); if (!lastCheck.IsValid() || lastCheck + CDateTimeSpan(1,0,0,0) < CDateTime::GetCurrentDateTime()) imageHash = m_pDS->fv(3).get_asString(); m_pDS->close(); // update the use count sql = PrepareSQL("update texture set usecount=usecount+1, lastusetime=CURRENT_TIMESTAMP where id=%u", textureID); m_pDS->exec(sql.c_str()); return true; } m_pDS->close(); } catch (...) { CLog::Log(LOGERROR, "%s, failed on url '%s'", __FUNCTION__, url.c_str()); } return false; }
bool CTextureDatabase::GetCachedTexture(const CStdString &url, CTextureDetails &details) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; CStdString sql = PrepareSQL("SELECT id, cachedurl, lasthashcheck, imagehash, width, height FROM texture JOIN sizes ON (texture.id=sizes.idtexture AND sizes.size=1) WHERE url='%s'", url.c_str()); m_pDS->query(sql.c_str()); if (!m_pDS->eof()) { // have some information details.id = m_pDS->fv(0).get_asInt(); details.file = m_pDS->fv(1).get_asString(); CDateTime lastCheck; lastCheck.SetFromDBDateTime(m_pDS->fv(2).get_asString()); if (lastCheck.IsValid() && lastCheck + CDateTimeSpan(1,0,0,0) < CDateTime::GetCurrentDateTime()) details.hash = m_pDS->fv(3).get_asString(); details.width = m_pDS->fv(4).get_asInt(); details.height = m_pDS->fv(5).get_asInt(); m_pDS->close(); return true; } m_pDS->close(); } catch (...) { CLog::Log(LOGERROR, "%s, failed on url '%s'", __FUNCTION__, url.c_str()); } return false; }
bool XMLUtils::GetDateTime(const TiXmlNode* pRootNode, const char* strTag, CDateTime& dateTime) { CStdString strDateTime; if (GetString(pRootNode, strTag, strDateTime) && !strDateTime.empty()) { dateTime.SetFromDBDateTime(strDateTime); return true; } return false; }
CDateTime CPVRDatabase::GetLastEpgScanTime() { if (lastScanTime.IsValid()) return lastScanTime; CStdString strValue = GetSingleValue("LastEPGScan", "ScanTime"); if (strValue.IsEmpty()) return -1; CDateTime lastTime; lastTime.SetFromDBDateTime(strValue); lastScanTime = lastTime; return lastTime; }
CDateTime CPVRDatabase::GetEpgDataEnd(long iChannelId /* = -1 */) { CDateTime lastProgramme; CStdString strWhereClause; if (iChannelId > 0) strWhereClause = FormatSQL("ChannelId = '%u'", iChannelId); CStdString strReturn = GetSingleValue("EpgData", "EndTime", strWhereClause, "EndTime DESC"); if (!strReturn.IsEmpty()) lastProgramme.SetFromDBDateTime(strReturn); if (!lastProgramme.IsValid()) return CDateTime::GetCurrentDateTime(); else return lastProgramme; }
CDateTime CAddonDatabase::GetRepoTimestamp(const std::string& id) { CDateTime date; try { if (NULL == m_pDB.get()) return date; if (NULL == m_pDS.get()) return date; std::string strSQL = PrepareSQL("select * from repo where addonID='%s'",id.c_str()); m_pDS->query(strSQL.c_str()); if (!m_pDS->eof()) { date.SetFromDBDateTime(m_pDS->fv("lastcheck").get_asString()); return date; } } catch (...) { CLog::Log(LOGERROR, "%s failed on repo '%s'", __FUNCTION__, id.c_str()); } return date; }
std::pair<CDateTime, ADDON::AddonVersion> CAddonDatabase::LastChecked(const std::string& id) { CDateTime date; AddonVersion version("0.0.0"); try { if (m_pDB.get() != nullptr && m_pDS.get() != nullptr) { std::string strSQL = PrepareSQL("select * from repo where addonID='%s'",id.c_str()); m_pDS->query(strSQL); if (!m_pDS->eof()) { date.SetFromDBDateTime(m_pDS->fv("lastcheck").get_asString()); version = AddonVersion(m_pDS->fv("version").get_asString()); } } } catch (...) { CLog::Log(LOGERROR, "%s failed on repo '%s'", __FUNCTION__, id.c_str()); } return std::make_pair(date, version); }