summaryrefslogtreecommitdiffstats
path: root/xbmc/utils/InfoLoader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/utils/InfoLoader.cpp')
-rw-r--r--xbmc/utils/InfoLoader.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/xbmc/utils/InfoLoader.cpp b/xbmc/utils/InfoLoader.cpp
new file mode 100644
index 0000000..cef6b70
--- /dev/null
+++ b/xbmc/utils/InfoLoader.cpp
@@ -0,0 +1,59 @@
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