bool CSavestateWriter::Initialize(const CGameClient* gameClient, uint64_t frameHistoryCount) { m_savestate.Reset(); m_fps = 0.0; m_fps = gameClient->Timing().GetFrameRate(); CDateTime now = CDateTime::GetCurrentDateTime(); std::string label = now.GetAsLocalizedDateTime(); m_savestate.SetType(SAVETYPE::MANUAL); m_savestate.SetLabel(label); m_savestate.SetGameClient(gameClient->ID()); m_savestate.SetGamePath(gameClient->GetGamePath()); m_savestate.SetTimestamp(now); m_savestate.SetPlaytimeFrames(frameHistoryCount); m_savestate.SetPlaytimeWallClock(frameHistoryCount / m_fps); //! @todo Accumulate playtime instead of deriving it //! @todo Get CRC from game data instead of filename Crc32 crc; crc.Compute(gameClient->GetGamePath()); m_savestate.SetGameCRC(StringUtils::Format("%08x", (unsigned __int32)crc)); m_savestate.SetPath(CSavestateUtils::MakePath(m_savestate)); if (m_savestate.Path().empty()) CLog::Log(LOGDEBUG, "Failed to calculate savestate path"); if (m_fps == 0.0) return false; // Sanity check return !m_savestate.Path().empty(); }
void CWeatherJob::SetFromProperties() { // Load in our tokens if necessary if (!m_localizedTokens.size()) LoadLocalizedToken(); CGUIWindow* window = g_windowManager.GetWindow(WINDOW_WEATHER); if (window) { CDateTime time = CDateTime::GetCurrentDateTime(); m_info.lastUpdateTime = time.GetAsLocalizedDateTime(false, false); m_info.currentConditions = window->GetProperty("Current.Condition").asString(); m_info.currentIcon = ConstructPath(window->GetProperty("Current.OutlookIcon").asString()); LocalizeOverview(m_info.currentConditions); FormatTemperature(m_info.currentTemperature, strtol(window->GetProperty("Current.Temperature").asString().c_str(),0,10)); FormatTemperature(m_info.currentFeelsLike, strtol(window->GetProperty("Current.FeelsLike").asString().c_str(),0,10)); m_info.currentUVIndex = window->GetProperty("Current.UVIndex").asString(); LocalizeOverview(m_info.currentUVIndex); int speed = ConvertSpeed(strtol(window->GetProperty("Current.Wind").asString().c_str(),0,10)); CStdString direction = window->GetProperty("Current.WindDirection").asString(); if (direction == "CALM") m_info.currentWind = g_localizeStrings.Get(1410); else { LocalizeOverviewToken(direction); m_info.currentWind.Format(g_localizeStrings.Get(434).c_str(), direction, speed, g_langInfo.GetSpeedUnitString().c_str()); } CStdString windspeed; windspeed.Format("%i %s",speed,g_langInfo.GetSpeedUnitString().c_str()); window->SetProperty("Current.WindSpeed",windspeed); FormatTemperature(m_info.currentDewPoint, strtol(window->GetProperty("Current.DewPoint").asString().c_str(),0,10)); if (window->GetProperty("Current.Humidity").asString().empty()) m_info.currentHumidity.clear(); else m_info.currentHumidity.Format("%s%%",window->GetProperty("Current.Humidity").asString().c_str()); m_info.location = window->GetProperty("Current.Location").asString(); for (int i=0;i<NUM_DAYS;++i) { CStdString strDay; strDay.Format("Day%i.Title",i); m_info.forecast[i].m_day = window->GetProperty(strDay).asString(); LocalizeOverviewToken(m_info.forecast[i].m_day); strDay.Format("Day%i.HighTemp",i); FormatTemperature(m_info.forecast[i].m_high, strtol(window->GetProperty(strDay).asString().c_str(),0,10)); strDay.Format("Day%i.LowTemp",i); FormatTemperature(m_info.forecast[i].m_low, strtol(window->GetProperty(strDay).asString().c_str(),0,10)); strDay.Format("Day%i.OutlookIcon",i); m_info.forecast[i].m_icon = ConstructPath(window->GetProperty(strDay).asString()); strDay.Format("Day%i.Outlook",i); m_info.forecast[i].m_overview = window->GetProperty(strDay).asString(); LocalizeOverview(m_info.forecast[i].m_overview); } } }
int CEpg::Get(CFileItemList &results) const { int iInitialSize = results.Size(); CSingleLock lock(m_critSection); for (map<CDateTime, CEpgInfoTag *>::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) { CDateTime localStartTime; localStartTime.SetFromUTCDateTime(it->first); CFileItemPtr entry(new CFileItem(*it->second)); entry->SetLabel2(localStartTime.GetAsLocalizedDateTime(false, false)); results.Add(entry); } return results.Size() - iInitialSize; }
bool CMythFile::SetupRecording(const CURL& url) { if (url.GetFileName().Left(11) != "recordings/" && url.GetFileName().Left(7) != "movies/" && url.GetFileName().Left(8) != "tvshows/") return false; if(!SetupConnection(url, true, false, false)) return false; m_filename = url.GetFileNameWithoutPath(); DLL_CTRL_CALL( m_program, m_program == NULL, m_control, proginfo_get_from_basename(m_control, m_filename.c_str()) ); if(!m_program) { CLog::Log(LOGERROR, "%s - unable to get find selected file", __FUNCTION__); return false; } DLL_CTRL_CALL( m_file, m_file == NULL, m_control, conn_connect_file(m_program, m_control, 16*1024, 4096) ); if(!m_file) { CLog::Log(LOGERROR, "%s - unable to connect to file", __FUNCTION__); return false; } /* * proginfo_get_from_basename doesn't return the recording status. Hopefully this will be added to * mythbackend eventually. * * Since cycling through the recorders to check if the program is recording takes some time * (depending on the MythTV backend configuration), make some assumptions based on the recording * end time since nearly all recordings opened won't be recording. */ m_recording = false; CDateTime start = GetValue(m_dll->proginfo_rec_start(m_program)); CDateTime end = GetValue(m_dll->proginfo_rec_end(m_program)); if (end > start // Assume could be recording if empty date comes back as the epoch && end < CDateTime::GetCurrentDateTime()) CLog::Log(LOGDEBUG, "%s - Assumed not recording since recording end time before current time: %s", __FUNCTION__, end.GetAsLocalizedDateTime().c_str()); else { CLog::Log(LOGDEBUG, "%s - Checking recording status using tuners since recording end time NULL or before current time: %s", __FUNCTION__, end.GetAsLocalizedDateTime().c_str()); for(int i=0;i<16 && !m_recording;i++) { cmyth_recorder_t recorder = NULL; DLL_CTRL_CALL( recorder, recorder == NULL, m_control, conn_get_recorder_from_num(m_control, i) ); if(!recorder) continue; if(m_dll->recorder_is_recording(recorder)) { cmyth_proginfo_t program = m_dll->recorder_get_cur_proginfo(recorder); if(m_dll->proginfo_compare(program, m_program) == 0) m_recording = true; m_dll->ref_release(program); } m_dll->ref_release(recorder); } } if (m_recording) CLog::Log(LOGDEBUG, "%s - Currently recording: %s", __FUNCTION__, m_filename.c_str()); return true; }