LinuxRendererGLES.h: correct path to `DVDVideoCodec.h`
[vuplus_xbmc] / xbmc / GUIInfoManager.cpp
1 /*
2  *      Copyright (C) 2005-2008 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, write to
17  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18  *  http://www.gnu.org/copyleft/gpl.html
19  *
20  */
21
22 #include "system.h"
23 #include "dialogs/GUIDialogSeekBar.h"
24 #include "windows/GUIMediaWindow.h"
25 #include "dialogs/GUIDialogFileBrowser.h"
26 #include "settings/GUIDialogContentSettings.h"
27 #include "dialogs/GUIDialogProgress.h"
28 #include "Application.h"
29 #include "Util.h"
30 #include "network/libscrobbler/lastfmscrobbler.h"
31 #include "utils/URIUtils.h"
32 #include "utils/Weather.h"
33 #include "PartyModeManager.h"
34 #include "addons/Visualisation.h"
35 #include "input/ButtonTranslator.h"
36 #include "utils/AlarmClock.h"
37 #ifdef HAS_LCD
38 #include "utils/LCD.h"
39 #endif
40 #include "GUIPassword.h"
41 #include "LangInfo.h"
42 #include "utils/SystemInfo.h"
43 #include "guilib/GUIButtonScroller.h"
44 #include "guilib/GUITextBox.h"
45 #include "GUIInfoManager.h"
46 #include "pictures/GUIWindowSlideShow.h"
47 #include "music/LastFmManager.h"
48 #include "pictures/PictureInfoTag.h"
49 #include "music/tags/MusicInfoTag.h"
50 #include "music/dialogs/GUIDialogMusicScan.h"
51 #include "video/dialogs/GUIDialogVideoScan.h"
52 #include "guilib/GUIWindowManager.h"
53 #include "filesystem/File.h"
54 #include "playlists/PlayList.h"
55 #include "utils/TuxBoxUtil.h"
56 #include "windowing/WindowingFactory.h"
57 #include "powermanagement/PowerManager.h"
58 #include "settings/AdvancedSettings.h"
59 #include "settings/Settings.h"
60 #include "guilib/LocalizeStrings.h"
61 #include "utils/CPUInfo.h"
62 #include "utils/StringUtils.h"
63 #include "utils/MathUtils.h"
64
65 // stuff for current song
66 #include "music/tags/MusicInfoTagLoaderFactory.h"
67 #include "music/MusicInfoLoader.h"
68 #include "utils/LabelFormatter.h"
69
70 #include "GUIUserMessages.h"
71 #include "video/dialogs/GUIDialogVideoInfo.h"
72 #include "music/dialogs/GUIDialogMusicInfo.h"
73 #include "storage/MediaManager.h"
74 #include "utils/TimeUtils.h"
75 #include "threads/SingleLock.h"
76 #include "utils/log.h"
77
78 #include "addons/AddonManager.h"
79
80 #define SYSHEATUPDATEINTERVAL 60000
81
82 using namespace std;
83 using namespace XFILE;
84 using namespace MUSIC_INFO;
85 using namespace ADDON;
86
87 CGUIInfoManager::CCombinedValue& CGUIInfoManager::CCombinedValue::operator =(const CGUIInfoManager::CCombinedValue& mSrc)
88 {
89   this->m_info = mSrc.m_info;
90   this->m_id = mSrc.m_id;
91   this->m_postfix = mSrc.m_postfix;
92   return *this;
93 }
94
95 CGUIInfoManager::CGUIInfoManager(void)
96 {
97   m_lastSysHeatInfoTime = -SYSHEATUPDATEINTERVAL;  // make sure we grab CPU temp on the first pass
98   m_lastMusicBitrateTime = 0;
99   m_fanSpeed = 0;
100   m_AfterSeekTimeout = 0;
101   m_seekOffset = 0;
102   m_playerSeeking = false;
103   m_performingSeek = false;
104   m_nextWindowID = WINDOW_INVALID;
105   m_prevWindowID = WINDOW_INVALID;
106   m_stringParameters.push_back("__ZZZZ__");   // to offset the string parameters by 1 to assure that all entries are non-zero
107   m_currentFile = new CFileItem;
108   m_currentSlide = new CFileItem;
109   m_frameCounter = 0;
110   m_lastFPSTime = 0;
111   ResetLibraryBools();
112 }
113
114 CGUIInfoManager::~CGUIInfoManager(void)
115 {
116   delete m_currentFile;
117   delete m_currentSlide;
118 }
119
120 bool CGUIInfoManager::OnMessage(CGUIMessage &message)
121 {
122   if (message.GetMessage() == GUI_MSG_NOTIFY_ALL)
123   {
124     if (message.GetParam1() == GUI_MSG_UPDATE_ITEM && message.GetItem())
125     {
126       CFileItemPtr item = boost::static_pointer_cast<CFileItem>(message.GetItem());
127       if (item && m_currentFile->m_strPath.Equals(item->m_strPath))
128         *m_currentFile = *item;
129       return true;
130     }
131   }
132   return false;
133 }
134
135 /// \brief Translates a string as given by the skin into an int that we use for more
136 /// efficient retrieval of data. Can handle combined strings on the form
137 /// Player.Caching + VideoPlayer.IsFullscreen (Logical and)
138 /// Player.HasVideo | Player.HasAudio (Logical or)
139 int CGUIInfoManager::TranslateString(const CStdString &condition)
140 {
141   // translate $LOCALIZE as required
142   CStdString strCondition(CGUIInfoLabel::ReplaceLocalize(condition));
143   if (strCondition.find_first_of("|") != strCondition.npos ||
144       strCondition.find_first_of("+") != strCondition.npos ||
145       strCondition.find_first_of("[") != strCondition.npos ||
146       strCondition.find_first_of("]") != strCondition.npos)
147   {
148     // Have a boolean expression
149     // Check if this was added before
150     vector<CCombinedValue>::iterator it;
151     for(it = m_CombinedValues.begin(); it != m_CombinedValues.end(); it++)
152     {
153       if(strCondition.CompareNoCase(it->m_info) == 0)
154         return it->m_id;
155     }
156     return TranslateBooleanExpression(strCondition);
157   }
158   //Just single command.
159   return TranslateSingleString(strCondition);
160 }
161
162
163 /// \brief Translates a string as given by the skin into an int that we use for more
164 /// efficient retrieval of data.
165 int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition)
166 {
167   // trim whitespace, and convert to lowercase
168   CStdString strTest = strCondition;
169   strTest.TrimLeft(" \t\r\n");
170   strTest.TrimRight(" \t\r\n");
171   if (strTest.IsEmpty()) return 0;
172
173   bool bNegate = strTest[0] == '!';
174   int ret = 0;
175
176   if(bNegate)
177     strTest.Delete(0, 1);
178   CStdString original(strTest);
179   strTest.ToLower();
180
181   CStdString strCategory = strTest.Left(strTest.Find("."));
182
183   // translate conditions...
184   if (strTest.Equals("false") || strTest.Equals("no") || strTest.Equals("off")) ret = SYSTEM_ALWAYS_FALSE;
185   else if (strTest.Equals("true") || strTest.Equals("yes") || strTest.Equals("on")) ret = SYSTEM_ALWAYS_TRUE;
186   if (strCategory.Equals("player"))
187   {
188     if (strTest.Equals("player.hasmedia")) ret = PLAYER_HAS_MEDIA;
189     else if (strTest.Equals("player.hasaudio")) ret = PLAYER_HAS_AUDIO;
190     else if (strTest.Equals("player.hasvideo")) ret = PLAYER_HAS_VIDEO;
191     else if (strTest.Equals("player.playing")) ret = PLAYER_PLAYING;
192     else if (strTest.Equals("player.paused")) ret = PLAYER_PAUSED;
193     else if (strTest.Equals("player.rewinding")) ret = PLAYER_REWINDING;
194     else if (strTest.Equals("player.forwarding")) ret = PLAYER_FORWARDING;
195     else if (strTest.Equals("player.rewinding2x")) ret = PLAYER_REWINDING_2x;
196     else if (strTest.Equals("player.rewinding4x")) ret = PLAYER_REWINDING_4x;
197     else if (strTest.Equals("player.rewinding8x")) ret = PLAYER_REWINDING_8x;
198     else if (strTest.Equals("player.rewinding16x")) ret = PLAYER_REWINDING_16x;
199     else if (strTest.Equals("player.rewinding32x")) ret = PLAYER_REWINDING_32x;
200     else if (strTest.Equals("player.forwarding2x")) ret = PLAYER_FORWARDING_2x;
201     else if (strTest.Equals("player.forwarding4x")) ret = PLAYER_FORWARDING_4x;
202     else if (strTest.Equals("player.forwarding8x")) ret = PLAYER_FORWARDING_8x;
203     else if (strTest.Equals("player.forwarding16x")) ret = PLAYER_FORWARDING_16x;
204     else if (strTest.Equals("player.forwarding32x")) ret = PLAYER_FORWARDING_32x;
205     else if (strTest.Equals("player.canrecord")) ret = PLAYER_CAN_RECORD;
206     else if (strTest.Equals("player.recording")) ret = PLAYER_RECORDING;
207     else if (strTest.Equals("player.displayafterseek")) ret = PLAYER_DISPLAY_AFTER_SEEK;
208     else if (strTest.Equals("player.caching")) ret = PLAYER_CACHING;
209     else if (strTest.Equals("player.cachelevel")) ret = PLAYER_CACHELEVEL;
210     else if (strTest.Equals("player.seekbar")) ret = PLAYER_SEEKBAR;
211     else if (strTest.Equals("player.progress")) ret = PLAYER_PROGRESS;
212     else if (strTest.Equals("player.seeking")) ret = PLAYER_SEEKING;
213     else if (strTest.Equals("player.showtime")) ret = PLAYER_SHOWTIME;
214     else if (strTest.Equals("player.showcodec")) ret = PLAYER_SHOWCODEC;
215     else if (strTest.Equals("player.showinfo")) ret = PLAYER_SHOWINFO;
216     else if (strTest.Left(15).Equals("player.seektime")) return AddMultiInfo(GUIInfo(PLAYER_SEEKTIME, TranslateTimeFormat(strTest.Mid(15))));
217     else if (strTest.Left(17).Equals("player.seekoffset")) return AddMultiInfo(GUIInfo(PLAYER_SEEKOFFSET, TranslateTimeFormat(strTest.Mid(17))));
218     else if (strTest.Left(20).Equals("player.timeremaining")) return AddMultiInfo(GUIInfo(PLAYER_TIME_REMAINING, TranslateTimeFormat(strTest.Mid(20))));
219     else if (strTest.Left(16).Equals("player.timespeed")) return AddMultiInfo(GUIInfo(PLAYER_TIME_SPEED, TranslateTimeFormat(strTest.Mid(16))));
220     else if (strTest.Left(11).Equals("player.time")) return AddMultiInfo(GUIInfo(PLAYER_TIME, TranslateTimeFormat(strTest.Mid(11))));
221     else if (strTest.Left(15).Equals("player.duration")) return AddMultiInfo(GUIInfo(PLAYER_DURATION, TranslateTimeFormat(strTest.Mid(15))));
222     else if (strTest.Left(17).Equals("player.finishtime")) return AddMultiInfo(GUIInfo(PLAYER_FINISH_TIME, TranslateTimeFormat(strTest.Mid(17))));
223     else if (strTest.Equals("player.volume")) ret = PLAYER_VOLUME;
224     else if (strTest.Equals("player.subtitledelay")) ret = PLAYER_SUBTITLE_DELAY;
225     else if (strTest.Equals("player.audiodelay")) ret = PLAYER_AUDIO_DELAY;
226     else if (strTest.Equals("player.muted")) ret = PLAYER_MUTED;
227     else if (strTest.Equals("player.hasduration")) ret = PLAYER_HASDURATION;
228     else if (strTest.Equals("player.chapter")) ret = PLAYER_CHAPTER;
229     else if (strTest.Equals("player.chaptercount")) ret = PLAYER_CHAPTERCOUNT;
230     else if (strTest.Equals("player.chaptername")) ret = PLAYER_CHAPTERNAME;
231     else if (strTest.Equals("player.starrating")) ret = PLAYER_STAR_RATING;
232     else if (strTest.Equals("player.passthrough")) ret = PLAYER_PASSTHROUGH;
233     else if (strTest.Equals("player.folderpath")) ret = PLAYER_PATH;
234     else if (strTest.Equals("player.filenameandpath")) ret = PLAYER_FILEPATH;
235   }
236   else if (strCategory.Equals("weather"))
237   {
238     if (strTest.Equals("weather.conditions")) ret = WEATHER_CONDITIONS;
239     else if (strTest.Equals("weather.temperature")) ret = WEATHER_TEMPERATURE;
240     else if (strTest.Equals("weather.location")) ret = WEATHER_LOCATION;
241     else if (strTest.Equals("weather.isfetched")) ret = WEATHER_IS_FETCHED;
242     else if (strTest.Equals("weather.fanartcode")) ret = WEATHER_FANART_CODE;
243     else if (strTest.Equals("weather.plugin")) ret = WEATHER_PLUGIN;
244   }
245   else if (strCategory.Equals("bar"))
246   {
247     if (strTest.Equals("bar.gputemperature")) ret = SYSTEM_GPU_TEMPERATURE;
248     else if (strTest.Equals("bar.cputemperature")) ret = SYSTEM_CPU_TEMPERATURE;
249     else if (strTest.Equals("bar.cpuusage")) ret = SYSTEM_CPU_USAGE;
250     else if (strTest.Equals("bar.freememory")) ret = SYSTEM_FREE_MEMORY;
251     else if (strTest.Equals("bar.usedmemory")) ret = SYSTEM_USED_MEMORY;
252     else if (strTest.Equals("bar.fanspeed")) ret = SYSTEM_FAN_SPEED;
253     else if (strTest.Equals("bar.usedspace")) ret = SYSTEM_USED_SPACE;
254     else if (strTest.Equals("bar.freespace")) ret = SYSTEM_FREE_SPACE;
255     else if (strTest.Equals("bar.usedspace(c)")) ret = SYSTEM_USED_SPACE_C;
256     else if (strTest.Equals("bar.freespace(c)")) ret = SYSTEM_FREE_SPACE_C;
257     else if (strTest.Equals("bar.usedspace(e)")) ret = SYSTEM_USED_SPACE_E;
258     else if (strTest.Equals("bar.freespace(e)")) ret = SYSTEM_FREE_SPACE_E;
259     else if (strTest.Equals("bar.usedspace(f)")) ret = SYSTEM_USED_SPACE_F;
260     else if (strTest.Equals("bar.freespace(f)")) ret = SYSTEM_FREE_SPACE_F;
261     else if (strTest.Equals("bar.usedspace(g)")) ret = SYSTEM_USED_SPACE_G;
262     else if (strTest.Equals("bar.freespace(g)")) ret = SYSTEM_FREE_SPACE_G;
263     else if (strTest.Equals("bar.usedspace(x)")) ret = SYSTEM_USED_SPACE_X;
264     else if (strTest.Equals("bar.freespace(x)")) ret = SYSTEM_FREE_SPACE_X;
265     else if (strTest.Equals("bar.usedspace(y)")) ret = SYSTEM_USED_SPACE_Y;
266     else if (strTest.Equals("bar.freespace(y)")) ret = SYSTEM_FREE_SPACE_Y;
267     else if (strTest.Equals("bar.usedspace(z)")) ret = SYSTEM_USED_SPACE_Z;
268     else if (strTest.Equals("bar.freespace(z)")) ret = SYSTEM_FREE_SPACE_Z;
269     else if (strTest.Equals("bar.hddtemperature")) ret = SYSTEM_HDD_TEMPERATURE;
270   }
271   else if (strCategory.Equals("system"))
272   {
273     if (strTest.Equals("system.date")) ret = SYSTEM_DATE;
274     else if (strTest.Left(12).Equals("system.date("))
275     {
276       // the skin must submit the date in the format MM-DD
277       // This InfoBool is designed for generic range checking, so year is NOT used.  Only Month-Day.
278       CStdString param = strTest.Mid(12, strTest.length() - 13);
279       CStdStringArray params;
280       StringUtils::SplitString(param, ",", params);
281       if (params.size() == 2)
282         return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_DATE : SYSTEM_DATE, StringUtils::DateStringToYYYYMMDD(params[0]) % 10000, StringUtils::DateStringToYYYYMMDD(params[1]) % 10000));
283       else if (params.size() == 1)
284         return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_DATE : SYSTEM_DATE, StringUtils::DateStringToYYYYMMDD(params[0]) % 10000));
285     }
286     else if (strTest.Left(11).Equals("system.time"))
287     {
288       // determine if this is a System.Time(TIME_FORMAT) infolabel or a System.Time(13:00,14:00) boolean based on the contents of the param
289       // essentially if it isn't a valid TIME_FORMAT then its considered to be the latter.
290       CStdString param = strTest.Mid(11);
291       TIME_FORMAT timeFormat = TranslateTimeFormat(param);
292       if ((timeFormat == TIME_FORMAT_GUESS) && (!param.IsEmpty()))
293       {
294         param = strTest.Mid(12, strTest.length() - 13);
295         CStdStringArray params;
296         StringUtils::SplitString(param, ",", params);
297         if (params.size() == 2)
298           return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_TIME : SYSTEM_TIME, StringUtils::TimeStringToSeconds(params[0]), StringUtils::TimeStringToSeconds(params[1])));
299         else if (params.size() == 1)
300           return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_TIME : SYSTEM_TIME, StringUtils::TimeStringToSeconds(params[0])));
301       }
302       else
303         return AddMultiInfo(GUIInfo(SYSTEM_TIME, timeFormat));
304     }
305     else if (strTest.Equals("system.cputemperature")) ret = SYSTEM_CPU_TEMPERATURE;
306     else if (strTest.Equals("system.cpuusage")) ret = SYSTEM_CPU_USAGE;
307     else if (strTest.Equals("system.gputemperature")) ret = SYSTEM_GPU_TEMPERATURE;
308     else if (strTest.Equals("system.fanspeed")) ret = SYSTEM_FAN_SPEED;
309     else if (strTest.Equals("system.freespace")) ret = SYSTEM_FREE_SPACE;
310     else if (strTest.Equals("system.usedspace")) ret = SYSTEM_USED_SPACE;
311     else if (strTest.Equals("system.totalspace")) ret = SYSTEM_TOTAL_SPACE;
312     else if (strTest.Equals("system.usedspacepercent")) ret = SYSTEM_USED_SPACE_PERCENT;
313     else if (strTest.Equals("system.freespacepercent")) ret = SYSTEM_FREE_SPACE_PERCENT;
314     else if (strTest.Equals("system.freespace(c)")) ret = SYSTEM_FREE_SPACE_C;
315     else if (strTest.Equals("system.usedspace(c)")) ret = SYSTEM_USED_SPACE_C;
316     else if (strTest.Equals("system.totalspace(c)")) ret = SYSTEM_TOTAL_SPACE_C;
317     else if (strTest.Equals("system.usedspacepercent(c)")) ret = SYSTEM_USED_SPACE_PERCENT_C;
318     else if (strTest.Equals("system.freespacepercent(c)")) ret = SYSTEM_FREE_SPACE_PERCENT_C;
319     else if (strTest.Equals("system.freespace(e)")) ret = SYSTEM_FREE_SPACE_E;
320     else if (strTest.Equals("system.usedspace(e)")) ret = SYSTEM_USED_SPACE_E;
321     else if (strTest.Equals("system.totalspace(e)")) ret = SYSTEM_TOTAL_SPACE_E;
322     else if (strTest.Equals("system.usedspacepercent(e)")) ret = SYSTEM_USED_SPACE_PERCENT_E;
323     else if (strTest.Equals("system.freespacepercent(e)")) ret = SYSTEM_FREE_SPACE_PERCENT_E;
324     else if (strTest.Equals("system.freespace(f)")) ret = SYSTEM_FREE_SPACE_F;
325     else if (strTest.Equals("system.usedspace(f)")) ret = SYSTEM_USED_SPACE_F;
326     else if (strTest.Equals("system.totalspace(f)")) ret = SYSTEM_TOTAL_SPACE_F;
327     else if (strTest.Equals("system.usedspacepercent(f)")) ret = SYSTEM_USED_SPACE_PERCENT_F;
328     else if (strTest.Equals("system.freespacepercent(f)")) ret = SYSTEM_FREE_SPACE_PERCENT_F;
329     else if (strTest.Equals("system.freespace(g)")) ret = SYSTEM_FREE_SPACE_G;
330     else if (strTest.Equals("system.usedspace(g)")) ret = SYSTEM_USED_SPACE_G;
331     else if (strTest.Equals("system.totalspace(g)")) ret = SYSTEM_TOTAL_SPACE_G;
332     else if (strTest.Equals("system.usedspacepercent(g)")) ret = SYSTEM_USED_SPACE_PERCENT_G;
333     else if (strTest.Equals("system.freespacepercent(g)")) ret = SYSTEM_FREE_SPACE_PERCENT_G;
334     else if (strTest.Equals("system.usedspace(x)")) ret = SYSTEM_USED_SPACE_X;
335     else if (strTest.Equals("system.freespace(x)")) ret = SYSTEM_FREE_SPACE_X;
336     else if (strTest.Equals("system.totalspace(x)")) ret = SYSTEM_TOTAL_SPACE_X;
337     else if (strTest.Equals("system.usedspace(y)")) ret = SYSTEM_USED_SPACE_Y;
338     else if (strTest.Equals("system.freespace(y)")) ret = SYSTEM_FREE_SPACE_Y;
339     else if (strTest.Equals("system.totalspace(y)")) ret = SYSTEM_TOTAL_SPACE_Y;
340     else if (strTest.Equals("system.usedspace(z)")) ret = SYSTEM_USED_SPACE_Z;
341     else if (strTest.Equals("system.freespace(z)")) ret = SYSTEM_FREE_SPACE_Z;
342     else if (strTest.Equals("system.totalspace(z)")) ret = SYSTEM_TOTAL_SPACE_Z;
343     else if (strTest.Equals("system.buildversion")) ret = SYSTEM_BUILD_VERSION;
344     else if (strTest.Equals("system.builddate")) ret = SYSTEM_BUILD_DATE;
345     else if (strTest.Equals("system.hasnetwork")) ret = SYSTEM_ETHERNET_LINK_ACTIVE;
346     else if (strTest.Equals("system.fps")) ret = SYSTEM_FPS;
347     else if (strTest.Equals("system.hasmediadvd")) ret = SYSTEM_MEDIA_DVD;
348     else if (strTest.Equals("system.dvdready")) ret = SYSTEM_DVDREADY;
349     else if (strTest.Equals("system.trayopen")) ret = SYSTEM_TRAYOPEN;
350     else if (strTest.Equals("system.dvdtraystate")) ret = SYSTEM_DVD_TRAY_STATE;
351
352     else if (strTest.Equals("system.memory(free)") || strTest.Equals("system.freememory")) ret = SYSTEM_FREE_MEMORY;
353     else if (strTest.Equals("system.memory(free.percent)")) ret = SYSTEM_FREE_MEMORY_PERCENT;
354     else if (strTest.Equals("system.memory(used)")) ret = SYSTEM_USED_MEMORY;
355     else if (strTest.Equals("system.memory(used.percent)")) ret = SYSTEM_USED_MEMORY_PERCENT;
356     else if (strTest.Equals("system.memory(total)")) ret = SYSTEM_TOTAL_MEMORY;
357
358     else if (strTest.Equals("system.language")) ret = SYSTEM_LANGUAGE;
359     else if (strTest.Equals("system.temperatureunits")) ret = SYSTEM_TEMPERATURE_UNITS;
360     else if (strTest.Equals("system.screenmode")) ret = SYSTEM_SCREEN_MODE;
361     else if (strTest.Equals("system.screenwidth")) ret = SYSTEM_SCREEN_WIDTH;
362     else if (strTest.Equals("system.screenheight")) ret = SYSTEM_SCREEN_HEIGHT;
363     else if (strTest.Equals("system.currentwindow")) ret = SYSTEM_CURRENT_WINDOW;
364     else if (strTest.Equals("system.currentcontrol")) ret = SYSTEM_CURRENT_CONTROL;
365     else if (strTest.Equals("system.dvdlabel")) ret = SYSTEM_DVD_LABEL;
366     else if (strTest.Equals("system.haslocks")) ret = SYSTEM_HASLOCKS;
367     else if (strTest.Equals("system.hasloginscreen")) ret = SYSTEM_HAS_LOGINSCREEN;
368     else if (strTest.Equals("system.ismaster")) ret = SYSTEM_ISMASTER;
369     else if (strTest.Equals("system.internetstate")) ret = SYSTEM_INTERNET_STATE;
370     else if (strTest.Equals("system.loggedon")) ret = SYSTEM_LOGGEDON;
371     else if (strTest.Equals("system.hasdrivef")) ret = SYSTEM_HAS_DRIVE_F;
372     else if (strTest.Equals("system.hasdriveg")) ret = SYSTEM_HAS_DRIVE_G;
373     else if (strTest.Equals("system.kernelversion")) ret = SYSTEM_KERNEL_VERSION;
374     else if (strTest.Equals("system.uptime")) ret = SYSTEM_UPTIME;
375     else if (strTest.Equals("system.totaluptime")) ret = SYSTEM_TOTALUPTIME;
376     else if (strTest.Equals("system.cpufrequency")) ret = SYSTEM_CPUFREQUENCY;
377     else if (strTest.Equals("system.screenresolution")) ret = SYSTEM_SCREEN_RESOLUTION;
378     else if (strTest.Equals("system.videoencoderinfo")) ret = SYSTEM_VIDEO_ENCODER_INFO;
379     else if (strTest.Left(16).Equals("system.idletime("))
380     {
381       int time = atoi((strTest.Mid(16, strTest.GetLength() - 17).c_str()));
382       if (time > SYSTEM_IDLE_TIME_FINISH - SYSTEM_IDLE_TIME_START)
383         time = SYSTEM_IDLE_TIME_FINISH - SYSTEM_IDLE_TIME_START;
384       if (time > 0)
385         ret = SYSTEM_IDLE_TIME_START + time;
386     }
387     else if (strTest.Left(16).Equals("system.hasalarm("))
388       return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_HAS_ALARM : SYSTEM_HAS_ALARM, ConditionalStringParameter(strTest.Mid(16,strTest.size()-17)), 0));
389     else if (strTest.Equals("system.alarmpos")) ret = SYSTEM_ALARM_POS;
390     else if (strTest.Left(24).Equals("system.alarmlessorequal("))
391     {
392       int pos = strTest.Find(",");
393       int skinOffset = ConditionalStringParameter(strTest.Mid(24, pos-24));
394       int compareString = ConditionalStringParameter(strTest.Mid(pos + 1, strTest.GetLength() - (pos + 2)));
395       return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_ALARM_LESS_OR_EQUAL: SYSTEM_ALARM_LESS_OR_EQUAL, skinOffset, compareString));
396     }
397     else if (strTest.Equals("system.profilename")) ret = SYSTEM_PROFILENAME;
398     else if (strTest.Equals("system.profilethumb")) ret = SYSTEM_PROFILETHUMB;
399     else if (strTest.Equals("system.profilecount")) ret = SYSTEM_PROFILECOUNT;
400     else if (strTest.Equals("system.progressbar")) ret = SYSTEM_PROGRESS_BAR;
401     else if (strTest.Equals("system.platform.linux")) ret = SYSTEM_PLATFORM_LINUX;
402     else if (strTest.Equals("system.platform.xbox")) ret = SYSTEM_PLATFORM_XBOX;
403     else if (strTest.Equals("system.platform.windows")) ret = SYSTEM_PLATFORM_WINDOWS;
404     else if (strTest.Equals("system.platform.osx")) ret = SYSTEM_PLATFORM_OSX;
405     else if (strTest.Left(15).Equals("system.getbool("))
406       return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_GET_BOOL : SYSTEM_GET_BOOL, ConditionalStringParameter(strTest.Mid(15,strTest.size()-16)), 0));
407     else if (strTest.Left(17).Equals("system.coreusage("))
408       return AddMultiInfo(GUIInfo(SYSTEM_GET_CORE_USAGE, atoi(strTest.Mid(17,strTest.size()-18)), 0));
409     else if (strTest.Left(17).Equals("system.hascoreid("))
410       return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_HAS_CORE_ID : SYSTEM_HAS_CORE_ID, ConditionalStringParameter(strTest.Mid(17,strTest.size()-18)), 0));
411     else if (strTest.Left(15).Equals("system.setting("))
412       return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_SETTING : SYSTEM_SETTING, ConditionalStringParameter(strTest.Mid(15,strTest.size()-16)), 0));
413     else if (strTest.Equals("system.canpowerdown")) ret = SYSTEM_CAN_POWERDOWN;
414     else if (strTest.Equals("system.cansuspend"))   ret = SYSTEM_CAN_SUSPEND;
415     else if (strTest.Equals("system.canhibernate")) ret = SYSTEM_CAN_HIBERNATE;
416     else if (strTest.Equals("system.canreboot"))    ret = SYSTEM_CAN_REBOOT;
417     else if (strTest.Left(16).Equals("system.hasaddon("))
418       return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_HAS_ADDON: SYSTEM_HAS_ADDON, ConditionalStringParameter(strTest.Mid(16,strTest.size()-17)), 0));
419     else if (strTest.Left(18).Equals("system.addontitle("))
420     {
421       CStdString param = strTest.Mid(18,strTest.size()-19);
422       int info = TranslateString(param);
423       if (info > 0)
424         return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_ADDON_TITLE: SYSTEM_ADDON_TITLE, info, 0));
425     // pipe our original string through the localize parsing then make it lowercase (picks up $LBRACKET etc.)
426       CStdString label = CGUIInfoLabel::GetLabel(param).ToLower();
427       int compareString = ConditionalStringParameter(label);
428       return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_ADDON_TITLE: SYSTEM_ADDON_TITLE, compareString, 1));
429     }
430     else if (strTest.Left(17).Equals("system.addonicon("))
431     {
432       CStdString param = strTest.Mid(17,strTest.size()-18);
433       int info = TranslateString(param);
434       if (info > 0)
435         return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_ADDON_ICON: SYSTEM_ADDON_ICON, info, 0));
436     // pipe our original string through the localize parsing then make it lowercase (picks up $LBRACKET etc.)
437       CStdString label = CGUIInfoLabel::GetLabel(param).ToLower();
438       int compareString = ConditionalStringParameter(label);
439       return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_ADDON_ICON : SYSTEM_ADDON_ICON, compareString, 1));
440     }
441   }
442   // library test conditions
443   else if (strTest.Left(7).Equals("library"))
444   {
445     if (strTest.Equals("library.hascontent(music)")) ret = LIBRARY_HAS_MUSIC;
446     else if (strTest.Equals("library.hascontent(video)")) ret = LIBRARY_HAS_VIDEO;
447     else if (strTest.Equals("library.hascontent(movies)")) ret = LIBRARY_HAS_MOVIES;
448     else if (strTest.Equals("library.hascontent(tvshows)")) ret = LIBRARY_HAS_TVSHOWS;
449     else if (strTest.Equals("library.hascontent(musicvideos)")) ret = LIBRARY_HAS_MUSICVIDEOS;
450     else if (strTest.Equals("library.isscanning")) ret = LIBRARY_IS_SCANNING;
451   }
452   else if (strTest.Left(8).Equals("isempty("))
453   {
454     CStdString str = strTest.Mid(8, strTest.GetLength() - 9);
455     return AddMultiInfo(GUIInfo(bNegate ? -STRING_IS_EMPTY : STRING_IS_EMPTY, TranslateSingleString(str)));
456   }
457   else if (strTest.Left(14).Equals("stringcompare("))
458   {
459     int pos = strTest.Find(",");
460     int info = TranslateString(strTest.Mid(14, pos-14));
461     int info2 = TranslateString(strTest.Mid(pos + 1, strTest.GetLength() - (pos + 2)));
462     if (info2 > 0)
463       return AddMultiInfo(GUIInfo(bNegate ? -STRING_COMPARE: STRING_COMPARE, info, -info2));
464     // pipe our original string through the localize parsing then make it lowercase (picks up $LBRACKET etc.)
465     CStdString label = CGUIInfoLabel::GetLabel(original.Mid(pos + 1, original.GetLength() - (pos + 2))).ToLower();
466     int compareString = ConditionalStringParameter(label);
467     return AddMultiInfo(GUIInfo(bNegate ? -STRING_COMPARE: STRING_COMPARE, info, compareString));
468   }
469   else if (strTest.Left(19).Equals("integergreaterthan("))
470   {
471     int pos = strTest.Find(",");
472     int info = TranslateString(strTest.Mid(19, pos-19));
473     int compareInt = atoi(strTest.Mid(pos + 1, strTest.GetLength() - (pos + 2)).c_str());
474     return AddMultiInfo(GUIInfo(bNegate ? -INTEGER_GREATER_THAN: INTEGER_GREATER_THAN, info, compareInt));
475   }
476   else if (strTest.Left(10).Equals("substring("))
477   {
478     int pos = strTest.Find(",");
479     int info = TranslateString(strTest.Mid(10, pos-10));
480     // pipe our original string through the localize parsing then make it lowercase (picks up $LBRACKET etc.)
481     CStdString label = CGUIInfoLabel::GetLabel(original.Mid(pos + 1, original.GetLength() - (pos + 2))).ToLower();
482     int compareString = ConditionalStringParameter(label);
483     return AddMultiInfo(GUIInfo(bNegate ? -STRING_STR: STRING_STR, info, compareString));
484   }
485   else if (strCategory.Equals("lcd"))
486   {
487     if (strTest.Equals("lcd.playicon")) ret = LCD_PLAY_ICON;
488     else if (strTest.Equals("lcd.progressbar")) ret = LCD_PROGRESS_BAR;
489     else if (strTest.Equals("lcd.cputemperature")) ret = LCD_CPU_TEMPERATURE;
490     else if (strTest.Equals("lcd.gputemperature")) ret = LCD_GPU_TEMPERATURE;
491     else if (strTest.Equals("lcd.hddtemperature")) ret = LCD_HDD_TEMPERATURE;
492     else if (strTest.Equals("lcd.fanspeed")) ret = LCD_FAN_SPEED;
493     else if (strTest.Equals("lcd.date")) ret = LCD_DATE;
494     else if (strTest.Equals("lcd.freespace(c)")) ret = LCD_FREE_SPACE_C;
495     else if (strTest.Equals("lcd.freespace(e)")) ret = LCD_FREE_SPACE_E;
496     else if (strTest.Equals("lcd.freespace(f)")) ret = LCD_FREE_SPACE_F;
497     else if (strTest.Equals("lcd.freespace(g)")) ret = LCD_FREE_SPACE_G;
498     else if (strTest.Equals("lcd.Time21")) ret = LCD_TIME_21; // Small LCD numbers
499     else if (strTest.Equals("lcd.Time22")) ret = LCD_TIME_22;
500     else if (strTest.Equals("lcd.TimeWide21")) ret = LCD_TIME_W21; // Medium LCD numbers
501     else if (strTest.Equals("lcd.TimeWide22")) ret = LCD_TIME_W22;
502     else if (strTest.Equals("lcd.Time41")) ret = LCD_TIME_41; // Big LCD numbers
503     else if (strTest.Equals("lcd.Time42")) ret = LCD_TIME_42;
504     else if (strTest.Equals("lcd.Time43")) ret = LCD_TIME_43;
505     else if (strTest.Equals("lcd.Time44")) ret = LCD_TIME_44;
506   }
507   else if (strCategory.Equals("network"))
508   {
509     if (strTest.Equals("network.ipaddress")) ret = NETWORK_IP_ADDRESS;
510     if (strTest.Equals("network.isdhcp")) ret = NETWORK_IS_DHCP;
511     if (strTest.Equals("network.linkstate")) ret = NETWORK_LINK_STATE;
512     if (strTest.Equals("network.macaddress")) ret = NETWORK_MAC_ADDRESS;
513     if (strTest.Equals("network.subnetaddress")) ret = NETWORK_SUBNET_ADDRESS;
514     if (strTest.Equals("network.gatewayaddress")) ret = NETWORK_GATEWAY_ADDRESS;
515     if (strTest.Equals("network.dns1address")) ret = NETWORK_DNS1_ADDRESS;
516     if (strTest.Equals("network.dns2address")) ret = NETWORK_DNS2_ADDRESS;
517     if (strTest.Equals("network.dhcpaddress")) ret = NETWORK_DHCP_ADDRESS;
518   }
519   else if (strCategory.Equals("musicplayer"))
520   {
521     CStdString info = strTest.Mid(strCategory.GetLength() + 1);
522     if (info.Left(9).Equals("position("))
523     {
524       int position = atoi(info.Mid(9));
525       int value = TranslateMusicPlayerString(info.Mid(info.Find(".")+1));
526       ret = AddMultiInfo(GUIInfo(value, 0, position));
527     }
528     else if (info.Left(7).Equals("offset("))
529     {
530       int position = atoi(info.Mid(7));
531       int value = TranslateMusicPlayerString(info.Mid(info.Find(".")+1));
532       ret = AddMultiInfo(GUIInfo(value, 1, position));
533     }
534     else if (info.Left(13).Equals("timeremaining")) return AddMultiInfo(GUIInfo(PLAYER_TIME_REMAINING, TranslateTimeFormat(info.Mid(13))));
535     else if (info.Left(9).Equals("timespeed")) return AddMultiInfo(GUIInfo(PLAYER_TIME_SPEED, TranslateTimeFormat(info.Mid(9))));
536     else if (info.Left(4).Equals("time")) return AddMultiInfo(GUIInfo(PLAYER_TIME, TranslateTimeFormat(info.Mid(4))));
537     else if (info.Left(8).Equals("duration")) return AddMultiInfo(GUIInfo(PLAYER_DURATION, TranslateTimeFormat(info.Mid(8))));
538     else if (info.Left(9).Equals("property("))
539       return AddListItemProp(info.Mid(9, info.GetLength() - 10), MUSICPLAYER_PROPERTY_OFFSET);
540     else
541       ret = TranslateMusicPlayerString(strTest.Mid(12));
542   }
543   else if (strCategory.Equals("videoplayer"))
544   {
545     if (strTest.Equals("videoplayer.title")) ret = VIDEOPLAYER_TITLE;
546     else if (strTest.Equals("videoplayer.genre")) ret = VIDEOPLAYER_GENRE;
547     else if (strTest.Equals("videoplayer.country")) ret = VIDEOPLAYER_COUNTRY;
548     else if (strTest.Equals("videoplayer.originaltitle")) ret = VIDEOPLAYER_ORIGINALTITLE;
549     else if (strTest.Equals("videoplayer.director")) ret = VIDEOPLAYER_DIRECTOR;
550     else if (strTest.Equals("videoplayer.year")) ret = VIDEOPLAYER_YEAR;
551     else if (strTest.Left(25).Equals("videoplayer.timeremaining")) ret = AddMultiInfo(GUIInfo(PLAYER_TIME_REMAINING, TranslateTimeFormat(strTest.Mid(25))));
552     else if (strTest.Left(21).Equals("videoplayer.timespeed")) ret = AddMultiInfo(GUIInfo(PLAYER_TIME_SPEED, TranslateTimeFormat(strTest.Mid(21))));
553     else if (strTest.Left(16).Equals("videoplayer.time")) ret = AddMultiInfo(GUIInfo(PLAYER_TIME, TranslateTimeFormat(strTest.Mid(16))));
554     else if (strTest.Left(20).Equals("videoplayer.duration")) ret = AddMultiInfo(GUIInfo(PLAYER_DURATION, TranslateTimeFormat(strTest.Mid(20))));
555     else if (strTest.Equals("videoplayer.cover")) ret = VIDEOPLAYER_COVER;
556     else if (strTest.Equals("videoplayer.usingoverlays")) ret = VIDEOPLAYER_USING_OVERLAYS;
557     else if (strTest.Equals("videoplayer.isfullscreen")) ret = VIDEOPLAYER_ISFULLSCREEN;
558     else if (strTest.Equals("videoplayer.hasmenu")) ret = VIDEOPLAYER_HASMENU;
559     else if (strTest.Equals("videoplayer.playlistlength")) ret = VIDEOPLAYER_PLAYLISTLEN;
560     else if (strTest.Equals("videoplayer.playlistposition")) ret = VIDEOPLAYER_PLAYLISTPOS;
561     else if (strTest.Equals("videoplayer.plot")) ret = VIDEOPLAYER_PLOT;
562     else if (strTest.Equals("videoplayer.plotoutline")) ret = VIDEOPLAYER_PLOT_OUTLINE;
563     else if (strTest.Equals("videoplayer.episode")) ret = VIDEOPLAYER_EPISODE;
564     else if (strTest.Equals("videoplayer.season")) ret = VIDEOPLAYER_SEASON;
565     else if (strTest.Equals("videoplayer.rating")) ret = VIDEOPLAYER_RATING;
566     else if (strTest.Equals("videoplayer.ratingandvotes")) ret = VIDEOPLAYER_RATING_AND_VOTES;
567     else if (strTest.Equals("videoplayer.tvshowtitle")) ret = VIDEOPLAYER_TVSHOW;
568     else if (strTest.Equals("videoplayer.premiered")) ret = VIDEOPLAYER_PREMIERED;
569     else if (strTest.Left(19).Equals("videoplayer.content")) return AddMultiInfo(GUIInfo(bNegate ? -VIDEOPLAYER_CONTENT : VIDEOPLAYER_CONTENT, ConditionalStringParameter(strTest.Mid(20,strTest.size()-21)), 0));
570     else if (strTest.Equals("videoplayer.studio")) ret = VIDEOPLAYER_STUDIO;
571     else if (strTest.Equals("videoplayer.mpaa")) return VIDEOPLAYER_MPAA;
572     else if (strTest.Equals("videoplayer.top250")) return VIDEOPLAYER_TOP250;
573     else if (strTest.Equals("videoplayer.cast")) return VIDEOPLAYER_CAST;
574     else if (strTest.Equals("videoplayer.castandrole")) return VIDEOPLAYER_CAST_AND_ROLE;
575     else if (strTest.Equals("videoplayer.artist")) return VIDEOPLAYER_ARTIST;
576     else if (strTest.Equals("videoplayer.album")) return VIDEOPLAYER_ALBUM;
577     else if (strTest.Equals("videoplayer.writer")) return VIDEOPLAYER_WRITER;
578     else if (strTest.Equals("videoplayer.tagline")) return VIDEOPLAYER_TAGLINE;
579     else if (strTest.Equals("videoplayer.hasinfo")) return VIDEOPLAYER_HAS_INFO;
580     else if (strTest.Equals("videoplayer.trailer")) return VIDEOPLAYER_TRAILER;
581     else if (strTest.Equals("videoplayer.videocodec")) return VIDEOPLAYER_VIDEO_CODEC;
582     else if (strTest.Equals("videoplayer.videoresolution")) return VIDEOPLAYER_VIDEO_RESOLUTION;
583     else if (strTest.Equals("videoplayer.videoaspect")) return VIDEOPLAYER_VIDEO_ASPECT;
584     else if (strTest.Equals("videoplayer.audiocodec")) return VIDEOPLAYER_AUDIO_CODEC;
585     else if (strTest.Equals("videoplayer.audiochannels")) return VIDEOPLAYER_AUDIO_CHANNELS;
586     else if (strTest.Equals("videoplayer.hasteletext")) return VIDEOPLAYER_HASTELETEXT;
587     else if (strTest.Equals("videoplayer.lastplayed")) return VIDEOPLAYER_LASTPLAYED;
588     else if (strTest.Equals("videoplayer.playcount")) return VIDEOPLAYER_PLAYCOUNT;
589   }
590   else if (strCategory.Equals("playlist"))
591   {
592     if (strTest.Equals("playlist.length")) ret = PLAYLIST_LENGTH;
593     else if (strTest.Equals("playlist.position")) ret = PLAYLIST_POSITION;
594     else if (strTest.Equals("playlist.random")) ret = PLAYLIST_RANDOM;
595     else if (strTest.Equals("playlist.repeat")) ret = PLAYLIST_REPEAT;
596     else if (strTest.Equals("playlist.israndom")) ret = PLAYLIST_ISRANDOM;
597     else if (strTest.Equals("playlist.isrepeat")) ret = PLAYLIST_ISREPEAT;
598     else if (strTest.Equals("playlist.isrepeatone")) ret = PLAYLIST_ISREPEATONE;
599   }
600   else if (strCategory.Equals("musicpartymode"))
601   {
602     if (strTest.Equals("musicpartymode.enabled")) ret = MUSICPM_ENABLED;
603     else if (strTest.Equals("musicpartymode.songsplayed")) ret = MUSICPM_SONGSPLAYED;
604     else if (strTest.Equals("musicpartymode.matchingsongs")) ret = MUSICPM_MATCHINGSONGS;
605     else if (strTest.Equals("musicpartymode.matchingsongspicked")) ret = MUSICPM_MATCHINGSONGSPICKED;
606     else if (strTest.Equals("musicpartymode.matchingsongsleft")) ret = MUSICPM_MATCHINGSONGSLEFT;
607     else if (strTest.Equals("musicpartymode.relaxedsongspicked")) ret = MUSICPM_RELAXEDSONGSPICKED;
608     else if (strTest.Equals("musicpartymode.randomsongspicked")) ret = MUSICPM_RANDOMSONGSPICKED;
609   }
610   else if (strCategory.Equals("audioscrobbler"))
611   {
612     if (strTest.Equals("audioscrobbler.enabled")) ret = AUDIOSCROBBLER_ENABLED;
613     else if (strTest.Equals("audioscrobbler.connectstate")) ret = AUDIOSCROBBLER_CONN_STATE;
614     else if (strTest.Equals("audioscrobbler.submitinterval")) ret = AUDIOSCROBBLER_SUBMIT_INT;
615     else if (strTest.Equals("audioscrobbler.filescached")) ret = AUDIOSCROBBLER_FILES_CACHED;
616     else if (strTest.Equals("audioscrobbler.submitstate")) ret = AUDIOSCROBBLER_SUBMIT_STATE;
617   }
618   else if (strCategory.Equals("lastfm"))
619   {
620     if (strTest.Equals("lastfm.radioplaying")) ret = LASTFM_RADIOPLAYING;
621     else if (strTest.Equals("lastfm.canlove")) ret = LASTFM_CANLOVE;
622     else if (strTest.Equals("lastfm.canban")) ret = LASTFM_CANBAN;
623   }
624   else if (strCategory.Equals("slideshow"))
625     ret = CPictureInfoTag::TranslateString(strTest.Mid(strCategory.GetLength() + 1));
626   else if (strCategory.Left(9).Equals("container"))
627   {
628     int id = atoi(strCategory.Mid(10, strCategory.GetLength() - 11));
629     CStdString info = strTest.Mid(strCategory.GetLength() + 1);
630     if (info.Left(14).Equals("listitemnowrap"))
631     {
632       int offset = atoi(info.Mid(15, info.GetLength() - 16));
633       ret = TranslateListItem(info.Mid(info.Find(".")+1));
634       if (offset || id)
635         return AddMultiInfo(GUIInfo(bNegate ? -ret : ret, id, offset));
636     }
637     else if (info.Left(16).Equals("listitemposition"))
638     {
639       int offset = atoi(info.Mid(17, info.GetLength() - 18));
640       ret = TranslateListItem(info.Mid(info.Find(".")+1));
641       if (offset || id)
642         return AddMultiInfo(GUIInfo(bNegate ? -ret : ret, id, offset, INFOFLAG_LISTITEM_POSITION));
643     }
644     else if (info.Left(8).Equals("listitem"))
645     {
646       int offset = atoi(info.Mid(9, info.GetLength() - 10));
647       ret = TranslateListItem(info.Mid(info.Find(".")+1));
648       if (offset || id)
649         return AddMultiInfo(GUIInfo(bNegate ? -ret : ret, id, offset, INFOFLAG_LISTITEM_WRAP));
650     }
651     else if (info.Equals("hasfiles")) ret = CONTAINER_HASFILES;
652     else if (info.Equals("hasfolders")) ret = CONTAINER_HASFOLDERS;
653     else if (info.Equals("isstacked")) ret = CONTAINER_STACKED;
654     else if (info.Equals("folderthumb")) ret = CONTAINER_FOLDERTHUMB;
655     else if (info.Equals("tvshowthumb")) ret = CONTAINER_TVSHOWTHUMB;
656     else if (info.Equals("seasonthumb")) ret = CONTAINER_SEASONTHUMB;
657     else if (info.Equals("folderpath")) ret = CONTAINER_FOLDERPATH;
658     else if (info.Equals("foldername")) ret = CONTAINER_FOLDERNAME;
659     else if (info.Equals("pluginname")) ret = CONTAINER_PLUGINNAME;
660     else if (info.Equals("viewmode")) ret = CONTAINER_VIEWMODE;
661     else if (info.Equals("onnext")) ret = CONTAINER_MOVE_NEXT;
662     else if (info.Equals("onprevious")) ret = CONTAINER_MOVE_PREVIOUS;
663     else if (info.Equals("onscrollnext")) ret = CONTAINER_SCROLL_NEXT;
664     else if (info.Equals("onscrollprevious")) ret = CONTAINER_SCROLL_PREVIOUS;
665     else if (info.Equals("totaltime")) ret = CONTAINER_TOTALTIME;
666     else if (info.Equals("scrolling"))
667       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_SCROLLING : CONTAINER_SCROLLING, id, 0));
668     else if (info.Equals("hasnext"))
669       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_HAS_NEXT : CONTAINER_HAS_NEXT, id, 0));
670     else if (info.Equals("hasprevious"))
671       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_HAS_PREVIOUS : CONTAINER_HAS_PREVIOUS, id, 0));
672     else if (info.Left(8).Equals("content("))
673       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_CONTENT : CONTAINER_CONTENT, ConditionalStringParameter(info.Mid(8,info.GetLength()-9)), 0));
674     else if (info.Left(4).Equals("row("))
675       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_ROW : CONTAINER_ROW, id, atoi(info.Mid(4, info.GetLength() - 5))));
676     else if (info.Left(7).Equals("column("))
677       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_COLUMN : CONTAINER_COLUMN, id, atoi(info.Mid(7, info.GetLength() - 8))));
678     else if (info.Left(8).Equals("position"))
679       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_POSITION : CONTAINER_POSITION, id, atoi(info.Mid(9, info.GetLength() - 10))));
680     else if (info.Left(8).Equals("subitem("))
681       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_SUBITEM : CONTAINER_SUBITEM, id, atoi(info.Mid(8, info.GetLength() - 9))));
682     else if (info.Equals("hasthumb")) ret = CONTAINER_HAS_THUMB;
683     else if (info.Equals("numpages")) ret = CONTAINER_NUM_PAGES;
684     else if (info.Equals("numitems")) ret = CONTAINER_NUM_ITEMS;
685     else if (info.Equals("currentpage")) ret = CONTAINER_CURRENT_PAGE;
686     else if (info.Equals("sortmethod")) ret = CONTAINER_SORT_METHOD;
687     else if (info.Left(13).Equals("sortdirection"))
688     {
689       CStdString direction = info.Mid(14, info.GetLength() - 15);
690       SORT_ORDER order = SORT_ORDER_NONE;
691       if (direction == "ascending")
692         order = SORT_ORDER_ASC;
693       else if (direction == "descending")
694         order = SORT_ORDER_DESC;
695       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_SORT_DIRECTION : CONTAINER_SORT_DIRECTION, order));
696     }
697     else if (info.Left(5).Equals("sort("))
698     {
699       SORT_METHOD sort = SORT_METHOD_NONE;
700       CStdString method(info.Mid(5, info.GetLength() - 6));
701       if (method.Equals("songrating")) sort = SORT_METHOD_SONG_RATING;
702       if (sort != SORT_METHOD_NONE)
703         return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_SORT_METHOD : CONTAINER_SORT_METHOD, sort));
704     }
705     else if (id && info.Left(9).Equals("hasfocus("))
706     {
707       int itemID = atoi(info.Mid(9, info.GetLength() - 10));
708       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_HAS_FOCUS : CONTAINER_HAS_FOCUS, id, itemID));
709     }
710     else if (info.Left(9).Equals("property("))
711     {
712       int compareString = ConditionalStringParameter(info.Mid(9, info.GetLength() - 10));
713       return AddMultiInfo(GUIInfo(CONTAINER_PROPERTY, id, compareString));
714     }
715     else if (info.Equals("showplot")) ret = CONTAINER_SHOWPLOT;
716     if (id && ((ret >= CONTAINER_SCROLL_PREVIOUS && ret <= CONTAINER_SCROLL_NEXT) || ret == CONTAINER_NUM_PAGES ||
717                ret == CONTAINER_NUM_ITEMS || ret == CONTAINER_CURRENT_PAGE))
718       return AddMultiInfo(GUIInfo(bNegate ? -ret : ret, id));
719   }
720   else if (strCategory.Left(8).Equals("listitem"))
721   {
722     int offset = atoi(strCategory.Mid(9, strCategory.GetLength() - 10));
723     ret = TranslateListItem(strTest.Mid(strCategory.GetLength() + 1));
724     if (offset || ret == LISTITEM_ISSELECTED || ret == LISTITEM_ISPLAYING || ret == LISTITEM_IS_FOLDER)
725       return AddMultiInfo(GUIInfo(bNegate ? -ret : ret, 0, offset, INFOFLAG_LISTITEM_WRAP));
726   }
727   else if (strCategory.Left(16).Equals("listitemposition"))
728   {
729     int offset = atoi(strCategory.Mid(17, strCategory.GetLength() - 18));
730     ret = TranslateListItem(strCategory.Mid(strCategory.GetLength()+1));
731     if (offset || ret == LISTITEM_ISSELECTED || ret == LISTITEM_ISPLAYING || ret == LISTITEM_IS_FOLDER)
732       return AddMultiInfo(GUIInfo(bNegate ? -ret : ret, 0, offset, INFOFLAG_LISTITEM_POSITION));
733   }
734   else if (strCategory.Left(14).Equals("listitemnowrap"))
735   {
736     int offset = atoi(strCategory.Mid(15, strCategory.GetLength() - 16));
737     ret = TranslateListItem(strTest.Mid(strCategory.GetLength() + 1));
738     if (offset || ret == LISTITEM_ISSELECTED || ret == LISTITEM_ISPLAYING || ret == LISTITEM_IS_FOLDER)
739       return AddMultiInfo(GUIInfo(bNegate ? -ret : ret, 0, offset));
740   }
741   else if (strCategory.Equals("visualisation"))
742   {
743     if (strTest.Equals("visualisation.locked")) ret = VISUALISATION_LOCKED;
744     else if (strTest.Equals("visualisation.preset")) ret = VISUALISATION_PRESET;
745     else if (strTest.Equals("visualisation.name")) ret = VISUALISATION_NAME;
746     else if (strTest.Equals("visualisation.enabled")) ret = VISUALISATION_ENABLED;
747   }
748   else if (strCategory.Equals("fanart"))
749   {
750     if (strTest.Equals("fanart.color1")) ret = FANART_COLOR1;
751     else if (strTest.Equals("fanart.color2")) ret = FANART_COLOR2;
752     else if (strTest.Equals("fanart.color3")) ret = FANART_COLOR3;
753     else if (strTest.Equals("fanart.image")) ret = FANART_IMAGE;
754   }
755   else if (strCategory.Equals("skin"))
756   {
757     if (strTest.Equals("skin.currenttheme"))
758       ret = SKIN_THEME;
759     else if (strTest.Equals("skin.currentcolourtheme"))
760       ret = SKIN_COLOUR_THEME;
761     else if (strTest.Left(12).Equals("skin.string("))
762     {
763       int pos = strTest.Find(",");
764       if (pos >= 0)
765       {
766         int skinOffset = g_settings.TranslateSkinString(strTest.Mid(12, pos - 12));
767         int compareString = ConditionalStringParameter(strTest.Mid(pos + 1, strTest.GetLength() - (pos + 2)));
768         return AddMultiInfo(GUIInfo(bNegate ? -SKIN_STRING : SKIN_STRING, skinOffset, compareString));
769       }
770       int skinOffset = g_settings.TranslateSkinString(strTest.Mid(12, strTest.GetLength() - 13));
771       return AddMultiInfo(GUIInfo(bNegate ? -SKIN_STRING : SKIN_STRING, skinOffset));
772     }
773     else if (strTest.Left(16).Equals("skin.hassetting("))
774     {
775       int skinOffset = g_settings.TranslateSkinBool(strTest.Mid(16, strTest.GetLength() - 17));
776       return AddMultiInfo(GUIInfo(bNegate ? -SKIN_BOOL : SKIN_BOOL, skinOffset));
777     }
778     else if (strTest.Left(14).Equals("skin.hastheme("))
779       ret = SKIN_HAS_THEME_START + ConditionalStringParameter(strTest.Mid(14, strTest.GetLength() -  15));
780   }
781   else if (strCategory.Left(6).Equals("window"))
782   {
783     CStdString info = strTest.Mid(strCategory.GetLength() + 1);
784     // special case for window.xml parameter, fails above
785     if (info.Left(5).Equals("xml)."))
786       info = info.Mid(5, info.GetLength() + 1);
787     if (info.Left(9).Equals("property("))
788     {
789       int winID = 0;
790       if (strTest.Left(7).Equals("window("))
791       {
792         CStdString window(strTest.Mid(7, strTest.Find(")", 7) - 7).ToLower());
793         winID = CButtonTranslator::TranslateWindow(window);
794       }
795       if (winID != WINDOW_INVALID)
796       {
797         int compareString = ConditionalStringParameter(info.Mid(9, info.GetLength() - 10));
798         return AddMultiInfo(GUIInfo(WINDOW_PROPERTY, winID, compareString));
799       }
800     }
801     else if (info.Left(9).Equals("isactive("))
802     {
803       CStdString window(strTest.Mid(16, strTest.GetLength() - 17).ToLower());
804       if (window.Find("xml") >= 0)
805         return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_IS_ACTIVE : WINDOW_IS_ACTIVE, 0, ConditionalStringParameter(window)));
806       int winID = CButtonTranslator::TranslateWindow(window);
807       if (winID != WINDOW_INVALID)
808         return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_IS_ACTIVE : WINDOW_IS_ACTIVE, winID, 0));
809     }
810     else if (info.Left(7).Equals("ismedia")) return WINDOW_IS_MEDIA;
811     else if (info.Left(10).Equals("istopmost("))
812     {
813       CStdString window(strTest.Mid(17, strTest.GetLength() - 18).ToLower());
814       if (window.Find("xml") >= 0)
815         return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_IS_TOPMOST : WINDOW_IS_TOPMOST, 0, ConditionalStringParameter(window)));
816       int winID = CButtonTranslator::TranslateWindow(window);
817       if (winID != WINDOW_INVALID)
818         return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_IS_TOPMOST : WINDOW_IS_TOPMOST, winID, 0));
819     }
820     else if (info.Left(10).Equals("isvisible("))
821     {
822       CStdString window(strTest.Mid(17, strTest.GetLength() - 18).ToLower());
823       if (window.Find("xml") >= 0)
824         return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_IS_VISIBLE : WINDOW_IS_VISIBLE, 0, ConditionalStringParameter(window)));
825       int winID = CButtonTranslator::TranslateWindow(window);
826       if (winID != WINDOW_INVALID)
827         return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_IS_VISIBLE : WINDOW_IS_VISIBLE, winID, 0));
828     }
829     else if (info.Left(9).Equals("previous("))
830     {
831       CStdString window(strTest.Mid(16, strTest.GetLength() - 17).ToLower());
832       if (window.Find("xml") >= 0)
833         return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_PREVIOUS : WINDOW_PREVIOUS, 0, ConditionalStringParameter(window)));
834       int winID = CButtonTranslator::TranslateWindow(window);
835       if (winID != WINDOW_INVALID)
836         return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_PREVIOUS : WINDOW_PREVIOUS, winID, 0));
837     }
838     else if (info.Left(5).Equals("next("))
839     {
840       CStdString window(strTest.Mid(12, strTest.GetLength() - 13).ToLower());
841       if (window.Find("xml") >= 0)
842         return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_NEXT : WINDOW_NEXT, 0, ConditionalStringParameter(window)));
843       int winID = CButtonTranslator::TranslateWindow(window);
844       if (winID != WINDOW_INVALID)
845         return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_NEXT : WINDOW_NEXT, winID, 0));
846     }
847   }
848   else if (strTest.Left(17).Equals("control.hasfocus("))
849   {
850     int controlID = atoi(strTest.Mid(17, strTest.GetLength() - 18).c_str());
851     if (controlID)
852       return AddMultiInfo(GUIInfo(bNegate ? -CONTROL_HAS_FOCUS : CONTROL_HAS_FOCUS, controlID, 0));
853   }
854   else if (strTest.Left(18).Equals("control.isvisible("))
855   {
856     int controlID = atoi(strTest.Mid(18, strTest.GetLength() - 19).c_str());
857     if (controlID)
858       return AddMultiInfo(GUIInfo(bNegate ? -CONTROL_IS_VISIBLE : CONTROL_IS_VISIBLE, controlID, 0));
859   }
860   else if (strTest.Left(18).Equals("control.isenabled("))
861   {
862     int controlID = atoi(strTest.Mid(18, strTest.GetLength() - 19).c_str());
863     if (controlID)
864       return AddMultiInfo(GUIInfo(bNegate ? -CONTROL_IS_ENABLED : CONTROL_IS_ENABLED, controlID, 0));
865   }
866   else if (strTest.Left(17).Equals("control.getlabel("))
867   {
868     int controlID = atoi(strTest.Mid(17, strTest.GetLength() - 18).c_str());
869     if (controlID)
870       return AddMultiInfo(GUIInfo(bNegate ? -CONTROL_GET_LABEL : CONTROL_GET_LABEL, controlID, 0));
871   }
872   else if (strTest.Left(13).Equals("controlgroup("))
873   {
874     int groupID = atoi(strTest.Mid(13).c_str());
875     int controlID = 0;
876     int controlPos = strTest.Find(".hasfocus(");
877     if (controlPos > 0)
878       controlID = atoi(strTest.Mid(controlPos + 10).c_str());
879     if (groupID)
880     {
881       return AddMultiInfo(GUIInfo(bNegate ? -CONTROL_GROUP_HAS_FOCUS : CONTROL_GROUP_HAS_FOCUS, groupID, controlID));
882     }
883   }
884   else if (strTest.Left(24).Equals("buttonscroller.hasfocus("))
885   {
886     int controlID = atoi(strTest.Mid(24, strTest.GetLength() - 24).c_str());
887     if (controlID)
888       return AddMultiInfo(GUIInfo(bNegate ? -BUTTON_SCROLLER_HAS_ICON : BUTTON_SCROLLER_HAS_ICON, controlID, 0));
889   }
890
891   return bNegate ? -ret : ret;
892 }
893
894 int CGUIInfoManager::TranslateListItem(const CStdString &info)
895 {
896   if (info.Equals("thumb")) return LISTITEM_THUMB;
897   else if (info.Equals("icon")) return LISTITEM_ICON;
898   else if (info.Equals("actualicon")) return LISTITEM_ACTUAL_ICON;
899   else if (info.Equals("overlay")) return LISTITEM_OVERLAY;
900   else if (info.Equals("label")) return LISTITEM_LABEL;
901   else if (info.Equals("label2")) return LISTITEM_LABEL2;
902   else if (info.Equals("title")) return LISTITEM_TITLE;
903   else if (info.Equals("tracknumber")) return LISTITEM_TRACKNUMBER;
904   else if (info.Equals("artist")) return LISTITEM_ARTIST;
905   else if (info.Equals("album")) return LISTITEM_ALBUM;
906   else if (info.Equals("albumartist")) return LISTITEM_ALBUM_ARTIST;
907   else if (info.Equals("year")) return LISTITEM_YEAR;
908   else if (info.Equals("genre")) return LISTITEM_GENRE;
909   else if (info.Equals("director")) return LISTITEM_DIRECTOR;
910   else if (info.Equals("filename")) return LISTITEM_FILENAME;
911   else if (info.Equals("filenameandpath")) return LISTITEM_FILENAME_AND_PATH;
912   else if (info.Equals("date")) return LISTITEM_DATE;
913   else if (info.Equals("size")) return LISTITEM_SIZE;
914   else if (info.Equals("rating")) return LISTITEM_RATING;
915   else if (info.Equals("ratingandvotes")) return LISTITEM_RATING_AND_VOTES;
916   else if (info.Equals("programcount")) return LISTITEM_PROGRAM_COUNT;
917   else if (info.Equals("duration")) return LISTITEM_DURATION;
918   else if (info.Equals("isselected")) return LISTITEM_ISSELECTED;
919   else if (info.Equals("isplaying")) return LISTITEM_ISPLAYING;
920   else if (info.Equals("plot")) return LISTITEM_PLOT;
921   else if (info.Equals("plotoutline")) return LISTITEM_PLOT_OUTLINE;
922   else if (info.Equals("episode")) return LISTITEM_EPISODE;
923   else if (info.Equals("season")) return LISTITEM_SEASON;
924   else if (info.Equals("tvshowtitle")) return LISTITEM_TVSHOW;
925   else if (info.Equals("premiered")) return LISTITEM_PREMIERED;
926   else if (info.Equals("comment")) return LISTITEM_COMMENT;
927   else if (info.Equals("path")) return LISTITEM_PATH;
928   else if (info.Equals("foldername")) return LISTITEM_FOLDERNAME;
929   else if (info.Equals("folderpath")) return LISTITEM_FOLDERPATH;
930   else if (info.Equals("picturepath")) return LISTITEM_PICTURE_PATH;
931   else if (info.Equals("pictureresolution")) return LISTITEM_PICTURE_RESOLUTION;
932   else if (info.Equals("picturedatetime")) return LISTITEM_PICTURE_DATETIME;
933   else if (info.Equals("studio")) return LISTITEM_STUDIO;
934   else if (info.Equals("country")) return LISTITEM_COUNTRY;
935   else if (info.Equals("mpaa")) return LISTITEM_MPAA;
936   else if (info.Equals("cast")) return LISTITEM_CAST;
937   else if (info.Equals("castandrole")) return LISTITEM_CAST_AND_ROLE;
938   else if (info.Equals("writer")) return LISTITEM_WRITER;
939   else if (info.Equals("tagline")) return LISTITEM_TAGLINE;
940   else if (info.Equals("top250")) return LISTITEM_TOP250;
941   else if (info.Equals("trailer")) return LISTITEM_TRAILER;
942   else if (info.Equals("starrating")) return LISTITEM_STAR_RATING;
943   else if (info.Equals("sortletter")) return LISTITEM_SORT_LETTER;
944   else if (info.Equals("videocodec")) return LISTITEM_VIDEO_CODEC;
945   else if (info.Equals("videoresolution")) return LISTITEM_VIDEO_RESOLUTION;
946   else if (info.Equals("videoaspect")) return LISTITEM_VIDEO_ASPECT;
947   else if (info.Equals("audiocodec")) return LISTITEM_AUDIO_CODEC;
948   else if (info.Equals("audiochannels")) return LISTITEM_AUDIO_CHANNELS;
949   else if (info.Equals("audiolanguage")) return LISTITEM_AUDIO_LANGUAGE;
950   else if (info.Equals("subtitlelanguage")) return LISTITEM_SUBTITLE_LANGUAGE;
951   else if (info.Equals("isfolder")) return LISTITEM_IS_FOLDER;
952   else if (info.Equals("originaltitle")) return LISTITEM_ORIGINALTITLE;
953   else if (info.Equals("lastplayed")) return LISTITEM_LASTPLAYED;
954   else if (info.Equals("playcount")) return LISTITEM_PLAYCOUNT;
955   else if (info.Left(9).Equals("property(")) return AddListItemProp(info.Mid(9, info.GetLength() - 10));
956   return 0;
957 }
958
959 int CGUIInfoManager::TranslateMusicPlayerString(const CStdString &info) const
960 {
961   if (info.Equals("title")) return MUSICPLAYER_TITLE;
962   else if (info.Equals("album")) return MUSICPLAYER_ALBUM;
963   else if (info.Equals("artist")) return MUSICPLAYER_ARTIST;
964   else if (info.Equals("albumartist")) return MUSICPLAYER_ALBUM_ARTIST;
965   else if (info.Equals("year")) return MUSICPLAYER_YEAR;
966   else if (info.Equals("genre")) return MUSICPLAYER_GENRE;
967   else if (info.Equals("duration")) return MUSICPLAYER_DURATION;
968   else if (info.Equals("tracknumber")) return MUSICPLAYER_TRACK_NUMBER;
969   else if (info.Equals("cover")) return MUSICPLAYER_COVER;
970   else if (info.Equals("bitrate")) return MUSICPLAYER_BITRATE;
971   else if (info.Equals("playlistlength")) return MUSICPLAYER_PLAYLISTLEN;
972   else if (info.Equals("playlistposition")) return MUSICPLAYER_PLAYLISTPOS;
973   else if (info.Equals("channels")) return MUSICPLAYER_CHANNELS;
974   else if (info.Equals("bitspersample")) return MUSICPLAYER_BITSPERSAMPLE;
975   else if (info.Equals("samplerate")) return MUSICPLAYER_SAMPLERATE;
976   else if (info.Equals("codec")) return MUSICPLAYER_CODEC;
977   else if (info.Equals("discnumber")) return MUSICPLAYER_DISC_NUMBER;
978   else if (info.Equals("rating")) return MUSICPLAYER_RATING;
979   else if (info.Equals("comment")) return MUSICPLAYER_COMMENT;
980   else if (info.Equals("lyrics")) return MUSICPLAYER_LYRICS;
981   else if (info.Equals("playlistplaying")) return MUSICPLAYER_PLAYLISTPLAYING;
982   else if (info.Equals("exists")) return MUSICPLAYER_EXISTS;
983   else if (info.Equals("hasprevious")) return MUSICPLAYER_HASPREVIOUS;
984   else if (info.Equals("hasnext")) return MUSICPLAYER_HASNEXT;
985   else if (info.Equals("playcount")) return MUSICPLAYER_PLAYCOUNT;
986   else if (info.Equals("lastplayed")) return MUSICPLAYER_LASTPLAYED;
987   return 0;
988 }
989
990 TIME_FORMAT CGUIInfoManager::TranslateTimeFormat(const CStdString &format)
991 {
992   if (format.IsEmpty()) return TIME_FORMAT_GUESS;
993   else if (format.Equals("(hh)")) return TIME_FORMAT_HH;
994   else if (format.Equals("(mm)")) return TIME_FORMAT_MM;
995   else if (format.Equals("(ss)")) return TIME_FORMAT_SS;
996   else if (format.Equals("(hh:mm)")) return TIME_FORMAT_HH_MM;
997   else if (format.Equals("(mm:ss)")) return TIME_FORMAT_MM_SS;
998   else if (format.Equals("(hh:mm:ss)")) return TIME_FORMAT_HH_MM_SS;
999   return TIME_FORMAT_GUESS;
1000 }
1001
1002 CStdString CGUIInfoManager::GetLabel(int info, int contextWindow)
1003 {
1004   CStdString strLabel;
1005   if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
1006     return GetMultiInfoLabel(m_multiInfo[info - MULTI_INFO_START], contextWindow);
1007
1008   if (info >= SLIDE_INFO_START && info <= SLIDE_INFO_END)
1009     return GetPictureLabel(info);
1010
1011   if (info >= LISTITEM_PROPERTY_START+MUSICPLAYER_PROPERTY_OFFSET &&
1012       info - (LISTITEM_PROPERTY_START+MUSICPLAYER_PROPERTY_OFFSET) < (int)m_listitemProperties.size())
1013   { // grab the property
1014     if (!m_currentFile)
1015       return "";
1016
1017     CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START-MUSICPLAYER_PROPERTY_OFFSET];
1018     return m_currentFile->GetProperty(property);
1019   }
1020
1021   if (info >= LISTITEM_START && info <= LISTITEM_END)
1022   {
1023     CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS); // true for has list items
1024     if (window)
1025     {
1026       CFileItemPtr item = window->GetCurrentListItem();
1027       strLabel = GetItemLabel(item.get(), info);
1028     }
1029
1030     return strLabel;
1031   }
1032
1033   switch (info)
1034   {
1035   case WEATHER_CONDITIONS:
1036     strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_COND);
1037     strLabel = strLabel.Trim();
1038     break;
1039   case WEATHER_TEMPERATURE:
1040     strLabel.Format("%s%s", g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_TEMP), g_langInfo.GetTempUnitString().c_str());
1041     break;
1042   case WEATHER_LOCATION:
1043     strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_LOCATION);
1044     break;
1045   case WEATHER_FANART_CODE:
1046     strLabel = URIUtils::GetFileName(g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON));
1047     URIUtils::RemoveExtension(strLabel);
1048     break;
1049   case WEATHER_PLUGIN:
1050     strLabel = g_guiSettings.GetString("weather.script");
1051     break;
1052   case SYSTEM_DATE:
1053     strLabel = GetDate();
1054     break;
1055   case LCD_DATE:
1056     strLabel = GetDate(true);
1057     break;
1058   case SYSTEM_FPS:
1059     strLabel.Format("%02.2f", m_fps);
1060     break;
1061   case PLAYER_VOLUME:
1062     strLabel.Format("%2.1f dB", (float)(g_settings.m_nVolumeLevel + g_settings.m_dynamicRangeCompressionLevel) * 0.01f);
1063     break;
1064   case PLAYER_SUBTITLE_DELAY:
1065     strLabel.Format("%2.3f s", g_settings.m_currentVideoSettings.m_SubtitleDelay);
1066     break;
1067   case PLAYER_AUDIO_DELAY:
1068     strLabel.Format("%2.3f s", g_settings.m_currentVideoSettings.m_AudioDelay);
1069     break;
1070   case PLAYER_CHAPTER:
1071     if(g_application.IsPlaying() && g_application.m_pPlayer)
1072       strLabel.Format("%02d", g_application.m_pPlayer->GetChapter());
1073     break;
1074   case PLAYER_CHAPTERCOUNT:
1075     if(g_application.IsPlaying() && g_application.m_pPlayer)
1076       strLabel.Format("%02d", g_application.m_pPlayer->GetChapterCount());
1077     break;
1078   case PLAYER_CHAPTERNAME:
1079     if(g_application.IsPlaying() && g_application.m_pPlayer)
1080       g_application.m_pPlayer->GetChapterName(strLabel);
1081     break;
1082   case PLAYER_CACHELEVEL:
1083     {
1084       int iLevel = 0;
1085       if(g_application.IsPlaying() && ((iLevel = GetInt(PLAYER_CACHELEVEL)) >= 0))
1086         strLabel.Format("%i", iLevel);
1087     }
1088     break;
1089   case PLAYER_TIME:
1090     if(g_application.IsPlaying() && g_application.m_pPlayer)
1091       strLabel = GetCurrentPlayTime(TIME_FORMAT_HH_MM);
1092     break;
1093   case PLAYER_DURATION:
1094     if(g_application.IsPlaying() && g_application.m_pPlayer)
1095       strLabel = GetDuration(TIME_FORMAT_HH_MM);
1096     break;
1097   case PLAYER_PATH:
1098   case PLAYER_FILEPATH:
1099     if (m_currentFile)
1100     {
1101       if (m_currentFile->HasMusicInfoTag())
1102         strLabel = m_currentFile->GetMusicInfoTag()->GetURL();
1103       else if (m_currentFile->HasVideoInfoTag())
1104         strLabel = m_currentFile->GetVideoInfoTag()->m_strFileNameAndPath;
1105       if (strLabel.IsEmpty())
1106         strLabel = m_currentFile->m_strPath;
1107     }
1108     if (info == PLAYER_PATH)
1109     {
1110       // do this twice since we want the path outside the archive if this
1111       // is to be of use.
1112       if (URIUtils::IsInArchive(strLabel))
1113         strLabel = URIUtils::GetParentPath(strLabel);
1114       strLabel = URIUtils::GetParentPath(strLabel);
1115     }
1116     break;
1117   case MUSICPLAYER_TITLE:
1118   case MUSICPLAYER_ALBUM:
1119   case MUSICPLAYER_ARTIST:
1120   case MUSICPLAYER_ALBUM_ARTIST:
1121   case MUSICPLAYER_GENRE:
1122   case MUSICPLAYER_YEAR:
1123   case MUSICPLAYER_TRACK_NUMBER:
1124   case MUSICPLAYER_BITRATE:
1125   case MUSICPLAYER_PLAYLISTLEN:
1126   case MUSICPLAYER_PLAYLISTPOS:
1127   case MUSICPLAYER_CHANNELS:
1128   case MUSICPLAYER_BITSPERSAMPLE:
1129   case MUSICPLAYER_SAMPLERATE:
1130   case MUSICPLAYER_CODEC:
1131   case MUSICPLAYER_DISC_NUMBER:
1132   case MUSICPLAYER_RATING:
1133   case MUSICPLAYER_COMMENT:
1134   case MUSICPLAYER_LYRICS:
1135   case MUSICPLAYER_PLAYCOUNT:
1136   case MUSICPLAYER_LASTPLAYED:
1137     strLabel = GetMusicLabel(info);
1138   break;
1139   case VIDEOPLAYER_TITLE:
1140   case VIDEOPLAYER_ORIGINALTITLE:
1141   case VIDEOPLAYER_GENRE:
1142   case VIDEOPLAYER_DIRECTOR:
1143   case VIDEOPLAYER_YEAR:
1144   case VIDEOPLAYER_PLAYLISTLEN:
1145   case VIDEOPLAYER_PLAYLISTPOS:
1146   case VIDEOPLAYER_PLOT:
1147   case VIDEOPLAYER_PLOT_OUTLINE:
1148   case VIDEOPLAYER_EPISODE:
1149   case VIDEOPLAYER_SEASON:
1150   case VIDEOPLAYER_RATING:
1151   case VIDEOPLAYER_RATING_AND_VOTES:
1152   case VIDEOPLAYER_TVSHOW:
1153   case VIDEOPLAYER_PREMIERED:
1154   case VIDEOPLAYER_STUDIO:
1155   case VIDEOPLAYER_COUNTRY:
1156   case VIDEOPLAYER_MPAA:
1157   case VIDEOPLAYER_TOP250:
1158   case VIDEOPLAYER_CAST:
1159   case VIDEOPLAYER_CAST_AND_ROLE:
1160   case VIDEOPLAYER_ARTIST:
1161   case VIDEOPLAYER_ALBUM:
1162   case VIDEOPLAYER_WRITER:
1163   case VIDEOPLAYER_TAGLINE:
1164   case VIDEOPLAYER_TRAILER:
1165   case VIDEOPLAYER_PLAYCOUNT:
1166   case VIDEOPLAYER_LASTPLAYED:
1167     strLabel = GetVideoLabel(info);
1168   break;
1169   case VIDEOPLAYER_VIDEO_CODEC:
1170     if(g_application.IsPlaying() && g_application.m_pPlayer)
1171       strLabel = g_application.m_pPlayer->GetVideoCodecName();
1172     break;
1173   case VIDEOPLAYER_VIDEO_RESOLUTION:
1174     if(g_application.IsPlaying() && g_application.m_pPlayer)
1175       return CStreamDetails::VideoDimsToResolutionDescription(g_application.m_pPlayer->GetPictureWidth(), g_application.m_pPlayer->GetPictureHeight());
1176     break;
1177   case VIDEOPLAYER_AUDIO_CODEC:
1178     if(g_application.IsPlaying() && g_application.m_pPlayer)
1179       strLabel = g_application.m_pPlayer->GetAudioCodecName();
1180     break;
1181   case VIDEOPLAYER_VIDEO_ASPECT:
1182     if (g_application.IsPlaying() && g_application.m_pPlayer)
1183     {
1184       float aspect;
1185       g_application.m_pPlayer->GetVideoAspectRatio(aspect);
1186       strLabel = CStreamDetails::VideoAspectToAspectDescription(aspect);
1187     }
1188     break;
1189   case VIDEOPLAYER_AUDIO_CHANNELS:
1190     if(g_application.IsPlaying() && g_application.m_pPlayer)
1191       strLabel.Format("%i", g_application.m_pPlayer->GetChannels());
1192     break;
1193   case PLAYLIST_LENGTH:
1194   case PLAYLIST_POSITION:
1195   case PLAYLIST_RANDOM:
1196   case PLAYLIST_REPEAT:
1197     strLabel = GetPlaylistLabel(info);
1198   break;
1199   case MUSICPM_SONGSPLAYED:
1200   case MUSICPM_MATCHINGSONGS:
1201   case MUSICPM_MATCHINGSONGSPICKED:
1202   case MUSICPM_MATCHINGSONGSLEFT:
1203   case MUSICPM_RELAXEDSONGSPICKED:
1204   case MUSICPM_RANDOMSONGSPICKED:
1205     strLabel = GetMusicPartyModeLabel(info);
1206   break;
1207
1208   case SYSTEM_FREE_SPACE:
1209   case SYSTEM_FREE_SPACE_C:
1210   case SYSTEM_FREE_SPACE_E:
1211   case SYSTEM_FREE_SPACE_F:
1212   case SYSTEM_FREE_SPACE_G:
1213   case SYSTEM_USED_SPACE:
1214   case SYSTEM_USED_SPACE_C:
1215   case SYSTEM_USED_SPACE_E:
1216   case SYSTEM_USED_SPACE_F:
1217   case SYSTEM_USED_SPACE_G:
1218   case SYSTEM_TOTAL_SPACE:
1219   case SYSTEM_TOTAL_SPACE_C:
1220   case SYSTEM_TOTAL_SPACE_E:
1221   case SYSTEM_TOTAL_SPACE_F:
1222   case SYSTEM_TOTAL_SPACE_G:
1223   case SYSTEM_FREE_SPACE_PERCENT:
1224   case SYSTEM_FREE_SPACE_PERCENT_C:
1225   case SYSTEM_FREE_SPACE_PERCENT_E:
1226   case SYSTEM_FREE_SPACE_PERCENT_F:
1227   case SYSTEM_FREE_SPACE_PERCENT_G:
1228   case SYSTEM_USED_SPACE_PERCENT:
1229   case SYSTEM_USED_SPACE_PERCENT_C:
1230   case SYSTEM_USED_SPACE_PERCENT_E:
1231   case SYSTEM_USED_SPACE_PERCENT_F:
1232   case SYSTEM_USED_SPACE_PERCENT_G:
1233   case SYSTEM_USED_SPACE_X:
1234   case SYSTEM_FREE_SPACE_X:
1235   case SYSTEM_TOTAL_SPACE_X:
1236   case SYSTEM_USED_SPACE_Y:
1237   case SYSTEM_FREE_SPACE_Y:
1238   case SYSTEM_TOTAL_SPACE_Y:
1239   case SYSTEM_USED_SPACE_Z:
1240   case SYSTEM_FREE_SPACE_Z:
1241   case SYSTEM_TOTAL_SPACE_Z:
1242     return g_sysinfo.GetHddSpaceInfo(info);
1243   break;
1244
1245   case LCD_FREE_SPACE_C:
1246   case LCD_FREE_SPACE_E:
1247   case LCD_FREE_SPACE_F:
1248   case LCD_FREE_SPACE_G:
1249     return g_sysinfo.GetHddSpaceInfo(info, true);
1250     break;
1251
1252   case SYSTEM_CPU_TEMPERATURE:
1253   case SYSTEM_GPU_TEMPERATURE:
1254   case SYSTEM_FAN_SPEED:
1255   case LCD_CPU_TEMPERATURE:
1256   case LCD_GPU_TEMPERATURE:
1257   case LCD_FAN_SPEED:
1258   case SYSTEM_CPU_USAGE:
1259     return GetSystemHeatInfo(info);
1260     break;
1261
1262   case SYSTEM_VIDEO_ENCODER_INFO:
1263   case NETWORK_MAC_ADDRESS:
1264   case SYSTEM_KERNEL_VERSION:
1265   case SYSTEM_CPUFREQUENCY:
1266   case SYSTEM_INTERNET_STATE:
1267   case SYSTEM_UPTIME:
1268   case SYSTEM_TOTALUPTIME:
1269     return g_sysinfo.GetInfo(info);
1270     break;
1271
1272   case SYSTEM_SCREEN_RESOLUTION:
1273     if (g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].bFullScreen)
1274       strLabel.Format("%ix%i@%.2fHz - %s (%02.2f fps)",
1275         g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iWidth,
1276         g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iHeight,
1277         g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].fRefreshRate,
1278         g_localizeStrings.Get(244), GetFPS());
1279     else
1280       strLabel.Format("%ix%i - %s (%02.2f fps)",
1281         g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iWidth,
1282         g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iHeight,
1283         g_localizeStrings.Get(242), GetFPS());
1284     return strLabel;
1285     break;
1286
1287   case CONTAINER_FOLDERPATH:
1288   case CONTAINER_FOLDERNAME:
1289     {
1290       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1291       if (window)
1292       {
1293         strLabel = CURL(((CGUIMediaWindow*)window)->CurrentDirectory().m_strPath).GetWithoutUserDetails();
1294         if (info==CONTAINER_FOLDERNAME)
1295         {
1296           URIUtils::RemoveSlashAtEnd(strLabel);
1297           strLabel=URIUtils::GetFileName(strLabel);
1298         }
1299       }
1300       break;
1301     }
1302   case CONTAINER_PLUGINNAME:
1303     {
1304       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1305       if (window)
1306       {
1307         CURL url(((CGUIMediaWindow*)window)->CurrentDirectory().m_strPath);
1308         if (url.GetProtocol().Equals("plugin"))
1309         {
1310           strLabel = url.GetFileName();
1311           URIUtils::RemoveSlashAtEnd(strLabel);
1312         }
1313       }
1314       break;
1315     }
1316   case CONTAINER_VIEWMODE:
1317     {
1318       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1319       if (window)
1320       {
1321         const CGUIControl *control = window->GetControl(window->GetViewContainerID());
1322         if (control && control->IsContainer())
1323           strLabel = ((CGUIBaseContainer *)control)->GetLabel();
1324       }
1325       break;
1326     }
1327   case CONTAINER_SORT_METHOD:
1328     {
1329       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1330       if (window)
1331       {
1332         const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
1333         if (viewState)
1334           strLabel = g_localizeStrings.Get(viewState->GetSortMethodLabel());
1335     }
1336     }
1337     break;
1338   case CONTAINER_NUM_PAGES:
1339   case CONTAINER_NUM_ITEMS:
1340   case CONTAINER_CURRENT_PAGE:
1341     return GetMultiInfoLabel(GUIInfo(info), contextWindow);
1342     break;
1343   case CONTAINER_SHOWPLOT:
1344     {
1345       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1346       if (window)
1347         return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("showplot");
1348     }
1349     break;
1350   case CONTAINER_TOTALTIME:
1351     {
1352       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1353       if (window)
1354       {
1355         const CFileItemList& items=((CGUIMediaWindow *)window)->CurrentDirectory();
1356         int duration=0;
1357         for (int i=0;i<items.Size();++i)
1358         {
1359           CFileItemPtr item=items.Get(i);
1360           if (item->HasMusicInfoTag())
1361             duration += item->GetMusicInfoTag()->GetDuration();
1362           else if (item->HasVideoInfoTag())
1363             duration += item->GetVideoInfoTag()->m_streamDetails.GetVideoDuration();
1364         }
1365         if (duration > 0)
1366           return StringUtils::SecondsToTimeString(duration);
1367       }
1368     }
1369     break;
1370   case SYSTEM_BUILD_VERSION:
1371     strLabel = GetVersion();
1372     break;
1373   case SYSTEM_BUILD_DATE:
1374     strLabel = GetBuild();
1375     break;
1376   case SYSTEM_FREE_MEMORY:
1377   case SYSTEM_FREE_MEMORY_PERCENT:
1378   case SYSTEM_USED_MEMORY:
1379   case SYSTEM_USED_MEMORY_PERCENT:
1380   case SYSTEM_TOTAL_MEMORY:
1381     {
1382       MEMORYSTATUS stat;
1383       GlobalMemoryStatus(&stat);
1384       int iMemPercentFree = 100 - ((int)( 100.0f* (stat.dwTotalPhys - stat.dwAvailPhys)/stat.dwTotalPhys + 0.5f ));
1385       int iMemPercentUsed = 100 - iMemPercentFree;
1386
1387       if (info == SYSTEM_FREE_MEMORY)
1388         strLabel.Format("%luMB", (ULONG)(stat.dwAvailPhys/MB));
1389       else if (info == SYSTEM_FREE_MEMORY_PERCENT)
1390         strLabel.Format("%i%%", iMemPercentFree);
1391       else if (info == SYSTEM_USED_MEMORY)
1392         strLabel.Format("%luMB", (ULONG)((stat.dwTotalPhys - stat.dwAvailPhys)/MB));
1393       else if (info == SYSTEM_USED_MEMORY_PERCENT)
1394         strLabel.Format("%i%%", iMemPercentUsed);
1395       else if (info == SYSTEM_TOTAL_MEMORY)
1396         strLabel.Format("%luMB", (ULONG)(stat.dwTotalPhys/MB));
1397     }
1398     break;
1399   case SYSTEM_SCREEN_MODE:
1400     strLabel = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].strMode;
1401     break;
1402   case SYSTEM_SCREEN_WIDTH:
1403     strLabel.Format("%i", g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].iWidth);
1404     break;
1405   case SYSTEM_SCREEN_HEIGHT:
1406     strLabel.Format("%i", g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].iHeight);
1407     break;
1408   case SYSTEM_CURRENT_WINDOW:
1409     return g_localizeStrings.Get(g_windowManager.GetFocusedWindow());
1410     break;
1411   case SYSTEM_CURRENT_CONTROL:
1412     {
1413       CGUIWindow *window = g_windowManager.GetWindow(g_windowManager.GetFocusedWindow());
1414       if (window)
1415       {
1416         CGUIControl *control = window->GetFocusedControl();
1417         if (control)
1418           strLabel = control->GetDescription();
1419       }
1420     }
1421     break;
1422 #ifdef HAS_DVD_DRIVE
1423   case SYSTEM_DVD_LABEL:
1424     strLabel = g_mediaManager.GetDiskLabel();
1425     break;
1426 #endif
1427   case SYSTEM_ALARM_POS:
1428     if (g_alarmClock.GetRemaining("shutdowntimer") == 0.f)
1429       strLabel = "";
1430     else
1431     {
1432       double fTime = g_alarmClock.GetRemaining("shutdowntimer");
1433       if (fTime > 60.f)
1434         strLabel.Format(g_localizeStrings.Get(13213).c_str(),g_alarmClock.GetRemaining("shutdowntimer")/60.f);
1435       else
1436         strLabel.Format(g_localizeStrings.Get(13214).c_str(),g_alarmClock.GetRemaining("shutdowntimer"));
1437     }
1438     break;
1439   case SYSTEM_PROFILENAME:
1440     strLabel = g_settings.GetCurrentProfile().getName();
1441     break;
1442   case SYSTEM_PROFILECOUNT:
1443     strLabel.Format("%i", g_settings.GetNumProfiles());
1444     break;
1445   case SYSTEM_LANGUAGE:
1446     strLabel = g_guiSettings.GetString("locale.language");
1447     break;
1448   case SYSTEM_TEMPERATURE_UNITS:
1449     strLabel = g_langInfo.GetTempUnitString();
1450     break;
1451   case SYSTEM_PROGRESS_BAR:
1452     {
1453       int percent = GetInt(SYSTEM_PROGRESS_BAR);
1454       if (percent)
1455         strLabel.Format("%i", percent);
1456     }
1457     break;
1458   case LCD_PLAY_ICON:
1459     {
1460       int iPlaySpeed = g_application.GetPlaySpeed();
1461       if (g_application.IsPaused())
1462         strLabel.Format("\7");
1463       else if (iPlaySpeed < 1)
1464         strLabel.Format("\3:%ix", iPlaySpeed);
1465       else if (iPlaySpeed > 1)
1466         strLabel.Format("\4:%ix", iPlaySpeed);
1467       else
1468         strLabel.Format("\5");
1469     }
1470     break;
1471
1472   case LCD_TIME_21:
1473   case LCD_TIME_22:
1474   case LCD_TIME_W21:
1475   case LCD_TIME_W22:
1476   case LCD_TIME_41:
1477   case LCD_TIME_42:
1478   case LCD_TIME_43:
1479   case LCD_TIME_44:
1480     //alternatively, set strLabel
1481     return GetLcdTime( info );
1482     break;
1483
1484   case SKIN_THEME:
1485     if (g_guiSettings.GetString("lookandfeel.skintheme").Equals("skindefault"))
1486       strLabel = g_localizeStrings.Get(15109);
1487     else
1488       strLabel = g_guiSettings.GetString("lookandfeel.skintheme");
1489     break;
1490   case SKIN_COLOUR_THEME:
1491     if (g_guiSettings.GetString("lookandfeel.skincolors").Equals("skindefault"))
1492       strLabel = g_localizeStrings.Get(15109);
1493     else
1494       strLabel = g_guiSettings.GetString("lookandfeel.skincolors");
1495     break;
1496 #ifdef HAS_LCD
1497   case LCD_PROGRESS_BAR:
1498     if (g_lcd) strLabel = g_lcd->GetProgressBar(g_application.GetTime(), g_application.GetTotalTime());
1499     break;
1500 #endif
1501   case NETWORK_IP_ADDRESS:
1502     {
1503       CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1504       if (iface)
1505         return iface->GetCurrentIPAddress();
1506     }
1507     break;
1508   case NETWORK_SUBNET_ADDRESS:
1509     {
1510       CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1511       if (iface)
1512         return iface->GetCurrentNetmask();
1513     }
1514     break;
1515   case NETWORK_GATEWAY_ADDRESS:
1516     {
1517       CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1518       if (iface)
1519         return iface->GetCurrentDefaultGateway();
1520     }
1521     break;
1522   case NETWORK_DNS1_ADDRESS:
1523     {
1524       vector<CStdString> nss = g_application.getNetwork().GetNameServers();
1525       if (nss.size() >= 1)
1526         return nss[0];
1527     }
1528     break;
1529   case NETWORK_DNS2_ADDRESS:
1530     {
1531       vector<CStdString> nss = g_application.getNetwork().GetNameServers();
1532       if (nss.size() >= 2)
1533         return nss[1];
1534     }
1535     break;
1536   case NETWORK_DHCP_ADDRESS:
1537     {
1538       CStdString dhcpserver;
1539       return dhcpserver;
1540     }
1541     break;
1542   case NETWORK_LINK_STATE:
1543     {
1544       CStdString linkStatus = g_localizeStrings.Get(151);
1545       linkStatus += " ";
1546       CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1547       if (iface && iface->IsConnected())
1548         linkStatus += g_localizeStrings.Get(15207);
1549       else
1550         linkStatus += g_localizeStrings.Get(15208);
1551       return linkStatus;
1552     }
1553     break;
1554
1555   case AUDIOSCROBBLER_CONN_STATE:
1556   case AUDIOSCROBBLER_SUBMIT_INT:
1557   case AUDIOSCROBBLER_FILES_CACHED:
1558   case AUDIOSCROBBLER_SUBMIT_STATE:
1559     strLabel=GetAudioScrobblerLabel(info);
1560     break;
1561   case VISUALISATION_PRESET:
1562     {
1563       CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
1564       g_windowManager.SendMessage(msg);
1565       if (msg.GetPointer())
1566       {
1567         CVisualisation* viz = NULL;
1568         viz = (CVisualisation*)msg.GetPointer();
1569         if (viz)
1570         {
1571           strLabel = viz->GetPresetName();
1572           URIUtils::RemoveExtension(strLabel);
1573         }
1574       }
1575     }
1576     break;
1577   case VISUALISATION_NAME:
1578     {
1579       AddonPtr addon;
1580       strLabel = g_guiSettings.GetString("musicplayer.visualisation");
1581       if (CAddonMgr::Get().GetAddon(strLabel,addon) && addon)
1582         strLabel = addon->Name();
1583     }
1584     break;
1585   case FANART_COLOR1:
1586     {
1587       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1588       if (window)
1589         return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color1");
1590     }
1591     break;
1592   case FANART_COLOR2:
1593     {
1594       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1595       if (window)
1596         return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color2");
1597     }
1598     break;
1599   case FANART_COLOR3:
1600     {
1601       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1602       if (window)
1603         return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color3");
1604     }
1605     break;
1606   case FANART_IMAGE:
1607     {
1608       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1609       if (window)
1610         return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_image");
1611     }
1612     break;
1613   case SYSTEM_RENDER_VENDOR:
1614     strLabel = g_Windowing.GetRenderVendor();
1615     break;
1616   case SYSTEM_RENDER_RENDERER:
1617     strLabel = g_Windowing.GetRenderRenderer();
1618     break;
1619   case SYSTEM_RENDER_VERSION:
1620     strLabel = g_Windowing.GetRenderVersionString();
1621     break;
1622   }
1623
1624   return strLabel;
1625 }
1626
1627 // tries to get a integer value for use in progressbars/sliders and such
1628 int CGUIInfoManager::GetInt(int info, int contextWindow) const
1629 {
1630   switch( info )
1631   {
1632     case PLAYER_VOLUME:
1633       return g_application.GetVolume();
1634     case PLAYER_SUBTITLE_DELAY:
1635       return g_application.GetSubtitleDelay();
1636     case PLAYER_AUDIO_DELAY:
1637       return g_application.GetAudioDelay();
1638     case PLAYER_PROGRESS:
1639     case PLAYER_SEEKBAR:
1640     case PLAYER_CACHELEVEL:
1641     case PLAYER_CHAPTER:
1642     case PLAYER_CHAPTERCOUNT:
1643       {
1644         if( g_application.IsPlaying() && g_application.m_pPlayer)
1645         {
1646           switch( info )
1647           {
1648           case PLAYER_PROGRESS:
1649             return (int)(g_application.GetPercentage());
1650           case PLAYER_SEEKBAR:
1651             {
1652               CGUIDialogSeekBar *seekBar = (CGUIDialogSeekBar*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
1653               return seekBar ? (int)seekBar->GetPercentage() : 0;
1654             }
1655           case PLAYER_CACHELEVEL:
1656             return (int)(g_application.m_pPlayer->GetCacheLevel());
1657           case PLAYER_CHAPTER:
1658             return g_application.m_pPlayer->GetChapter();
1659           case PLAYER_CHAPTERCOUNT:
1660             return g_application.m_pPlayer->GetChapterCount();
1661           }
1662         }
1663       }
1664       break;
1665     case SYSTEM_FREE_MEMORY:
1666     case SYSTEM_USED_MEMORY:
1667       {
1668         MEMORYSTATUS stat;
1669         GlobalMemoryStatus(&stat);
1670         int memPercentUsed = (int)( 100.0f* (stat.dwTotalPhys - stat.dwAvailPhys)/stat.dwTotalPhys + 0.5f );
1671         if (info == SYSTEM_FREE_MEMORY)
1672           return 100 - memPercentUsed;
1673         return memPercentUsed;
1674       }
1675     case SYSTEM_PROGRESS_BAR:
1676       {
1677         CGUIDialogProgress *bar = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
1678         if (bar && bar->IsDialogRunning())
1679           return bar->GetPercentage();
1680       }
1681     case SYSTEM_FREE_SPACE:
1682     case SYSTEM_FREE_SPACE_C:
1683     case SYSTEM_FREE_SPACE_E:
1684     case SYSTEM_FREE_SPACE_F:
1685     case SYSTEM_FREE_SPACE_G:
1686     case SYSTEM_USED_SPACE:
1687     case SYSTEM_USED_SPACE_C:
1688     case SYSTEM_USED_SPACE_E:
1689     case SYSTEM_USED_SPACE_F:
1690     case SYSTEM_USED_SPACE_G:
1691     case SYSTEM_FREE_SPACE_X:
1692     case SYSTEM_USED_SPACE_X:
1693     case SYSTEM_FREE_SPACE_Y:
1694     case SYSTEM_USED_SPACE_Y:
1695     case SYSTEM_FREE_SPACE_Z:
1696     case SYSTEM_USED_SPACE_Z:
1697       {
1698         int ret = 0;
1699         g_sysinfo.GetHddSpaceInfo(ret, info, true);
1700         return ret;
1701       }
1702     case SYSTEM_CPU_USAGE:
1703       return g_cpuInfo.getUsedPercentage();
1704   }
1705   return 0;
1706 }
1707 // checks the condition and returns it as necessary.  Currently used
1708 // for toggle button controls and visibility of images.
1709 bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListItem *item)
1710 {
1711   // check our cache
1712   bool bReturn = false;
1713   if (!item && IsCached(condition1, contextWindow, bReturn)) // never use cache for list items
1714     return bReturn;
1715
1716   int condition = abs(condition1);
1717
1718   if(condition >= COMBINED_VALUES_START && (condition - COMBINED_VALUES_START) < (int)(m_CombinedValues.size()) )
1719   {
1720     const CCombinedValue &comb = m_CombinedValues[condition - COMBINED_VALUES_START];
1721     if (!EvaluateBooleanExpression(comb, bReturn, contextWindow, item))
1722       bReturn = false;
1723   }
1724   else if (item && condition >= LISTITEM_START && condition < LISTITEM_END)
1725     bReturn = GetItemBool(item, condition);
1726   // Ethernet Link state checking
1727   // Will check if the Xbox has a Ethernet Link connection! [Cable in!]
1728   // This can used for the skinner to switch off Network or Inter required functions
1729   else if ( condition == SYSTEM_ALWAYS_TRUE)
1730     bReturn = true;
1731   else if (condition == SYSTEM_ALWAYS_FALSE)
1732     bReturn = false;
1733   else if (condition == SYSTEM_ETHERNET_LINK_ACTIVE)
1734     bReturn = true;
1735   else if (condition > SYSTEM_IDLE_TIME_START && condition <= SYSTEM_IDLE_TIME_FINISH)
1736     bReturn = (g_application.GlobalIdleTime() >= condition - SYSTEM_IDLE_TIME_START);
1737   else if (condition == WINDOW_IS_MEDIA)
1738   { // note: This doesn't return true for dialogs (content, favourites, login, videoinfo)
1739     CGUIWindow *pWindow = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
1740     bReturn = (pWindow && pWindow->IsMediaWindow());
1741   }
1742   else if (condition == PLAYER_MUTED)
1743     bReturn = g_settings.m_bMute;
1744   else if (condition >= LIBRARY_HAS_MUSIC && condition <= LIBRARY_HAS_MUSICVIDEOS)
1745     bReturn = GetLibraryBool(condition);
1746   else if (condition == LIBRARY_IS_SCANNING)
1747   {
1748     CGUIDialogMusicScan *musicScanner = (CGUIDialogMusicScan *)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_SCAN);
1749     CGUIDialogVideoScan *videoScanner = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN);
1750     if (musicScanner->IsScanning() || videoScanner->IsScanning())
1751       bReturn = true;
1752     else
1753       bReturn = false;
1754   }
1755   else if (condition == SYSTEM_PLATFORM_LINUX)
1756 #if defined(_LINUX) && !defined(__APPLE__)
1757     bReturn = true;
1758 #else
1759     bReturn = false;
1760 #endif
1761   else if (condition == SYSTEM_PLATFORM_WINDOWS)
1762 #ifdef WIN32
1763     bReturn = true;
1764 #else
1765     bReturn = false;
1766 #endif
1767   else if (condition == SYSTEM_PLATFORM_OSX)
1768 #ifdef __APPLE__
1769     bReturn = true;
1770 #else
1771     bReturn = false;
1772 #endif
1773   else if (condition == SYSTEM_PLATFORM_XBOX)
1774     bReturn = false;
1775   else if (condition == SYSTEM_MEDIA_DVD)
1776     bReturn = g_mediaManager.IsDiscInDrive();
1777 #ifdef HAS_DVD_DRIVE
1778   else if (condition == SYSTEM_HAS_DRIVE_F)
1779     bReturn = CIoSupport::DriveExists('F');
1780   else if (condition == SYSTEM_HAS_DRIVE_G)
1781     bReturn = CIoSupport::DriveExists('G');
1782   else if (condition == SYSTEM_DVDREADY)
1783     bReturn = g_mediaManager.GetDriveStatus() != DRIVE_NOT_READY;
1784   else if (condition == SYSTEM_TRAYOPEN)
1785     bReturn = g_mediaManager.GetDriveStatus() == DRIVE_OPEN;
1786 #endif
1787   else if (condition == SYSTEM_CAN_POWERDOWN)
1788     bReturn = g_powerManager.CanPowerdown();
1789   else if (condition == SYSTEM_CAN_SUSPEND)
1790     bReturn = g_powerManager.CanSuspend();
1791   else if (condition == SYSTEM_CAN_HIBERNATE)
1792     bReturn = g_powerManager.CanHibernate();
1793   else if (condition == SYSTEM_CAN_REBOOT)
1794     bReturn = g_powerManager.CanReboot();
1795
1796   else if (condition == PLAYER_SHOWINFO)
1797     bReturn = m_playerShowInfo;
1798   else if (condition == PLAYER_SHOWCODEC)
1799     bReturn = m_playerShowCodec;
1800   else if (condition >= SKIN_HAS_THEME_START && condition <= SKIN_HAS_THEME_END)
1801   { // Note that the code used here could probably be extended to general
1802     // settings conditions (parameter would need to store both the setting name an
1803     // the and the comparison string)
1804     CStdString theme = g_guiSettings.GetString("lookandfeel.skintheme");
1805     theme.ToLower();
1806     URIUtils::RemoveExtension(theme);
1807     bReturn = theme.Equals(m_stringParameters[condition - SKIN_HAS_THEME_START]);
1808   }
1809   else if (condition >= MULTI_INFO_START && condition <= MULTI_INFO_END)
1810   {
1811     // cache return value
1812     bool result = GetMultiInfoBool(m_multiInfo[condition - MULTI_INFO_START], contextWindow, item);
1813     if (!item)
1814       CacheBool(condition1, contextWindow, result);
1815     return result;
1816   }
1817   else if (condition == SYSTEM_HASLOCKS)
1818     bReturn = g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE;
1819   else if (condition == SYSTEM_ISMASTER)
1820     bReturn = g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && g_passwordManager.bMasterUser;
1821   else if (condition == SYSTEM_LOGGEDON)
1822     bReturn = !(g_windowManager.GetActiveWindow() == WINDOW_LOGIN_SCREEN);
1823   else if (condition == SYSTEM_HAS_LOGINSCREEN)
1824     bReturn = g_settings.UsingLoginScreen();
1825   else if (condition == WEATHER_IS_FETCHED)
1826     bReturn = g_weatherManager.IsFetched();
1827   else if (condition == SYSTEM_INTERNET_STATE)
1828   {
1829     g_sysinfo.GetInfo(condition);
1830     bReturn = g_sysinfo.HasInternet();
1831   }
1832   else if (condition == SKIN_HAS_VIDEO_OVERLAY)
1833   {
1834     bReturn = g_windowManager.IsOverlayAllowed() && g_application.IsPlayingVideo();
1835   }
1836   else if (condition == SKIN_HAS_MUSIC_OVERLAY)
1837   {
1838     bReturn = g_windowManager.IsOverlayAllowed() && g_application.IsPlayingAudio();
1839   }
1840   else if (condition == CONTAINER_HASFILES || condition == CONTAINER_HASFOLDERS)
1841   {
1842     CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1843     if (pWindow)
1844     {
1845       const CFileItemList& items=((CGUIMediaWindow*)pWindow)->CurrentDirectory();
1846       for (int i=0;i<items.Size();++i)
1847       {
1848         CFileItemPtr item=items.Get(i);
1849         if (!item->m_bIsFolder && condition == CONTAINER_HASFILES)
1850         {
1851           bReturn=true;
1852           break;
1853         }
1854         else if (item->m_bIsFolder && !item->IsParentFolder() && condition == CONTAINER_HASFOLDERS)
1855         {
1856           bReturn=true;
1857           break;
1858         }
1859       }
1860     }
1861   }
1862   else if (condition == CONTAINER_STACKED)
1863   {
1864     CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1865     if (pWindow)
1866       bReturn = ((CGUIMediaWindow*)pWindow)->CurrentDirectory().GetProperty("isstacked")=="1";
1867   }
1868   else if (condition == CONTAINER_HAS_THUMB)
1869   {
1870     CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1871     if (pWindow)
1872       bReturn = ((CGUIMediaWindow*)pWindow)->CurrentDirectory().HasThumbnail();
1873   }
1874   else if (condition == VIDEOPLAYER_HAS_INFO)
1875     bReturn = (m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->IsEmpty());
1876   else if (condition >= CONTAINER_SCROLL_PREVIOUS && condition <= CONTAINER_SCROLL_NEXT)
1877   {
1878     // no parameters, so we assume it's just requested for a media window.  It therefore
1879     // can only happen if the list has focus.
1880     CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1881     if (pWindow)
1882     {
1883       map<int,int>::const_iterator it = m_containerMoves.find(pWindow->GetViewContainerID());
1884       if (it != m_containerMoves.end())
1885       {
1886         if (condition > CONTAINER_STATIC) // moving up
1887           bReturn = it->second >= std::max(condition - CONTAINER_STATIC, 1);
1888         else
1889           bReturn = it->second <= std::min(condition - CONTAINER_STATIC, -1);
1890       }
1891     }
1892   }
1893   else if (g_application.IsPlaying())
1894   {
1895     switch (condition)
1896     {
1897     case PLAYER_HAS_MEDIA:
1898       bReturn = true;
1899       break;
1900     case PLAYER_HAS_AUDIO:
1901       bReturn = g_application.IsPlayingAudio();
1902       break;
1903     case PLAYER_HAS_VIDEO:
1904       bReturn = g_application.IsPlayingVideo();
1905       break;
1906     case PLAYER_PLAYING:
1907       bReturn = !g_application.IsPaused() && (g_application.GetPlaySpeed() == 1);
1908       break;
1909     case PLAYER_PAUSED:
1910       bReturn = g_application.IsPaused();
1911       break;
1912     case PLAYER_REWINDING:
1913       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() < 1;
1914       break;
1915     case PLAYER_FORWARDING:
1916       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() > 1;
1917       break;
1918     case PLAYER_REWINDING_2x:
1919       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -2;
1920       break;
1921     case PLAYER_REWINDING_4x:
1922       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -4;
1923       break;
1924     case PLAYER_REWINDING_8x:
1925       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -8;
1926       break;
1927     case PLAYER_REWINDING_16x:
1928       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -16;
1929       break;
1930     case PLAYER_REWINDING_32x:
1931       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -32;
1932       break;
1933     case PLAYER_FORWARDING_2x:
1934       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 2;
1935       break;
1936     case PLAYER_FORWARDING_4x:
1937       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 4;
1938       break;
1939     case PLAYER_FORWARDING_8x:
1940       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 8;
1941       break;
1942     case PLAYER_FORWARDING_16x:
1943       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 16;
1944       break;
1945     case PLAYER_FORWARDING_32x:
1946       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 32;
1947       break;
1948     case PLAYER_CAN_RECORD:
1949       bReturn = g_application.m_pPlayer->CanRecord();
1950       break;
1951     case PLAYER_RECORDING:
1952       bReturn = g_application.m_pPlayer->IsRecording();
1953     break;
1954     case PLAYER_DISPLAY_AFTER_SEEK:
1955       bReturn = GetDisplayAfterSeek();
1956     break;
1957     case PLAYER_CACHING:
1958       bReturn = g_application.m_pPlayer->IsCaching();
1959     break;
1960     case PLAYER_SEEKBAR:
1961       {
1962         CGUIDialogSeekBar *seekBar = (CGUIDialogSeekBar*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
1963         bReturn = seekBar ? seekBar->IsDialogRunning() : false;
1964       }
1965     break;
1966     case PLAYER_SEEKING:
1967       bReturn = m_playerSeeking;
1968     break;
1969     case PLAYER_SHOWTIME:
1970       bReturn = m_playerShowTime;
1971     break;
1972     case PLAYER_PASSTHROUGH:
1973       bReturn = g_application.m_pPlayer && g_application.m_pPlayer->IsPassthrough();
1974       break;
1975     case MUSICPM_ENABLED:
1976       bReturn = g_partyModeManager.IsEnabled();
1977     break;
1978     case AUDIOSCROBBLER_ENABLED:
1979       bReturn = CLastFmManager::GetInstance()->IsLastFmEnabled();
1980     break;
1981     case LASTFM_RADIOPLAYING:
1982       bReturn = CLastFmManager::GetInstance()->IsRadioEnabled();
1983       break;
1984     case LASTFM_CANLOVE:
1985       bReturn = CLastFmManager::GetInstance()->CanLove();
1986       break;
1987     case LASTFM_CANBAN:
1988       bReturn = CLastFmManager::GetInstance()->CanBan();
1989       break;
1990     case MUSICPLAYER_HASPREVIOUS:
1991       {
1992         // requires current playlist be PLAYLIST_MUSIC
1993         bReturn = false;
1994         if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
1995           bReturn = (g_playlistPlayer.GetCurrentSong() > 0); // not first song
1996       }
1997       break;
1998     case MUSICPLAYER_HASNEXT:
1999       {
2000         // requires current playlist be PLAYLIST_MUSIC
2001         bReturn = false;
2002         if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2003           bReturn = (g_playlistPlayer.GetCurrentSong() < (g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC).size() - 1)); // not last song
2004       }
2005       break;
2006     case MUSICPLAYER_PLAYLISTPLAYING:
2007       {
2008         bReturn = false;
2009         if (g_application.IsPlayingAudio() && g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2010           bReturn = true;
2011       }
2012       break;
2013     case VIDEOPLAYER_USING_OVERLAYS:
2014       bReturn = (g_guiSettings.GetInt("videoplayer.rendermethod") == RENDER_OVERLAYS);
2015     break;
2016     case VIDEOPLAYER_ISFULLSCREEN:
2017       bReturn = g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO;
2018     break;
2019     case VIDEOPLAYER_HASMENU:
2020       bReturn = g_application.m_pPlayer->HasMenu();
2021     break;
2022     case PLAYLIST_ISRANDOM:
2023       bReturn = g_playlistPlayer.IsShuffled(g_playlistPlayer.GetCurrentPlaylist());
2024     break;
2025     case PLAYLIST_ISREPEAT:
2026       bReturn = g_playlistPlayer.GetRepeat(g_playlistPlayer.GetCurrentPlaylist()) == PLAYLIST::REPEAT_ALL;
2027     break;
2028     case PLAYLIST_ISREPEATONE:
2029       bReturn = g_playlistPlayer.GetRepeat(g_playlistPlayer.GetCurrentPlaylist()) == PLAYLIST::REPEAT_ONE;
2030     break;
2031     case PLAYER_HASDURATION:
2032       bReturn = g_application.GetTotalTime() > 0;
2033       break;
2034     case VIDEOPLAYER_HASTELETEXT:
2035       if (g_application.m_pPlayer->GetTeletextCache())
2036         bReturn = true;
2037       break;
2038     case VISUALISATION_LOCKED:
2039       {
2040         CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
2041         g_windowManager.SendMessage(msg);
2042         if (msg.GetPointer())
2043         {
2044           CVisualisation *pVis = (CVisualisation *)msg.GetPointer();
2045           bReturn = pVis->IsLocked();
2046         }
2047       }
2048     break;
2049     case VISUALISATION_ENABLED:
2050       bReturn = g_guiSettings.GetString("musicplayer.visualisation") != "None";
2051     break;
2052     default: // default, use integer value different from 0 as true
2053       bReturn = GetInt(condition) != 0;
2054     }
2055   }
2056   // cache return value
2057   if (condition1 < 0) bReturn = !bReturn;
2058
2059   if (!item) // don't cache item properties
2060     CacheBool(condition1, contextWindow, bReturn);
2061
2062   return bReturn;
2063 }
2064
2065 /// \brief Examines the multi information sent and returns true or false accordingly.
2066 bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, const CGUIListItem *item)
2067 {
2068   bool bReturn = false;
2069   int condition = abs(info.m_info);
2070
2071   if (condition >= LISTITEM_START && condition <= LISTITEM_END)
2072   {
2073     // TODO: We currently don't use the item that is passed in to here, as these
2074     //       conditions only come from Container(id).ListItem(offset).* at this point.
2075     CGUIListItemPtr item;
2076     CGUIWindow *window = NULL;
2077     int data1 = info.GetData1();
2078     if (!data1) // No container specified, so we lookup the current view container
2079     {
2080       window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
2081       if (window && window->IsMediaWindow())
2082         data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
2083     }
2084
2085     if (!window) // If we don't have a window already (from lookup above), get one
2086       window = GetWindowWithCondition(contextWindow, 0);
2087
2088     if (window)
2089     {
2090       const CGUIControl *control = window->GetControl(data1);
2091       if (control && control->IsContainer())
2092         item = ((CGUIBaseContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag());
2093     }
2094
2095     if (item) // If we got a valid item, do the lookup
2096       bReturn = GetItemBool(item.get(), condition); // Image prioritizes images over labels (in the case of music item ratings for instance)
2097   }
2098   else
2099   {
2100     switch (condition)
2101     {
2102       case SKIN_BOOL:
2103         {
2104           bReturn = g_settings.GetSkinBool(info.GetData1());
2105         }
2106         break;
2107       case SKIN_STRING:
2108         {
2109           if (info.GetData2())
2110             bReturn = g_settings.GetSkinString(info.GetData1()).Equals(m_stringParameters[info.GetData2()]);
2111           else
2112             bReturn = !g_settings.GetSkinString(info.GetData1()).IsEmpty();
2113         }
2114         break;
2115       case STRING_IS_EMPTY:
2116         // note: Get*Image() falls back to Get*Label(), so this should cover all of them
2117         if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2118           bReturn = GetItemImage((const CFileItem *)item, info.GetData1()).IsEmpty();
2119         else
2120           bReturn = GetImage(info.GetData1(), contextWindow).IsEmpty();
2121         break;
2122       case STRING_COMPARE:
2123         {
2124           CStdString compare;
2125           if (info.GetData2() < 0) // info labels are stored with negative numbers
2126           {
2127             int info2 = -info.GetData2();
2128             if (item && item->IsFileItem() && info2 >= LISTITEM_START && info2 < LISTITEM_END)
2129               compare = GetItemImage((const CFileItem *)item, info2);
2130             else
2131               compare = GetImage(info2, contextWindow);
2132           }
2133           else if (info.GetData2() < (int)m_stringParameters.size())
2134           { // conditional string
2135             compare = m_stringParameters[info.GetData2()];
2136           }
2137           if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2138             bReturn = GetItemImage((const CFileItem *)item, info.GetData1()).Equals(compare);
2139           else
2140             bReturn = GetImage(info.GetData1(), contextWindow).Equals(compare);
2141         }
2142         break;
2143       case INTEGER_GREATER_THAN:
2144         {
2145           CStdString value;
2146
2147           if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2148             value = GetItemImage((const CFileItem *)item, info.GetData1());
2149           else
2150             value = GetImage(info.GetData1(), contextWindow);
2151
2152           // Handle the case when a value contains time separator (:). This makes IntegerGreaterThan
2153           // useful for Player.Time* members without adding a separate set of members returning time in seconds
2154           if ( value.find_first_of( ':' ) != value.npos )
2155             bReturn = StringUtils::TimeStringToSeconds( value ) > info.GetData2();
2156           else
2157             bReturn = atoi( value.c_str() ) > info.GetData2();
2158         }
2159         break;
2160       case STRING_STR:
2161           {
2162             CStdString compare = m_stringParameters[info.GetData2()];
2163             // our compare string is already in lowercase, so lower case our label as well
2164             // as CStdString::Find() is case sensitive
2165             CStdString label;
2166             if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2167               label = GetItemImage((const CFileItem *)item, info.GetData1()).ToLower();
2168             else
2169               label = GetImage(info.GetData1(), contextWindow).ToLower();
2170             if (compare.Right(5).Equals(",left"))
2171               bReturn = label.Find(compare.Mid(0,compare.size()-5)) == 0;
2172             else if (compare.Right(6).Equals(",right"))
2173             {
2174               compare = compare.Mid(0,compare.size()-6);
2175               bReturn = label.Find(compare) == (int)(label.size()-compare.size());
2176             }
2177             else
2178               bReturn = label.Find(compare) > -1;
2179           }
2180         break;
2181     case SYSTEM_ALARM_LESS_OR_EQUAL:
2182     {
2183       int time = lrint(g_alarmClock.GetRemaining(m_stringParameters[info.GetData1()]));
2184       int timeCompare = atoi(m_stringParameters[info.GetData2()]);
2185       if (time > 0)
2186         bReturn = timeCompare >= time;
2187       else
2188         bReturn = false;
2189     }
2190     break;
2191       case CONTROL_GROUP_HAS_FOCUS:
2192         {
2193           CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2194           if (window)
2195             bReturn = window->ControlGroupHasFocus(info.GetData1(), info.GetData2());
2196         }
2197         break;
2198       case CONTROL_IS_VISIBLE:
2199         {
2200           CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2201           if (window)
2202           {
2203             // Note: This'll only work for unique id's
2204             const CGUIControl *control = window->GetControl(info.GetData1());
2205             if (control)
2206               bReturn = control->IsVisible();
2207           }
2208         }
2209         break;
2210       case CONTROL_IS_ENABLED:
2211         {
2212           CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2213           if (window)
2214           {
2215             // Note: This'll only work for unique id's
2216             const CGUIControl *control = window->GetControl(info.GetData1());
2217             if (control)
2218               bReturn = !control->IsDisabled();
2219           }
2220         }
2221         break;
2222       case CONTROL_HAS_FOCUS:
2223         {
2224           CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2225           if (window)
2226             bReturn = (window->GetFocusedControlID() == (int)info.GetData1());
2227         }
2228         break;
2229       case BUTTON_SCROLLER_HAS_ICON:
2230         {
2231           CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2232           if (window)
2233           {
2234             CGUIControl *pControl = window->GetFocusedControl();
2235             if (pControl && pControl->GetControlType() == CGUIControl::GUICONTROL_BUTTONBAR)
2236               bReturn = ((CGUIButtonScroller *)pControl)->GetActiveButtonID() == (int)info.GetData1();
2237           }
2238         }
2239         break;
2240       case WINDOW_NEXT:
2241         if (info.GetData1())
2242           bReturn = ((int)info.GetData1() == m_nextWindowID);
2243         else
2244         {
2245           CGUIWindow *window = g_windowManager.GetWindow(m_nextWindowID);
2246           if (window && URIUtils::GetFileName(window->GetProperty("xmlfile")).Equals(m_stringParameters[info.GetData2()]))
2247             bReturn = true;
2248         }
2249         break;
2250       case WINDOW_PREVIOUS:
2251         if (info.GetData1())
2252           bReturn = ((int)info.GetData1() == m_prevWindowID);
2253         else
2254         {
2255           CGUIWindow *window = g_windowManager.GetWindow(m_prevWindowID);
2256           if (window && URIUtils::GetFileName(window->GetProperty("xmlfile")).Equals(m_stringParameters[info.GetData2()]))
2257             bReturn = true;
2258         }
2259         break;
2260       case WINDOW_IS_VISIBLE:
2261         if (info.GetData1())
2262           bReturn = g_windowManager.IsWindowVisible(info.GetData1());
2263         else
2264           bReturn = g_windowManager.IsWindowVisible(m_stringParameters[info.GetData2()]);
2265         break;
2266       case WINDOW_IS_TOPMOST:
2267         if (info.GetData1())
2268           bReturn = g_windowManager.IsWindowTopMost(info.GetData1());
2269         else
2270           bReturn = g_windowManager.IsWindowTopMost(m_stringParameters[info.GetData2()]);
2271         break;
2272       case WINDOW_IS_ACTIVE:
2273         if (info.GetData1())
2274           bReturn = g_windowManager.IsWindowActive(info.GetData1());
2275         else
2276           bReturn = g_windowManager.IsWindowActive(m_stringParameters[info.GetData2()]);
2277         break;
2278       case SYSTEM_HAS_ALARM:
2279         bReturn = g_alarmClock.HasAlarm(m_stringParameters[info.GetData1()]);
2280         break;
2281       case SYSTEM_GET_BOOL:
2282         bReturn = g_guiSettings.GetBool(m_stringParameters[info.GetData1()]);
2283         break;
2284       case SYSTEM_HAS_CORE_ID:
2285         bReturn = g_cpuInfo.HasCoreId(info.GetData1());
2286         break;
2287       case SYSTEM_SETTING:
2288         {
2289           if ( m_stringParameters[info.GetData1()].Equals("hidewatched") )
2290           {
2291             CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2292             if (window)
2293               bReturn = g_settings.GetWatchMode(((CGUIMediaWindow *)window)->CurrentDirectory().GetContent()) == VIDEO_SHOW_UNWATCHED;
2294           }
2295         }
2296         break;
2297       case SYSTEM_HAS_ADDON:
2298       {
2299         AddonPtr addon;
2300         bReturn = CAddonMgr::Get().GetAddon(m_stringParameters[info.GetData1()],addon) && addon;
2301         break;
2302       }
2303       case CONTAINER_SCROLL_PREVIOUS:
2304       case CONTAINER_MOVE_PREVIOUS:
2305       case CONTAINER_MOVE_NEXT:
2306       case CONTAINER_SCROLL_NEXT:
2307         {
2308           map<int,int>::const_iterator it = m_containerMoves.find(info.GetData1());
2309           if (it != m_containerMoves.end())
2310           {
2311             if (condition > CONTAINER_STATIC) // moving up
2312               bReturn = it->second >= std::max(condition - CONTAINER_STATIC, 1);
2313             else
2314               bReturn = it->second <= std::min(condition - CONTAINER_STATIC, -1);
2315           }
2316         }
2317         break;
2318       case CONTAINER_CONTENT:
2319         {
2320           CStdString content;
2321           CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2322           if (window)
2323           {
2324             if (window->GetID() == WINDOW_DIALOG_MUSIC_INFO)
2325               content = ((CGUIDialogMusicInfo *)window)->CurrentDirectory().GetContent();
2326             else if (window->GetID() == WINDOW_DIALOG_VIDEO_INFO)
2327               content = ((CGUIDialogVideoInfo *)window)->CurrentDirectory().GetContent();
2328           }
2329           if (content.IsEmpty())
2330           {
2331             window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2332             if (window)
2333               content = ((CGUIMediaWindow *)window)->CurrentDirectory().GetContent();
2334           }
2335           bReturn = m_stringParameters[info.GetData1()].Equals(content);
2336         }
2337         break;
2338       case CONTAINER_ROW:
2339       case CONTAINER_COLUMN:
2340       case CONTAINER_POSITION:
2341       case CONTAINER_HAS_NEXT:
2342       case CONTAINER_HAS_PREVIOUS:
2343       case CONTAINER_SCROLLING:
2344       case CONTAINER_SUBITEM:
2345         {
2346           const CGUIControl *control = NULL;
2347           if (info.GetData1())
2348           { // container specified
2349             CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2350             if (window)
2351               control = window->GetControl(info.GetData1());
2352           }
2353           else
2354           { // no container specified - assume a mediawindow
2355             CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2356             if (window)
2357               control = window->GetControl(window->GetViewContainerID());
2358           }
2359           if (control)
2360             bReturn = control->GetCondition(condition, info.GetData2());
2361         }
2362         break;
2363       case CONTAINER_HAS_FOCUS:
2364         { // grab our container
2365           CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2366           if (window)
2367           {
2368             const CGUIControl *control = window->GetControl(info.GetData1());
2369             if (control && control->IsContainer())
2370             {
2371               CFileItemPtr item = boost::static_pointer_cast<CFileItem>(((CGUIBaseContainer *)control)->GetListItem(0));
2372               if (item && item->m_iprogramCount == info.GetData2())  // programcount used to store item id
2373                 bReturn = true;
2374             }
2375           }
2376           break;
2377         }
2378       case VIDEOPLAYER_CONTENT:
2379         {
2380           CStdString strContent="movies";
2381           if (!m_currentFile->HasVideoInfoTag() || m_currentFile->GetVideoInfoTag()->IsEmpty())
2382             strContent = "files";
2383           if (m_currentFile->HasVideoInfoTag() && m_currentFile->GetVideoInfoTag()->m_iSeason > -1) // episode
2384             strContent = "episodes";
2385           if (m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->m_strArtist.IsEmpty())
2386             strContent = "musicvideos";
2387           if (m_currentFile->HasVideoInfoTag() && m_currentFile->GetVideoInfoTag()->m_strStatus == "livetv")
2388             strContent = "livetv";
2389           bReturn = m_stringParameters[info.GetData1()].Equals(strContent);
2390         }
2391         break;
2392       case CONTAINER_SORT_METHOD:
2393       {
2394         CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2395         if (window)
2396         {
2397           const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
2398           if (viewState)
2399             bReturn = ((unsigned int)viewState->GetSortMethod() == info.GetData1());
2400         }
2401         break;
2402       }
2403       case CONTAINER_SORT_DIRECTION:
2404       {
2405         CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2406         if (window)
2407         {
2408           const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
2409           if (viewState)
2410             bReturn = ((unsigned int)viewState->GetDisplaySortOrder() == info.GetData1());
2411         }
2412         break;
2413       }
2414       case SYSTEM_DATE:
2415         {
2416           CDateTime date = CDateTime::GetCurrentDateTime();
2417           int currentDate = date.GetMonth()*100+date.GetDay();
2418           int startDate = info.GetData1();
2419           int stopDate = info.GetData2();
2420
2421           if (stopDate < startDate)
2422             bReturn = currentDate >= startDate || currentDate < stopDate;
2423           else
2424             bReturn = currentDate >= startDate && currentDate < stopDate;
2425         }
2426         break;
2427       case SYSTEM_TIME:
2428         {
2429           CDateTime time=CDateTime::GetCurrentDateTime();
2430           int currentTime = time.GetMinuteOfDay();
2431           int startTime = info.GetData1();
2432           int stopTime = info.GetData2();
2433
2434           if (stopTime < startTime)
2435             bReturn = currentTime >= startTime || currentTime < stopTime;
2436           else
2437             bReturn = currentTime >= startTime && currentTime < stopTime;
2438         }
2439         break;
2440       case MUSICPLAYER_EXISTS:
2441         {
2442           int index = info.GetData2();
2443           if (info.GetData1() == 1)
2444           { // relative index
2445             if (g_playlistPlayer.GetCurrentPlaylist() != PLAYLIST_MUSIC)
2446               return false;
2447             index += g_playlistPlayer.GetCurrentSong();
2448           }
2449           if (index >= 0 && index < g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC).size())
2450             return true;
2451           return false;
2452         }
2453         break;
2454     }
2455   }
2456   return (info.m_info < 0) ? !bReturn : bReturn;
2457 }
2458
2459 /// \brief Examines the multi information sent and returns the string as appropriate
2460 CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWindow) const
2461 {
2462   if (info.m_info == SKIN_STRING)
2463   {
2464     return g_settings.GetSkinString(info.GetData1());
2465   }
2466   else if (info.m_info == SKIN_BOOL)
2467   {
2468     bool bInfo = g_settings.GetSkinBool(info.GetData1());
2469     if (bInfo)
2470       return g_localizeStrings.Get(20122);
2471   }
2472   if (info.m_info >= LISTITEM_START && info.m_info <= LISTITEM_END)
2473   {
2474     CFileItemPtr item;
2475     CGUIWindow *window = NULL;
2476
2477     int data1 = info.GetData1();
2478     if (!data1) // No container specified, so we lookup the current view container
2479     {
2480       window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
2481       if (window && window->IsMediaWindow())
2482         data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
2483     }
2484
2485     if (!window) // If we don't have a window already (from lookup above), get one
2486       window = GetWindowWithCondition(contextWindow, 0);
2487
2488     if (window)
2489     {
2490       const CGUIControl *control = window->GetControl(data1);
2491       if (control && control->IsContainer())
2492         item = boost::static_pointer_cast<CFileItem>(((CGUIBaseContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()));
2493     }
2494
2495     if (item) // If we got a valid item, do the lookup
2496       return GetItemImage(item.get(), info.m_info); // Image prioritizes images over labels (in the case of music item ratings for instance)
2497   }
2498   else if (info.m_info == PLAYER_TIME)
2499   {
2500     return GetCurrentPlayTime((TIME_FORMAT)info.GetData1());
2501   }
2502   else if (info.m_info == PLAYER_TIME_REMAINING)
2503   {
2504     return GetCurrentPlayTimeRemaining((TIME_FORMAT)info.GetData1());
2505   }
2506   else if (info.m_info == PLAYER_FINISH_TIME)
2507   {
2508     CDateTime time = CDateTime::GetCurrentDateTime();
2509     time += CDateTimeSpan(0, 0, 0, GetPlayTimeRemaining());
2510     return LocalizeTime(time, (TIME_FORMAT)info.GetData1());
2511   }
2512   else if (info.m_info == PLAYER_TIME_SPEED)
2513   {
2514     CStdString strTime;
2515     if (g_application.GetPlaySpeed() != 1)
2516       strTime.Format("%s (%ix)", GetCurrentPlayTime((TIME_FORMAT)info.GetData1()).c_str(), g_application.GetPlaySpeed());
2517     else
2518       strTime = GetCurrentPlayTime();
2519     return strTime;
2520   }
2521   else if (info.m_info == PLAYER_DURATION)
2522   {
2523     return GetDuration((TIME_FORMAT)info.GetData1());
2524   }
2525   else if (info.m_info == PLAYER_SEEKTIME)
2526   {
2527     TIME_FORMAT format = (TIME_FORMAT)info.GetData1();
2528     if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
2529       format = TIME_FORMAT_HH_MM_SS;
2530     CGUIDialogSeekBar *seekBar = (CGUIDialogSeekBar*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
2531     if (seekBar)
2532       return seekBar->GetSeekTimeLabel(format);
2533   }
2534   else if (info.m_info == PLAYER_SEEKOFFSET)
2535   {
2536     CStdString seekOffset = StringUtils::SecondsToTimeString(abs(m_seekOffset), (TIME_FORMAT)info.GetData1());
2537     if (m_seekOffset < 0)
2538       return "-" + seekOffset;
2539     if (m_seekOffset > 0)
2540       return "+" + seekOffset;
2541   }
2542   else if (info.m_info == SYSTEM_TIME)
2543   {
2544     return GetTime((TIME_FORMAT)info.GetData1());
2545   }
2546   else if (info.m_info == CONTAINER_NUM_PAGES || info.m_info == CONTAINER_CURRENT_PAGE ||
2547            info.m_info == CONTAINER_NUM_ITEMS || info.m_info == CONTAINER_POSITION)
2548   {
2549     const CGUIControl *control = NULL;
2550     if (info.GetData1())
2551     { // container specified
2552       CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2553       if (window)
2554         control = window->GetControl(info.GetData1());
2555     }
2556     else
2557     { // no container specified - assume a mediawindow
2558       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2559       if (window)
2560         control = window->GetControl(window->GetViewContainerID());
2561     }
2562     if (control)
2563     {
2564       if (control->IsContainer())
2565         return ((CGUIBaseContainer *)control)->GetLabel(info.m_info);
2566       else if (control->GetControlType() == CGUIControl::GUICONTROL_TEXTBOX)
2567         return ((CGUITextBox *)control)->GetLabel(info.m_info);
2568     }
2569   }
2570   else if (info.m_info == SYSTEM_GET_CORE_USAGE)
2571   {
2572     CStdString strCpu;
2573     strCpu.Format("%4.2f", g_cpuInfo.GetCoreInfo(info.GetData1()).m_fPct);
2574     return strCpu;
2575   }
2576   else if (info.m_info >= MUSICPLAYER_TITLE && info.m_info <= MUSICPLAYER_ALBUM_ARTIST)
2577     return GetMusicPlaylistInfo(info);
2578   else if (info.m_info == CONTAINER_PROPERTY)
2579   {
2580     CGUIWindow *window = NULL;
2581     if (info.GetData1())
2582     { // container specified
2583       window = GetWindowWithCondition(contextWindow, 0);
2584     }
2585     else
2586     { // no container specified - assume a mediawindow
2587       window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2588     }
2589     if (window)
2590       return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty(m_stringParameters[info.GetData2()]);
2591   }
2592   else if (info.m_info == CONTROL_GET_LABEL)
2593   {
2594     CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2595     if (window)
2596     {
2597       const CGUIControl *control = window->GetControl(info.GetData1());
2598       if (control)
2599         return control->GetDescription();
2600     }
2601   }
2602   else if (info.m_info == WINDOW_PROPERTY)
2603   {
2604     CGUIWindow *window = NULL;
2605     if (info.GetData1())
2606     { // window specified
2607       window = g_windowManager.GetWindow(info.GetData1());//GetWindowWithCondition(contextWindow, 0);
2608     }
2609     else
2610     { // no window specified - assume active
2611       window = GetWindowWithCondition(contextWindow, 0);
2612     }
2613
2614     if (window)
2615       return window->GetProperty(m_stringParameters[info.GetData2()]);
2616   }
2617   else if (info.m_info == SYSTEM_ADDON_TITLE ||
2618            info.m_info == SYSTEM_ADDON_ICON)
2619   {
2620     AddonPtr addon;
2621     if (info.GetData2() == 0)
2622       CAddonMgr::Get().GetAddon(const_cast<CGUIInfoManager*>(this)->GetLabel(info.GetData1(), contextWindow),addon);
2623     else 
2624       CAddonMgr::Get().GetAddon(m_stringParameters[info.GetData1()],addon);
2625     if (addon && info.m_info == SYSTEM_ADDON_TITLE)
2626       return addon->Name();
2627     if (addon && info.m_info == SYSTEM_ADDON_ICON)
2628       return addon->Icon();
2629   }
2630
2631   return StringUtils::EmptyString;
2632 }
2633
2634 /// \brief Obtains the filename of the image to show from whichever subsystem is needed
2635 CStdString CGUIInfoManager::GetImage(int info, int contextWindow)
2636 {
2637   if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
2638   {
2639     return GetMultiInfoLabel(m_multiInfo[info - MULTI_INFO_START], contextWindow);
2640   }
2641   else if (info == WEATHER_CONDITIONS)
2642     return g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON);
2643   else if (info == SYSTEM_PROFILETHUMB)
2644   {
2645     CStdString thumb = g_settings.GetCurrentProfile().getThumb();
2646     if (thumb.IsEmpty())
2647       thumb = "unknown-user.png";
2648     return thumb;
2649   }
2650   else if (info == MUSICPLAYER_COVER)
2651   {
2652     if (!g_application.IsPlayingAudio()) return "";
2653     return m_currentFile->HasThumbnail() ? m_currentFile->GetThumbnailImage() : "DefaultAlbumCover.png";
2654   }
2655   else if (info == MUSICPLAYER_RATING)
2656   {
2657     if (!g_application.IsPlayingAudio()) return "";
2658     return GetItemImage(m_currentFile, LISTITEM_RATING);
2659   }
2660   else if (info == PLAYER_STAR_RATING)
2661   {
2662     if (!g_application.IsPlaying()) return "";
2663     return GetItemImage(m_currentFile, LISTITEM_STAR_RATING);
2664   }
2665   else if (info == VIDEOPLAYER_COVER)
2666   {
2667     if (!g_application.IsPlayingVideo()) return "";
2668     if(m_currentMovieThumb.IsEmpty())
2669       return m_currentFile->HasThumbnail() ? m_currentFile->GetThumbnailImage() : "DefaultVideoCover.png";
2670     else return m_currentMovieThumb;
2671   }
2672   else if (info == CONTAINER_FOLDERTHUMB)
2673   {
2674     CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2675     if (window)
2676       return GetItemImage(&const_cast<CFileItemList&>(((CGUIMediaWindow*)window)->CurrentDirectory()), LISTITEM_THUMB);
2677   }
2678   else if (info == CONTAINER_TVSHOWTHUMB)
2679   {
2680     CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2681     if (window)
2682       return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("tvshowthumb");
2683   }
2684   else if (info == CONTAINER_SEASONTHUMB)
2685   {
2686     CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2687     if (window)
2688       return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("seasonthumb");
2689   }
2690   else if (info == LISTITEM_THUMB || info == LISTITEM_ICON || info == LISTITEM_ACTUAL_ICON ||
2691           info == LISTITEM_OVERLAY || info == LISTITEM_RATING || info == LISTITEM_STAR_RATING)
2692   {
2693     CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
2694     if (window)
2695     {
2696       CFileItemPtr item = window->GetCurrentListItem();
2697       if (item)
2698         return GetItemImage(item.get(), info);
2699     }
2700   }
2701   return GetLabel(info, contextWindow);
2702 }
2703
2704 CStdString CGUIInfoManager::GetDate(bool bNumbersOnly)
2705 {
2706   CDateTime time=CDateTime::GetCurrentDateTime();
2707   return time.GetAsLocalizedDate(!bNumbersOnly);
2708 }
2709
2710 CStdString CGUIInfoManager::GetTime(TIME_FORMAT format) const
2711 {
2712   CDateTime time=CDateTime::GetCurrentDateTime();
2713   return LocalizeTime(time, format);
2714 }
2715
2716 CStdString CGUIInfoManager::GetLcdTime( int _eInfo ) const
2717 {
2718   CDateTime time=CDateTime::GetCurrentDateTime();
2719   CStdString strLcdTime;
2720
2721 #ifdef HAS_LCD
2722
2723   UINT       nCharset;
2724   UINT       nLine;
2725   CStdString strTimeMarker;
2726
2727   nCharset = 0;
2728   nLine = 0;
2729
2730   switch ( _eInfo )
2731   {
2732     case LCD_TIME_21:
2733       nCharset = 1; // CUSTOM_CHARSET_SMALLCHAR;
2734       nLine = 0;
2735       strTimeMarker = ".";
2736     break;
2737     case LCD_TIME_22:
2738       nCharset = 1; // CUSTOM_CHARSET_SMALLCHAR;
2739       nLine = 1;
2740       strTimeMarker = ".";
2741     break;
2742
2743     case LCD_TIME_W21:
2744       nCharset = 2; // CUSTOM_CHARSET_MEDIUMCHAR;
2745       nLine = 0;
2746       strTimeMarker = ".";
2747     break;
2748     case LCD_TIME_W22:
2749       nCharset = 2; // CUSTOM_CHARSET_MEDIUMCHAR;
2750       nLine = 1;
2751       strTimeMarker = ".";
2752     break;
2753
2754     case LCD_TIME_41:
2755       nCharset = 3; // CUSTOM_CHARSET_BIGCHAR;
2756       nLine = 0;
2757       strTimeMarker = " ";
2758     break;
2759     case LCD_TIME_42:
2760       nCharset = 3; // CUSTOM_CHARSET_BIGCHAR;
2761       nLine = 1;
2762       strTimeMarker = "o";
2763     break;
2764     case LCD_TIME_43:
2765       nCharset = 3; // CUSTOM_CHARSET_BIGCHAR;
2766       nLine = 2;
2767       strTimeMarker = "o";
2768     break;
2769     case LCD_TIME_44:
2770       nCharset = 3; // CUSTOM_CHARSET_BIGCHAR;
2771       nLine = 3;
2772       strTimeMarker = " ";
2773     break;
2774   }
2775
2776   strLcdTime += g_lcd->GetBigDigit( nCharset, time.GetHour()  , nLine, 2, 2, true );
2777   strLcdTime += strTimeMarker;
2778   strLcdTime += g_lcd->GetBigDigit( nCharset, time.GetMinute(), nLine, 2, 2, false );
2779   strLcdTime += strTimeMarker;
2780   strLcdTime += g_lcd->GetBigDigit( nCharset, time.GetSecond(), nLine, 2, 2, false );
2781
2782 #endif
2783
2784   return strLcdTime;
2785 }
2786
2787 CStdString CGUIInfoManager::LocalizeTime(const CDateTime &time, TIME_FORMAT format) const
2788 {
2789   const CStdString timeFormat = g_langInfo.GetTimeFormat();
2790   bool use12hourclock = timeFormat.Find('h') != -1;
2791   switch (format)
2792   {
2793   case TIME_FORMAT_GUESS:
2794     return time.GetAsLocalizedTime("", false);
2795   case TIME_FORMAT_SS:
2796     return time.GetAsLocalizedTime("ss", true);
2797   case TIME_FORMAT_MM:
2798     return time.GetAsLocalizedTime("mm", true);
2799   case TIME_FORMAT_MM_SS:
2800     return time.GetAsLocalizedTime("mm:ss", true);
2801   case TIME_FORMAT_HH:  // this forces it to a 12 hour clock
2802     return time.GetAsLocalizedTime(use12hourclock ? "h" : "HH", false);
2803   case TIME_FORMAT_HH_MM:
2804     return time.GetAsLocalizedTime(use12hourclock ? "h:mm" : "HH:mm", false);
2805   case TIME_FORMAT_HH_MM_XX:
2806       return time.GetAsLocalizedTime(use12hourclock ? "h:mm xx" : "HH:mm", false);      
2807   case TIME_FORMAT_HH_MM_SS:
2808     return time.GetAsLocalizedTime("", true);
2809   default:
2810     break;
2811   }
2812   return time.GetAsLocalizedTime("", false);
2813 }
2814
2815 CStdString CGUIInfoManager::GetDuration(TIME_FORMAT format) const
2816 {
2817   if (g_application.IsPlayingAudio() && m_currentFile->HasMusicInfoTag())
2818   {
2819     const CMusicInfoTag& tag = *m_currentFile->GetMusicInfoTag();
2820     if (tag.GetDuration() > 0)
2821       return StringUtils::SecondsToTimeString(tag.GetDuration(), format);
2822   }
2823   if (g_application.IsPlayingVideo() && !m_currentMovieDuration.IsEmpty())
2824     return m_currentMovieDuration;  // for tuxbox
2825   unsigned int iTotal = (unsigned int)g_application.GetTotalTime();
2826   if (iTotal > 0)
2827     return StringUtils::SecondsToTimeString(iTotal, format);
2828   return "";
2829 }
2830
2831 CStdString CGUIInfoManager::GetMusicPartyModeLabel(int item)
2832 {
2833   // get song counts
2834   if (item >= MUSICPM_SONGSPLAYED && item <= MUSICPM_RANDOMSONGSPICKED)
2835   {
2836     int iSongs = -1;
2837     switch (item)
2838     {
2839     case MUSICPM_SONGSPLAYED:
2840       {
2841         iSongs = g_partyModeManager.GetSongsPlayed();
2842         break;
2843       }
2844     case MUSICPM_MATCHINGSONGS:
2845       {
2846         iSongs = g_partyModeManager.GetMatchingSongs();
2847         break;
2848       }
2849     case MUSICPM_MATCHINGSONGSPICKED:
2850       {
2851         iSongs = g_partyModeManager.GetMatchingSongsPicked();
2852         break;
2853       }
2854     case MUSICPM_MATCHINGSONGSLEFT:
2855       {
2856         iSongs = g_partyModeManager.GetMatchingSongsLeft();
2857         break;
2858       }
2859     case MUSICPM_RELAXEDSONGSPICKED:
2860       {
2861         iSongs = g_partyModeManager.GetRelaxedSongs();
2862         break;
2863       }
2864     case MUSICPM_RANDOMSONGSPICKED:
2865       {
2866         iSongs = g_partyModeManager.GetRandomSongs();
2867         break;
2868       }
2869     }
2870     if (iSongs < 0)
2871       return "";
2872     CStdString strLabel;
2873     strLabel.Format("%i", iSongs);
2874     return strLabel;
2875   }
2876   return "";
2877 }
2878
2879 const CStdString CGUIInfoManager::GetMusicPlaylistInfo(const GUIInfo& info) const
2880 {
2881   PLAYLIST::CPlayList& playlist = g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC);
2882   if (playlist.size() < 1)
2883     return "";
2884   int index = info.GetData2();
2885   if (info.GetData1() == 1)
2886   { // relative index (requires current playlist is PLAYLIST_MUSIC)
2887     if (g_playlistPlayer.GetCurrentPlaylist() != PLAYLIST_MUSIC)
2888       return "";
2889     index = g_playlistPlayer.GetNextSong(index);
2890   }
2891   if (index < 0 || index >= playlist.size())
2892     return "";
2893   CFileItemPtr playlistItem = playlist[index];
2894   if (!playlistItem->GetMusicInfoTag()->Loaded())
2895   {
2896     playlistItem->LoadMusicTag();
2897     playlistItem->GetMusicInfoTag()->SetLoaded();
2898   }
2899   // try to set a thumbnail
2900   if (!playlistItem->HasThumbnail())
2901   {
2902     playlistItem->SetMusicThumb();
2903     // still no thumb? then just the set the default cover
2904     if (!playlistItem->HasThumbnail())
2905       playlistItem->SetThumbnailImage("DefaultAlbumCover.png");
2906   }
2907   if (info.m_info == MUSICPLAYER_PLAYLISTPOS)
2908   {
2909     CStdString strPosition = "";
2910     strPosition.Format("%i", index + 1);
2911     return strPosition;
2912   }
2913   else if (info.m_info == MUSICPLAYER_COVER)
2914     return playlistItem->GetThumbnailImage();
2915   return GetMusicTagLabel(info.m_info, playlistItem.get());
2916 }
2917
2918 CStdString CGUIInfoManager::GetPlaylistLabel(int item) const
2919 {
2920   if (!g_application.IsPlaying()) return "";
2921   int iPlaylist = g_playlistPlayer.GetCurrentPlaylist();
2922   switch (item)
2923   {
2924   case PLAYLIST_LENGTH:
2925     {
2926       CStdString strLength = "";
2927       strLength.Format("%i", g_playlistPlayer.GetPlaylist(iPlaylist).size());
2928       return strLength;
2929     }
2930   case PLAYLIST_POSITION:
2931     {
2932       CStdString strPosition = "";
2933       strPosition.Format("%i", g_playlistPlayer.GetCurrentSong() + 1);
2934       return strPosition;
2935     }
2936   case PLAYLIST_RANDOM:
2937     {
2938       if (g_playlistPlayer.IsShuffled(iPlaylist))
2939         return g_localizeStrings.Get(590); // 590: Random
2940       else
2941         return g_localizeStrings.Get(591); // 591: Off
2942     }
2943   case PLAYLIST_REPEAT:
2944     {
2945       PLAYLIST::REPEAT_STATE state = g_playlistPlayer.GetRepeat(iPlaylist);
2946       if (state == PLAYLIST::REPEAT_ONE)
2947         return g_localizeStrings.Get(592); // 592: One
2948       else if (state == PLAYLIST::REPEAT_ALL)
2949         return g_localizeStrings.Get(593); // 593: All
2950       else
2951         return g_localizeStrings.Get(594); // 594: Off
2952     }
2953   }
2954   return "";
2955 }
2956
2957 CStdString CGUIInfoManager::GetMusicLabel(int item)
2958 {
2959   if (!g_application.IsPlayingAudio() || !m_currentFile->HasMusicInfoTag()) return "";
2960   switch (item)
2961   {
2962   case MUSICPLAYER_PLAYLISTLEN:
2963     {
2964       if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2965         return GetPlaylistLabel(PLAYLIST_LENGTH);
2966     }
2967     break;
2968   case MUSICPLAYER_PLAYLISTPOS:
2969     {
2970       if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2971         return GetPlaylistLabel(PLAYLIST_POSITION);
2972     }
2973     break;
2974   case MUSICPLAYER_BITRATE:
2975     {
2976       float fTimeSpan = (float)(CTimeUtils::GetFrameTime() - m_lastMusicBitrateTime);
2977       if (fTimeSpan >= 500.0f)
2978       {
2979         m_MusicBitrate = g_application.m_pPlayer->GetAudioBitrate();
2980         m_lastMusicBitrateTime = CTimeUtils::GetFrameTime();
2981       }
2982       CStdString strBitrate = "";
2983       if (m_MusicBitrate > 0)
2984         strBitrate.Format("%i", MathUtils::round_int((double)m_MusicBitrate / 1000.0));
2985       return strBitrate;
2986     }
2987     break;
2988   case MUSICPLAYER_CHANNELS:
2989     {
2990       CStdString strChannels = "";
2991       if (g_application.m_pPlayer->GetChannels() > 0)
2992       {
2993         strChannels.Format("%i", g_application.m_pPlayer->GetChannels());
2994       }
2995       return strChannels;
2996     }
2997     break;
2998   case MUSICPLAYER_BITSPERSAMPLE:
2999     {
3000       CStdString strBitsPerSample = "";
3001       if (g_application.m_pPlayer->GetBitsPerSample() > 0)
3002       {
3003         strBitsPerSample.Format("%i", g_application.m_pPlayer->GetBitsPerSample());
3004       }
3005       return strBitsPerSample;
3006     }
3007     break;
3008   case MUSICPLAYER_SAMPLERATE:
3009     {
3010       CStdString strSampleRate = "";
3011       if (g_application.m_pPlayer->GetSampleRate() > 0)
3012       {
3013         strSampleRate.Format("%i",g_application.m_pPlayer->GetSampleRate());
3014       }
3015       return strSampleRate;
3016     }
3017     break;
3018   case MUSICPLAYER_CODEC:
3019     {
3020       CStdString strCodec;
3021       strCodec.Format("%s", g_application.m_pPlayer->GetAudioCodecName().c_str());
3022       return strCodec;
3023     }
3024     break;
3025   case MUSICPLAYER_LYRICS:
3026     return GetItemLabel(m_currentFile, AddListItemProp("lyrics"));
3027   }
3028   return GetMusicTagLabel(item, m_currentFile);
3029 }
3030
3031 CStdString CGUIInfoManager::GetMusicTagLabel(int info, const CFileItem *item) const
3032 {
3033   if (!item->HasMusicInfoTag()) return "";
3034   const CMusicInfoTag &tag = *item->GetMusicInfoTag();
3035   switch (info)
3036   {
3037   case MUSICPLAYER_TITLE:
3038     if (tag.GetTitle().size()) { return tag.GetTitle(); }
3039     break;
3040   case MUSICPLAYER_ALBUM:
3041     if (tag.GetAlbum().size()) { return tag.GetAlbum(); }
3042     break;
3043   case MUSICPLAYER_ARTIST:
3044     if (tag.GetArtist().size()) { return tag.GetArtist(); }
3045     break;
3046   case MUSICPLAYER_ALBUM_ARTIST:
3047     if (tag.GetAlbumArtist().size()) { return tag.GetAlbumArtist(); }
3048     break;
3049   case MUSICPLAYER_YEAR:
3050     if (tag.GetYear()) { return tag.GetYearString(); }
3051     break;
3052   case MUSICPLAYER_GENRE:
3053     if (tag.GetGenre().size()) { return tag.GetGenre(); }
3054     break;
3055   case MUSICPLAYER_LYRICS: 
3056     if (tag.GetLyrics().size()) { return tag.GetLyrics(); } 
3057         break;
3058   case MUSICPLAYER_TRACK_NUMBER:
3059     {
3060       CStdString strTrack;
3061       if (tag.Loaded() && tag.GetTrackNumber() > 0)
3062       {
3063         strTrack.Format("%02i", tag.GetTrackNumber());
3064         return strTrack;
3065       }
3066     }
3067     break;
3068   case MUSICPLAYER_DISC_NUMBER:
3069     {
3070       CStdString strDisc;
3071       if (tag.Loaded() && tag.GetDiscNumber() > 0)
3072       {
3073         strDisc.Format("%02i", tag.GetDiscNumber());
3074         return strDisc;
3075       }
3076     }
3077     break;
3078   case MUSICPLAYER_RATING:
3079     return GetItemLabel(item, LISTITEM_RATING);
3080   case MUSICPLAYER_COMMENT:
3081     return GetItemLabel(item, LISTITEM_COMMENT);
3082   case MUSICPLAYER_DURATION:
3083     return GetItemLabel(item, LISTITEM_DURATION);
3084   case MUSICPLAYER_PLAYCOUNT:
3085     return GetItemLabel(item, LISTITEM_PLAYCOUNT);
3086   case MUSICPLAYER_LASTPLAYED:
3087     return GetItemLabel(item, LISTITEM_LASTPLAYED);
3088   }
3089   return "";
3090 }
3091
3092 CStdString CGUIInfoManager::GetVideoLabel(int item)
3093 {
3094   if (!g_application.IsPlayingVideo())
3095     return "";
3096
3097   if (item == VIDEOPLAYER_TITLE)
3098   {
3099     if (m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->m_strTitle.IsEmpty())
3100       return m_currentFile->GetVideoInfoTag()->m_strTitle;
3101     // don't have the title, so use dvdplayer, label, or drop down to title from path
3102     if (!g_application.m_pPlayer->GetPlayingTitle().IsEmpty())
3103       return g_application.m_pPlayer->GetPlayingTitle();
3104     if (!m_currentFile->GetLabel().IsEmpty())
3105       return m_currentFile->GetLabel();
3106     return CUtil::GetTitleFromPath(m_currentFile->m_strPath);
3107   }
3108   else if (item == VIDEOPLAYER_PLAYLISTLEN)
3109   {
3110     if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_VIDEO)
3111       return GetPlaylistLabel(PLAYLIST_LENGTH);
3112   }
3113   else if (item == VIDEOPLAYER_PLAYLISTPOS)
3114   {
3115     if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_VIDEO)
3116       return GetPlaylistLabel(PLAYLIST_POSITION);
3117   }
3118   else if (m_currentFile->HasVideoInfoTag())
3119   {
3120     switch (item)
3121     {
3122     case VIDEOPLAYER_ORIGINALTITLE:
3123       return m_currentFile->GetVideoInfoTag()->m_strOriginalTitle;
3124       break;
3125     case VIDEOPLAYER_GENRE:
3126       return m_currentFile->GetVideoInfoTag()->m_strGenre;
3127       break;
3128     case VIDEOPLAYER_DIRECTOR:
3129       return m_currentFile->GetVideoInfoTag()->m_strDirector;
3130       break;
3131     case VIDEOPLAYER_RATING:
3132       {
3133         CStdString strRating;
3134         if (m_currentFile->GetVideoInfoTag()->m_fRating > 0.f)
3135           strRating.Format("%.1f", m_currentFile->GetVideoInfoTag()->m_fRating);
3136         return strRating;
3137       }
3138       break;
3139     case VIDEOPLAYER_RATING_AND_VOTES:
3140       {
3141         CStdString strRatingAndVotes;
3142         if (m_currentFile->GetVideoInfoTag()->m_fRating > 0.f)
3143         {
3144           if (m_currentFile->GetVideoInfoTag()->m_strVotes.IsEmpty())
3145             strRatingAndVotes.Format("%.1f", m_currentFile->GetVideoInfoTag()->m_fRating);
3146           else
3147             strRatingAndVotes.Format("%.1f (%s %s)", m_currentFile->GetVideoInfoTag()->m_fRating, m_currentFile->GetVideoInfoTag()->m_strVotes, g_localizeStrings.Get(20350));
3148         }
3149         return strRatingAndVotes;
3150       }
3151       break;
3152     case VIDEOPLAYER_YEAR:
3153       {
3154         CStdString strYear;
3155         if (m_currentFile->GetVideoInfoTag()->m_iYear > 0)
3156           strYear.Format("%i", m_currentFile->GetVideoInfoTag()->m_iYear);
3157         return strYear;
3158       }
3159       break;
3160     case VIDEOPLAYER_PREMIERED:
3161       {
3162         if (!m_currentFile->GetVideoInfoTag()->m_strFirstAired.IsEmpty())
3163           return m_currentFile->GetVideoInfoTag()->m_strFirstAired;
3164         if (!m_currentFile->GetVideoInfoTag()->m_strPremiered.IsEmpty())
3165           return m_currentFile->GetVideoInfoTag()->m_strPremiered;
3166       }
3167       break;
3168     case VIDEOPLAYER_PLOT:
3169       return m_currentFile->GetVideoInfoTag()->m_strPlot;
3170     case VIDEOPLAYER_TRAILER:
3171       return m_currentFile->GetVideoInfoTag()->m_strTrailer;
3172     case VIDEOPLAYER_PLOT_OUTLINE:
3173       return m_currentFile->GetVideoInfoTag()->m_strPlotOutline;
3174     case VIDEOPLAYER_EPISODE:
3175       {
3176         CStdString strYear;
3177         if (m_currentFile->GetVideoInfoTag()->m_iSpecialSortEpisode > 0)
3178           strYear.Format("S%i", m_currentFile->GetVideoInfoTag()->m_iEpisode);
3179         else if(m_currentFile->GetVideoInfoTag()->m_iEpisode > 0) 
3180           strYear.Format("%i", m_currentFile->GetVideoInfoTag()->m_iEpisode);
3181         return strYear;
3182       }
3183       break;
3184     case VIDEOPLAYER_SEASON:
3185       {
3186         CStdString strYear;
3187         if (m_currentFile->GetVideoInfoTag()->m_iSpecialSortSeason > 0)
3188           strYear.Format("%i", m_currentFile->GetVideoInfoTag()->m_iSpecialSortSeason);
3189         else if(m_currentFile->GetVideoInfoTag()->m_iSeason > 0)
3190           strYear.Format("%i", m_currentFile->GetVideoInfoTag()->m_iSeason);
3191         return strYear;
3192       }
3193       break;
3194     case VIDEOPLAYER_TVSHOW:
3195       return m_currentFile->GetVideoInfoTag()->m_strShowTitle;
3196
3197     case VIDEOPLAYER_STUDIO:
3198       return m_currentFile->GetVideoInfoTag()->m_strStudio;
3199     case VIDEOPLAYER_COUNTRY:
3200       return m_currentFile->GetVideoInfoTag()->m_strCountry;
3201     case VIDEOPLAYER_MPAA:
3202       return m_currentFile->GetVideoInfoTag()->m_strMPAARating;
3203     case VIDEOPLAYER_TOP250:
3204       {
3205         CStdString strTop250;
3206         if (m_currentFile->GetVideoInfoTag()->m_iTop250 > 0)
3207           strTop250.Format("%i", m_currentFile->GetVideoInfoTag()->m_iTop250);
3208         return strTop250;
3209       }
3210       break;
3211     case VIDEOPLAYER_CAST:
3212       return m_currentFile->GetVideoInfoTag()->GetCast();
3213     case VIDEOPLAYER_CAST_AND_ROLE:
3214       return m_currentFile->GetVideoInfoTag()->GetCast(true);
3215     case VIDEOPLAYER_ARTIST:
3216       return m_currentFile->GetVideoInfoTag()->m_strArtist;
3217     case VIDEOPLAYER_ALBUM:
3218       return m_currentFile->GetVideoInfoTag()->m_strAlbum;
3219     case VIDEOPLAYER_WRITER:
3220       return m_currentFile->GetVideoInfoTag()->m_strWritingCredits;
3221     case VIDEOPLAYER_TAGLINE:
3222       return m_currentFile->GetVideoInfoTag()->m_strTagLine;
3223     case VIDEOPLAYER_LASTPLAYED:
3224       return m_currentFile->GetVideoInfoTag()->m_lastPlayed;
3225     case VIDEOPLAYER_PLAYCOUNT:
3226       {
3227         CStdString strPlayCount;
3228         if (m_currentFile->GetVideoInfoTag()->m_playCount > 0)
3229           strPlayCount.Format("%i", m_currentFile->GetVideoInfoTag()->m_playCount);
3230         return strPlayCount;
3231       }
3232     }
3233   }
3234   return "";
3235 }
3236
3237 __int64 CGUIInfoManager::GetPlayTime() const
3238 {
3239   if (g_application.IsPlaying())
3240   {
3241     __int64 lPTS = (__int64)(g_application.GetTime() * 1000);
3242     if (lPTS < 0) lPTS = 0;
3243     return lPTS;
3244   }
3245   return 0;
3246 }
3247
3248 CStdString CGUIInfoManager::GetCurrentPlayTime(TIME_FORMAT format) const
3249 {
3250   if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
3251     format = TIME_FORMAT_HH_MM_SS;
3252   if (g_application.IsPlayingAudio() || g_application.IsPlayingVideo())
3253     return StringUtils::SecondsToTimeString((int)(GetPlayTime()/1000), format);
3254   return "";
3255 }
3256
3257 int CGUIInfoManager::GetTotalPlayTime() const
3258 {
3259   int iTotalTime = (int)g_application.GetTotalTime();
3260   return iTotalTime > 0 ? iTotalTime : 0;
3261 }
3262
3263 int CGUIInfoManager::GetPlayTimeRemaining() const
3264 {
3265   int iReverse = GetTotalPlayTime() - (int)g_application.GetTime();
3266   return iReverse > 0 ? iReverse : 0;
3267 }
3268
3269 CStdString CGUIInfoManager::GetCurrentPlayTimeRemaining(TIME_FORMAT format) const
3270 {
3271   if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
3272     format = TIME_FORMAT_HH_MM_SS;
3273   int timeRemaining = GetPlayTimeRemaining();
3274   if (timeRemaining && (g_application.IsPlayingAudio() || g_application.IsPlayingVideo()))
3275     return StringUtils::SecondsToTimeString(timeRemaining, format);
3276   return "";
3277 }
3278
3279 void CGUIInfoManager::ResetCurrentItem()
3280 {
3281   m_currentFile->Reset();
3282   m_currentMovieThumb = "";
3283   m_currentMovieDuration = "";
3284 }
3285
3286 void CGUIInfoManager::SetCurrentItem(CFileItem &item)
3287 {
3288   ResetCurrentItem();
3289
3290   if (item.IsAudio())
3291     SetCurrentSong(item);
3292   else
3293     SetCurrentMovie(item);
3294 }
3295
3296 void CGUIInfoManager::SetCurrentAlbumThumb(const CStdString thumbFileName)
3297 {
3298   if (CFile::Exists(thumbFileName))
3299     m_currentFile->SetThumbnailImage(thumbFileName);
3300   else
3301   {
3302     m_currentFile->SetThumbnailImage("");
3303     m_currentFile->FillInDefaultIcon();
3304   }
3305 }
3306
3307 void CGUIInfoManager::SetCurrentSong(CFileItem &item)
3308 {
3309   CLog::Log(LOGDEBUG,"CGUIInfoManager::SetCurrentSong(%s)",item.m_strPath.c_str());
3310   *m_currentFile = item;
3311
3312   m_currentFile->LoadMusicTag();
3313   if (m_currentFile->GetMusicInfoTag()->GetTitle().IsEmpty())
3314   {
3315     // No title in tag, show filename only
3316     m_currentFile->GetMusicInfoTag()->SetTitle(CUtil::GetTitleFromPath(m_currentFile->m_strPath));
3317   }
3318   m_currentFile->GetMusicInfoTag()->SetLoaded(true);
3319
3320   // find a thumb for this file.
3321   if (m_currentFile->IsInternetStream())
3322   {
3323     if (!g_application.m_strPlayListFile.IsEmpty())
3324     {
3325       CLog::Log(LOGDEBUG,"Streaming media detected... using %s to find a thumb", g_application.m_strPlayListFile.c_str());
3326       CFileItem streamingItem(g_application.m_strPlayListFile,false);
3327       streamingItem.SetMusicThumb();
3328       CStdString strThumb = streamingItem.GetThumbnailImage();
3329       if (CFile::Exists(strThumb))
3330         m_currentFile->SetThumbnailImage(strThumb);
3331     }
3332   }
3333   else
3334     m_currentFile->SetMusicThumb();
3335   m_currentFile->FillInDefaultIcon();
3336
3337   CMusicInfoLoader::LoadAdditionalTagInfo(m_currentFile);
3338 }
3339
3340 void CGUIInfoManager::SetCurrentMovie(CFileItem &item)
3341 {
3342   CLog::Log(LOGDEBUG,"CGUIInfoManager::SetCurrentMovie(%s)",item.m_strPath.c_str());
3343   *m_currentFile = item;
3344
3345   CVideoDatabase dbs;
3346   dbs.Open();
3347   if (dbs.HasMovieInfo(item.m_strPath))
3348   {
3349     dbs.GetMovieInfo(item.m_strPath, *m_currentFile->GetVideoInfoTag());
3350     CLog::Log(LOGDEBUG,"%s, got movie info!", __FUNCTION__);
3351     CLog::Log(LOGDEBUG,"  Title = %s", m_currentFile->GetVideoInfoTag()->m_strTitle.c_str());
3352   }
3353   else if (dbs.HasEpisodeInfo(item.m_strPath))
3354   {
3355     dbs.GetEpisodeInfo(item.m_strPath, *m_currentFile->GetVideoInfoTag());
3356     CLog::Log(LOGDEBUG,"%s, got episode info!", __FUNCTION__);
3357     CLog::Log(LOGDEBUG,"  Title = %s", m_currentFile->GetVideoInfoTag()->m_strTitle.c_str());
3358   }
3359   else if (dbs.HasMusicVideoInfo(item.m_strPath))
3360   {
3361     dbs.GetMusicVideoInfo(item.m_strPath, *m_currentFile->GetVideoInfoTag());
3362     CLog::Log(LOGDEBUG,"%s, got music video info!", __FUNCTION__);
3363     CLog::Log(LOGDEBUG,"  Title = %s", m_currentFile->GetVideoInfoTag()->m_strTitle.c_str());
3364   }
3365   dbs.Close();
3366
3367   // Find a thumb for this file.
3368   item.SetVideoThumb();
3369   if (!item.HasThumbnail())
3370   {
3371     CStdString strPath, strFileName;
3372     URIUtils::Split(item.GetCachedVideoThumb(), strPath, strFileName);
3373
3374     // create unique thumb for auto generated thumbs
3375     CStdString cachedThumb = strPath + "auto-" + strFileName;
3376     if (CFile::Exists(cachedThumb))
3377       item.SetThumbnailImage(cachedThumb);
3378   }
3379
3380   // find a thumb for this stream
3381   if (item.IsInternetStream())
3382   {
3383     // case where .strm is used to start an audio stream
3384     if (g_application.IsPlayingAudio())
3385     {
3386       SetCurrentSong(item);
3387       return;
3388     }
3389
3390     // else its a video
3391     if (!g_application.m_strPlayListFile.IsEmpty())
3392     {
3393       CLog::Log(LOGDEBUG,"Streaming media detected... using %s to find a thumb", g_application.m_strPlayListFile.c_str());
3394       CFileItem thumbItem(g_application.m_strPlayListFile,false);
3395       thumbItem.SetVideoThumb();
3396       if (thumbItem.HasThumbnail())
3397         item.SetThumbnailImage(thumbItem.GetThumbnailImage());
3398     }
3399   }
3400
3401   item.FillInDefaultIcon();
3402   m_currentMovieThumb = item.GetThumbnailImage();
3403 }
3404
3405 string CGUIInfoManager::GetSystemHeatInfo(int info)
3406 {
3407   if (CTimeUtils::GetFrameTime() - m_lastSysHeatInfoTime >= SYSHEATUPDATEINTERVAL)
3408   { // update our variables
3409     m_lastSysHeatInfoTime = CTimeUtils::GetFrameTime();
3410 #if defined(_LINUX)
3411     m_cpuTemp = g_cpuInfo.getTemperature();
3412     m_gpuTemp = GetGPUTemperature();
3413 #endif
3414   }
3415
3416   CStdString text;
3417   switch(info)
3418   {
3419     case LCD_CPU_TEMPERATURE:
3420     case SYSTEM_CPU_TEMPERATURE:
3421       return m_cpuTemp.IsValid() ? m_cpuTemp.ToString() : "?";
3422       break;
3423     case LCD_GPU_TEMPERATURE:
3424     case SYSTEM_GPU_TEMPERATURE:
3425       return m_gpuTemp.IsValid() ? m_gpuTemp.ToString() : "?";
3426       break;
3427     case LCD_FAN_SPEED:
3428     case SYSTEM_FAN_SPEED:
3429       text.Format("%i%%", m_fanSpeed * 2);
3430       break;
3431     case SYSTEM_CPU_USAGE:
3432 #if defined(__APPLE__) || defined(_WIN32)
3433       text.Format("%d%%", g_cpuInfo.getUsedPercentage());
3434 #else
3435       text.Format("%s", g_cpuInfo.GetCoresUsageString());
3436 #endif
3437       break;
3438   }
3439   return text;
3440 }
3441
3442 CTemperature CGUIInfoManager::GetGPUTemperature()
3443 {
3444   CStdString  cmd   = g_advancedSettings.m_gpuTempCmd;
3445   int         value = 0,
3446               ret   = 0;
3447   char        scale = 0;
3448   FILE        *p    = NULL;
3449
3450   if (cmd.IsEmpty() || !(p = popen(cmd.c_str(), "r")))
3451     return CTemperature();
3452
3453   ret = fscanf(p, "%d %c", &value, &scale);
3454   pclose(p);
3455
3456   if (ret != 2)
3457     return CTemperature();
3458
3459   if (scale == 'C' || scale == 'c')
3460     return CTemperature::CreateFromCelsius(value);
3461   if (scale == 'F' || scale == 'f')
3462     return CTemperature::CreateFromFahrenheit(value);
3463   return CTemperature();
3464 }
3465
3466 CStdString CGUIInfoManager::GetVersion()
3467 {
3468   CStdString tmp;
3469 #ifdef GIT_REV
3470   tmp.Format("%s Git:%s", VERSION_STRING, GIT_REV);
3471 #else
3472   tmp.Format("%s", VERSION_STRING);
3473 #endif
3474   return tmp;
3475 }
3476
3477 CStdString CGUIInfoManager::GetBuild()
3478 {
3479   CStdString tmp;
3480   tmp.Format("%s", __DATE__);
3481   return tmp;
3482 }
3483
3484 void CGUIInfoManager::SetDisplayAfterSeek(unsigned int timeOut, int seekOffset)
3485 {
3486   if (timeOut>0)
3487   {
3488     m_AfterSeekTimeout = CTimeUtils::GetFrameTime() +  timeOut;
3489     if (seekOffset)
3490       m_seekOffset = seekOffset;
3491   }
3492   else
3493     m_AfterSeekTimeout = 0;
3494 }
3495
3496 bool CGUIInfoManager::GetDisplayAfterSeek()
3497 {
3498   if (CTimeUtils::GetFrameTime() < m_AfterSeekTimeout)
3499     return true;
3500   m_seekOffset = 0;
3501   return false;
3502 }
3503
3504 CStdString CGUIInfoManager::GetAudioScrobblerLabel(int item)
3505 {
3506   switch (item)
3507   {
3508   case AUDIOSCROBBLER_CONN_STATE:
3509     return CLastfmScrobbler::GetInstance()->GetConnectionState();
3510     break;
3511   case AUDIOSCROBBLER_SUBMIT_INT:
3512     return CLastfmScrobbler::GetInstance()->GetSubmitInterval();
3513     break;
3514   case AUDIOSCROBBLER_FILES_CACHED:
3515     return CLastfmScrobbler::GetInstance()->GetFilesCached();
3516     break;
3517   case AUDIOSCROBBLER_SUBMIT_STATE:
3518     return CLastfmScrobbler::GetInstance()->GetSubmitState();
3519     break;
3520   }
3521
3522   return "";
3523 }
3524
3525 int CGUIInfoManager::GetOperator(const char ch)
3526 {
3527   if (ch == '[')
3528     return 5;
3529   else if (ch == ']')
3530     return 4;
3531   else if (ch == '!')
3532     return OPERATOR_NOT;
3533   else if (ch == '+')
3534     return OPERATOR_AND;
3535   else if (ch == '|')
3536     return OPERATOR_OR;
3537   else
3538     return 0;
3539 }
3540
3541 bool CGUIInfoManager::EvaluateBooleanExpression(const CCombinedValue &expression, bool &result, int contextWindow, const CGUIListItem *item)
3542 {
3543   // stack to save our bool state as we go
3544   stack<bool> save;
3545
3546   for (list<int>::const_iterator it = expression.m_postfix.begin(); it != expression.m_postfix.end(); ++it)
3547   {
3548     int expr = *it;
3549     if (expr == -OPERATOR_NOT)
3550     { // NOT the top item on the stack
3551       if (save.size() < 1) return false;
3552       bool expr = save.top();
3553       save.pop();
3554       save.push(!expr);
3555     }
3556     else if (expr == -OPERATOR_AND)
3557     { // AND the top two items on the stack
3558       if (save.size() < 2) return false;
3559       bool right = save.top(); save.pop();
3560       bool left = save.top(); save.pop();
3561       save.push(left && right);
3562     }
3563     else if (expr == -OPERATOR_OR)
3564     { // OR the top two items on the stack
3565       if (save.size() < 2) return false;
3566       bool right = save.top(); save.pop();
3567       bool left = save.top(); save.pop();
3568       save.push(left || right);
3569     }
3570     else  // operator
3571       save.push(GetBool(expr, contextWindow, item));
3572   }
3573   if (save.size() != 1) return false;
3574   result = save.top();
3575   return true;
3576 }
3577
3578 int CGUIInfoManager::TranslateBooleanExpression(const CStdString &expression)
3579 {
3580   CCombinedValue comb;
3581   comb.m_info = expression;
3582   comb.m_id = COMBINED_VALUES_START + m_CombinedValues.size();
3583
3584   // operator stack
3585   stack<char> save;
3586
3587   CStdString operand;
3588
3589   for (unsigned int i = 0; i < expression.size(); i++)
3590   {
3591     if (GetOperator(expression[i]))
3592     {
3593       // cleanup any operand, translate and put into our expression list
3594       if (!operand.IsEmpty())
3595       {
3596         int iOp = TranslateSingleString(operand);
3597         if (iOp)
3598           comb.m_postfix.push_back(iOp);
3599         operand.clear();
3600       }
3601       // handle closing parenthesis
3602       if (expression[i] == ']')
3603       {
3604         while (save.size())
3605         {
3606           char oper = save.top();
3607           save.pop();
3608
3609           if (oper == '[')
3610             break;
3611
3612           comb.m_postfix.push_back(-GetOperator(oper));
3613         }
3614       }
3615       else
3616       {
3617         // all other operators we pop off the stack any operator
3618         // that has a higher priority than the one we have.
3619         while (!save.empty() && GetOperator(save.top()) > GetOperator(expression[i]))
3620         {
3621           // only handle parenthesis once they're closed.
3622           if (save.top() == '[' && expression[i] != ']')
3623             break;
3624
3625           comb.m_postfix.push_back(-GetOperator(save.top()));  // negative denotes operator
3626           save.pop();
3627         }
3628         save.push(expression[i]);
3629       }
3630     }
3631     else
3632     {
3633       operand += expression[i];
3634     }
3635   }
3636
3637   if (!operand.empty())
3638   {
3639     int op = TranslateSingleString(operand);
3640     if (op)
3641       comb.m_postfix.push_back(op);
3642   }
3643
3644   // finish up by adding any operators
3645   while (!save.empty())
3646   {
3647     comb.m_postfix.push_back(-GetOperator(save.top()));
3648     save.pop();
3649   }
3650
3651   // test evaluate
3652   bool test;
3653   if (!EvaluateBooleanExpression(comb, test, WINDOW_INVALID))
3654     CLog::Log(LOGERROR, "Error evaluating boolean expression %s", expression.c_str());
3655   // success - add to our combined values
3656   m_CombinedValues.push_back(comb);
3657   return comb.m_id;
3658 }
3659
3660 void CGUIInfoManager::Clear()
3661 {
3662   m_CombinedValues.clear();
3663 }
3664
3665 void CGUIInfoManager::UpdateFPS()
3666 {
3667   m_frameCounter++;
3668   unsigned int curTime = CTimeUtils::GetFrameTime();
3669
3670   float fTimeSpan = (float)(curTime - m_lastFPSTime);
3671   if (fTimeSpan >= 1000.0f)
3672   {
3673     fTimeSpan /= 1000.0f;
3674     m_fps = m_frameCounter / fTimeSpan;
3675     m_lastFPSTime = curTime;
3676     m_frameCounter = 0;
3677   }
3678 }
3679
3680 int CGUIInfoManager::AddListItemProp(const CStdString &str, int offset)
3681 {
3682   for (int i=0; i < (int)m_listitemProperties.size(); i++)
3683     if (m_listitemProperties[i] == str)
3684       return (LISTITEM_PROPERTY_START+offset + i);
3685
3686   if (m_listitemProperties.size() < LISTITEM_PROPERTY_END - LISTITEM_PROPERTY_START)
3687   {
3688     m_listitemProperties.push_back(str);
3689     return LISTITEM_PROPERTY_START + offset + m_listitemProperties.size() - 1;
3690   }
3691
3692   CLog::Log(LOGERROR,"%s - not enough listitem property space!", __FUNCTION__);
3693   return 0;
3694 }
3695
3696 int CGUIInfoManager::AddMultiInfo(const GUIInfo &info)
3697 {
3698   // check to see if we have this info already
3699   for (unsigned int i = 0; i < m_multiInfo.size(); i++)
3700     if (m_multiInfo[i] == info)
3701       return (int)i + MULTI_INFO_START;
3702   // return the new offset
3703   m_multiInfo.push_back(info);
3704   int id = (int)m_multiInfo.size() + MULTI_INFO_START - 1;
3705   if (id > MULTI_INFO_END)
3706     CLog::Log(LOGERROR, "%s - too many multiinfo bool/labels in this skin", __FUNCTION__);
3707   return id;
3708 }
3709
3710 int CGUIInfoManager::ConditionalStringParameter(const CStdString &parameter)
3711 {
3712   // check to see if we have this parameter already
3713   for (unsigned int i = 0; i < m_stringParameters.size(); i++)
3714     if (parameter.Equals(m_stringParameters[i]))
3715       return (int)i;
3716   // return the new offset
3717   m_stringParameters.push_back(parameter);
3718   return (int)m_stringParameters.size() - 1;
3719 }
3720
3721 CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info) const
3722 {
3723   if (!item) return "";
3724
3725   if (info >= LISTITEM_PROPERTY_START && info - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size())
3726   { // grab the property
3727     CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START];
3728     return item->GetProperty(property);
3729   }
3730
3731   switch (info)
3732   {
3733   case LISTITEM_LABEL:
3734     return item->GetLabel();
3735   case LISTITEM_LABEL2:
3736     return item->GetLabel2();
3737   case LISTITEM_TITLE:
3738     if (item->HasVideoInfoTag())
3739       return item->GetVideoInfoTag()->m_strTitle;
3740     if (item->HasMusicInfoTag())
3741       return item->GetMusicInfoTag()->GetTitle();
3742     break;
3743   case LISTITEM_ORIGINALTITLE:
3744     if (item->HasVideoInfoTag())
3745       return item->GetVideoInfoTag()->m_strOriginalTitle;
3746     break;
3747   case LISTITEM_PLAYCOUNT:
3748     {
3749       CStdString strPlayCount;
3750       if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_playCount > 0)
3751         strPlayCount.Format("%i", item->GetVideoInfoTag()->m_playCount);
3752       if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetPlayCount() > 0)
3753         strPlayCount.Format("%i", item->GetMusicInfoTag()->GetPlayCount());
3754       return strPlayCount;
3755     }
3756   case LISTITEM_LASTPLAYED:
3757     {
3758       CStdString strLastPlayed;
3759       if (item->HasVideoInfoTag())
3760         return item->GetVideoInfoTag()->m_lastPlayed;
3761       if (item->HasMusicInfoTag())
3762         return item->GetMusicInfoTag()->GetLastPlayed();
3763       break;
3764     }
3765   case LISTITEM_TRACKNUMBER:
3766     {
3767       CStdString track;
3768       if (item->HasMusicInfoTag())
3769         track.Format("%i", item->GetMusicInfoTag()->GetTrackNumber());
3770
3771       return track;
3772     }
3773   case LISTITEM_ARTIST:
3774     if (item->HasVideoInfoTag())
3775       return item->GetVideoInfoTag()->m_strArtist;
3776     if (item->HasMusicInfoTag())
3777       return item->GetMusicInfoTag()->GetArtist();
3778     break;
3779   case LISTITEM_ALBUM_ARTIST:
3780     if (item->HasMusicInfoTag())
3781       return item->GetMusicInfoTag()->GetAlbumArtist();
3782     break;
3783   case LISTITEM_DIRECTOR:
3784     if (item->HasVideoInfoTag())
3785       return item->GetVideoInfoTag()->m_strDirector;
3786   case LISTITEM_ALBUM:
3787     if (item->HasVideoInfoTag())
3788       return item->GetVideoInfoTag()->m_strAlbum;
3789     if (item->HasMusicInfoTag())
3790       return item->GetMusicInfoTag()->GetAlbum();
3791     break;
3792   case LISTITEM_YEAR:
3793     if (item->HasVideoInfoTag())
3794     {
3795       CStdString strResult;
3796       if (item->GetVideoInfoTag()->m_iYear > 0)
3797         strResult.Format("%i",item->GetVideoInfoTag()->m_iYear);
3798       return strResult;
3799     }
3800     if (item->HasMusicInfoTag())
3801       return item->GetMusicInfoTag()->GetYearString();
3802     break;
3803   case LISTITEM_PREMIERED:
3804     if (item->HasVideoInfoTag())
3805     {
3806       if (!item->GetVideoInfoTag()->m_strFirstAired.IsEmpty())
3807         return item->GetVideoInfoTag()->m_strFirstAired;
3808       if (!item->GetVideoInfoTag()->m_strPremiered.IsEmpty())
3809         return item->GetVideoInfoTag()->m_strPremiered;
3810     }
3811     break;
3812   case LISTITEM_GENRE:
3813     if (item->HasVideoInfoTag())
3814       return item->GetVideoInfoTag()->m_strGenre;
3815     if (item->HasMusicInfoTag())
3816       return item->GetMusicInfoTag()->GetGenre();
3817     break;
3818   case LISTITEM_FILENAME:
3819     if (item->IsMusicDb() && item->HasMusicInfoTag())
3820       return URIUtils::GetFileName(item->GetMusicInfoTag()->GetURL());
3821     if (item->IsVideoDb() && item->HasVideoInfoTag())
3822       return URIUtils::GetFileName(item->GetVideoInfoTag()->m_strFileNameAndPath);
3823     return URIUtils::GetFileName(item->m_strPath);
3824   case LISTITEM_DATE:
3825     if (item->m_dateTime.IsValid())
3826       return item->m_dateTime.GetAsLocalizedDate();
3827     break;
3828   case LISTITEM_SIZE:
3829     if (!item->m_bIsFolder || item->m_dwSize)
3830       return StringUtils::SizeToString(item->m_dwSize);
3831     break;
3832   case LISTITEM_RATING:
3833     {
3834       CStdString rating;
3835       if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_fRating > 0.f) // movie rating
3836         rating.Format("%.1f", item->GetVideoInfoTag()->m_fRating);
3837       else if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetRating() > '0')
3838       { // song rating.  Images will probably be better than numbers for this in the long run
3839         rating = item->GetMusicInfoTag()->GetRating();
3840       }
3841       return rating;
3842     }
3843   case LISTITEM_RATING_AND_VOTES:
3844     {
3845       if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_fRating > 0.f) // movie rating
3846       {
3847         CStdString strRatingAndVotes;
3848         if (item->GetVideoInfoTag()->m_strVotes.IsEmpty())
3849           strRatingAndVotes.Format("%.1f", item->GetVideoInfoTag()->m_fRating);
3850         else
3851           strRatingAndVotes.Format("%.1f (%s %s)", item->GetVideoInfoTag()->m_fRating, item->GetVideoInfoTag()->m_strVotes, g_localizeStrings.Get(20350));
3852         return strRatingAndVotes;
3853       }
3854     }
3855     break;
3856   case LISTITEM_PROGRAM_COUNT:
3857     {
3858       CStdString count;
3859       count.Format("%i", item->m_iprogramCount);
3860       return count;
3861     }
3862   case LISTITEM_DURATION:
3863     {
3864       CStdString duration;
3865       if (item->HasVideoInfoTag())
3866       {
3867         if (item->GetVideoInfoTag()->m_streamDetails.GetVideoDuration() > 0)
3868           duration.Format("%i", item->GetVideoInfoTag()->m_streamDetails.GetVideoDuration() / 60);
3869         else if (!item->GetVideoInfoTag()->m_strRuntime.IsEmpty())
3870           duration = item->GetVideoInfoTag()->m_strRuntime;
3871       }
3872       if (item->HasMusicInfoTag())
3873       {
3874         if (item->GetMusicInfoTag()->GetDuration() > 0)
3875           duration = StringUtils::SecondsToTimeString(item->GetMusicInfoTag()->GetDuration());
3876       }
3877       return duration;
3878     }
3879   case LISTITEM_PLOT:
3880     if (item->HasVideoInfoTag())
3881     {
3882       if (!(!item->GetVideoInfoTag()->m_strShowTitle.IsEmpty() && item->GetVideoInfoTag()->m_iSeason == -1)) // dont apply to tvshows
3883         if (item->GetVideoInfoTag()->m_playCount == 0 && !g_guiSettings.GetBool("videolibrary.showunwatchedplots"))
3884           return g_localizeStrings.Get(20370);
3885
3886       return item->GetVideoInfoTag()->m_strPlot;
3887     }
3888     break;
3889   case LISTITEM_PLOT_OUTLINE:
3890     if (item->HasVideoInfoTag())
3891       return item->GetVideoInfoTag()->m_strPlotOutline;
3892     break;
3893   case LISTITEM_EPISODE:
3894     if (item->HasVideoInfoTag())
3895     {
3896       CStdString strResult;
3897       if (item->GetVideoInfoTag()->m_iSpecialSortEpisode > 0)
3898         strResult.Format("S%d",item->GetVideoInfoTag()->m_iEpisode);
3899       else if (item->GetVideoInfoTag()->m_iEpisode > 0) // if m_iEpisode = -1 there's no episode detail
3900         strResult.Format("%d",item->GetVideoInfoTag()->m_iEpisode);
3901       return strResult;
3902     }
3903     break;
3904   case LISTITEM_SEASON:
3905     if (item->HasVideoInfoTag())
3906     {
3907       CStdString strResult;
3908       if (item->GetVideoInfoTag()->m_iSpecialSortSeason > 0)
3909         strResult.Format("%d",item->GetVideoInfoTag()->m_iSpecialSortSeason);
3910       else if (item->GetVideoInfoTag()->m_iSeason > 0) // if m_iSeason = -1 there's no season detail
3911         strResult.Format("%d",item->GetVideoInfoTag()->m_iSeason);
3912       return strResult;
3913     }
3914     break;
3915   case LISTITEM_TVSHOW:
3916     if (item->HasVideoInfoTag())
3917       return item->GetVideoInfoTag()->m_strShowTitle;
3918     break;
3919   case LISTITEM_COMMENT:
3920     if (item->HasMusicInfoTag())
3921       return item->GetMusicInfoTag()->GetComment();
3922     break;
3923   case LISTITEM_ACTUAL_ICON:
3924     return item->GetIconImage();
3925   case LISTITEM_ICON:
3926     {
3927       CStdString strThumb = item->GetThumbnailImage();
3928       if(!strThumb.IsEmpty() && !g_TextureManager.CanLoad(strThumb))
3929         strThumb = "";
3930
3931       if(strThumb.IsEmpty() && !item->GetIconImage().IsEmpty())
3932         strThumb = item->GetIconImage();
3933       return strThumb;
3934     }
3935   case LISTITEM_OVERLAY:
3936     return item->GetOverlayImage();
3937   case LISTITEM_THUMB:
3938     return item->GetThumbnailImage();
3939   case LISTITEM_FOLDERPATH:
3940     return CURL(item->m_strPath).GetWithoutUserDetails();
3941   case LISTITEM_FOLDERNAME:
3942   case LISTITEM_PATH:
3943     {
3944       CStdString path;
3945       if (item->IsMusicDb() && item->HasMusicInfoTag())
3946         URIUtils::GetDirectory(item->GetMusicInfoTag()->GetURL(), path);
3947       else if (item->IsVideoDb() && item->HasVideoInfoTag())
3948       {
3949         if( item->m_bIsFolder )
3950           path = item->GetVideoInfoTag()->m_strPath;
3951         else
3952           URIUtils::GetParentPath(item->GetVideoInfoTag()->m_strFileNameAndPath, path);
3953       }
3954       else
3955         URIUtils::GetParentPath(item->m_strPath, path);
3956       path = CURL(path).GetWithoutUserDetails();
3957       if (info==CONTAINER_FOLDERNAME)
3958       {
3959         URIUtils::RemoveSlashAtEnd(path);
3960         path=URIUtils::GetFileName(path);
3961       }
3962       CURL::Decode(path);
3963       return path;
3964     }
3965   case LISTITEM_FILENAME_AND_PATH:
3966     {
3967       CStdString path;
3968       if (item->IsMusicDb() && item->HasMusicInfoTag())
3969         path = item->GetMusicInfoTag()->GetURL();
3970       else if (item->IsVideoDb() && item->HasVideoInfoTag())
3971         path = item->GetVideoInfoTag()->m_strFileNameAndPath;
3972       else
3973         path = item->m_strPath;
3974       path = CURL(path).GetWithoutUserDetails();
3975       CURL::Decode(path);
3976       return path;
3977     }
3978   case LISTITEM_PICTURE_PATH:
3979     if (item->IsPicture() && (!item->IsZIP() || item->IsRAR() || item->IsCBZ() || item->IsCBR()))
3980       return item->m_strPath;
3981     break;
3982   case LISTITEM_PICTURE_DATETIME:
3983     if (item->HasPictureInfoTag())
3984       return item->GetPictureInfoTag()->GetInfo(SLIDE_EXIF_DATE_TIME);
3985     break;
3986   case LISTITEM_PICTURE_RESOLUTION:
3987     if (item->HasPictureInfoTag())
3988       return item->GetPictureInfoTag()->GetInfo(SLIDE_RESOLUTION);
3989     break;
3990   case LISTITEM_STUDIO:
3991     if (item->HasVideoInfoTag())
3992       return item->GetVideoInfoTag()->m_strStudio;
3993     break;
3994   case LISTITEM_COUNTRY:
3995     if (item->HasVideoInfoTag())
3996       return item->GetVideoInfoTag()->m_strCountry;
3997     break;
3998   case LISTITEM_MPAA:
3999     if (item->HasVideoInfoTag())
4000       return item->GetVideoInfoTag()->m_strMPAARating;
4001     break;
4002   case LISTITEM_CAST:
4003     if (item->HasVideoInfoTag())
4004       return item->GetVideoInfoTag()->GetCast();
4005     break;
4006   case LISTITEM_CAST_AND_ROLE:
4007     if (item->HasVideoInfoTag())
4008       return item->GetVideoInfoTag()->GetCast(true);
4009     break;
4010   case LISTITEM_WRITER:
4011     if (item->HasVideoInfoTag())
4012       return item->GetVideoInfoTag()->m_strWritingCredits;;
4013     break;
4014   case LISTITEM_TAGLINE:
4015     if (item->HasVideoInfoTag())
4016       return item->GetVideoInfoTag()->m_strTagLine;
4017     break;
4018   case LISTITEM_TRAILER:
4019     if (item->HasVideoInfoTag())
4020       return item->GetVideoInfoTag()->m_strTrailer;
4021     break;
4022   case LISTITEM_TOP250:
4023     if (item->HasVideoInfoTag())
4024     {
4025       CStdString strResult;
4026       if (item->GetVideoInfoTag()->m_iTop250 > 0)
4027         strResult.Format("%i",item->GetVideoInfoTag()->m_iTop250);
4028       return strResult;
4029     }
4030     break;
4031   case LISTITEM_SORT_LETTER:
4032     {
4033       CStdString letter;
4034       g_charsetConverter.wToUTF8(item->GetSortLabel().Left(1).ToUpper(), letter);
4035       return letter;
4036     }
4037     break;
4038   case LISTITEM_VIDEO_CODEC:
4039     if (item->HasVideoInfoTag())
4040       return item->GetVideoInfoTag()->m_streamDetails.GetVideoCodec();
4041     break;
4042   case LISTITEM_VIDEO_RESOLUTION:
4043     if (item->HasVideoInfoTag())
4044       return CStreamDetails::VideoDimsToResolutionDescription(item->GetVideoInfoTag()->m_streamDetails.GetVideoWidth(), item->GetVideoInfoTag()->m_streamDetails.GetVideoHeight());
4045     break;
4046   case LISTITEM_VIDEO_ASPECT:
4047     if (item->HasVideoInfoTag())
4048       return CStreamDetails::VideoAspectToAspectDescription(item->GetVideoInfoTag()->m_streamDetails.GetVideoAspect());
4049     break;
4050   case LISTITEM_AUDIO_CODEC:
4051     if (item->HasVideoInfoTag())
4052     {
4053       return item->GetVideoInfoTag()->m_streamDetails.GetAudioCodec();
4054     }
4055     break;
4056   case LISTITEM_AUDIO_CHANNELS:
4057     if (item->HasVideoInfoTag())
4058     {
4059       CStdString strResult;
4060       int iChannels = item->GetVideoInfoTag()->m_streamDetails.GetAudioChannels();
4061       if (iChannels > -1)
4062         strResult.Format("%i", iChannels);
4063       return strResult;
4064     }
4065     break;
4066   case LISTITEM_AUDIO_LANGUAGE:
4067     if (item->HasVideoInfoTag())
4068       return item->GetVideoInfoTag()->m_streamDetails.GetAudioLanguage();
4069     break;
4070   case LISTITEM_SUBTITLE_LANGUAGE:
4071     if (item->HasVideoInfoTag())
4072       return item->GetVideoInfoTag()->m_streamDetails.GetSubtitleLanguage();
4073     break;
4074   }
4075   return "";
4076 }
4077
4078 CStdString CGUIInfoManager::GetItemImage(const CFileItem *item, int info) const
4079 {
4080   switch (info)
4081   {
4082   case LISTITEM_RATING:  // old song rating format
4083     {
4084       CStdString rating;
4085       if (item->HasMusicInfoTag())
4086       {
4087         rating.Format("songrating%c.png", item->GetMusicInfoTag()->GetRating());
4088         return rating;
4089       }
4090     }
4091     break;
4092   case LISTITEM_STAR_RATING:
4093     {
4094       CStdString rating;
4095       if (item->HasVideoInfoTag())
4096       { // rating for videos is assumed 0..10, so convert to 0..5
4097         rating.Format("rating%d.png", (long)((item->GetVideoInfoTag()->m_fRating * 0.5f) + 0.5f));
4098       }
4099       else if (item->HasMusicInfoTag())
4100       { // song rating.
4101         rating.Format("rating%c.png", item->GetMusicInfoTag()->GetRating());
4102       }
4103       return rating;
4104     }
4105     break;
4106   }  /* switch (info) */
4107
4108   return GetItemLabel(item, info);
4109 }
4110
4111 bool CGUIInfoManager::GetItemBool(const CGUIListItem *item, int condition) const
4112 {
4113   if (!item) return false;
4114   if (condition >= LISTITEM_PROPERTY_START && condition - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size())
4115   { // grab the property
4116     CStdString property = m_listitemProperties[condition - LISTITEM_PROPERTY_START];
4117     CStdString val = item->GetProperty(property);
4118     return (val == "1" || val.CompareNoCase("true") == 0);
4119   }
4120   else if (condition == LISTITEM_ISPLAYING)
4121   {
4122     if (item->IsFileItem() && !m_currentFile->m_strPath.IsEmpty())
4123     {
4124       if (!g_application.m_strPlayListFile.IsEmpty())
4125       {
4126         //playlist file that is currently playing or the playlistitem that is currently playing.
4127         return g_application.m_strPlayListFile.Equals(((const CFileItem *)item)->m_strPath) || m_currentFile->IsSamePath((const CFileItem *)item);
4128       }
4129       return m_currentFile->IsSamePath((const CFileItem *)item);
4130     }
4131   }
4132   else if (condition == LISTITEM_ISSELECTED)
4133     return item->IsSelected();
4134   else if (condition == LISTITEM_IS_FOLDER)
4135     return item->m_bIsFolder;
4136   return false;
4137 }
4138
4139 void CGUIInfoManager::ResetCache()
4140 {
4141   CSingleLock lock(m_critInfo);
4142   m_boolCache.clear();
4143   // reset any animation triggers as well
4144   m_containerMoves.clear();
4145 }
4146
4147 void CGUIInfoManager::ResetPersistentCache()
4148 {
4149   CSingleLock lock(m_critInfo);
4150   m_persistentBoolCache.clear();
4151 }
4152
4153 inline void CGUIInfoManager::CacheBool(int condition, int contextWindow, bool result, bool persistent)
4154 {
4155   // windows have id's up to 13100 or thereabouts (ie 2^14 needed)
4156   // conditionals have id's up to 100000 or thereabouts (ie 2^18 needed)
4157   CSingleLock lock(m_critInfo);
4158   int hash = ((contextWindow & 0x3fff) << 18) | (condition & 0x3ffff);
4159   if (persistent)
4160     m_persistentBoolCache.insert(pair<int, bool>(hash, result));
4161   else
4162     m_boolCache.insert(pair<int, bool>(hash, result));
4163 }
4164
4165 bool CGUIInfoManager::IsCached(int condition, int contextWindow, bool &result) const
4166 {
4167   // windows have id's up to 13100 or thereabouts (ie 2^14 needed)
4168   // conditionals have id's up to 100000 or thereabouts (ie 2^18 needed)
4169
4170   CSingleLock lock(m_critInfo);
4171   int hash = ((contextWindow & 0x3fff) << 18) | (condition & 0x3ffff);
4172   map<int, bool>::const_iterator it = m_boolCache.find(hash);
4173   if (it != m_boolCache.end())
4174   {
4175     result = (*it).second;
4176     return true;
4177   }
4178   it = m_persistentBoolCache.find(hash);
4179   if (it != m_persistentBoolCache.end())
4180   {
4181     result = (*it).second;
4182     return true;
4183   }
4184
4185   return false;
4186 }
4187
4188 // Called from tuxbox service thread to update current status
4189 void CGUIInfoManager::UpdateFromTuxBox()
4190 {
4191   if(g_tuxbox.vVideoSubChannel.mode)
4192     m_currentFile->GetVideoInfoTag()->m_strTitle = g_tuxbox.vVideoSubChannel.current_name;
4193
4194   // Set m_currentMovieDuration
4195   if(!g_tuxbox.sCurSrvData.current_event_duration.IsEmpty() &&
4196     !g_tuxbox.sCurSrvData.next_event_description.IsEmpty() &&
4197     !g_tuxbox.sCurSrvData.current_event_duration.Equals("-") &&
4198     !g_tuxbox.sCurSrvData.next_event_description.Equals("-"))
4199   {
4200     g_tuxbox.sCurSrvData.current_event_duration.Replace("(","");
4201     g_tuxbox.sCurSrvData.current_event_duration.Replace(")","");
4202
4203     m_currentMovieDuration.Format("%s: %s %s (%s - %s)",
4204       g_localizeStrings.Get(180),
4205       g_tuxbox.sCurSrvData.current_event_duration,
4206       g_localizeStrings.Get(12391),
4207       g_tuxbox.sCurSrvData.current_event_time,
4208       g_tuxbox.sCurSrvData.next_event_time);
4209   }
4210
4211   //Set strVideoGenre
4212   if (!g_tuxbox.sCurSrvData.current_event_description.IsEmpty() &&
4213     !g_tuxbox.sCurSrvData.next_event_description.IsEmpty() &&
4214     !g_tuxbox.sCurSrvData.current_event_description.Equals("-") &&
4215     !g_tuxbox.sCurSrvData.next_event_description.Equals("-"))
4216   {
4217     m_currentFile->GetVideoInfoTag()->m_strGenre.Format("%s %s  -  (%s: %s)",
4218       g_localizeStrings.Get(143),
4219       g_tuxbox.sCurSrvData.current_event_description,
4220       g_localizeStrings.Get(209),
4221       g_tuxbox.sCurSrvData.next_event_description);
4222   }
4223
4224   //Set m_currentMovie.m_strDirector
4225   if (!g_tuxbox.sCurSrvData.current_event_details.Equals("-") &&
4226     !g_tuxbox.sCurSrvData.current_event_details.IsEmpty())
4227   {
4228     m_currentFile->GetVideoInfoTag()->m_strDirector = g_tuxbox.sCurSrvData.current_event_details;
4229   }
4230 }
4231
4232 CStdString CGUIInfoManager::GetPictureLabel(int info) const
4233 {
4234   if (info == SLIDE_FILE_NAME)
4235     return GetItemLabel(m_currentSlide, LISTITEM_FILENAME);
4236   else if (info == SLIDE_FILE_PATH)
4237   {
4238     CStdString path;
4239     URIUtils::GetDirectory(m_currentSlide->m_strPath, path);
4240     return CURL(path).GetWithoutUserDetails();
4241   }
4242   else if (info == SLIDE_FILE_SIZE)
4243     return GetItemLabel(m_currentSlide, LISTITEM_SIZE);
4244   else if (info == SLIDE_FILE_DATE)
4245     return GetItemLabel(m_currentSlide, LISTITEM_DATE);
4246   else if (info == SLIDE_INDEX)
4247   {
4248     CGUIWindowSlideShow *slideshow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
4249     if (slideshow && slideshow->NumSlides())
4250     {
4251       CStdString index;
4252       index.Format("%d/%d", slideshow->CurrentSlide(), slideshow->NumSlides());
4253       return index;
4254     }
4255   }
4256   if (m_currentSlide->HasPictureInfoTag())
4257     return m_currentSlide->GetPictureInfoTag()->GetInfo(info);
4258   return "";
4259 }
4260
4261 void CGUIInfoManager::SetCurrentSlide(CFileItem &item)
4262 {
4263   if (m_currentSlide->m_strPath != item.m_strPath)
4264   {
4265     if (!item.HasPictureInfoTag() && !item.GetPictureInfoTag()->Loaded())
4266       item.GetPictureInfoTag()->Load(item.m_strPath);
4267     *m_currentSlide = item;
4268   }
4269 }
4270
4271 void CGUIInfoManager::ResetCurrentSlide()
4272 {
4273   m_currentSlide->Reset();
4274 }
4275
4276 bool CGUIInfoManager::CheckWindowCondition(CGUIWindow *window, int condition) const
4277 {
4278   // check if it satisfies our condition
4279   if (!window) return false;
4280   if ((condition & WINDOW_CONDITION_HAS_LIST_ITEMS) && !window->HasListItems())
4281     return false;
4282   if ((condition & WINDOW_CONDITION_IS_MEDIA_WINDOW) && !window->IsMediaWindow())
4283     return false;
4284   return true;
4285 }
4286
4287 CGUIWindow *CGUIInfoManager::GetWindowWithCondition(int contextWindow, int condition) const
4288 {
4289   CGUIWindow *window = g_windowManager.GetWindow(contextWindow);
4290   if (CheckWindowCondition(window, condition))
4291     return window;
4292
4293   // try topmost dialog
4294   window = g_windowManager.GetWindow(g_windowManager.GetTopMostModalDialogID());
4295   if (CheckWindowCondition(window, condition))
4296     return window;
4297
4298   // try active window
4299   window = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
4300   if (CheckWindowCondition(window, condition))
4301     return window;
4302
4303   return NULL;
4304 }
4305
4306 void CGUIInfoManager::SetCurrentVideoTag(const CVideoInfoTag &tag)
4307 {
4308   *m_currentFile->GetVideoInfoTag() = tag;
4309   m_currentFile->m_lStartOffset = 0;
4310 }
4311
4312 void CGUIInfoManager::SetCurrentSongTag(const MUSIC_INFO::CMusicInfoTag &tag)
4313 {
4314   //CLog::Log(LOGDEBUG, "Asked to SetCurrentTag");
4315   *m_currentFile->GetMusicInfoTag() = tag;
4316   m_currentFile->m_lStartOffset = 0;
4317 }
4318
4319 const CFileItem& CGUIInfoManager::GetCurrentSlide() const
4320 {
4321   return *m_currentSlide;
4322 }
4323
4324 const MUSIC_INFO::CMusicInfoTag* CGUIInfoManager::GetCurrentSongTag() const
4325 {
4326   if (m_currentFile->HasMusicInfoTag())
4327     return m_currentFile->GetMusicInfoTag();
4328
4329   return NULL;
4330 }
4331
4332 const CVideoInfoTag* CGUIInfoManager::GetCurrentMovieTag() const
4333 {
4334   if (m_currentFile->HasVideoInfoTag())
4335     return m_currentFile->GetVideoInfoTag();
4336
4337   return NULL;
4338 }
4339
4340 void GUIInfo::SetInfoFlag(uint32_t flag)
4341 {
4342   assert(flag >= (1 << 24));
4343   m_data1 |= flag;
4344 }
4345
4346 uint32_t GUIInfo::GetInfoFlag() const
4347 {
4348   // we strip out the bottom 24 bits, where we keep data
4349   // and return the flag only
4350   return m_data1 & 0xff000000;
4351 }
4352
4353 uint32_t GUIInfo::GetData1() const
4354 {
4355   // we strip out the top 8 bits, where we keep flags
4356   // and return the unflagged data
4357   return m_data1 & ((1 << 24) -1);
4358 }
4359
4360 int GUIInfo::GetData2() const
4361 {
4362   return m_data2;
4363 }
4364
4365 void CGUIInfoManager::SetLibraryBool(int condition, bool value)
4366 {
4367   switch (condition)
4368   {
4369     case LIBRARY_HAS_MUSIC:
4370       m_libraryHasMusic = value ? 1 : 0;
4371       break;
4372     case LIBRARY_HAS_MOVIES:
4373       m_libraryHasMovies = value ? 1 : 0;
4374       break;
4375     case LIBRARY_HAS_TVSHOWS:
4376       m_libraryHasTVShows = value ? 1 : 0;
4377       break;
4378     case LIBRARY_HAS_MUSICVIDEOS:
4379       m_libraryHasMusicVideos = value ? 1 : 0;
4380       break;
4381     default:
4382       break;
4383   }
4384 }
4385
4386 void CGUIInfoManager::ResetLibraryBools()
4387 {
4388   m_libraryHasMusic = -1;
4389   m_libraryHasMovies = -1;
4390   m_libraryHasTVShows = -1;
4391   m_libraryHasMusicVideos = -1;
4392 }
4393
4394 bool CGUIInfoManager::GetLibraryBool(int condition)
4395 {
4396   if (condition == LIBRARY_HAS_MUSIC)
4397   {
4398     if (m_libraryHasMusic < 0)
4399     { // query
4400       CMusicDatabase db;
4401       if (db.Open())
4402       {
4403         m_libraryHasMusic = (db.GetSongsCount() > 0) ? 1 : 0;
4404         db.Close();
4405       }
4406     }
4407     return m_libraryHasMusic > 0;
4408   }
4409   else if (condition == LIBRARY_HAS_MOVIES)
4410   {
4411     if (m_libraryHasMovies < 0)
4412     {
4413       CVideoDatabase db;
4414       if (db.Open())
4415       {
4416         m_libraryHasMovies = db.HasContent(VIDEODB_CONTENT_MOVIES) ? 1 : 0;
4417         db.Close();
4418       }
4419     }
4420     return m_libraryHasMovies > 0;
4421   }
4422   else if (condition == LIBRARY_HAS_TVSHOWS)
4423   {
4424     if (m_libraryHasTVShows < 0)
4425     {
4426       CVideoDatabase db;
4427       if (db.Open())
4428       {
4429         m_libraryHasTVShows = db.HasContent(VIDEODB_CONTENT_TVSHOWS) ? 1 : 0;
4430         db.Close();
4431       }
4432     }
4433     return m_libraryHasTVShows > 0;
4434   }
4435   else if (condition == LIBRARY_HAS_MUSICVIDEOS)
4436   {
4437     if (m_libraryHasMusicVideos < 0)
4438     {
4439       CVideoDatabase db;
4440       if (db.Open())
4441       {
4442         m_libraryHasMusicVideos = db.HasContent(VIDEODB_CONTENT_MUSICVIDEOS) ? 1 : 0;
4443         db.Close();
4444       }
4445     }
4446     return m_libraryHasMusicVideos > 0;
4447   }
4448   else if (condition == LIBRARY_HAS_VIDEO)
4449   {
4450     return (GetLibraryBool(LIBRARY_HAS_MOVIES) ||
4451             GetLibraryBool(LIBRARY_HAS_TVSHOWS) ||
4452             GetLibraryBool(LIBRARY_HAS_MUSICVIDEOS));
4453   }
4454   return false;
4455 }