PageRenderTime 32ms CodeModel.GetById 25ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/xbmc/utils/InfoLoader.cpp

http://github.com/xbmc/xbmc
C++ | 59 lines | 41 code | 10 blank | 8 comment | 4 complexity | 62d6949bfeba62fc9f1a689c833a198c MD5 | raw file
 1/*
 2 *  Copyright (C) 2005-2018 Team Kodi
 3 *  This file is part of Kodi - https://kodi.tv
 4 *
 5 *  SPDX-License-Identifier: GPL-2.0-or-later
 6 *  See LICENSES/README.md for more information.
 7 */
 8
 9#include "InfoLoader.h"
10
11#include "JobManager.h"
12#include "TimeUtils.h"
13#include "guilib/LocalizeStrings.h"
14
15CInfoLoader::CInfoLoader(unsigned int timeToRefresh)
16{
17  m_refreshTime = 0;
18  m_timeToRefresh = timeToRefresh;
19  m_busy = false;
20}
21
22CInfoLoader::~CInfoLoader() = default;
23
24void CInfoLoader::OnJobComplete(unsigned int jobID, bool success, CJob *job)
25{
26  m_refreshTime = CTimeUtils::GetFrameTime() + m_timeToRefresh;
27  m_busy = false;
28}
29
30std::string CInfoLoader::GetInfo(int info)
31{
32  // Refresh if need be
33  if (m_refreshTime < CTimeUtils::GetFrameTime() && !m_busy)
34  { // queue up the job
35    m_busy = true;
36    CJobManager::GetInstance().AddJob(GetJob(), this);
37  }
38  if (m_busy && CTimeUtils::GetFrameTime() - m_refreshTime > 1000)
39  {
40    return BusyInfo(info);
41  }
42  return TranslateInfo(info);
43}
44
45std::string CInfoLoader::BusyInfo(int info) const
46{
47  return g_localizeStrings.Get(503);
48}
49
50std::string CInfoLoader::TranslateInfo(int info) const
51{
52  return "";
53}
54
55void CInfoLoader::Refresh()
56{
57  m_refreshTime = CTimeUtils::GetFrameTime();
58}
59