diff options
| author | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
| commit | be933ef2241d79558f91796cc5b3a161f72ebf9c (patch) | |
| tree | fe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/utils/InfoLoader.cpp | |
| parent | 5f8335c1e49ce108ef3481863833c98efa00411b (diff) | |
| download | kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2 kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip | |
sync with upstream
Diffstat (limited to 'xbmc/utils/InfoLoader.cpp')
| -rw-r--r-- | xbmc/utils/InfoLoader.cpp | 59 |
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 | |||
| 15 | CInfoLoader::CInfoLoader(unsigned int timeToRefresh) | ||
| 16 | { | ||
| 17 | m_refreshTime = 0; | ||
| 18 | m_timeToRefresh = timeToRefresh; | ||
| 19 | m_busy = false; | ||
| 20 | } | ||
| 21 | |||
| 22 | CInfoLoader::~CInfoLoader() = default; | ||
| 23 | |||
| 24 | void CInfoLoader::OnJobComplete(unsigned int jobID, bool success, CJob *job) | ||
| 25 | { | ||
| 26 | m_refreshTime = CTimeUtils::GetFrameTime() + m_timeToRefresh; | ||
| 27 | m_busy = false; | ||
| 28 | } | ||
| 29 | |||
| 30 | std::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 | |||
| 45 | std::string CInfoLoader::BusyInfo(int info) const | ||
| 46 | { | ||
| 47 | return g_localizeStrings.Get(503); | ||
| 48 | } | ||
| 49 | |||
| 50 | std::string CInfoLoader::TranslateInfo(int info) const | ||
| 51 | { | ||
| 52 | return ""; | ||
| 53 | } | ||
| 54 | |||
| 55 | void CInfoLoader::Refresh() | ||
| 56 | { | ||
| 57 | m_refreshTime = CTimeUtils::GetFrameTime(); | ||
| 58 | } | ||
| 59 | |||
