2 * Copyright (C) 2005-2008 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
23 #include "dialogs/GUIDialogSeekBar.h"
24 #include "windows/GUIMediaWindow.h"
25 #include "dialogs/GUIDialogFileBrowser.h"
26 #include "settings/GUIDialogContentSettings.h"
27 #include "dialogs/GUIDialogProgress.h"
28 #include "Application.h"
30 #include "network/libscrobbler/lastfmscrobbler.h"
31 #include "utils/URIUtils.h"
32 #include "utils/Weather.h"
33 #include "PartyModeManager.h"
34 #include "addons/Visualisation.h"
35 #include "input/ButtonTranslator.h"
36 #include "utils/AlarmClock.h"
38 #include "utils/LCD.h"
40 #include "GUIPassword.h"
42 #include "utils/SystemInfo.h"
43 #include "guilib/GUITextBox.h"
44 #include "GUIInfoManager.h"
45 #include "pictures/GUIWindowSlideShow.h"
46 #include "music/LastFmManager.h"
47 #include "pictures/PictureInfoTag.h"
48 #include "music/tags/MusicInfoTag.h"
49 #include "music/dialogs/GUIDialogMusicScan.h"
50 #include "video/dialogs/GUIDialogVideoScan.h"
51 #include "guilib/GUIWindowManager.h"
52 #include "filesystem/File.h"
53 #include "playlists/PlayList.h"
54 #include "utils/TuxBoxUtil.h"
55 #include "windowing/WindowingFactory.h"
56 #include "powermanagement/PowerManager.h"
57 #include "settings/AdvancedSettings.h"
58 #include "settings/Settings.h"
59 #include "guilib/LocalizeStrings.h"
60 #include "utils/CPUInfo.h"
61 #include "utils/StringUtils.h"
62 #include "utils/MathUtils.h"
64 // stuff for current song
65 #include "music/tags/MusicInfoTagLoaderFactory.h"
66 #include "music/MusicInfoLoader.h"
67 #include "utils/LabelFormatter.h"
69 #include "GUIUserMessages.h"
70 #include "video/dialogs/GUIDialogVideoInfo.h"
71 #include "music/dialogs/GUIDialogMusicInfo.h"
72 #include "storage/MediaManager.h"
73 #include "utils/TimeUtils.h"
74 #include "threads/SingleLock.h"
75 #include "utils/log.h"
77 #include "addons/AddonManager.h"
78 #include "interfaces/info/InfoBool.h"
80 #define SYSHEATUPDATEINTERVAL 60000
83 using namespace XFILE;
84 using namespace MUSIC_INFO;
85 using namespace ADDON;
88 CGUIInfoManager::CGUIInfoManager(void)
90 m_lastSysHeatInfoTime = -SYSHEATUPDATEINTERVAL; // make sure we grab CPU temp on the first pass
91 m_lastMusicBitrateTime = 0;
93 m_AfterSeekTimeout = 0;
95 m_playerSeeking = false;
96 m_performingSeek = false;
97 m_nextWindowID = WINDOW_INVALID;
98 m_prevWindowID = WINDOW_INVALID;
99 m_stringParameters.push_back("__ZZZZ__"); // to offset the string parameters by 1 to assure that all entries are non-zero
100 m_currentFile = new CFileItem;
101 m_currentSlide = new CFileItem;
108 CGUIInfoManager::~CGUIInfoManager(void)
110 delete m_currentFile;
111 delete m_currentSlide;
114 bool CGUIInfoManager::OnMessage(CGUIMessage &message)
116 if (message.GetMessage() == GUI_MSG_NOTIFY_ALL)
118 if (message.GetParam1() == GUI_MSG_UPDATE_ITEM && message.GetItem())
120 CFileItemPtr item = boost::static_pointer_cast<CFileItem>(message.GetItem());
121 if (item && m_currentFile->GetPath().Equals(item->GetPath()))
122 *m_currentFile = *item;
129 /// \brief Translates a string as given by the skin into an int that we use for more
130 /// efficient retrieval of data. Can handle combined strings on the form
131 /// Player.Caching + VideoPlayer.IsFullscreen (Logical and)
132 /// Player.HasVideo | Player.HasAudio (Logical or)
133 int CGUIInfoManager::TranslateString(const CStdString &condition)
135 // translate $LOCALIZE as required
136 CStdString strCondition(CGUIInfoLabel::ReplaceLocalize(condition));
137 return TranslateSingleString(strCondition);
146 const infomap player_labels[] = {{ "hasmedia", PLAYER_HAS_MEDIA }, // bools from here
147 { "hasaudio", PLAYER_HAS_AUDIO },
148 { "hasvideo", PLAYER_HAS_VIDEO },
149 { "playing", PLAYER_PLAYING },
150 { "paused", PLAYER_PAUSED },
151 { "rewinding", PLAYER_REWINDING },
152 { "forwarding", PLAYER_FORWARDING },
153 { "rewinding2x", PLAYER_REWINDING_2x },
154 { "rewinding4x", PLAYER_REWINDING_4x },
155 { "rewinding8x", PLAYER_REWINDING_8x },
156 { "rewinding16x", PLAYER_REWINDING_16x },
157 { "rewinding32x", PLAYER_REWINDING_32x },
158 { "forwarding2x", PLAYER_FORWARDING_2x },
159 { "forwarding4x", PLAYER_FORWARDING_4x },
160 { "forwarding8x", PLAYER_FORWARDING_8x },
161 { "forwarding16x", PLAYER_FORWARDING_16x },
162 { "forwarding32x", PLAYER_FORWARDING_32x },
163 { "canrecord", PLAYER_CAN_RECORD },
164 { "recording", PLAYER_RECORDING },
165 { "displayafterseek", PLAYER_DISPLAY_AFTER_SEEK },
166 { "caching", PLAYER_CACHING },
167 { "seekbar", PLAYER_SEEKBAR },
168 { "seeking", PLAYER_SEEKING },
169 { "showtime", PLAYER_SHOWTIME },
170 { "showcodec", PLAYER_SHOWCODEC },
171 { "showinfo", PLAYER_SHOWINFO },
172 { "muted", PLAYER_MUTED },
173 { "hasduration", PLAYER_HASDURATION },
174 { "passthrough", PLAYER_PASSTHROUGH },
175 { "cachelevel", PLAYER_CACHELEVEL }, // labels from here
176 { "seekbar", PLAYER_SEEKBAR },
177 { "progress", PLAYER_PROGRESS },
178 { "progresscache", PLAYER_PROGRESS_CACHE },
179 { "volume", PLAYER_VOLUME },
180 { "subtitledelay", PLAYER_SUBTITLE_DELAY },
181 { "audiodelay", PLAYER_AUDIO_DELAY },
182 { "chapter", PLAYER_CHAPTER },
183 { "chaptercount", PLAYER_CHAPTERCOUNT },
184 { "chaptername", PLAYER_CHAPTERNAME },
185 { "starrating", PLAYER_STAR_RATING },
186 { "folderpath", PLAYER_PATH },
187 { "filenameandpath", PLAYER_FILEPATH }};
189 const infomap player_times[] = {{ "seektime", PLAYER_SEEKTIME },
190 { "seekoffset", PLAYER_SEEKOFFSET },
191 { "timeremaining", PLAYER_TIME_REMAINING },
192 { "timespeed", PLAYER_TIME_SPEED },
193 { "time", PLAYER_TIME },
194 { "duration", PLAYER_DURATION },
195 { "finishtime", PLAYER_FINISH_TIME }};
197 const infomap weather[] = {{ "isfetched", WEATHER_IS_FETCHED },
198 { "conditions", WEATHER_CONDITIONS }, // labels from here
199 { "temperature", WEATHER_TEMPERATURE },
200 { "location", WEATHER_LOCATION },
201 { "fanartcode", WEATHER_FANART_CODE },
202 { "plugin", WEATHER_PLUGIN }};
204 const infomap system_labels[] = {{ "hasnetwork", SYSTEM_ETHERNET_LINK_ACTIVE },
205 { "hasmediadvd", SYSTEM_MEDIA_DVD },
206 { "dvdready", SYSTEM_DVDREADY },
207 { "trayopen", SYSTEM_TRAYOPEN },
208 { "haslocks", SYSTEM_HASLOCKS },
209 { "hasloginscreen", SYSTEM_HAS_LOGINSCREEN },
210 { "ismaster", SYSTEM_ISMASTER },
211 { "isfullscreen", SYSTEM_ISFULLSCREEN },
212 { "isstandalone", SYSTEM_ISSTANDALONE },
213 { "loggedon", SYSTEM_LOGGEDON },
214 { "showexitbutton", SYSTEM_SHOW_EXIT_BUTTON },
215 { "hasdrivef", SYSTEM_HAS_DRIVE_F },
216 { "hasdriveg", SYSTEM_HAS_DRIVE_G },
217 { "canpowerdown", SYSTEM_CAN_POWERDOWN },
218 { "cansuspend", SYSTEM_CAN_SUSPEND },
219 { "canhibernate", SYSTEM_CAN_HIBERNATE },
220 { "canreboot", SYSTEM_CAN_REBOOT },
221 { "cputemperature", SYSTEM_CPU_TEMPERATURE }, // labels from here
222 { "cpuusage", SYSTEM_CPU_USAGE },
223 { "gputemperature", SYSTEM_GPU_TEMPERATURE },
224 { "fanspeed", SYSTEM_FAN_SPEED },
225 { "freespace", SYSTEM_FREE_SPACE },
226 { "usedspace", SYSTEM_USED_SPACE },
227 { "totalspace", SYSTEM_TOTAL_SPACE },
228 { "usedspacepercent", SYSTEM_USED_SPACE_PERCENT },
229 { "freespacepercent", SYSTEM_FREE_SPACE_PERCENT },
230 { "buildversion", SYSTEM_BUILD_VERSION },
231 { "builddate", SYSTEM_BUILD_DATE },
232 { "fps", SYSTEM_FPS },
233 { "dvdtraystate", SYSTEM_DVD_TRAY_STATE },
234 { "freememory", SYSTEM_FREE_MEMORY },
235 { "language", SYSTEM_LANGUAGE },
236 { "temperatureunits", SYSTEM_TEMPERATURE_UNITS },
237 { "screenmode", SYSTEM_SCREEN_MODE },
238 { "screenwidth", SYSTEM_SCREEN_WIDTH },
239 { "screenheight", SYSTEM_SCREEN_HEIGHT },
240 { "currentwindow", SYSTEM_CURRENT_WINDOW },
241 { "currentcontrol", SYSTEM_CURRENT_CONTROL },
242 { "dvdlabel", SYSTEM_DVD_LABEL },
243 { "internetstate", SYSTEM_INTERNET_STATE },
244 { "kernelversion", SYSTEM_KERNEL_VERSION },
245 { "uptime", SYSTEM_UPTIME },
246 { "totaluptime", SYSTEM_TOTALUPTIME },
247 { "cpufrequency", SYSTEM_CPUFREQUENCY },
248 { "screenresolution", SYSTEM_SCREEN_RESOLUTION },
249 { "videoencoderinfo", SYSTEM_VIDEO_ENCODER_INFO },
250 { "profilename", SYSTEM_PROFILENAME },
251 { "profilethumb", SYSTEM_PROFILETHUMB },
252 { "profilecount", SYSTEM_PROFILECOUNT },
253 { "progressbar", SYSTEM_PROGRESS_BAR },
254 { "batterylevel", SYSTEM_BATTERY_LEVEL },
255 { "friendlyname", SYSTEM_FRIENDLY_NAME },
256 { "alarmpos", SYSTEM_ALARM_POS }};
258 const infomap system_param[] = {{ "hasalarm", SYSTEM_HAS_ALARM },
259 { "getbool", SYSTEM_GET_BOOL },
260 { "hascoreid", SYSTEM_HAS_CORE_ID },
261 { "setting", SYSTEM_SETTING },
262 { "hasaddon", SYSTEM_HAS_ADDON },
263 { "coreusage", SYSTEM_GET_CORE_USAGE }};
265 const infomap lcd_labels[] = {{ "playicon", LCD_PLAY_ICON },
266 { "progressbar", LCD_PROGRESS_BAR },
267 { "cputemperature", LCD_CPU_TEMPERATURE },
268 { "gputemperature", LCD_GPU_TEMPERATURE },
269 { "hddtemperature", LCD_HDD_TEMPERATURE },
270 { "fanspeed", LCD_FAN_SPEED },
271 { "date", LCD_DATE },
272 { "time21", LCD_TIME_21 },
273 { "time22", LCD_TIME_22 },
274 { "timewide21", LCD_TIME_W21 },
275 { "timewide22", LCD_TIME_W22 },
276 { "time41", LCD_TIME_41 },
277 { "time42", LCD_TIME_42 },
278 { "time43", LCD_TIME_43 },
279 { "time44", LCD_TIME_44 }};
281 const infomap network_labels[] = {{ "isdhcp", NETWORK_IS_DHCP },
282 { "ipaddress", NETWORK_IP_ADDRESS }, //labels from here
283 { "linkstate", NETWORK_LINK_STATE },
284 { "macaddress", NETWORK_MAC_ADDRESS },
285 { "subnetaddress", NETWORK_SUBNET_MASK }, //subnetaddress is misleading/wrong. should be deprecated. use subnetmask in stead
286 { "subnetmask", NETWORK_SUBNET_MASK },
287 { "gatewayaddress", NETWORK_GATEWAY_ADDRESS },
288 { "dns1address", NETWORK_DNS1_ADDRESS },
289 { "dns2address", NETWORK_DNS2_ADDRESS },
290 { "dhcpaddress", NETWORK_DHCP_ADDRESS }};
292 const infomap musicpartymode[] = {{ "enabled", MUSICPM_ENABLED },
293 { "songsplayed", MUSICPM_SONGSPLAYED },
294 { "matchingsongs", MUSICPM_MATCHINGSONGS },
295 { "matchingsongspicked", MUSICPM_MATCHINGSONGSPICKED },
296 { "matchingsongsleft", MUSICPM_MATCHINGSONGSLEFT },
297 { "relaxedsongspicked",MUSICPM_RELAXEDSONGSPICKED },
298 { "randomsongspicked", MUSICPM_RANDOMSONGSPICKED }};
300 const infomap audioscrobbler[] = {{ "enabled", AUDIOSCROBBLER_ENABLED },
301 { "connectstate", AUDIOSCROBBLER_CONN_STATE }, //labels from here
302 { "submitinterval", AUDIOSCROBBLER_SUBMIT_INT },
303 { "filescached", AUDIOSCROBBLER_FILES_CACHED },
304 { "submitstate", AUDIOSCROBBLER_SUBMIT_STATE }};
306 const infomap lastfm[] = {{ "radioplaying", LASTFM_RADIOPLAYING },
307 { "canlove", LASTFM_CANLOVE},
308 { "canban", LASTFM_CANBAN}};
310 const infomap musicplayer[] = {{ "title", MUSICPLAYER_TITLE },
311 { "album", MUSICPLAYER_ALBUM },
312 { "artist", MUSICPLAYER_ARTIST },
313 { "albumartist", MUSICPLAYER_ALBUM_ARTIST },
314 { "year", MUSICPLAYER_YEAR },
315 { "genre", MUSICPLAYER_GENRE },
316 { "duration", MUSICPLAYER_DURATION },
317 { "tracknumber", MUSICPLAYER_TRACK_NUMBER },
318 { "cover", MUSICPLAYER_COVER },
319 { "bitrate", MUSICPLAYER_BITRATE },
320 { "playlistlength", MUSICPLAYER_PLAYLISTLEN },
321 { "playlistposition", MUSICPLAYER_PLAYLISTPOS },
322 { "channels", MUSICPLAYER_CHANNELS },
323 { "bitspersample", MUSICPLAYER_BITSPERSAMPLE },
324 { "samplerate", MUSICPLAYER_SAMPLERATE },
325 { "codec", MUSICPLAYER_CODEC },
326 { "discnumber", MUSICPLAYER_DISC_NUMBER },
327 { "rating", MUSICPLAYER_RATING },
328 { "comment", MUSICPLAYER_COMMENT },
329 { "lyrics", MUSICPLAYER_LYRICS },
330 { "playlistplaying", MUSICPLAYER_PLAYLISTPLAYING },
331 { "exists", MUSICPLAYER_EXISTS },
332 { "hasprevious", MUSICPLAYER_HASPREVIOUS },
333 { "hasnext", MUSICPLAYER_HASNEXT },
334 { "playcount", MUSICPLAYER_PLAYCOUNT },
335 { "lastplayed", MUSICPLAYER_LASTPLAYED }};
337 const infomap videoplayer[] = {{ "title", VIDEOPLAYER_TITLE },
338 { "genre", VIDEOPLAYER_GENRE },
339 { "country", VIDEOPLAYER_COUNTRY },
340 { "originaltitle", VIDEOPLAYER_ORIGINALTITLE },
341 { "director", VIDEOPLAYER_DIRECTOR },
342 { "year", VIDEOPLAYER_YEAR },
343 { "cover", VIDEOPLAYER_COVER },
344 { "usingoverlays", VIDEOPLAYER_USING_OVERLAYS },
345 { "isfullscreen", VIDEOPLAYER_ISFULLSCREEN },
346 { "hasmenu", VIDEOPLAYER_HASMENU },
347 { "playlistlength", VIDEOPLAYER_PLAYLISTLEN },
348 { "playlistposition", VIDEOPLAYER_PLAYLISTPOS },
349 { "plot", VIDEOPLAYER_PLOT },
350 { "plotoutline", VIDEOPLAYER_PLOT_OUTLINE },
351 { "episode", VIDEOPLAYER_EPISODE },
352 { "season", VIDEOPLAYER_SEASON },
353 { "rating", VIDEOPLAYER_RATING },
354 { "ratingandvotes", VIDEOPLAYER_RATING_AND_VOTES },
355 { "tvshowtitle", VIDEOPLAYER_TVSHOW },
356 { "premiered", VIDEOPLAYER_PREMIERED },
357 { "studio", VIDEOPLAYER_STUDIO },
358 { "mpaa", VIDEOPLAYER_MPAA },
359 { "top250", VIDEOPLAYER_TOP250 },
360 { "cast", VIDEOPLAYER_CAST },
361 { "castandrole", VIDEOPLAYER_CAST_AND_ROLE },
362 { "artist", VIDEOPLAYER_ARTIST },
363 { "album", VIDEOPLAYER_ALBUM },
364 { "writer", VIDEOPLAYER_WRITER },
365 { "tagline", VIDEOPLAYER_TAGLINE },
366 { "hasinfo", VIDEOPLAYER_HAS_INFO },
367 { "trailer", VIDEOPLAYER_TRAILER },
368 { "videocodec", VIDEOPLAYER_VIDEO_CODEC },
369 { "videoresolution", VIDEOPLAYER_VIDEO_RESOLUTION },
370 { "videoaspect", VIDEOPLAYER_VIDEO_ASPECT },
371 { "audiocodec", VIDEOPLAYER_AUDIO_CODEC },
372 { "audiochannels", VIDEOPLAYER_AUDIO_CHANNELS },
373 { "hasteletext", VIDEOPLAYER_HASTELETEXT },
374 { "lastplayed", VIDEOPLAYER_LASTPLAYED },
375 { "playcount", VIDEOPLAYER_PLAYCOUNT },
376 { "hassubtitles", VIDEOPLAYER_HASSUBTITLES },
377 { "subtitlesenabled", VIDEOPLAYER_SUBTITLESENABLED }};
379 const infomap mediacontainer[] = {{ "hasfiles", CONTAINER_HASFILES },
380 { "hasfolders", CONTAINER_HASFOLDERS },
381 { "isstacked", CONTAINER_STACKED },
382 { "folderthumb", CONTAINER_FOLDERTHUMB },
383 { "tvshowthumb", CONTAINER_TVSHOWTHUMB },
384 { "seasonthumb", CONTAINER_SEASONTHUMB },
385 { "folderpath", CONTAINER_FOLDERPATH },
386 { "foldername", CONTAINER_FOLDERNAME },
387 { "pluginname", CONTAINER_PLUGINNAME },
388 { "viewmode", CONTAINER_VIEWMODE },
389 { "totaltime", CONTAINER_TOTALTIME },
390 { "hasthumb", CONTAINER_HAS_THUMB },
391 { "sortmethod", CONTAINER_SORT_METHOD },
392 { "showplot", CONTAINER_SHOWPLOT }};
394 const infomap container_bools[] ={{ "onnext", CONTAINER_MOVE_NEXT },
395 { "onprevious", CONTAINER_MOVE_PREVIOUS },
396 { "onscrollnext", CONTAINER_SCROLL_NEXT },
397 { "onscrollprevious", CONTAINER_SCROLL_PREVIOUS },
398 { "numpages", CONTAINER_NUM_PAGES },
399 { "numitems", CONTAINER_NUM_ITEMS },
400 { "currentpage", CONTAINER_CURRENT_PAGE },
401 { "scrolling", CONTAINER_SCROLLING },
402 { "hasnext", CONTAINER_HAS_NEXT },
403 { "hasprevious", CONTAINER_HAS_PREVIOUS }};
405 const infomap container_ints[] = {{ "row", CONTAINER_ROW },
406 { "column", CONTAINER_COLUMN },
407 { "position", CONTAINER_POSITION },
408 { "subitem", CONTAINER_SUBITEM },
409 { "hasfocus", CONTAINER_HAS_FOCUS }};
411 const infomap container_str[] = {{ "property", CONTAINER_PROPERTY },
412 { "content", CONTAINER_CONTENT }};
414 const infomap listitem_labels[]= {{ "thumb", LISTITEM_THUMB },
415 { "icon", LISTITEM_ICON },
416 { "actualicon", LISTITEM_ACTUAL_ICON },
417 { "overlay", LISTITEM_OVERLAY },
418 { "label", LISTITEM_LABEL },
419 { "label2", LISTITEM_LABEL2 },
420 { "title", LISTITEM_TITLE },
421 { "tracknumber", LISTITEM_TRACKNUMBER },
422 { "artist", LISTITEM_ARTIST },
423 { "album", LISTITEM_ALBUM },
424 { "albumartist", LISTITEM_ALBUM_ARTIST },
425 { "year", LISTITEM_YEAR },
426 { "genre", LISTITEM_GENRE },
427 { "director", LISTITEM_DIRECTOR },
428 { "filename", LISTITEM_FILENAME },
429 { "filenameandpath", LISTITEM_FILENAME_AND_PATH },
430 { "fileextension", LISTITEM_FILE_EXTENSION },
431 { "date", LISTITEM_DATE },
432 { "size", LISTITEM_SIZE },
433 { "rating", LISTITEM_RATING },
434 { "ratingandvotes", LISTITEM_RATING_AND_VOTES },
435 { "programcount", LISTITEM_PROGRAM_COUNT },
436 { "duration", LISTITEM_DURATION },
437 { "isselected", LISTITEM_ISSELECTED },
438 { "isplaying", LISTITEM_ISPLAYING },
439 { "plot", LISTITEM_PLOT },
440 { "plotoutline", LISTITEM_PLOT_OUTLINE },
441 { "episode", LISTITEM_EPISODE },
442 { "season", LISTITEM_SEASON },
443 { "tvshowtitle", LISTITEM_TVSHOW },
444 { "premiered", LISTITEM_PREMIERED },
445 { "comment", LISTITEM_COMMENT },
446 { "path", LISTITEM_PATH },
447 { "foldername", LISTITEM_FOLDERNAME },
448 { "folderpath", LISTITEM_FOLDERPATH },
449 { "picturepath", LISTITEM_PICTURE_PATH },
450 { "pictureresolution",LISTITEM_PICTURE_RESOLUTION },
451 { "picturedatetime", LISTITEM_PICTURE_DATETIME },
452 { "studio", LISTITEM_STUDIO },
453 { "country", LISTITEM_COUNTRY },
454 { "mpaa", LISTITEM_MPAA },
455 { "cast", LISTITEM_CAST },
456 { "castandrole", LISTITEM_CAST_AND_ROLE },
457 { "writer", LISTITEM_WRITER },
458 { "tagline", LISTITEM_TAGLINE },
459 { "top250", LISTITEM_TOP250 },
460 { "trailer", LISTITEM_TRAILER },
461 { "starrating", LISTITEM_STAR_RATING },
462 { "sortletter", LISTITEM_SORT_LETTER },
463 { "videocodec", LISTITEM_VIDEO_CODEC },
464 { "videoresolution", LISTITEM_VIDEO_RESOLUTION },
465 { "videoaspect", LISTITEM_VIDEO_ASPECT },
466 { "audiocodec", LISTITEM_AUDIO_CODEC },
467 { "audiochannels", LISTITEM_AUDIO_CHANNELS },
468 { "audiolanguage", LISTITEM_AUDIO_LANGUAGE },
469 { "subtitlelanguage", LISTITEM_SUBTITLE_LANGUAGE },
470 { "isresumable", LISTITEM_IS_RESUMABLE},
471 { "percentplayed", LISTITEM_PERCENT_PLAYED},
472 { "isfolder", LISTITEM_IS_FOLDER },
473 { "originaltitle", LISTITEM_ORIGINALTITLE },
474 { "lastplayed", LISTITEM_LASTPLAYED },
475 { "playcount", LISTITEM_PLAYCOUNT },
476 { "discnumber", LISTITEM_DISC_NUMBER }};
478 const infomap visualisation[] = {{ "locked", VISUALISATION_LOCKED },
479 { "preset", VISUALISATION_PRESET },
480 { "name", VISUALISATION_NAME },
481 { "enabled", VISUALISATION_ENABLED }};
483 const infomap fanart_labels[] = {{ "color1", FANART_COLOR1 },
484 { "color2", FANART_COLOR2 },
485 { "color3", FANART_COLOR3 },
486 { "image", FANART_IMAGE }};
488 const infomap skin_labels[] = {{ "currenttheme", SKIN_THEME },
489 { "currentcolourtheme",SKIN_COLOUR_THEME },
490 {"hasvideooverlay", SKIN_HAS_VIDEO_OVERLAY},
491 {"hasmusicoverlay", SKIN_HAS_MUSIC_OVERLAY}};
493 const infomap window_bools[] = {{ "ismedia", WINDOW_IS_MEDIA },
494 { "isactive", WINDOW_IS_ACTIVE },
495 { "istopmost", WINDOW_IS_TOPMOST },
496 { "isvisible", WINDOW_IS_VISIBLE },
497 { "previous", WINDOW_PREVIOUS },
498 { "next", WINDOW_NEXT }};
500 const infomap control_labels[] = {{ "hasfocus", CONTROL_HAS_FOCUS },
501 { "isvisible", CONTROL_IS_VISIBLE },
502 { "isenabled", CONTROL_IS_ENABLED },
503 { "getlabel", CONTROL_GET_LABEL }};
505 const infomap playlist[] = {{ "length", PLAYLIST_LENGTH },
506 { "position", PLAYLIST_POSITION },
507 { "random", PLAYLIST_RANDOM },
508 { "repeat", PLAYLIST_REPEAT },
509 { "israndom", PLAYLIST_ISRANDOM },
510 { "isrepeat", PLAYLIST_ISREPEAT },
511 { "isrepeatone", PLAYLIST_ISREPEATONE }};
513 const infomap slideshow[] = {{ "ispaused", SLIDESHOW_ISPAUSED },
514 { "isactive", SLIDESHOW_ISACTIVE },
515 { "israndom", SLIDESHOW_ISRANDOM }};
517 CGUIInfoManager::Property::Property(const CStdString &property, const CStdString ¶meters)
520 CUtil::SplitParams(parameters, params);
523 const CStdString &CGUIInfoManager::Property::param(unsigned int n /* = 0 */) const
525 if (n < params.size())
527 return StringUtils::EmptyString;
530 unsigned int CGUIInfoManager::Property::num_params() const
532 return params.size();
535 void CGUIInfoManager::SplitInfoString(const CStdString &infoString, vector<Property> &info)
537 // our string is of the form:
538 // category[(params)][.info(params).info2(params)] ...
539 // so we need to split on . while taking into account of () pairs
540 unsigned int parentheses = 0;
543 for (size_t i = 0; i < infoString.size(); ++i)
545 if (infoString[i] == '(')
550 else if (infoString[i] == ')')
553 CLog::Log(LOGERROR, "unmatched parentheses in %s", infoString.c_str());
554 else if (!--parentheses)
557 else if (infoString[i] == '.' && !parentheses)
559 if (!property.IsEmpty()) // add our property and parameters
560 info.push_back(Property(property.ToLower(), param));
566 param += infoString[i];
568 property += infoString[i];
571 CLog::Log(LOGERROR, "unmatched parentheses in %s", infoString.c_str());
572 if (!property.IsEmpty())
573 info.push_back(Property(property.ToLower(), param));
576 /// \brief Translates a string as given by the skin into an int that we use for more
577 /// efficient retrieval of data.
578 int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition)
580 // trim whitespace, and convert to lowercase
581 CStdString strTest = strCondition;
582 strTest.TrimLeft(" \t\r\n");
583 strTest.TrimRight(" \t\r\n");
585 vector< Property> info;
586 SplitInfoString(strTest, info);
591 const Property &cat = info[0];
592 if (info.size() == 1)
594 if (cat.name == "false" || cat.name == "no" || cat.name == "off")
595 return SYSTEM_ALWAYS_FALSE;
596 else if (cat.name == "true" || cat.name == "yes" || cat.name == "on")
597 return SYSTEM_ALWAYS_TRUE;
598 if (cat.name == "isempty" && cat.num_params() == 1)
599 return AddMultiInfo(GUIInfo(STRING_IS_EMPTY, TranslateSingleString(cat.param())));
600 else if (cat.name == "stringcompare" && cat.num_params() == 2)
602 int info = TranslateSingleString(cat.param(0));
603 int info2 = TranslateSingleString(cat.param(1));
605 return AddMultiInfo(GUIInfo(STRING_COMPARE, info, -info2));
606 // pipe our original string through the localize parsing then make it lowercase (picks up $LBRACKET etc.)
607 CStdString label = CGUIInfoLabel::GetLabel(cat.param(1)).ToLower();
608 int compareString = ConditionalStringParameter(label);
609 return AddMultiInfo(GUIInfo(STRING_COMPARE, info, compareString));
611 else if (cat.name == "integergreaterthan" && cat.num_params() == 2)
613 int info = TranslateSingleString(cat.param(0));
614 int compareInt = atoi(cat.param(1).c_str());
615 return AddMultiInfo(GUIInfo(INTEGER_GREATER_THAN, info, compareInt));
617 else if (cat.name == "substring" && cat.num_params() >= 2)
619 int info = TranslateSingleString(cat.param(0));
620 CStdString label = CGUIInfoLabel::GetLabel(cat.param(1)).ToLower();
621 int compareString = ConditionalStringParameter(label);
622 if (cat.num_params() > 2)
624 if (cat.param(2).CompareNoCase("left") == 0)
625 return AddMultiInfo(GUIInfo(STRING_STR_LEFT, info, compareString));
626 else if (cat.param(2).CompareNoCase("right") == 0)
627 return AddMultiInfo(GUIInfo(STRING_STR_RIGHT, info, compareString));
629 return AddMultiInfo(GUIInfo(STRING_STR, info, compareString));
632 else if (info.size() == 2)
634 const Property &prop = info[1];
635 if (cat.name == "player")
637 for (size_t i = 0; i < sizeof(player_labels) / sizeof(infomap); i++)
639 if (prop.name == player_labels[i].str)
640 return player_labels[i].val;
642 for (size_t i = 0; i < sizeof(player_times) / sizeof(infomap); i++)
644 if (prop.name == player_times[i].str)
645 return AddMultiInfo(GUIInfo(player_times[i].val, TranslateTimeFormat(prop.param())));
648 else if (cat.name == "weather")
650 for (size_t i = 0; i < sizeof(weather) / sizeof(infomap); i++)
652 if (prop.name == weather[i].str)
653 return weather[i].val;
656 else if (cat.name == "lcd")
658 for (size_t i = 0; i < sizeof(lcd_labels) / sizeof(infomap); i++)
660 if (prop.name == lcd_labels[i].str)
661 return lcd_labels[i].val;
664 else if (cat.name == "network")
666 for (size_t i = 0; i < sizeof(network_labels) / sizeof(infomap); i++)
668 if (prop.name == network_labels[i].str)
669 return network_labels[i].val;
672 else if (cat.name == "musicpartymode")
674 for (size_t i = 0; i < sizeof(musicpartymode) / sizeof(infomap); i++)
676 if (prop.name == musicpartymode[i].str)
677 return musicpartymode[i].val;
680 else if (cat.name == "audioscrobbler")
682 for (size_t i = 0; i < sizeof(audioscrobbler) / sizeof(infomap); i++)
684 if (prop.name == audioscrobbler[i].str)
685 return audioscrobbler[i].val;
688 else if (cat.name == "lastfm")
690 for (size_t i = 0; i < sizeof(lastfm) / sizeof(infomap); i++)
692 if (prop.name == lastfm[i].str)
693 return lastfm[i].val;
696 else if (cat.name == "system")
698 for (size_t i = 0; i < sizeof(system_labels) / sizeof(infomap); i++)
700 if (prop.name == system_labels[i].str)
701 return system_labels[i].val;
703 if (prop.num_params() == 1)
705 const CStdString ¶m = prop.param();
706 for (size_t i = 0; i < sizeof(system_param) / sizeof(infomap); i++)
708 if (prop.name == system_param[i].str)
709 return AddMultiInfo(GUIInfo(system_param[i].val, ConditionalStringParameter(param)));
711 if (prop.name == "memory")
713 if (param == "free") return SYSTEM_FREE_MEMORY;
714 else if (param == "free.percent") return SYSTEM_FREE_MEMORY_PERCENT;
715 else if (param == "used") return SYSTEM_USED_MEMORY;
716 else if (param == "used.percent") return SYSTEM_USED_MEMORY_PERCENT;
717 else if (param == "total") return SYSTEM_TOTAL_MEMORY;
719 else if (prop.name == "addontitle")
721 int infoLabel = TranslateSingleString(param);
723 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_TITLE, infoLabel, 0));
724 CStdString label = CGUIInfoLabel::GetLabel(param).ToLower();
725 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_TITLE, ConditionalStringParameter(label), 1));
727 else if (prop.name == "addonicon")
729 int infoLabel = TranslateSingleString(param);
731 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_ICON, infoLabel, 0));
732 CStdString label = CGUIInfoLabel::GetLabel(param).ToLower();
733 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_ICON, ConditionalStringParameter(label), 1));
735 else if (prop.name == "idletime")
736 return AddMultiInfo(GUIInfo(SYSTEM_IDLE_TIME, atoi(param.c_str())));
738 if (prop.name == "alarmlessorequal" && prop.num_params() == 2)
739 return AddMultiInfo(GUIInfo(SYSTEM_ALARM_LESS_OR_EQUAL, ConditionalStringParameter(prop.param(0)), ConditionalStringParameter(prop.param(1))));
740 else if (prop.name == "date")
742 if (prop.num_params() == 2)
743 return AddMultiInfo(GUIInfo(SYSTEM_DATE, StringUtils::DateStringToYYYYMMDD(prop.param(0)) % 10000, StringUtils::DateStringToYYYYMMDD(prop.param(1)) % 10000));
744 else if (prop.num_params() == 1)
746 int dateformat = StringUtils::DateStringToYYYYMMDD(prop.param(0));
747 if (dateformat <= 0) // not concrete date
748 return AddMultiInfo(GUIInfo(SYSTEM_DATE, ConditionalStringParameter(prop.param(0), true), -1));
750 return AddMultiInfo(GUIInfo(SYSTEM_DATE, dateformat % 10000));
754 else if (prop.name == "time")
756 if (prop.num_params() == 0)
757 return AddMultiInfo(GUIInfo(SYSTEM_TIME, TIME_FORMAT_GUESS));
758 if (prop.num_params() == 1)
760 TIME_FORMAT timeFormat = TranslateTimeFormat(prop.param(0));
761 if (timeFormat == TIME_FORMAT_GUESS)
762 return AddMultiInfo(GUIInfo(SYSTEM_TIME, StringUtils::TimeStringToSeconds(prop.param(0))));
763 return AddMultiInfo(GUIInfo(SYSTEM_TIME, timeFormat));
766 return AddMultiInfo(GUIInfo(SYSTEM_TIME, StringUtils::TimeStringToSeconds(prop.param(0)), StringUtils::TimeStringToSeconds(prop.param(1))));
769 else if (cat.name == "library")
771 if (prop.name == "isscanning") return LIBRARY_IS_SCANNING;
772 else if (prop.name == "isscanningvideo") return LIBRARY_IS_SCANNING_VIDEO; // TODO: change to IsScanning(Video)
773 else if (prop.name == "isscanningmusic") return LIBRARY_IS_SCANNING_MUSIC;
774 else if (prop.name == "hascontent" && prop.num_params())
776 CStdString cat = prop.param(0); cat.ToLower();
777 if (cat == "music") return LIBRARY_HAS_MUSIC;
778 else if (cat == "video") return LIBRARY_HAS_VIDEO;
779 else if (cat == "movies") return LIBRARY_HAS_MOVIES;
780 else if (cat == "tvshows") return LIBRARY_HAS_TVSHOWS;
781 else if (cat == "musicvideos") return LIBRARY_HAS_MUSICVIDEOS;
784 else if (cat.name == "musicplayer")
786 for (size_t i = 0; i < sizeof(player_times) / sizeof(infomap); i++) // TODO: remove these, they're repeats
788 if (prop.name == player_times[i].str)
789 return AddMultiInfo(GUIInfo(player_times[i].val, TranslateTimeFormat(prop.param())));
791 if (prop.name == "property")
792 return AddListItemProp(prop.param(), MUSICPLAYER_PROPERTY_OFFSET);
793 return TranslateMusicPlayerString(prop.name);
795 else if (cat.name == "videoplayer")
797 for (size_t i = 0; i < sizeof(player_times) / sizeof(infomap); i++) // TODO: remove these, they're repeats
799 if (prop.name == player_times[i].str)
800 return AddMultiInfo(GUIInfo(player_times[i].val, TranslateTimeFormat(prop.param())));
802 if (prop.name == "content" && prop.num_params())
803 return AddMultiInfo(GUIInfo(VIDEOPLAYER_CONTENT, ConditionalStringParameter(prop.param()), 0));
804 for (size_t i = 0; i < sizeof(videoplayer) / sizeof(infomap); i++)
806 if (prop.name == videoplayer[i].str)
807 return videoplayer[i].val;
810 else if (cat.name == "slideshow")
812 for (size_t i = 0; i < sizeof(slideshow) / sizeof(infomap); i++)
814 if (prop.name == slideshow[i].str)
815 return slideshow[i].val;
817 return CPictureInfoTag::TranslateString(prop.name);
819 else if (cat.name == "container")
821 for (size_t i = 0; i < sizeof(mediacontainer) / sizeof(infomap); i++) // these ones don't have or need an id
823 if (prop.name == mediacontainer[i].str)
824 return mediacontainer[i].val;
826 int id = atoi(cat.param().c_str());
827 for (size_t i = 0; i < sizeof(container_bools) / sizeof(infomap); i++) // these ones can have an id (but don't need to?)
829 if (prop.name == container_bools[i].str)
830 return id ? AddMultiInfo(GUIInfo(container_bools[i].val, id)) : container_bools[i].val;
832 for (size_t i = 0; i < sizeof(container_ints) / sizeof(infomap); i++) // these ones can have an int param on the property
834 if (prop.name == container_ints[i].str)
835 return AddMultiInfo(GUIInfo(container_ints[i].val, id, atoi(prop.param().c_str())));
837 for (size_t i = 0; i < sizeof(container_str) / sizeof(infomap); i++) // these ones have a string param on the property
839 if (prop.name == container_str[i].str)
840 return AddMultiInfo(GUIInfo(container_str[i].val, id, ConditionalStringParameter(prop.param())));
842 if (prop.name == "sortdirection")
844 SORT_ORDER order = SORT_ORDER_NONE;
845 if (prop.param().Equals("ascending"))
846 order = SORT_ORDER_ASC;
847 else if (prop.param().Equals("descending"))
848 order = SORT_ORDER_DESC;
849 return AddMultiInfo(GUIInfo(CONTAINER_SORT_DIRECTION, order));
851 else if (prop.name == "sort")
853 SORT_METHOD sort = SORT_METHOD_NONE;
854 if (prop.param().Equals("songrating")) sort = SORT_METHOD_SONG_RATING;
855 if (sort != SORT_METHOD_NONE)
856 return AddMultiInfo(GUIInfo(CONTAINER_SORT_METHOD, sort));
859 else if (cat.name == "listitem")
861 int offset = atoi(cat.param().c_str());
862 int ret = TranslateListItem(prop);
863 if (offset || ret == LISTITEM_ISSELECTED || ret == LISTITEM_ISPLAYING || ret == LISTITEM_IS_FOLDER)
864 return AddMultiInfo(GUIInfo(ret, 0, offset, INFOFLAG_LISTITEM_WRAP));
867 else if (cat.name == "listitemposition")
869 int offset = atoi(cat.param().c_str());
870 int ret = TranslateListItem(prop);
871 if (offset || ret == LISTITEM_ISSELECTED || ret == LISTITEM_ISPLAYING || ret == LISTITEM_IS_FOLDER)
872 return AddMultiInfo(GUIInfo(ret, 0, offset, INFOFLAG_LISTITEM_POSITION));
875 else if (cat.name == "listitemnowrap")
877 int offset = atoi(cat.param().c_str());
878 int ret = TranslateListItem(prop);
879 if (offset || ret == LISTITEM_ISSELECTED || ret == LISTITEM_ISPLAYING || ret == LISTITEM_IS_FOLDER)
880 return AddMultiInfo(GUIInfo(ret, 0, offset));
883 else if (cat.name == "visualisation")
885 for (size_t i = 0; i < sizeof(visualisation) / sizeof(infomap); i++)
887 if (prop.name == visualisation[i].str)
888 return visualisation[i].val;
891 else if (cat.name == "fanart")
893 for (size_t i = 0; i < sizeof(fanart_labels) / sizeof(infomap); i++)
895 if (prop.name == fanart_labels[i].str)
896 return fanart_labels[i].val;
899 else if (cat.name == "skin")
901 for (size_t i = 0; i < sizeof(skin_labels) / sizeof(infomap); i++)
903 if (prop.name == skin_labels[i].str)
904 return skin_labels[i].val;
906 if (prop.num_params())
908 if (prop.name == "string")
910 if (prop.num_params() == 2)
911 return AddMultiInfo(GUIInfo(SKIN_STRING, g_settings.TranslateSkinString(prop.param(0)), ConditionalStringParameter(prop.param(1))));
913 return AddMultiInfo(GUIInfo(SKIN_STRING, g_settings.TranslateSkinString(prop.param(0))));
915 if (prop.name == "hassetting")
916 return AddMultiInfo(GUIInfo(SKIN_BOOL, g_settings.TranslateSkinBool(prop.param(0))));
917 else if (prop.name == "hastheme")
918 return AddMultiInfo(GUIInfo(SKIN_HAS_THEME, ConditionalStringParameter(prop.param(0))));
921 else if (cat.name == "window")
923 if (prop.name == "property" && prop.num_params() == 1)
924 { // TODO: this doesn't support foo.xml
925 int winID = cat.param().IsEmpty() ? 0 : CButtonTranslator::TranslateWindow(cat.param());
926 if (winID != WINDOW_INVALID)
927 return AddMultiInfo(GUIInfo(WINDOW_PROPERTY, winID, ConditionalStringParameter(prop.param())));
929 for (size_t i = 0; i < sizeof(window_bools) / sizeof(infomap); i++)
931 if (prop.name == window_bools[i].str)
932 { // TODO: The parameter for these should really be on the first not the second property
933 if (prop.param().Find("xml") >= 0)
934 return AddMultiInfo(GUIInfo(window_bools[i].val, 0, ConditionalStringParameter(prop.param())));
935 int winID = prop.param().IsEmpty() ? 0 : CButtonTranslator::TranslateWindow(prop.param());
936 if (winID != WINDOW_INVALID)
937 return AddMultiInfo(GUIInfo(window_bools[i].val, winID, 0));
942 else if (cat.name == "control")
944 for (size_t i = 0; i < sizeof(control_labels) / sizeof(infomap); i++)
946 if (prop.name == control_labels[i].str)
947 { // TODO: The parameter for these should really be on the first not the second property
948 int controlID = atoi(prop.param().c_str());
950 return AddMultiInfo(GUIInfo(control_labels[i].val, controlID, 0));
955 else if (cat.name == "controlgroup" && prop.name == "hasfocus")
957 int groupID = atoi(cat.param().c_str());
959 return AddMultiInfo(GUIInfo(CONTROL_GROUP_HAS_FOCUS, groupID, atoi(prop.param(0).c_str())));
961 else if (cat.name == "playlist")
963 for (size_t i = 0; i < sizeof(playlist) / sizeof(infomap); i++)
965 if (prop.name == playlist[i].str)
966 return playlist[i].val;
970 else if (info.size() == 3)
972 if (info[0].name == "system" && info[1].name == "platform")
973 { // TODO: replace with a single system.platform
974 CStdString platform = info[2].name;
975 if (platform == "linux") return SYSTEM_PLATFORM_LINUX;
976 else if (platform == "windows") return SYSTEM_PLATFORM_WINDOWS;
977 else if (platform == "osx") return SYSTEM_PLATFORM_OSX;
979 if (info[0].name == "musicplayer")
980 { // TODO: these two don't allow duration(foo) and also don't allow more than this number of levels...
981 if (info[1].name == "position")
983 int position = atoi(info[1].param().c_str());
984 int value = TranslateMusicPlayerString(info[2].name); // musicplayer.position(foo).bar
985 return AddMultiInfo(GUIInfo(value, 0, position));
987 else if (info[1].name == "offset")
989 int position = atoi(info[1].param().c_str());
990 int value = TranslateMusicPlayerString(info[2].name); // musicplayer.offset(foo).bar
991 return AddMultiInfo(GUIInfo(value, 1, position));
994 else if (info[0].name == "container")
996 int id = atoi(info[0].param().c_str());
997 int offset = atoi(info[1].param().c_str());
998 if (info[1].name == "listitemnowrap")
999 return AddMultiInfo(GUIInfo(TranslateListItem(info[2]), id, offset));
1000 else if (info[1].name == "listitemposition")
1001 return AddMultiInfo(GUIInfo(TranslateListItem(info[2]), id, offset, INFOFLAG_LISTITEM_POSITION));
1002 else if (info[1].name == "listitem")
1003 return AddMultiInfo(GUIInfo(TranslateListItem(info[2]), id, offset, INFOFLAG_LISTITEM_WRAP));
1010 int CGUIInfoManager::TranslateListItem(const Property &info)
1012 for (size_t i = 0; i < sizeof(listitem_labels) / sizeof(infomap); i++) // these ones don't have or need an id
1014 if (info.name == listitem_labels[i].str)
1015 return listitem_labels[i].val;
1017 if (info.name == "property" && info.num_params() == 1)
1018 return AddListItemProp(info.param());
1022 int CGUIInfoManager::TranslateMusicPlayerString(const CStdString &info) const
1024 for (size_t i = 0; i < sizeof(musicplayer) / sizeof(infomap); i++)
1026 if (info == musicplayer[i].str)
1027 return musicplayer[i].val;
1032 TIME_FORMAT CGUIInfoManager::TranslateTimeFormat(const CStdString &format)
1034 if (format.IsEmpty()) return TIME_FORMAT_GUESS;
1035 else if (format.Equals("hh")) return TIME_FORMAT_HH;
1036 else if (format.Equals("mm")) return TIME_FORMAT_MM;
1037 else if (format.Equals("ss")) return TIME_FORMAT_SS;
1038 else if (format.Equals("hh:mm")) return TIME_FORMAT_HH_MM;
1039 else if (format.Equals("mm:ss")) return TIME_FORMAT_MM_SS;
1040 else if (format.Equals("hh:mm:ss")) return TIME_FORMAT_HH_MM_SS;
1041 else if (format.Equals("h")) return TIME_FORMAT_H;
1042 else if (format.Equals("h:mm:ss")) return TIME_FORMAT_H_MM_SS;
1043 else if (format.Equals("xx")) return TIME_FORMAT_XX;
1044 return TIME_FORMAT_GUESS;
1047 CStdString CGUIInfoManager::GetLabel(int info, int contextWindow)
1049 if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
1050 return GetSkinVariableString(info, contextWindow, false);
1052 CStdString strLabel;
1053 if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
1054 return GetMultiInfoLabel(m_multiInfo[info - MULTI_INFO_START], contextWindow);
1056 if (info >= SLIDE_INFO_START && info <= SLIDE_INFO_END)
1057 return GetPictureLabel(info);
1059 if (info >= LISTITEM_PROPERTY_START+MUSICPLAYER_PROPERTY_OFFSET &&
1060 info - (LISTITEM_PROPERTY_START+MUSICPLAYER_PROPERTY_OFFSET) < (int)m_listitemProperties.size())
1061 { // grab the property
1065 CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START-MUSICPLAYER_PROPERTY_OFFSET];
1066 return m_currentFile->GetProperty(property).asString();
1069 if (info >= LISTITEM_START && info <= LISTITEM_END)
1071 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS); // true for has list items
1074 CFileItemPtr item = window->GetCurrentListItem();
1075 strLabel = GetItemLabel(item.get(), info);
1083 case WEATHER_CONDITIONS:
1084 strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_COND);
1085 strLabel = strLabel.Trim();
1087 case WEATHER_TEMPERATURE:
1088 strLabel.Format("%s%s", g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_TEMP), g_langInfo.GetTempUnitString().c_str());
1090 case WEATHER_LOCATION:
1091 strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_LOCATION);
1093 case WEATHER_FANART_CODE:
1094 strLabel = URIUtils::GetFileName(g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON));
1095 URIUtils::RemoveExtension(strLabel);
1097 case WEATHER_PLUGIN:
1098 strLabel = g_guiSettings.GetString("weather.script");
1101 strLabel = GetDate();
1104 strLabel = GetDate(true);
1107 strLabel.Format("%02.2f", m_fps);
1110 strLabel.Format("%2.1f dB", (float)(g_settings.m_nVolumeLevel + g_settings.m_dynamicRangeCompressionLevel) * 0.01f);
1112 case PLAYER_SUBTITLE_DELAY:
1113 strLabel.Format("%2.3f s", g_settings.m_currentVideoSettings.m_SubtitleDelay);
1115 case PLAYER_AUDIO_DELAY:
1116 strLabel.Format("%2.3f s", g_settings.m_currentVideoSettings.m_AudioDelay);
1118 case PLAYER_CHAPTER:
1119 if(g_application.IsPlaying() && g_application.m_pPlayer)
1120 strLabel.Format("%02d", g_application.m_pPlayer->GetChapter());
1122 case PLAYER_CHAPTERCOUNT:
1123 if(g_application.IsPlaying() && g_application.m_pPlayer)
1124 strLabel.Format("%02d", g_application.m_pPlayer->GetChapterCount());
1126 case PLAYER_CHAPTERNAME:
1127 if(g_application.IsPlaying() && g_application.m_pPlayer)
1128 g_application.m_pPlayer->GetChapterName(strLabel);
1130 case PLAYER_CACHELEVEL:
1133 if(g_application.IsPlaying() && GetInt(iLevel, PLAYER_CACHELEVEL) && iLevel >= 0)
1134 strLabel.Format("%i", iLevel);
1138 if(g_application.IsPlaying() && g_application.m_pPlayer)
1139 strLabel = GetCurrentPlayTime(TIME_FORMAT_HH_MM);
1141 case PLAYER_DURATION:
1142 if(g_application.IsPlaying() && g_application.m_pPlayer)
1143 strLabel = GetDuration(TIME_FORMAT_HH_MM);
1146 case PLAYER_FILEPATH:
1149 if (m_currentFile->HasMusicInfoTag())
1150 strLabel = m_currentFile->GetMusicInfoTag()->GetURL();
1151 else if (m_currentFile->HasVideoInfoTag())
1152 strLabel = m_currentFile->GetVideoInfoTag()->m_strFileNameAndPath;
1153 if (strLabel.IsEmpty())
1154 strLabel = m_currentFile->GetPath();
1156 if (info == PLAYER_PATH)
1158 // do this twice since we want the path outside the archive if this
1160 if (URIUtils::IsInArchive(strLabel))
1161 strLabel = URIUtils::GetParentPath(strLabel);
1162 strLabel = URIUtils::GetParentPath(strLabel);
1165 case MUSICPLAYER_TITLE:
1166 case MUSICPLAYER_ALBUM:
1167 case MUSICPLAYER_ARTIST:
1168 case MUSICPLAYER_ALBUM_ARTIST:
1169 case MUSICPLAYER_GENRE:
1170 case MUSICPLAYER_YEAR:
1171 case MUSICPLAYER_TRACK_NUMBER:
1172 case MUSICPLAYER_BITRATE:
1173 case MUSICPLAYER_PLAYLISTLEN:
1174 case MUSICPLAYER_PLAYLISTPOS:
1175 case MUSICPLAYER_CHANNELS:
1176 case MUSICPLAYER_BITSPERSAMPLE:
1177 case MUSICPLAYER_SAMPLERATE:
1178 case MUSICPLAYER_CODEC:
1179 case MUSICPLAYER_DISC_NUMBER:
1180 case MUSICPLAYER_RATING:
1181 case MUSICPLAYER_COMMENT:
1182 case MUSICPLAYER_LYRICS:
1183 case MUSICPLAYER_PLAYCOUNT:
1184 case MUSICPLAYER_LASTPLAYED:
1185 strLabel = GetMusicLabel(info);
1187 case VIDEOPLAYER_TITLE:
1188 case VIDEOPLAYER_ORIGINALTITLE:
1189 case VIDEOPLAYER_GENRE:
1190 case VIDEOPLAYER_DIRECTOR:
1191 case VIDEOPLAYER_YEAR:
1192 case VIDEOPLAYER_PLAYLISTLEN:
1193 case VIDEOPLAYER_PLAYLISTPOS:
1194 case VIDEOPLAYER_PLOT:
1195 case VIDEOPLAYER_PLOT_OUTLINE:
1196 case VIDEOPLAYER_EPISODE:
1197 case VIDEOPLAYER_SEASON:
1198 case VIDEOPLAYER_RATING:
1199 case VIDEOPLAYER_RATING_AND_VOTES:
1200 case VIDEOPLAYER_TVSHOW:
1201 case VIDEOPLAYER_PREMIERED:
1202 case VIDEOPLAYER_STUDIO:
1203 case VIDEOPLAYER_COUNTRY:
1204 case VIDEOPLAYER_MPAA:
1205 case VIDEOPLAYER_TOP250:
1206 case VIDEOPLAYER_CAST:
1207 case VIDEOPLAYER_CAST_AND_ROLE:
1208 case VIDEOPLAYER_ARTIST:
1209 case VIDEOPLAYER_ALBUM:
1210 case VIDEOPLAYER_WRITER:
1211 case VIDEOPLAYER_TAGLINE:
1212 case VIDEOPLAYER_TRAILER:
1213 case VIDEOPLAYER_PLAYCOUNT:
1214 case VIDEOPLAYER_LASTPLAYED:
1215 strLabel = GetVideoLabel(info);
1217 case VIDEOPLAYER_VIDEO_CODEC:
1218 if(g_application.IsPlaying() && g_application.m_pPlayer)
1219 strLabel = g_application.m_pPlayer->GetVideoCodecName();
1221 case VIDEOPLAYER_VIDEO_RESOLUTION:
1222 if(g_application.IsPlaying() && g_application.m_pPlayer)
1223 return CStreamDetails::VideoDimsToResolutionDescription(g_application.m_pPlayer->GetPictureWidth(), g_application.m_pPlayer->GetPictureHeight());
1225 case VIDEOPLAYER_AUDIO_CODEC:
1226 if(g_application.IsPlaying() && g_application.m_pPlayer)
1227 strLabel = g_application.m_pPlayer->GetAudioCodecName();
1229 case VIDEOPLAYER_VIDEO_ASPECT:
1230 if (g_application.IsPlaying() && g_application.m_pPlayer)
1233 g_application.m_pPlayer->GetVideoAspectRatio(aspect);
1234 strLabel = CStreamDetails::VideoAspectToAspectDescription(aspect);
1237 case VIDEOPLAYER_AUDIO_CHANNELS:
1238 if(g_application.IsPlaying() && g_application.m_pPlayer)
1239 strLabel.Format("%i", g_application.m_pPlayer->GetChannels());
1241 case PLAYLIST_LENGTH:
1242 case PLAYLIST_POSITION:
1243 case PLAYLIST_RANDOM:
1244 case PLAYLIST_REPEAT:
1245 strLabel = GetPlaylistLabel(info);
1247 case MUSICPM_SONGSPLAYED:
1248 case MUSICPM_MATCHINGSONGS:
1249 case MUSICPM_MATCHINGSONGSPICKED:
1250 case MUSICPM_MATCHINGSONGSLEFT:
1251 case MUSICPM_RELAXEDSONGSPICKED:
1252 case MUSICPM_RANDOMSONGSPICKED:
1253 strLabel = GetMusicPartyModeLabel(info);
1256 case SYSTEM_FREE_SPACE:
1257 case SYSTEM_USED_SPACE:
1258 case SYSTEM_TOTAL_SPACE:
1259 case SYSTEM_FREE_SPACE_PERCENT:
1260 case SYSTEM_USED_SPACE_PERCENT:
1261 return g_sysinfo.GetHddSpaceInfo(info);
1264 case SYSTEM_CPU_TEMPERATURE:
1265 case SYSTEM_GPU_TEMPERATURE:
1266 case SYSTEM_FAN_SPEED:
1267 case LCD_CPU_TEMPERATURE:
1268 case LCD_GPU_TEMPERATURE:
1270 case SYSTEM_CPU_USAGE:
1271 return GetSystemHeatInfo(info);
1274 case SYSTEM_VIDEO_ENCODER_INFO:
1275 case NETWORK_MAC_ADDRESS:
1276 case SYSTEM_KERNEL_VERSION:
1277 case SYSTEM_CPUFREQUENCY:
1278 case SYSTEM_INTERNET_STATE:
1280 case SYSTEM_TOTALUPTIME:
1281 case SYSTEM_BATTERY_LEVEL:
1282 return g_sysinfo.GetInfo(info);
1285 case SYSTEM_SCREEN_RESOLUTION:
1286 if (g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].bFullScreen)
1287 strLabel.Format("%ix%i@%.2fHz - %s (%02.2f fps)",
1288 g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iWidth,
1289 g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iHeight,
1290 g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].fRefreshRate,
1291 g_localizeStrings.Get(244), GetFPS());
1293 strLabel.Format("%ix%i - %s (%02.2f fps)",
1294 g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iWidth,
1295 g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iHeight,
1296 g_localizeStrings.Get(242), GetFPS());
1300 case CONTAINER_FOLDERPATH:
1301 case CONTAINER_FOLDERNAME:
1303 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1306 if (info==CONTAINER_FOLDERNAME)
1307 strLabel = ((CGUIMediaWindow*)window)->CurrentDirectory().GetLabel();
1309 strLabel = CURL(((CGUIMediaWindow*)window)->CurrentDirectory().GetPath()).GetWithoutUserDetails();
1313 case CONTAINER_PLUGINNAME:
1315 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1318 CURL url(((CGUIMediaWindow*)window)->CurrentDirectory().GetPath());
1319 if (url.GetProtocol().Equals("plugin"))
1321 strLabel = url.GetFileName();
1322 URIUtils::RemoveSlashAtEnd(strLabel);
1327 case CONTAINER_VIEWMODE:
1329 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1332 const CGUIControl *control = window->GetControl(window->GetViewContainerID());
1333 if (control && control->IsContainer())
1334 strLabel = ((CGUIBaseContainer *)control)->GetLabel();
1338 case CONTAINER_SORT_METHOD:
1340 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1343 const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
1345 strLabel = g_localizeStrings.Get(viewState->GetSortMethodLabel());
1349 case CONTAINER_NUM_PAGES:
1350 case CONTAINER_NUM_ITEMS:
1351 case CONTAINER_CURRENT_PAGE:
1352 return GetMultiInfoLabel(GUIInfo(info), contextWindow);
1354 case CONTAINER_SHOWPLOT:
1356 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1358 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("showplot").asString();
1361 case CONTAINER_TOTALTIME:
1363 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1366 const CFileItemList& items=((CGUIMediaWindow *)window)->CurrentDirectory();
1368 for (int i=0;i<items.Size();++i)
1370 CFileItemPtr item=items.Get(i);
1371 if (item->HasMusicInfoTag())
1372 duration += item->GetMusicInfoTag()->GetDuration();
1373 else if (item->HasVideoInfoTag())
1374 duration += item->GetVideoInfoTag()->m_streamDetails.GetVideoDuration();
1377 return StringUtils::SecondsToTimeString(duration);
1381 case SYSTEM_BUILD_VERSION:
1382 strLabel = GetVersion();
1384 case SYSTEM_BUILD_DATE:
1385 strLabel = GetBuild();
1387 case SYSTEM_FREE_MEMORY:
1388 case SYSTEM_FREE_MEMORY_PERCENT:
1389 case SYSTEM_USED_MEMORY:
1390 case SYSTEM_USED_MEMORY_PERCENT:
1391 case SYSTEM_TOTAL_MEMORY:
1394 GlobalMemoryStatus(&stat);
1395 int iMemPercentFree = 100 - ((int)( 100.0f* (stat.dwTotalPhys - stat.dwAvailPhys)/stat.dwTotalPhys + 0.5f ));
1396 int iMemPercentUsed = 100 - iMemPercentFree;
1398 if (info == SYSTEM_FREE_MEMORY)
1399 strLabel.Format("%luMB", (ULONG)(stat.dwAvailPhys/MB));
1400 else if (info == SYSTEM_FREE_MEMORY_PERCENT)
1401 strLabel.Format("%i%%", iMemPercentFree);
1402 else if (info == SYSTEM_USED_MEMORY)
1403 strLabel.Format("%luMB", (ULONG)((stat.dwTotalPhys - stat.dwAvailPhys)/MB));
1404 else if (info == SYSTEM_USED_MEMORY_PERCENT)
1405 strLabel.Format("%i%%", iMemPercentUsed);
1406 else if (info == SYSTEM_TOTAL_MEMORY)
1407 strLabel.Format("%luMB", (ULONG)(stat.dwTotalPhys/MB));
1410 case SYSTEM_SCREEN_MODE:
1411 strLabel = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].strMode;
1413 case SYSTEM_SCREEN_WIDTH:
1414 strLabel.Format("%i", g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].iWidth);
1416 case SYSTEM_SCREEN_HEIGHT:
1417 strLabel.Format("%i", g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].iHeight);
1419 case SYSTEM_CURRENT_WINDOW:
1420 return g_localizeStrings.Get(g_windowManager.GetFocusedWindow());
1422 case SYSTEM_CURRENT_CONTROL:
1424 CGUIWindow *window = g_windowManager.GetWindow(g_windowManager.GetFocusedWindow());
1427 CGUIControl *control = window->GetFocusedControl();
1429 strLabel = control->GetDescription();
1433 #ifdef HAS_DVD_DRIVE
1434 case SYSTEM_DVD_LABEL:
1435 strLabel = g_mediaManager.GetDiskLabel();
1438 case SYSTEM_ALARM_POS:
1439 if (g_alarmClock.GetRemaining("shutdowntimer") == 0.f)
1443 double fTime = g_alarmClock.GetRemaining("shutdowntimer");
1445 strLabel.Format(g_localizeStrings.Get(13213).c_str(),g_alarmClock.GetRemaining("shutdowntimer")/60.f);
1447 strLabel.Format(g_localizeStrings.Get(13214).c_str(),g_alarmClock.GetRemaining("shutdowntimer"));
1450 case SYSTEM_PROFILENAME:
1451 strLabel = g_settings.GetCurrentProfile().getName();
1453 case SYSTEM_PROFILECOUNT:
1454 strLabel.Format("%i", g_settings.GetNumProfiles());
1456 case SYSTEM_LANGUAGE:
1457 strLabel = g_guiSettings.GetString("locale.language");
1459 case SYSTEM_TEMPERATURE_UNITS:
1460 strLabel = g_langInfo.GetTempUnitString();
1462 case SYSTEM_PROGRESS_BAR:
1465 if (GetInt(percent, SYSTEM_PROGRESS_BAR) && percent > 0)
1466 strLabel.Format("%i", percent);
1469 case SYSTEM_FRIENDLY_NAME:
1471 CStdString friendlyName = g_guiSettings.GetString("services.devicename");
1472 if (friendlyName.Equals("XBMC"))
1473 strLabel.Format("%s (%s)", friendlyName.c_str(), g_application.getNetwork().GetHostName().c_str());
1475 strLabel = friendlyName;
1480 int iPlaySpeed = g_application.GetPlaySpeed();
1481 if (g_application.IsPaused())
1482 strLabel.Format("\7");
1483 else if (iPlaySpeed < 1)
1484 strLabel.Format("\3:%ix", iPlaySpeed);
1485 else if (iPlaySpeed > 1)
1486 strLabel.Format("\4:%ix", iPlaySpeed);
1488 strLabel.Format("\5");
1500 //alternatively, set strLabel
1501 return GetLcdTime( info );
1505 if (g_guiSettings.GetString("lookandfeel.skintheme").Equals("skindefault"))
1506 strLabel = g_localizeStrings.Get(15109);
1508 strLabel = g_guiSettings.GetString("lookandfeel.skintheme");
1510 case SKIN_COLOUR_THEME:
1511 if (g_guiSettings.GetString("lookandfeel.skincolors").Equals("skindefault"))
1512 strLabel = g_localizeStrings.Get(15109);
1514 strLabel = g_guiSettings.GetString("lookandfeel.skincolors");
1517 case LCD_PROGRESS_BAR:
1518 if (g_lcd) strLabel = g_lcd->GetProgressBar(g_application.GetTime(), g_application.GetTotalTime());
1521 case NETWORK_IP_ADDRESS:
1523 CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1525 return iface->GetCurrentIPAddress();
1528 case NETWORK_SUBNET_MASK:
1530 CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1532 return iface->GetCurrentNetmask();
1535 case NETWORK_GATEWAY_ADDRESS:
1537 CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1539 return iface->GetCurrentDefaultGateway();
1542 case NETWORK_DNS1_ADDRESS:
1544 vector<CStdString> nss = g_application.getNetwork().GetNameServers();
1545 if (nss.size() >= 1)
1549 case NETWORK_DNS2_ADDRESS:
1551 vector<CStdString> nss = g_application.getNetwork().GetNameServers();
1552 if (nss.size() >= 2)
1556 case NETWORK_DHCP_ADDRESS:
1558 CStdString dhcpserver;
1562 case NETWORK_LINK_STATE:
1564 CStdString linkStatus = g_localizeStrings.Get(151);
1566 CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1567 if (iface && iface->IsConnected())
1568 linkStatus += g_localizeStrings.Get(15207);
1570 linkStatus += g_localizeStrings.Get(15208);
1575 case AUDIOSCROBBLER_CONN_STATE:
1576 case AUDIOSCROBBLER_SUBMIT_INT:
1577 case AUDIOSCROBBLER_FILES_CACHED:
1578 case AUDIOSCROBBLER_SUBMIT_STATE:
1579 strLabel=GetAudioScrobblerLabel(info);
1581 case VISUALISATION_PRESET:
1583 CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
1584 g_windowManager.SendMessage(msg);
1585 if (msg.GetPointer())
1587 CVisualisation* viz = NULL;
1588 viz = (CVisualisation*)msg.GetPointer();
1591 strLabel = viz->GetPresetName();
1592 URIUtils::RemoveExtension(strLabel);
1597 case VISUALISATION_NAME:
1600 strLabel = g_guiSettings.GetString("musicplayer.visualisation");
1601 if (CAddonMgr::Get().GetAddon(strLabel,addon) && addon)
1602 strLabel = addon->Name();
1607 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1609 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color1").asString();
1614 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1616 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color2").asString();
1621 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1623 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color3").asString();
1628 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1630 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_image").asString();
1633 case SYSTEM_RENDER_VENDOR:
1634 strLabel = g_Windowing.GetRenderVendor();
1636 case SYSTEM_RENDER_RENDERER:
1637 strLabel = g_Windowing.GetRenderRenderer();
1639 case SYSTEM_RENDER_VERSION:
1640 strLabel = g_Windowing.GetRenderVersionString();
1647 // tries to get a integer value for use in progressbars/sliders and such
1648 bool CGUIInfoManager::GetInt(int &value, int info, int contextWindow, const CGUIListItem *item /* = NULL */) const
1650 if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
1651 return GetMultiInfoInt(value, m_multiInfo[info - MULTI_INFO_START], contextWindow);
1653 if (info >= LISTITEM_START && info <= LISTITEM_END)
1654 return GetItemInt(value, item, info);
1660 value = g_application.GetVolume();
1662 case PLAYER_SUBTITLE_DELAY:
1663 value = g_application.GetSubtitleDelay();
1665 case PLAYER_AUDIO_DELAY:
1666 value = g_application.GetAudioDelay();
1668 case PLAYER_PROGRESS:
1669 case PLAYER_PROGRESS_CACHE:
1670 case PLAYER_SEEKBAR:
1671 case PLAYER_CACHELEVEL:
1672 case PLAYER_CHAPTER:
1673 case PLAYER_CHAPTERCOUNT:
1675 if( g_application.IsPlaying() && g_application.m_pPlayer)
1679 case PLAYER_PROGRESS:
1680 value = (int)(g_application.GetPercentage());
1682 case PLAYER_PROGRESS_CACHE:
1683 value = (int)(g_application.GetCachePercentage());
1685 case PLAYER_SEEKBAR:
1687 CGUIDialogSeekBar *seekBar = (CGUIDialogSeekBar*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
1688 value = seekBar ? (int)seekBar->GetPercentage() : 0;
1691 case PLAYER_CACHELEVEL:
1692 value = (int)(g_application.m_pPlayer->GetCacheLevel());
1694 case PLAYER_CHAPTER:
1695 value = g_application.m_pPlayer->GetChapter();
1697 case PLAYER_CHAPTERCOUNT:
1698 value = g_application.m_pPlayer->GetChapterCount();
1704 case SYSTEM_FREE_MEMORY:
1705 case SYSTEM_USED_MEMORY:
1708 GlobalMemoryStatus(&stat);
1709 int memPercentUsed = (int)( 100.0f* (stat.dwTotalPhys - stat.dwAvailPhys)/stat.dwTotalPhys + 0.5f );
1710 if (info == SYSTEM_FREE_MEMORY)
1711 value = 100 - memPercentUsed;
1713 value = memPercentUsed;
1716 case SYSTEM_PROGRESS_BAR:
1718 CGUIDialogProgress *bar = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
1719 if (bar && bar->IsDialogRunning())
1720 value = bar->GetPercentage();
1723 case SYSTEM_FREE_SPACE:
1724 case SYSTEM_USED_SPACE:
1726 g_sysinfo.GetHddSpaceInfo(value, info, true);
1729 case SYSTEM_CPU_USAGE:
1730 value = g_cpuInfo.getUsedPercentage();
1732 case SYSTEM_BATTERY_LEVEL:
1733 value = g_powerManager.BatteryLevel();
1739 unsigned int CGUIInfoManager::Register(const CStdString &expression, int context)
1741 CStdString condition(CGUIInfoLabel::ReplaceLocalize(expression));
1742 condition.TrimLeft(" \t\r\n");
1743 condition.TrimRight(" \t\r\n");
1745 if (condition.IsEmpty())
1748 CSingleLock lock(m_critInfo);
1749 // do we have the boolean expression already registered?
1750 InfoBool test(condition, context);
1751 for (unsigned int i = 0; i < m_bools.size(); ++i)
1753 if (*m_bools[i] == test)
1757 if (condition.find_first_of("|+[]!") != condition.npos)
1758 m_bools.push_back(new InfoExpression(condition, context));
1760 m_bools.push_back(new InfoSingle(condition, context));
1762 return m_bools.size();
1765 bool CGUIInfoManager::EvaluateBool(const CStdString &expression, int contextWindow)
1767 bool result = false;
1768 unsigned int info = Register(expression, contextWindow);
1770 result = GetBoolValue(info);
1775 TODO: what to do with item-based infobools...
1777 1. if condition is between LISTITEM_START and LISTITEM_END
1778 2. if condition is STRING_IS_EMPTY, STRING_COMPARE, STRING_STR, INTEGER_GREATER_THAN and the
1779 corresponding label is between LISTITEM_START and LISTITEM_END
1781 In both cases they shouldn't be in our cache as they depend on items outside of our control atm.
1783 We only pass a listitem object in for controls inside a listitemlayout, so I think it's probably OK
1784 to not cache these, as they're "pushed" out anyway.
1786 The problem is how do we avoid these? The only thing we have to go on is the expression here, so I
1787 guess what we have to do is call through via Update. One thing we don't handle, however, is that the
1788 majority of conditions (even inside lists) don't depend on the listitem at all.
1790 Advantage is that we know this at creation time I think, so could perhaps signal it in IsDirty()?
1792 bool CGUIInfoManager::GetBoolValue(unsigned int expression, const CGUIListItem *item)
1794 if (expression && --expression < m_bools.size())
1795 return m_bools[expression]->Get(m_updateTime, item);
1799 // checks the condition and returns it as necessary. Currently used
1800 // for toggle button controls and visibility of images.
1801 bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListItem *item)
1803 bool bReturn = false;
1804 int condition = abs(condition1);
1806 if (item && condition >= LISTITEM_START && condition < LISTITEM_END)
1807 bReturn = GetItemBool(item, condition);
1808 // Ethernet Link state checking
1809 // Will check if the Xbox has a Ethernet Link connection! [Cable in!]
1810 // This can used for the skinner to switch off Network or Inter required functions
1811 else if ( condition == SYSTEM_ALWAYS_TRUE)
1813 else if (condition == SYSTEM_ALWAYS_FALSE)
1815 else if (condition == SYSTEM_ETHERNET_LINK_ACTIVE)
1817 else if (condition == WINDOW_IS_MEDIA)
1818 { // note: This doesn't return true for dialogs (content, favourites, login, videoinfo)
1819 CGUIWindow *pWindow = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
1820 bReturn = (pWindow && pWindow->IsMediaWindow());
1822 else if (condition == PLAYER_MUTED)
1823 bReturn = g_settings.m_bMute;
1824 else if (condition >= LIBRARY_HAS_MUSIC && condition <= LIBRARY_HAS_MUSICVIDEOS)
1825 bReturn = GetLibraryBool(condition);
1826 else if (condition == LIBRARY_IS_SCANNING)
1828 CGUIDialogMusicScan *musicScanner = (CGUIDialogMusicScan *)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_SCAN);
1829 CGUIDialogVideoScan *videoScanner = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN);
1830 if (musicScanner->IsScanning() || videoScanner->IsScanning())
1835 else if (condition == LIBRARY_IS_SCANNING_VIDEO)
1837 CGUIDialogVideoScan *videoScanner = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN);
1838 bReturn = (videoScanner && videoScanner->IsScanning());
1840 else if (condition == LIBRARY_IS_SCANNING_MUSIC)
1842 CGUIDialogMusicScan *musicScanner = (CGUIDialogMusicScan *)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_SCAN);
1843 bReturn = (musicScanner && musicScanner->IsScanning());
1845 else if (condition == SYSTEM_PLATFORM_LINUX)
1846 #if defined(_LINUX) && !defined(__APPLE__)
1851 else if (condition == SYSTEM_PLATFORM_WINDOWS)
1857 else if (condition == SYSTEM_PLATFORM_OSX)
1863 else if (condition == SYSTEM_MEDIA_DVD)
1864 bReturn = g_mediaManager.IsDiscInDrive();
1865 #ifdef HAS_DVD_DRIVE
1866 else if (condition == SYSTEM_HAS_DRIVE_F)
1867 bReturn = CIoSupport::DriveExists('F');
1868 else if (condition == SYSTEM_HAS_DRIVE_G)
1869 bReturn = CIoSupport::DriveExists('G');
1870 else if (condition == SYSTEM_DVDREADY)
1871 bReturn = g_mediaManager.GetDriveStatus() != DRIVE_NOT_READY;
1872 else if (condition == SYSTEM_TRAYOPEN)
1873 bReturn = g_mediaManager.GetDriveStatus() == DRIVE_OPEN;
1875 else if (condition == SYSTEM_CAN_POWERDOWN)
1876 bReturn = g_powerManager.CanPowerdown();
1877 else if (condition == SYSTEM_CAN_SUSPEND)
1878 bReturn = g_powerManager.CanSuspend();
1879 else if (condition == SYSTEM_CAN_HIBERNATE)
1880 bReturn = g_powerManager.CanHibernate();
1881 else if (condition == SYSTEM_CAN_REBOOT)
1882 bReturn = g_powerManager.CanReboot();
1884 else if (condition == PLAYER_SHOWINFO)
1885 bReturn = m_playerShowInfo;
1886 else if (condition == PLAYER_SHOWCODEC)
1887 bReturn = m_playerShowCodec;
1888 else if (condition >= MULTI_INFO_START && condition <= MULTI_INFO_END)
1890 return GetMultiInfoBool(m_multiInfo[condition - MULTI_INFO_START], contextWindow, item);
1892 else if (condition == SYSTEM_HASLOCKS)
1893 bReturn = g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE;
1894 else if (condition == SYSTEM_ISMASTER)
1895 bReturn = g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && g_passwordManager.bMasterUser;
1896 else if (condition == SYSTEM_ISFULLSCREEN)
1897 bReturn = g_Windowing.IsFullScreen();
1898 else if (condition == SYSTEM_ISSTANDALONE)
1899 bReturn = g_application.IsStandAlone();
1900 else if (condition == SYSTEM_LOGGEDON)
1901 bReturn = !(g_windowManager.GetActiveWindow() == WINDOW_LOGIN_SCREEN);
1902 else if (condition == SYSTEM_SHOW_EXIT_BUTTON)
1903 bReturn = g_advancedSettings.m_showExitButton;
1904 else if (condition == SYSTEM_HAS_LOGINSCREEN)
1905 bReturn = g_settings.UsingLoginScreen();
1906 else if (condition == WEATHER_IS_FETCHED)
1907 bReturn = g_weatherManager.IsFetched();
1908 else if (condition == SYSTEM_INTERNET_STATE)
1910 g_sysinfo.GetInfo(condition);
1911 bReturn = g_sysinfo.HasInternet();
1913 else if (condition == SKIN_HAS_VIDEO_OVERLAY)
1915 bReturn = g_windowManager.IsOverlayAllowed() && g_application.IsPlayingVideo();
1917 else if (condition == SKIN_HAS_MUSIC_OVERLAY)
1919 bReturn = g_windowManager.IsOverlayAllowed() && g_application.IsPlayingAudio();
1921 else if (condition == CONTAINER_HASFILES || condition == CONTAINER_HASFOLDERS)
1923 CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1926 const CFileItemList& items=((CGUIMediaWindow*)pWindow)->CurrentDirectory();
1927 for (int i=0;i<items.Size();++i)
1929 CFileItemPtr item=items.Get(i);
1930 if (!item->m_bIsFolder && condition == CONTAINER_HASFILES)
1935 else if (item->m_bIsFolder && !item->IsParentFolder() && condition == CONTAINER_HASFOLDERS)
1943 else if (condition == CONTAINER_STACKED)
1945 CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1947 bReturn = ((CGUIMediaWindow*)pWindow)->CurrentDirectory().GetProperty("isstacked")=="1";
1949 else if (condition == CONTAINER_HAS_THUMB)
1951 CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1953 bReturn = ((CGUIMediaWindow*)pWindow)->CurrentDirectory().HasThumbnail();
1955 else if (condition == CONTAINER_HAS_NEXT || condition == CONTAINER_HAS_PREVIOUS || condition == CONTAINER_SCROLLING)
1957 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1960 const CGUIControl* control = window->GetControl(window->GetViewContainerID());
1962 bReturn = control->GetCondition(condition, 0);
1965 else if (condition == VIDEOPLAYER_HAS_INFO)
1966 bReturn = (m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->IsEmpty());
1967 else if (condition >= CONTAINER_SCROLL_PREVIOUS && condition <= CONTAINER_SCROLL_NEXT)
1969 // no parameters, so we assume it's just requested for a media window. It therefore
1970 // can only happen if the list has focus.
1971 CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1974 map<int,int>::const_iterator it = m_containerMoves.find(pWindow->GetViewContainerID());
1975 if (it != m_containerMoves.end())
1977 if (condition > CONTAINER_STATIC) // moving up
1978 bReturn = it->second >= std::max(condition - CONTAINER_STATIC, 1);
1980 bReturn = it->second <= std::min(condition - CONTAINER_STATIC, -1);
1984 else if (condition == SLIDESHOW_ISPAUSED)
1986 CGUIWindowSlideShow *slideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
1987 bReturn = (slideShow && slideShow->IsPaused());
1989 else if (condition == SLIDESHOW_ISRANDOM)
1991 CGUIWindowSlideShow *slideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
1992 bReturn = (slideShow && slideShow->IsShuffled());
1994 else if (condition == SLIDESHOW_ISACTIVE)
1996 CGUIWindowSlideShow *slideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
1997 bReturn = (slideShow && slideShow->InSlideShow());
1999 else if (g_application.IsPlaying())
2003 case PLAYER_HAS_MEDIA:
2006 case PLAYER_HAS_AUDIO:
2007 bReturn = g_application.IsPlayingAudio();
2009 case PLAYER_HAS_VIDEO:
2010 bReturn = g_application.IsPlayingVideo();
2012 case PLAYER_PLAYING:
2013 bReturn = !g_application.IsPaused() && (g_application.GetPlaySpeed() == 1);
2016 bReturn = g_application.IsPaused();
2018 case PLAYER_REWINDING:
2019 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() < 1;
2021 case PLAYER_FORWARDING:
2022 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() > 1;
2024 case PLAYER_REWINDING_2x:
2025 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -2;
2027 case PLAYER_REWINDING_4x:
2028 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -4;
2030 case PLAYER_REWINDING_8x:
2031 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -8;
2033 case PLAYER_REWINDING_16x:
2034 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -16;
2036 case PLAYER_REWINDING_32x:
2037 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -32;
2039 case PLAYER_FORWARDING_2x:
2040 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 2;
2042 case PLAYER_FORWARDING_4x:
2043 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 4;
2045 case PLAYER_FORWARDING_8x:
2046 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 8;
2048 case PLAYER_FORWARDING_16x:
2049 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 16;
2051 case PLAYER_FORWARDING_32x:
2052 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 32;
2054 case PLAYER_CAN_RECORD:
2055 bReturn = g_application.m_pPlayer->CanRecord();
2057 case PLAYER_RECORDING:
2058 bReturn = g_application.m_pPlayer->IsRecording();
2060 case PLAYER_DISPLAY_AFTER_SEEK:
2061 bReturn = GetDisplayAfterSeek();
2063 case PLAYER_CACHING:
2064 bReturn = g_application.m_pPlayer->IsCaching();
2066 case PLAYER_SEEKBAR:
2068 CGUIDialogSeekBar *seekBar = (CGUIDialogSeekBar*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
2069 bReturn = seekBar ? seekBar->IsDialogRunning() : false;
2072 case PLAYER_SEEKING:
2073 bReturn = m_playerSeeking;
2075 case PLAYER_SHOWTIME:
2076 bReturn = m_playerShowTime;
2078 case PLAYER_PASSTHROUGH:
2079 bReturn = g_application.m_pPlayer && g_application.m_pPlayer->IsPassthrough();
2081 case MUSICPM_ENABLED:
2082 bReturn = g_partyModeManager.IsEnabled();
2084 case AUDIOSCROBBLER_ENABLED:
2085 bReturn = CLastFmManager::GetInstance()->IsLastFmEnabled();
2087 case LASTFM_RADIOPLAYING:
2088 bReturn = CLastFmManager::GetInstance()->IsRadioEnabled();
2090 case LASTFM_CANLOVE:
2091 bReturn = CLastFmManager::GetInstance()->CanLove();
2094 bReturn = CLastFmManager::GetInstance()->CanBan();
2096 case MUSICPLAYER_HASPREVIOUS:
2098 // requires current playlist be PLAYLIST_MUSIC
2100 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2101 bReturn = (g_playlistPlayer.GetCurrentSong() > 0); // not first song
2104 case MUSICPLAYER_HASNEXT:
2106 // requires current playlist be PLAYLIST_MUSIC
2108 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2109 bReturn = (g_playlistPlayer.GetCurrentSong() < (g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC).size() - 1)); // not last song
2112 case MUSICPLAYER_PLAYLISTPLAYING:
2115 if (g_application.IsPlayingAudio() && g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2119 case VIDEOPLAYER_USING_OVERLAYS:
2120 bReturn = (g_guiSettings.GetInt("videoplayer.rendermethod") == RENDER_OVERLAYS);
2122 case VIDEOPLAYER_ISFULLSCREEN:
2123 bReturn = g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO;
2125 case VIDEOPLAYER_HASMENU:
2126 bReturn = g_application.m_pPlayer->HasMenu();
2128 case PLAYLIST_ISRANDOM:
2129 bReturn = g_playlistPlayer.IsShuffled(g_playlistPlayer.GetCurrentPlaylist());
2131 case PLAYLIST_ISREPEAT:
2132 bReturn = g_playlistPlayer.GetRepeat(g_playlistPlayer.GetCurrentPlaylist()) == PLAYLIST::REPEAT_ALL;
2134 case PLAYLIST_ISREPEATONE:
2135 bReturn = g_playlistPlayer.GetRepeat(g_playlistPlayer.GetCurrentPlaylist()) == PLAYLIST::REPEAT_ONE;
2137 case PLAYER_HASDURATION:
2138 bReturn = g_application.GetTotalTime() > 0;
2140 case VIDEOPLAYER_HASTELETEXT:
2141 if (g_application.m_pPlayer->GetTeletextCache())
2144 case VIDEOPLAYER_HASSUBTITLES:
2145 bReturn = g_application.m_pPlayer->GetSubtitleCount() > 0;
2147 case VIDEOPLAYER_SUBTITLESENABLED:
2148 bReturn = g_application.m_pPlayer->GetSubtitleVisible();
2150 case VISUALISATION_LOCKED:
2152 CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
2153 g_windowManager.SendMessage(msg);
2154 if (msg.GetPointer())
2156 CVisualisation *pVis = (CVisualisation *)msg.GetPointer();
2157 bReturn = pVis->IsLocked();
2161 case VISUALISATION_ENABLED:
2162 bReturn = !g_guiSettings.GetString("musicplayer.visualisation").IsEmpty();
2164 default: // default, use integer value different from 0 as true
2167 bReturn = GetInt(val, condition) && val != 0;
2176 /// \brief Examines the multi information sent and returns true or false accordingly.
2177 bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, const CGUIListItem *item)
2179 bool bReturn = false;
2180 int condition = abs(info.m_info);
2182 if (condition >= LISTITEM_START && condition <= LISTITEM_END)
2186 CGUIWindow *window = NULL;
2187 int data1 = info.GetData1();
2188 if (!data1) // No container specified, so we lookup the current view container
2190 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
2191 if (window && window->IsMediaWindow())
2192 data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
2195 if (!window) // If we don't have a window already (from lookup above), get one
2196 window = GetWindowWithCondition(contextWindow, 0);
2200 const CGUIControl *control = window->GetControl(data1);
2201 if (control && control->IsContainer())
2202 item = ((CGUIBaseContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()).get();
2205 if (item) // If we got a valid item, do the lookup
2206 bReturn = GetItemBool(item, condition); // Image prioritizes images over labels (in the case of music item ratings for instance)
2214 bReturn = g_settings.GetSkinBool(info.GetData1());
2219 if (info.GetData2())
2220 bReturn = g_settings.GetSkinString(info.GetData1()).Equals(m_stringParameters[info.GetData2()]);
2222 bReturn = !g_settings.GetSkinString(info.GetData1()).IsEmpty();
2225 case SKIN_HAS_THEME:
2227 CStdString theme = g_guiSettings.GetString("lookandfeel.skintheme");
2229 URIUtils::RemoveExtension(theme);
2230 bReturn = theme.Equals(m_stringParameters[info.GetData1()]);
2233 case STRING_IS_EMPTY:
2234 // note: Get*Image() falls back to Get*Label(), so this should cover all of them
2235 if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2236 bReturn = GetItemImage((const CFileItem *)item, info.GetData1()).IsEmpty();
2238 bReturn = GetImage(info.GetData1(), contextWindow).IsEmpty();
2240 case STRING_COMPARE:
2243 if (info.GetData2() < 0) // info labels are stored with negative numbers
2245 int info2 = -info.GetData2();
2246 if (item && item->IsFileItem() && info2 >= LISTITEM_START && info2 < LISTITEM_END)
2247 compare = GetItemImage((const CFileItem *)item, info2);
2249 compare = GetImage(info2, contextWindow);
2251 else if (info.GetData2() < (int)m_stringParameters.size())
2252 { // conditional string
2253 compare = m_stringParameters[info.GetData2()];
2255 if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2256 bReturn = GetItemImage((const CFileItem *)item, info.GetData1()).Equals(compare);
2258 bReturn = GetImage(info.GetData1(), contextWindow).Equals(compare);
2261 case INTEGER_GREATER_THAN:
2264 if (GetInt(integer, info.GetData1(), contextWindow, item))
2265 bReturn = integer > info.GetData2();
2270 if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2271 value = GetItemImage((const CFileItem *)item, info.GetData1());
2273 value = GetImage(info.GetData1(), contextWindow);
2275 // Handle the case when a value contains time separator (:). This makes IntegerGreaterThan
2276 // useful for Player.Time* members without adding a separate set of members returning time in seconds
2277 if ( value.find_first_of( ':' ) != value.npos )
2278 bReturn = StringUtils::TimeStringToSeconds( value ) > info.GetData2();
2280 bReturn = atoi( value.c_str() ) > info.GetData2();
2285 case STRING_STR_LEFT:
2286 case STRING_STR_RIGHT:
2288 CStdString compare = m_stringParameters[info.GetData2()];
2289 // our compare string is already in lowercase, so lower case our label as well
2290 // as CStdString::Find() is case sensitive
2292 if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2293 label = GetItemImage((const CFileItem *)item, info.GetData1()).ToLower();
2295 label = GetImage(info.GetData1(), contextWindow).ToLower();
2296 if (condition == STRING_STR_LEFT)
2297 bReturn = label.Find(compare) == 0;
2298 else if (condition == STRING_STR_RIGHT)
2299 bReturn = label.Find(compare) == (int)(label.size()-compare.size());
2301 bReturn = label.Find(compare) > -1;
2304 case SYSTEM_ALARM_LESS_OR_EQUAL:
2306 int time = lrint(g_alarmClock.GetRemaining(m_stringParameters[info.GetData1()]));
2307 int timeCompare = atoi(m_stringParameters[info.GetData2()]);
2309 bReturn = timeCompare >= time;
2314 case SYSTEM_IDLE_TIME:
2315 bReturn = g_application.GlobalIdleTime() >= (int)info.GetData1();
2317 case CONTROL_GROUP_HAS_FOCUS:
2319 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2321 bReturn = window->ControlGroupHasFocus(info.GetData1(), info.GetData2());
2324 case CONTROL_IS_VISIBLE:
2326 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2329 // Note: This'll only work for unique id's
2330 const CGUIControl *control = window->GetControl(info.GetData1());
2332 bReturn = control->IsVisible();
2336 case CONTROL_IS_ENABLED:
2338 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2341 // Note: This'll only work for unique id's
2342 const CGUIControl *control = window->GetControl(info.GetData1());
2344 bReturn = !control->IsDisabled();
2348 case CONTROL_HAS_FOCUS:
2350 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2352 bReturn = (window->GetFocusedControlID() == (int)info.GetData1());
2356 if (info.GetData1())
2357 bReturn = ((int)info.GetData1() == m_nextWindowID);
2360 CGUIWindow *window = g_windowManager.GetWindow(m_nextWindowID);
2361 if (window && URIUtils::GetFileName(window->GetProperty("xmlfile").asString()).Equals(m_stringParameters[info.GetData2()]))
2365 case WINDOW_PREVIOUS:
2366 if (info.GetData1())
2367 bReturn = ((int)info.GetData1() == m_prevWindowID);
2370 CGUIWindow *window = g_windowManager.GetWindow(m_prevWindowID);
2371 if (window && URIUtils::GetFileName(window->GetProperty("xmlfile").asString()).Equals(m_stringParameters[info.GetData2()]))
2375 case WINDOW_IS_VISIBLE:
2376 if (info.GetData1())
2377 bReturn = g_windowManager.IsWindowVisible(info.GetData1());
2379 bReturn = g_windowManager.IsWindowVisible(m_stringParameters[info.GetData2()]);
2381 case WINDOW_IS_TOPMOST:
2382 if (info.GetData1())
2383 bReturn = g_windowManager.IsWindowTopMost(info.GetData1());
2385 bReturn = g_windowManager.IsWindowTopMost(m_stringParameters[info.GetData2()]);
2387 case WINDOW_IS_ACTIVE:
2388 if (info.GetData1())
2389 bReturn = g_windowManager.IsWindowActive(info.GetData1());
2391 bReturn = g_windowManager.IsWindowActive(m_stringParameters[info.GetData2()]);
2393 case SYSTEM_HAS_ALARM:
2394 bReturn = g_alarmClock.HasAlarm(m_stringParameters[info.GetData1()]);
2396 case SYSTEM_GET_BOOL:
2397 bReturn = g_guiSettings.GetBool(m_stringParameters[info.GetData1()]);
2399 case SYSTEM_HAS_CORE_ID:
2400 bReturn = g_cpuInfo.HasCoreId(info.GetData1());
2402 case SYSTEM_SETTING:
2404 if ( m_stringParameters[info.GetData1()].Equals("hidewatched") )
2406 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2408 bReturn = g_settings.GetWatchMode(((CGUIMediaWindow *)window)->CurrentDirectory().GetContent()) == VIDEO_SHOW_UNWATCHED;
2412 case SYSTEM_HAS_ADDON:
2415 bReturn = CAddonMgr::Get().GetAddon(m_stringParameters[info.GetData1()],addon) && addon;
2418 case CONTAINER_SCROLL_PREVIOUS:
2419 case CONTAINER_MOVE_PREVIOUS:
2420 case CONTAINER_MOVE_NEXT:
2421 case CONTAINER_SCROLL_NEXT:
2423 map<int,int>::const_iterator it = m_containerMoves.find(info.GetData1());
2424 if (it != m_containerMoves.end())
2426 if (condition > CONTAINER_STATIC) // moving up
2427 bReturn = it->second >= std::max(condition - CONTAINER_STATIC, 1);
2429 bReturn = it->second <= std::min(condition - CONTAINER_STATIC, -1);
2433 case CONTAINER_CONTENT:
2436 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2439 if (window->GetID() == WINDOW_DIALOG_MUSIC_INFO)
2440 content = ((CGUIDialogMusicInfo *)window)->CurrentDirectory().GetContent();
2441 else if (window->GetID() == WINDOW_DIALOG_VIDEO_INFO)
2442 content = ((CGUIDialogVideoInfo *)window)->CurrentDirectory().GetContent();
2444 if (content.IsEmpty())
2446 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2448 content = ((CGUIMediaWindow *)window)->CurrentDirectory().GetContent();
2450 bReturn = m_stringParameters[info.GetData2()].Equals(content);
2454 case CONTAINER_COLUMN:
2455 case CONTAINER_POSITION:
2456 case CONTAINER_HAS_NEXT:
2457 case CONTAINER_HAS_PREVIOUS:
2458 case CONTAINER_SCROLLING:
2459 case CONTAINER_SUBITEM:
2461 const CGUIControl *control = NULL;
2462 if (info.GetData1())
2463 { // container specified
2464 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2466 control = window->GetControl(info.GetData1());
2469 { // no container specified - assume a mediawindow
2470 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2472 control = window->GetControl(window->GetViewContainerID());
2475 bReturn = control->GetCondition(condition, info.GetData2());
2478 case CONTAINER_HAS_FOCUS:
2479 { // grab our container
2480 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2483 const CGUIControl *control = window->GetControl(info.GetData1());
2484 if (control && control->IsContainer())
2486 CFileItemPtr item = boost::static_pointer_cast<CFileItem>(((CGUIBaseContainer *)control)->GetListItem(0));
2487 if (item && item->m_iprogramCount == info.GetData2()) // programcount used to store item id
2493 case VIDEOPLAYER_CONTENT:
2495 CStdString strContent="movies";
2496 if (!m_currentFile->HasVideoInfoTag() || m_currentFile->GetVideoInfoTag()->IsEmpty())
2497 strContent = "files";
2498 if (m_currentFile->HasVideoInfoTag() && m_currentFile->GetVideoInfoTag()->m_iSeason > -1) // episode
2499 strContent = "episodes";
2500 if (m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->m_strArtist.IsEmpty())
2501 strContent = "musicvideos";
2502 if (m_currentFile->HasVideoInfoTag() && m_currentFile->GetVideoInfoTag()->m_strStatus == "livetv")
2503 strContent = "livetv";
2504 bReturn = m_stringParameters[info.GetData1()].Equals(strContent);
2507 case CONTAINER_SORT_METHOD:
2509 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2512 const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
2514 bReturn = ((unsigned int)viewState->GetSortMethod() == info.GetData1());
2518 case CONTAINER_SORT_DIRECTION:
2520 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2523 const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
2525 bReturn = ((unsigned int)viewState->GetDisplaySortOrder() == info.GetData1());
2531 if (info.GetData2() == -1) // info doesn't contain valid startDate
2533 CDateTime date = CDateTime::GetCurrentDateTime();
2534 int currentDate = date.GetMonth()*100+date.GetDay();
2535 int startDate = info.GetData1();
2536 int stopDate = info.GetData2();
2538 if (stopDate < startDate)
2539 bReturn = currentDate >= startDate || currentDate < stopDate;
2541 bReturn = currentDate >= startDate && currentDate < stopDate;
2546 CDateTime time=CDateTime::GetCurrentDateTime();
2547 int currentTime = time.GetMinuteOfDay();
2548 int startTime = info.GetData1();
2549 int stopTime = info.GetData2();
2551 if (stopTime < startTime)
2552 bReturn = currentTime >= startTime || currentTime < stopTime;
2554 bReturn = currentTime >= startTime && currentTime < stopTime;
2557 case MUSICPLAYER_EXISTS:
2559 int index = info.GetData2();
2560 if (info.GetData1() == 1)
2562 if (g_playlistPlayer.GetCurrentPlaylist() != PLAYLIST_MUSIC)
2564 index += g_playlistPlayer.GetCurrentSong();
2566 if (index >= 0 && index < g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC).size())
2573 return (info.m_info < 0) ? !bReturn : bReturn;
2576 bool CGUIInfoManager::GetMultiInfoInt(int &value, const GUIInfo &info, int contextWindow) const
2578 if (info.m_info >= LISTITEM_START && info.m_info <= LISTITEM_END)
2581 CGUIWindow *window = NULL;
2583 int data1 = info.GetData1();
2584 if (!data1) // No container specified, so we lookup the current view container
2586 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
2587 if (window && window->IsMediaWindow())
2588 data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
2591 if (!window) // If we don't have a window already (from lookup above), get one
2592 window = GetWindowWithCondition(contextWindow, 0);
2596 const CGUIControl *control = window->GetControl(data1);
2597 if (control && control->IsContainer())
2598 item = boost::static_pointer_cast<CFileItem>(((CGUIBaseContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()));
2601 if (item) // If we got a valid item, do the lookup
2602 return GetItemInt(value, item.get(), info.m_info);
2608 /// \brief Examines the multi information sent and returns the string as appropriate
2609 CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWindow)
2611 if (info.m_info == SKIN_STRING)
2613 return g_settings.GetSkinString(info.GetData1());
2615 else if (info.m_info == SKIN_BOOL)
2617 bool bInfo = g_settings.GetSkinBool(info.GetData1());
2619 return g_localizeStrings.Get(20122);
2621 if (info.m_info >= LISTITEM_START && info.m_info <= LISTITEM_END)
2624 CGUIWindow *window = NULL;
2626 int data1 = info.GetData1();
2627 if (!data1) // No container specified, so we lookup the current view container
2629 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
2630 if (window && window->IsMediaWindow())
2631 data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
2634 if (!window) // If we don't have a window already (from lookup above), get one
2635 window = GetWindowWithCondition(contextWindow, 0);
2639 const CGUIControl *control = window->GetControl(data1);
2640 if (control && control->IsContainer())
2641 item = boost::static_pointer_cast<CFileItem>(((CGUIBaseContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()));
2644 if (item) // If we got a valid item, do the lookup
2645 return GetItemImage(item.get(), info.m_info); // Image prioritizes images over labels (in the case of music item ratings for instance)
2647 else if (info.m_info == PLAYER_TIME)
2649 return GetCurrentPlayTime((TIME_FORMAT)info.GetData1());
2651 else if (info.m_info == PLAYER_TIME_REMAINING)
2653 return GetCurrentPlayTimeRemaining((TIME_FORMAT)info.GetData1());
2655 else if (info.m_info == PLAYER_FINISH_TIME)
2657 CDateTime time = CDateTime::GetCurrentDateTime();
2658 time += CDateTimeSpan(0, 0, 0, GetPlayTimeRemaining());
2659 return LocalizeTime(time, (TIME_FORMAT)info.GetData1());
2661 else if (info.m_info == PLAYER_TIME_SPEED)
2664 if (g_application.GetPlaySpeed() != 1)
2665 strTime.Format("%s (%ix)", GetCurrentPlayTime((TIME_FORMAT)info.GetData1()).c_str(), g_application.GetPlaySpeed());
2667 strTime = GetCurrentPlayTime();
2670 else if (info.m_info == PLAYER_DURATION)
2672 return GetDuration((TIME_FORMAT)info.GetData1());
2674 else if (info.m_info == PLAYER_SEEKTIME)
2676 TIME_FORMAT format = (TIME_FORMAT)info.GetData1();
2677 if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
2678 format = TIME_FORMAT_HH_MM_SS;
2679 CGUIDialogSeekBar *seekBar = (CGUIDialogSeekBar*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
2681 return seekBar->GetSeekTimeLabel(format);
2683 else if (info.m_info == PLAYER_SEEKOFFSET)
2685 CStdString seekOffset = StringUtils::SecondsToTimeString(abs(m_seekOffset), (TIME_FORMAT)info.GetData1());
2686 if (m_seekOffset < 0)
2687 return "-" + seekOffset;
2688 if (m_seekOffset > 0)
2689 return "+" + seekOffset;
2691 else if (info.m_info == SYSTEM_TIME)
2693 return GetTime((TIME_FORMAT)info.GetData1());
2695 else if (info.m_info == SYSTEM_DATE)
2697 CDateTime time=CDateTime::GetCurrentDateTime();
2698 return time.GetAsLocalizedDate(m_stringParameters[info.GetData1()],false);
2700 else if (info.m_info == CONTAINER_NUM_PAGES || info.m_info == CONTAINER_CURRENT_PAGE ||
2701 info.m_info == CONTAINER_NUM_ITEMS || info.m_info == CONTAINER_POSITION)
2703 const CGUIControl *control = NULL;
2704 if (info.GetData1())
2705 { // container specified
2706 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2708 control = window->GetControl(info.GetData1());
2711 { // no container specified - assume a mediawindow
2712 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2714 control = window->GetControl(window->GetViewContainerID());
2718 if (control->IsContainer())
2719 return ((CGUIBaseContainer *)control)->GetLabel(info.m_info);
2720 else if (control->GetControlType() == CGUIControl::GUICONTROL_TEXTBOX)
2721 return ((CGUITextBox *)control)->GetLabel(info.m_info);
2724 else if (info.m_info == SYSTEM_GET_CORE_USAGE)
2727 strCpu.Format("%4.2f", g_cpuInfo.GetCoreInfo(atoi(m_stringParameters[info.GetData1()].c_str())).m_fPct);
2730 else if (info.m_info >= MUSICPLAYER_TITLE && info.m_info <= MUSICPLAYER_ALBUM_ARTIST)
2731 return GetMusicPlaylistInfo(info);
2732 else if (info.m_info == CONTAINER_PROPERTY)
2734 CGUIWindow *window = NULL;
2735 if (info.GetData1())
2736 { // container specified
2737 window = GetWindowWithCondition(contextWindow, 0);
2740 { // no container specified - assume a mediawindow
2741 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2744 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty(m_stringParameters[info.GetData2()]).asString();
2746 else if (info.m_info == CONTROL_GET_LABEL)
2748 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2751 const CGUIControl *control = window->GetControl(info.GetData1());
2753 return control->GetDescription();
2756 else if (info.m_info == WINDOW_PROPERTY)
2758 CGUIWindow *window = NULL;
2759 if (info.GetData1())
2760 { // window specified
2761 window = g_windowManager.GetWindow(info.GetData1());//GetWindowWithCondition(contextWindow, 0);
2764 { // no window specified - assume active
2765 window = GetWindowWithCondition(contextWindow, 0);
2769 return window->GetProperty(m_stringParameters[info.GetData2()]).asString();
2771 else if (info.m_info == SYSTEM_ADDON_TITLE ||
2772 info.m_info == SYSTEM_ADDON_ICON)
2775 if (info.GetData2() == 0)
2776 CAddonMgr::Get().GetAddon(const_cast<CGUIInfoManager*>(this)->GetLabel(info.GetData1(), contextWindow),addon);
2778 CAddonMgr::Get().GetAddon(m_stringParameters[info.GetData1()],addon);
2779 if (addon && info.m_info == SYSTEM_ADDON_TITLE)
2780 return addon->Name();
2781 if (addon && info.m_info == SYSTEM_ADDON_ICON)
2782 return addon->Icon();
2785 return StringUtils::EmptyString;
2788 /// \brief Obtains the filename of the image to show from whichever subsystem is needed
2789 CStdString CGUIInfoManager::GetImage(int info, int contextWindow)
2791 if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
2792 return GetSkinVariableString(info, contextWindow, true);
2794 if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
2796 return GetMultiInfoLabel(m_multiInfo[info - MULTI_INFO_START], contextWindow);
2798 else if (info == WEATHER_CONDITIONS)
2799 return g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON);
2800 else if (info == SYSTEM_PROFILETHUMB)
2802 CStdString thumb = g_settings.GetCurrentProfile().getThumb();
2803 if (thumb.IsEmpty())
2804 thumb = "unknown-user.png";
2807 else if (info == MUSICPLAYER_COVER)
2809 if (!g_application.IsPlayingAudio()) return "";
2810 return m_currentFile->HasThumbnail() ? m_currentFile->GetThumbnailImage() : "DefaultAlbumCover.png";
2812 else if (info == MUSICPLAYER_RATING)
2814 if (!g_application.IsPlayingAudio()) return "";
2815 return GetItemImage(m_currentFile, LISTITEM_RATING);
2817 else if (info == PLAYER_STAR_RATING)
2819 if (!g_application.IsPlaying()) return "";
2820 return GetItemImage(m_currentFile, LISTITEM_STAR_RATING);
2822 else if (info == VIDEOPLAYER_COVER)
2824 if (!g_application.IsPlayingVideo()) return "";
2825 if(m_currentMovieThumb.IsEmpty())
2826 return m_currentFile->HasThumbnail() ? m_currentFile->GetThumbnailImage() : "DefaultVideoCover.png";
2827 else return m_currentMovieThumb;
2829 else if (info == CONTAINER_FOLDERTHUMB)
2831 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2833 return GetItemImage(&const_cast<CFileItemList&>(((CGUIMediaWindow*)window)->CurrentDirectory()), LISTITEM_THUMB);
2835 else if (info == CONTAINER_TVSHOWTHUMB)
2837 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2839 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("tvshowthumb").asString();
2841 else if (info == CONTAINER_SEASONTHUMB)
2843 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2845 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("seasonthumb").asString();
2847 else if (info == LISTITEM_THUMB || info == LISTITEM_ICON || info == LISTITEM_ACTUAL_ICON ||
2848 info == LISTITEM_OVERLAY || info == LISTITEM_RATING || info == LISTITEM_STAR_RATING)
2850 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
2853 CFileItemPtr item = window->GetCurrentListItem();
2855 return GetItemImage(item.get(), info);
2858 return GetLabel(info, contextWindow);
2861 CStdString CGUIInfoManager::GetDate(bool bNumbersOnly)
2863 CDateTime time=CDateTime::GetCurrentDateTime();
2864 return time.GetAsLocalizedDate(!bNumbersOnly);
2867 CStdString CGUIInfoManager::GetTime(TIME_FORMAT format) const
2869 CDateTime time=CDateTime::GetCurrentDateTime();
2870 return LocalizeTime(time, format);
2873 CStdString CGUIInfoManager::GetLcdTime( int _eInfo ) const
2875 CDateTime time=CDateTime::GetCurrentDateTime();
2876 CStdString strLcdTime;
2882 CStdString strTimeMarker;
2890 nCharset = 1; // CUSTOM_CHARSET_SMALLCHAR;
2892 strTimeMarker = ".";
2895 nCharset = 1; // CUSTOM_CHARSET_SMALLCHAR;
2897 strTimeMarker = ".";
2901 nCharset = 2; // CUSTOM_CHARSET_MEDIUMCHAR;
2903 strTimeMarker = ".";
2906 nCharset = 2; // CUSTOM_CHARSET_MEDIUMCHAR;
2908 strTimeMarker = ".";
2912 nCharset = 3; // CUSTOM_CHARSET_BIGCHAR;
2914 strTimeMarker = " ";
2917 nCharset = 3; // CUSTOM_CHARSET_BIGCHAR;
2919 strTimeMarker = "o";
2922 nCharset = 3; // CUSTOM_CHARSET_BIGCHAR;
2924 strTimeMarker = "o";
2927 nCharset = 3; // CUSTOM_CHARSET_BIGCHAR;
2929 strTimeMarker = " ";
2933 strLcdTime += g_lcd->GetBigDigit( nCharset, time.GetHour() , nLine, 2, 2, true );
2934 strLcdTime += strTimeMarker;
2935 strLcdTime += g_lcd->GetBigDigit( nCharset, time.GetMinute(), nLine, 2, 2, false );
2936 strLcdTime += strTimeMarker;
2937 strLcdTime += g_lcd->GetBigDigit( nCharset, time.GetSecond(), nLine, 2, 2, false );
2944 CStdString CGUIInfoManager::LocalizeTime(const CDateTime &time, TIME_FORMAT format) const
2946 const CStdString timeFormat = g_langInfo.GetTimeFormat();
2947 bool use12hourclock = timeFormat.Find('h') != -1;
2950 case TIME_FORMAT_GUESS:
2951 return time.GetAsLocalizedTime("", false);
2952 case TIME_FORMAT_SS:
2953 return time.GetAsLocalizedTime("ss", true);
2954 case TIME_FORMAT_MM:
2955 return time.GetAsLocalizedTime("mm", true);
2956 case TIME_FORMAT_MM_SS:
2957 return time.GetAsLocalizedTime("mm:ss", true);
2958 case TIME_FORMAT_HH: // this forces it to a 12 hour clock
2959 return time.GetAsLocalizedTime(use12hourclock ? "h" : "HH", false);
2960 case TIME_FORMAT_HH_MM:
2961 return time.GetAsLocalizedTime(use12hourclock ? "h:mm" : "HH:mm", false);
2962 case TIME_FORMAT_HH_MM_XX:
2963 return time.GetAsLocalizedTime(use12hourclock ? "h:mm xx" : "HH:mm", false);
2964 case TIME_FORMAT_HH_MM_SS:
2965 return time.GetAsLocalizedTime("", true);
2967 return time.GetAsLocalizedTime("h", false);
2968 case TIME_FORMAT_H_MM_SS:
2969 return time.GetAsLocalizedTime("h:mm:ss", true);
2970 case TIME_FORMAT_XX:
2971 return use12hourclock ? time.GetAsLocalizedTime("xx", false) : "";
2975 return time.GetAsLocalizedTime("", false);
2978 CStdString CGUIInfoManager::GetDuration(TIME_FORMAT format) const
2980 if (g_application.IsPlayingAudio() && m_currentFile->HasMusicInfoTag())
2982 const CMusicInfoTag& tag = *m_currentFile->GetMusicInfoTag();
2983 if (tag.GetDuration() > 0)
2984 return StringUtils::SecondsToTimeString(tag.GetDuration(), format);
2986 if (g_application.IsPlayingVideo() && !m_currentMovieDuration.IsEmpty())
2987 return m_currentMovieDuration; // for tuxbox
2988 unsigned int iTotal = (unsigned int)g_application.GetTotalTime();
2990 return StringUtils::SecondsToTimeString(iTotal, format);
2994 CStdString CGUIInfoManager::GetMusicPartyModeLabel(int item)
2997 if (item >= MUSICPM_SONGSPLAYED && item <= MUSICPM_RANDOMSONGSPICKED)
3002 case MUSICPM_SONGSPLAYED:
3004 iSongs = g_partyModeManager.GetSongsPlayed();
3007 case MUSICPM_MATCHINGSONGS:
3009 iSongs = g_partyModeManager.GetMatchingSongs();
3012 case MUSICPM_MATCHINGSONGSPICKED:
3014 iSongs = g_partyModeManager.GetMatchingSongsPicked();
3017 case MUSICPM_MATCHINGSONGSLEFT:
3019 iSongs = g_partyModeManager.GetMatchingSongsLeft();
3022 case MUSICPM_RELAXEDSONGSPICKED:
3024 iSongs = g_partyModeManager.GetRelaxedSongs();
3027 case MUSICPM_RANDOMSONGSPICKED:
3029 iSongs = g_partyModeManager.GetRandomSongs();
3035 CStdString strLabel;
3036 strLabel.Format("%i", iSongs);
3042 const CStdString CGUIInfoManager::GetMusicPlaylistInfo(const GUIInfo& info)
3044 PLAYLIST::CPlayList& playlist = g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC);
3045 if (playlist.size() < 1)
3047 int index = info.GetData2();
3048 if (info.GetData1() == 1)
3049 { // relative index (requires current playlist is PLAYLIST_MUSIC)
3050 if (g_playlistPlayer.GetCurrentPlaylist() != PLAYLIST_MUSIC)
3052 index = g_playlistPlayer.GetNextSong(index);
3054 if (index < 0 || index >= playlist.size())
3056 CFileItemPtr playlistItem = playlist[index];
3057 if (!playlistItem->GetMusicInfoTag()->Loaded())
3059 playlistItem->LoadMusicTag();
3060 playlistItem->GetMusicInfoTag()->SetLoaded();
3062 // try to set a thumbnail
3063 if (!playlistItem->HasThumbnail())
3065 playlistItem->SetMusicThumb();
3066 // still no thumb? then just the set the default cover
3067 if (!playlistItem->HasThumbnail())
3068 playlistItem->SetThumbnailImage("DefaultAlbumCover.png");
3070 if (info.m_info == MUSICPLAYER_PLAYLISTPOS)
3072 CStdString strPosition = "";
3073 strPosition.Format("%i", index + 1);
3076 else if (info.m_info == MUSICPLAYER_COVER)
3077 return playlistItem->GetThumbnailImage();
3078 return GetMusicTagLabel(info.m_info, playlistItem.get());
3081 CStdString CGUIInfoManager::GetPlaylistLabel(int item) const
3083 if (!g_application.IsPlaying()) return "";
3084 int iPlaylist = g_playlistPlayer.GetCurrentPlaylist();
3087 case PLAYLIST_LENGTH:
3089 CStdString strLength = "";
3090 strLength.Format("%i", g_playlistPlayer.GetPlaylist(iPlaylist).size());
3093 case PLAYLIST_POSITION:
3095 CStdString strPosition = "";
3096 strPosition.Format("%i", g_playlistPlayer.GetCurrentSong() + 1);
3099 case PLAYLIST_RANDOM:
3101 if (g_playlistPlayer.IsShuffled(iPlaylist))
3102 return g_localizeStrings.Get(590); // 590: Random
3104 return g_localizeStrings.Get(591); // 591: Off
3106 case PLAYLIST_REPEAT:
3108 PLAYLIST::REPEAT_STATE state = g_playlistPlayer.GetRepeat(iPlaylist);
3109 if (state == PLAYLIST::REPEAT_ONE)
3110 return g_localizeStrings.Get(592); // 592: One
3111 else if (state == PLAYLIST::REPEAT_ALL)
3112 return g_localizeStrings.Get(593); // 593: All
3114 return g_localizeStrings.Get(594); // 594: Off
3120 CStdString CGUIInfoManager::GetMusicLabel(int item)
3122 if (!g_application.IsPlayingAudio() || !m_currentFile->HasMusicInfoTag()) return "";
3125 case MUSICPLAYER_PLAYLISTLEN:
3127 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
3128 return GetPlaylistLabel(PLAYLIST_LENGTH);
3131 case MUSICPLAYER_PLAYLISTPOS:
3133 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
3134 return GetPlaylistLabel(PLAYLIST_POSITION);
3137 case MUSICPLAYER_BITRATE:
3139 float fTimeSpan = (float)(CTimeUtils::GetFrameTime() - m_lastMusicBitrateTime);
3140 if (fTimeSpan >= 500.0f)
3142 m_MusicBitrate = g_application.m_pPlayer->GetAudioBitrate();
3143 m_lastMusicBitrateTime = CTimeUtils::GetFrameTime();
3145 CStdString strBitrate = "";
3146 if (m_MusicBitrate > 0)
3147 strBitrate.Format("%i", MathUtils::round_int((double)m_MusicBitrate / 1000.0));
3151 case MUSICPLAYER_CHANNELS:
3153 CStdString strChannels = "";
3154 if (g_application.m_pPlayer->GetChannels() > 0)
3156 strChannels.Format("%i", g_application.m_pPlayer->GetChannels());
3161 case MUSICPLAYER_BITSPERSAMPLE:
3163 CStdString strBitsPerSample = "";
3164 if (g_application.m_pPlayer->GetBitsPerSample() > 0)
3166 strBitsPerSample.Format("%i", g_application.m_pPlayer->GetBitsPerSample());
3168 return strBitsPerSample;
3171 case MUSICPLAYER_SAMPLERATE:
3173 CStdString strSampleRate = "";
3174 if (g_application.m_pPlayer->GetSampleRate() > 0)
3176 strSampleRate.Format("%i",g_application.m_pPlayer->GetSampleRate());
3178 return strSampleRate;
3181 case MUSICPLAYER_CODEC:
3183 CStdString strCodec;
3184 strCodec.Format("%s", g_application.m_pPlayer->GetAudioCodecName().c_str());
3188 case MUSICPLAYER_LYRICS:
3189 return GetItemLabel(m_currentFile, AddListItemProp("lyrics"));
3191 return GetMusicTagLabel(item, m_currentFile);
3194 CStdString CGUIInfoManager::GetMusicTagLabel(int info, const CFileItem *item)
3196 if (!item->HasMusicInfoTag()) return "";
3197 const CMusicInfoTag &tag = *item->GetMusicInfoTag();
3200 case MUSICPLAYER_TITLE:
3201 if (tag.GetTitle().size()) { return tag.GetTitle(); }
3203 case MUSICPLAYER_ALBUM:
3204 if (tag.GetAlbum().size()) { return tag.GetAlbum(); }
3206 case MUSICPLAYER_ARTIST:
3207 if (tag.GetArtist().size()) { return tag.GetArtist(); }
3209 case MUSICPLAYER_ALBUM_ARTIST:
3210 if (tag.GetAlbumArtist().size()) { return tag.GetAlbumArtist(); }
3212 case MUSICPLAYER_YEAR:
3213 if (tag.GetYear()) { return tag.GetYearString(); }
3215 case MUSICPLAYER_GENRE:
3216 if (tag.GetGenre().size()) { return tag.GetGenre(); }
3218 case MUSICPLAYER_LYRICS:
3219 if (tag.GetLyrics().size()) { return tag.GetLyrics(); }
3221 case MUSICPLAYER_TRACK_NUMBER:
3223 CStdString strTrack;
3224 if (tag.Loaded() && tag.GetTrackNumber() > 0)
3226 strTrack.Format("%02i", tag.GetTrackNumber());
3231 case MUSICPLAYER_DISC_NUMBER:
3232 return GetItemLabel(item, LISTITEM_DISC_NUMBER);
3233 case MUSICPLAYER_RATING:
3234 return GetItemLabel(item, LISTITEM_RATING);
3235 case MUSICPLAYER_COMMENT:
3236 return GetItemLabel(item, LISTITEM_COMMENT);
3237 case MUSICPLAYER_DURATION:
3238 return GetItemLabel(item, LISTITEM_DURATION);
3239 case MUSICPLAYER_PLAYCOUNT:
3240 return GetItemLabel(item, LISTITEM_PLAYCOUNT);
3241 case MUSICPLAYER_LASTPLAYED:
3242 return GetItemLabel(item, LISTITEM_LASTPLAYED);
3247 CStdString CGUIInfoManager::GetVideoLabel(int item)
3249 if (!g_application.IsPlayingVideo())
3252 if (item == VIDEOPLAYER_TITLE)
3254 if (m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->m_strTitle.IsEmpty())
3255 return m_currentFile->GetVideoInfoTag()->m_strTitle;
3256 // don't have the title, so use dvdplayer, label, or drop down to title from path
3257 if (!g_application.m_pPlayer->GetPlayingTitle().IsEmpty())
3258 return g_application.m_pPlayer->GetPlayingTitle();
3259 if (!m_currentFile->GetLabel().IsEmpty())
3260 return m_currentFile->GetLabel();
3261 return CUtil::GetTitleFromPath(m_currentFile->GetPath());
3263 else if (item == VIDEOPLAYER_PLAYLISTLEN)
3265 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_VIDEO)
3266 return GetPlaylistLabel(PLAYLIST_LENGTH);
3268 else if (item == VIDEOPLAYER_PLAYLISTPOS)
3270 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_VIDEO)
3271 return GetPlaylistLabel(PLAYLIST_POSITION);
3273 else if (m_currentFile->HasVideoInfoTag())
3277 case VIDEOPLAYER_ORIGINALTITLE:
3278 return m_currentFile->GetVideoInfoTag()->m_strOriginalTitle;
3280 case VIDEOPLAYER_GENRE:
3281 return m_currentFile->GetVideoInfoTag()->m_strGenre;
3283 case VIDEOPLAYER_DIRECTOR:
3284 return m_currentFile->GetVideoInfoTag()->m_strDirector;
3286 case VIDEOPLAYER_RATING:
3288 CStdString strRating;
3289 if (m_currentFile->GetVideoInfoTag()->m_fRating > 0.f)
3290 strRating.Format("%.1f", m_currentFile->GetVideoInfoTag()->m_fRating);
3294 case VIDEOPLAYER_RATING_AND_VOTES:
3296 CStdString strRatingAndVotes;
3297 if (m_currentFile->GetVideoInfoTag()->m_fRating > 0.f)
3299 if (m_currentFile->GetVideoInfoTag()->m_strVotes.IsEmpty())
3300 strRatingAndVotes.Format("%.1f", m_currentFile->GetVideoInfoTag()->m_fRating);
3302 strRatingAndVotes.Format("%.1f (%s %s)", m_currentFile->GetVideoInfoTag()->m_fRating, m_currentFile->GetVideoInfoTag()->m_strVotes, g_localizeStrings.Get(20350));
3304 return strRatingAndVotes;
3307 case VIDEOPLAYER_YEAR:
3310 if (m_currentFile->GetVideoInfoTag()->m_iYear > 0)
3311 strYear.Format("%i", m_currentFile->GetVideoInfoTag()->m_iYear);
3315 case VIDEOPLAYER_PREMIERED:
3317 if (!m_currentFile->GetVideoInfoTag()->m_strFirstAired.IsEmpty())
3318 return m_currentFile->GetVideoInfoTag()->m_strFirstAired;
3319 if (!m_currentFile->GetVideoInfoTag()->m_strPremiered.IsEmpty())
3320 return m_currentFile->GetVideoInfoTag()->m_strPremiered;
3323 case VIDEOPLAYER_PLOT:
3324 return m_currentFile->GetVideoInfoTag()->m_strPlot;
3325 case VIDEOPLAYER_TRAILER:
3326 return m_currentFile->GetVideoInfoTag()->m_strTrailer;
3327 case VIDEOPLAYER_PLOT_OUTLINE:
3328 return m_currentFile->GetVideoInfoTag()->m_strPlotOutline;
3329 case VIDEOPLAYER_EPISODE:
3331 CStdString strEpisode;
3332 if (m_currentFile->GetVideoInfoTag()->m_iSpecialSortEpisode > 0)
3333 strEpisode.Format("S%i", m_currentFile->GetVideoInfoTag()->m_iSpecialSortEpisode);
3334 else if(m_currentFile->GetVideoInfoTag()->m_iEpisode > 0)
3335 strEpisode.Format("%i", m_currentFile->GetVideoInfoTag()->m_iEpisode);
3339 case VIDEOPLAYER_SEASON:
3341 CStdString strSeason;
3342 if (m_currentFile->GetVideoInfoTag()->m_iSpecialSortSeason > 0)
3343 strSeason.Format("%i", m_currentFile->GetVideoInfoTag()->m_iSpecialSortSeason);
3344 else if(m_currentFile->GetVideoInfoTag()->m_iSeason > 0)
3345 strSeason.Format("%i", m_currentFile->GetVideoInfoTag()->m_iSeason);
3349 case VIDEOPLAYER_TVSHOW:
3350 return m_currentFile->GetVideoInfoTag()->m_strShowTitle;
3352 case VIDEOPLAYER_STUDIO:
3353 return m_currentFile->GetVideoInfoTag()->m_strStudio;
3354 case VIDEOPLAYER_COUNTRY:
3355 return m_currentFile->GetVideoInfoTag()->m_strCountry;
3356 case VIDEOPLAYER_MPAA:
3357 return m_currentFile->GetVideoInfoTag()->m_strMPAARating;
3358 case VIDEOPLAYER_TOP250:
3360 CStdString strTop250;
3361 if (m_currentFile->GetVideoInfoTag()->m_iTop250 > 0)
3362 strTop250.Format("%i", m_currentFile->GetVideoInfoTag()->m_iTop250);
3366 case VIDEOPLAYER_CAST:
3367 return m_currentFile->GetVideoInfoTag()->GetCast();
3368 case VIDEOPLAYER_CAST_AND_ROLE:
3369 return m_currentFile->GetVideoInfoTag()->GetCast(true);
3370 case VIDEOPLAYER_ARTIST:
3371 return m_currentFile->GetVideoInfoTag()->m_strArtist;
3372 case VIDEOPLAYER_ALBUM:
3373 return m_currentFile->GetVideoInfoTag()->m_strAlbum;
3374 case VIDEOPLAYER_WRITER:
3375 return m_currentFile->GetVideoInfoTag()->m_strWritingCredits;
3376 case VIDEOPLAYER_TAGLINE:
3377 return m_currentFile->GetVideoInfoTag()->m_strTagLine;
3378 case VIDEOPLAYER_LASTPLAYED:
3379 return m_currentFile->GetVideoInfoTag()->m_lastPlayed;
3380 case VIDEOPLAYER_PLAYCOUNT:
3382 CStdString strPlayCount;
3383 if (m_currentFile->GetVideoInfoTag()->m_playCount > 0)
3384 strPlayCount.Format("%i", m_currentFile->GetVideoInfoTag()->m_playCount);
3385 return strPlayCount;
3392 __int64 CGUIInfoManager::GetPlayTime() const
3394 if (g_application.IsPlaying())
3396 __int64 lPTS = (__int64)(g_application.GetTime() * 1000);
3397 if (lPTS < 0) lPTS = 0;
3403 CStdString CGUIInfoManager::GetCurrentPlayTime(TIME_FORMAT format) const
3405 if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
3406 format = TIME_FORMAT_HH_MM_SS;
3407 if (g_application.IsPlayingAudio() || g_application.IsPlayingVideo())
3408 return StringUtils::SecondsToTimeString((int)(GetPlayTime()/1000), format);
3412 int CGUIInfoManager::GetTotalPlayTime() const
3414 int iTotalTime = (int)g_application.GetTotalTime();
3415 return iTotalTime > 0 ? iTotalTime : 0;
3418 int CGUIInfoManager::GetPlayTimeRemaining() const
3420 int iReverse = GetTotalPlayTime() - (int)g_application.GetTime();
3421 return iReverse > 0 ? iReverse : 0;
3424 CStdString CGUIInfoManager::GetCurrentPlayTimeRemaining(TIME_FORMAT format) const
3426 if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
3427 format = TIME_FORMAT_HH_MM_SS;
3428 int timeRemaining = GetPlayTimeRemaining();
3429 if (timeRemaining && (g_application.IsPlayingAudio() || g_application.IsPlayingVideo()))
3430 return StringUtils::SecondsToTimeString(timeRemaining, format);
3434 void CGUIInfoManager::ResetCurrentItem()
3436 m_currentFile->Reset();
3437 m_currentMovieThumb = "";
3438 m_currentMovieDuration = "";
3441 void CGUIInfoManager::SetCurrentItem(CFileItem &item)
3446 SetCurrentSong(item);
3448 SetCurrentMovie(item);
3451 void CGUIInfoManager::SetCurrentAlbumThumb(const CStdString thumbFileName)
3453 if (CFile::Exists(thumbFileName))
3454 m_currentFile->SetThumbnailImage(thumbFileName);
3457 m_currentFile->SetThumbnailImage("");
3458 m_currentFile->FillInDefaultIcon();
3462 void CGUIInfoManager::SetCurrentSong(CFileItem &item)
3464 CLog::Log(LOGDEBUG,"CGUIInfoManager::SetCurrentSong(%s)",item.GetPath().c_str());
3465 *m_currentFile = item;
3467 m_currentFile->LoadMusicTag();
3468 if (m_currentFile->GetMusicInfoTag()->GetTitle().IsEmpty())
3470 // No title in tag, show filename only
3471 m_currentFile->GetMusicInfoTag()->SetTitle(CUtil::GetTitleFromPath(m_currentFile->GetPath()));
3473 m_currentFile->GetMusicInfoTag()->SetLoaded(true);
3475 // find a thumb for this file.
3476 if (m_currentFile->IsInternetStream())
3478 if (!g_application.m_strPlayListFile.IsEmpty())
3480 CLog::Log(LOGDEBUG,"Streaming media detected... using %s to find a thumb", g_application.m_strPlayListFile.c_str());
3481 CFileItem streamingItem(g_application.m_strPlayListFile,false);
3482 streamingItem.SetMusicThumb();
3483 CStdString strThumb = streamingItem.GetThumbnailImage();
3484 if (CFile::Exists(strThumb))
3485 m_currentFile->SetThumbnailImage(strThumb);
3489 m_currentFile->SetMusicThumb();
3490 if (!m_currentFile->HasProperty("fanart_image"))
3492 if (m_currentFile->CacheLocalFanart())
3493 m_currentFile->SetProperty("fanart_image", m_currentFile->GetCachedFanart());
3495 m_currentFile->FillInDefaultIcon();
3497 CMusicInfoLoader::LoadAdditionalTagInfo(m_currentFile);
3500 void CGUIInfoManager::SetCurrentMovie(CFileItem &item)
3502 CLog::Log(LOGDEBUG,"CGUIInfoManager::SetCurrentMovie(%s)",item.GetPath().c_str());
3503 *m_currentFile = item;
3508 dbs.LoadVideoInfo(item.GetPath(), *m_currentFile->GetVideoInfoTag());
3512 // Find a thumb for this file.
3513 item.SetVideoThumb();
3514 if (!item.HasThumbnail())
3516 CStdString strPath, strFileName;
3517 URIUtils::Split(item.GetCachedVideoThumb(), strPath, strFileName);
3519 // create unique thumb for auto generated thumbs
3520 CStdString cachedThumb = strPath + "auto-" + strFileName;
3521 if (CFile::Exists(cachedThumb))
3522 item.SetThumbnailImage(cachedThumb);
3525 // find a thumb for this stream
3526 if (item.IsInternetStream())
3528 // case where .strm is used to start an audio stream
3529 if (g_application.IsPlayingAudio())
3531 SetCurrentSong(item);
3536 if (!g_application.m_strPlayListFile.IsEmpty())
3538 CLog::Log(LOGDEBUG,"Streaming media detected... using %s to find a thumb", g_application.m_strPlayListFile.c_str());
3539 CFileItem thumbItem(g_application.m_strPlayListFile,false);
3540 thumbItem.SetVideoThumb();
3541 if (thumbItem.HasThumbnail())
3542 item.SetThumbnailImage(thumbItem.GetThumbnailImage());
3546 item.FillInDefaultIcon();
3547 m_currentMovieThumb = item.GetThumbnailImage();
3550 string CGUIInfoManager::GetSystemHeatInfo(int info)
3552 if (CTimeUtils::GetFrameTime() - m_lastSysHeatInfoTime >= SYSHEATUPDATEINTERVAL)
3553 { // update our variables
3554 m_lastSysHeatInfoTime = CTimeUtils::GetFrameTime();
3556 m_cpuTemp = g_cpuInfo.getTemperature();
3557 m_gpuTemp = GetGPUTemperature();
3564 case LCD_CPU_TEMPERATURE:
3565 case SYSTEM_CPU_TEMPERATURE:
3566 return m_cpuTemp.IsValid() ? m_cpuTemp.ToString() : "?";
3568 case LCD_GPU_TEMPERATURE:
3569 case SYSTEM_GPU_TEMPERATURE:
3570 return m_gpuTemp.IsValid() ? m_gpuTemp.ToString() : "?";
3573 case SYSTEM_FAN_SPEED:
3574 text.Format("%i%%", m_fanSpeed * 2);
3576 case SYSTEM_CPU_USAGE:
3577 #if defined(__APPLE__) || defined(_WIN32)
3578 text.Format("%d%%", g_cpuInfo.getUsedPercentage());
3580 text.Format("%s", g_cpuInfo.GetCoresUsageString());
3587 CTemperature CGUIInfoManager::GetGPUTemperature()
3589 CStdString cmd = g_advancedSettings.m_gpuTempCmd;
3595 if (cmd.IsEmpty() || !(p = popen(cmd.c_str(), "r")))
3596 return CTemperature();
3598 ret = fscanf(p, "%d %c", &value, &scale);
3602 return CTemperature();
3604 if (scale == 'C' || scale == 'c')
3605 return CTemperature::CreateFromCelsius(value);
3606 if (scale == 'F' || scale == 'f')
3607 return CTemperature::CreateFromFahrenheit(value);
3608 return CTemperature();
3611 // Version string MUST NOT contain spaces. It is used
3612 // in the HTTP request user agent.
3613 CStdString CGUIInfoManager::GetVersion()
3617 tmp.Format("%s%d.%d Git:%s", VERSION_TAG, VERSION_MAJOR, VERSION_MINOR, GIT_REV);
3619 tmp.Format("%s%d.%d", VERSION_TAG, VERSION_MAJOR, VERSION_MINOR);
3624 CStdString CGUIInfoManager::GetBuild()
3627 tmp.Format("%s", __DATE__);
3631 void CGUIInfoManager::SetDisplayAfterSeek(unsigned int timeOut, int seekOffset)
3635 m_AfterSeekTimeout = CTimeUtils::GetFrameTime() + timeOut;
3637 m_seekOffset = seekOffset;
3640 m_AfterSeekTimeout = 0;
3643 bool CGUIInfoManager::GetDisplayAfterSeek()
3645 if (CTimeUtils::GetFrameTime() < m_AfterSeekTimeout)
3651 CStdString CGUIInfoManager::GetAudioScrobblerLabel(int item)
3655 case AUDIOSCROBBLER_CONN_STATE:
3656 return CLastfmScrobbler::GetInstance()->GetConnectionState();
3658 case AUDIOSCROBBLER_SUBMIT_INT:
3659 return CLastfmScrobbler::GetInstance()->GetSubmitInterval();
3661 case AUDIOSCROBBLER_FILES_CACHED:
3662 return CLastfmScrobbler::GetInstance()->GetFilesCached();
3664 case AUDIOSCROBBLER_SUBMIT_STATE:
3665 return CLastfmScrobbler::GetInstance()->GetSubmitState();
3672 void CGUIInfoManager::Clear()
3674 CSingleLock lock(m_critInfo);
3675 for (unsigned int i = 0; i < m_bools.size(); ++i)
3679 m_skinVariableStrings.clear();
3682 void CGUIInfoManager::UpdateFPS()
3685 unsigned int curTime = CTimeUtils::GetFrameTime();
3687 float fTimeSpan = (float)(curTime - m_lastFPSTime);
3688 if (fTimeSpan >= 1000.0f)
3690 fTimeSpan /= 1000.0f;
3691 m_fps = m_frameCounter / fTimeSpan;
3692 m_lastFPSTime = curTime;
3697 int CGUIInfoManager::AddListItemProp(const CStdString &str, int offset)
3699 for (int i=0; i < (int)m_listitemProperties.size(); i++)
3700 if (m_listitemProperties[i] == str)
3701 return (LISTITEM_PROPERTY_START+offset + i);
3703 if (m_listitemProperties.size() < LISTITEM_PROPERTY_END - LISTITEM_PROPERTY_START)
3705 m_listitemProperties.push_back(str);
3706 return LISTITEM_PROPERTY_START + offset + m_listitemProperties.size() - 1;
3709 CLog::Log(LOGERROR,"%s - not enough listitem property space!", __FUNCTION__);
3713 int CGUIInfoManager::AddMultiInfo(const GUIInfo &info)
3715 // check to see if we have this info already
3716 for (unsigned int i = 0; i < m_multiInfo.size(); i++)
3717 if (m_multiInfo[i] == info)
3718 return (int)i + MULTI_INFO_START;
3719 // return the new offset
3720 m_multiInfo.push_back(info);
3721 int id = (int)m_multiInfo.size() + MULTI_INFO_START - 1;
3722 if (id > MULTI_INFO_END)
3723 CLog::Log(LOGERROR, "%s - too many multiinfo bool/labels in this skin", __FUNCTION__);
3727 int CGUIInfoManager::ConditionalStringParameter(const CStdString ¶meter, bool caseSensitive /*= false*/)
3729 // check to see if we have this parameter already
3730 for (unsigned int i = 0; i < m_stringParameters.size(); i++)
3731 if (parameter.Equals(m_stringParameters[i], caseSensitive))
3733 // return the new offset
3734 m_stringParameters.push_back(parameter);
3735 return (int)m_stringParameters.size() - 1;
3738 bool CGUIInfoManager::GetItemInt(int &value, const CGUIListItem *item, int info) const
3746 if (info >= LISTITEM_PROPERTY_START && info - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size())
3747 { // grab the property
3748 CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START];
3749 CStdString val = item->GetProperty(property).asString();
3756 case LISTITEM_PERCENT_PLAYED:
3757 if (item->IsFileItem() && ((const CFileItem *)item)->HasVideoInfoTag() && ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds > 0)
3758 value = (int)(100 * ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.timeInSeconds / ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds);
3768 CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info)
3770 if (!item) return "";
3772 if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
3773 return GetSkinVariableString(info, 0, false, item);
3775 if (info >= LISTITEM_PROPERTY_START && info - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size())
3776 { // grab the property
3777 CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START];
3778 return item->GetProperty(property).asString();
3783 case LISTITEM_LABEL:
3784 return item->GetLabel();
3785 case LISTITEM_LABEL2:
3786 return item->GetLabel2();
3787 case LISTITEM_TITLE:
3788 if (item->HasVideoInfoTag())
3789 return item->GetVideoInfoTag()->m_strTitle;
3790 if (item->HasMusicInfoTag())
3791 return item->GetMusicInfoTag()->GetTitle();
3793 case LISTITEM_ORIGINALTITLE:
3794 if (item->HasVideoInfoTag())
3795 return item->GetVideoInfoTag()->m_strOriginalTitle;
3797 case LISTITEM_PLAYCOUNT:
3799 CStdString strPlayCount;
3800 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_playCount > 0)
3801 strPlayCount.Format("%i", item->GetVideoInfoTag()->m_playCount);
3802 if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetPlayCount() > 0)
3803 strPlayCount.Format("%i", item->GetMusicInfoTag()->GetPlayCount());
3804 return strPlayCount;
3806 case LISTITEM_LASTPLAYED:
3808 CStdString strLastPlayed;
3809 if (item->HasVideoInfoTag())
3810 return item->GetVideoInfoTag()->m_lastPlayed;
3811 if (item->HasMusicInfoTag())
3812 return item->GetMusicInfoTag()->GetLastPlayed();
3815 case LISTITEM_TRACKNUMBER:
3818 if (item->HasMusicInfoTag())
3819 track.Format("%i", item->GetMusicInfoTag()->GetTrackNumber());
3823 case LISTITEM_DISC_NUMBER:
3826 if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDiscNumber() > 0)
3827 disc.Format("%i", item->GetMusicInfoTag()->GetDiscNumber());
3830 case LISTITEM_ARTIST:
3831 if (item->HasVideoInfoTag())
3832 return item->GetVideoInfoTag()->m_strArtist;
3833 if (item->HasMusicInfoTag())
3834 return item->GetMusicInfoTag()->GetArtist();
3836 case LISTITEM_ALBUM_ARTIST:
3837 if (item->HasMusicInfoTag())
3838 return item->GetMusicInfoTag()->GetAlbumArtist();
3840 case LISTITEM_DIRECTOR:
3841 if (item->HasVideoInfoTag())
3842 return item->GetVideoInfoTag()->m_strDirector;
3843 case LISTITEM_ALBUM:
3844 if (item->HasVideoInfoTag())
3845 return item->GetVideoInfoTag()->m_strAlbum;
3846 if (item->HasMusicInfoTag())
3847 return item->GetMusicInfoTag()->GetAlbum();
3850 if (item->HasVideoInfoTag())
3852 CStdString strResult;
3853 if (item->GetVideoInfoTag()->m_iYear > 0)
3854 strResult.Format("%i",item->GetVideoInfoTag()->m_iYear);
3857 if (item->HasMusicInfoTag())
3858 return item->GetMusicInfoTag()->GetYearString();
3860 case LISTITEM_PREMIERED:
3861 if (item->HasVideoInfoTag())
3863 if (!item->GetVideoInfoTag()->m_strFirstAired.IsEmpty())
3864 return item->GetVideoInfoTag()->m_strFirstAired;
3865 if (!item->GetVideoInfoTag()->m_strPremiered.IsEmpty())
3866 return item->GetVideoInfoTag()->m_strPremiered;
3869 case LISTITEM_GENRE:
3870 if (item->HasVideoInfoTag())
3871 return item->GetVideoInfoTag()->m_strGenre;
3872 if (item->HasMusicInfoTag())
3873 return item->GetMusicInfoTag()->GetGenre();
3875 case LISTITEM_FILENAME:
3876 case LISTITEM_FILE_EXTENSION:
3879 if (item->IsMusicDb() && item->HasMusicInfoTag())
3880 strFile = URIUtils::GetFileName(item->GetMusicInfoTag()->GetURL());
3881 else if (item->IsVideoDb() && item->HasVideoInfoTag())
3882 strFile = URIUtils::GetFileName(item->GetVideoInfoTag()->m_strFileNameAndPath);
3884 strFile = URIUtils::GetFileName(item->GetPath());
3886 if (info==LISTITEM_FILE_EXTENSION)
3888 CStdString strExtension = URIUtils::GetExtension(strFile);
3889 return strExtension.TrimLeft(".");
3895 if (item->m_dateTime.IsValid())
3896 return item->m_dateTime.GetAsLocalizedDate();
3899 if (!item->m_bIsFolder || item->m_dwSize)
3900 return StringUtils::SizeToString(item->m_dwSize);
3902 case LISTITEM_RATING:
3905 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_fRating > 0.f) // movie rating
3906 rating.Format("%.1f", item->GetVideoInfoTag()->m_fRating);
3907 else if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetRating() > '0')
3908 { // song rating. Images will probably be better than numbers for this in the long run
3909 rating = item->GetMusicInfoTag()->GetRating();
3913 case LISTITEM_RATING_AND_VOTES:
3915 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_fRating > 0.f) // movie rating
3917 CStdString strRatingAndVotes;
3918 if (item->GetVideoInfoTag()->m_strVotes.IsEmpty())
3919 strRatingAndVotes.Format("%.1f", item->GetVideoInfoTag()->m_fRating);
3921 strRatingAndVotes.Format("%.1f (%s %s)", item->GetVideoInfoTag()->m_fRating, item->GetVideoInfoTag()->m_strVotes, g_localizeStrings.Get(20350));
3922 return strRatingAndVotes;
3926 case LISTITEM_PROGRAM_COUNT:
3929 count.Format("%i", item->m_iprogramCount);
3932 case LISTITEM_DURATION:
3934 CStdString duration;
3935 if (item->HasVideoInfoTag())
3937 if (!item->GetVideoInfoTag()->m_strRuntime.IsEmpty())
3938 duration = item->GetVideoInfoTag()->m_strRuntime;
3940 if (item->HasMusicInfoTag())
3942 if (item->GetMusicInfoTag()->GetDuration() > 0)
3943 duration = StringUtils::SecondsToTimeString(item->GetMusicInfoTag()->GetDuration());
3948 if (item->HasVideoInfoTag())
3950 if (!(!item->GetVideoInfoTag()->m_strShowTitle.IsEmpty() && item->GetVideoInfoTag()->m_iSeason == -1)) // dont apply to tvshows
3951 if (item->GetVideoInfoTag()->m_playCount == 0 && !g_guiSettings.GetBool("videolibrary.showunwatchedplots"))
3952 return g_localizeStrings.Get(20370);
3954 return item->GetVideoInfoTag()->m_strPlot;
3957 case LISTITEM_PLOT_OUTLINE:
3958 if (item->HasVideoInfoTag())
3959 return item->GetVideoInfoTag()->m_strPlotOutline;
3961 case LISTITEM_EPISODE:
3962 if (item->HasVideoInfoTag())
3964 CStdString strResult;
3965 if (item->GetVideoInfoTag()->m_iSpecialSortEpisode > 0)
3966 strResult.Format("S%d",item->GetVideoInfoTag()->m_iEpisode);
3967 else if (item->GetVideoInfoTag()->m_iEpisode > 0) // if m_iEpisode = -1 there's no episode detail
3968 strResult.Format("%d",item->GetVideoInfoTag()->m_iEpisode);
3972 case LISTITEM_SEASON:
3973 if (item->HasVideoInfoTag())
3975 CStdString strResult;
3976 if (item->GetVideoInfoTag()->m_iSpecialSortSeason > 0)
3977 strResult.Format("%d",item->GetVideoInfoTag()->m_iSpecialSortSeason);
3978 else if (item->GetVideoInfoTag()->m_iSeason > 0) // if m_iSeason = -1 there's no season detail
3979 strResult.Format("%d",item->GetVideoInfoTag()->m_iSeason);
3983 case LISTITEM_TVSHOW:
3984 if (item->HasVideoInfoTag())
3985 return item->GetVideoInfoTag()->m_strShowTitle;
3987 case LISTITEM_COMMENT:
3988 if (item->HasMusicInfoTag())
3989 return item->GetMusicInfoTag()->GetComment();
3991 case LISTITEM_ACTUAL_ICON:
3992 return item->GetIconImage();
3995 CStdString strThumb = item->GetThumbnailImage();
3996 if(!strThumb.IsEmpty() && !g_TextureManager.CanLoad(strThumb))
3999 if(strThumb.IsEmpty() && !item->GetIconImage().IsEmpty())
4000 strThumb = item->GetIconImage();
4003 case LISTITEM_OVERLAY:
4004 return item->GetOverlayImage();
4005 case LISTITEM_THUMB:
4006 return item->GetThumbnailImage();
4007 case LISTITEM_FOLDERPATH:
4008 return CURL(item->GetPath()).GetWithoutUserDetails();
4009 case LISTITEM_FOLDERNAME:
4013 if (item->IsMusicDb() && item->HasMusicInfoTag())
4014 URIUtils::GetDirectory(item->GetMusicInfoTag()->GetURL(), path);
4015 else if (item->IsVideoDb() && item->HasVideoInfoTag())
4017 if( item->m_bIsFolder )
4018 path = item->GetVideoInfoTag()->m_strPath;
4020 URIUtils::GetParentPath(item->GetVideoInfoTag()->m_strFileNameAndPath, path);
4023 URIUtils::GetParentPath(item->GetPath(), path);
4024 path = CURL(path).GetWithoutUserDetails();
4025 if (info==LISTITEM_FOLDERNAME)
4027 URIUtils::RemoveSlashAtEnd(path);
4028 path=URIUtils::GetFileName(path);
4033 case LISTITEM_FILENAME_AND_PATH:
4036 if (item->IsMusicDb() && item->HasMusicInfoTag())
4037 path = item->GetMusicInfoTag()->GetURL();
4038 else if (item->IsVideoDb() && item->HasVideoInfoTag())
4039 path = item->GetVideoInfoTag()->m_strFileNameAndPath;
4041 path = item->GetPath();
4042 path = CURL(path).GetWithoutUserDetails();
4046 case LISTITEM_PICTURE_PATH:
4047 if (item->IsPicture() && (!item->IsZIP() || item->IsRAR() || item->IsCBZ() || item->IsCBR()))
4048 return item->GetPath();
4050 case LISTITEM_PICTURE_DATETIME:
4051 if (item->HasPictureInfoTag())
4052 return item->GetPictureInfoTag()->GetInfo(SLIDE_EXIF_DATE_TIME);
4054 case LISTITEM_PICTURE_RESOLUTION:
4055 if (item->HasPictureInfoTag())
4056 return item->GetPictureInfoTag()->GetInfo(SLIDE_RESOLUTION);
4058 case LISTITEM_STUDIO:
4059 if (item->HasVideoInfoTag())
4060 return item->GetVideoInfoTag()->m_strStudio;
4062 case LISTITEM_COUNTRY:
4063 if (item->HasVideoInfoTag())
4064 return item->GetVideoInfoTag()->m_strCountry;
4067 if (item->HasVideoInfoTag())
4068 return item->GetVideoInfoTag()->m_strMPAARating;
4071 if (item->HasVideoInfoTag())
4072 return item->GetVideoInfoTag()->GetCast();
4074 case LISTITEM_CAST_AND_ROLE:
4075 if (item->HasVideoInfoTag())
4076 return item->GetVideoInfoTag()->GetCast(true);
4078 case LISTITEM_WRITER:
4079 if (item->HasVideoInfoTag())
4080 return item->GetVideoInfoTag()->m_strWritingCredits;
4082 case LISTITEM_TAGLINE:
4083 if (item->HasVideoInfoTag())
4084 return item->GetVideoInfoTag()->m_strTagLine;
4086 case LISTITEM_TRAILER:
4087 if (item->HasVideoInfoTag())
4088 return item->GetVideoInfoTag()->m_strTrailer;
4090 case LISTITEM_TOP250:
4091 if (item->HasVideoInfoTag())
4093 CStdString strResult;
4094 if (item->GetVideoInfoTag()->m_iTop250 > 0)
4095 strResult.Format("%i",item->GetVideoInfoTag()->m_iTop250);
4099 case LISTITEM_SORT_LETTER:
4102 g_charsetConverter.wToUTF8(item->GetSortLabel().Left(1).ToUpper(), letter);
4106 case LISTITEM_VIDEO_CODEC:
4107 if (item->HasVideoInfoTag())
4108 return item->GetVideoInfoTag()->m_streamDetails.GetVideoCodec();
4110 case LISTITEM_VIDEO_RESOLUTION:
4111 if (item->HasVideoInfoTag())
4112 return CStreamDetails::VideoDimsToResolutionDescription(item->GetVideoInfoTag()->m_streamDetails.GetVideoWidth(), item->GetVideoInfoTag()->m_streamDetails.GetVideoHeight());
4114 case LISTITEM_VIDEO_ASPECT:
4115 if (item->HasVideoInfoTag())
4116 return CStreamDetails::VideoAspectToAspectDescription(item->GetVideoInfoTag()->m_streamDetails.GetVideoAspect());
4118 case LISTITEM_AUDIO_CODEC:
4119 if (item->HasVideoInfoTag())
4121 return item->GetVideoInfoTag()->m_streamDetails.GetAudioCodec();
4124 case LISTITEM_AUDIO_CHANNELS:
4125 if (item->HasVideoInfoTag())
4127 CStdString strResult;
4128 int iChannels = item->GetVideoInfoTag()->m_streamDetails.GetAudioChannels();
4130 strResult.Format("%i", iChannels);
4134 case LISTITEM_AUDIO_LANGUAGE:
4135 if (item->HasVideoInfoTag())
4136 return item->GetVideoInfoTag()->m_streamDetails.GetAudioLanguage();
4138 case LISTITEM_SUBTITLE_LANGUAGE:
4139 if (item->HasVideoInfoTag())
4140 return item->GetVideoInfoTag()->m_streamDetails.GetSubtitleLanguage();
4142 case LISTITEM_PERCENT_PLAYED:
4145 if (GetItemInt(val, item, info))
4148 str.Format("%d", val);
4156 CStdString CGUIInfoManager::GetItemImage(const CFileItem *item, int info)
4158 if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
4159 return GetSkinVariableString(info, 0, true, item);
4163 case LISTITEM_RATING: // old song rating format
4166 if (item->HasMusicInfoTag())
4168 rating.Format("songrating%c.png", item->GetMusicInfoTag()->GetRating());
4173 case LISTITEM_STAR_RATING:
4176 if (item->HasVideoInfoTag())
4177 { // rating for videos is assumed 0..10, so convert to 0..5
4178 rating.Format("rating%d.png", (long)((item->GetVideoInfoTag()->m_fRating * 0.5f) + 0.5f));
4180 else if (item->HasMusicInfoTag())
4182 rating.Format("rating%c.png", item->GetMusicInfoTag()->GetRating());
4187 } /* switch (info) */
4189 return GetItemLabel(item, info);
4192 bool CGUIInfoManager::GetItemBool(const CGUIListItem *item, int condition) const
4194 if (!item) return false;
4195 if (condition >= LISTITEM_PROPERTY_START && condition - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size())
4196 { // grab the property
4197 CStdString property = m_listitemProperties[condition - LISTITEM_PROPERTY_START];
4198 return item->GetProperty(property).asBoolean();
4200 else if (condition == LISTITEM_ISPLAYING)
4202 if (item->HasProperty("playlistposition"))
4203 return (int)item->GetProperty("playlisttype").asInteger() == g_playlistPlayer.GetCurrentPlaylist() && (int)item->GetProperty("playlistposition").asInteger() == g_playlistPlayer.GetCurrentSong();
4204 else if (item->IsFileItem() && !m_currentFile->GetPath().IsEmpty())
4206 if (!g_application.m_strPlayListFile.IsEmpty())
4208 //playlist file that is currently playing or the playlistitem that is currently playing.
4209 return g_application.m_strPlayListFile.Equals(((const CFileItem *)item)->GetPath()) || m_currentFile->IsSamePath((const CFileItem *)item);
4211 return m_currentFile->IsSamePath((const CFileItem *)item);
4214 else if (condition == LISTITEM_ISSELECTED)
4215 return item->IsSelected();
4216 else if (condition == LISTITEM_IS_FOLDER)
4217 return item->m_bIsFolder;
4218 else if (condition == LISTITEM_IS_RESUMABLE)
4219 return (item->IsFileItem() && ((const CFileItem *)item)->HasVideoInfoTag() && ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds > 0);
4223 void CGUIInfoManager::ResetCache()
4225 // reset any animation triggers as well
4226 m_containerMoves.clear();
4230 // Called from tuxbox service thread to update current status
4231 void CGUIInfoManager::UpdateFromTuxBox()
4233 if(g_tuxbox.vVideoSubChannel.mode)
4234 m_currentFile->GetVideoInfoTag()->m_strTitle = g_tuxbox.vVideoSubChannel.current_name;
4236 // Set m_currentMovieDuration
4237 if(!g_tuxbox.sCurSrvData.current_event_duration.IsEmpty() &&
4238 !g_tuxbox.sCurSrvData.next_event_description.IsEmpty() &&
4239 !g_tuxbox.sCurSrvData.current_event_duration.Equals("-") &&
4240 !g_tuxbox.sCurSrvData.next_event_description.Equals("-"))
4242 g_tuxbox.sCurSrvData.current_event_duration.Replace("(","");
4243 g_tuxbox.sCurSrvData.current_event_duration.Replace(")","");
4245 m_currentMovieDuration.Format("%s: %s %s (%s - %s)",
4246 g_localizeStrings.Get(180),
4247 g_tuxbox.sCurSrvData.current_event_duration,
4248 g_localizeStrings.Get(12391),
4249 g_tuxbox.sCurSrvData.current_event_time,
4250 g_tuxbox.sCurSrvData.next_event_time);
4254 if (!g_tuxbox.sCurSrvData.current_event_description.IsEmpty() &&
4255 !g_tuxbox.sCurSrvData.next_event_description.IsEmpty() &&
4256 !g_tuxbox.sCurSrvData.current_event_description.Equals("-") &&
4257 !g_tuxbox.sCurSrvData.next_event_description.Equals("-"))
4259 m_currentFile->GetVideoInfoTag()->m_strGenre.Format("%s %s - (%s: %s)",
4260 g_localizeStrings.Get(143),
4261 g_tuxbox.sCurSrvData.current_event_description,
4262 g_localizeStrings.Get(209),
4263 g_tuxbox.sCurSrvData.next_event_description);
4266 //Set m_currentMovie.m_strDirector
4267 if (!g_tuxbox.sCurSrvData.current_event_details.Equals("-") &&
4268 !g_tuxbox.sCurSrvData.current_event_details.IsEmpty())
4270 m_currentFile->GetVideoInfoTag()->m_strDirector = g_tuxbox.sCurSrvData.current_event_details;
4274 CStdString CGUIInfoManager::GetPictureLabel(int info)
4276 if (info == SLIDE_FILE_NAME)
4277 return GetItemLabel(m_currentSlide, LISTITEM_FILENAME);
4278 else if (info == SLIDE_FILE_PATH)
4281 URIUtils::GetDirectory(m_currentSlide->GetPath(), path);
4282 return CURL(path).GetWithoutUserDetails();
4284 else if (info == SLIDE_FILE_SIZE)
4285 return GetItemLabel(m_currentSlide, LISTITEM_SIZE);
4286 else if (info == SLIDE_FILE_DATE)
4287 return GetItemLabel(m_currentSlide, LISTITEM_DATE);
4288 else if (info == SLIDE_INDEX)
4290 CGUIWindowSlideShow *slideshow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
4291 if (slideshow && slideshow->NumSlides())
4294 index.Format("%d/%d", slideshow->CurrentSlide(), slideshow->NumSlides());
4298 if (m_currentSlide->HasPictureInfoTag())
4299 return m_currentSlide->GetPictureInfoTag()->GetInfo(info);
4303 void CGUIInfoManager::SetCurrentSlide(CFileItem &item)
4305 if (m_currentSlide->GetPath() != item.GetPath())
4307 if (!item.HasPictureInfoTag() && !item.GetPictureInfoTag()->Loaded())
4308 item.GetPictureInfoTag()->Load(item.GetPath());
4309 *m_currentSlide = item;
4313 void CGUIInfoManager::ResetCurrentSlide()
4315 m_currentSlide->Reset();
4318 bool CGUIInfoManager::CheckWindowCondition(CGUIWindow *window, int condition) const
4320 // check if it satisfies our condition
4321 if (!window) return false;
4322 if ((condition & WINDOW_CONDITION_HAS_LIST_ITEMS) && !window->HasListItems())
4324 if ((condition & WINDOW_CONDITION_IS_MEDIA_WINDOW) && !window->IsMediaWindow())
4329 CGUIWindow *CGUIInfoManager::GetWindowWithCondition(int contextWindow, int condition) const
4331 CGUIWindow *window = g_windowManager.GetWindow(contextWindow);
4332 if (CheckWindowCondition(window, condition))
4335 // try topmost dialog
4336 window = g_windowManager.GetWindow(g_windowManager.GetTopMostModalDialogID());
4337 if (CheckWindowCondition(window, condition))
4340 // try active window
4341 window = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
4342 if (CheckWindowCondition(window, condition))
4348 void CGUIInfoManager::SetCurrentVideoTag(const CVideoInfoTag &tag)
4350 *m_currentFile->GetVideoInfoTag() = tag;
4351 m_currentFile->m_lStartOffset = 0;
4354 void CGUIInfoManager::SetCurrentSongTag(const MUSIC_INFO::CMusicInfoTag &tag)
4356 //CLog::Log(LOGDEBUG, "Asked to SetCurrentTag");
4357 *m_currentFile->GetMusicInfoTag() = tag;
4358 m_currentFile->m_lStartOffset = 0;
4361 const CFileItem& CGUIInfoManager::GetCurrentSlide() const
4363 return *m_currentSlide;
4366 const MUSIC_INFO::CMusicInfoTag* CGUIInfoManager::GetCurrentSongTag() const
4368 if (m_currentFile->HasMusicInfoTag())
4369 return m_currentFile->GetMusicInfoTag();
4374 const CVideoInfoTag* CGUIInfoManager::GetCurrentMovieTag() const
4376 if (m_currentFile->HasVideoInfoTag())
4377 return m_currentFile->GetVideoInfoTag();
4382 void GUIInfo::SetInfoFlag(uint32_t flag)
4384 assert(flag >= (1 << 24));
4388 uint32_t GUIInfo::GetInfoFlag() const
4390 // we strip out the bottom 24 bits, where we keep data
4391 // and return the flag only
4392 return m_data1 & 0xff000000;
4395 uint32_t GUIInfo::GetData1() const
4397 // we strip out the top 8 bits, where we keep flags
4398 // and return the unflagged data
4399 return m_data1 & ((1 << 24) -1);
4402 int GUIInfo::GetData2() const
4407 void CGUIInfoManager::SetLibraryBool(int condition, bool value)
4411 case LIBRARY_HAS_MUSIC:
4412 m_libraryHasMusic = value ? 1 : 0;
4414 case LIBRARY_HAS_MOVIES:
4415 m_libraryHasMovies = value ? 1 : 0;
4417 case LIBRARY_HAS_TVSHOWS:
4418 m_libraryHasTVShows = value ? 1 : 0;
4420 case LIBRARY_HAS_MUSICVIDEOS:
4421 m_libraryHasMusicVideos = value ? 1 : 0;
4428 void CGUIInfoManager::ResetLibraryBools()
4430 m_libraryHasMusic = -1;
4431 m_libraryHasMovies = -1;
4432 m_libraryHasTVShows = -1;
4433 m_libraryHasMusicVideos = -1;
4436 bool CGUIInfoManager::GetLibraryBool(int condition)
4438 if (condition == LIBRARY_HAS_MUSIC)
4440 if (m_libraryHasMusic < 0)
4445 m_libraryHasMusic = (db.GetSongsCount() > 0) ? 1 : 0;
4449 return m_libraryHasMusic > 0;
4451 else if (condition == LIBRARY_HAS_MOVIES)
4453 if (m_libraryHasMovies < 0)
4458 m_libraryHasMovies = db.HasContent(VIDEODB_CONTENT_MOVIES) ? 1 : 0;
4462 return m_libraryHasMovies > 0;
4464 else if (condition == LIBRARY_HAS_TVSHOWS)
4466 if (m_libraryHasTVShows < 0)
4471 m_libraryHasTVShows = db.HasContent(VIDEODB_CONTENT_TVSHOWS) ? 1 : 0;
4475 return m_libraryHasTVShows > 0;
4477 else if (condition == LIBRARY_HAS_MUSICVIDEOS)
4479 if (m_libraryHasMusicVideos < 0)
4484 m_libraryHasMusicVideos = db.HasContent(VIDEODB_CONTENT_MUSICVIDEOS) ? 1 : 0;
4488 return m_libraryHasMusicVideos > 0;
4490 else if (condition == LIBRARY_HAS_VIDEO)
4492 return (GetLibraryBool(LIBRARY_HAS_MOVIES) ||
4493 GetLibraryBool(LIBRARY_HAS_TVSHOWS) ||
4494 GetLibraryBool(LIBRARY_HAS_MUSICVIDEOS));
4499 int CGUIInfoManager::RegisterSkinVariableString(const CSkinVariableString& info)
4501 CSingleLock lock(m_critInfo);
4502 int id = TranslateSkinVariableString(info.GetName());
4506 m_skinVariableStrings.push_back(info);
4507 return CONDITIONAL_LABEL_START + m_skinVariableStrings.size() - 1;
4510 int CGUIInfoManager::TranslateSkinVariableString(const CStdString& name)
4512 for (vector<CSkinVariableString>::const_iterator it = m_skinVariableStrings.begin();
4513 it != m_skinVariableStrings.end(); ++it)
4515 if (it->GetName().Equals(name))
4516 return it - m_skinVariableStrings.begin() + CONDITIONAL_LABEL_START;
4521 CStdString CGUIInfoManager::GetSkinVariableString(int info, int contextWindow,
4522 bool preferImage /*= false*/,
4523 const CGUIListItem *item /*= NULL*/)
4525 info -= CONDITIONAL_LABEL_START;
4526 if (info >= 0 && info < (int)m_skinVariableStrings.size())
4527 return m_skinVariableStrings[info].GetValue(contextWindow, preferImage, item);