CDateTime CPVRChannelGroup::GetEPGDate(EpgDateType epgDateType) const { CDateTime date; CSingleLock lock(m_critSection); for (std::vector<PVRChannelGroupMember>::const_iterator it = m_members.begin(); it != m_members.end(); it++) { if (it->channel && !it->channel->IsHidden()) { CEpg* epg = it->channel->GetEPG(); if (epg) { CDateTime epgDate; switch (epgDateType) { case EPG_FIRST_DATE: epgDate = epg->GetFirstDate(); if (epgDate.IsValid() && (!date.IsValid() || epgDate < date)) date = epgDate; break; case EPG_LAST_DATE: epgDate = epg->GetLastDate(); if (epgDate.IsValid() && (!date.IsValid() || epgDate > date)) date = epgDate; break; } } } } return date; }
CDateTime CPVRChannelGroup::GetEPGDate(EpgDateType epgDateType) const { CDateTime date; CEpgPtr epg; CPVRChannelPtr channel; CSingleLock lock(m_critSection); for (PVR_CHANNEL_GROUP_MEMBERS::const_iterator it = m_members.begin(); it != m_members.end(); ++it) { channel = it->second.channel; if (!channel->IsHidden() && (epg = channel->GetEPG())) { CDateTime epgDate; switch (epgDateType) { case EPG_FIRST_DATE: epgDate = epg->GetFirstDate(); if (epgDate.IsValid() && (!date.IsValid() || epgDate < date)) date = epgDate; break; case EPG_LAST_DATE: epgDate = epg->GetLastDate(); if (epgDate.IsValid() && (!date.IsValid() || epgDate > date)) date = epgDate; break; } } } return date; }
const CDateTime CEpgContainer::GetLastEPGDate(void) { CDateTime returnValue; CSingleLock lock(m_critSection); for (unsigned int iEpgPtr = 0; iEpgPtr < m_epgs.size(); iEpgPtr++) { CDateTime entry = m_epgs[iEpgPtr]->GetLastDate(); if (entry.IsValid() && (!returnValue.IsValid() || entry > returnValue)) returnValue = entry; } return returnValue; }
const CDateTime CEpgContainer::GetFirstEPGDate(void) const { CDateTime returnValue; CSingleLock lock(m_critSection); for (unsigned int iEpgPtr = 0; iEpgPtr < size(); iEpgPtr++) { CDateTime entry = at(iEpgPtr)->GetFirstDate(); if (entry.IsValid() && (!returnValue.IsValid() || entry < returnValue)) returnValue = entry; } return returnValue; }
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; }
const CDateTime CEpgContainer::GetLastEPGDate(void) { CDateTime returnValue; CSingleLock lock(m_critSection); for (map<unsigned int, CEpg *>::iterator it = m_epgs.begin(); it != m_epgs.end(); it++) { lock.Leave(); CDateTime entry = it->second->GetLastDate(); if (entry.IsValid() && (!returnValue.IsValid() || entry > returnValue)) returnValue = entry; lock.Enter(); } return returnValue; }
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 CPVRManager::SetWakeupCommand(void) { if (!g_guiSettings.GetBool("pvrpowermanagement.enabled")) return false; const CStdString strWakeupCommand = g_guiSettings.GetString("pvrpowermanagement.setwakeupcmd", false); if (!strWakeupCommand.IsEmpty() && m_timers) { time_t iWakeupTime; const CDateTime nextEvent = m_timers->GetNextEventTime(); if (nextEvent.IsValid()) { nextEvent.GetAsTime(iWakeupTime); CStdString strExecCommand; strExecCommand.Format("%s %d", strWakeupCommand, iWakeupTime); const int iReturn = system(strExecCommand.c_str()); if (iReturn != 0) CLog::Log(LOGERROR, "%s - failed to execute wakeup command '%s': %s (%d)", __FUNCTION__, strExecCommand.c_str(), strerror(iReturn), iReturn); return iReturn == 0; } } return false; }
bool CPVRManager::SetWakeupCommand(void) { #if !defined(TARGET_DARWIN_IOS) && !defined(TARGET_WINDOWS_STORE) if (!m_settings.GetBoolValue(CSettings::SETTING_PVRPOWERMANAGEMENT_ENABLED)) return false; const std::string strWakeupCommand(m_settings.GetStringValue(CSettings::SETTING_PVRPOWERMANAGEMENT_SETWAKEUPCMD)); if (!strWakeupCommand.empty() && m_timers) { time_t iWakeupTime; const CDateTime nextEvent = m_timers->GetNextEventTime(); if (nextEvent.IsValid()) { nextEvent.GetAsTime(iWakeupTime); std::string strExecCommand = StringUtils::Format("%s %ld", strWakeupCommand.c_str(), iWakeupTime); const int iReturn = system(strExecCommand.c_str()); if (iReturn != 0) CLog::LogF(LOGERROR, "PVR Manager failed to execute wakeup command '%s': %s (%d)", strExecCommand.c_str(), strerror(iReturn), iReturn); return iReturn == 0; } } #endif return false; }
const CDateTime CEpgContainer::GetLastEPGDate(void) { CDateTime returnValue; CSingleLock lock(m_critSection); for (const auto &epgEntry : m_epgs) { lock.Leave(); CDateTime entry = epgEntry.second->GetLastDate(); if (entry.IsValid() && (!returnValue.IsValid() || entry > returnValue)) returnValue = entry; lock.Enter(); } return returnValue; }
const CDateTime CEpgContainer::GetFirstEPGDate(void) { CDateTime returnValue; CSingleLock lock(m_critSection); for (EPGMAP_CITR it = m_epgs.begin(); it != m_epgs.end(); it++) { lock.Leave(); CDateTime entry = it->second->GetFirstDate(); if (entry.IsValid() && (!returnValue.IsValid() || entry < returnValue)) returnValue = entry; lock.Enter(); } return returnValue; }
bool CPVRManager::SetWakeupCommand(void) { if (!CSettings::GetInstance().GetBool(CSettings::SETTING_PVRPOWERMANAGEMENT_ENABLED)) return false; const std::string strWakeupCommand = CSettings::GetInstance().GetString(CSettings::SETTING_PVRPOWERMANAGEMENT_SETWAKEUPCMD); if (!strWakeupCommand.empty() && m_timers) { time_t iWakeupTime; const CDateTime nextEvent = m_timers->GetNextEventTime(); if (nextEvent.IsValid()) { nextEvent.GetAsTime(iWakeupTime); std::string strExecCommand = StringUtils::Format("%s %ld", strWakeupCommand.c_str(), iWakeupTime); const int iReturn = system(strExecCommand.c_str()); if (iReturn != 0) CLog::Log(LOGERROR, "%s - failed to execute wakeup command '%s': %s (%d)", __FUNCTION__, strExecCommand.c_str(), strerror(iReturn), iReturn); return iReturn == 0; } } return false; }
void CGUIDialogNumeric::SetMode(INPUT_MODE mode, const std::string &initial) { m_mode = mode; m_block = 0; m_lastblock = 0; if (m_mode == INPUT_TIME || m_mode == INPUT_TIME_SECONDS || m_mode == INPUT_DATE) { CDateTime dateTime; if (m_mode == INPUT_TIME || m_mode == INPUT_TIME_SECONDS) { // check if we have a pure number if (initial.find_first_not_of("0123456789") == std::string::npos) { long seconds = strtol(initial.c_str(), nullptr, 10); dateTime = seconds; } else { std::string tmp = initial; // if we are handling seconds and if the string only contains // "mm:ss" we need to add dummy "hh:" to get "hh:mm:ss" if (m_mode == INPUT_TIME_SECONDS && tmp.length() <= 5) tmp = "00:" + tmp; dateTime.SetFromDBTime(tmp); } } else if (m_mode == INPUT_DATE) { std::string tmp = initial; StringUtils::Replace(tmp, '/', '.'); dateTime.SetFromDBDate(tmp); } if (!dateTime.IsValid()) return; dateTime.GetAsSystemTime(m_datetime); m_lastblock = (m_mode == INPUT_DATE) ? 2 : 1; } else if (m_mode == INPUT_IP_ADDRESS) { m_lastblock = 3; auto blocks = StringUtils::Split(initial, '.'); if (blocks.size() != 4) return; for (size_t i = 0; i < blocks.size(); ++i) { if (blocks[i].length() > 3) return; m_ip[i] = static_cast<uint8_t>(atoi(blocks[i].c_str())); } } else if (m_mode == INPUT_NUMBER || m_mode == INPUT_PASSWORD) m_number = initial; }
bool CEpg::PersistTags(void) const { bool bReturn = false; CEpgDatabase *database = g_EpgContainer.GetDatabase(); if (!database || !database->IsOpen()) { CLog::Log(LOGERROR, "EPG - %s - could not load the database", __FUNCTION__); return bReturn; } CDateTime first = GetFirstDate(); CDateTime last = GetLastDate(); time_t iStart(0), iEnd(0); if (first.IsValid()) first.GetAsTime(iStart); if (last.IsValid()) last.GetAsTime(iEnd); database->Delete(*this, iStart, iEnd); if (m_tags.size() > 0) { for (map<CDateTime, CEpgInfoTag *>::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) { if (!it->second->Persist()) { CLog::Log(LOGERROR, "failed to persist epg tag %d", it->second->UniqueBroadcastID()); bReturn = false; } } } else { /* Return true if we have no tags, so that no error is logged */ bReturn = true; } return bReturn; }
wxString CTimeFormat::Format(CDateTime const& time) { wxString ret; if( time.IsValid() ) { if( time.GetAccuracy() > CDateTime::days ) { ret = FormatDateTime(time.Degenerate()); } else { ret = FormatDate(time.Degenerate()); } } return ret; }
bool CXmlFile::Modified() { wxCHECK(!m_fileName.empty(), false); if (!m_modificationTime.IsValid()) return true; CDateTime const modificationTime = CLocalFileSystem::GetModificationTime(m_fileName); if (modificationTime.IsValid() && modificationTime == m_modificationTime) return false; return true; }
CDateTime CAddonInstaller::LastRepoUpdate() const { CDateTime update; VECADDONS addons; CAddonMgr::Get().GetAddons(ADDON_REPOSITORY,addons); for (unsigned int i=0;i<addons.size();++i) { CAddonDatabase database; database.Open(); CDateTime lastUpdate = database.GetRepoTimestamp(addons[i]->ID()); if (lastUpdate.IsValid() && lastUpdate > update) update = lastUpdate; } return update; }
bool CLocalFileSystem::ConvertCDateTimeToFileTime(FILETIME &ft, const CDateTime& time) { if (!time.IsValid()) return false; wxLongLong t = time.Degenerate().GetValue(); t += EPOCH_OFFSET_IN_MSEC; t *= 10000; ft.dwHighDateTime = t.GetHi(); ft.dwLowDateTime = t.GetLo(); return true; }
bool CWebServer::IsRequestRanged(const HTTPRequest& request, const CDateTime &lastModified) const { // parse the Range header and store it in the request object CHttpRanges ranges; bool ranged = ranges.Parse(HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_RANGE)); // handle If-Range header but only if the Range header is present if (ranged && lastModified.IsValid()) { std::string ifRange = HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_RANGE); if (!ifRange.empty() && lastModified.IsValid()) { CDateTime ifRangeDate; ifRangeDate.SetFromRFC1123DateTime(ifRange); // check if the last modification is newer than the If-Range date // if so we have to server the whole file instead if (lastModified.GetAsUTCDateTime() > ifRangeDate) ranges.Clear(); } } return !ranges.IsEmpty(); }
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 CPVRTimers::GetNextEventTime(void) const { const bool dailywakup = m_settings.GetBoolValue(CSettings::SETTING_PVRPOWERMANAGEMENT_DAILYWAKEUP); const CDateTime now = CDateTime::GetUTCDateTime(); const CDateTimeSpan prewakeup(0, 0, m_settings.GetIntValue(CSettings::SETTING_PVRPOWERMANAGEMENT_PREWAKEUP), 0); const CDateTimeSpan idle(0, 0, m_settings.GetIntValue(CSettings::SETTING_PVRPOWERMANAGEMENT_BACKENDIDLETIME), 0); CDateTime wakeuptime; /* Check next active time */ const std::shared_ptr<CPVRTimerInfoTag> timer = GetNextActiveTimer(); if (timer) { const CDateTimeSpan prestart(0, 0, timer->MarginStart(), 0); const CDateTime start = timer->StartAsUTC(); wakeuptime = ((start - prestart - prewakeup - idle) > now) ? start - prestart - prewakeup : now + idle; } /* check daily wake up */ if (dailywakup) { CDateTime dailywakeuptime; dailywakeuptime.SetFromDBTime(m_settings.GetStringValue(CSettings::SETTING_PVRPOWERMANAGEMENT_DAILYWAKEUPTIME)); dailywakeuptime = dailywakeuptime.GetAsUTCDateTime(); dailywakeuptime.SetDateTime( now.GetYear(), now.GetMonth(), now.GetDay(), dailywakeuptime.GetHour(), dailywakeuptime.GetMinute(), dailywakeuptime.GetSecond() ); if ((dailywakeuptime - idle) < now) { const CDateTimeSpan oneDay(1,0,0,0); dailywakeuptime += oneDay; } if (!wakeuptime.IsValid() || dailywakeuptime < wakeuptime) wakeuptime = dailywakeuptime; } const CDateTime retVal(wakeuptime); return retVal; }
CDateTime CPVRTimers::GetNextEventTime(void) const { const bool dailywakup = CSettings::Get().GetBool("pvrpowermanagement.dailywakeup"); const CDateTime now = CDateTime::GetUTCDateTime(); const CDateTimeSpan prewakeup(0, 0, CSettings::Get().GetInt("pvrpowermanagement.prewakeup"), 0); const CDateTimeSpan idle(0, 0, CSettings::Get().GetInt("pvrpowermanagement.backendidletime"), 0); CDateTime wakeuptime; /* Check next active time */ CFileItemPtr item = GetNextActiveTimer(); if (item && item->HasPVRTimerInfoTag()) { const CDateTimeSpan prestart(0, 0, item->GetPVRTimerInfoTag()->MarginStart(), 0); const CDateTime start = item->GetPVRTimerInfoTag()->StartAsUTC(); wakeuptime = ((start - prestart - prewakeup - idle) > now) ? start - prestart - prewakeup : now + idle; } /* check daily wake up */ if (dailywakup) { CDateTime dailywakeuptime; dailywakeuptime.SetFromDBTime(CSettings::Get().GetString("pvrpowermanagement.dailywakeuptime")); dailywakeuptime = dailywakeuptime.GetAsUTCDateTime(); dailywakeuptime.SetDateTime( now.GetYear(), now.GetMonth(), now.GetDay(), dailywakeuptime.GetHour(), dailywakeuptime.GetMinute(), dailywakeuptime.GetSecond() ); if ((dailywakeuptime - idle) < now) { const CDateTimeSpan oneDay(1,0,0,0); dailywakeuptime += oneDay; } if (!wakeuptime.IsValid() || dailywakeuptime < wakeuptime) wakeuptime = dailywakeuptime; } const CDateTime retVal(wakeuptime); return retVal; }
CDateTime CPVRTimers::GetNextEventTime(void) const { const bool dailywakup = CSettings::GetInstance().GetBool(CSettings::SETTING_PVRPOWERMANAGEMENT_DAILYWAKEUP); const CDateTime now = CDateTime::GetUTCDateTime(); const CDateTimeSpan prewakeup(0, 0, CSettings::GetInstance().GetInt(CSettings::SETTING_PVRPOWERMANAGEMENT_PREWAKEUP), 0); const CDateTimeSpan idle(0, 0, CSettings::GetInstance().GetInt(CSettings::SETTING_PVRPOWERMANAGEMENT_BACKENDIDLETIME), 0); CDateTime wakeuptime; /* Check next active time */ CFileItemPtr item = GetNextActiveTimer(); if (item && item->HasPVRTimerInfoTag()) { const CDateTimeSpan prestart(0, 0, item->GetPVRTimerInfoTag()->MarginStart(), 0); const CDateTime start = item->GetPVRTimerInfoTag()->StartAsUTC(); wakeuptime = ((start - prestart - prewakeup - idle) > now) ? start - prestart - prewakeup : now + idle; } /* check daily wake up */ if (dailywakup) { CDateTime dailywakeuptime; dailywakeuptime.SetFromDBTime(CSettings::GetInstance().GetString(CSettings::SETTING_PVRPOWERMANAGEMENT_DAILYWAKEUPTIME)); dailywakeuptime = dailywakeuptime.GetAsUTCDateTime(); dailywakeuptime.SetDateTime( now.GetYear(), now.GetMonth(), now.GetDay(), dailywakeuptime.GetHour(), dailywakeuptime.GetMinute(), dailywakeuptime.GetSecond() ); if ((dailywakeuptime - idle) < now) { const CDateTimeSpan oneDay(1,0,0,0); dailywakeuptime += oneDay; } if (!wakeuptime.IsValid() || dailywakeuptime < wakeuptime) wakeuptime = dailywakeuptime; } const CDateTime retVal(wakeuptime); return retVal; }
void CAddonMgr::UpdateRepos(bool force) { CSingleLock lock(m_critSection); if (!force && m_watch.IsRunning() && m_watch.GetElapsedSeconds() < 600) return; m_watch.StartZero(); VECADDONS addons; GetAddons(ADDON_REPOSITORY,addons); for (unsigned int i=0;i<addons.size();++i) { RepositoryPtr repo = boost::dynamic_pointer_cast<CRepository>(addons[i]); CDateTime lastUpdate = m_database.GetRepoTimestamp(repo->ID()); if (force || !lastUpdate.IsValid() || lastUpdate + CDateTimeSpan(0,6,0,0) < CDateTime::GetCurrentDateTime()) { CLog::Log(LOGDEBUG,"Checking repository %s for updates",repo->Name().c_str()); CJobManager::GetInstance().AddJob(new CRepositoryUpdateJob(repo), NULL); } } }
void CGUIDialogNumeric::SetMode(INPUT_MODE mode, const CStdString &initial) { m_mode = mode; m_block = 0; m_lastblock = 0; if (m_mode == INPUT_TIME || m_mode == INPUT_TIME_SECONDS || m_mode == INPUT_DATE) { CDateTime dateTime; if (m_mode == INPUT_TIME || m_mode == INPUT_TIME_SECONDS) { // check if we have a pure number if (initial.find_first_not_of("0123456789") == std::string::npos) { long seconds = strtol(initial.c_str(), NULL, 10); dateTime = seconds; } else { CStdString tmp = initial; // if we are handling seconds and if the string only contains // "mm:ss" we need to add dummy "hh:" to get "hh:mm:ss" if (m_mode == INPUT_TIME_SECONDS && tmp.size() <= 5) tmp = "00:" + tmp; dateTime.SetFromDBTime(tmp); } } else if (m_mode == INPUT_DATE) { CStdString tmp = initial; StringUtils::Replace(tmp, '/', '.'); dateTime.SetFromDBDate(tmp); } if (!dateTime.IsValid()) return; dateTime.GetAsSystemTime(m_datetime); m_lastblock = (m_mode == INPUT_DATE) ? 2 : 1; } else SetMode(mode, (void*)&initial); }
bool CLocalFileSystem::ConvertFileTimeToCDateTime(CDateTime& time, const FILETIME &ft) { if (!ft.dwHighDateTime && !ft.dwLowDateTime) return false; // See http://trac.wxwidgets.org/changeset/74423 and http://trac.wxwidgets.org/ticket/13098 // Directly converting to time_t wxLongLong t(ft.dwHighDateTime, ft.dwLowDateTime); t /= 10000; // Convert hundreds of nanoseconds to milliseconds. t -= EPOCH_OFFSET_IN_MSEC; if (t < 0) { return false; } // Interestingly wxDateTime has this constructor which // even more interestingly isn't even marked explicit. time = CDateTime(wxDateTime(t), CDateTime::milliseconds); return time.IsValid(); }
void CFileExistsDlg::DisplayFile(bool left, wxString name, wxLongLong const& size, CDateTime const& time, wxString const& iconFile) { name = GetPathEllipsis(name, FindWindow(left ? XRCID("ID_FILE1_NAME") : XRCID("ID_FILE2_NAME"))); name.Replace(_T("&"), _T("&&")); wxString sizeStr = _("Size unknown"); if (size != -1) { bool const thousands_separator = COptions::Get()->GetOptionVal(OPTION_SIZE_USETHOUSANDSEP) != 0; sizeStr = CSizeFormat::Format(size, true, CSizeFormat::bytes, thousands_separator, 0); } wxString timeStr = _("Date/time unknown"); if (time.IsValid()) timeStr = CTimeFormat::Format(time); xrc_call(*this, left ? "ID_FILE1_NAME" : "ID_FILE2_NAME", &wxStaticText::SetLabel, name); xrc_call(*this, left ? "ID_FILE1_SIZE" : "ID_FILE2_SIZE", &wxStaticText::SetLabel, sizeStr); xrc_call(*this, left ? "ID_FILE1_TIME" : "ID_FILE2_TIME", &wxStaticText::SetLabel, timeStr); LoadIcon(left ? XRCID("ID_FILE1_ICON") : XRCID("ID_FILE2_ICON"), iconFile); }
void CAddonInstaller::UpdateRepos(bool force, bool wait) { CSingleLock lock(m_critSection); if (m_repoUpdateJob) { if (wait) { // wait for our job to complete lock.Leave(); CLog::Log(LOGDEBUG, "%s - waiting for repository update job to finish...", __FUNCTION__); m_repoUpdateDone.Wait(); } return; } // don't run repo update jobs while on the login screen which runs under the master profile if((g_windowManager.GetActiveWindow() & WINDOW_ID_MASK) == WINDOW_LOGIN_SCREEN) return; if (!force && m_repoUpdateWatch.IsRunning() && m_repoUpdateWatch.GetElapsedSeconds() < 600) return; m_repoUpdateWatch.StartZero(); VECADDONS addons; CAddonMgr::Get().GetAddons(ADDON_REPOSITORY,addons); for (unsigned int i=0;i<addons.size();++i) { CAddonDatabase database; database.Open(); CDateTime lastUpdate = database.GetRepoTimestamp(addons[i]->ID()); if (force || !lastUpdate.IsValid() || lastUpdate + CDateTimeSpan(0,6,0,0) < CDateTime::GetCurrentDateTime()) { CLog::Log(LOGDEBUG,"Checking repositories for updates (triggered by %s)",addons[i]->Name().c_str()); m_repoUpdateJob = CJobManager::GetInstance().AddJob(new CRepositoryUpdateJob(addons), this); if (wait) { // wait for our job to complete lock.Leave(); CLog::Log(LOGDEBUG, "%s - waiting for this repository update job to finish...", __FUNCTION__); m_repoUpdateDone.Wait(); } return; } } }
bool CLocalFileSystem::SetModificationTime(const wxString& path, const CDateTime& t) { if (!t.IsValid()) return false; #ifdef __WXMSW__ FILETIME ft; if (!ConvertCDateTimeToFileTime(ft, t)) return false; HANDLE h = CreateFile(path, GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); if (h == INVALID_HANDLE_VALUE) return false; bool ret = SetFileTime(h, 0, &ft, &ft) == TRUE; CloseHandle(h); return ret; #else wxFileName fn(path); wxDateTime d = t.Degenerate(); return fn.SetTimes( &d, &d, 0 ); #endif }
bool GetLastModifiedOfTestFile(const std::string& testFile, CDateTime& lastModified) { CFile file; if (!file.Open(URIUtils::AddFileToFolder(sourcePath, testFile), READ_NO_CACHE)) return false; struct __stat64 statBuffer; if (file.Stat(&statBuffer) != 0) return false; struct tm *time; #ifdef HAVE_LOCALTIME_R struct tm result = {}; time = localtime_r((time_t*)&statBuffer.st_mtime, &result); #else time = localtime((time_t *)&statBuffer.st_mtime); #endif if (time == NULL) return false; lastModified = *time; return lastModified.IsValid(); }