[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / utils / InfoLoader.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://www.xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "InfoLoader.h"
22 #include "guilib/LocalizeStrings.h"
23 #include "JobManager.h"
24 #include "TimeUtils.h"
25
26 CInfoLoader::CInfoLoader(unsigned int timeToRefresh)
27 {
28   m_refreshTime = 0;
29   m_timeToRefresh = timeToRefresh;
30   m_busy = false;
31 }
32
33 CInfoLoader::~CInfoLoader()
34 {
35 }
36
37 void CInfoLoader::OnJobComplete(unsigned int jobID, bool success, CJob *job)
38 {
39   m_refreshTime = CTimeUtils::GetFrameTime() + m_timeToRefresh;
40   m_busy = false;
41 }
42
43 CStdString CInfoLoader::GetInfo(int info)
44 {
45   // Refresh if need be
46   if (m_refreshTime < CTimeUtils::GetFrameTime() && !m_busy)
47   { // queue up the job
48     m_busy = true;
49     CJobManager::GetInstance().AddJob(GetJob(), this);
50   }
51   if (m_busy)
52   {
53     return BusyInfo(info);
54   }
55   return TranslateInfo(info);
56 }
57
58 CStdString CInfoLoader::BusyInfo(int info) const
59 {
60   return g_localizeStrings.Get(503);
61 }
62
63 CStdString CInfoLoader::TranslateInfo(int info) const
64 {
65   return "";
66 }
67
68 void CInfoLoader::Refresh()
69 {
70   m_refreshTime = CTimeUtils::GetFrameTime();
71 }
72