added: container.seasonthumb info label
[xbmc:xbmc-antiquated.git] / xbmc / utils / GUIInfoManager.cpp
1 #include "stdafx.h"
2 #include "../GUIDialogSeekBar.h"
3 #include "../GUIMediaWindow.h"
4 #include "../GUIDialogFileBrowser.h"
5 #include "../GUIDialogContentSettings.h"
6 #include "../Application.h"
7 #include "../Util.h"
8 #include "../lib/libscrobbler/scrobbler.h"
9 #include "../utils/TuxBoxUtil.h"
10 #include "KaiClient.h"
11 #include "Weather.h"
12 #include "../PlayListPlayer.h"
13 #include "../PartyModeManager.h"
14 #include "../visualizations/Visualisation.h"
15 #include "../ButtonTranslator.h"
16 #include "../MusicDatabase.h"
17 #include "../utils/AlarmClock.h"
18 #ifdef HAS_LCD
19 #include "../utils/LCD.h"
20 #endif
21 #include "../GUIPassword.h"
22 #ifdef HAS_XBOX_HARDWARE
23 #include "FanController.h"
24 #include "../xbox/XKHDD.h"
25 #endif
26 #include "SystemInfo.h"
27 #include "GUIButtonScroller.h"
28 #include "GUIInfoManager.h"
29 #include <stack>
30 #include "../xbox/network.h"
31 #include "GUIWindowSlideShow.h"
32 #include "../LastFmManager.h"
33
34 // stuff for current song
35 #ifdef HAS_FILESYSTEM
36 #include "../FileSystem/SndtrkDirectory.h"
37 #endif
38 #include "../musicInfoTagLoaderFactory.h"
39 #include "../MusicInfoLoader.h"
40 #include "LabelFormatter.h"
41
42 #include "GUILabelControl.h"  // for CInfoLabel
43
44 using namespace std;
45 using namespace XFILE;
46 using namespace DIRECTORY;
47 using namespace MEDIA_DETECT;
48 using namespace MUSIC_INFO;
49
50 CGUIInfoManager g_infoManager;
51
52 void CGUIInfoManager::CCombinedValue::operator =(const CGUIInfoManager::CCombinedValue& mSrc)
53 {
54   this->m_info = mSrc.m_info;
55   this->m_id = mSrc.m_id;
56   this->m_postfix = mSrc.m_postfix;
57 }
58
59 CGUIInfoManager::CGUIInfoManager(void)
60 {
61   m_lastSysHeatInfoTime = 0; 
62   m_lastMusicBitrateTime = 0;
63   m_fanSpeed = 0;
64   m_AfterSeekTimeout = 0;
65   m_playerSeeking = false;
66   m_performingSeek = false;
67   m_nextWindowID = WINDOW_INVALID;
68   m_prevWindowID = WINDOW_INVALID;
69   m_stringParameters.push_back("__ZZZZ__");   // to offset the string parameters by 1 to assure that all entries are non-zero
70 }
71
72 CGUIInfoManager::~CGUIInfoManager(void)
73 {
74 }
75
76 bool CGUIInfoManager::OnMessage(CGUIMessage &message)
77 {
78   if (message.GetMessage() == GUI_MSG_NOTIFY_ALL)
79   {
80     if (message.GetParam1() == GUI_MSG_UPDATE_ITEM && message.GetLPVOID())
81     {
82       CFileItem *item = (CFileItem *)message.GetLPVOID();
83       if (m_currentFile.m_strPath.Equals(item->m_strPath))
84         m_currentFile = *item;
85       return true;
86     }
87   }
88   return false;
89 }
90
91 /// \brief Translates a string as given by the skin into an int that we use for more
92 /// efficient retrieval of data. Can handle combined strings on the form
93 /// Player.Caching + VideoPlayer.IsFullscreen (Logical and)
94 /// Player.HasVideo | Player.HasAudio (Logical or)
95 int CGUIInfoManager::TranslateString(const CStdString &strCondition)
96 {
97   if (strCondition.find_first_of("|") != strCondition.npos ||
98       strCondition.find_first_of("+") != strCondition.npos ||
99       strCondition.find_first_of("[") != strCondition.npos ||
100       strCondition.find_first_of("]") != strCondition.npos)
101   {
102     // Have a boolean expression
103     // Check if this was added before
104     std::vector<CCombinedValue>::iterator it;
105     for(it = m_CombinedValues.begin(); it != m_CombinedValues.end(); it++)
106     {
107       if(strCondition.CompareNoCase(it->m_info) == 0)
108         return it->m_id;
109     }
110     return TranslateBooleanExpression(strCondition);
111   }  
112   //Just single command.
113   return TranslateSingleString(strCondition);
114 }
115
116
117 /// \brief Translates a string as given by the skin into an int that we use for more
118 /// efficient retrieval of data.
119 int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition)
120 {
121   if (strCondition.IsEmpty()) return 0;
122   CStdString strTest = strCondition;
123   strTest.ToLower();
124   strTest.TrimLeft(" ");
125   strTest.TrimRight(" ");
126   bool bNegate = strTest[0] == '!';
127   int ret = 0;
128
129   if(bNegate)
130     strTest.Delete(0, 1);
131
132   CStdString strCategory = strTest.Left(strTest.Find("."));
133
134   // translate conditions...
135   if (strTest.Equals("false") || strTest.Equals("no") || strTest.Equals("off")) ret = SYSTEM_ALWAYS_FALSE;
136   else if (strTest.Equals("true") || strTest.Equals("yes") || strTest.Equals("on")) ret = SYSTEM_ALWAYS_TRUE;
137   if (strCategory.Equals("player"))
138   {
139     if (strTest.Equals("player.hasmedia")) ret = PLAYER_HAS_MEDIA;
140     else if (strTest.Equals("player.hasaudio")) ret = PLAYER_HAS_AUDIO;
141     else if (strTest.Equals("player.hasvideo")) ret = PLAYER_HAS_VIDEO;
142     else if (strTest.Equals("player.playing")) ret = PLAYER_PLAYING;
143     else if (strTest.Equals("player.paused")) ret = PLAYER_PAUSED;
144     else if (strTest.Equals("player.rewinding")) ret = PLAYER_REWINDING;
145     else if (strTest.Equals("player.forwarding")) ret = PLAYER_FORWARDING;
146     else if (strTest.Equals("player.rewinding2x")) ret = PLAYER_REWINDING_2x;
147     else if (strTest.Equals("player.rewinding4x")) ret = PLAYER_REWINDING_4x;
148     else if (strTest.Equals("player.rewinding8x")) ret = PLAYER_REWINDING_8x;
149     else if (strTest.Equals("player.rewinding16x")) ret = PLAYER_REWINDING_16x;
150     else if (strTest.Equals("player.rewinding32x")) ret = PLAYER_REWINDING_32x;
151     else if (strTest.Equals("player.forwarding2x")) ret = PLAYER_FORWARDING_2x;
152     else if (strTest.Equals("player.forwarding4x")) ret = PLAYER_FORWARDING_4x;
153     else if (strTest.Equals("player.forwarding8x")) ret = PLAYER_FORWARDING_8x;
154     else if (strTest.Equals("player.forwarding16x")) ret = PLAYER_FORWARDING_16x;
155     else if (strTest.Equals("player.forwarding32x")) ret = PLAYER_FORWARDING_32x;
156     else if (strTest.Equals("player.canrecord")) ret = PLAYER_CAN_RECORD;
157     else if (strTest.Equals("player.recording")) ret = PLAYER_RECORDING;
158     else if (strTest.Equals("player.displayafterseek")) ret = PLAYER_DISPLAY_AFTER_SEEK;
159     else if (strTest.Equals("player.caching")) ret = PLAYER_CACHING;
160     else if (strTest.Equals("player.cachelevel")) ret = PLAYER_CACHELEVEL;
161     else if (strTest.Equals("player.seekbar")) ret = PLAYER_SEEKBAR;
162     else if (strTest.Equals("player.progress")) ret = PLAYER_PROGRESS;
163     else if (strTest.Equals("player.seeking")) ret = PLAYER_SEEKING;
164     else if (strTest.Equals("player.showtime")) ret = PLAYER_SHOWTIME;
165     else if (strTest.Equals("player.showcodec")) ret = PLAYER_SHOWCODEC;
166     else if (strTest.Equals("player.showinfo")) ret = PLAYER_SHOWINFO;
167     else if (strTest.Left(15).Equals("player.seektime")) return AddMultiInfo(GUIInfo(PLAYER_SEEKTIME, TranslateTimeFormat(strTest.Mid(15))));
168     else if (strTest.Left(20).Equals("player.timeremaining")) return AddMultiInfo(GUIInfo(PLAYER_TIME_REMAINING, TranslateTimeFormat(strTest.Mid(20))));
169     else if (strTest.Left(16).Equals("player.timespeed")) return AddMultiInfo(GUIInfo(PLAYER_TIME_SPEED, TranslateTimeFormat(strTest.Mid(16))));
170     else if (strTest.Left(11).Equals("player.time")) return AddMultiInfo(GUIInfo(PLAYER_TIME, TranslateTimeFormat(strTest.Mid(11))));
171     else if (strTest.Left(15).Equals("player.duration")) return AddMultiInfo(GUIInfo(PLAYER_DURATION, TranslateTimeFormat(strTest.Mid(15))));
172     else if (strTest.Left(17).Equals("player.finishtime")) return AddMultiInfo(GUIInfo(PLAYER_FINISH_TIME, TranslateTimeFormat(strTest.Mid(17))));
173     else if (strTest.Equals("player.volume")) ret = PLAYER_VOLUME;
174     else if (strTest.Equals("player.muted")) ret = PLAYER_MUTED;
175     else if (strTest.Equals("player.hasduration")) ret = PLAYER_HASDURATION;
176     else if (strTest.Equals("player.chapter")) ret = PLAYER_CHAPTER;
177     else if (strTest.Equals("player.chaptercount")) ret = PLAYER_CHAPTERCOUNT;
178     else if (strTest.Equals("player.starrating")) ret = PLAYER_STAR_RATING;
179   }
180   else if (strCategory.Equals("weather"))
181   {
182     if (strTest.Equals("weather.conditions")) ret = WEATHER_CONDITIONS;
183     else if (strTest.Equals("weather.temperature")) ret = WEATHER_TEMPERATURE;
184     else if (strTest.Equals("weather.location")) ret = WEATHER_LOCATION;
185     else if (strTest.Equals("weather.isfetched")) ret = WEATHER_IS_FETCHED;
186   }
187   else if (strCategory.Equals("bar"))
188   {
189     if (strTest.Equals("bar.gputemperature")) ret = SYSTEM_GPU_TEMPERATURE;
190     else if (strTest.Equals("bar.cputemperature")) ret = SYSTEM_CPU_TEMPERATURE;
191     else if (strTest.Equals("bar.cpuusage")) ret = SYSTEM_CPU_USAGE;
192     else if (strTest.Equals("bar.freememory")) ret = SYSTEM_FREE_MEMORY;
193     else if (strTest.Equals("bar.usedmemory")) ret = SYSTEM_USED_MEMORY;
194     else if (strTest.Equals("bar.fanspeed")) ret = SYSTEM_FAN_SPEED;
195     else if (strTest.Equals("bar.usedspace")) ret = SYSTEM_USED_SPACE;
196     else if (strTest.Equals("bar.freespace")) ret = SYSTEM_FREE_SPACE;
197     else if (strTest.Equals("bar.usedspace(c)")) ret = SYSTEM_USED_SPACE_C;
198     else if (strTest.Equals("bar.freespace(c)")) ret = SYSTEM_FREE_SPACE_C;
199     else if (strTest.Equals("bar.usedspace(e)")) ret = SYSTEM_USED_SPACE_E;   
200     else if (strTest.Equals("bar.freespace(e)")) ret = SYSTEM_FREE_SPACE_E; 
201     else if (strTest.Equals("bar.usedspace(f)")) ret = SYSTEM_USED_SPACE_F;
202     else if (strTest.Equals("bar.freespace(f)")) ret = SYSTEM_FREE_SPACE_F;
203     else if (strTest.Equals("bar.usedspace(g)")) ret = SYSTEM_USED_SPACE_G;
204     else if (strTest.Equals("bar.freespace(g)")) ret = SYSTEM_FREE_SPACE_G;
205     else if (strTest.Equals("bar.usedspace(x)")) ret = SYSTEM_USED_SPACE_X;
206     else if (strTest.Equals("bar.freespace(x)")) ret = SYSTEM_FREE_SPACE_X;
207     else if (strTest.Equals("bar.usedspace(y)")) ret = SYSTEM_USED_SPACE_Y;
208     else if (strTest.Equals("bar.freespace(y)")) ret = SYSTEM_FREE_SPACE_Y;
209     else if (strTest.Equals("bar.usedspace(z)")) ret = SYSTEM_USED_SPACE_Z;
210     else if (strTest.Equals("bar.freespace(z)")) ret = SYSTEM_FREE_SPACE_Z;
211     else if (strTest.Equals("bar.hddtemperature")) ret = SYSTEM_HDD_TEMPERATURE;
212   }
213   else if (strCategory.Equals("system"))
214   {
215     if (strTest.Equals("system.date")) ret = SYSTEM_DATE;
216     else if (strTest.Left(12).Equals("system.date("))
217     {
218       // the skin must submit the date in the format MM-DD
219       // This InfoBool is designed for generic range checking, so year is NOT used.  Only Month-Day.
220       CStdString param = strTest.Mid(13, strTest.length() - 14);
221       CStdStringArray params;
222       StringUtils::SplitString(param, ",", params);
223       if (params.size() == 2)
224         return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_DATE : SYSTEM_DATE, StringUtils::DateStringToYYYYMMDD(params[0]) % 10000, StringUtils::DateStringToYYYYMMDD(params[1]) % 10000));
225       else if (params.size() == 1)
226         return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_DATE : SYSTEM_DATE, StringUtils::DateStringToYYYYMMDD(params[0]) % 10000));
227     }
228     else if (strTest.Left(11).Equals("system.time")) 
229     {
230       // 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
231       // essentially if it isn't a valid TIME_FORMAT then its considered to be the latter.
232       CStdString param = strTest.Mid(12, strTest.length() - 13);
233       TIME_FORMAT timeFormat = TranslateTimeFormat(param);
234       if ((timeFormat == TIME_FORMAT_GUESS) && (!param.IsEmpty()))
235       {
236         CStdStringArray params;
237         StringUtils::SplitString(param, ",", params);
238         if (params.size() == 2)
239           return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_TIME : SYSTEM_TIME, StringUtils::TimeStringToSeconds(params[0]), StringUtils::TimeStringToSeconds(params[1])));
240         else if (params.size() == 1)
241           return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_TIME : SYSTEM_TIME, StringUtils::TimeStringToSeconds(params[0])));
242       }
243       else
244         return AddMultiInfo(GUIInfo(SYSTEM_TIME, timeFormat));
245     }
246     else if (strTest.Equals("system.cputemperature")) ret = SYSTEM_CPU_TEMPERATURE;
247     else if (strTest.Equals("system.cpuusage")) ret = SYSTEM_CPU_USAGE;
248     else if (strTest.Equals("system.gputemperature")) ret = SYSTEM_GPU_TEMPERATURE;
249     else if (strTest.Equals("system.fanspeed")) ret = SYSTEM_FAN_SPEED;
250     else if (strTest.Equals("system.freespace")) ret = SYSTEM_FREE_SPACE;
251     else if (strTest.Equals("system.usedspace")) ret = SYSTEM_USED_SPACE;
252     else if (strTest.Equals("system.totalspace")) ret = SYSTEM_TOTAL_SPACE;
253     else if (strTest.Equals("system.usedspacepercent")) ret = SYSTEM_USED_SPACE_PERCENT;
254     else if (strTest.Equals("system.freespacepercent")) ret = SYSTEM_FREE_SPACE_PERCENT;
255     else if (strTest.Equals("system.freespace(c)")) ret = SYSTEM_FREE_SPACE_C;
256     else if (strTest.Equals("system.usedspace(c)")) ret = SYSTEM_USED_SPACE_C;
257     else if (strTest.Equals("system.totalspace(c)")) ret = SYSTEM_TOTAL_SPACE_C;
258     else if (strTest.Equals("system.usedspacepercent(c)")) ret = SYSTEM_USED_SPACE_PERCENT_C;
259     else if (strTest.Equals("system.freespacepercent(c)")) ret = SYSTEM_FREE_SPACE_PERCENT_C;
260     else if (strTest.Equals("system.freespace(e)")) ret = SYSTEM_FREE_SPACE_E;
261     else if (strTest.Equals("system.usedspace(e)")) ret = SYSTEM_USED_SPACE_E;
262     else if (strTest.Equals("system.totalspace(e)")) ret = SYSTEM_TOTAL_SPACE_E;
263     else if (strTest.Equals("system.usedspacepercent(e)")) ret = SYSTEM_USED_SPACE_PERCENT_E;
264     else if (strTest.Equals("system.freespacepercent(e)")) ret = SYSTEM_FREE_SPACE_PERCENT_E;
265     else if (strTest.Equals("system.freespace(f)")) ret = SYSTEM_FREE_SPACE_F;
266     else if (strTest.Equals("system.usedspace(f)")) ret = SYSTEM_USED_SPACE_F;
267     else if (strTest.Equals("system.totalspace(f)")) ret = SYSTEM_TOTAL_SPACE_F;
268     else if (strTest.Equals("system.usedspacepercent(f)")) ret = SYSTEM_USED_SPACE_PERCENT_F;
269     else if (strTest.Equals("system.freespacepercent(f)")) ret = SYSTEM_FREE_SPACE_PERCENT_F;
270     else if (strTest.Equals("system.freespace(g)")) ret = SYSTEM_FREE_SPACE_G;
271     else if (strTest.Equals("system.usedspace(g)")) ret = SYSTEM_USED_SPACE_G;
272     else if (strTest.Equals("system.totalspace(g)")) ret = SYSTEM_TOTAL_SPACE_G;
273     else if (strTest.Equals("system.usedspacepercent(g)")) ret = SYSTEM_USED_SPACE_PERCENT_G;
274     else if (strTest.Equals("system.freespacepercent(g)")) ret = SYSTEM_FREE_SPACE_PERCENT_G;
275     else if (strTest.Equals("system.usedspace(x)")) ret = SYSTEM_USED_SPACE_X;
276     else if (strTest.Equals("system.freespace(x)")) ret = SYSTEM_FREE_SPACE_X;
277     else if (strTest.Equals("system.totalspace(x)")) ret = SYSTEM_TOTAL_SPACE_X;
278     else if (strTest.Equals("system.usedspace(y)")) ret = SYSTEM_USED_SPACE_Y;
279     else if (strTest.Equals("system.freespace(y)")) ret = SYSTEM_FREE_SPACE_Y;
280     else if (strTest.Equals("system.totalspace(y)")) ret = SYSTEM_TOTAL_SPACE_Y;
281     else if (strTest.Equals("system.usedspace(z)")) ret = SYSTEM_USED_SPACE_Z;
282     else if (strTest.Equals("system.freespace(z)")) ret = SYSTEM_FREE_SPACE_Z;
283     else if (strTest.Equals("system.totalspace(z)")) ret = SYSTEM_TOTAL_SPACE_Z;
284     else if (strTest.Equals("system.buildversion")) ret = SYSTEM_BUILD_VERSION;
285     else if (strTest.Equals("system.builddate")) ret = SYSTEM_BUILD_DATE;
286     else if (strTest.Equals("system.hasnetwork")) ret = SYSTEM_ETHERNET_LINK_ACTIVE;
287     else if (strTest.Equals("system.fps")) ret = SYSTEM_FPS;
288     else if (strTest.Equals("system.kaiconnected")) ret = SYSTEM_KAI_CONNECTED;
289     else if (strTest.Equals("system.kaienabled")) ret = SYSTEM_KAI_ENABLED;
290     else if (strTest.Equals("system.hasmediadvd")) ret = SYSTEM_MEDIA_DVD;
291     else if (strTest.Equals("system.dvdready")) ret = SYSTEM_DVDREADY;
292     else if (strTest.Equals("system.trayopen")) ret = SYSTEM_TRAYOPEN;
293     else if (strTest.Equals("system.dvdtraystate")) ret = SYSTEM_DVD_TRAY_STATE;
294     
295     else if (strTest.Equals("system.memory(free)") || strTest.Equals("system.freememory")) ret = SYSTEM_FREE_MEMORY;
296     else if (strTest.Equals("system.memory(free.percent)")) ret = SYSTEM_FREE_MEMORY_PERCENT;
297     else if (strTest.Equals("system.memory(used)")) ret = SYSTEM_USED_MEMORY;
298     else if (strTest.Equals("system.memory(used.percent)")) ret = SYSTEM_USED_MEMORY_PERCENT;
299     else if (strTest.Equals("system.memory(total)")) ret = SYSTEM_TOTAL_MEMORY;
300
301     else if (strTest.Equals("system.language")) ret = SYSTEM_LANGUAGE;
302     else if (strTest.Equals("system.screenmode")) ret = SYSTEM_SCREEN_MODE;
303     else if (strTest.Equals("system.screenwidth")) ret = SYSTEM_SCREEN_WIDTH;
304     else if (strTest.Equals("system.screenheight")) ret = SYSTEM_SCREEN_HEIGHT;
305     else if (strTest.Equals("system.currentwindow")) ret = SYSTEM_CURRENT_WINDOW;
306     else if (strTest.Equals("system.currentcontrol")) ret = SYSTEM_CURRENT_CONTROL;
307     else if (strTest.Equals("system.xboxnickname")) ret = SYSTEM_XBOX_NICKNAME;
308     else if (strTest.Equals("system.dvdlabel")) ret = SYSTEM_DVD_LABEL;
309     else if (strTest.Equals("system.haslocks")) ret = SYSTEM_HASLOCKS;
310     else if (strTest.Equals("system.hasloginscreen")) ret = SYSTEM_HAS_LOGINSCREEN;
311     else if (strTest.Equals("system.ismaster")) ret = SYSTEM_ISMASTER;
312     else if (strTest.Equals("system.internetstate")) ret = SYSTEM_INTERNET_STATE;
313     else if (strTest.Equals("system.loggedon")) ret = SYSTEM_LOGGEDON;
314     else if (strTest.Equals("system.hasdrivef")) ret = SYSTEM_HAS_DRIVE_F;
315     else if (strTest.Equals("system.hasdriveg")) ret = SYSTEM_HAS_DRIVE_G;
316     else if (strTest.Equals("system.hddtemperature")) ret = SYSTEM_HDD_TEMPERATURE;
317     else if (strTest.Equals("system.hddinfomodel")) ret = SYSTEM_HDD_MODEL;
318     else if (strTest.Equals("system.hddinfofirmware")) ret = SYSTEM_HDD_FIRMWARE;
319     else if (strTest.Equals("system.hddinfoserial")) ret = SYSTEM_HDD_SERIAL;
320     else if (strTest.Equals("system.hddinfopw")) ret = SYSTEM_HDD_PASSWORD;
321     else if (strTest.Equals("system.hddinfolockstate")) ret = SYSTEM_HDD_LOCKSTATE;
322     else if (strTest.Equals("system.hddlockkey")) ret = SYSTEM_HDD_LOCKKEY;
323     else if (strTest.Equals("system.hddbootdate")) ret = SYSTEM_HDD_BOOTDATE;
324     else if (strTest.Equals("system.hddcyclecount")) ret = SYSTEM_HDD_CYCLECOUNT;
325     else if (strTest.Equals("system.dvdinfomodel")) ret = SYSTEM_DVD_MODEL;
326     else if (strTest.Equals("system.dvdinfofirmware")) ret = SYSTEM_DVD_FIRMWARE;
327     else if (strTest.Equals("system.mplayerversion")) ret = SYSTEM_MPLAYER_VERSION;
328     else if (strTest.Equals("system.kernelversion")) ret = SYSTEM_KERNEL_VERSION;
329     else if (strTest.Equals("system.uptime")) ret = SYSTEM_UPTIME;
330     else if (strTest.Equals("system.totaluptime")) ret = SYSTEM_TOTALUPTIME;
331     else if (strTest.Equals("system.cpufrequency")) ret = SYSTEM_CPUFREQUENCY;
332     else if (strTest.Equals("system.xboxversion")) ret = SYSTEM_XBOX_VERSION;
333     else if (strTest.Equals("system.avpackinfo")) ret = SYSTEM_AV_PACK_INFO;
334     else if (strTest.Equals("system.screenresolution")) ret = SYSTEM_SCREEN_RESOLUTION;
335     else if (strTest.Equals("system.videoencoderinfo")) ret = SYSTEM_VIDEO_ENCODER_INFO;
336     else if (strTest.Equals("system.xboxproduceinfo")) ret = SYSTEM_XBOX_PRODUCE_INFO;
337     else if (strTest.Equals("system.xboxserial")) ret = SYSTEM_XBOX_SERIAL;
338     else if (strTest.Equals("system.xberegion")) ret = SYSTEM_XBE_REGION;
339     else if (strTest.Equals("system.dvdzone")) ret = SYSTEM_DVD_ZONE;
340     else if (strTest.Equals("system.bios")) ret = SYSTEM_XBOX_BIOS;
341     else if (strTest.Equals("system.modchip")) ret = SYSTEM_XBOX_MODCHIP;
342     else if (strTest.Left(22).Equals("system.controllerport("))
343     {
344       int i_ControllerPort = atoi((strTest.Mid(22, strTest.GetLength() - 23).c_str()));
345       if (i_ControllerPort == 1) ret = SYSTEM_CONTROLLER_PORT_1;
346       else if (i_ControllerPort == 2) ret = SYSTEM_CONTROLLER_PORT_2;
347       else if (i_ControllerPort == 3) ret = SYSTEM_CONTROLLER_PORT_3;
348       else if (i_ControllerPort == 4)ret = SYSTEM_CONTROLLER_PORT_4;
349       else ret = SYSTEM_CONTROLLER_PORT_1;
350     }
351     else if (strTest.Left(16).Equals("system.idletime("))
352     {
353       int time = atoi((strTest.Mid(16, strTest.GetLength() - 17).c_str()));
354       if (time > SYSTEM_IDLE_TIME_FINISH - SYSTEM_IDLE_TIME_START)
355         time = SYSTEM_IDLE_TIME_FINISH - SYSTEM_IDLE_TIME_START;
356       if (time > 0)
357         ret = SYSTEM_IDLE_TIME_START + time;
358     }
359     else if (strTest.Left(16).Equals("system.hasalarm("))
360       return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_HAS_ALARM : SYSTEM_HAS_ALARM, ConditionalStringParameter(strTest.Mid(16,strTest.size()-17)), 0));
361     else if (strTest.Equals("system.alarmpos")) ret = SYSTEM_ALARM_POS;
362     else if (strTest.Equals("system.profilename")) ret = SYSTEM_PROFILENAME;
363     else if (strTest.Equals("system.profilethumb")) ret = SYSTEM_PROFILETHUMB;
364     else if (strTest.Equals("system.launchxbe")) ret = SYSTEM_LAUNCHING_XBE;
365     else if (strTest.Equals("system.progressbar")) ret = SYSTEM_PROGRESS_BAR;
366     else if (strTest.Equals("system.platform.linux")) ret = SYSTEM_PLATFORM_LINUX;
367     else if (strTest.Equals("system.platform.xbox")) ret = SYSTEM_PLATFORM_XBOX;
368     else if (strTest.Equals("system.platform.windows")) ret = SYSTEM_PLATFORM_WINDOWS;
369     else if (strTest.Left(15).Equals("system.getbool("))
370       return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_GET_BOOL : SYSTEM_GET_BOOL, ConditionalStringParameter(strTest.Mid(15,strTest.size()-16)), 0));
371   }
372   // library test conditions
373   else if (strTest.Left(7).Equals("library"))
374   {
375     if (strTest.Equals("library.hascontent(music)")) ret = LIBRARY_HAS_MUSIC;
376     else if (strTest.Equals("library.hascontent(video)")) ret = LIBRARY_HAS_VIDEO;
377     else if (strTest.Equals("library.hascontent(movies)")) ret = LIBRARY_HAS_MOVIES;
378     else if (strTest.Equals("library.hascontent(tvshows)")) ret = LIBRARY_HAS_TVSHOWS;
379     else if (strTest.Equals("library.hascontent(musicvideos)")) ret = LIBRARY_HAS_MUSICVIDEOS;
380   }
381   else if (strTest.Left(8).Equals("isempty("))
382   {
383     CStdString str = strTest.Mid(8, strTest.GetLength() - 9);
384     return AddMultiInfo(GUIInfo(bNegate ? -STRING_IS_EMPTY : STRING_IS_EMPTY, TranslateSingleString(str)));
385   }
386   else if (strCategory.Equals("xlinkkai"))
387   {
388     if (strTest.Equals("xlinkkai.username")) ret = XLINK_KAI_USERNAME;
389   }
390   else if (strCategory.Equals("lcd"))
391   {
392     if (strTest.Equals("lcd.playicon")) ret = LCD_PLAY_ICON;
393     else if (strTest.Equals("lcd.progressbar")) ret = LCD_PROGRESS_BAR;
394     else if (strTest.Equals("lcd.cputemperature")) ret = LCD_CPU_TEMPERATURE;
395     else if (strTest.Equals("lcd.gputemperature")) ret = LCD_GPU_TEMPERATURE;
396     else if (strTest.Equals("lcd.hddtemperature")) ret = LCD_HDD_TEMPERATURE;
397     else if (strTest.Equals("lcd.fanspeed")) ret = LCD_FAN_SPEED;
398     else if (strTest.Equals("lcd.date")) ret = LCD_DATE;
399     else if (strTest.Equals("lcd.freespace(c)")) ret = LCD_FREE_SPACE_C;
400     else if (strTest.Equals("lcd.freespace(e)")) ret = LCD_FREE_SPACE_E;
401     else if (strTest.Equals("lcd.freespace(f)")) ret = LCD_FREE_SPACE_F;
402     else if (strTest.Equals("lcd.freespace(g)")) ret = LCD_FREE_SPACE_G;
403     else if (strTest.Equals("lcd.Time21")) ret = LCD_TIME_21; // Small LCD numbers
404     else if (strTest.Equals("lcd.Time22")) ret = LCD_TIME_22;
405     else if (strTest.Equals("lcd.TimeWide21")) ret = LCD_TIME_W21; // Medium LCD numbers
406     else if (strTest.Equals("lcd.TimeWide22")) ret = LCD_TIME_W22;
407     else if (strTest.Equals("lcd.Time41")) ret = LCD_TIME_41; // Big LCD numbers
408     else if (strTest.Equals("lcd.Time42")) ret = LCD_TIME_42;
409     else if (strTest.Equals("lcd.Time43")) ret = LCD_TIME_43;
410     else if (strTest.Equals("lcd.Time44")) ret = LCD_TIME_44;
411   }
412   else if (strCategory.Equals("network"))
413   {
414     if (strTest.Equals("network.ipaddress")) ret = NETWORK_IP_ADDRESS;
415     if (strTest.Equals("network.isdhcp")) ret = NETWORK_IS_DHCP;
416     if (strTest.Equals("network.linkstate")) ret = NETWORK_LINK_STATE;
417 #ifdef PRE_SKIN_VERSION_2_1_COMPATIBILITY
418     if (strTest.Equals("network.macadress") || strTest.Equals("network.macaddress")) ret = NETWORK_MAC_ADDRESS;
419     if (strTest.Equals("network.subetadress") || strTest.Equals("network.subnetaddress")) ret = NETWORK_SUBNET_ADDRESS;
420     if (strTest.Equals("network.gatewayadress") || strTest.Equals("network.gatewayaddress")) ret = NETWORK_GATEWAY_ADDRESS;
421     if (strTest.Equals("network.dns1adress") || strTest.Equals("network.dns1address")) ret = NETWORK_DNS1_ADDRESS;
422     if (strTest.Equals("network.dns2adress") || strTest.Equals("network.dns2address")) ret = NETWORK_DNS2_ADDRESS;
423     if (strTest.Equals("network.dhcpadress") || strTest.Equals("network.dhcpaddress")) ret = NETWORK_DHCP_ADDRESS;
424 #else
425     if (strTest.Equals("network.macaddress")) ret = NETWORK_MAC_ADDRESS;
426     if (strTest.Equals("network.subnetaddress")) ret = NETWORK_SUBNET_ADDRESS;
427     if (strTest.Equals("network.gatewayaddress")) ret = NETWORK_GATEWAY_ADDRESS;
428     if (strTest.Equals("network.dns1address")) ret = NETWORK_DNS1_ADDRESS;
429     if (strTest.Equals("network.dns2address")) ret = NETWORK_DNS2_ADDRESS;
430     if (strTest.Equals("network.dhcpaddress")) ret = NETWORK_DHCP_ADDRESS;
431 #endif
432   }
433   else if (strCategory.Equals("musicplayer"))
434   {
435     if (strTest.Equals("musicplayer.title")) ret = MUSICPLAYER_TITLE;
436     else if (strTest.Equals("musicplayer.album")) ret = MUSICPLAYER_ALBUM;
437     else if (strTest.Equals("musicplayer.artist")) ret = MUSICPLAYER_ARTIST;
438     else if (strTest.Equals("musicplayer.year")) ret = MUSICPLAYER_YEAR;
439     else if (strTest.Equals("musicplayer.genre")) ret = MUSICPLAYER_GENRE;
440     else if (strTest.Left(25).Equals("musicplayer.timeremaining")) ret = AddMultiInfo(GUIInfo(PLAYER_TIME_REMAINING, TranslateTimeFormat(strTest.Mid(25))));
441     else if (strTest.Left(21).Equals("musicplayer.timespeed")) ret = AddMultiInfo(GUIInfo(PLAYER_TIME_SPEED, TranslateTimeFormat(strTest.Mid(21))));
442     else if (strTest.Left(16).Equals("musicplayer.time")) ret = AddMultiInfo(GUIInfo(PLAYER_TIME, TranslateTimeFormat(strTest.Mid(16))));
443     else if (strTest.Left(20).Equals("musicplayer.duration")) ret = AddMultiInfo(GUIInfo(PLAYER_DURATION, TranslateTimeFormat(strTest.Mid(20))));
444     else if (strTest.Equals("musicplayer.tracknumber")) ret = MUSICPLAYER_TRACK_NUMBER;
445     else if (strTest.Equals("musicplayer.cover")) ret = MUSICPLAYER_COVER;
446     else if (strTest.Equals("musicplayer.bitrate")) ret = MUSICPLAYER_BITRATE;
447     else if (strTest.Equals("musicplayer.playlistlength")) ret = MUSICPLAYER_PLAYLISTLEN;
448     else if (strTest.Equals("musicplayer.playlistposition")) ret = MUSICPLAYER_PLAYLISTPOS;
449     else if (strTest.Equals("musicplayer.channels")) ret = MUSICPLAYER_CHANNELS;
450     else if (strTest.Equals("musicplayer.bitspersample")) ret = MUSICPLAYER_BITSPERSAMPLE;
451     else if (strTest.Equals("musicplayer.samplerate")) ret = MUSICPLAYER_SAMPLERATE;
452     else if (strTest.Equals("musicplayer.codec")) ret = MUSICPLAYER_CODEC;
453     else if (strTest.Equals("musicplayer.discnumber")) ret = MUSICPLAYER_DISC_NUMBER;
454     else if (strTest.Equals("musicplayer.rating")) ret = MUSICPLAYER_RATING;
455     else if (strTest.Equals("musicplayer.comment")) ret = MUSICPLAYER_COMMENT;
456     else if (strTest.Equals("musicplayer.lyrics")) ret = MUSICPLAYER_LYRICS;
457   }
458   else if (strCategory.Equals("videoplayer"))
459   {
460     if (strTest.Equals("videoplayer.title")) ret = VIDEOPLAYER_TITLE;
461     else if (strTest.Equals("videoplayer.genre")) ret = VIDEOPLAYER_GENRE;
462     else if (strTest.Equals("videoplayer.originaltitle")) ret = VIDEOPLAYER_ORIGINALTITLE;
463     else if (strTest.Equals("videoplayer.director")) ret = VIDEOPLAYER_DIRECTOR;
464     else if (strTest.Equals("videoplayer.year")) ret = VIDEOPLAYER_YEAR;
465     else if (strTest.Left(25).Equals("videoplayer.timeremaining")) ret = AddMultiInfo(GUIInfo(PLAYER_TIME_REMAINING, TranslateTimeFormat(strTest.Mid(25))));
466     else if (strTest.Left(21).Equals("videoplayer.timespeed")) ret = AddMultiInfo(GUIInfo(PLAYER_TIME_SPEED, TranslateTimeFormat(strTest.Mid(21))));
467     else if (strTest.Left(16).Equals("videoplayer.time")) ret = AddMultiInfo(GUIInfo(PLAYER_TIME, TranslateTimeFormat(strTest.Mid(16))));
468     else if (strTest.Left(20).Equals("videoplayer.duration")) ret = AddMultiInfo(GUIInfo(PLAYER_DURATION, TranslateTimeFormat(strTest.Mid(20))));
469     else if (strTest.Equals("videoplayer.cover")) ret = VIDEOPLAYER_COVER;
470     else if (strTest.Equals("videoplayer.usingoverlays")) ret = VIDEOPLAYER_USING_OVERLAYS;
471     else if (strTest.Equals("videoplayer.isfullscreen")) ret = VIDEOPLAYER_ISFULLSCREEN;
472     else if (strTest.Equals("videoplayer.hasmenu")) ret = VIDEOPLAYER_HASMENU;
473     else if (strTest.Equals("videoplayer.playlistlength")) ret = VIDEOPLAYER_PLAYLISTLEN;
474     else if (strTest.Equals("videoplayer.playlistposition")) ret = VIDEOPLAYER_PLAYLISTPOS;
475     else if (strTest.Equals("videoplayer.plot")) ret = VIDEOPLAYER_PLOT;
476     else if (strTest.Equals("videoplayer.plotoutline")) ret = VIDEOPLAYER_PLOT_OUTLINE;
477     else if (strTest.Equals("videoplayer.episode")) ret = VIDEOPLAYER_EPISODE;
478     else if (strTest.Equals("videoplayer.season")) ret = VIDEOPLAYER_SEASON;
479     else if (strTest.Equals("videoplayer.rating")) ret = VIDEOPLAYER_RATING;
480     else if (strTest.Equals("videoplayer.ratingandvotes")) ret = VIDEOPLAYER_RATING_AND_VOTES;
481     else if (strTest.Equals("videoplayer.tvshowtitle")) ret = VIDEOPLAYER_TVSHOW;
482     else if (strTest.Equals("videoplayer.premiered")) ret = VIDEOPLAYER_PREMIERED;
483     else if (strTest.Left(19).Equals("videoplayer.content")) return AddMultiInfo(GUIInfo(bNegate ? -VIDEOPLAYER_CONTENT : VIDEOPLAYER_CONTENT, ConditionalStringParameter(strTest.Mid(20,strTest.size()-21)), 0));
484     else if (strTest.Equals("videoplayer.studio")) ret = VIDEOPLAYER_STUDIO;
485     else if (strTest.Equals("videoplayer.mpaa")) return VIDEOPLAYER_MPAA;
486     else if (strTest.Equals("videoplayer.top250")) return VIDEOPLAYER_TOP250;
487     else if (strTest.Equals("videoplayer.cast")) return VIDEOPLAYER_CAST;
488     else if (strTest.Equals("videoplayer.castandrole")) return VIDEOPLAYER_CAST_AND_ROLE;
489     else if (strTest.Equals("videoplayer.artist")) return VIDEOPLAYER_ARTIST;
490     else if (strTest.Equals("videoplayer.album")) return VIDEOPLAYER_ALBUM;
491     else if (strTest.Equals("videoplayer.writer")) return VIDEOPLAYER_WRITER;
492     else if (strTest.Equals("videoplayer.tagline")) return VIDEOPLAYER_TAGLINE;
493     else if (strTest.Equals("videoplayer.hasinfo")) return VIDEOPLAYER_HAS_INFO;
494         else if (strTest.Equals("videoplayer.trailer")) return VIDEOPLAYER_TRAILER;
495   }
496   else if (strCategory.Equals("playlist"))
497   {
498     if (strTest.Equals("playlist.length")) ret = PLAYLIST_LENGTH;
499     else if (strTest.Equals("playlist.position")) ret = PLAYLIST_POSITION;
500     else if (strTest.Equals("playlist.random")) ret = PLAYLIST_RANDOM;
501     else if (strTest.Equals("playlist.repeat")) ret = PLAYLIST_REPEAT;
502     else if (strTest.Equals("playlist.israndom")) ret = PLAYLIST_ISRANDOM;
503     else if (strTest.Equals("playlist.isrepeat")) ret = PLAYLIST_ISREPEAT;
504     else if (strTest.Equals("playlist.isrepeatone")) ret = PLAYLIST_ISREPEATONE;
505   }
506   else if (strCategory.Equals("musicpartymode"))
507   {
508     if (strTest.Equals("musicpartymode.enabled")) ret = MUSICPM_ENABLED;
509     else if (strTest.Equals("musicpartymode.songsplayed")) ret = MUSICPM_SONGSPLAYED;
510     else if (strTest.Equals("musicpartymode.matchingsongs")) ret = MUSICPM_MATCHINGSONGS;
511     else if (strTest.Equals("musicpartymode.matchingsongspicked")) ret = MUSICPM_MATCHINGSONGSPICKED;
512     else if (strTest.Equals("musicpartymode.matchingsongsleft")) ret = MUSICPM_MATCHINGSONGSLEFT;
513     else if (strTest.Equals("musicpartymode.relaxedsongspicked")) ret = MUSICPM_RELAXEDSONGSPICKED;
514     else if (strTest.Equals("musicpartymode.randomsongspicked")) ret = MUSICPM_RANDOMSONGSPICKED;
515   }
516   else if (strCategory.Equals("audioscrobbler"))
517   {
518     if (strTest.Equals("audioscrobbler.enabled")) ret = AUDIOSCROBBLER_ENABLED;
519     else if (strTest.Equals("audioscrobbler.connectstate")) ret = AUDIOSCROBBLER_CONN_STATE;
520     else if (strTest.Equals("audioscrobbler.submitinterval")) ret = AUDIOSCROBBLER_SUBMIT_INT;
521     else if (strTest.Equals("audioscrobbler.filescached")) ret = AUDIOSCROBBLER_FILES_CACHED;
522     else if (strTest.Equals("audioscrobbler.submitstate")) ret = AUDIOSCROBBLER_SUBMIT_STATE;
523   }
524   else if (strCategory.Equals("lastfm"))
525   {
526     if (strTest.Equals("lastfm.radioplaying")) ret = LASTFM_RADIOPLAYING;
527     else if (strTest.Equals("lastfm.canlove")) ret = LASTFM_CANLOVE;
528     else if (strTest.Equals("lastfm.canban")) ret = LASTFM_CANBAN;
529   }
530   else if (strCategory.Equals("slideshow"))
531     ret = CPictureInfoTag::TranslateString(strTest.Mid(strCategory.GetLength() + 1));
532   else if (strCategory.Left(9).Equals("container"))
533   {
534     int id = atoi(strCategory.Mid(10, strCategory.GetLength() - 11));
535     CStdString info = strTest.Mid(strCategory.GetLength() + 1);
536     if (info.Left(8).Equals("listitem"))
537     {
538       int offset = atoi(info.Mid(9, info.GetLength() - 10));
539       ret = TranslateListItem(info.Mid(info.Find(".")+1));
540       if (offset || id)
541         return AddMultiInfo(GUIInfo(bNegate ? -ret : ret, id, offset));
542     }
543     else if (info.Equals("folderthumb")) ret = CONTAINER_FOLDERTHUMB;
544     else if (info.Equals("tvshowthumb")) ret = CONTAINER_TVSHOWTHUMB;
545     else if (info.Equals("seasonthumb")) ret = CONTAINER_SEASONTHUMB;
546     else if (info.Equals("folderpath")) ret = CONTAINER_FOLDERPATH;
547     else if (info.Equals("viewmode")) ret = CONTAINER_VIEWMODE;
548     else if (info.Equals("onnext")) ret = CONTAINER_ON_NEXT;
549     else if (info.Equals("onprevious")) ret = CONTAINER_ON_PREVIOUS;
550     else if (info.Equals("hasnext"))
551       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_HAS_NEXT : CONTAINER_HAS_NEXT, id, 0));
552     else if (info.Equals("hasprevious"))    
553       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_HAS_PREVIOUS : CONTAINER_HAS_PREVIOUS, id, 0));
554     else if (info.Left(8).Equals("content("))
555       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_CONTENT : CONTAINER_CONTENT, ConditionalStringParameter(info.Mid(8,info.GetLength()-9)), 0));
556     else if (info.Left(4).Equals("row("))
557       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_ROW : CONTAINER_ROW, id, atoi(info.Mid(4, info.GetLength() - 5))));
558     else if (info.Left(7).Equals("column("))
559       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_COLUMN : CONTAINER_COLUMN, id, atoi(info.Mid(7, info.GetLength() - 8))));
560     else if (info.Left(9).Equals("position("))
561       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_POSITION : CONTAINER_POSITION, id, atoi(info.Mid(9, info.GetLength() - 10))));
562     else if (info.Left(8).Equals("subitem("))
563       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_SUBITEM : CONTAINER_SUBITEM, id, atoi(info.Mid(8, info.GetLength() - 9))));
564     else if (info.Equals("hasthumb")) ret = CONTAINER_HAS_THUMB;
565     else if (info.Equals("numpages")) ret = CONTAINER_NUM_PAGES;
566     else if (info.Equals("currentpage")) ret = CONTAINER_CURRENT_PAGE;
567     else if (info.Equals("sortmethod")) ret = CONTAINER_SORT_METHOD;
568     else if (info.Left(5).Equals("sort("))
569     {
570       SORT_METHOD sort = SORT_METHOD_NONE;
571       CStdString method(info.Mid(5, info.GetLength() - 6));
572       if (method.Equals("songrating")) sort = SORT_METHOD_SONG_RATING;
573       if (sort != SORT_METHOD_NONE)
574         return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_SORT_METHOD : CONTAINER_SORT_METHOD, sort));
575     }
576     else if (id && info.Left(9).Equals("hasfocus("))
577     {
578       int itemID = atoi(info.Mid(9, info.GetLength() - 10));
579       return AddMultiInfo(GUIInfo(bNegate ? -CONTAINER_HAS_FOCUS : CONTAINER_HAS_FOCUS, id, itemID));
580     }
581     if (id && (ret == CONTAINER_ON_NEXT || ret == CONTAINER_ON_PREVIOUS))
582       return AddMultiInfo(GUIInfo(bNegate ? -ret : ret, id));
583   }
584   else if (strCategory.Left(8).Equals("listitem"))
585   {
586     int offset = atoi(strCategory.Mid(9, strCategory.GetLength() - 10));
587     ret = TranslateListItem(strTest.Mid(strCategory.GetLength() + 1));
588     if (offset || ret == LISTITEM_ISSELECTED || ret == LISTITEM_ISPLAYING)
589       return AddMultiInfo(GUIInfo(bNegate ? -ret : ret, 0, offset));
590   }
591   else if (strCategory.Equals("visualisation"))
592   {
593     if (strTest.Equals("visualisation.locked")) ret = VISUALISATION_LOCKED;
594     else if (strTest.Equals("visualisation.preset")) ret = VISUALISATION_PRESET;
595     else if (strTest.Equals("visualisation.name")) ret = VISUALISATION_NAME;
596     else if (strTest.Equals("visualisation.enabled")) ret = VISUALISATION_ENABLED;
597   }
598   else if (strCategory.Equals("fanart"))
599   {
600     if (strTest.Equals("fanart.color1")) ret = FANART_COLOR1;
601     else if (strTest.Equals("fanart.color2")) ret = FANART_COLOR2;
602     else if (strTest.Equals("fanart.color3")) ret = FANART_COLOR3;
603     else if (strTest.Equals("fanart.image")) ret = FANART_IMAGE;
604   }
605   else if (strCategory.Equals("skin"))
606   {
607     if (strTest.Equals("skin.currenttheme"))
608       ret = SKIN_THEME;
609     else if (strTest.Equals("skin.currentcolourtheme"))
610       ret = SKIN_COLOUR_THEME;
611     else if (strTest.Left(12).Equals("skin.string("))
612     {
613       int pos = strTest.Find(",");
614       if (pos >= 0)
615       {
616         int skinOffset = g_settings.TranslateSkinString(strTest.Mid(12, pos - 12));
617         int compareString = ConditionalStringParameter(strTest.Mid(pos + 1, strTest.GetLength() - (pos + 2)));
618         return AddMultiInfo(GUIInfo(bNegate ? -SKIN_STRING : SKIN_STRING, skinOffset, compareString));
619       }
620       int skinOffset = g_settings.TranslateSkinString(strTest.Mid(12, strTest.GetLength() - 13));
621       return AddMultiInfo(GUIInfo(bNegate ? -SKIN_STRING : SKIN_STRING, skinOffset));
622     }
623     else if (strTest.Left(16).Equals("skin.hassetting("))
624     {
625       int skinOffset = g_settings.TranslateSkinBool(strTest.Mid(16, strTest.GetLength() - 17));
626       return AddMultiInfo(GUIInfo(bNegate ? -SKIN_BOOL : SKIN_BOOL, skinOffset));
627     }
628     else if (strTest.Left(14).Equals("skin.hastheme("))
629       ret = SKIN_HAS_THEME_START + ConditionalStringParameter(strTest.Mid(14, strTest.GetLength() -  15));
630   }
631   else if (strTest.Left(16).Equals("window.isactive("))
632   {
633     CStdString window(strTest.Mid(16, strTest.GetLength() - 17).ToLower());
634     if (window.Find("xml") >= 0)
635       return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_IS_ACTIVE : WINDOW_IS_ACTIVE, 0, ConditionalStringParameter(window)));
636     int winID = g_buttonTranslator.TranslateWindowString(window.c_str());
637     if (winID != WINDOW_INVALID)
638       return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_IS_ACTIVE : WINDOW_IS_ACTIVE, winID, 0));
639   }
640   else if (strTest.Equals("window.ismedia")) return WINDOW_IS_MEDIA;
641   else if (strTest.Left(17).Equals("window.istopmost("))
642   {
643     CStdString window(strTest.Mid(17, strTest.GetLength() - 18).ToLower());
644     if (window.Find("xml") >= 0)
645       return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_IS_TOPMOST : WINDOW_IS_TOPMOST, 0, ConditionalStringParameter(window)));
646     int winID = g_buttonTranslator.TranslateWindowString(window.c_str());
647     if (winID != WINDOW_INVALID)
648       return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_IS_TOPMOST : WINDOW_IS_TOPMOST, winID, 0));
649   }
650   else if (strTest.Left(17).Equals("window.isvisible("))
651   {
652     CStdString window(strTest.Mid(17, strTest.GetLength() - 18).ToLower());
653     if (window.Find("xml") >= 0)
654       return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_IS_VISIBLE : WINDOW_IS_VISIBLE, 0, ConditionalStringParameter(window)));
655     int winID = g_buttonTranslator.TranslateWindowString(window.c_str());
656     if (winID != WINDOW_INVALID)
657       return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_IS_VISIBLE : WINDOW_IS_VISIBLE, winID, 0));
658   }
659   else if (strTest.Left(16).Equals("window.previous("))
660   {
661     CStdString window(strTest.Mid(16, strTest.GetLength() - 17).ToLower());
662     if (window.Find("xml") >= 0)
663       return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_PREVIOUS : WINDOW_PREVIOUS, 0, ConditionalStringParameter(window)));
664     int winID = g_buttonTranslator.TranslateWindowString(window.c_str());
665     if (winID != WINDOW_INVALID)
666       return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_PREVIOUS : WINDOW_PREVIOUS, winID, 0));
667   }
668   else if (strTest.Left(12).Equals("window.next("))
669   {
670     CStdString window(strTest.Mid(12, strTest.GetLength() - 13).ToLower());
671     if (window.Find("xml") >= 0)
672       return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_NEXT : WINDOW_NEXT, 0, ConditionalStringParameter(window)));
673     int winID = g_buttonTranslator.TranslateWindowString(window.c_str());
674     if (winID != WINDOW_INVALID)
675       return AddMultiInfo(GUIInfo(bNegate ? -WINDOW_NEXT : WINDOW_NEXT, winID, 0));
676   }
677   else if (strTest.Left(17).Equals("control.hasfocus("))
678   {
679     int controlID = atoi(strTest.Mid(17, strTest.GetLength() - 18).c_str());
680     if (controlID)
681       return AddMultiInfo(GUIInfo(bNegate ? -CONTROL_HAS_FOCUS : CONTROL_HAS_FOCUS, controlID, 0));
682   }
683   else if (strTest.Left(18).Equals("control.isvisible("))
684   {
685     int controlID = atoi(strTest.Mid(18, strTest.GetLength() - 19).c_str());
686     if (controlID)
687       return AddMultiInfo(GUIInfo(bNegate ? -CONTROL_IS_VISIBLE : CONTROL_IS_VISIBLE, controlID, 0));
688   }
689   else if (strTest.Left(18).Equals("control.isenabled("))
690   {
691     int controlID = atoi(strTest.Mid(18, strTest.GetLength() - 19).c_str());
692     if (controlID)
693       return AddMultiInfo(GUIInfo(bNegate ? -CONTROL_IS_ENABLED : CONTROL_IS_ENABLED, controlID, 0));
694   }
695   else if (strTest.Left(13).Equals("controlgroup("))
696   {
697     int groupID = atoi(strTest.Mid(13).c_str());
698     int controlID = 0;
699     int controlPos = strTest.Find(".hasfocus(");
700     if (controlPos > 0)
701       controlID = atoi(strTest.Mid(controlPos + 10).c_str());
702     if (groupID)
703     {
704       return AddMultiInfo(GUIInfo(bNegate ? -CONTROL_GROUP_HAS_FOCUS : CONTROL_GROUP_HAS_FOCUS, groupID, controlID));
705     }
706   }
707   else if (strTest.Left(24).Equals("buttonscroller.hasfocus("))
708   {
709     int controlID = atoi(strTest.Mid(24, strTest.GetLength() - 24).c_str());
710     if (controlID)
711       return AddMultiInfo(GUIInfo(bNegate ? -BUTTON_SCROLLER_HAS_ICON : BUTTON_SCROLLER_HAS_ICON, controlID, 0));
712   }
713
714   return bNegate ? -ret : ret;
715 }
716
717 int CGUIInfoManager::TranslateListItem(const CStdString &info)
718 {
719   if (info.Equals("thumb")) return LISTITEM_THUMB;
720   else if (info.Equals("icon")) return LISTITEM_ICON;
721   else if (info.Equals("actualicon")) return LISTITEM_ACTUAL_ICON;
722   else if (info.Equals("overlay")) return LISTITEM_OVERLAY;
723   else if (info.Equals("label")) return LISTITEM_LABEL;
724   else if (info.Equals("label2")) return LISTITEM_LABEL2;
725   else if (info.Equals("title")) return LISTITEM_TITLE;
726   else if (info.Equals("tracknumber")) return LISTITEM_TRACKNUMBER;
727   else if (info.Equals("artist")) return LISTITEM_ARTIST;
728   else if (info.Equals("album")) return LISTITEM_ALBUM;
729   else if (info.Equals("year")) return LISTITEM_YEAR;
730   else if (info.Equals("genre")) return LISTITEM_GENRE;
731   else if (info.Equals("director")) return LISTITEM_DIRECTOR;
732   else if (info.Equals("filename")) return LISTITEM_FILENAME;
733   else if (info.Equals("date")) return LISTITEM_DATE;
734   else if (info.Equals("size")) return LISTITEM_SIZE;
735   else if (info.Equals("rating")) return LISTITEM_RATING;
736   else if (info.Equals("ratingandvotes")) return LISTITEM_RATING_AND_VOTES;
737   else if (info.Equals("programcount")) return LISTITEM_PROGRAM_COUNT;
738   else if (info.Equals("duration")) return LISTITEM_DURATION;
739   else if (info.Equals("isselected")) return LISTITEM_ISSELECTED;
740   else if (info.Equals("isplaying")) return LISTITEM_ISPLAYING;
741   else if (info.Equals("plot")) return LISTITEM_PLOT;
742   else if (info.Equals("plotoutline")) return LISTITEM_PLOT_OUTLINE;
743   else if (info.Equals("episode")) return LISTITEM_EPISODE;
744   else if (info.Equals("season")) return LISTITEM_SEASON;
745   else if (info.Equals("tvshowtitle")) return LISTITEM_TVSHOW;
746   else if (info.Equals("premiered")) return LISTITEM_PREMIERED;
747   else if (info.Equals("comment")) return LISTITEM_COMMENT;
748   else if (info.Equals("path")) return LISTITEM_PATH;
749   else if (info.Equals("picturepath")) return LISTITEM_PICTURE_PATH;
750   else if (info.Equals("pictureresolution")) return LISTITEM_PICTURE_RESOLUTION;
751   else if (info.Equals("picturedatetime")) return LISTITEM_PICTURE_DATETIME;
752   else if (info.Equals("studio")) return LISTITEM_STUDIO;
753   else if (info.Equals("mpaa")) return LISTITEM_MPAA;
754   else if (info.Equals("cast")) return LISTITEM_CAST;
755   else if (info.Equals("castandrole")) return LISTITEM_CAST_AND_ROLE;
756   else if (info.Equals("writer")) return LISTITEM_WRITER;
757   else if (info.Equals("tagline")) return LISTITEM_TAGLINE;
758   else if (info.Equals("top250")) return LISTITEM_TOP250;
759   else if (info.Equals("trailer")) return LISTITEM_TRAILER;
760   else if (info.Equals("starrating")) return LISTITEM_STAR_RATING;
761   else if (info.Left(9).Equals("property(")) return AddListItemProp(info.Mid(9, info.GetLength() - 10));
762   return 0;
763 }
764
765 TIME_FORMAT CGUIInfoManager::TranslateTimeFormat(const CStdString &format)
766 {
767   if (format.IsEmpty()) return TIME_FORMAT_GUESS;
768   else if (format.Equals("(hh)")) return TIME_FORMAT_HH;
769   else if (format.Equals("(mm)")) return TIME_FORMAT_MM;
770   else if (format.Equals("(ss)")) return TIME_FORMAT_SS;
771   else if (format.Equals("(hh:mm)")) return TIME_FORMAT_HH_MM;
772   else if (format.Equals("(mm:ss)")) return TIME_FORMAT_MM_SS;
773   else if (format.Equals("(hh:mm:ss)")) return TIME_FORMAT_HH_MM_SS;
774   return TIME_FORMAT_GUESS;
775 }
776
777 CStdString CGUIInfoManager::GetLabel(int info, DWORD contextWindow)
778 {
779   CStdString strLabel;
780   if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
781     return GetMultiInfoLabel(m_multiInfo[info - MULTI_INFO_START], contextWindow);
782
783   if (info >= SLIDE_INFO_START && info <= SLIDE_INFO_END)
784     return GetPictureLabel(info);
785
786   if (info >= LISTITEM_START && info <= LISTITEM_END)
787   {
788     CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS); // true for has list items
789     if (window)
790       strLabel = GetItemLabel(window->GetCurrentListItem(), info);
791
792     return strLabel;
793   }
794
795   switch (info)
796   {
797   case WEATHER_CONDITIONS:
798     strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_COND);
799     break;
800   case WEATHER_TEMPERATURE:
801     strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_TEMP);
802     break;
803   case WEATHER_LOCATION:
804     strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_LOCATION);
805     break;
806   case SYSTEM_DATE:
807     strLabel = GetDate();
808     break;
809   case SYSTEM_LAUNCHING_XBE:
810     strLabel = m_launchingXBE;
811     break;
812   case LCD_DATE:
813     strLabel = GetDate(true);
814     break;
815   case SYSTEM_FPS:
816     strLabel.Format("%02.2f", m_fps);
817     break;
818   case PLAYER_VOLUME:
819     strLabel.Format("%2.1f dB", (float)(g_stSettings.m_nVolumeLevel + g_stSettings.m_dynamicRangeCompressionLevel) * 0.01f);
820     break;
821   case PLAYER_CHAPTER:
822     if(g_application.IsPlaying() && g_application.m_pPlayer)
823       strLabel.Format("%02d", g_application.m_pPlayer->GetChapter());
824     break;
825   case PLAYER_CHAPTERCOUNT:
826     if(g_application.IsPlaying() && g_application.m_pPlayer)
827       strLabel.Format("%02d", g_application.m_pPlayer->GetChapterCount());
828     break;
829   case PLAYER_CACHELEVEL:
830     {
831       int iLevel = 0;
832       if(g_application.IsPlaying() && ((iLevel = GetInt(PLAYER_CACHELEVEL)) >= 0))
833         strLabel.Format("%i", iLevel);
834     }
835     break;
836   case MUSICPLAYER_TITLE:
837   case MUSICPLAYER_ALBUM:
838   case MUSICPLAYER_ARTIST:
839   case MUSICPLAYER_GENRE:
840   case MUSICPLAYER_YEAR:
841   case MUSICPLAYER_TRACK_NUMBER:
842   case MUSICPLAYER_BITRATE:
843   case MUSICPLAYER_PLAYLISTLEN:
844   case MUSICPLAYER_PLAYLISTPOS:
845   case MUSICPLAYER_CHANNELS:
846   case MUSICPLAYER_BITSPERSAMPLE:
847   case MUSICPLAYER_SAMPLERATE:
848   case MUSICPLAYER_CODEC:
849   case MUSICPLAYER_DISC_NUMBER:
850   case MUSICPLAYER_RATING:
851   case MUSICPLAYER_COMMENT:
852   case MUSICPLAYER_LYRICS:
853     strLabel = GetMusicLabel(info);
854   break;
855   case VIDEOPLAYER_TITLE:
856   case VIDEOPLAYER_ORIGINALTITLE:
857   case VIDEOPLAYER_GENRE:
858   case VIDEOPLAYER_DIRECTOR:
859   case VIDEOPLAYER_YEAR:
860   case VIDEOPLAYER_PLAYLISTLEN:
861   case VIDEOPLAYER_PLAYLISTPOS:
862   case VIDEOPLAYER_PLOT:
863   case VIDEOPLAYER_PLOT_OUTLINE:
864   case VIDEOPLAYER_EPISODE:
865   case VIDEOPLAYER_SEASON:
866   case VIDEOPLAYER_RATING:
867   case VIDEOPLAYER_RATING_AND_VOTES:
868   case VIDEOPLAYER_TVSHOW:
869   case VIDEOPLAYER_PREMIERED:
870   case VIDEOPLAYER_STUDIO:
871   case VIDEOPLAYER_MPAA:
872   case VIDEOPLAYER_TOP250:
873   case VIDEOPLAYER_CAST:
874   case VIDEOPLAYER_CAST_AND_ROLE:
875   case VIDEOPLAYER_ARTIST:
876   case VIDEOPLAYER_ALBUM:
877   case VIDEOPLAYER_WRITER:
878   case VIDEOPLAYER_TAGLINE:
879   case VIDEOPLAYER_TRAILER:
880     strLabel = GetVideoLabel(info);
881   break;
882   case PLAYLIST_LENGTH:
883   case PLAYLIST_POSITION:
884   case PLAYLIST_RANDOM:
885   case PLAYLIST_REPEAT:
886     strLabel = GetPlaylistLabel(info);
887   break;
888   case MUSICPM_SONGSPLAYED:
889   case MUSICPM_MATCHINGSONGS:
890   case MUSICPM_MATCHINGSONGSPICKED:
891   case MUSICPM_MATCHINGSONGSLEFT:
892   case MUSICPM_RELAXEDSONGSPICKED:
893   case MUSICPM_RANDOMSONGSPICKED:
894     strLabel = GetMusicPartyModeLabel(info);
895   break;
896   
897   case SYSTEM_FREE_SPACE:
898   case SYSTEM_FREE_SPACE_C:
899   case SYSTEM_FREE_SPACE_E:
900   case SYSTEM_FREE_SPACE_F:
901   case SYSTEM_FREE_SPACE_G:
902   case SYSTEM_USED_SPACE:
903   case SYSTEM_USED_SPACE_C:
904   case SYSTEM_USED_SPACE_E:
905   case SYSTEM_USED_SPACE_F:
906   case SYSTEM_USED_SPACE_G:
907   case SYSTEM_TOTAL_SPACE:
908   case SYSTEM_TOTAL_SPACE_C:
909   case SYSTEM_TOTAL_SPACE_E:
910   case SYSTEM_TOTAL_SPACE_F:
911   case SYSTEM_TOTAL_SPACE_G:
912   case SYSTEM_FREE_SPACE_PERCENT:
913   case SYSTEM_FREE_SPACE_PERCENT_C:
914   case SYSTEM_FREE_SPACE_PERCENT_E:
915   case SYSTEM_FREE_SPACE_PERCENT_F:
916   case SYSTEM_FREE_SPACE_PERCENT_G:
917   case SYSTEM_USED_SPACE_PERCENT:
918   case SYSTEM_USED_SPACE_PERCENT_C:
919   case SYSTEM_USED_SPACE_PERCENT_E:
920   case SYSTEM_USED_SPACE_PERCENT_F:
921   case SYSTEM_USED_SPACE_PERCENT_G:
922   case SYSTEM_USED_SPACE_X:
923   case SYSTEM_FREE_SPACE_X:
924   case SYSTEM_TOTAL_SPACE_X:
925   case SYSTEM_USED_SPACE_Y:
926   case SYSTEM_FREE_SPACE_Y:
927   case SYSTEM_TOTAL_SPACE_Y:
928   case SYSTEM_USED_SPACE_Z:
929   case SYSTEM_FREE_SPACE_Z:
930   case SYSTEM_TOTAL_SPACE_Z:
931     return g_sysinfo.GetHddSpaceInfo(info);
932   break;
933
934   case LCD_FREE_SPACE_C:
935   case LCD_FREE_SPACE_E:
936   case LCD_FREE_SPACE_F:
937   case LCD_FREE_SPACE_G:
938     return g_sysinfo.GetHddSpaceInfo(info, true);
939     break;
940
941 #ifdef HAS_XBOX_HARDWARE
942   case SYSTEM_DVD_TRAY_STATE:
943     return g_sysinfo.GetTrayState();
944     break;
945 #endif
946
947   case SYSTEM_CPU_TEMPERATURE:
948   case SYSTEM_GPU_TEMPERATURE:
949   case SYSTEM_FAN_SPEED:
950   case LCD_CPU_TEMPERATURE:
951   case LCD_GPU_TEMPERATURE:
952   case LCD_FAN_SPEED:
953   case SYSTEM_CPU_USAGE:
954     return GetSystemHeatInfo(info);
955     break;
956
957 #ifdef HAS_XBOX_HARDWARE
958   case LCD_HDD_TEMPERATURE:
959   case SYSTEM_HDD_MODEL:
960   case SYSTEM_HDD_SERIAL:
961   case SYSTEM_HDD_FIRMWARE:
962   case SYSTEM_HDD_PASSWORD:
963   case SYSTEM_HDD_LOCKSTATE:
964   case SYSTEM_DVD_MODEL:
965   case SYSTEM_DVD_FIRMWARE:
966   case SYSTEM_HDD_TEMPERATURE:
967   case SYSTEM_XBOX_MODCHIP:
968   case SYSTEM_CPUFREQUENCY:
969   case SYSTEM_XBOX_VERSION:
970   case SYSTEM_AV_PACK_INFO:
971   case SYSTEM_VIDEO_ENCODER_INFO:
972   case NETWORK_MAC_ADDRESS:
973   case SYSTEM_XBOX_SERIAL:
974   case SYSTEM_XBE_REGION:
975   case SYSTEM_DVD_ZONE:
976   case SYSTEM_XBOX_PRODUCE_INFO:
977   case SYSTEM_XBOX_BIOS:
978   case SYSTEM_HDD_LOCKKEY:
979   case SYSTEM_HDD_CYCLECOUNT:
980   case SYSTEM_HDD_BOOTDATE:  
981   case SYSTEM_MPLAYER_VERSION:
982   case SYSTEM_KERNEL_VERSION:
983 #endif
984   case SYSTEM_INTERNET_STATE:
985   case SYSTEM_UPTIME:
986   case SYSTEM_TOTALUPTIME:
987     return g_sysinfo.GetInfo(info);
988     break;
989
990   case SYSTEM_SCREEN_RESOLUTION:
991     strLabel.Format("%s %ix%i %s %02.2f Hz.",g_localizeStrings.Get(13287),
992     g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iWidth,
993     g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iHeight,
994     g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].strMode,GetFPS());
995     return strLabel;
996     break;
997 #ifdef HAS_XBOX_HARDWARE
998   case SYSTEM_CONTROLLER_PORT_1:
999     return g_sysinfo.GetUnits(1);
1000     break;
1001   case SYSTEM_CONTROLLER_PORT_2:
1002     return g_sysinfo.GetUnits(2);
1003     break;
1004   case SYSTEM_CONTROLLER_PORT_3:
1005     return g_sysinfo.GetUnits(3);
1006     break;
1007   case SYSTEM_CONTROLLER_PORT_4:
1008     return g_sysinfo.GetUnits(4);
1009     break;
1010 #endif  
1011   case CONTAINER_FOLDERPATH:
1012     {
1013       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1014       if (window)
1015       {
1016         CURL url(((CGUIMediaWindow*)window)->CurrentDirectory().m_strPath);
1017         url.GetURLWithoutUserDetails(strLabel);
1018       }
1019       break;
1020     }
1021   case CONTAINER_VIEWMODE:
1022     {
1023       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1024       if (window)
1025       {
1026         const CGUIControl *control = window->GetControl(window->GetViewContainerID());
1027         if (control && control->IsContainer())
1028           strLabel = ((CGUIBaseContainer *)control)->GetLabel();
1029       }
1030       break;
1031     }
1032   case CONTAINER_SORT_METHOD:
1033     {
1034       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1035       if (window)
1036         strLabel = g_localizeStrings.Get(((CGUIMediaWindow*)window)->GetContainerSortMethod());
1037     }
1038     break;
1039   case CONTAINER_NUM_PAGES:
1040   case CONTAINER_CURRENT_PAGE:
1041     return GetMultiInfoLabel(GUIInfo(info), contextWindow);
1042     break;
1043   case SYSTEM_BUILD_VERSION:
1044     strLabel = GetVersion();
1045     break;
1046   case SYSTEM_BUILD_DATE:
1047     strLabel = GetBuild();
1048     break;
1049   case SYSTEM_FREE_MEMORY:
1050   case SYSTEM_FREE_MEMORY_PERCENT:
1051   case SYSTEM_USED_MEMORY:
1052   case SYSTEM_USED_MEMORY_PERCENT:
1053   case SYSTEM_TOTAL_MEMORY:
1054     {
1055       MEMORYSTATUS stat;
1056       GlobalMemoryStatus(&stat);
1057       int iMemPercentFree = 100 - ((int)( 100.0f* (stat.dwTotalPhys - stat.dwAvailPhys)/stat.dwTotalPhys + 0.5f ));
1058       int iMemPercentUsed = 100 - iMemPercentFree;
1059
1060       if (info == SYSTEM_FREE_MEMORY)
1061         strLabel.Format("%iMB", stat.dwAvailPhys /MB);      
1062       else if (info == SYSTEM_FREE_MEMORY_PERCENT)
1063         strLabel.Format("%i%%", iMemPercentFree);
1064       else if (info == SYSTEM_USED_MEMORY)
1065         strLabel.Format("%iMB", (stat.dwTotalPhys - stat.dwAvailPhys)/MB);
1066       else if (info == SYSTEM_USED_MEMORY_PERCENT)
1067         strLabel.Format("%i%%", iMemPercentUsed);
1068       else if (info == SYSTEM_TOTAL_MEMORY)
1069         strLabel.Format("%iMB", stat.dwTotalPhys/MB);
1070     }
1071     break;
1072   case SYSTEM_SCREEN_MODE:
1073     strLabel = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].strMode;
1074     break;
1075   case SYSTEM_SCREEN_WIDTH:
1076     strLabel.Format("%i", g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].iWidth);
1077     break;
1078   case SYSTEM_SCREEN_HEIGHT:
1079     strLabel.Format("%i", g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].iHeight);
1080     break;
1081   case SYSTEM_CURRENT_WINDOW:
1082     return g_localizeStrings.Get(m_gWindowManager.GetFocusedWindow());
1083     break;
1084   case SYSTEM_CURRENT_CONTROL:
1085     {
1086       CGUIWindow *window = m_gWindowManager.GetWindow(m_gWindowManager.GetFocusedWindow());
1087       if (window)
1088       {
1089         CGUIControl *control = window->GetFocusedControl();
1090         if (control)
1091           strLabel = control->GetDescription();
1092       }
1093     }
1094     break;
1095   case SYSTEM_XBOX_NICKNAME:
1096     {
1097       if (!CUtil::GetXBOXNickName(strLabel))
1098         strLabel=g_localizeStrings.Get(416); // 
1099       break;
1100     }
1101   case SYSTEM_DVD_LABEL:
1102     strLabel = CDetectDVDMedia::GetDVDLabel();
1103     break;
1104   case SYSTEM_ALARM_POS:
1105     if (g_alarmClock.GetRemaining("shutdowntimer") == 0.f)
1106       strLabel = "";
1107     else
1108     {
1109       double fTime = g_alarmClock.GetRemaining("shutdowntimer");
1110       if (fTime > 60.f)
1111         strLabel.Format("%2.0fm",g_alarmClock.GetRemaining("shutdowntimer")/60.f);
1112       else
1113         strLabel.Format("%2.0fs",g_alarmClock.GetRemaining("shutdowntimer")/60.f);
1114     }
1115     break;
1116   case SYSTEM_PROFILENAME:
1117     strLabel = g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].getName();
1118     break;
1119   case SYSTEM_LANGUAGE:
1120     strLabel = g_guiSettings.GetString("locale.language");
1121     break;
1122   case SYSTEM_PROGRESS_BAR:
1123     {
1124       int percent = GetInt(SYSTEM_PROGRESS_BAR);
1125       if (percent)
1126         strLabel.Format("%i", percent);
1127     }
1128     break;
1129   case XLINK_KAI_USERNAME:
1130     strLabel = g_guiSettings.GetString("xlinkkai.username");
1131     break;
1132   case LCD_PLAY_ICON:
1133     {
1134       int iPlaySpeed = g_application.GetPlaySpeed();
1135       if (g_application.IsPaused())
1136         strLabel.Format("\7");
1137       else if (iPlaySpeed < 1)
1138         strLabel.Format("\3:%ix", iPlaySpeed);
1139       else if (iPlaySpeed > 1)
1140         strLabel.Format("\4:%ix", iPlaySpeed);
1141       else
1142         strLabel.Format("\5");
1143     }
1144     break;
1145     
1146   case LCD_TIME_21:
1147   case LCD_TIME_22:
1148   case LCD_TIME_W21:
1149   case LCD_TIME_W22:
1150   case LCD_TIME_41:
1151   case LCD_TIME_42:
1152   case LCD_TIME_43:
1153   case LCD_TIME_44:
1154     //alternatively, set strLabel
1155     return GetLcdTime( info );
1156     break;
1157
1158   case SKIN_THEME:
1159     if (g_guiSettings.GetString("lookandfeel.skintheme").Equals("skindefault"))
1160       strLabel = g_localizeStrings.Get(15109);
1161     else
1162       strLabel = g_guiSettings.GetString("lookandfeel.skintheme");
1163     break;
1164   case SKIN_COLOUR_THEME:
1165     if (g_guiSettings.GetString("lookandfeel.skincolors").Equals("skindefault"))
1166       strLabel = g_localizeStrings.Get(15109);
1167     else
1168       strLabel = g_guiSettings.GetString("lookandfeel.skincolors");
1169     break;
1170 #ifdef HAS_LCD
1171   case LCD_PROGRESS_BAR:
1172     if (g_lcd) strLabel = g_lcd->GetProgressBar(g_application.GetTime(), g_application.GetTotalTime());
1173     break;
1174 #endif
1175   case NETWORK_IP_ADDRESS:
1176     {
1177       CStdString ip;
1178       ip.Format("%s: %s", g_localizeStrings.Get(150).c_str(), g_network.m_networkinfo.ip);
1179       return ip;
1180     }
1181     break;
1182   case NETWORK_SUBNET_ADDRESS:
1183     {
1184       CStdString subnet;
1185       subnet.Format("%s: %s", g_localizeStrings.Get(13159), g_network.m_networkinfo.subnet);
1186       return subnet;
1187     }
1188     break;
1189   case NETWORK_GATEWAY_ADDRESS:
1190     {
1191       CStdString gateway;
1192       gateway.Format("%s: %s", g_localizeStrings.Get(13160), g_network.m_networkinfo.gateway);
1193       return gateway;
1194     }
1195     break;
1196   case NETWORK_DNS1_ADDRESS:
1197     {
1198       CStdString dns;
1199       dns.Format("%s: %s", g_localizeStrings.Get(13161), g_network.m_networkinfo.DNS1);
1200       return dns;
1201     }
1202     break;
1203   case NETWORK_DNS2_ADDRESS:
1204     {
1205       CStdString dns;
1206       dns.Format("%s: %s", g_localizeStrings.Get(20307), g_network.m_networkinfo.DNS2);
1207       return dns;
1208     }
1209     break;
1210   case NETWORK_DHCP_ADDRESS:
1211     {
1212       CStdString dhcpserver;
1213       dhcpserver.Format("%s: %s", g_localizeStrings.Get(20308), g_network.m_networkinfo.dhcpserver);
1214       return dhcpserver;
1215     }
1216     break;
1217   case NETWORK_IS_DHCP:
1218     {
1219       CStdString dhcp;
1220       if(g_network.m_networkinfo.DHCP)
1221         dhcp.Format("%s %s", g_localizeStrings.Get(146), g_localizeStrings.Get(148)); // is dhcp ip
1222       else
1223         dhcp.Format("%s %s", g_localizeStrings.Get(146), g_localizeStrings.Get(147)); // is fixed ip
1224      return dhcp;
1225     }
1226     break;
1227 #ifdef HAS_XBOX_HARDWARE
1228   case NETWORK_LINK_STATE:
1229     {
1230       DWORD dwnetstatus = XNetGetEthernetLinkStatus();
1231       CStdString linkStatus = g_localizeStrings.Get(151);
1232       linkStatus += " ";
1233       if (dwnetstatus & XNET_ETHERNET_LINK_ACTIVE)
1234       {
1235         if (dwnetstatus & XNET_ETHERNET_LINK_100MBPS)
1236           linkStatus += "100mbps ";
1237         if (dwnetstatus & XNET_ETHERNET_LINK_10MBPS)
1238           linkStatus += "10mbps ";
1239         if (dwnetstatus & XNET_ETHERNET_LINK_FULL_DUPLEX)
1240           linkStatus += g_localizeStrings.Get(153);
1241         if (dwnetstatus & XNET_ETHERNET_LINK_HALF_DUPLEX)
1242           linkStatus += g_localizeStrings.Get(152);
1243       }
1244       else
1245         linkStatus += g_localizeStrings.Get(159);
1246       return linkStatus;
1247     }
1248     break;
1249 #endif
1250   case AUDIOSCROBBLER_CONN_STATE:
1251   case AUDIOSCROBBLER_SUBMIT_INT:
1252   case AUDIOSCROBBLER_FILES_CACHED:
1253   case AUDIOSCROBBLER_SUBMIT_STATE:
1254     strLabel=GetAudioScrobblerLabel(info);
1255     break;
1256   case VISUALISATION_PRESET:
1257     {
1258       CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
1259       g_graphicsContext.SendMessage(msg);
1260       if (msg.GetLPVOID())
1261       {
1262         CVisualisation *pVis = (CVisualisation *)msg.GetLPVOID();
1263         char *preset = pVis->GetPreset();
1264         if (preset)
1265         {
1266           strLabel = preset;
1267           CUtil::RemoveExtension(strLabel);
1268         }
1269       }
1270     }
1271     break;
1272   case VISUALISATION_NAME:
1273     {
1274       strLabel = g_guiSettings.GetString("mymusic.visualisation");
1275       if (strLabel != "None" && strLabel.size() > 4)
1276       { // make it look pretty
1277         strLabel = strLabel.Left(strLabel.size() - 4);
1278         strLabel[0] = toupper(strLabel[0]);
1279       }
1280     }
1281     break;
1282   case FANART_COLOR1:
1283     {
1284       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1285       if (window)
1286         return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color1");
1287     }
1288     break;
1289   case FANART_COLOR2:
1290     {
1291       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1292       if (window)
1293         return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color2");
1294     }
1295     break;
1296   case FANART_COLOR3:
1297     {
1298       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1299       if (window)
1300         return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color3");
1301     }
1302     break;
1303   case FANART_IMAGE:
1304     {
1305       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1306       if (window)
1307         return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_image");
1308     }
1309     break;
1310   }
1311
1312   return strLabel;
1313 }
1314
1315 // tries to get a integer value for use in progressbars/sliders and such
1316 int CGUIInfoManager::GetInt(int info, DWORD contextWindow) const
1317 {
1318   switch( info )
1319   {
1320     case PLAYER_VOLUME:
1321       return g_application.GetVolume();
1322     case PLAYER_PROGRESS:
1323     case PLAYER_SEEKBAR:
1324     case PLAYER_CACHELEVEL:
1325     case PLAYER_CHAPTER:
1326     case PLAYER_CHAPTERCOUNT:
1327       {
1328         if( g_application.IsPlaying() && g_application.m_pPlayer)
1329         {
1330           switch( info )
1331           {
1332           case PLAYER_PROGRESS:
1333             return (int)(g_application.GetPercentage());
1334           case PLAYER_SEEKBAR:
1335             {
1336               CGUIDialogSeekBar *seekBar = (CGUIDialogSeekBar*)m_gWindowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
1337               return seekBar ? (int)seekBar->GetPercentage() : 0;
1338             }
1339           case PLAYER_CACHELEVEL:
1340             return (int)(g_application.m_pPlayer->GetCacheLevel());
1341           case PLAYER_CHAPTER:
1342             return g_application.m_pPlayer->GetChapter();
1343           case PLAYER_CHAPTERCOUNT:
1344             return g_application.m_pPlayer->GetChapterCount();
1345           }
1346         }
1347       }
1348       break;
1349     case SYSTEM_FREE_MEMORY:
1350     case SYSTEM_USED_MEMORY:
1351       {
1352         MEMORYSTATUS stat;
1353         GlobalMemoryStatus(&stat);
1354         int memPercentUsed = (int)( 100.0f* (stat.dwTotalPhys - stat.dwAvailPhys)/stat.dwTotalPhys + 0.5f );
1355         if (info == SYSTEM_FREE_MEMORY)
1356           return 100 - memPercentUsed;
1357         return memPercentUsed;
1358       }
1359     case SYSTEM_PROGRESS_BAR:
1360       {
1361         CGUIDialogProgress *bar = (CGUIDialogProgress *)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
1362         if (bar && bar->IsDialogRunning())
1363           return bar->GetPercentage();
1364       }
1365 #ifdef HAS_XBOX_HARDWARE
1366     case SYSTEM_HDD_TEMPERATURE:
1367       return atoi(g_sysinfo.GetInfo(LCD_HDD_TEMPERATURE));
1368     case SYSTEM_CPU_TEMPERATURE:
1369       return atoi(CFanController::Instance()->GetCPUTemp().ToString());
1370     case SYSTEM_GPU_TEMPERATURE:
1371       return atoi(CFanController::Instance()->GetGPUTemp().ToString());
1372     case SYSTEM_FAN_SPEED:
1373       return CFanController::Instance()->GetFanSpeed() * 2;
1374 #endif
1375     case SYSTEM_FREE_SPACE:
1376     case SYSTEM_FREE_SPACE_C:
1377     case SYSTEM_FREE_SPACE_E:
1378     case SYSTEM_FREE_SPACE_F:
1379     case SYSTEM_FREE_SPACE_G:
1380     case SYSTEM_USED_SPACE:
1381     case SYSTEM_USED_SPACE_C:
1382     case SYSTEM_USED_SPACE_E:
1383     case SYSTEM_USED_SPACE_F:
1384     case SYSTEM_USED_SPACE_G:
1385     case SYSTEM_FREE_SPACE_X:
1386     case SYSTEM_USED_SPACE_X:
1387     case SYSTEM_FREE_SPACE_Y:
1388     case SYSTEM_USED_SPACE_Y:
1389     case SYSTEM_FREE_SPACE_Z:
1390     case SYSTEM_USED_SPACE_Z:
1391       {
1392         int ret = 0;
1393         g_sysinfo.GetHddSpaceInfo(ret, info, true);
1394         return ret;
1395       }
1396     case SYSTEM_CPU_USAGE:
1397       return 100 - ((int)(100.0f *g_application.m_idleThread.GetRelativeUsage()));
1398   }
1399   return 0;
1400 }
1401 // checks the condition and returns it as necessary.  Currently used
1402 // for toggle button controls and visibility of images.
1403 bool CGUIInfoManager::GetBool(int condition1, DWORD dwContextWindow, const CGUIListItem *item)
1404 {
1405   // check our cache
1406   bool bReturn = false;
1407   if (!item && IsCached(condition1, dwContextWindow, bReturn)) // never use cache for list items
1408     return bReturn;
1409
1410   int condition = abs(condition1);
1411
1412   if(condition >= COMBINED_VALUES_START && (condition - COMBINED_VALUES_START) < (int)(m_CombinedValues.size()) )
1413   {
1414     const CCombinedValue &comb = m_CombinedValues[condition - COMBINED_VALUES_START];
1415     if (!EvaluateBooleanExpression(comb, bReturn, dwContextWindow, item))
1416       bReturn = false;
1417   }
1418   else if (item && condition >= LISTITEM_START && condition < LISTITEM_END)
1419     bReturn = GetItemBool(item, condition);
1420   // Ethernet Link state checking
1421   // Will check if the Xbox has a Ethernet Link connection! [Cable in!]
1422   // This can used for the skinner to switch off Network or Inter required functions
1423   else if ( condition == SYSTEM_ALWAYS_TRUE)
1424     bReturn = true;
1425   else if (condition == SYSTEM_ALWAYS_FALSE)
1426     bReturn = false;
1427   else if (condition == SYSTEM_ETHERNET_LINK_ACTIVE)
1428 #ifdef HAS_XBOX_NETWORK
1429     bReturn = (XNetGetEthernetLinkStatus() & XNET_ETHERNET_LINK_ACTIVE);
1430 #else
1431     bReturn = true;
1432 #endif
1433   else if (condition > SYSTEM_IDLE_TIME_START && condition <= SYSTEM_IDLE_TIME_FINISH)
1434     bReturn = (g_application.GlobalIdleTime() >= condition - SYSTEM_IDLE_TIME_START);
1435   else if (condition == WINDOW_IS_MEDIA)
1436   { // note: This doesn't return true for dialogs (content, favourites, login, videoinfo)
1437     CGUIWindow *pWindow = m_gWindowManager.GetWindow(m_gWindowManager.GetActiveWindow());
1438     bReturn = (pWindow && pWindow->IsMediaWindow());
1439   }
1440   else if (condition == PLAYER_MUTED)
1441     bReturn = g_stSettings.m_bMute;
1442   else if (condition == LIBRARY_HAS_MUSIC)
1443   {
1444     CMusicDatabase database;
1445     database.Open();
1446     bReturn = (database.GetSongsCount() > 0);
1447     database.Close();
1448     if (condition1 < 0) bReturn = !bReturn;
1449     CacheBool(condition1,dwContextWindow,bReturn,true);
1450   }
1451   else if (condition >= LIBRARY_HAS_VIDEO &&
1452       condition <= LIBRARY_HAS_MUSICVIDEOS)
1453   {
1454     CVideoDatabase database;
1455     database.Open();
1456     switch (condition)
1457     {
1458       case LIBRARY_HAS_VIDEO:
1459         bReturn = (database.GetItemCount() > 0);
1460         break;
1461       case LIBRARY_HAS_MOVIES:
1462         bReturn = (database.GetMovieCount() > 0);
1463         break;
1464       case LIBRARY_HAS_TVSHOWS:
1465         bReturn = (database.GetTvShowCount() > 0);
1466         break;
1467       case LIBRARY_HAS_MUSICVIDEOS:
1468         bReturn = (database.GetMusicVideoCount() > 0);
1469         break;
1470       default: // should never get here
1471         bReturn = false;
1472     }
1473     database.Close();
1474     // persistently cache return value
1475     if (condition1 < 0) bReturn = !bReturn;
1476     CacheBool(condition1,dwContextWindow,bReturn,true);
1477   }
1478   else if (condition == SYSTEM_KAI_CONNECTED)
1479     bReturn = g_network.IsAvailable(false) && g_guiSettings.GetBool("xlinkkai.enabled") && CKaiClient::GetInstance()->IsEngineConnected();
1480   else if (condition == SYSTEM_KAI_ENABLED)
1481     bReturn = g_network.IsAvailable(false) && g_guiSettings.GetBool("xlinkkai.enabled");
1482   else if (condition == SYSTEM_PLATFORM_LINUX)
1483     bReturn = false;
1484   else if (condition == SYSTEM_PLATFORM_WINDOWS)
1485 #ifdef WIN32
1486     bReturn = true;
1487 #else
1488     bReturn = false;
1489 #endif
1490   else if (condition == SYSTEM_PLATFORM_XBOX)
1491 #ifdef HAS_XBOX_HARDWARE
1492     bReturn = true;
1493 #else
1494     bReturn = false;
1495 #endif
1496   else if (condition == SYSTEM_MEDIA_DVD)
1497   {
1498     // we must: 1.  Check tray state.
1499     //          2.  Check that we actually have a disc in the drive (detection
1500     //              of disk type takes a while from a separate thread).
1501
1502     int iTrayState = CIoSupport::GetTrayState();
1503     if ( iTrayState == DRIVE_CLOSED_MEDIA_PRESENT || iTrayState == TRAY_CLOSED_MEDIA_PRESENT )
1504       bReturn = CDetectDVDMedia::IsDiscInDrive();
1505     else 
1506       bReturn = false;
1507   }
1508   else if (condition == SYSTEM_HAS_DRIVE_F)
1509     bReturn = CIoSupport::DriveExists('F');
1510   else if (condition == SYSTEM_HAS_DRIVE_G)
1511     bReturn = CIoSupport::DriveExists('G');
1512   else if (condition == SYSTEM_DVDREADY)
1513     bReturn = CDetectDVDMedia::DriveReady() != DRIVE_NOT_READY;
1514   else if (condition == SYSTEM_TRAYOPEN)
1515     bReturn = CDetectDVDMedia::DriveReady() == DRIVE_OPEN;
1516   else if (condition == PLAYER_SHOWINFO)
1517     bReturn = m_playerShowInfo;
1518   else if (condition == PLAYER_SHOWCODEC)
1519     bReturn = m_playerShowCodec;
1520   else if (condition >= SKIN_HAS_THEME_START && condition <= SKIN_HAS_THEME_END)
1521   { // Note that the code used here could probably be extended to general
1522     // settings conditions (parameter would need to store both the setting name an
1523     // the and the comparison string)
1524     CStdString theme = g_guiSettings.GetString("lookandfeel.skintheme");
1525     theme.ToLower();
1526     CUtil::RemoveExtension(theme);
1527     bReturn = theme.Equals(m_stringParameters[condition - SKIN_HAS_THEME_START]);
1528   }
1529   else if (condition >= MULTI_INFO_START && condition <= MULTI_INFO_END)
1530   {
1531     // cache return value
1532     bool result = GetMultiInfoBool(m_multiInfo[condition - MULTI_INFO_START], dwContextWindow, item);
1533     if (!item)
1534       CacheBool(condition1, dwContextWindow, result);
1535     return result;
1536   }
1537   else if (condition == SYSTEM_HASLOCKS)  
1538     bReturn = g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE;
1539   else if (condition == SYSTEM_ISMASTER)
1540     bReturn = g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && g_passwordManager.bMasterUser;
1541   else if (condition == SYSTEM_LOGGEDON)
1542     bReturn = !(m_gWindowManager.GetActiveWindow() == WINDOW_LOGIN_SCREEN);
1543   else if (condition == SYSTEM_HAS_LOGINSCREEN)
1544     bReturn = g_settings.bUseLoginScreen;
1545   else if (condition == WEATHER_IS_FETCHED)
1546     bReturn = g_weatherManager.IsFetched();
1547   else if (condition == SYSTEM_INTERNET_STATE)
1548   {
1549     g_sysinfo.GetInfo(condition);
1550     bReturn = g_sysinfo.m_bInternetState;
1551   }
1552   else if (condition == SKIN_HAS_VIDEO_OVERLAY)
1553   {
1554     bReturn = !g_application.IsInScreenSaver() && m_gWindowManager.IsOverlayAllowed() &&
1555               g_application.IsPlayingVideo() && m_gWindowManager.GetActiveWindow() != WINDOW_FULLSCREEN_VIDEO;
1556   }
1557   else if (condition == SKIN_HAS_MUSIC_OVERLAY)
1558   {
1559     bReturn = !g_application.IsInScreenSaver() && m_gWindowManager.IsOverlayAllowed() &&
1560               g_application.IsPlayingAudio();
1561   }
1562   else if (condition == CONTAINER_HAS_THUMB)
1563   {
1564     CGUIWindow *pWindow = GetWindowWithCondition(dwContextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1565     if (pWindow)
1566       bReturn = ((CGUIMediaWindow*)pWindow)->CurrentDirectory().HasThumbnail();
1567   }
1568   else if (condition == VIDEOPLAYER_HAS_INFO)
1569     bReturn = m_currentFile.HasVideoInfoTag();
1570   else if (condition == CONTAINER_ON_NEXT || condition == CONTAINER_ON_PREVIOUS)
1571   {
1572     // no parameters, so we assume it's just requested for a media window.  It therefore
1573     // can only happen if the list has focus.
1574     CGUIWindow *pWindow = GetWindowWithCondition(dwContextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1575     if (pWindow)
1576     {
1577       map<int,int>::const_iterator it = m_containerMoves.find(pWindow->GetViewContainerID());
1578       if (it != m_containerMoves.end())
1579         bReturn = condition == CONTAINER_ON_NEXT ? it->second > 0 : it->second < 0;
1580     }
1581   }
1582   else if (g_application.IsPlaying())
1583   {
1584     switch (condition)
1585     {
1586     case PLAYER_HAS_MEDIA:
1587       bReturn = true;
1588       break;
1589     case PLAYER_HAS_AUDIO:
1590       bReturn = g_application.IsPlayingAudio();
1591       break;
1592     case PLAYER_HAS_VIDEO:
1593       bReturn = g_application.IsPlayingVideo();
1594       break;
1595     case PLAYER_PLAYING:
1596       bReturn = !g_application.IsPaused() && (g_application.GetPlaySpeed() == 1);
1597       break;
1598     case PLAYER_PAUSED:
1599       bReturn = g_application.IsPaused();
1600       break;
1601     case PLAYER_REWINDING:
1602       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() < 1;
1603       break;
1604     case PLAYER_FORWARDING:
1605       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() > 1;
1606       break;
1607     case PLAYER_REWINDING_2x:
1608       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -2;
1609       break;
1610     case PLAYER_REWINDING_4x:
1611       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -4;
1612       break;
1613     case PLAYER_REWINDING_8x:
1614       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -8;
1615       break;
1616     case PLAYER_REWINDING_16x:
1617       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -16;
1618       break;
1619     case PLAYER_REWINDING_32x:
1620       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -32;
1621       break;
1622     case PLAYER_FORWARDING_2x:
1623       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 2;
1624       break;
1625     case PLAYER_FORWARDING_4x:
1626       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 4;
1627       break;
1628     case PLAYER_FORWARDING_8x:
1629       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 8;
1630       break;
1631     case PLAYER_FORWARDING_16x:
1632       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 16;
1633       break;
1634     case PLAYER_FORWARDING_32x:
1635       bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 32;
1636       break;
1637     case PLAYER_CAN_RECORD:
1638       bReturn = g_application.m_pPlayer->CanRecord();
1639       break;
1640     case PLAYER_RECORDING:
1641       bReturn = g_application.m_pPlayer->IsRecording();
1642     break;
1643     case PLAYER_DISPLAY_AFTER_SEEK:
1644       bReturn = GetDisplayAfterSeek();
1645     break;
1646     case PLAYER_CACHING:
1647       bReturn = g_application.m_pPlayer->IsCaching();
1648     break;
1649     case PLAYER_SEEKBAR:
1650       {
1651         CGUIDialogSeekBar *seekBar = (CGUIDialogSeekBar*)m_gWindowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
1652         bReturn = seekBar ? seekBar->IsDialogRunning() : false;
1653       }
1654     break;
1655     case PLAYER_SEEKING:
1656       bReturn = m_playerSeeking;
1657     break;
1658     case PLAYER_SHOWTIME:
1659       bReturn = m_playerShowTime;
1660     break;
1661     case MUSICPM_ENABLED:
1662       bReturn = g_partyModeManager.IsEnabled();
1663     break;
1664     case AUDIOSCROBBLER_ENABLED:
1665       bReturn = CLastFmManager::GetInstance()->IsLastFmEnabled();
1666     break;
1667     case LASTFM_RADIOPLAYING:
1668       bReturn = CLastFmManager::GetInstance()->IsRadioEnabled();
1669       break;
1670     case LASTFM_CANLOVE:
1671       bReturn = CLastFmManager::GetInstance()->CanLove();
1672       break;
1673     case LASTFM_CANBAN:
1674       bReturn = CLastFmManager::GetInstance()->CanBan();
1675       break;
1676     case VIDEOPLAYER_USING_OVERLAYS:
1677       bReturn = (g_guiSettings.GetInt("videoplayer.rendermethod") == RENDER_OVERLAYS);
1678     break;
1679     case VIDEOPLAYER_ISFULLSCREEN:
1680       bReturn = m_gWindowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO;
1681     break;
1682     case VIDEOPLAYER_HASMENU:
1683       bReturn = g_application.m_pPlayer->HasMenu();
1684     break;
1685     case PLAYLIST_ISRANDOM:
1686       bReturn = g_playlistPlayer.IsShuffled(g_playlistPlayer.GetCurrentPlaylist());
1687     break;
1688     case PLAYLIST_ISREPEAT:
1689       bReturn = g_playlistPlayer.GetRepeat(g_playlistPlayer.GetCurrentPlaylist()) == PLAYLIST::REPEAT_ALL;
1690     break;
1691     case PLAYLIST_ISREPEATONE:
1692       bReturn = g_playlistPlayer.GetRepeat(g_playlistPlayer.GetCurrentPlaylist()) == PLAYLIST::REPEAT_ONE;
1693     break;
1694     case PLAYER_HASDURATION:
1695       bReturn = g_application.GetTotalTime() > 0;
1696       break;
1697     case VISUALISATION_LOCKED:
1698       {
1699         CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
1700         g_graphicsContext.SendMessage(msg);
1701         if (msg.GetLPVOID())
1702         {
1703           CVisualisation *pVis = (CVisualisation *)msg.GetLPVOID();
1704           bReturn = pVis->IsLocked();
1705         }
1706       }
1707     break;
1708     case VISUALISATION_ENABLED:
1709       bReturn = g_guiSettings.GetString("mymusic.visualisation") != "None";
1710     break;
1711     default: // default, use integer value different from 0 as true
1712       bReturn = GetInt(condition) != 0;
1713     }
1714   }
1715   // cache return value
1716   if (condition1 < 0) bReturn = !bReturn;
1717   
1718   if (!item) // don't cache item properties
1719     CacheBool(condition1, dwContextWindow, bReturn);
1720
1721   return bReturn;
1722 }
1723
1724 /// \brief Examines the multi information sent and returns true or false accordingly.
1725 bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, DWORD dwContextWindow, const CGUIListItem *item)
1726 {
1727   bool bReturn = false;
1728   int condition = abs(info.m_info);
1729   switch (condition)
1730   {
1731     case SKIN_BOOL:
1732       {
1733         bReturn = g_settings.GetSkinBool(info.m_data1);
1734       }
1735       break;
1736     case SKIN_STRING:
1737       {
1738         if (info.m_data2)
1739           bReturn = g_settings.GetSkinString(info.m_data1).Equals(m_stringParameters[info.m_data2]);
1740         else
1741           bReturn = !g_settings.GetSkinString(info.m_data1).IsEmpty();
1742       }
1743       break;
1744     case STRING_IS_EMPTY:
1745       // note: Get*Image() falls back to Get*Label(), so this should cover all of them
1746       if (item && item->IsFileItem() && info.m_data1 >= LISTITEM_START && info.m_data1 < LISTITEM_END)
1747         bReturn = GetItemImage((CFileItem *)item, info.m_data1).IsEmpty();
1748       else
1749         bReturn = GetImage(info.m_data1, dwContextWindow).IsEmpty();
1750       break;
1751     case CONTROL_GROUP_HAS_FOCUS:
1752       {
1753         CGUIWindow *window = GetWindowWithCondition(dwContextWindow, 0);
1754         if (window) 
1755           bReturn = window->ControlGroupHasFocus(info.m_data1, info.m_data2);
1756       }
1757       break;
1758     case CONTROL_IS_VISIBLE:
1759       {
1760         CGUIWindow *window = GetWindowWithCondition(dwContextWindow, 0);
1761         if (window) 
1762         {
1763           // Note: This'll only work for unique id's
1764           const CGUIControl *control = window->GetControl(info.m_data1);
1765           if (control)
1766             bReturn = control->IsVisible();
1767         }
1768       }
1769       break;
1770     case CONTROL_IS_ENABLED:
1771       {
1772         CGUIWindow *window = GetWindowWithCondition(dwContextWindow, 0);
1773         if (window) 
1774         {
1775           // Note: This'll only work for unique id's
1776           const CGUIControl *control = window->GetControl(info.m_data1);
1777           if (control)
1778             bReturn = !control->IsDisabled();
1779         }
1780       }
1781       break;
1782     case CONTROL_HAS_FOCUS:
1783       {
1784         CGUIWindow *window = GetWindowWithCondition(dwContextWindow, 0);
1785         if (window) 
1786           bReturn = (window->GetFocusedControlID() == info.m_data1);
1787       }
1788       break;
1789     case BUTTON_SCROLLER_HAS_ICON:
1790       {
1791         CGUIWindow *window = GetWindowWithCondition(dwContextWindow, 0);
1792         if (window) 
1793         {
1794           CGUIControl *pControl = window->GetFocusedControl();
1795           if (pControl && pControl->GetControlType() == CGUIControl::GUICONTROL_BUTTONBAR)
1796             bReturn = ((CGUIButtonScroller *)pControl)->GetActiveButtonID() == info.m_data1;
1797         }
1798       }
1799       break;
1800     case WINDOW_NEXT:
1801       if (info.m_data1)
1802         bReturn = (info.m_data1 == m_nextWindowID);
1803       else
1804       {
1805         CGUIWindow *window = m_gWindowManager.GetWindow(m_nextWindowID);
1806         if (window && CUtil::GetFileName(window->GetXMLFile()).Equals(m_stringParameters[info.m_data2]))
1807           bReturn = true;
1808       }
1809       break;
1810     case WINDOW_PREVIOUS:
1811       if (info.m_data1)
1812         bReturn = (info.m_data1 == m_prevWindowID);
1813       else
1814       {
1815         CGUIWindow *window = m_gWindowManager.GetWindow(m_prevWindowID);
1816         if (window && CUtil::GetFileName(window->GetXMLFile()).Equals(m_stringParameters[info.m_data2]))
1817           bReturn = true;
1818       }
1819       break;
1820     case WINDOW_IS_VISIBLE:
1821       if (info.m_data1)
1822         bReturn = m_gWindowManager.IsWindowVisible(info.m_data1);
1823       else
1824         bReturn = m_gWindowManager.IsWindowVisible(m_stringParameters[info.m_data2]);
1825       break;
1826     case WINDOW_IS_TOPMOST:
1827       if (info.m_data1)
1828         bReturn = m_gWindowManager.IsWindowTopMost(info.m_data1);
1829       else
1830         bReturn = m_gWindowManager.IsWindowTopMost(m_stringParameters[info.m_data2]);
1831       break;
1832     case WINDOW_IS_ACTIVE:
1833       if (info.m_data1)
1834         bReturn = m_gWindowManager.IsWindowActive(info.m_data1);
1835       else
1836         bReturn = m_gWindowManager.IsWindowActive(m_stringParameters[info.m_data2]);
1837       break;
1838     case SYSTEM_HAS_ALARM:
1839       bReturn = g_alarmClock.hasAlarm(m_stringParameters[info.m_data1]);
1840       break;
1841     case SYSTEM_GET_BOOL:
1842       bReturn = g_guiSettings.GetBool(m_stringParameters[info.m_data1]);
1843       break;
1844     case CONTAINER_CONTENT:
1845       bReturn = m_stringParameters[info.m_data1].Equals(m_content);
1846       break;
1847     case CONTAINER_ON_NEXT:
1848     case CONTAINER_ON_PREVIOUS:
1849       {
1850         map<int,int>::const_iterator it = m_containerMoves.find(info.m_data1);
1851         if (it != m_containerMoves.end())
1852           bReturn = condition == CONTAINER_ON_NEXT ? it->second > 0 : it->second < 0;
1853       }
1854       break;
1855     case CONTAINER_ROW:
1856     case CONTAINER_COLUMN:
1857     case CONTAINER_POSITION:
1858     case CONTAINER_HAS_NEXT:
1859     case CONTAINER_HAS_PREVIOUS:
1860     case CONTAINER_SUBITEM:
1861       {
1862         const CGUIControl *control = NULL;
1863         if (info.m_data1)
1864         { // container specified
1865           CGUIWindow *window = GetWindowWithCondition(dwContextWindow, 0);
1866           if (window)
1867             control = window->GetControl(info.m_data1);
1868         }
1869         else
1870         { // no container specified - assume a mediawindow
1871           CGUIWindow *window = GetWindowWithCondition(dwContextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1872           if (window)
1873             control = window->GetControl(window->GetViewContainerID());
1874         }
1875         if (control)
1876           bReturn = control->GetCondition(info.m_info, info.m_data2);
1877       }
1878       break;
1879     case CONTAINER_HAS_FOCUS:
1880       { // grab our container
1881         CGUIWindow *window = GetWindowWithCondition(dwContextWindow, 0);
1882         if (window)
1883         {
1884           const CGUIControl *control = window->GetControl(info.m_data1);
1885           if (control && control->IsContainer())
1886           {
1887             CFileItem *item = (CFileItem *)((CGUIBaseContainer *)control)->GetListItem(0);
1888             if (item && item->m_iprogramCount == info.m_data2)  // programcount used to store item id
1889               bReturn = true;
1890           }
1891         }
1892         break;
1893       }
1894     case LISTITEM_ISSELECTED:
1895     case LISTITEM_ISPLAYING:
1896       {
1897         CFileItem *item=NULL;
1898         if (!info.m_data1)
1899         { // assumes a media window
1900           CGUIWindow *window = GetWindowWithCondition(dwContextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
1901           if (window)
1902             item = window->GetCurrentListItem(info.m_data2);
1903         }
1904         else
1905         {
1906           CGUIWindow *window = GetWindowWithCondition(dwContextWindow, 0);
1907           if (window)
1908           {
1909             const CGUIControl *control = window->GetControl(info.m_data1);
1910             if (control && control->IsContainer())
1911               item = (CFileItem *)((CGUIBaseContainer *)control)->GetListItem(info.m_data2);
1912           }
1913         }
1914         if (item)
1915           bReturn = GetBool(info.m_info, dwContextWindow, item);
1916       }
1917       break;
1918     case VIDEOPLAYER_CONTENT:
1919       {
1920         CStdString strContent="movies";
1921         if (!m_currentFile.HasVideoInfoTag())
1922           strContent = "files";
1923         if (m_currentFile.HasVideoInfoTag() && m_currentFile.GetVideoInfoTag()->m_iSeason > -1) // episode
1924           strContent = "episodes";
1925         if (m_currentFile.HasVideoInfoTag() && m_currentFile.GetVideoInfoTag()->m_artist.size() > 0)
1926           strContent = "musicvideos";
1927         if (m_currentFile.HasVideoInfoTag() && m_currentFile.GetVideoInfoTag()->m_strStatus == "livetv")
1928           strContent = "livetv";
1929         bReturn = m_stringParameters[info.m_data1].Equals(strContent);
1930       }
1931       break;
1932     case CONTAINER_SORT_METHOD:
1933     {
1934       CGUIWindow *window = GetWindowWithCondition(dwContextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1935       if (window)
1936       {
1937         const CFileItemList &item = ((CGUIMediaWindow*)window)->CurrentDirectory();
1938         SORT_METHOD method = item.GetSortMethod();
1939         bReturn = (method == info.m_data1);
1940       }
1941       break;
1942     }
1943     case SYSTEM_DATE:
1944       {
1945         CDateTime date = CDateTime::GetCurrentDateTime();
1946         int currentDate = date.GetMonth()*100+date.GetDay();
1947         int startDate = info.m_data1;
1948         int stopDate = info.m_data2;
1949
1950         if (stopDate < startDate)
1951           bReturn = currentDate >= startDate || currentDate < stopDate;
1952         else
1953           bReturn = currentDate >= startDate && currentDate < stopDate;
1954       }
1955       break;
1956     case SYSTEM_TIME:
1957       {
1958         CDateTime time=CDateTime::GetCurrentDateTime();
1959         int currentTime = time.GetMinuteOfDay();
1960         int startTime = info.m_data1;
1961         int stopTime = info.m_data2;
1962
1963         if (stopTime < startTime)
1964           bReturn = currentTime >= startTime || currentTime < stopTime;
1965         else
1966           bReturn = currentTime >= startTime && currentTime < stopTime;
1967       }
1968       break;
1969   }
1970   return (info.m_info < 0) ? !bReturn : bReturn;
1971 }
1972
1973 /// \brief Examines the multi information sent and returns the string as appropriate
1974 CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, DWORD contextWindow) const
1975 {
1976   if (info.m_info == SKIN_STRING)
1977   {
1978     return g_settings.GetSkinString(info.m_data1);
1979   }
1980   else if (info.m_info == SKIN_BOOL)
1981   {
1982     bool bInfo = g_settings.GetSkinBool(info.m_data1);
1983     if (bInfo)
1984       return g_localizeStrings.Get(20122);
1985   }
1986   if (info.m_info >= LISTITEM_START && info.m_info <= LISTITEM_END)
1987   {
1988     CFileItem *item = NULL;
1989     if (!info.m_data1)
1990     { // no id given, must be a media window
1991       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
1992       if (window)
1993         item = window->GetCurrentListItem(info.m_data2);
1994     }
1995     else
1996     {
1997       CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
1998       if (window)
1999       {
2000         const CGUIControl *control = window->GetControl(info.m_data1);
2001         if (control && control->IsContainer())
2002           item = (CFileItem *)((CGUIBaseContainer *)control)->GetListItem(info.m_data2);
2003       }
2004     }
2005     if (item)
2006       return GetItemImage(item, info.m_info); // Image prioritizes images over labels (in the case of music item ratings for instance)
2007   }
2008   else if (info.m_info == PLAYER_TIME)
2009   {
2010     return GetCurrentPlayTime((TIME_FORMAT)info.m_data1);
2011   }
2012   else if (info.m_info == PLAYER_TIME_REMAINING)
2013   {
2014     return GetCurrentPlayTimeRemaining((TIME_FORMAT)info.m_data1);
2015   }
2016   else if (info.m_info == PLAYER_FINISH_TIME)
2017   {
2018     CDateTime time = CDateTime::GetCurrentDateTime();
2019     time += CDateTimeSpan(0, 0, 0, GetPlayTimeRemaining());
2020     return LocalizeTime(time, (TIME_FORMAT)info.m_data1);
2021   }
2022   else if (info.m_info == PLAYER_TIME_SPEED)
2023   {
2024     CStdString strTime;
2025     if (g_application.GetPlaySpeed() != 1)
2026       strTime.Format("%s (%ix)", GetCurrentPlayTime((TIME_FORMAT)info.m_data1).c_str(), g_application.GetPlaySpeed());
2027     else
2028       strTime = GetCurrentPlayTime();
2029     return strTime;
2030   }
2031   else if (info.m_info == PLAYER_DURATION)
2032   {
2033     return GetDuration((TIME_FORMAT)info.m_data1);
2034   }
2035   else if (info.m_info == PLAYER_SEEKTIME)
2036   {
2037     TIME_FORMAT format = (TIME_FORMAT)info.m_data1;
2038     if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
2039       format = TIME_FORMAT_HH_MM_SS;
2040     CGUIDialogSeekBar *seekBar = (CGUIDialogSeekBar*)m_gWindowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
2041     if (seekBar)
2042       return seekBar->GetSeekTimeLabel(format);
2043   }
2044   else if (info.m_info == SYSTEM_TIME)
2045   {
2046     return GetTime((TIME_FORMAT)info.m_data1);
2047   }
2048   else if (info.m_info == CONTAINER_NUM_PAGES || info.m_info == CONTAINER_CURRENT_PAGE)
2049   {
2050     const CGUIControl *control = NULL;
2051     if (info.m_data1)
2052     { // container specified
2053       CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2054       if (window)
2055         control = window->GetControl(info.m_data1);
2056     }
2057     else
2058     { // no container specified - assume a mediawindow
2059       CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2060       if (window)
2061         control = window->GetControl(window->GetViewContainerID());
2062     }
2063     if (control && control->IsContainer())
2064     {
2065       CStdString strNum;
2066       if (info.m_info == CONTAINER_NUM_PAGES)
2067         strNum.Format("%u", ((CGUIBaseContainer *)control)->GetNumPages());
2068       else
2069         strNum.Format("%u", ((CGUIBaseContainer *)control)->GetCurrentPage());
2070       return strNum;
2071     }
2072   }
2073   return StringUtils::EmptyString;
2074 }
2075
2076 /// \brief Obtains the filename of the image to show from whichever subsystem is needed
2077 CStdString CGUIInfoManager::GetImage(int info, DWORD contextWindow)
2078 {
2079   if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
2080   {
2081     return GetMultiInfoLabel(m_multiInfo[info - MULTI_INFO_START], contextWindow);
2082   }
2083   else if (info == WEATHER_CONDITIONS)
2084     return g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON);
2085   else if (info == SYSTEM_PROFILETHUMB)
2086   {
2087     CStdString thumb = g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].getThumb();
2088     if (thumb.IsEmpty())
2089       thumb = "unknown-user.png";
2090     return thumb;
2091   }
2092   else if (info == MUSICPLAYER_COVER)
2093   {
2094     if (!g_application.IsPlayingAudio()) return "";
2095     return m_currentFile.HasThumbnail() ? m_currentFile.GetThumbnailImage() : "defaultAlbumCover.png";
2096   }
2097   else if (info == MUSICPLAYER_RATING)
2098   {
2099     if (!g_application.IsPlayingAudio()) return "";
2100     return GetItemImage(&m_currentFile, LISTITEM_RATING);
2101   }
2102   else if (info == PLAYER_STAR_RATING)
2103   {
2104     if (!g_application.IsPlaying()) return "";
2105     return GetItemImage(&m_currentFile, LISTITEM_STAR_RATING);
2106   }
2107   else if (info == VIDEOPLAYER_COVER)
2108   {
2109     if (!g_application.IsPlayingVideo()) return "";
2110     if(m_currentMovieThumb.IsEmpty())
2111       return m_currentFile.HasThumbnail() ? m_currentFile.GetThumbnailImage() : "defaultVideoCover.png";
2112     else return m_currentMovieThumb;
2113   }
2114   else if (info == CONTAINER_FOLDERTHUMB)
2115   {
2116     CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2117     if (window)
2118       return GetItemImage(&const_cast<CFileItemList&>(((CGUIMediaWindow*)window)->CurrentDirectory()), LISTITEM_THUMB);
2119   }
2120   else if (info == CONTAINER_TVSHOWTHUMB)
2121   {
2122     CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2123     if (window)
2124       return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("tvshowthumb");
2125   }
2126   else if (info == CONTAINER_SEASONTHUMB)
2127   {
2128     CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2129     if (window)
2130       return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("seasonthumb");
2131   }
2132   else if (info == LISTITEM_THUMB || info == LISTITEM_ICON || info == LISTITEM_ACTUAL_ICON ||
2133           info == LISTITEM_OVERLAY || info == LISTITEM_RATING || info == LISTITEM_STAR_RATING)
2134   {
2135     CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
2136     if (window)
2137     {
2138       CFileItem* item = window->GetCurrentListItem();
2139       if (item)
2140         return GetItemImage(item, info);
2141     }
2142   }
2143   return GetLabel(info, contextWindow);
2144 }
2145
2146 CStdString CGUIInfoManager::GetDate(bool bNumbersOnly)
2147 {
2148   CDateTime time=CDateTime::GetCurrentDateTime();
2149   return time.GetAsLocalizedDate(!bNumbersOnly);
2150 }
2151
2152 CStdString CGUIInfoManager::GetTime(TIME_FORMAT format) const
2153 {
2154   CDateTime time=CDateTime::GetCurrentDateTime();
2155   return LocalizeTime(time, format);
2156 }
2157
2158 CStdString CGUIInfoManager::GetLcdTime( int _eInfo ) const
2159 {
2160   CDateTime time=CDateTime::GetCurrentDateTime();
2161   CStdString strLcdTime;
2162
2163 #ifdef HAS_LCD
2164
2165   UINT       nCharset;
2166   UINT       nLine;
2167   CStdString strTimeMarker;
2168
2169   switch ( _eInfo )
2170   {
2171     case LCD_TIME_21:
2172       nCharset = 1; // CUSTOM_CHARSET_SMALLCHAR;
2173       nLine = 0;
2174       strTimeMarker = ".";
2175     break;
2176     case LCD_TIME_22:
2177       nCharset = 1; // CUSTOM_CHARSET_SMALLCHAR;
2178       nLine = 1;
2179       strTimeMarker = ".";
2180     break;
2181
2182     case LCD_TIME_W21:
2183       nCharset = 2; // CUSTOM_CHARSET_MEDIUMCHAR;
2184       nLine = 0;
2185       strTimeMarker = ".";
2186     break;
2187     case LCD_TIME_W22:
2188       nCharset = 2; // CUSTOM_CHARSET_MEDIUMCHAR;
2189       nLine = 1;
2190       strTimeMarker = ".";
2191     break;
2192
2193     case LCD_TIME_41:
2194       nCharset = 3; // CUSTOM_CHARSET_BIGCHAR;
2195       nLine = 0;
2196       strTimeMarker = " ";
2197     break;
2198     case LCD_TIME_42:
2199       nCharset = 3; // CUSTOM_CHARSET_BIGCHAR;
2200       nLine = 1;
2201       strTimeMarker = "o";
2202     break;
2203     case LCD_TIME_43:
2204       nCharset = 3; // CUSTOM_CHARSET_BIGCHAR;
2205       nLine = 2;
2206       strTimeMarker = "o";
2207     break;
2208     case LCD_TIME_44:
2209       nCharset = 3; // CUSTOM_CHARSET_BIGCHAR;
2210       nLine = 3;
2211       strTimeMarker = " ";
2212     break;
2213   }
2214
2215   strLcdTime += g_lcd->GetBigDigit( nCharset, time.GetHour()  , nLine, 2, 2, true );
2216   strLcdTime += strTimeMarker;
2217   strLcdTime += g_lcd->GetBigDigit( nCharset, time.GetMinute(), nLine, 2, 2, false );
2218   strLcdTime += strTimeMarker;
2219   strLcdTime += g_lcd->GetBigDigit( nCharset, time.GetSecond(), nLine, 2, 2, false );
2220
2221 #endif
2222   
2223   return strLcdTime;
2224 }
2225
2226 CStdString CGUIInfoManager::LocalizeTime(const CDateTime &time, TIME_FORMAT format) const
2227 {
2228   const CStdString timeFormat = g_langInfo.GetTimeFormat();
2229   bool use12hourclock = timeFormat.Find('h') != -1;
2230   switch (format)
2231   {
2232   case TIME_FORMAT_GUESS:
2233     return time.GetAsLocalizedTime("", false);
2234   case TIME_FORMAT_SS:
2235     return time.GetAsLocalizedTime("ss", true);
2236   case TIME_FORMAT_MM:
2237     return time.GetAsLocalizedTime("mm", true);
2238   case TIME_FORMAT_MM_SS:
2239     return time.GetAsLocalizedTime("mm:ss", true);
2240   case TIME_FORMAT_HH:  // this forces it to a 12 hour clock
2241     return time.GetAsLocalizedTime(use12hourclock ? "h" : "H", false);
2242   case TIME_FORMAT_HH_MM:
2243     return time.GetAsLocalizedTime(use12hourclock ? "h:mm" : "H:mm", false);
2244   case TIME_FORMAT_HH_MM_SS:
2245     return time.GetAsLocalizedTime("", true);
2246   default:
2247     break;
2248   }
2249   return time.GetAsLocalizedTime("", false);
2250 }
2251
2252 CStdString CGUIInfoManager::GetDuration(TIME_FORMAT format) const
2253 {
2254   CStdString strDuration;
2255   if (g_application.IsPlayingAudio() && m_currentFile.HasMusicInfoTag())
2256   {
2257     const CMusicInfoTag& tag = *m_currentFile.GetMusicInfoTag();
2258     if (tag.GetDuration() > 0)
2259       StringUtils::SecondsToTimeString(tag.GetDuration(), strDuration, format);
2260   }
2261   if (g_application.IsPlayingVideo() && !m_currentMovieDuration.IsEmpty())
2262     return m_currentMovieDuration;  // for tuxbox
2263   if (strDuration.IsEmpty())
2264   {
2265     unsigned int iTotal = (unsigned int)g_application.GetTotalTime();
2266     if (iTotal > 0)
2267       StringUtils::SecondsToTimeString(iTotal, strDuration, format);
2268   }
2269   return strDuration;
2270 }
2271
2272 CStdString CGUIInfoManager::GetMusicPartyModeLabel(int item)
2273 {
2274   // get song counts
2275   if (item >= MUSICPM_SONGSPLAYED && item <= MUSICPM_RANDOMSONGSPICKED)
2276   {
2277     int iSongs = -1;
2278     switch (item)
2279     {
2280     case MUSICPM_SONGSPLAYED:
2281       {
2282         iSongs = g_partyModeManager.GetSongsPlayed();
2283         break;
2284       }
2285     case MUSICPM_MATCHINGSONGS:
2286       {
2287         iSongs = g_partyModeManager.GetMatchingSongs();
2288         break;
2289       }
2290     case MUSICPM_MATCHINGSONGSPICKED:
2291       {
2292         iSongs = g_partyModeManager.GetMatchingSongsPicked();
2293         break;
2294       }
2295     case MUSICPM_MATCHINGSONGSLEFT:
2296       {
2297         iSongs = g_partyModeManager.GetMatchingSongsLeft();
2298         break;
2299       }
2300     case MUSICPM_RELAXEDSONGSPICKED:
2301       {
2302         iSongs = g_partyModeManager.GetRelaxedSongs();
2303         break;
2304       }
2305     case MUSICPM_RANDOMSONGSPICKED:
2306       {
2307         iSongs = g_partyModeManager.GetRandomSongs();
2308         break;
2309       }
2310     }
2311     if (iSongs < 0)
2312       return "";
2313     CStdString strLabel;
2314     strLabel.Format("%i", iSongs);
2315     return strLabel;
2316   }
2317   return "";
2318 }
2319
2320 CStdString CGUIInfoManager::GetPlaylistLabel(int item)
2321 {
2322   if (!g_application.IsPlaying()) return "";
2323   int iPlaylist = g_playlistPlayer.GetCurrentPlaylist();
2324   switch (item)
2325   {
2326   case PLAYLIST_LENGTH:
2327     {
2328       CStdString strLength = "";
2329       strLength.Format("%i", g_playlistPlayer.GetPlaylist(iPlaylist).size());
2330       return strLength;
2331     }
2332   case PLAYLIST_POSITION:
2333     {
2334       CStdString strPosition = "";
2335       strPosition.Format("%i", g_playlistPlayer.GetCurrentSong() + 1);
2336       return strPosition;
2337     }
2338   case PLAYLIST_RANDOM:
2339     {
2340       if (g_playlistPlayer.IsShuffled(iPlaylist))
2341         return g_localizeStrings.Get(590); // 590: Random
2342       else
2343         return g_localizeStrings.Get(591); // 591: Off
2344     }
2345   case PLAYLIST_REPEAT:
2346     {
2347       PLAYLIST::REPEAT_STATE state = g_playlistPlayer.GetRepeat(iPlaylist);
2348       if (state == PLAYLIST::REPEAT_ONE)
2349         return g_localizeStrings.Get(592); // 592: One
2350       else if (state == PLAYLIST::REPEAT_ALL)
2351         return g_localizeStrings.Get(593); // 593: All
2352       else
2353         return g_localizeStrings.Get(594); // 594: Off
2354     }
2355   }
2356   return "";
2357 }
2358
2359
2360 CStdString CGUIInfoManager::GetMusicLabel(int item)
2361 {
2362   if (!g_application.IsPlayingAudio() || !m_currentFile.HasMusicInfoTag()) return "";
2363   CMusicInfoTag& tag = *m_currentFile.GetMusicInfoTag();
2364   switch (item)
2365   {
2366   case MUSICPLAYER_TITLE:
2367     if (tag.GetTitle().size()) { return tag.GetTitle(); }
2368     break;
2369   case MUSICPLAYER_ALBUM: 
2370     if (tag.GetAlbum().size()) { return tag.GetAlbum(); }
2371     break;
2372   case MUSICPLAYER_ARTIST: 
2373     if (tag.GetArtist().size()) { return tag.GetArtist(); }
2374     break;
2375   case MUSICPLAYER_YEAR: 
2376     if (tag.GetYear()) { return tag.GetYearString(); }
2377     break;
2378   case MUSICPLAYER_GENRE: 
2379     if (tag.GetGenre().size()) { return tag.GetGenre(); }
2380     break;
2381   case MUSICPLAYER_TRACK_NUMBER:
2382     {
2383       CStdString strTrack;
2384       if (tag.Loaded() && tag.GetTrackNumber() > 0)
2385       {
2386         strTrack.Format("%02i", tag.GetTrackNumber());
2387         return strTrack;
2388       }
2389     }
2390     break;
2391   case MUSICPLAYER_PLAYLISTLEN:
2392     {
2393       if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2394         return GetPlaylistLabel(PLAYLIST_LENGTH);
2395     }
2396     break;
2397   case MUSICPLAYER_PLAYLISTPOS:
2398     {
2399       if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2400         return GetPlaylistLabel(PLAYLIST_POSITION);
2401     }
2402     break;
2403   case MUSICPLAYER_BITRATE:
2404     {
2405       float fTimeSpan = (float)(timeGetTime() - m_lastMusicBitrateTime);
2406       if (fTimeSpan >= 500.0f)
2407       {
2408         m_MusicBitrate = g_application.m_pPlayer->GetBitrate();
2409         m_lastMusicBitrateTime = timeGetTime();
2410       }
2411       CStdString strBitrate = "";
2412       if (m_MusicBitrate > 0)
2413         strBitrate.Format("%i", m_MusicBitrate);
2414       return strBitrate;
2415     }
2416     break;
2417   case MUSICPLAYER_CHANNELS:
2418     {
2419       CStdString strChannels = "";
2420       if (g_application.m_pPlayer->GetChannels() > 0)
2421       {
2422         strChannels.Format("%i", g_application.m_pPlayer->GetChannels());
2423       }
2424       return strChannels;
2425     }
2426     break;
2427   case MUSICPLAYER_BITSPERSAMPLE:
2428     {
2429       CStdString strBitsPerSample = "";
2430       if (g_application.m_pPlayer->GetBitsPerSample() > 0)
2431       {
2432         strBitsPerSample.Format("%i", g_application.m_pPlayer->GetBitsPerSample());
2433       }
2434       return strBitsPerSample;
2435     }
2436     break;
2437   case MUSICPLAYER_SAMPLERATE:
2438     {
2439       CStdString strSampleRate = "";
2440       if (g_application.m_pPlayer->GetSampleRate() > 0)
2441       {
2442         strSampleRate.Format("%i",g_application.m_pPlayer->GetSampleRate());
2443       }
2444       return strSampleRate;
2445     }
2446     break;
2447   case MUSICPLAYER_CODEC:
2448     {
2449       CStdString strCodec;
2450       strCodec.Format("%s", g_application.m_pPlayer->GetCodecName().c_str());
2451       return strCodec;
2452     }
2453     break;
2454   case MUSICPLAYER_DISC_NUMBER:
2455     {
2456       CStdString strDisc;
2457       if (tag.Loaded() && tag.GetDiscNumber() > 0)
2458       {
2459         strDisc.Format("%02i", tag.GetDiscNumber());
2460         return strDisc;
2461       } 
2462     }
2463     break;
2464   case MUSICPLAYER_RATING:
2465     return GetItemLabel(&m_currentFile, LISTITEM_RATING);
2466   case MUSICPLAYER_COMMENT:
2467     return GetItemLabel(&m_currentFile, LISTITEM_COMMENT);
2468   case MUSICPLAYER_LYRICS: 
2469     return GetItemLabel(&m_currentFile, AddListItemProp("lyrics"));
2470   }
2471   return "";
2472 }
2473
2474 CStdString CGUIInfoManager::GetVideoLabel(int item)
2475 {
2476   if (!g_application.IsPlayingVideo()) 
2477     return "";
2478   
2479   if (item == VIDEOPLAYER_TITLE)
2480   {
2481     if (m_currentFile.HasVideoInfoTag() && !m_currentFile.GetVideoInfoTag()->m_strTitle.IsEmpty())
2482       return m_currentFile.GetVideoInfoTag()->m_strTitle;
2483     // don't have the title, so use label, or drop down to title from path
2484     if (!m_currentFile.GetLabel().IsEmpty())
2485       return m_currentFile.GetLabel();
2486     return CUtil::GetTitleFromPath(m_currentFile.m_strPath);
2487   }
2488   else if (item == VIDEOPLAYER_PLAYLISTLEN)
2489   {
2490     if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_VIDEO)
2491       return GetPlaylistLabel(PLAYLIST_LENGTH);
2492   }
2493   else if (item == VIDEOPLAYER_PLAYLISTPOS)
2494   {
2495     if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_VIDEO)
2496       return GetPlaylistLabel(PLAYLIST_POSITION);
2497   }
2498   else if (m_currentFile.HasVideoInfoTag())
2499   {
2500     switch (item)
2501     {
2502     case VIDEOPLAYER_ORIGINALTITLE:
2503       return m_currentFile.GetVideoInfoTag()->m_strOriginalTitle;
2504       break;
2505     case VIDEOPLAYER_GENRE:
2506       return m_currentFile.GetVideoInfoTag()->m_strGenre;
2507       break;
2508     case VIDEOPLAYER_DIRECTOR:
2509       return m_currentFile.GetVideoInfoTag()->m_strDirector;
2510       break;
2511     case VIDEOPLAYER_RATING:
2512       {
2513         CStdString strRating;
2514         if (m_currentFile.GetVideoInfoTag()->m_fRating > 0.f)
2515           strRating.Format("%2.2f", m_currentFile.GetVideoInfoTag()->m_fRating);
2516         return strRating;
2517       }
2518       break;
2519     case VIDEOPLAYER_RATING_AND_VOTES:
2520       {
2521         CStdString strRatingAndVotes;
2522         if (m_currentFile.GetVideoInfoTag()->m_fRating > 0.f)
2523               strRatingAndVotes.Format("%2.2f (%s %s)", m_currentFile.GetVideoInfoTag()->m_fRating, m_currentFile.GetVideoInfoTag()->m_strVotes, g_localizeStrings.Get(20350));
2524         return strRatingAndVotes;
2525       }
2526       break;
2527     case VIDEOPLAYER_YEAR:
2528       {
2529         CStdString strYear;
2530         if (m_currentFile.GetVideoInfoTag()->m_iYear > 0)
2531           strYear.Format("%i", m_currentFile.GetVideoInfoTag()->m_iYear);
2532         return strYear;
2533       }
2534       break;
2535     case VIDEOPLAYER_PREMIERED:
2536       {
2537         CStdString strYear;
2538         if (!m_currentFile.GetVideoInfoTag()->m_strPremiered.IsEmpty())
2539           strYear = m_currentFile.GetVideoInfoTag()->m_strPremiered;
2540         else if (!m_currentFile.GetVideoInfoTag()->m_strFirstAired.IsEmpty())
2541           strYear = m_currentFile.GetVideoInfoTag()->m_strFirstAired;
2542         return strYear;
2543       }
2544       break;
2545     case VIDEOPLAYER_PLOT:
2546       return m_currentFile.GetVideoInfoTag()->m_strPlot;
2547         case VIDEOPLAYER_TRAILER:
2548       return m_currentFile.GetVideoInfoTag()->m_strTrailer;
2549     case VIDEOPLAYER_PLOT_OUTLINE:
2550       return m_currentFile.GetVideoInfoTag()->m_strPlotOutline;
2551     case VIDEOPLAYER_EPISODE:
2552       if (m_currentFile.GetVideoInfoTag()->m_iEpisode > 0)
2553       {
2554         CStdString strYear;
2555         if (m_currentFile.GetVideoInfoTag()->m_iSpecialSortEpisode > 0)
2556           strYear.Format("S%i", m_currentFile.GetVideoInfoTag()->m_iEpisode);
2557         else
2558           strYear.Format("%i", m_currentFile.GetVideoInfoTag()->m_iEpisode);
2559         return strYear;
2560       }
2561       break;
2562     case VIDEOPLAYER_SEASON:
2563       if (m_currentFile.GetVideoInfoTag()->m_iSeason > -1)
2564       {
2565         CStdString strYear;
2566         if (m_currentFile.GetVideoInfoTag()->m_iSpecialSortSeason > 0)
2567           strYear.Format("%i", m_currentFile.GetVideoInfoTag()->m_iSpecialSortSeason);
2568         else
2569           strYear.Format("%i", m_currentFile.GetVideoInfoTag()->m_iSeason);
2570         return strYear;
2571       }
2572       break;
2573     case VIDEOPLAYER_TVSHOW:
2574       return m_currentFile.GetVideoInfoTag()->m_strShowTitle;
2575
2576     case VIDEOPLAYER_STUDIO:
2577       return m_currentFile.GetVideoInfoTag()->m_strStudio;
2578     case VIDEOPLAYER_MPAA:
2579       return m_currentFile.GetVideoInfoTag()->m_strMPAARating;
2580     case VIDEOPLAYER_TOP250:
2581       {
2582         CStdString strTop250;
2583         if (m_currentFile.GetVideoInfoTag()->m_iTop250 > 0)
2584           strTop250.Format("%i", m_currentFile.GetVideoInfoTag()->m_iTop250);
2585         return strTop250;
2586       }
2587       break;
2588     case VIDEOPLAYER_CAST:
2589       return m_currentFile.GetVideoInfoTag()->GetCast();
2590     case VIDEOPLAYER_CAST_AND_ROLE:
2591       return m_currentFile.GetVideoInfoTag()->GetCast(true);
2592     case VIDEOPLAYER_ARTIST:
2593       if (m_currentFile.GetVideoInfoTag()->m_artist.size() > 0)
2594         return m_currentFile.GetVideoInfoTag()->GetArtist();
2595       break;
2596     case VIDEOPLAYER_ALBUM:
2597       return m_currentFile.GetVideoInfoTag()->m_strAlbum;
2598     case VIDEOPLAYER_WRITER:
2599       return m_currentFile.GetVideoInfoTag()->m_strWritingCredits;
2600     case VIDEOPLAYER_TAGLINE:
2601       return m_currentFile.GetVideoInfoTag()->m_strTagLine;
2602     }
2603   }
2604   return "";
2605 }
2606
2607 __int64 CGUIInfoManager::GetPlayTime() const
2608 {
2609   if (g_application.IsPlaying())
2610   {
2611     __int64 lPTS = (__int64)(g_application.GetTime() * 1000);
2612     if (lPTS < 0) lPTS = 0;
2613     return lPTS;
2614   }
2615   return 0;
2616 }
2617
2618 CStdString CGUIInfoManager::GetCurrentPlayTime(TIME_FORMAT format) const
2619 {
2620   CStdString strTime;
2621   if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
2622     format = TIME_FORMAT_HH_MM_SS;
2623   if (g_application.IsPlayingAudio())
2624     StringUtils::SecondsToTimeString((int)(GetPlayTime()/1000), strTime, format);
2625   else if (g_application.IsPlayingVideo())
2626     StringUtils::SecondsToTimeString((int)(GetPlayTime()/1000), strTime, format);
2627   return strTime;
2628 }
2629
2630 int CGUIInfoManager::GetTotalPlayTime() const
2631 {
2632   int iTotalTime = (int)g_application.GetTotalTime();
2633   return iTotalTime > 0 ? iTotalTime : 0;
2634 }
2635
2636 int CGUIInfoManager::GetPlayTimeRemaining() const
2637 {
2638   int iReverse = GetTotalPlayTime() - (int)g_application.GetTime();
2639   return iReverse > 0 ? iReverse : 0;
2640 }
2641
2642 CStdString CGUIInfoManager::GetCurrentPlayTimeRemaining(TIME_FORMAT format) const
2643 {
2644   if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
2645     format = TIME_FORMAT_HH_MM_SS;
2646   CStdString strTime;
2647   int timeRemaining = GetPlayTimeRemaining();
2648   if (timeRemaining)
2649   {
2650     if (g_application.IsPlayingAudio())
2651       StringUtils::SecondsToTimeString(timeRemaining, strTime, format);
2652     else if (g_application.IsPlayingVideo())
2653       StringUtils::SecondsToTimeString(timeRemaining, strTime, format);
2654   }
2655   return strTime;
2656 }
2657
2658 void CGUIInfoManager::ResetCurrentItem()
2659
2660   m_currentFile.Reset();
2661   m_currentMovieThumb = "";
2662   m_currentMovieDuration = "";
2663   
2664 }
2665
2666 void CGUIInfoManager::SetCurrentItem(CFileItem &item)
2667 {
2668   ResetCurrentItem();
2669
2670   if (item.IsAudio())
2671     SetCurrentSong(item);
2672   else
2673     SetCurrentMovie(item);
2674 }
2675
2676 void CGUIInfoManager::SetCurrentAlbumThumb(const CStdString thumbFileName)
2677 {
2678   if (CFile::Exists(thumbFileName))
2679     m_currentFile.SetThumbnailImage(thumbFileName);
2680   else
2681   {
2682     m_currentFile.SetThumbnailImage("");
2683     m_currentFile.FillInDefaultIcon();
2684   }
2685 }
2686
2687 void CGUIInfoManager::SetCurrentSong(CFileItem &item)
2688 {
2689   CLog::Log(LOGDEBUG,"CGUIInfoManager::SetCurrentSong(%s)",item.m_strPath.c_str());
2690   m_currentFile = item;
2691
2692   // Get a reference to the item's tag
2693   CMusicInfoTag& tag = *m_currentFile.GetMusicInfoTag();
2694   // check if we don't have the tag already loaded
2695   if (!tag.Loaded())
2696   {
2697     // we have a audio file.
2698     // Look if we have this file in database...
2699     bool bFound = false;
2700     CMusicDatabase musicdatabase;
2701     if (musicdatabase.Open())
2702     {
2703       CSong song;
2704       bFound = musicdatabase.GetSongByFileName(m_currentFile.m_strPath, song);
2705       m_currentFile.GetMusicInfoTag()->SetSong(song);
2706       musicdatabase.Close();
2707     }
2708
2709     if (!bFound)
2710     {
2711       // always get id3 info for the overlay
2712       CMusicInfoTagLoaderFactory factory;
2713       auto_ptr<IMusicInfoTagLoader> pLoader (factory.CreateLoader(m_currentFile.m_strPath));
2714       // Do we have a tag loader for this file type?
2715       if (NULL != pLoader.get())
2716         pLoader->Load(m_currentFile.m_strPath, tag);
2717     }
2718   }
2719
2720   // If we have tag information, ...
2721   if (tag.Loaded())
2722   {
2723     if (!tag.GetTitle().size())
2724     {
2725       // No title in tag, show filename only
2726 #ifdef HAS_FILESYSTEM      
2727       CSndtrkDirectory dir;
2728       char NameOfSong[64];
2729       if (dir.FindTrackName(m_currentFile.m_strPath, NameOfSong))
2730         tag.SetTitle(NameOfSong);
2731       else
2732 #endif
2733         tag.SetTitle( CUtil::GetTitleFromPath(m_currentFile.m_strPath) );
2734     }
2735   } // if (tag.Loaded())
2736   else
2737   {
2738     // If we have a cdda track without cddb information,...
2739     if (m_currentFile.IsCDDA())
2740     {
2741       // we have the tracknumber...
2742       int iTrack = tag.GetTrackNumber();
2743       if (iTrack >= 1)
2744       {
2745         CStdString strText = g_localizeStrings.Get(435); // "Track"
2746         if (strText.GetAt(strText.size() - 1) != ' ')
2747           strText += " ";
2748         CStdString strTrack;
2749         strTrack.Format(strText + "%i", iTrack);
2750         tag.SetTitle(strTrack);
2751         tag.SetLoaded(true);
2752       }
2753     } // if (!tag.Loaded() && url.GetProtocol()=="cdda" )
2754     else
2755     {
2756       CStdString fileName = CUtil::GetFileName(m_currentFile.m_strPath);
2757       CUtil::RemoveExtension(fileName);
2758       for (unsigned int i = 0; i < g_advancedSettings.m_musicTagsFromFileFilters.size(); i++)
2759       {
2760         CLabelFormatter formatter(g_advancedSettings.m_musicTagsFromFileFilters[i], "");
2761         if (formatter.FillMusicTag(fileName, &tag))
2762         {
2763           tag.SetLoaded(true);
2764           break;
2765         }
2766       }
2767       if (!tag.Loaded()) // at worse, set our title as the filename
2768         tag.SetTitle( CUtil::GetTitleFromPath(m_currentFile.m_strPath) );
2769     }
2770     // we now have at least the title
2771     tag.SetLoaded(true);
2772   }
2773
2774   // find a thumb for this file.
2775   if (m_currentFile.IsInternetStream())
2776   {
2777     if (!g_application.m_strPlayListFile.IsEmpty())
2778     {
2779       CLog::Log(LOGDEBUG,"Streaming media detected... using %s to find a thumb", g_application.m_strPlayListFile.c_str());
2780       CFileItem streamingItem(g_application.m_strPlayListFile,false);
2781       streamingItem.SetMusicThumb();
2782       CStdString strThumb = streamingItem.GetThumbnailImage();
2783       if (CFile::Exists(strThumb))
2784         m_currentFile.SetThumbnailImage(strThumb);
2785     }
2786   }
2787   else
2788     m_currentFile.SetMusicThumb();
2789   m_currentFile.FillInDefaultIcon();
2790
2791   CMusicInfoLoader::LoadAdditionalTagInfo(&m_currentFile);
2792 }
2793
2794 void CGUIInfoManager::SetCurrentMovie(CFileItem &item)
2795 {
2796   CLog::Log(LOGDEBUG,"CGUIInfoManager::SetCurrentMovie(%s)",item.m_strPath.c_str());
2797   m_currentFile = item;
2798   
2799   if (!m_currentFile.HasVideoInfoTag())
2800   { // attempt to get some information
2801     CVideoDatabase dbs;
2802     dbs.Open();
2803     if (dbs.HasMovieInfo(item.m_strPath))
2804     {
2805       dbs.GetMovieInfo(item.m_strPath, *m_currentFile.GetVideoInfoTag());