2 * Copyright (C) 2005-2013 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, see
17 * <http://www.gnu.org/licenses/>.
21 #include "network/Network.h"
23 #include "GitRevision.h"
24 #include "GUIInfoManager.h"
25 #include "windows/GUIMediaWindow.h"
26 #include "dialogs/GUIDialogProgress.h"
27 #include "Application.h"
29 #include "utils/URIUtils.h"
30 #include "utils/Weather.h"
31 #include "PartyModeManager.h"
32 #include "addons/Visualisation.h"
33 #include "input/ButtonTranslator.h"
34 #include "utils/AlarmClock.h"
36 #include "utils/SystemInfo.h"
37 #include "guilib/GUITextBox.h"
38 #include "pictures/GUIWindowSlideShow.h"
39 #include "pictures/PictureInfoTag.h"
40 #include "music/tags/MusicInfoTag.h"
41 #include "guilib/IGUIContainer.h"
42 #include "guilib/GUIWindowManager.h"
43 #include "playlists/PlayList.h"
44 #include "profiles/ProfilesManager.h"
45 #include "utils/TuxBoxUtil.h"
46 #include "windowing/WindowingFactory.h"
47 #include "powermanagement/PowerManager.h"
48 #include "settings/AdvancedSettings.h"
49 #include "settings/DisplaySettings.h"
50 #include "settings/MediaSettings.h"
51 #include "settings/Settings.h"
52 #include "settings/SkinSettings.h"
53 #include "guilib/LocalizeStrings.h"
54 #include "guilib/StereoscopicsManager.h"
55 #include "utils/CharsetConverter.h"
56 #include "utils/CPUInfo.h"
57 #include "utils/StringUtils.h"
58 #include "utils/MathUtils.h"
59 #include "utils/SeekHandler.h"
61 #include "addons/Skin.h"
62 #include "boost/make_shared.hpp"
64 // stuff for current song
65 #include "music/MusicInfoLoader.h"
67 #include "GUIUserMessages.h"
68 #include "video/dialogs/GUIDialogVideoInfo.h"
69 #include "music/dialogs/GUIDialogMusicInfo.h"
70 #include "storage/MediaManager.h"
71 #include "utils/TimeUtils.h"
72 #include "threads/SingleLock.h"
73 #include "utils/log.h"
75 #include "pvr/PVRManager.h"
76 #include "pvr/channels/PVRChannelGroupsContainer.h"
77 #include "epg/EpgInfoTag.h"
78 #include "pvr/timers/PVRTimers.h"
79 #include "pvr/recordings/PVRRecording.h"
81 #include "addons/AddonManager.h"
82 #include "interfaces/info/InfoBool.h"
83 #include "video/VideoThumbLoader.h"
84 #include "music/MusicThumbLoader.h"
85 #include "video/VideoDatabase.h"
86 #include "cores/IPlayer.h"
87 #include "cores/AudioEngine/Utils/AEUtil.h"
88 #include "cores/VideoRenderers/BaseRenderer.h"
89 #include "interfaces/info/InfoExpression.h"
91 #if defined(TARGET_DARWIN_OSX)
93 #include "linux/LinuxResourceCounter.h"
94 static CLinuxResourceCounter m_resourceCounter;
97 #define SYSHEATUPDATEINTERVAL 60000
100 using namespace XFILE;
101 using namespace MUSIC_INFO;
102 using namespace ADDON;
104 using namespace INFO;
107 CGUIInfoManager::CGUIInfoManager(void) :
110 m_lastSysHeatInfoTime = -SYSHEATUPDATEINTERVAL; // make sure we grab CPU temp on the first pass
112 m_AfterSeekTimeout = 0;
114 m_playerSeeking = false;
115 m_performingSeek = false;
116 m_nextWindowID = WINDOW_INVALID;
117 m_prevWindowID = WINDOW_INVALID;
118 m_stringParameters.push_back("__ZZZZ__"); // to offset the string parameters by 1 to assure that all entries are non-zero
119 m_currentFile = new CFileItem;
120 m_currentSlide = new CFileItem;
123 m_playerShowTime = false;
124 m_playerShowCodec = false;
125 m_playerShowInfo = false;
127 m_AVInfoValid = false;
131 CGUIInfoManager::~CGUIInfoManager(void)
133 delete m_currentFile;
134 delete m_currentSlide;
137 bool CGUIInfoManager::OnMessage(CGUIMessage &message)
139 if (message.GetMessage() == GUI_MSG_NOTIFY_ALL)
141 if (message.GetParam1() == GUI_MSG_UPDATE_ITEM && message.GetItem())
143 CFileItemPtr item = boost::static_pointer_cast<CFileItem>(message.GetItem());
144 if (m_currentFile->IsSamePath(item.get()))
146 m_currentFile->UpdateInfo(*item);
154 /// \brief Translates a string as given by the skin into an int that we use for more
155 /// efficient retrieval of data. Can handle combined strings on the form
156 /// Player.Caching + VideoPlayer.IsFullscreen (Logical and)
157 /// Player.HasVideo | Player.HasAudio (Logical or)
158 int CGUIInfoManager::TranslateString(const CStdString &condition)
160 // translate $LOCALIZE as required
161 CStdString strCondition(CGUIInfoLabel::ReplaceLocalize(condition));
162 return TranslateSingleString(strCondition);
171 const infomap player_labels[] = {{ "hasmedia", PLAYER_HAS_MEDIA }, // bools from here
172 { "hasaudio", PLAYER_HAS_AUDIO },
173 { "hasvideo", PLAYER_HAS_VIDEO },
174 { "playing", PLAYER_PLAYING },
175 { "paused", PLAYER_PAUSED },
176 { "rewinding", PLAYER_REWINDING },
177 { "forwarding", PLAYER_FORWARDING },
178 { "rewinding2x", PLAYER_REWINDING_2x },
179 { "rewinding4x", PLAYER_REWINDING_4x },
180 { "rewinding8x", PLAYER_REWINDING_8x },
181 { "rewinding16x", PLAYER_REWINDING_16x },
182 { "rewinding32x", PLAYER_REWINDING_32x },
183 { "forwarding2x", PLAYER_FORWARDING_2x },
184 { "forwarding4x", PLAYER_FORWARDING_4x },
185 { "forwarding8x", PLAYER_FORWARDING_8x },
186 { "forwarding16x", PLAYER_FORWARDING_16x },
187 { "forwarding32x", PLAYER_FORWARDING_32x },
188 { "canrecord", PLAYER_CAN_RECORD },
189 { "recording", PLAYER_RECORDING },
190 { "displayafterseek", PLAYER_DISPLAY_AFTER_SEEK },
191 { "caching", PLAYER_CACHING },
192 { "seekbar", PLAYER_SEEKBAR },
193 { "seeking", PLAYER_SEEKING },
194 { "showtime", PLAYER_SHOWTIME },
195 { "showcodec", PLAYER_SHOWCODEC },
196 { "showinfo", PLAYER_SHOWINFO },
197 { "title", PLAYER_TITLE },
198 { "muted", PLAYER_MUTED },
199 { "hasduration", PLAYER_HASDURATION },
200 { "passthrough", PLAYER_PASSTHROUGH },
201 { "cachelevel", PLAYER_CACHELEVEL }, // labels from here
202 { "progress", PLAYER_PROGRESS },
203 { "progresscache", PLAYER_PROGRESS_CACHE },
204 { "volume", PLAYER_VOLUME },
205 { "subtitledelay", PLAYER_SUBTITLE_DELAY },
206 { "audiodelay", PLAYER_AUDIO_DELAY },
207 { "chapter", PLAYER_CHAPTER },
208 { "chaptercount", PLAYER_CHAPTERCOUNT },
209 { "chaptername", PLAYER_CHAPTERNAME },
210 { "starrating", PLAYER_STAR_RATING },
211 { "folderpath", PLAYER_PATH },
212 { "filenameandpath", PLAYER_FILEPATH },
213 { "filename", PLAYER_FILENAME },
214 { "isinternetstream", PLAYER_ISINTERNETSTREAM },
215 { "pauseenabled", PLAYER_CAN_PAUSE },
216 { "seekenabled", PLAYER_CAN_SEEK }};
218 const infomap player_param[] = {{ "art", PLAYER_ITEM_ART }};
220 const infomap player_times[] = {{ "seektime", PLAYER_SEEKTIME },
221 { "seekoffset", PLAYER_SEEKOFFSET },
222 { "timeremaining", PLAYER_TIME_REMAINING },
223 { "timespeed", PLAYER_TIME_SPEED },
224 { "time", PLAYER_TIME },
225 { "duration", PLAYER_DURATION },
226 { "finishtime", PLAYER_FINISH_TIME },
227 { "starttime", PLAYER_START_TIME}};
229 const infomap weather[] = {{ "isfetched", WEATHER_IS_FETCHED },
230 { "conditions", WEATHER_CONDITIONS }, // labels from here
231 { "temperature", WEATHER_TEMPERATURE },
232 { "location", WEATHER_LOCATION },
233 { "fanartcode", WEATHER_FANART_CODE },
234 { "plugin", WEATHER_PLUGIN }};
236 const infomap system_labels[] = {{ "hasnetwork", SYSTEM_ETHERNET_LINK_ACTIVE },
237 { "hasmediadvd", SYSTEM_MEDIA_DVD },
238 { "dvdready", SYSTEM_DVDREADY },
239 { "trayopen", SYSTEM_TRAYOPEN },
240 { "haslocks", SYSTEM_HASLOCKS },
241 { "hasloginscreen", SYSTEM_HAS_LOGINSCREEN },
242 { "ismaster", SYSTEM_ISMASTER },
243 { "isfullscreen", SYSTEM_ISFULLSCREEN },
244 { "isstandalone", SYSTEM_ISSTANDALONE },
245 { "loggedon", SYSTEM_LOGGEDON },
246 { "showexitbutton", SYSTEM_SHOW_EXIT_BUTTON },
247 { "canpowerdown", SYSTEM_CAN_POWERDOWN },
248 { "cansuspend", SYSTEM_CAN_SUSPEND },
249 { "canhibernate", SYSTEM_CAN_HIBERNATE },
250 { "canreboot", SYSTEM_CAN_REBOOT },
251 { "screensaveractive",SYSTEM_SCREENSAVER_ACTIVE },
252 { "cputemperature", SYSTEM_CPU_TEMPERATURE }, // labels from here
253 { "cpuusage", SYSTEM_CPU_USAGE },
254 { "gputemperature", SYSTEM_GPU_TEMPERATURE },
255 { "fanspeed", SYSTEM_FAN_SPEED },
256 { "freespace", SYSTEM_FREE_SPACE },
257 { "usedspace", SYSTEM_USED_SPACE },
258 { "totalspace", SYSTEM_TOTAL_SPACE },
259 { "usedspacepercent", SYSTEM_USED_SPACE_PERCENT },
260 { "freespacepercent", SYSTEM_FREE_SPACE_PERCENT },
261 { "buildversion", SYSTEM_BUILD_VERSION },
262 { "builddate", SYSTEM_BUILD_DATE },
263 { "fps", SYSTEM_FPS },
264 { "dvdtraystate", SYSTEM_DVD_TRAY_STATE },
265 { "freememory", SYSTEM_FREE_MEMORY },
266 { "language", SYSTEM_LANGUAGE },
267 { "temperatureunits", SYSTEM_TEMPERATURE_UNITS },
268 { "screenmode", SYSTEM_SCREEN_MODE },
269 { "screenwidth", SYSTEM_SCREEN_WIDTH },
270 { "screenheight", SYSTEM_SCREEN_HEIGHT },
271 { "currentwindow", SYSTEM_CURRENT_WINDOW },
272 { "currentcontrol", SYSTEM_CURRENT_CONTROL },
273 { "dvdlabel", SYSTEM_DVD_LABEL },
274 { "internetstate", SYSTEM_INTERNET_STATE },
275 { "kernelversion", SYSTEM_KERNEL_VERSION },
276 { "uptime", SYSTEM_UPTIME },
277 { "totaluptime", SYSTEM_TOTALUPTIME },
278 { "cpufrequency", SYSTEM_CPUFREQUENCY },
279 { "screenresolution", SYSTEM_SCREEN_RESOLUTION },
280 { "videoencoderinfo", SYSTEM_VIDEO_ENCODER_INFO },
281 { "profilename", SYSTEM_PROFILENAME },
282 { "profilethumb", SYSTEM_PROFILETHUMB },
283 { "profilecount", SYSTEM_PROFILECOUNT },
284 { "profileautologin", SYSTEM_PROFILEAUTOLOGIN },
285 { "progressbar", SYSTEM_PROGRESS_BAR },
286 { "batterylevel", SYSTEM_BATTERY_LEVEL },
287 { "friendlyname", SYSTEM_FRIENDLY_NAME },
288 { "alarmpos", SYSTEM_ALARM_POS },
289 { "isinhibit", SYSTEM_ISINHIBIT },
290 { "hasshutdown", SYSTEM_HAS_SHUTDOWN },
291 { "haspvr", SYSTEM_HAS_PVR },
292 { "startupwindow", SYSTEM_STARTUP_WINDOW },
293 { "stereoscopicmode", SYSTEM_STEREOSCOPIC_MODE } };
295 const infomap system_param[] = {{ "hasalarm", SYSTEM_HAS_ALARM },
296 { "hascoreid", SYSTEM_HAS_CORE_ID },
297 { "setting", SYSTEM_SETTING },
298 { "hasaddon", SYSTEM_HAS_ADDON },
299 { "coreusage", SYSTEM_GET_CORE_USAGE }};
301 const infomap network_labels[] = {{ "isdhcp", NETWORK_IS_DHCP },
302 { "ipaddress", NETWORK_IP_ADDRESS }, //labels from here
303 { "linkstate", NETWORK_LINK_STATE },
304 { "macaddress", NETWORK_MAC_ADDRESS },
305 { "subnetmask", NETWORK_SUBNET_MASK },
306 { "gatewayaddress", NETWORK_GATEWAY_ADDRESS },
307 { "dns1address", NETWORK_DNS1_ADDRESS },
308 { "dns2address", NETWORK_DNS2_ADDRESS },
309 { "dhcpaddress", NETWORK_DHCP_ADDRESS }};
311 const infomap musicpartymode[] = {{ "enabled", MUSICPM_ENABLED },
312 { "songsplayed", MUSICPM_SONGSPLAYED },
313 { "matchingsongs", MUSICPM_MATCHINGSONGS },
314 { "matchingsongspicked", MUSICPM_MATCHINGSONGSPICKED },
315 { "matchingsongsleft", MUSICPM_MATCHINGSONGSLEFT },
316 { "relaxedsongspicked",MUSICPM_RELAXEDSONGSPICKED },
317 { "randomsongspicked", MUSICPM_RANDOMSONGSPICKED }};
319 const infomap musicplayer[] = {{ "title", MUSICPLAYER_TITLE },
320 { "album", MUSICPLAYER_ALBUM },
321 { "artist", MUSICPLAYER_ARTIST },
322 { "albumartist", MUSICPLAYER_ALBUM_ARTIST },
323 { "year", MUSICPLAYER_YEAR },
324 { "genre", MUSICPLAYER_GENRE },
325 { "duration", MUSICPLAYER_DURATION },
326 { "tracknumber", MUSICPLAYER_TRACK_NUMBER },
327 { "cover", MUSICPLAYER_COVER },
328 { "bitrate", MUSICPLAYER_BITRATE },
329 { "playlistlength", MUSICPLAYER_PLAYLISTLEN },
330 { "playlistposition", MUSICPLAYER_PLAYLISTPOS },
331 { "channels", MUSICPLAYER_CHANNELS },
332 { "bitspersample", MUSICPLAYER_BITSPERSAMPLE },
333 { "samplerate", MUSICPLAYER_SAMPLERATE },
334 { "codec", MUSICPLAYER_CODEC },
335 { "discnumber", MUSICPLAYER_DISC_NUMBER },
336 { "rating", MUSICPLAYER_RATING },
337 { "comment", MUSICPLAYER_COMMENT },
338 { "lyrics", MUSICPLAYER_LYRICS },
339 { "playlistplaying", MUSICPLAYER_PLAYLISTPLAYING },
340 { "exists", MUSICPLAYER_EXISTS },
341 { "hasprevious", MUSICPLAYER_HASPREVIOUS },
342 { "hasnext", MUSICPLAYER_HASNEXT },
343 { "playcount", MUSICPLAYER_PLAYCOUNT },
344 { "lastplayed", MUSICPLAYER_LASTPLAYED },
345 { "channelname", MUSICPLAYER_CHANNEL_NAME },
346 { "channelnumber", MUSICPLAYER_CHANNEL_NUMBER },
347 { "channelgroup", MUSICPLAYER_CHANNEL_GROUP }
350 const infomap videoplayer[] = {{ "title", VIDEOPLAYER_TITLE },
351 { "genre", VIDEOPLAYER_GENRE },
352 { "country", VIDEOPLAYER_COUNTRY },
353 { "originaltitle", VIDEOPLAYER_ORIGINALTITLE },
354 { "director", VIDEOPLAYER_DIRECTOR },
355 { "year", VIDEOPLAYER_YEAR },
356 { "cover", VIDEOPLAYER_COVER },
357 { "usingoverlays", VIDEOPLAYER_USING_OVERLAYS },
358 { "isfullscreen", VIDEOPLAYER_ISFULLSCREEN },
359 { "hasmenu", VIDEOPLAYER_HASMENU },
360 { "playlistlength", VIDEOPLAYER_PLAYLISTLEN },
361 { "playlistposition", VIDEOPLAYER_PLAYLISTPOS },
362 { "plot", VIDEOPLAYER_PLOT },
363 { "plotoutline", VIDEOPLAYER_PLOT_OUTLINE },
364 { "episode", VIDEOPLAYER_EPISODE },
365 { "season", VIDEOPLAYER_SEASON },
366 { "rating", VIDEOPLAYER_RATING },
367 { "ratingandvotes", VIDEOPLAYER_RATING_AND_VOTES },
368 { "votes", VIDEOPLAYER_VOTES },
369 { "tvshowtitle", VIDEOPLAYER_TVSHOW },
370 { "premiered", VIDEOPLAYER_PREMIERED },
371 { "studio", VIDEOPLAYER_STUDIO },
372 { "mpaa", VIDEOPLAYER_MPAA },
373 { "top250", VIDEOPLAYER_TOP250 },
374 { "cast", VIDEOPLAYER_CAST },
375 { "castandrole", VIDEOPLAYER_CAST_AND_ROLE },
376 { "artist", VIDEOPLAYER_ARTIST },
377 { "album", VIDEOPLAYER_ALBUM },
378 { "writer", VIDEOPLAYER_WRITER },
379 { "tagline", VIDEOPLAYER_TAGLINE },
380 { "hasinfo", VIDEOPLAYER_HAS_INFO },
381 { "trailer", VIDEOPLAYER_TRAILER },
382 { "videocodec", VIDEOPLAYER_VIDEO_CODEC },
383 { "videoresolution", VIDEOPLAYER_VIDEO_RESOLUTION },
384 { "videoaspect", VIDEOPLAYER_VIDEO_ASPECT },
385 { "audiocodec", VIDEOPLAYER_AUDIO_CODEC },
386 { "audiochannels", VIDEOPLAYER_AUDIO_CHANNELS },
387 { "audiolanguage", VIDEOPLAYER_AUDIO_LANG },
388 { "hasteletext", VIDEOPLAYER_HASTELETEXT },
389 { "lastplayed", VIDEOPLAYER_LASTPLAYED },
390 { "playcount", VIDEOPLAYER_PLAYCOUNT },
391 { "hassubtitles", VIDEOPLAYER_HASSUBTITLES },
392 { "subtitlesenabled", VIDEOPLAYER_SUBTITLESENABLED },
393 { "subtitleslanguage",VIDEOPLAYER_SUBTITLES_LANG },
394 { "endtime", VIDEOPLAYER_ENDTIME },
395 { "nexttitle", VIDEOPLAYER_NEXT_TITLE },
396 { "nextgenre", VIDEOPLAYER_NEXT_GENRE },
397 { "nextplot", VIDEOPLAYER_NEXT_PLOT },
398 { "nextplotoutline", VIDEOPLAYER_NEXT_PLOT_OUTLINE },
399 { "nextstarttime", VIDEOPLAYER_NEXT_STARTTIME },
400 { "nextendtime", VIDEOPLAYER_NEXT_ENDTIME },
401 { "nextduration", VIDEOPLAYER_NEXT_DURATION },
402 { "channelname", VIDEOPLAYER_CHANNEL_NAME },
403 { "channelnumber", VIDEOPLAYER_CHANNEL_NUMBER },
404 { "channelgroup", VIDEOPLAYER_CHANNEL_GROUP },
405 { "hasepg", VIDEOPLAYER_HAS_EPG },
406 { "parentalrating", VIDEOPLAYER_PARENTAL_RATING },
407 { "isstereoscopic", VIDEOPLAYER_IS_STEREOSCOPIC },
408 { "stereoscopicmode", VIDEOPLAYER_STEREOSCOPIC_MODE }
411 const infomap mediacontainer[] = {{ "hasfiles", CONTAINER_HASFILES },
412 { "hasfolders", CONTAINER_HASFOLDERS },
413 { "isstacked", CONTAINER_STACKED },
414 { "folderthumb", CONTAINER_FOLDERTHUMB },
415 { "tvshowthumb", CONTAINER_TVSHOWTHUMB },
416 { "seasonthumb", CONTAINER_SEASONTHUMB },
417 { "folderpath", CONTAINER_FOLDERPATH },
418 { "foldername", CONTAINER_FOLDERNAME },
419 { "pluginname", CONTAINER_PLUGINNAME },
420 { "viewmode", CONTAINER_VIEWMODE },
421 { "totaltime", CONTAINER_TOTALTIME },
422 { "hasthumb", CONTAINER_HAS_THUMB },
423 { "sortmethod", CONTAINER_SORT_METHOD },
424 { "showplot", CONTAINER_SHOWPLOT }};
426 const infomap container_bools[] ={{ "onnext", CONTAINER_MOVE_NEXT },
427 { "onprevious", CONTAINER_MOVE_PREVIOUS },
428 { "onscrollnext", CONTAINER_SCROLL_NEXT },
429 { "onscrollprevious", CONTAINER_SCROLL_PREVIOUS },
430 { "numpages", CONTAINER_NUM_PAGES },
431 { "numitems", CONTAINER_NUM_ITEMS },
432 { "currentpage", CONTAINER_CURRENT_PAGE },
433 { "scrolling", CONTAINER_SCROLLING },
434 { "hasnext", CONTAINER_HAS_NEXT },
435 { "hasprevious", CONTAINER_HAS_PREVIOUS },
436 { "canfilter", CONTAINER_CAN_FILTER },
437 { "canfilteradvanced",CONTAINER_CAN_FILTERADVANCED },
438 { "filtered", CONTAINER_FILTERED }};
440 const infomap container_ints[] = {{ "row", CONTAINER_ROW },
441 { "column", CONTAINER_COLUMN },
442 { "position", CONTAINER_POSITION },
443 { "subitem", CONTAINER_SUBITEM },
444 { "hasfocus", CONTAINER_HAS_FOCUS }};
446 const infomap container_str[] = {{ "property", CONTAINER_PROPERTY },
447 { "content", CONTAINER_CONTENT }};
449 const infomap listitem_labels[]= {{ "thumb", LISTITEM_THUMB },
450 { "icon", LISTITEM_ICON },
451 { "actualicon", LISTITEM_ACTUAL_ICON },
452 { "overlay", LISTITEM_OVERLAY },
453 { "label", LISTITEM_LABEL },
454 { "label2", LISTITEM_LABEL2 },
455 { "title", LISTITEM_TITLE },
456 { "tracknumber", LISTITEM_TRACKNUMBER },
457 { "artist", LISTITEM_ARTIST },
458 { "album", LISTITEM_ALBUM },
459 { "albumartist", LISTITEM_ALBUM_ARTIST },
460 { "year", LISTITEM_YEAR },
461 { "genre", LISTITEM_GENRE },
462 { "director", LISTITEM_DIRECTOR },
463 { "filename", LISTITEM_FILENAME },
464 { "filenameandpath", LISTITEM_FILENAME_AND_PATH },
465 { "fileextension", LISTITEM_FILE_EXTENSION },
466 { "date", LISTITEM_DATE },
467 { "size", LISTITEM_SIZE },
468 { "rating", LISTITEM_RATING },
469 { "ratingandvotes", LISTITEM_RATING_AND_VOTES },
470 { "votes", LISTITEM_VOTES },
471 { "programcount", LISTITEM_PROGRAM_COUNT },
472 { "duration", LISTITEM_DURATION },
473 { "isselected", LISTITEM_ISSELECTED },
474 { "isplaying", LISTITEM_ISPLAYING },
475 { "plot", LISTITEM_PLOT },
476 { "plotoutline", LISTITEM_PLOT_OUTLINE },
477 { "episode", LISTITEM_EPISODE },
478 { "season", LISTITEM_SEASON },
479 { "tvshowtitle", LISTITEM_TVSHOW },
480 { "premiered", LISTITEM_PREMIERED },
481 { "comment", LISTITEM_COMMENT },
482 { "path", LISTITEM_PATH },
483 { "foldername", LISTITEM_FOLDERNAME },
484 { "folderpath", LISTITEM_FOLDERPATH },
485 { "picturepath", LISTITEM_PICTURE_PATH },
486 { "pictureresolution",LISTITEM_PICTURE_RESOLUTION },
487 { "picturedatetime", LISTITEM_PICTURE_DATETIME },
488 { "picturedate", LISTITEM_PICTURE_DATE },
489 { "picturelongdatetime",LISTITEM_PICTURE_LONGDATETIME },
490 { "picturelongdate", LISTITEM_PICTURE_LONGDATE },
491 { "picturecomment", LISTITEM_PICTURE_COMMENT },
492 { "picturecaption", LISTITEM_PICTURE_CAPTION },
493 { "picturedesc", LISTITEM_PICTURE_DESC },
494 { "picturekeywords", LISTITEM_PICTURE_KEYWORDS },
495 { "picturecammake", LISTITEM_PICTURE_CAM_MAKE },
496 { "picturecammodel", LISTITEM_PICTURE_CAM_MODEL },
497 { "pictureaperture", LISTITEM_PICTURE_APERTURE },
498 { "picturefocallen", LISTITEM_PICTURE_FOCAL_LEN },
499 { "picturefocusdist", LISTITEM_PICTURE_FOCUS_DIST },
500 { "pictureexpmode", LISTITEM_PICTURE_EXP_MODE },
501 { "pictureexptime", LISTITEM_PICTURE_EXP_TIME },
502 { "pictureiso", LISTITEM_PICTURE_ISO },
503 { "pictureauthor", LISTITEM_PICTURE_AUTHOR },
504 { "picturebyline", LISTITEM_PICTURE_BYLINE },
505 { "picturebylinetitle", LISTITEM_PICTURE_BYLINE_TITLE },
506 { "picturecategory", LISTITEM_PICTURE_CATEGORY },
507 { "pictureccdwidth", LISTITEM_PICTURE_CCD_WIDTH },
508 { "picturecity", LISTITEM_PICTURE_CITY },
509 { "pictureurgency", LISTITEM_PICTURE_URGENCY },
510 { "picturecopyrightnotice", LISTITEM_PICTURE_COPYRIGHT_NOTICE },
511 { "picturecountry", LISTITEM_PICTURE_COUNTRY },
512 { "picturecountrycode", LISTITEM_PICTURE_COUNTRY_CODE },
513 { "picturecredit", LISTITEM_PICTURE_CREDIT },
514 { "pictureiptcdate", LISTITEM_PICTURE_IPTCDATE },
515 { "picturedigitalzoom", LISTITEM_PICTURE_DIGITAL_ZOOM },
516 { "pictureexposure", LISTITEM_PICTURE_EXPOSURE },
517 { "pictureexposurebias", LISTITEM_PICTURE_EXPOSURE_BIAS },
518 { "pictureflashused", LISTITEM_PICTURE_FLASH_USED },
519 { "pictureheadline", LISTITEM_PICTURE_HEADLINE },
520 { "picturecolour", LISTITEM_PICTURE_COLOUR },
521 { "picturelightsource", LISTITEM_PICTURE_LIGHT_SOURCE },
522 { "picturemeteringmode", LISTITEM_PICTURE_METERING_MODE },
523 { "pictureobjectname", LISTITEM_PICTURE_OBJECT_NAME },
524 { "pictureorientation", LISTITEM_PICTURE_ORIENTATION },
525 { "pictureprocess", LISTITEM_PICTURE_PROCESS },
526 { "picturereferenceservice", LISTITEM_PICTURE_REF_SERVICE },
527 { "picturesource", LISTITEM_PICTURE_SOURCE },
528 { "picturespecialinstructions", LISTITEM_PICTURE_SPEC_INSTR },
529 { "picturestate", LISTITEM_PICTURE_STATE },
530 { "picturesupplementalcategories", LISTITEM_PICTURE_SUP_CATEGORIES },
531 { "picturetransmissionreference", LISTITEM_PICTURE_TX_REFERENCE },
532 { "picturewhitebalance", LISTITEM_PICTURE_WHITE_BALANCE },
533 { "pictureimagetype", LISTITEM_PICTURE_IMAGETYPE },
534 { "picturesublocation", LISTITEM_PICTURE_SUBLOCATION },
535 { "pictureiptctime", LISTITEM_PICTURE_TIMECREATED },
536 { "picturegpslat", LISTITEM_PICTURE_GPS_LAT },
537 { "picturegpslon", LISTITEM_PICTURE_GPS_LON },
538 { "picturegpsalt", LISTITEM_PICTURE_GPS_ALT },
539 { "studio", LISTITEM_STUDIO },
540 { "country", LISTITEM_COUNTRY },
541 { "mpaa", LISTITEM_MPAA },
542 { "cast", LISTITEM_CAST },
543 { "castandrole", LISTITEM_CAST_AND_ROLE },
544 { "writer", LISTITEM_WRITER },
545 { "tagline", LISTITEM_TAGLINE },
546 { "top250", LISTITEM_TOP250 },
547 { "trailer", LISTITEM_TRAILER },
548 { "starrating", LISTITEM_STAR_RATING },
549 { "sortletter", LISTITEM_SORT_LETTER },
550 { "videocodec", LISTITEM_VIDEO_CODEC },
551 { "videoresolution", LISTITEM_VIDEO_RESOLUTION },
552 { "videoaspect", LISTITEM_VIDEO_ASPECT },
553 { "audiocodec", LISTITEM_AUDIO_CODEC },
554 { "audiochannels", LISTITEM_AUDIO_CHANNELS },
555 { "audiolanguage", LISTITEM_AUDIO_LANGUAGE },
556 { "subtitlelanguage", LISTITEM_SUBTITLE_LANGUAGE },
557 { "isresumable", LISTITEM_IS_RESUMABLE},
558 { "percentplayed", LISTITEM_PERCENT_PLAYED},
559 { "isfolder", LISTITEM_IS_FOLDER },
560 { "originaltitle", LISTITEM_ORIGINALTITLE },
561 { "lastplayed", LISTITEM_LASTPLAYED },
562 { "playcount", LISTITEM_PLAYCOUNT },
563 { "discnumber", LISTITEM_DISC_NUMBER },
564 { "starttime", LISTITEM_STARTTIME },
565 { "endtime", LISTITEM_ENDTIME },
566 { "startdate", LISTITEM_STARTDATE },
567 { "enddate", LISTITEM_ENDDATE },
568 { "nexttitle", LISTITEM_NEXT_TITLE },
569 { "nextgenre", LISTITEM_NEXT_GENRE },
570 { "nextplot", LISTITEM_NEXT_PLOT },
571 { "nextplotoutline", LISTITEM_NEXT_PLOT_OUTLINE },
572 { "nextstarttime", LISTITEM_NEXT_STARTTIME },
573 { "nextendtime", LISTITEM_NEXT_ENDTIME },
574 { "nextstartdate", LISTITEM_NEXT_STARTDATE },
575 { "nextenddate", LISTITEM_NEXT_ENDDATE },
576 { "channelname", LISTITEM_CHANNEL_NAME },
577 { "channelnumber", LISTITEM_CHANNEL_NUMBER },
578 { "channelgroup", LISTITEM_CHANNEL_GROUP },
579 { "hasepg", LISTITEM_HAS_EPG },
580 { "hastimer", LISTITEM_HASTIMER },
581 { "isrecording", LISTITEM_ISRECORDING },
582 { "isencrypted", LISTITEM_ISENCRYPTED },
583 { "progress", LISTITEM_PROGRESS },
584 { "dateadded", LISTITEM_DATE_ADDED },
585 { "dbtype", LISTITEM_DBTYPE },
586 { "dbid", LISTITEM_DBID },
587 { "stereoscopicmode", LISTITEM_STEREOSCOPIC_MODE },
588 { "isstereoscopic", LISTITEM_IS_STEREOSCOPIC }};
590 const infomap visualisation[] = {{ "locked", VISUALISATION_LOCKED },
591 { "preset", VISUALISATION_PRESET },
592 { "name", VISUALISATION_NAME },
593 { "enabled", VISUALISATION_ENABLED }};
595 const infomap fanart_labels[] = {{ "color1", FANART_COLOR1 },
596 { "color2", FANART_COLOR2 },
597 { "color3", FANART_COLOR3 },
598 { "image", FANART_IMAGE }};
600 const infomap skin_labels[] = {{ "currenttheme", SKIN_THEME },
601 { "currentcolourtheme",SKIN_COLOUR_THEME },
602 {"hasvideooverlay", SKIN_HAS_VIDEO_OVERLAY},
603 {"hasmusicoverlay", SKIN_HAS_MUSIC_OVERLAY},
604 {"aspectratio", SKIN_ASPECT_RATIO}};
606 const infomap window_bools[] = {{ "ismedia", WINDOW_IS_MEDIA },
607 { "isactive", WINDOW_IS_ACTIVE },
608 { "istopmost", WINDOW_IS_TOPMOST },
609 { "isvisible", WINDOW_IS_VISIBLE },
610 { "previous", WINDOW_PREVIOUS },
611 { "next", WINDOW_NEXT }};
613 const infomap control_labels[] = {{ "hasfocus", CONTROL_HAS_FOCUS },
614 { "isvisible", CONTROL_IS_VISIBLE },
615 { "isenabled", CONTROL_IS_ENABLED },
616 { "getlabel", CONTROL_GET_LABEL }};
618 const infomap playlist[] = {{ "length", PLAYLIST_LENGTH },
619 { "position", PLAYLIST_POSITION },
620 { "random", PLAYLIST_RANDOM },
621 { "repeat", PLAYLIST_REPEAT },
622 { "israndom", PLAYLIST_ISRANDOM },
623 { "isrepeat", PLAYLIST_ISREPEAT },
624 { "isrepeatone", PLAYLIST_ISREPEATONE }};
626 const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING },
627 { "hastimer", PVR_HAS_TIMER },
628 { "hasnonrecordingtimer", PVR_HAS_NONRECORDING_TIMER },
629 { "nowrecordingtitle", PVR_NOW_RECORDING_TITLE },
630 { "nowrecordingdatetime", PVR_NOW_RECORDING_DATETIME },
631 { "nowrecordingchannel", PVR_NOW_RECORDING_CHANNEL },
632 { "nowrecordingchannelicon", PVR_NOW_RECORDING_CHAN_ICO },
633 { "nextrecordingtitle", PVR_NEXT_RECORDING_TITLE },
634 { "nextrecordingdatetime", PVR_NEXT_RECORDING_DATETIME },
635 { "nextrecordingchannel", PVR_NEXT_RECORDING_CHANNEL },
636 { "nextrecordingchannelicon", PVR_NEXT_RECORDING_CHAN_ICO },
637 { "backendname", PVR_BACKEND_NAME },
638 { "backendversion", PVR_BACKEND_VERSION },
639 { "backendhost", PVR_BACKEND_HOST },
640 { "backenddiskspace", PVR_BACKEND_DISKSPACE },
641 { "backendchannels", PVR_BACKEND_CHANNELS },
642 { "backendtimers", PVR_BACKEND_TIMERS },
643 { "backendrecordings", PVR_BACKEND_RECORDINGS },
644 { "backendnumber", PVR_BACKEND_NUMBER },
645 { "hasepg", PVR_HAS_EPG },
646 { "hastxt", PVR_HAS_TXT },
647 { "hasdirector", PVR_HAS_DIRECTOR },
648 { "totaldiscspace", PVR_TOTAL_DISKSPACE },
649 { "nexttimer", PVR_NEXT_TIMER },
650 { "isplayingtv", PVR_IS_PLAYING_TV },
651 { "isplayingradio", PVR_IS_PLAYING_RADIO },
652 { "isplayingrecording", PVR_IS_PLAYING_RECORDING },
653 { "duration", PVR_PLAYING_DURATION },
654 { "time", PVR_PLAYING_TIME },
655 { "progress", PVR_PLAYING_PROGRESS },
656 { "actstreamclient", PVR_ACTUAL_STREAM_CLIENT },
657 { "actstreamdevice", PVR_ACTUAL_STREAM_DEVICE },
658 { "actstreamstatus", PVR_ACTUAL_STREAM_STATUS },
659 { "actstreamsignal", PVR_ACTUAL_STREAM_SIG },
660 { "actstreamsnr", PVR_ACTUAL_STREAM_SNR },
661 { "actstreamber", PVR_ACTUAL_STREAM_BER },
662 { "actstreamunc", PVR_ACTUAL_STREAM_UNC },
663 { "actstreamvideobitrate", PVR_ACTUAL_STREAM_VIDEO_BR },
664 { "actstreamaudiobitrate", PVR_ACTUAL_STREAM_AUDIO_BR },
665 { "actstreamdolbybitrate", PVR_ACTUAL_STREAM_DOLBY_BR },
666 { "actstreamprogrsignal", PVR_ACTUAL_STREAM_SIG_PROGR },
667 { "actstreamprogrsnr", PVR_ACTUAL_STREAM_SNR_PROGR },
668 { "actstreamisencrypted", PVR_ACTUAL_STREAM_ENCRYPTED },
669 { "actstreamencryptionname", PVR_ACTUAL_STREAM_CRYPTION },
670 { "actstreamservicename", PVR_ACTUAL_STREAM_SERVICE },
671 { "actstreammux", PVR_ACTUAL_STREAM_MUX },
672 { "actstreamprovidername", PVR_ACTUAL_STREAM_PROVIDER }};
674 const infomap slideshow[] = {{ "ispaused", SLIDESHOW_ISPAUSED },
675 { "isactive", SLIDESHOW_ISACTIVE },
676 { "isvideo", SLIDESHOW_ISVIDEO },
677 { "israndom", SLIDESHOW_ISRANDOM }};
679 const int picture_slide_map[] = {/* LISTITEM_PICTURE_RESOLUTION => */ SLIDE_RESOLUTION,
680 /* LISTITEM_PICTURE_LONGDATE => */ SLIDE_EXIF_LONG_DATE,
681 /* LISTITEM_PICTURE_LONGDATETIME => */ SLIDE_EXIF_LONG_DATE_TIME,
682 /* LISTITEM_PICTURE_DATE => */ SLIDE_EXIF_DATE,
683 /* LISTITEM_PICTURE_DATETIME => */ SLIDE_EXIF_DATE_TIME,
684 /* LISTITEM_PICTURE_COMMENT => */ SLIDE_COMMENT,
685 /* LISTITEM_PICTURE_CAPTION => */ SLIDE_IPTC_CAPTION,
686 /* LISTITEM_PICTURE_DESC => */ SLIDE_EXIF_DESCRIPTION,
687 /* LISTITEM_PICTURE_KEYWORDS => */ SLIDE_IPTC_KEYWORDS,
688 /* LISTITEM_PICTURE_CAM_MAKE => */ SLIDE_EXIF_CAMERA_MAKE,
689 /* LISTITEM_PICTURE_CAM_MODEL => */ SLIDE_EXIF_CAMERA_MODEL,
690 /* LISTITEM_PICTURE_APERTURE => */ SLIDE_EXIF_APERTURE,
691 /* LISTITEM_PICTURE_FOCAL_LEN => */ SLIDE_EXIF_FOCAL_LENGTH,
692 /* LISTITEM_PICTURE_FOCUS_DIST => */ SLIDE_EXIF_FOCUS_DIST,
693 /* LISTITEM_PICTURE_EXP_MODE => */ SLIDE_EXIF_EXPOSURE_MODE,
694 /* LISTITEM_PICTURE_EXP_TIME => */ SLIDE_EXIF_EXPOSURE_TIME,
695 /* LISTITEM_PICTURE_ISO => */ SLIDE_EXIF_ISO_EQUIV,
696 /* LISTITEM_PICTURE_AUTHOR => */ SLIDE_IPTC_AUTHOR,
697 /* LISTITEM_PICTURE_BYLINE => */ SLIDE_IPTC_BYLINE,
698 /* LISTITEM_PICTURE_BYLINE_TITLE => */ SLIDE_IPTC_BYLINE_TITLE,
699 /* LISTITEM_PICTURE_CATEGORY => */ SLIDE_IPTC_CATEGORY,
700 /* LISTITEM_PICTURE_CCD_WIDTH => */ SLIDE_EXIF_CCD_WIDTH,
701 /* LISTITEM_PICTURE_CITY => */ SLIDE_IPTC_CITY,
702 /* LISTITEM_PICTURE_URGENCY => */ SLIDE_IPTC_URGENCY,
703 /* LISTITEM_PICTURE_COPYRIGHT_NOTICE => */ SLIDE_IPTC_COPYRIGHT_NOTICE,
704 /* LISTITEM_PICTURE_COUNTRY => */ SLIDE_IPTC_COUNTRY,
705 /* LISTITEM_PICTURE_COUNTRY_CODE => */ SLIDE_IPTC_COUNTRY_CODE,
706 /* LISTITEM_PICTURE_CREDIT => */ SLIDE_IPTC_CREDIT,
707 /* LISTITEM_PICTURE_IPTCDATE => */ SLIDE_IPTC_DATE,
708 /* LISTITEM_PICTURE_DIGITAL_ZOOM => */ SLIDE_EXIF_DIGITAL_ZOOM,
709 /* LISTITEM_PICTURE_EXPOSURE => */ SLIDE_EXIF_EXPOSURE,
710 /* LISTITEM_PICTURE_EXPOSURE_BIAS => */ SLIDE_EXIF_EXPOSURE_BIAS,
711 /* LISTITEM_PICTURE_FLASH_USED => */ SLIDE_EXIF_FLASH_USED,
712 /* LISTITEM_PICTURE_HEADLINE => */ SLIDE_IPTC_HEADLINE,
713 /* LISTITEM_PICTURE_COLOUR => */ SLIDE_COLOUR,
714 /* LISTITEM_PICTURE_LIGHT_SOURCE => */ SLIDE_EXIF_LIGHT_SOURCE,
715 /* LISTITEM_PICTURE_METERING_MODE => */ SLIDE_EXIF_METERING_MODE,
716 /* LISTITEM_PICTURE_OBJECT_NAME => */ SLIDE_IPTC_OBJECT_NAME,
717 /* LISTITEM_PICTURE_ORIENTATION => */ SLIDE_EXIF_ORIENTATION,
718 /* LISTITEM_PICTURE_PROCESS => */ SLIDE_PROCESS,
719 /* LISTITEM_PICTURE_REF_SERVICE => */ SLIDE_IPTC_REF_SERVICE,
720 /* LISTITEM_PICTURE_SOURCE => */ SLIDE_IPTC_SOURCE,
721 /* LISTITEM_PICTURE_SPEC_INSTR => */ SLIDE_IPTC_SPEC_INSTR,
722 /* LISTITEM_PICTURE_STATE => */ SLIDE_IPTC_STATE,
723 /* LISTITEM_PICTURE_SUP_CATEGORIES => */ SLIDE_IPTC_SUP_CATEGORIES,
724 /* LISTITEM_PICTURE_TX_REFERENCE => */ SLIDE_IPTC_TX_REFERENCE,
725 /* LISTITEM_PICTURE_WHITE_BALANCE => */ SLIDE_EXIF_WHITE_BALANCE,
726 /* LISTITEM_PICTURE_IMAGETYPE => */ SLIDE_IPTC_IMAGETYPE,
727 /* LISTITEM_PICTURE_SUBLOCATION => */ SLIDE_IPTC_SUBLOCATION,
728 /* LISTITEM_PICTURE_TIMECREATED => */ SLIDE_IPTC_TIMECREATED,
729 /* LISTITEM_PICTURE_GPS_LAT => */ SLIDE_EXIF_GPS_LATITUDE,
730 /* LISTITEM_PICTURE_GPS_LON => */ SLIDE_EXIF_GPS_LONGITUDE,
731 /* LISTITEM_PICTURE_GPS_ALT => */ SLIDE_EXIF_GPS_ALTITUDE };
733 CGUIInfoManager::Property::Property(const CStdString &property, const CStdString ¶meters)
736 CUtil::SplitParams(parameters, params);
739 const CStdString &CGUIInfoManager::Property::param(unsigned int n /* = 0 */) const
741 if (n < params.size())
743 return StringUtils::EmptyString;
746 unsigned int CGUIInfoManager::Property::num_params() const
748 return params.size();
751 void CGUIInfoManager::SplitInfoString(const CStdString &infoString, vector<Property> &info)
753 // our string is of the form:
754 // category[(params)][.info(params).info2(params)] ...
755 // so we need to split on . while taking into account of () pairs
756 unsigned int parentheses = 0;
759 for (size_t i = 0; i < infoString.size(); ++i)
761 if (infoString[i] == '(')
766 else if (infoString[i] == ')')
769 CLog::Log(LOGERROR, "unmatched parentheses in %s", infoString.c_str());
770 else if (!--parentheses)
773 else if (infoString[i] == '.' && !parentheses)
775 if (!property.empty()) // add our property and parameters
777 StringUtils::ToLower(property);
778 info.push_back(Property(property, param));
785 param += infoString[i];
787 property += infoString[i];
790 CLog::Log(LOGERROR, "unmatched parentheses in %s", infoString.c_str());
791 if (!property.empty())
793 StringUtils::ToLower(property);
794 info.push_back(Property(property, param));
798 /// \brief Translates a string as given by the skin into an int that we use for more
799 /// efficient retrieval of data.
800 int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition)
802 bool listItemDependent;
803 return TranslateSingleString(strCondition, listItemDependent);
806 int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition, bool &listItemDependent)
808 /* We need to disable caching in INFO::InfoBool::Get if either of the following are true:
809 * 1. if condition is between LISTITEM_START and LISTITEM_END
810 * 2. if condition is STRING_IS_EMPTY, STRING_COMPARE, STRING_STR, INTEGER_GREATER_THAN and the
811 * corresponding label is between LISTITEM_START and LISTITEM_END
812 * This is achieved by setting the bool pointed at by listItemDependent, either here or in a recursive call
815 CStdString strTest = strCondition;
816 StringUtils::Trim(strTest);
818 vector< Property> info;
819 SplitInfoString(strTest, info);
824 const Property &cat = info[0];
825 if (info.size() == 1)
827 if (cat.name == "false" || cat.name == "no" || cat.name == "off")
828 return SYSTEM_ALWAYS_FALSE;
829 else if (cat.name == "true" || cat.name == "yes" || cat.name == "on")
830 return SYSTEM_ALWAYS_TRUE;
831 if (cat.name == "isempty" && cat.num_params() == 1)
832 return AddMultiInfo(GUIInfo(STRING_IS_EMPTY, TranslateSingleString(cat.param(), listItemDependent)));
833 else if (cat.name == "stringcompare" && cat.num_params() == 2)
835 int info = TranslateSingleString(cat.param(0), listItemDependent);
836 int info2 = TranslateSingleString(cat.param(1), listItemDependent);
838 return AddMultiInfo(GUIInfo(STRING_COMPARE, info, -info2));
839 // pipe our original string through the localize parsing then make it lowercase (picks up $LBRACKET etc.)
840 CStdString label = CGUIInfoLabel::GetLabel(cat.param(1));
841 StringUtils::ToLower(label);
842 int compareString = ConditionalStringParameter(label);
843 return AddMultiInfo(GUIInfo(STRING_COMPARE, info, compareString));
845 else if (cat.name == "integergreaterthan" && cat.num_params() == 2)
847 int info = TranslateSingleString(cat.param(0), listItemDependent);
848 int compareInt = atoi(cat.param(1).c_str());
849 return AddMultiInfo(GUIInfo(INTEGER_GREATER_THAN, info, compareInt));
851 else if (cat.name == "substring" && cat.num_params() >= 2)
853 int info = TranslateSingleString(cat.param(0), listItemDependent);
854 CStdString label = CGUIInfoLabel::GetLabel(cat.param(1));
855 StringUtils::ToLower(label);
856 int compareString = ConditionalStringParameter(label);
857 if (cat.num_params() > 2)
859 if (StringUtils::EqualsNoCase(cat.param(2), "left"))
860 return AddMultiInfo(GUIInfo(STRING_STR_LEFT, info, compareString));
861 else if (StringUtils::EqualsNoCase(cat.param(2), "right"))
862 return AddMultiInfo(GUIInfo(STRING_STR_RIGHT, info, compareString));
864 return AddMultiInfo(GUIInfo(STRING_STR, info, compareString));
867 else if (info.size() == 2)
869 const Property &prop = info[1];
870 if (cat.name == "player")
872 for (size_t i = 0; i < sizeof(player_labels) / sizeof(infomap); i++)
874 if (prop.name == player_labels[i].str)
875 return player_labels[i].val;
877 for (size_t i = 0; i < sizeof(player_times) / sizeof(infomap); i++)
879 if (prop.name == player_times[i].str)
880 return AddMultiInfo(GUIInfo(player_times[i].val, TranslateTimeFormat(prop.param())));
882 if (prop.num_params() == 1)
884 for (size_t i = 0; i < sizeof(player_param) / sizeof(infomap); i++)
886 if (prop.name == player_param[i].str)
887 return AddMultiInfo(GUIInfo(player_param[i].val, ConditionalStringParameter(prop.param())));
891 else if (cat.name == "weather")
893 for (size_t i = 0; i < sizeof(weather) / sizeof(infomap); i++)
895 if (prop.name == weather[i].str)
896 return weather[i].val;
899 else if (cat.name == "network")
901 for (size_t i = 0; i < sizeof(network_labels) / sizeof(infomap); i++)
903 if (prop.name == network_labels[i].str)
904 return network_labels[i].val;
907 else if (cat.name == "musicpartymode")
909 for (size_t i = 0; i < sizeof(musicpartymode) / sizeof(infomap); i++)
911 if (prop.name == musicpartymode[i].str)
912 return musicpartymode[i].val;
915 else if (cat.name == "system")
917 for (size_t i = 0; i < sizeof(system_labels) / sizeof(infomap); i++)
919 if (prop.name == system_labels[i].str)
920 return system_labels[i].val;
922 if (prop.num_params() == 1)
924 const CStdString ¶m = prop.param();
925 if (prop.name == "getbool")
927 std::string paramCopy = param;
928 StringUtils::ToLower(paramCopy);
929 return AddMultiInfo(GUIInfo(SYSTEM_GET_BOOL, ConditionalStringParameter(paramCopy, true)));
931 for (size_t i = 0; i < sizeof(system_param) / sizeof(infomap); i++)
933 if (prop.name == system_param[i].str)
934 return AddMultiInfo(GUIInfo(system_param[i].val, ConditionalStringParameter(param)));
936 if (prop.name == "memory")
938 if (param == "free") return SYSTEM_FREE_MEMORY;
939 else if (param == "free.percent") return SYSTEM_FREE_MEMORY_PERCENT;
940 else if (param == "used") return SYSTEM_USED_MEMORY;
941 else if (param == "used.percent") return SYSTEM_USED_MEMORY_PERCENT;
942 else if (param == "total") return SYSTEM_TOTAL_MEMORY;
944 else if (prop.name == "addontitle")
946 int infoLabel = TranslateSingleString(param, listItemDependent);
948 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_TITLE, infoLabel, 0));
949 CStdString label = CGUIInfoLabel::GetLabel(param);
950 StringUtils::ToLower(label);
951 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_TITLE, ConditionalStringParameter(label), 1));
953 else if (prop.name == "addonicon")
955 int infoLabel = TranslateSingleString(param, listItemDependent);
957 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_ICON, infoLabel, 0));
958 CStdString label = CGUIInfoLabel::GetLabel(param);
959 StringUtils::ToLower(label);
960 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_ICON, ConditionalStringParameter(label), 1));
962 else if (prop.name == "addonversion")
964 int infoLabel = TranslateSingleString(param, listItemDependent);
966 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_VERSION, infoLabel, 0));
967 CStdString label = CGUIInfoLabel::GetLabel(param);
968 StringUtils::ToLower(label);
969 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_VERSION, ConditionalStringParameter(label), 1));
971 else if (prop.name == "idletime")
972 return AddMultiInfo(GUIInfo(SYSTEM_IDLE_TIME, atoi(param.c_str())));
974 if (prop.name == "alarmlessorequal" && prop.num_params() == 2)
975 return AddMultiInfo(GUIInfo(SYSTEM_ALARM_LESS_OR_EQUAL, ConditionalStringParameter(prop.param(0)), ConditionalStringParameter(prop.param(1))));
976 else if (prop.name == "date")
978 if (prop.num_params() == 2)
979 return AddMultiInfo(GUIInfo(SYSTEM_DATE, StringUtils::DateStringToYYYYMMDD(prop.param(0)) % 10000, StringUtils::DateStringToYYYYMMDD(prop.param(1)) % 10000));
980 else if (prop.num_params() == 1)
982 int dateformat = StringUtils::DateStringToYYYYMMDD(prop.param(0));
983 if (dateformat <= 0) // not concrete date
984 return AddMultiInfo(GUIInfo(SYSTEM_DATE, ConditionalStringParameter(prop.param(0), true), -1));
986 return AddMultiInfo(GUIInfo(SYSTEM_DATE, dateformat % 10000));
990 else if (prop.name == "time")
992 if (prop.num_params() == 0)
993 return AddMultiInfo(GUIInfo(SYSTEM_TIME, TIME_FORMAT_GUESS));
994 if (prop.num_params() == 1)
996 TIME_FORMAT timeFormat = TranslateTimeFormat(prop.param(0));
997 if (timeFormat == TIME_FORMAT_GUESS)
998 return AddMultiInfo(GUIInfo(SYSTEM_TIME, StringUtils::TimeStringToSeconds(prop.param(0))));
999 return AddMultiInfo(GUIInfo(SYSTEM_TIME, timeFormat));
1002 return AddMultiInfo(GUIInfo(SYSTEM_TIME, StringUtils::TimeStringToSeconds(prop.param(0)), StringUtils::TimeStringToSeconds(prop.param(1))));
1005 else if (cat.name == "library")
1007 if (prop.name == "isscanning") return LIBRARY_IS_SCANNING;
1008 else if (prop.name == "isscanningvideo") return LIBRARY_IS_SCANNING_VIDEO; // TODO: change to IsScanning(Video)
1009 else if (prop.name == "isscanningmusic") return LIBRARY_IS_SCANNING_MUSIC;
1010 else if (prop.name == "hascontent" && prop.num_params())
1012 CStdString cat = prop.param(0);
1013 StringUtils::ToLower(cat);
1014 if (cat == "music") return LIBRARY_HAS_MUSIC;
1015 else if (cat == "video") return LIBRARY_HAS_VIDEO;
1016 else if (cat == "movies") return LIBRARY_HAS_MOVIES;
1017 else if (cat == "tvshows") return LIBRARY_HAS_TVSHOWS;
1018 else if (cat == "musicvideos") return LIBRARY_HAS_MUSICVIDEOS;
1019 else if (cat == "moviesets") return LIBRARY_HAS_MOVIE_SETS;
1022 else if (cat.name == "musicplayer")
1024 for (size_t i = 0; i < sizeof(player_times) / sizeof(infomap); i++) // TODO: remove these, they're repeats
1026 if (prop.name == player_times[i].str)
1027 return AddMultiInfo(GUIInfo(player_times[i].val, TranslateTimeFormat(prop.param())));
1029 if (prop.name == "property")
1031 if (prop.param().Equals("fanart_image"))
1032 return AddMultiInfo(GUIInfo(PLAYER_ITEM_ART, ConditionalStringParameter("fanart")));
1033 return AddListItemProp(prop.param(), MUSICPLAYER_PROPERTY_OFFSET);
1035 return TranslateMusicPlayerString(prop.name);
1037 else if (cat.name == "videoplayer")
1039 for (size_t i = 0; i < sizeof(player_times) / sizeof(infomap); i++) // TODO: remove these, they're repeats
1041 if (prop.name == player_times[i].str)
1042 return AddMultiInfo(GUIInfo(player_times[i].val, TranslateTimeFormat(prop.param())));
1044 if (prop.name == "content" && prop.num_params())
1045 return AddMultiInfo(GUIInfo(VIDEOPLAYER_CONTENT, ConditionalStringParameter(prop.param()), 0));
1046 for (size_t i = 0; i < sizeof(videoplayer) / sizeof(infomap); i++)
1048 if (prop.name == videoplayer[i].str)
1049 return videoplayer[i].val;
1052 else if (cat.name == "slideshow")
1054 for (size_t i = 0; i < sizeof(slideshow) / sizeof(infomap); i++)
1056 if (prop.name == slideshow[i].str)
1057 return slideshow[i].val;
1059 return CPictureInfoTag::TranslateString(prop.name);
1061 else if (cat.name == "container")
1063 for (size_t i = 0; i < sizeof(mediacontainer) / sizeof(infomap); i++) // these ones don't have or need an id
1065 if (prop.name == mediacontainer[i].str)
1066 return mediacontainer[i].val;
1068 int id = atoi(cat.param().c_str());
1069 for (size_t i = 0; i < sizeof(container_bools) / sizeof(infomap); i++) // these ones can have an id (but don't need to?)
1071 if (prop.name == container_bools[i].str)
1072 return id ? AddMultiInfo(GUIInfo(container_bools[i].val, id)) : container_bools[i].val;
1074 for (size_t i = 0; i < sizeof(container_ints) / sizeof(infomap); i++) // these ones can have an int param on the property
1076 if (prop.name == container_ints[i].str)
1077 return AddMultiInfo(GUIInfo(container_ints[i].val, id, atoi(prop.param().c_str())));
1079 for (size_t i = 0; i < sizeof(container_str) / sizeof(infomap); i++) // these ones have a string param on the property
1081 if (prop.name == container_str[i].str)
1082 return AddMultiInfo(GUIInfo(container_str[i].val, id, ConditionalStringParameter(prop.param())));
1084 if (prop.name == "sortdirection")
1086 SortOrder order = SortOrderNone;
1087 if (prop.param().Equals("ascending"))
1088 order = SortOrderAscending;
1089 else if (prop.param().Equals("descending"))
1090 order = SortOrderDescending;
1091 return AddMultiInfo(GUIInfo(CONTAINER_SORT_DIRECTION, order));
1093 else if (prop.name == "sort")
1095 if (prop.param().Equals("songrating"))
1096 return AddMultiInfo(GUIInfo(CONTAINER_SORT_METHOD, SortByRating));
1099 else if (cat.name == "listitem")
1101 int offset = atoi(cat.param().c_str());
1102 int ret = TranslateListItem(prop);
1104 listItemDependent = true;
1106 return AddMultiInfo(GUIInfo(ret, 0, offset, INFOFLAG_LISTITEM_WRAP));
1109 else if (cat.name == "listitemposition")
1111 int offset = atoi(cat.param().c_str());
1112 int ret = TranslateListItem(prop);
1114 listItemDependent = true;
1116 return AddMultiInfo(GUIInfo(ret, 0, offset, INFOFLAG_LISTITEM_POSITION));
1119 else if (cat.name == "listitemnowrap")
1121 int offset = atoi(cat.param().c_str());
1122 int ret = TranslateListItem(prop);
1124 listItemDependent = true;
1126 return AddMultiInfo(GUIInfo(ret, 0, offset));
1129 else if (cat.name == "visualisation")
1131 for (size_t i = 0; i < sizeof(visualisation) / sizeof(infomap); i++)
1133 if (prop.name == visualisation[i].str)
1134 return visualisation[i].val;
1137 else if (cat.name == "fanart")
1139 for (size_t i = 0; i < sizeof(fanart_labels) / sizeof(infomap); i++)
1141 if (prop.name == fanart_labels[i].str)
1142 return fanart_labels[i].val;
1145 else if (cat.name == "skin")
1147 for (size_t i = 0; i < sizeof(skin_labels) / sizeof(infomap); i++)
1149 if (prop.name == skin_labels[i].str)
1150 return skin_labels[i].val;
1152 if (prop.num_params())
1154 if (prop.name == "string")
1156 if (prop.num_params() == 2)
1157 return AddMultiInfo(GUIInfo(SKIN_STRING, CSkinSettings::Get().TranslateString(prop.param(0)), ConditionalStringParameter(prop.param(1))));
1159 return AddMultiInfo(GUIInfo(SKIN_STRING, CSkinSettings::Get().TranslateString(prop.param(0))));
1161 if (prop.name == "hassetting")
1162 return AddMultiInfo(GUIInfo(SKIN_BOOL, CSkinSettings::Get().TranslateBool(prop.param(0))));
1163 else if (prop.name == "hastheme")
1164 return AddMultiInfo(GUIInfo(SKIN_HAS_THEME, ConditionalStringParameter(prop.param(0))));
1167 else if (cat.name == "window")
1169 if (prop.name == "property" && prop.num_params() == 1)
1170 { // TODO: this doesn't support foo.xml
1171 int winID = cat.param().empty() ? 0 : CButtonTranslator::TranslateWindow(cat.param());
1172 if (winID != WINDOW_INVALID)
1173 return AddMultiInfo(GUIInfo(WINDOW_PROPERTY, winID, ConditionalStringParameter(prop.param())));
1175 for (size_t i = 0; i < sizeof(window_bools) / sizeof(infomap); i++)
1177 if (prop.name == window_bools[i].str)
1178 { // TODO: The parameter for these should really be on the first not the second property
1179 if (prop.param().find("xml") != std::string::npos)
1180 return AddMultiInfo(GUIInfo(window_bools[i].val, 0, ConditionalStringParameter(prop.param())));
1181 int winID = prop.param().empty() ? 0 : CButtonTranslator::TranslateWindow(prop.param());
1182 if (winID != WINDOW_INVALID)
1183 return AddMultiInfo(GUIInfo(window_bools[i].val, winID, 0));
1188 else if (cat.name == "control")
1190 for (size_t i = 0; i < sizeof(control_labels) / sizeof(infomap); i++)
1192 if (prop.name == control_labels[i].str)
1193 { // TODO: The parameter for these should really be on the first not the second property
1194 int controlID = atoi(prop.param().c_str());
1196 return AddMultiInfo(GUIInfo(control_labels[i].val, controlID, 0));
1201 else if (cat.name == "controlgroup" && prop.name == "hasfocus")
1203 int groupID = atoi(cat.param().c_str());
1205 return AddMultiInfo(GUIInfo(CONTROL_GROUP_HAS_FOCUS, groupID, atoi(prop.param(0).c_str())));
1207 else if (cat.name == "playlist")
1210 for (size_t i = 0; i < sizeof(playlist) / sizeof(infomap); i++)
1212 if (prop.name == playlist[i].str)
1214 ret = playlist[i].val;
1220 if (prop.num_params() <= 0)
1224 int playlistid = PLAYLIST_NONE;
1225 if (prop.param().Equals("video"))
1226 playlistid = PLAYLIST_VIDEO;
1227 else if (prop.param().Equals("music"))
1228 playlistid = PLAYLIST_MUSIC;
1230 if (playlistid > PLAYLIST_NONE)
1231 return AddMultiInfo(GUIInfo(ret, playlistid));
1235 else if (cat.name == "pvr")
1237 for (size_t i = 0; i < sizeof(pvr) / sizeof(infomap); i++)
1239 if (prop.name == pvr[i].str)
1244 else if (info.size() == 3 || info.size() == 4)
1246 if (info[0].name == "system" && info[1].name == "platform")
1247 { // TODO: replace with a single system.platform
1248 CStdString platform = info[2].name;
1249 if (platform == "linux")
1251 if (info.size() == 4)
1253 CStdString device = info[3].name;
1254 if (device == "raspberrypi") return SYSTEM_PLATFORM_LINUX_RASPBERRY_PI;
1256 else return SYSTEM_PLATFORM_LINUX;
1258 else if (platform == "windows") return SYSTEM_PLATFORM_WINDOWS;
1259 else if (platform == "darwin") return SYSTEM_PLATFORM_DARWIN;
1260 else if (platform == "osx") return SYSTEM_PLATFORM_DARWIN_OSX;
1261 else if (platform == "ios") return SYSTEM_PLATFORM_DARWIN_IOS;
1262 else if (platform == "atv2") return SYSTEM_PLATFORM_DARWIN_ATV2;
1263 else if (platform == "android") return SYSTEM_PLATFORM_ANDROID;
1265 if (info[0].name == "musicplayer")
1266 { // TODO: these two don't allow duration(foo) and also don't allow more than this number of levels...
1267 if (info[1].name == "position")
1269 int position = atoi(info[1].param().c_str());
1270 int value = TranslateMusicPlayerString(info[2].name); // musicplayer.position(foo).bar
1271 return AddMultiInfo(GUIInfo(value, 0, position));
1273 else if (info[1].name == "offset")
1275 int position = atoi(info[1].param().c_str());
1276 int value = TranslateMusicPlayerString(info[2].name); // musicplayer.offset(foo).bar
1277 return AddMultiInfo(GUIInfo(value, 1, position));
1280 else if (info[0].name == "container")
1282 int id = atoi(info[0].param().c_str());
1283 int offset = atoi(info[1].param().c_str());
1284 if (info[1].name == "listitemnowrap")
1286 listItemDependent = true;
1287 return AddMultiInfo(GUIInfo(TranslateListItem(info[2]), id, offset));
1289 else if (info[1].name == "listitemposition")
1291 listItemDependent = true;
1292 return AddMultiInfo(GUIInfo(TranslateListItem(info[2]), id, offset, INFOFLAG_LISTITEM_POSITION));
1294 else if (info[1].name == "listitem")
1296 listItemDependent = true;
1297 return AddMultiInfo(GUIInfo(TranslateListItem(info[2]), id, offset, INFOFLAG_LISTITEM_WRAP));
1305 int CGUIInfoManager::TranslateListItem(const Property &info)
1307 for (size_t i = 0; i < sizeof(listitem_labels) / sizeof(infomap); i++) // these ones don't have or need an id
1309 if (info.name == listitem_labels[i].str)
1310 return listitem_labels[i].val;
1312 if (info.name == "property" && info.num_params() == 1)
1314 if (info.param().Equals("fanart_image"))
1315 return AddListItemProp("fanart", LISTITEM_ART_OFFSET);
1316 return AddListItemProp(info.param());
1318 if (info.name == "art" && info.num_params() == 1)
1319 return AddListItemProp(info.param(), LISTITEM_ART_OFFSET);
1323 int CGUIInfoManager::TranslateMusicPlayerString(const CStdString &info) const
1325 for (size_t i = 0; i < sizeof(musicplayer) / sizeof(infomap); i++)
1327 if (info == musicplayer[i].str)
1328 return musicplayer[i].val;
1333 TIME_FORMAT CGUIInfoManager::TranslateTimeFormat(const CStdString &format)
1335 if (format.empty()) return TIME_FORMAT_GUESS;
1336 else if (format.Equals("hh")) return TIME_FORMAT_HH;
1337 else if (format.Equals("mm")) return TIME_FORMAT_MM;
1338 else if (format.Equals("ss")) return TIME_FORMAT_SS;
1339 else if (format.Equals("hh:mm")) return TIME_FORMAT_HH_MM;
1340 else if (format.Equals("mm:ss")) return TIME_FORMAT_MM_SS;
1341 else if (format.Equals("hh:mm:ss")) return TIME_FORMAT_HH_MM_SS;
1342 else if (format.Equals("hh:mm:ss xx")) return TIME_FORMAT_HH_MM_SS_XX;
1343 else if (format.Equals("h")) return TIME_FORMAT_H;
1344 else if (format.Equals("h:mm:ss")) return TIME_FORMAT_H_MM_SS;
1345 else if (format.Equals("h:mm:ss xx")) return TIME_FORMAT_H_MM_SS_XX;
1346 else if (format.Equals("xx")) return TIME_FORMAT_XX;
1347 return TIME_FORMAT_GUESS;
1350 CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fallback)
1352 if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
1353 return GetSkinVariableString(info, false);
1355 CStdString strLabel;
1356 if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
1357 return GetMultiInfoLabel(m_multiInfo[info - MULTI_INFO_START], contextWindow);
1359 if (info >= SLIDE_INFO_START && info <= SLIDE_INFO_END)
1360 return GetPictureLabel(info);
1362 if (info >= LISTITEM_PROPERTY_START+MUSICPLAYER_PROPERTY_OFFSET &&
1363 info - (LISTITEM_PROPERTY_START+MUSICPLAYER_PROPERTY_OFFSET) < (int)m_listitemProperties.size())
1364 { // grab the property
1368 CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START-MUSICPLAYER_PROPERTY_OFFSET];
1369 return m_currentFile->GetProperty(property).asString();
1372 if (info >= LISTITEM_START && info <= LISTITEM_END)
1374 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS); // true for has list items
1377 CFileItemPtr item = window->GetCurrentListItem();
1378 strLabel = GetItemLabel(item.get(), info, fallback);
1386 case PVR_NEXT_RECORDING_CHANNEL:
1387 case PVR_NEXT_RECORDING_CHAN_ICO:
1388 case PVR_NEXT_RECORDING_DATETIME:
1389 case PVR_NEXT_RECORDING_TITLE:
1390 case PVR_NOW_RECORDING_CHANNEL:
1391 case PVR_NOW_RECORDING_CHAN_ICO:
1392 case PVR_NOW_RECORDING_DATETIME:
1393 case PVR_NOW_RECORDING_TITLE:
1394 case PVR_BACKEND_NAME:
1395 case PVR_BACKEND_VERSION:
1396 case PVR_BACKEND_HOST:
1397 case PVR_BACKEND_DISKSPACE:
1398 case PVR_BACKEND_CHANNELS:
1399 case PVR_BACKEND_TIMERS:
1400 case PVR_BACKEND_RECORDINGS:
1401 case PVR_BACKEND_NUMBER:
1402 case PVR_TOTAL_DISKSPACE:
1403 case PVR_NEXT_TIMER:
1404 case PVR_PLAYING_DURATION:
1405 case PVR_PLAYING_TIME:
1406 case PVR_PLAYING_PROGRESS:
1407 case PVR_ACTUAL_STREAM_CLIENT:
1408 case PVR_ACTUAL_STREAM_DEVICE:
1409 case PVR_ACTUAL_STREAM_STATUS:
1410 case PVR_ACTUAL_STREAM_SIG:
1411 case PVR_ACTUAL_STREAM_SNR:
1412 case PVR_ACTUAL_STREAM_SIG_PROGR:
1413 case PVR_ACTUAL_STREAM_SNR_PROGR:
1414 case PVR_ACTUAL_STREAM_BER:
1415 case PVR_ACTUAL_STREAM_UNC:
1416 case PVR_ACTUAL_STREAM_VIDEO_BR:
1417 case PVR_ACTUAL_STREAM_AUDIO_BR:
1418 case PVR_ACTUAL_STREAM_DOLBY_BR:
1419 case PVR_ACTUAL_STREAM_CRYPTION:
1420 case PVR_ACTUAL_STREAM_SERVICE:
1421 case PVR_ACTUAL_STREAM_MUX:
1422 case PVR_ACTUAL_STREAM_PROVIDER:
1423 g_PVRManager.TranslateCharInfo(info, strLabel);
1425 case WEATHER_CONDITIONS:
1426 strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_COND);
1427 StringUtils::Trim(strLabel);
1429 case WEATHER_TEMPERATURE:
1430 strLabel = StringUtils::Format("%s%s",
1431 g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_TEMP).c_str(),
1432 g_langInfo.GetTempUnitString().c_str());
1434 case WEATHER_LOCATION:
1435 strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_LOCATION);
1437 case WEATHER_FANART_CODE:
1438 strLabel = URIUtils::GetFileName(g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON));
1439 URIUtils::RemoveExtension(strLabel);
1441 case WEATHER_PLUGIN:
1442 strLabel = CSettings::Get().GetString("weather.addon");
1445 strLabel = GetDate();
1448 strLabel = StringUtils::Format("%02.2f", m_fps);
1451 strLabel = StringUtils::Format("%2.1f dB", CAEUtil::PercentToGain(g_application.GetVolume(false)));
1453 case PLAYER_SUBTITLE_DELAY:
1454 strLabel = StringUtils::Format("%2.3f s", CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay);
1456 case PLAYER_AUDIO_DELAY:
1457 strLabel = StringUtils::Format("%2.3f s", CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay);
1459 case PLAYER_CHAPTER:
1460 if(g_application.m_pPlayer->IsPlaying())
1461 strLabel = StringUtils::Format("%02d", g_application.m_pPlayer->GetChapter());
1463 case PLAYER_CHAPTERCOUNT:
1464 if(g_application.m_pPlayer->IsPlaying())
1465 strLabel = StringUtils::Format("%02d", g_application.m_pPlayer->GetChapterCount());
1467 case PLAYER_CHAPTERNAME:
1468 if(g_application.m_pPlayer->IsPlaying())
1469 g_application.m_pPlayer->GetChapterName(strLabel);
1471 case PLAYER_CACHELEVEL:
1474 if(g_application.m_pPlayer->IsPlaying() && GetInt(iLevel, PLAYER_CACHELEVEL) && iLevel >= 0)
1475 strLabel = StringUtils::Format("%i", iLevel);
1479 if(g_application.m_pPlayer->IsPlaying())
1480 strLabel = GetCurrentPlayTime(TIME_FORMAT_HH_MM);
1482 case PLAYER_DURATION:
1483 if(g_application.m_pPlayer->IsPlaying())
1484 strLabel = GetDuration(TIME_FORMAT_HH_MM);
1487 case PLAYER_FILENAME:
1488 case PLAYER_FILEPATH:
1491 if (m_currentFile->HasMusicInfoTag())
1492 strLabel = m_currentFile->GetMusicInfoTag()->GetURL();
1493 else if (m_currentFile->HasVideoInfoTag())
1494 strLabel = m_currentFile->GetVideoInfoTag()->m_strFileNameAndPath;
1495 if (strLabel.empty())
1496 strLabel = m_currentFile->GetPath();
1498 if (info == PLAYER_PATH)
1500 // do this twice since we want the path outside the archive if this
1502 if (URIUtils::IsInArchive(strLabel))
1503 strLabel = URIUtils::GetParentPath(strLabel);
1504 strLabel = URIUtils::GetParentPath(strLabel);
1506 else if (info == PLAYER_FILENAME)
1507 strLabel = URIUtils::GetFileName(strLabel);
1513 if (m_currentFile->HasPVRChannelInfoTag())
1516 return m_currentFile->GetPVRChannelInfoTag()->GetEPGNow(tag) ?
1518 CSettings::Get().GetBool("epg.hidenoinfoavailable") ?
1519 StringUtils::EmptyString :
1520 g_localizeStrings.Get(19055); // no information available
1522 if (m_currentFile->HasPVRRecordingInfoTag() && !m_currentFile->GetPVRRecordingInfoTag()->m_strTitle.empty())
1523 return m_currentFile->GetPVRRecordingInfoTag()->m_strTitle;
1524 if (m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->m_strTitle.empty())
1525 return m_currentFile->GetVideoInfoTag()->m_strTitle;
1526 if (m_currentFile->HasMusicInfoTag() && !m_currentFile->GetMusicInfoTag()->GetTitle().empty())
1527 return m_currentFile->GetMusicInfoTag()->GetTitle();
1528 // don't have the title, so use dvdplayer, label, or drop down to title from path
1529 if (!g_application.m_pPlayer->GetPlayingTitle().empty())
1530 return g_application.m_pPlayer->GetPlayingTitle();
1531 if (!m_currentFile->GetLabel().empty())
1532 return m_currentFile->GetLabel();
1533 return CUtil::GetTitleFromPath(m_currentFile->GetPath());
1537 if (!g_application.m_pPlayer->GetPlayingTitle().empty())
1538 return g_application.m_pPlayer->GetPlayingTitle();
1542 case MUSICPLAYER_TITLE:
1543 case MUSICPLAYER_ALBUM:
1544 case MUSICPLAYER_ARTIST:
1545 case MUSICPLAYER_ALBUM_ARTIST:
1546 case MUSICPLAYER_GENRE:
1547 case MUSICPLAYER_YEAR:
1548 case MUSICPLAYER_TRACK_NUMBER:
1549 case MUSICPLAYER_BITRATE:
1550 case MUSICPLAYER_PLAYLISTLEN:
1551 case MUSICPLAYER_PLAYLISTPOS:
1552 case MUSICPLAYER_CHANNELS:
1553 case MUSICPLAYER_BITSPERSAMPLE:
1554 case MUSICPLAYER_SAMPLERATE:
1555 case MUSICPLAYER_CODEC:
1556 case MUSICPLAYER_DISC_NUMBER:
1557 case MUSICPLAYER_RATING:
1558 case MUSICPLAYER_COMMENT:
1559 case MUSICPLAYER_LYRICS:
1560 case MUSICPLAYER_CHANNEL_NAME:
1561 case MUSICPLAYER_CHANNEL_NUMBER:
1562 case MUSICPLAYER_CHANNEL_GROUP:
1563 case MUSICPLAYER_PLAYCOUNT:
1564 case MUSICPLAYER_LASTPLAYED:
1565 strLabel = GetMusicLabel(info);
1567 case VIDEOPLAYER_TITLE:
1568 case VIDEOPLAYER_ORIGINALTITLE:
1569 case VIDEOPLAYER_GENRE:
1570 case VIDEOPLAYER_DIRECTOR:
1571 case VIDEOPLAYER_YEAR:
1572 case VIDEOPLAYER_PLAYLISTLEN:
1573 case VIDEOPLAYER_PLAYLISTPOS:
1574 case VIDEOPLAYER_PLOT:
1575 case VIDEOPLAYER_PLOT_OUTLINE:
1576 case VIDEOPLAYER_EPISODE:
1577 case VIDEOPLAYER_SEASON:
1578 case VIDEOPLAYER_RATING:
1579 case VIDEOPLAYER_RATING_AND_VOTES:
1580 case VIDEOPLAYER_TVSHOW:
1581 case VIDEOPLAYER_PREMIERED:
1582 case VIDEOPLAYER_STUDIO:
1583 case VIDEOPLAYER_COUNTRY:
1584 case VIDEOPLAYER_MPAA:
1585 case VIDEOPLAYER_TOP250:
1586 case VIDEOPLAYER_CAST:
1587 case VIDEOPLAYER_CAST_AND_ROLE:
1588 case VIDEOPLAYER_ARTIST:
1589 case VIDEOPLAYER_ALBUM:
1590 case VIDEOPLAYER_WRITER:
1591 case VIDEOPLAYER_TAGLINE:
1592 case VIDEOPLAYER_TRAILER:
1593 case VIDEOPLAYER_STARTTIME:
1594 case VIDEOPLAYER_ENDTIME:
1595 case VIDEOPLAYER_NEXT_TITLE:
1596 case VIDEOPLAYER_NEXT_GENRE:
1597 case VIDEOPLAYER_NEXT_PLOT:
1598 case VIDEOPLAYER_NEXT_PLOT_OUTLINE:
1599 case VIDEOPLAYER_NEXT_STARTTIME:
1600 case VIDEOPLAYER_NEXT_ENDTIME:
1601 case VIDEOPLAYER_NEXT_DURATION:
1602 case VIDEOPLAYER_CHANNEL_NAME:
1603 case VIDEOPLAYER_CHANNEL_NUMBER:
1604 case VIDEOPLAYER_CHANNEL_GROUP:
1605 case VIDEOPLAYER_PARENTAL_RATING:
1606 case VIDEOPLAYER_PLAYCOUNT:
1607 case VIDEOPLAYER_LASTPLAYED:
1608 strLabel = GetVideoLabel(info);
1610 case VIDEOPLAYER_VIDEO_CODEC:
1611 if(g_application.m_pPlayer->IsPlaying())
1614 strLabel = m_videoInfo.videoCodecName;
1617 case VIDEOPLAYER_VIDEO_RESOLUTION:
1618 if(g_application.m_pPlayer->IsPlaying())
1621 return CStreamDetails::VideoDimsToResolutionDescription(m_videoInfo.width, m_videoInfo.height);
1624 case VIDEOPLAYER_AUDIO_CODEC:
1625 if(g_application.m_pPlayer->IsPlaying())
1628 strLabel = m_audioInfo.audioCodecName;
1631 case VIDEOPLAYER_VIDEO_ASPECT:
1632 if (g_application.m_pPlayer->IsPlaying())
1635 strLabel = CStreamDetails::VideoAspectToAspectDescription(m_videoInfo.videoAspectRatio);
1638 case VIDEOPLAYER_AUDIO_CHANNELS:
1639 if(g_application.m_pPlayer->IsPlaying())
1642 strLabel = StringUtils::Format("%i", m_audioInfo.channels);
1645 case VIDEOPLAYER_AUDIO_LANG:
1646 if(g_application.m_pPlayer->IsPlaying())
1648 SPlayerAudioStreamInfo info;
1649 g_application.m_pPlayer->GetAudioStreamInfo(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream, info);
1650 strLabel = info.language;
1653 case VIDEOPLAYER_STEREOSCOPIC_MODE:
1654 if(g_application.m_pPlayer->IsPlaying())
1657 strLabel = m_videoInfo.stereoMode;
1660 case VIDEOPLAYER_SUBTITLES_LANG:
1661 // use g_settings.m_currentVideoSettings.m_SubtitleOn and g_settings.m_currentVideoSettings.m_SubtitleStream
1662 // instead of g_application.m_pPlayer->GetSubtitleVisible and g_application.m_pPlayer->GetSubtitle()
1663 // because when we switch subtitles there is few frames when weird things happen on subtitles switch with latter:
1664 // - when we switch from one sub to another, for few frames (time to handle message, close old and open new subs)
1665 // g_application.m_pPlayer->GetSubtitle() will return last of sub streams (that's how CSelectionStreams::IndexOf work for -1 index)
1666 // - when we toggle disable/enable subs there will be few frames before message will be handled
1667 if(g_application.m_pPlayer && g_application.m_pPlayer->IsPlaying() && CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn)
1669 SPlayerSubtitleStreamInfo info;
1670 g_application.m_pPlayer->GetSubtitleStreamInfo(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream, info);
1671 strLabel = info.language;
1674 case PLAYLIST_LENGTH:
1675 case PLAYLIST_POSITION:
1676 case PLAYLIST_RANDOM:
1677 case PLAYLIST_REPEAT:
1678 strLabel = GetPlaylistLabel(info);
1680 case MUSICPM_SONGSPLAYED:
1681 case MUSICPM_MATCHINGSONGS:
1682 case MUSICPM_MATCHINGSONGSPICKED:
1683 case MUSICPM_MATCHINGSONGSLEFT:
1684 case MUSICPM_RELAXEDSONGSPICKED:
1685 case MUSICPM_RANDOMSONGSPICKED:
1686 strLabel = GetMusicPartyModeLabel(info);
1689 case SYSTEM_FREE_SPACE:
1690 case SYSTEM_USED_SPACE:
1691 case SYSTEM_TOTAL_SPACE:
1692 case SYSTEM_FREE_SPACE_PERCENT:
1693 case SYSTEM_USED_SPACE_PERCENT:
1694 return g_sysinfo.GetHddSpaceInfo(info);
1697 case SYSTEM_CPU_TEMPERATURE:
1698 case SYSTEM_GPU_TEMPERATURE:
1699 case SYSTEM_FAN_SPEED:
1700 case SYSTEM_CPU_USAGE:
1701 return GetSystemHeatInfo(info);
1704 case SYSTEM_VIDEO_ENCODER_INFO:
1705 case NETWORK_MAC_ADDRESS:
1706 case SYSTEM_KERNEL_VERSION:
1707 case SYSTEM_CPUFREQUENCY:
1708 case SYSTEM_INTERNET_STATE:
1710 case SYSTEM_TOTALUPTIME:
1711 case SYSTEM_BATTERY_LEVEL:
1712 return g_sysinfo.GetInfo(info);
1715 case SYSTEM_SCREEN_RESOLUTION:
1716 if(g_Windowing.IsFullScreen())
1717 strLabel = StringUtils::Format("%ix%i@%.2fHz - %s (%02.2f fps)",
1718 CDisplaySettings::Get().GetCurrentResolutionInfo().iScreenWidth,
1719 CDisplaySettings::Get().GetCurrentResolutionInfo().iScreenHeight,
1720 CDisplaySettings::Get().GetCurrentResolutionInfo().fRefreshRate,
1721 g_localizeStrings.Get(244).c_str(),
1724 strLabel = StringUtils::Format("%ix%i - %s (%02.2f fps)",
1725 CDisplaySettings::Get().GetCurrentResolutionInfo().iScreenWidth,
1726 CDisplaySettings::Get().GetCurrentResolutionInfo().iScreenHeight,
1727 g_localizeStrings.Get(242).c_str(),
1732 case CONTAINER_FOLDERPATH:
1733 case CONTAINER_FOLDERNAME:
1735 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1738 if (info==CONTAINER_FOLDERNAME)
1739 strLabel = ((CGUIMediaWindow*)window)->CurrentDirectory().GetLabel();
1741 strLabel = CURL(((CGUIMediaWindow*)window)->CurrentDirectory().GetPath()).GetWithoutUserDetails();
1745 case CONTAINER_PLUGINNAME:
1747 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1750 CURL url(((CGUIMediaWindow*)window)->CurrentDirectory().GetPath());
1751 if (url.GetProtocol().Equals("plugin"))
1753 strLabel = url.GetFileName();
1754 URIUtils::RemoveSlashAtEnd(strLabel);
1759 case CONTAINER_VIEWMODE:
1761 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1764 const CGUIControl *control = window->GetControl(window->GetViewContainerID());
1765 if (control && control->IsContainer())
1766 strLabel = ((IGUIContainer *)control)->GetLabel();
1770 case CONTAINER_SORT_METHOD:
1772 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1775 const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
1777 strLabel = g_localizeStrings.Get(viewState->GetSortMethodLabel());
1781 case CONTAINER_NUM_PAGES:
1782 case CONTAINER_NUM_ITEMS:
1783 case CONTAINER_CURRENT_PAGE:
1784 return GetMultiInfoLabel(GUIInfo(info), contextWindow);
1786 case CONTAINER_SHOWPLOT:
1788 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1790 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("showplot").asString();
1793 case CONTAINER_TOTALTIME:
1795 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1798 const CFileItemList& items=((CGUIMediaWindow *)window)->CurrentDirectory();
1800 for (int i=0;i<items.Size();++i)
1802 CFileItemPtr item=items.Get(i);
1803 if (item->HasMusicInfoTag())
1804 duration += item->GetMusicInfoTag()->GetDuration();
1805 else if (item->HasVideoInfoTag())
1806 duration += item->GetVideoInfoTag()->m_streamDetails.GetVideoDuration();
1809 return StringUtils::SecondsToTimeString(duration);
1813 case SYSTEM_BUILD_VERSION:
1814 strLabel = GetVersion();
1816 case SYSTEM_BUILD_DATE:
1817 strLabel = GetBuild();
1819 case SYSTEM_FREE_MEMORY:
1820 case SYSTEM_FREE_MEMORY_PERCENT:
1821 case SYSTEM_USED_MEMORY:
1822 case SYSTEM_USED_MEMORY_PERCENT:
1823 case SYSTEM_TOTAL_MEMORY:
1825 MEMORYSTATUSEX stat;
1826 stat.dwLength = sizeof(MEMORYSTATUSEX);
1827 GlobalMemoryStatusEx(&stat);
1828 int iMemPercentFree = 100 - ((int)( 100.0f* (stat.ullTotalPhys - stat.ullAvailPhys)/stat.ullTotalPhys + 0.5f ));
1829 int iMemPercentUsed = 100 - iMemPercentFree;
1831 if (info == SYSTEM_FREE_MEMORY)
1832 strLabel = StringUtils::Format("%luMB", (ULONG)(stat.ullAvailPhys/MB));
1833 else if (info == SYSTEM_FREE_MEMORY_PERCENT)
1834 strLabel = StringUtils::Format("%i%%", iMemPercentFree);
1835 else if (info == SYSTEM_USED_MEMORY)
1836 strLabel = StringUtils::Format("%luMB", (ULONG)((stat.ullTotalPhys - stat.ullAvailPhys)/MB));
1837 else if (info == SYSTEM_USED_MEMORY_PERCENT)
1838 strLabel = StringUtils::Format("%i%%", iMemPercentUsed);
1839 else if (info == SYSTEM_TOTAL_MEMORY)
1840 strLabel = StringUtils::Format("%luMB", (ULONG)(stat.ullTotalPhys/MB));
1843 case SYSTEM_SCREEN_MODE:
1844 strLabel = g_graphicsContext.GetResInfo().strMode;
1846 case SYSTEM_SCREEN_WIDTH:
1847 strLabel = StringUtils::Format("%i", g_graphicsContext.GetResInfo().iScreenWidth);
1849 case SYSTEM_SCREEN_HEIGHT:
1850 strLabel = StringUtils::Format("%i", g_graphicsContext.GetResInfo().iScreenHeight);
1852 case SYSTEM_CURRENT_WINDOW:
1853 return g_localizeStrings.Get(g_windowManager.GetFocusedWindow());
1855 case SYSTEM_STARTUP_WINDOW:
1856 strLabel = StringUtils::Format("%i", CSettings::Get().GetInt("lookandfeel.startupwindow"));
1858 case SYSTEM_CURRENT_CONTROL:
1860 CGUIWindow *window = g_windowManager.GetWindow(g_windowManager.GetFocusedWindow());
1863 CGUIControl *control = window->GetFocusedControl();
1865 strLabel = control->GetDescription();
1869 #ifdef HAS_DVD_DRIVE
1870 case SYSTEM_DVD_LABEL:
1871 strLabel = g_mediaManager.GetDiskLabel();
1874 case SYSTEM_ALARM_POS:
1875 if (g_alarmClock.GetRemaining("shutdowntimer") == 0.f)
1879 double fTime = g_alarmClock.GetRemaining("shutdowntimer");
1881 strLabel = StringUtils::Format(g_localizeStrings.Get(13213).c_str(), g_alarmClock.GetRemaining("shutdowntimer")/60.f);
1883 strLabel = StringUtils::Format(g_localizeStrings.Get(13214).c_str(), g_alarmClock.GetRemaining("shutdowntimer"));
1886 case SYSTEM_PROFILENAME:
1887 strLabel = CProfilesManager::Get().GetCurrentProfile().getName();
1889 case SYSTEM_PROFILECOUNT:
1890 strLabel = StringUtils::Format("%i", CProfilesManager::Get().GetNumberOfProfiles());
1892 case SYSTEM_PROFILEAUTOLOGIN:
1894 int profileId = CProfilesManager::Get().GetAutoLoginProfileId();
1895 if ((profileId < 0) || (!CProfilesManager::Get().GetProfileName(profileId, strLabel)))
1896 strLabel = g_localizeStrings.Get(37014); // Last used profile
1899 case SYSTEM_LANGUAGE:
1900 strLabel = CSettings::Get().GetString("locale.language");
1902 case SYSTEM_TEMPERATURE_UNITS:
1903 strLabel = g_langInfo.GetTempUnitString();
1905 case SYSTEM_PROGRESS_BAR:
1908 if (GetInt(percent, SYSTEM_PROGRESS_BAR) && percent > 0)
1909 strLabel = StringUtils::Format("%i", percent);
1912 case SYSTEM_FRIENDLY_NAME:
1914 CStdString friendlyName = CSettings::Get().GetString("services.devicename");
1915 if (friendlyName.Equals("XBMC"))
1916 strLabel = StringUtils::Format("%s (%s)", friendlyName.c_str(), g_application.getNetwork().GetHostName().c_str());
1918 strLabel = friendlyName;
1921 case SYSTEM_STEREOSCOPIC_MODE:
1923 int stereoMode = CSettings::Get().GetInt("videoscreen.stereoscopicmode");
1924 strLabel = StringUtils::Format("%i", stereoMode);
1929 strLabel = CSettings::Get().GetString("lookandfeel.skintheme");
1931 case SKIN_COLOUR_THEME:
1932 strLabel = CSettings::Get().GetString("lookandfeel.skincolors");
1934 case SKIN_ASPECT_RATIO:
1936 strLabel = g_SkinInfo->GetCurrentAspect();
1938 case NETWORK_IP_ADDRESS:
1940 CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1942 return iface->GetCurrentIPAddress();
1945 case NETWORK_SUBNET_MASK:
1947 CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1949 return iface->GetCurrentNetmask();
1952 case NETWORK_GATEWAY_ADDRESS:
1954 CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1956 return iface->GetCurrentDefaultGateway();
1959 case NETWORK_DNS1_ADDRESS:
1961 vector<CStdString> nss = g_application.getNetwork().GetNameServers();
1962 if (nss.size() >= 1)
1966 case NETWORK_DNS2_ADDRESS:
1968 vector<CStdString> nss = g_application.getNetwork().GetNameServers();
1969 if (nss.size() >= 2)
1973 case NETWORK_DHCP_ADDRESS:
1975 CStdString dhcpserver;
1979 case NETWORK_LINK_STATE:
1981 CStdString linkStatus = g_localizeStrings.Get(151);
1983 CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1984 if (iface && iface->IsConnected())
1985 linkStatus += g_localizeStrings.Get(15207);
1987 linkStatus += g_localizeStrings.Get(15208);
1992 case VISUALISATION_PRESET:
1994 CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
1995 g_windowManager.SendMessage(msg);
1996 if (msg.GetPointer())
1998 CVisualisation* viz = NULL;
1999 viz = (CVisualisation*)msg.GetPointer();
2002 strLabel = viz->GetPresetName();
2003 URIUtils::RemoveExtension(strLabel);
2008 case VISUALISATION_NAME:
2011 strLabel = CSettings::Get().GetString("musicplayer.visualisation");
2012 if (CAddonMgr::Get().GetAddon(strLabel,addon) && addon)
2013 strLabel = addon->Name();
2018 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2020 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color1").asString();
2025 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2027 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color2").asString();
2032 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2034 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color3").asString();
2039 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2041 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetArt("fanart");
2044 case SYSTEM_RENDER_VENDOR:
2045 strLabel = g_Windowing.GetRenderVendor();
2047 case SYSTEM_RENDER_RENDERER:
2048 strLabel = g_Windowing.GetRenderRenderer();
2050 case SYSTEM_RENDER_VERSION:
2051 strLabel = g_Windowing.GetRenderVersionString();
2058 // tries to get a integer value for use in progressbars/sliders and such
2059 bool CGUIInfoManager::GetInt(int &value, int info, int contextWindow, const CGUIListItem *item /* = NULL */) const
2061 if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
2062 return GetMultiInfoInt(value, m_multiInfo[info - MULTI_INFO_START], contextWindow);
2064 if (info >= LISTITEM_START && info <= LISTITEM_END)
2065 return GetItemInt(value, item, info);
2071 value = (int)g_application.GetVolume();
2073 case PLAYER_SUBTITLE_DELAY:
2074 value = g_application.GetSubtitleDelay();
2076 case PLAYER_AUDIO_DELAY:
2077 value = g_application.GetAudioDelay();
2079 case PLAYER_PROGRESS:
2080 case PLAYER_PROGRESS_CACHE:
2081 case PLAYER_SEEKBAR:
2082 case PLAYER_CACHELEVEL:
2083 case PLAYER_CHAPTER:
2084 case PLAYER_CHAPTERCOUNT:
2086 if( g_application.m_pPlayer->IsPlaying())
2090 case PLAYER_PROGRESS:
2091 value = (int)(g_application.GetPercentage());
2093 case PLAYER_PROGRESS_CACHE:
2094 value = (int)(g_application.GetCachePercentage());
2096 case PLAYER_SEEKBAR:
2097 value = (int)g_application.GetSeekHandler()->GetPercent();
2099 case PLAYER_CACHELEVEL:
2100 value = (int)(g_application.m_pPlayer->GetCacheLevel());
2102 case PLAYER_CHAPTER:
2103 value = g_application.m_pPlayer->GetChapter();
2105 case PLAYER_CHAPTERCOUNT:
2106 value = g_application.m_pPlayer->GetChapterCount();
2112 case SYSTEM_FREE_MEMORY:
2113 case SYSTEM_USED_MEMORY:
2115 MEMORYSTATUSEX stat;
2116 stat.dwLength = sizeof(MEMORYSTATUSEX);
2117 GlobalMemoryStatusEx(&stat);
2118 int memPercentUsed = (int)( 100.0f* (stat.ullTotalPhys - stat.ullAvailPhys)/stat.ullTotalPhys + 0.5f );
2119 if (info == SYSTEM_FREE_MEMORY)
2120 value = 100 - memPercentUsed;
2122 value = memPercentUsed;
2125 case SYSTEM_PROGRESS_BAR:
2127 CGUIDialogProgress *bar = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
2128 if (bar && bar->IsDialogRunning())
2129 value = bar->GetPercentage();
2132 case SYSTEM_FREE_SPACE:
2133 case SYSTEM_USED_SPACE:
2135 g_sysinfo.GetHddSpaceInfo(value, info, true);
2138 case SYSTEM_CPU_USAGE:
2139 value = g_cpuInfo.getUsedPercentage();
2141 case PVR_PLAYING_PROGRESS:
2142 case PVR_ACTUAL_STREAM_SIG_PROGR:
2143 case PVR_ACTUAL_STREAM_SNR_PROGR:
2144 value = g_PVRManager.TranslateIntInfo(info);
2146 case SYSTEM_BATTERY_LEVEL:
2147 value = g_powerManager.BatteryLevel();
2153 // functor for comparison InfoPtr's
2154 struct InfoBoolFinder
2156 InfoBoolFinder(const std::string &expression, int context) : m_bool(expression, context) {};
2157 bool operator() (const InfoPtr &right) const { return m_bool == *right; };
2161 INFO::InfoPtr CGUIInfoManager::Register(const CStdString &expression, int context)
2163 CStdString condition(CGUIInfoLabel::ReplaceLocalize(expression));
2164 StringUtils::Trim(condition);
2165 StringUtils::ToLower(condition);
2167 if (condition.empty())
2168 return INFO::InfoPtr();
2170 CSingleLock lock(m_critInfo);
2171 // do we have the boolean expression already registered?
2172 vector<InfoPtr>::const_iterator i = find_if(m_bools.begin(), m_bools.end(), InfoBoolFinder(condition, context));
2173 if (i != m_bools.end())
2176 if (condition.find_first_of("|+[]!") != condition.npos)
2177 m_bools.push_back(boost::make_shared<InfoExpression>(condition, context));
2179 m_bools.push_back(boost::make_shared<InfoSingle>(condition, context));
2181 return m_bools.back();
2184 bool CGUIInfoManager::EvaluateBool(const CStdString &expression, int contextWindow)
2186 bool result = false;
2187 INFO::InfoPtr info = Register(expression, contextWindow);
2189 result = info->Get();
2193 // checks the condition and returns it as necessary. Currently used
2194 // for toggle button controls and visibility of images.
2195 bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListItem *item)
2197 bool bReturn = false;
2198 int condition = abs(condition1);
2200 if (condition >= LISTITEM_START && condition < LISTITEM_END)
2203 bReturn = GetItemBool(item, condition);
2206 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS); // true for has list items
2209 CFileItemPtr item = window->GetCurrentListItem();
2210 bReturn = GetItemBool(item.get(), condition);
2214 // Ethernet Link state checking
2215 // Will check if system has a Ethernet Link connection! [Cable in!]
2216 // This can used for the skinner to switch off Network or Inter required functions
2217 else if ( condition == SYSTEM_ALWAYS_TRUE)
2219 else if (condition == SYSTEM_ALWAYS_FALSE)
2221 else if (condition == SYSTEM_ETHERNET_LINK_ACTIVE)
2223 else if (condition == WINDOW_IS_MEDIA)
2224 { // note: This doesn't return true for dialogs (content, favourites, login, videoinfo)
2225 CGUIWindow *pWindow = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
2226 bReturn = (pWindow && pWindow->IsMediaWindow());
2228 else if (condition == PLAYER_MUTED)
2229 bReturn = g_application.IsMuted();
2230 else if (condition >= LIBRARY_HAS_MUSIC && condition <= LIBRARY_HAS_MUSICVIDEOS)
2231 bReturn = GetLibraryBool(condition);
2232 else if (condition == LIBRARY_IS_SCANNING)
2234 if (g_application.IsMusicScanning() || g_application.IsVideoScanning())
2239 else if (condition == LIBRARY_IS_SCANNING_VIDEO)
2241 bReturn = g_application.IsVideoScanning();
2243 else if (condition == LIBRARY_IS_SCANNING_MUSIC)
2245 bReturn = g_application.IsMusicScanning();
2247 else if (condition == SYSTEM_PLATFORM_LINUX)
2248 #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
2253 else if (condition == SYSTEM_PLATFORM_WINDOWS)
2254 #ifdef TARGET_WINDOWS
2259 else if (condition == SYSTEM_PLATFORM_DARWIN)
2260 #ifdef TARGET_DARWIN
2265 else if (condition == SYSTEM_PLATFORM_DARWIN_OSX)
2266 #ifdef TARGET_DARWIN_OSX
2271 else if (condition == SYSTEM_PLATFORM_DARWIN_IOS)
2272 #ifdef TARGET_DARWIN_IOS
2277 else if (condition == SYSTEM_PLATFORM_DARWIN_ATV2)
2278 #ifdef TARGET_DARWIN_IOS_ATV2
2283 else if (condition == SYSTEM_PLATFORM_ANDROID)
2284 #if defined(TARGET_ANDROID)
2289 else if (condition == SYSTEM_PLATFORM_LINUX_RASPBERRY_PI)
2290 #if defined(TARGET_RASPBERRY_PI)
2295 else if (condition == SYSTEM_MEDIA_DVD)
2296 bReturn = g_mediaManager.IsDiscInDrive();
2297 #ifdef HAS_DVD_DRIVE
2298 else if (condition == SYSTEM_DVDREADY)
2299 bReturn = g_mediaManager.GetDriveStatus() != DRIVE_NOT_READY;
2300 else if (condition == SYSTEM_TRAYOPEN)
2301 bReturn = g_mediaManager.GetDriveStatus() == DRIVE_OPEN;
2303 else if (condition == SYSTEM_CAN_POWERDOWN)
2304 bReturn = g_powerManager.CanPowerdown();
2305 else if (condition == SYSTEM_CAN_SUSPEND)
2306 bReturn = g_powerManager.CanSuspend();
2307 else if (condition == SYSTEM_CAN_HIBERNATE)
2308 bReturn = g_powerManager.CanHibernate();
2309 else if (condition == SYSTEM_CAN_REBOOT)
2310 bReturn = g_powerManager.CanReboot();
2311 else if (condition == SYSTEM_SCREENSAVER_ACTIVE)
2312 bReturn = g_application.IsInScreenSaver();
2314 else if (condition == PLAYER_SHOWINFO)
2315 bReturn = m_playerShowInfo;
2316 else if (condition == PLAYER_SHOWCODEC)
2317 bReturn = m_playerShowCodec;
2318 else if (condition >= MULTI_INFO_START && condition <= MULTI_INFO_END)
2320 return GetMultiInfoBool(m_multiInfo[condition - MULTI_INFO_START], contextWindow, item);
2322 else if (condition == SYSTEM_HASLOCKS)
2323 bReturn = CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE;
2324 else if (condition == SYSTEM_HAS_PVR)
2326 else if (condition == SYSTEM_ISMASTER)
2327 bReturn = CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && g_passwordManager.bMasterUser;
2328 else if (condition == SYSTEM_ISFULLSCREEN)
2329 bReturn = g_Windowing.IsFullScreen();
2330 else if (condition == SYSTEM_ISSTANDALONE)
2331 bReturn = g_application.IsStandAlone();
2332 else if (condition == SYSTEM_ISINHIBIT)
2333 bReturn = g_application.IsIdleShutdownInhibited();
2334 else if (condition == SYSTEM_HAS_SHUTDOWN)
2335 bReturn = (CSettings::Get().GetInt("powermanagement.shutdowntime") > 0);
2336 else if (condition == SYSTEM_LOGGEDON)
2337 bReturn = !(g_windowManager.GetActiveWindow() == WINDOW_LOGIN_SCREEN);
2338 else if (condition == SYSTEM_SHOW_EXIT_BUTTON)
2339 bReturn = g_advancedSettings.m_showExitButton;
2340 else if (condition == SYSTEM_HAS_LOGINSCREEN)
2341 bReturn = CProfilesManager::Get().UsingLoginScreen();
2342 else if (condition == WEATHER_IS_FETCHED)
2343 bReturn = g_weatherManager.IsFetched();
2344 else if (condition >= PVR_CONDITIONS_START && condition <= PVR_CONDITIONS_END)
2345 bReturn = g_PVRManager.TranslateBoolInfo(condition);
2347 else if (condition == SYSTEM_INTERNET_STATE)
2349 g_sysinfo.GetInfo(condition);
2350 bReturn = g_sysinfo.HasInternet();
2352 else if (condition == SKIN_HAS_VIDEO_OVERLAY)
2354 bReturn = g_windowManager.IsOverlayAllowed() && g_application.m_pPlayer->IsPlayingVideo();
2356 else if (condition == SKIN_HAS_MUSIC_OVERLAY)
2358 bReturn = g_windowManager.IsOverlayAllowed() && g_application.m_pPlayer->IsPlayingAudio();
2360 else if (condition == CONTAINER_HASFILES || condition == CONTAINER_HASFOLDERS)
2362 CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2365 const CFileItemList& items=((CGUIMediaWindow*)pWindow)->CurrentDirectory();
2366 for (int i=0;i<items.Size();++i)
2368 CFileItemPtr item=items.Get(i);
2369 if (!item->m_bIsFolder && condition == CONTAINER_HASFILES)
2374 else if (item->m_bIsFolder && !item->IsParentFolder() && condition == CONTAINER_HASFOLDERS)
2382 else if (condition == CONTAINER_STACKED)
2384 CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2386 bReturn = ((CGUIMediaWindow*)pWindow)->CurrentDirectory().GetProperty("isstacked").asBoolean();
2388 else if (condition == CONTAINER_HAS_THUMB)
2390 CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2392 bReturn = ((CGUIMediaWindow*)pWindow)->CurrentDirectory().HasArt("thumb");
2394 else if (condition == CONTAINER_HAS_NEXT || condition == CONTAINER_HAS_PREVIOUS || condition == CONTAINER_SCROLLING)
2396 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2399 const CGUIControl* control = window->GetControl(window->GetViewContainerID());
2401 bReturn = control->GetCondition(condition, 0);
2404 else if (condition == CONTAINER_CAN_FILTER)
2406 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2408 bReturn = !((CGUIMediaWindow*)window)->CanFilterAdvanced();
2410 else if (condition == CONTAINER_CAN_FILTERADVANCED)
2412 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2414 bReturn = ((CGUIMediaWindow*)window)->CanFilterAdvanced();
2416 else if (condition == CONTAINER_FILTERED)
2418 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2420 bReturn = ((CGUIMediaWindow*)window)->IsFiltered();
2422 else if (condition == VIDEOPLAYER_HAS_INFO)
2423 bReturn = ((m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->IsEmpty()) ||
2424 (m_currentFile->HasPVRChannelInfoTag() && !m_currentFile->GetPVRChannelInfoTag()->IsEmpty()));
2425 else if (condition >= CONTAINER_SCROLL_PREVIOUS && condition <= CONTAINER_SCROLL_NEXT)
2427 // no parameters, so we assume it's just requested for a media window. It therefore
2428 // can only happen if the list has focus.
2429 CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2432 map<int,int>::const_iterator it = m_containerMoves.find(pWindow->GetViewContainerID());
2433 if (it != m_containerMoves.end())
2435 if (condition > CONTAINER_STATIC) // moving up
2436 bReturn = it->second >= std::max(condition - CONTAINER_STATIC, 1);
2438 bReturn = it->second <= std::min(condition - CONTAINER_STATIC, -1);
2442 else if (condition == SLIDESHOW_ISPAUSED)
2444 CGUIWindowSlideShow *slideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
2445 bReturn = (slideShow && slideShow->IsPaused());
2447 else if (condition == SLIDESHOW_ISRANDOM)
2449 CGUIWindowSlideShow *slideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
2450 bReturn = (slideShow && slideShow->IsShuffled());
2452 else if (condition == SLIDESHOW_ISACTIVE)
2454 CGUIWindowSlideShow *slideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
2455 bReturn = (slideShow && slideShow->InSlideShow());
2457 else if (condition == SLIDESHOW_ISVIDEO)
2459 CGUIWindowSlideShow *slideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
2460 bReturn = (slideShow && slideShow->GetCurrentSlide() && slideShow->GetCurrentSlide()->IsVideo());
2462 else if (g_application.m_pPlayer->IsPlaying())
2466 case PLAYER_HAS_MEDIA:
2469 case PLAYER_HAS_AUDIO:
2470 bReturn = g_application.m_pPlayer->IsPlayingAudio();
2472 case PLAYER_HAS_VIDEO:
2473 bReturn = g_application.m_pPlayer->IsPlayingVideo();
2475 case PLAYER_PLAYING:
2476 bReturn = !g_application.m_pPlayer->IsPausedPlayback() && (g_application.m_pPlayer->GetPlaySpeed() == 1);
2479 bReturn = g_application.m_pPlayer->IsPausedPlayback();
2481 case PLAYER_REWINDING:
2482 bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() < 1;
2484 case PLAYER_FORWARDING:
2485 bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() > 1;
2487 case PLAYER_REWINDING_2x:
2488 bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == -2;
2490 case PLAYER_REWINDING_4x:
2491 bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == -4;
2493 case PLAYER_REWINDING_8x:
2494 bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == -8;
2496 case PLAYER_REWINDING_16x:
2497 bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == -16;
2499 case PLAYER_REWINDING_32x:
2500 bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == -32;
2502 case PLAYER_FORWARDING_2x:
2503 bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == 2;
2505 case PLAYER_FORWARDING_4x:
2506 bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == 4;
2508 case PLAYER_FORWARDING_8x:
2509 bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == 8;
2511 case PLAYER_FORWARDING_16x:
2512 bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == 16;
2514 case PLAYER_FORWARDING_32x:
2515 bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == 32;
2517 case PLAYER_CAN_RECORD:
2518 bReturn = g_application.m_pPlayer->CanRecord();
2520 case PLAYER_CAN_PAUSE:
2521 bReturn = g_application.m_pPlayer->CanPause();
2523 case PLAYER_CAN_SEEK:
2524 bReturn = g_application.m_pPlayer->CanSeek();
2526 case PLAYER_RECORDING:
2527 bReturn = g_application.m_pPlayer->IsRecording();
2529 case PLAYER_DISPLAY_AFTER_SEEK:
2530 bReturn = GetDisplayAfterSeek();
2532 case PLAYER_CACHING:
2533 bReturn = g_application.m_pPlayer->IsCaching();
2535 case PLAYER_SEEKBAR:
2537 CGUIDialog *seekBar = (CGUIDialog*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
2538 bReturn = seekBar ? seekBar->IsDialogRunning() : false;
2541 case PLAYER_SEEKING:
2542 bReturn = m_playerSeeking;
2544 case PLAYER_SHOWTIME:
2545 bReturn = m_playerShowTime;
2547 case PLAYER_PASSTHROUGH:
2548 bReturn = g_application.m_pPlayer->IsPassthrough();
2550 case PLAYER_ISINTERNETSTREAM:
2551 bReturn = m_currentFile && URIUtils::IsInternetStream(m_currentFile->GetPath());
2553 case MUSICPM_ENABLED:
2554 bReturn = g_partyModeManager.IsEnabled();
2556 case MUSICPLAYER_HASPREVIOUS:
2558 // requires current playlist be PLAYLIST_MUSIC
2560 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2561 bReturn = (g_playlistPlayer.GetCurrentSong() > 0); // not first song
2564 case MUSICPLAYER_HASNEXT:
2566 // requires current playlist be PLAYLIST_MUSIC
2568 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2569 bReturn = (g_playlistPlayer.GetCurrentSong() < (g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC).size() - 1)); // not last song
2572 case MUSICPLAYER_PLAYLISTPLAYING:
2575 if (g_application.m_pPlayer->IsPlayingAudio() && g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2579 case VIDEOPLAYER_USING_OVERLAYS:
2580 bReturn = (CSettings::Get().GetInt("videoplayer.rendermethod") == RENDER_OVERLAYS);
2582 case VIDEOPLAYER_ISFULLSCREEN:
2583 bReturn = g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO;
2585 case VIDEOPLAYER_HASMENU:
2586 bReturn = g_application.m_pPlayer->HasMenu();
2588 case PLAYLIST_ISRANDOM:
2589 bReturn = g_playlistPlayer.IsShuffled(g_playlistPlayer.GetCurrentPlaylist());
2591 case PLAYLIST_ISREPEAT:
2592 bReturn = g_playlistPlayer.GetRepeat(g_playlistPlayer.GetCurrentPlaylist()) == PLAYLIST::REPEAT_ALL;
2594 case PLAYLIST_ISREPEATONE:
2595 bReturn = g_playlistPlayer.GetRepeat(g_playlistPlayer.GetCurrentPlaylist()) == PLAYLIST::REPEAT_ONE;
2597 case PLAYER_HASDURATION:
2598 bReturn = g_application.GetTotalTime() > 0;
2600 case VIDEOPLAYER_HASTELETEXT:
2601 if (g_application.m_pPlayer->GetTeletextCache())
2604 case VIDEOPLAYER_HASSUBTITLES:
2605 bReturn = g_application.m_pPlayer->GetSubtitleCount() > 0;
2607 case VIDEOPLAYER_SUBTITLESENABLED:
2608 bReturn = g_application.m_pPlayer->GetSubtitleVisible();
2610 case VISUALISATION_LOCKED:
2612 CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
2613 g_windowManager.SendMessage(msg);
2614 if (msg.GetPointer())
2616 CVisualisation *pVis = (CVisualisation *)msg.GetPointer();
2617 bReturn = pVis->IsLocked();
2621 case VISUALISATION_ENABLED:
2622 bReturn = !CSettings::Get().GetString("musicplayer.visualisation").empty();
2624 case VIDEOPLAYER_HAS_EPG:
2625 if (m_currentFile->HasPVRChannelInfoTag())
2628 bReturn = m_currentFile->GetPVRChannelInfoTag()->GetEPGNow(epgTag);
2631 case VIDEOPLAYER_IS_STEREOSCOPIC:
2632 if(g_application.m_pPlayer->IsPlaying())
2635 bReturn = !m_videoInfo.stereoMode.empty();
2638 default: // default, use integer value different from 0 as true
2641 bReturn = GetInt(val, condition) && val != 0;
2650 /// \brief Examines the multi information sent and returns true or false accordingly.
2651 bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, const CGUIListItem *item)
2653 bool bReturn = false;
2654 int condition = abs(info.m_info);
2656 if (condition >= LISTITEM_START && condition <= LISTITEM_END)
2660 CGUIWindow *window = NULL;
2661 int data1 = info.GetData1();
2662 if (!data1) // No container specified, so we lookup the current view container
2664 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
2665 if (window && window->IsMediaWindow())
2666 data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
2669 if (!window) // If we don't have a window already (from lookup above), get one
2670 window = GetWindowWithCondition(contextWindow, 0);
2674 const CGUIControl *control = window->GetControl(data1);
2675 if (control && control->IsContainer())
2676 item = ((IGUIContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()).get();
2679 if (item) // If we got a valid item, do the lookup
2680 bReturn = GetItemBool(item, condition); // Image prioritizes images over labels (in the case of music item ratings for instance)
2688 bReturn = CSkinSettings::Get().GetBool(info.GetData1());
2693 if (info.GetData2())
2694 bReturn = StringUtils::EqualsNoCase(CSkinSettings::Get().GetString(info.GetData1()), m_stringParameters[info.GetData2()]);
2696 bReturn = !CSkinSettings::Get().GetString(info.GetData1()).empty();
2699 case SKIN_HAS_THEME:
2701 CStdString theme = CSettings::Get().GetString("lookandfeel.skintheme");
2702 StringUtils::ToLower(theme);
2703 URIUtils::RemoveExtension(theme);
2704 bReturn = theme.Equals(m_stringParameters[info.GetData1()]);
2707 case STRING_IS_EMPTY:
2708 // note: Get*Image() falls back to Get*Label(), so this should cover all of them
2709 if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2710 bReturn = GetItemImage((const CFileItem *)item, info.GetData1()).empty();
2712 bReturn = GetImage(info.GetData1(), contextWindow).empty();
2714 case STRING_COMPARE:
2717 if (info.GetData2() < 0) // info labels are stored with negative numbers
2719 int info2 = -info.GetData2();
2720 if (item && item->IsFileItem() && info2 >= LISTITEM_START && info2 < LISTITEM_END)
2721 compare = GetItemImage((const CFileItem *)item, info2);
2723 compare = GetImage(info2, contextWindow);
2725 else if (info.GetData2() < (int)m_stringParameters.size())
2726 { // conditional string
2727 compare = m_stringParameters[info.GetData2()];
2729 if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2730 bReturn = GetItemImage((const CFileItem *)item, info.GetData1()).Equals(compare);
2732 bReturn = GetImage(info.GetData1(), contextWindow).Equals(compare);
2735 case INTEGER_GREATER_THAN:
2738 if (GetInt(integer, info.GetData1(), contextWindow, item))
2739 bReturn = integer > info.GetData2();
2744 if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2745 value = GetItemImage((const CFileItem *)item, info.GetData1());
2747 value = GetImage(info.GetData1(), contextWindow);
2749 // Handle the case when a value contains time separator (:). This makes IntegerGreaterThan
2750 // useful for Player.Time* members without adding a separate set of members returning time in seconds
2751 if ( value.find_first_of( ':' ) != value.npos )
2752 bReturn = StringUtils::TimeStringToSeconds( value ) > info.GetData2();
2754 bReturn = atoi( value.c_str() ) > info.GetData2();
2759 case STRING_STR_LEFT:
2760 case STRING_STR_RIGHT:
2762 CStdString compare = m_stringParameters[info.GetData2()];
2763 // our compare string is already in lowercase, so lower case our label as well
2764 // as CStdString::Find() is case sensitive
2766 if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2768 label = GetItemImage((const CFileItem *)item, info.GetData1());
2769 StringUtils::ToLower(label);
2773 label = GetImage(info.GetData1(), contextWindow);
2774 StringUtils::ToLower(label);
2776 if (condition == STRING_STR_LEFT)
2777 bReturn = StringUtils::StartsWith(label, compare);
2778 else if (condition == STRING_STR_RIGHT)
2779 bReturn = StringUtils::EndsWith(label, compare);
2781 bReturn = label.find(compare) != std::string::npos;
2784 case SYSTEM_ALARM_LESS_OR_EQUAL:
2786 int time = lrint(g_alarmClock.GetRemaining(m_stringParameters[info.GetData1()]));
2787 int timeCompare = atoi(m_stringParameters[info.GetData2()]);
2789 bReturn = timeCompare >= time;
2794 case SYSTEM_IDLE_TIME:
2795 bReturn = g_application.GlobalIdleTime() >= (int)info.GetData1();
2797 case CONTROL_GROUP_HAS_FOCUS:
2799 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2801 bReturn = window->ControlGroupHasFocus(info.GetData1(), info.GetData2());
2804 case CONTROL_IS_VISIBLE:
2806 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2809 // Note: This'll only work for unique id's
2810 const CGUIControl *control = window->GetControl(info.GetData1());
2812 bReturn = control->IsVisible();
2816 case CONTROL_IS_ENABLED:
2818 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2821 // Note: This'll only work for unique id's
2822 const CGUIControl *control = window->GetControl(info.GetData1());
2824 bReturn = !control->IsDisabled();
2828 case CONTROL_HAS_FOCUS:
2830 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2832 bReturn = (window->GetFocusedControlID() == (int)info.GetData1());
2836 if (info.GetData1())
2837 bReturn = ((int)info.GetData1() == m_nextWindowID);
2840 CGUIWindow *window = g_windowManager.GetWindow(m_nextWindowID);
2841 if (window && URIUtils::GetFileName(window->GetProperty("xmlfile").asString()).Equals(m_stringParameters[info.GetData2()]))
2845 case WINDOW_PREVIOUS:
2846 if (info.GetData1())
2847 bReturn = ((int)info.GetData1() == m_prevWindowID);
2850 CGUIWindow *window = g_windowManager.GetWindow(m_prevWindowID);
2851 if (window && URIUtils::GetFileName(window->GetProperty("xmlfile").asString()).Equals(m_stringParameters[info.GetData2()]))
2855 case WINDOW_IS_VISIBLE:
2856 if (info.GetData1())
2857 bReturn = g_windowManager.IsWindowVisible(info.GetData1());
2859 bReturn = g_windowManager.IsWindowVisible(m_stringParameters[info.GetData2()]);
2861 case WINDOW_IS_TOPMOST:
2862 if (info.GetData1())
2863 bReturn = g_windowManager.IsWindowTopMost(info.GetData1());
2865 bReturn = g_windowManager.IsWindowTopMost(m_stringParameters[info.GetData2()]);
2867 case WINDOW_IS_ACTIVE:
2868 if (info.GetData1())
2869 bReturn = g_windowManager.IsWindowActive(info.GetData1());
2871 bReturn = g_windowManager.IsWindowActive(m_stringParameters[info.GetData2()]);
2873 case SYSTEM_HAS_ALARM:
2874 bReturn = g_alarmClock.HasAlarm(m_stringParameters[info.GetData1()]);
2876 case SYSTEM_GET_BOOL:
2877 bReturn = CSettings::Get().GetBool(m_stringParameters[info.GetData1()]);
2879 case SYSTEM_HAS_CORE_ID:
2880 bReturn = g_cpuInfo.HasCoreId(info.GetData1());
2882 case SYSTEM_SETTING:
2884 if ( m_stringParameters[info.GetData1()].Equals("hidewatched") )
2886 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2888 bReturn = CMediaSettings::Get().GetWatchedMode(((CGUIMediaWindow *)window)->CurrentDirectory().GetContent()) == WatchedModeUnwatched;
2892 case SYSTEM_HAS_ADDON:
2895 bReturn = CAddonMgr::Get().GetAddon(m_stringParameters[info.GetData1()],addon) && addon;
2898 case CONTAINER_SCROLL_PREVIOUS:
2899 case CONTAINER_MOVE_PREVIOUS:
2900 case CONTAINER_MOVE_NEXT:
2901 case CONTAINER_SCROLL_NEXT:
2903 map<int,int>::const_iterator it = m_containerMoves.find(info.GetData1());
2904 if (it != m_containerMoves.end())
2906 if (condition > CONTAINER_STATIC) // moving up
2907 bReturn = it->second >= std::max(condition - CONTAINER_STATIC, 1);
2909 bReturn = it->second <= std::min(condition - CONTAINER_STATIC, -1);
2913 case CONTAINER_CONTENT:
2916 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2919 if (window->GetID() == WINDOW_DIALOG_MUSIC_INFO)
2920 content = ((CGUIDialogMusicInfo *)window)->CurrentDirectory().GetContent();
2921 else if (window->GetID() == WINDOW_DIALOG_VIDEO_INFO)
2922 content = ((CGUIDialogVideoInfo *)window)->CurrentDirectory().GetContent();
2924 if (content.empty())
2926 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2928 content = ((CGUIMediaWindow *)window)->CurrentDirectory().GetContent();
2930 bReturn = m_stringParameters[info.GetData2()].Equals(content);
2934 case CONTAINER_COLUMN:
2935 case CONTAINER_POSITION:
2936 case CONTAINER_HAS_NEXT:
2937 case CONTAINER_HAS_PREVIOUS:
2938 case CONTAINER_SCROLLING:
2939 case CONTAINER_SUBITEM:
2941 const CGUIControl *control = NULL;
2942 if (info.GetData1())
2943 { // container specified
2944 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2946 control = window->GetControl(info.GetData1());
2949 { // no container specified - assume a mediawindow
2950 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2952 control = window->GetControl(window->GetViewContainerID());
2955 bReturn = control->GetCondition(condition, info.GetData2());
2958 case CONTAINER_HAS_FOCUS:
2959 { // grab our container
2960 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2963 const CGUIControl *control = window->GetControl(info.GetData1());
2964 if (control && control->IsContainer())
2966 CFileItemPtr item = boost::static_pointer_cast<CFileItem>(((IGUIContainer *)control)->GetListItem(0));
2967 if (item && item->m_iprogramCount == info.GetData2()) // programcount used to store item id
2973 case VIDEOPLAYER_CONTENT:
2975 CStdString strContent="movies";
2976 if (!m_currentFile->HasVideoInfoTag() || m_currentFile->GetVideoInfoTag()->IsEmpty())
2977 strContent = "files";
2978 if (m_currentFile->HasVideoInfoTag() && m_currentFile->GetVideoInfoTag()->m_iSeason > -1) // episode
2979 strContent = "episodes";
2980 if (m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->m_artist.empty())
2981 strContent = "musicvideos";
2982 if (m_currentFile->HasVideoInfoTag() && m_currentFile->GetVideoInfoTag()->m_strStatus == "livetv")
2983 strContent = "livetv";
2984 if (m_currentFile->HasPVRChannelInfoTag())
2985 strContent = "livetv";
2986 bReturn = m_stringParameters[info.GetData1()].Equals(strContent);
2989 case CONTAINER_SORT_METHOD:
2991 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2994 const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
2996 bReturn = ((unsigned int)viewState->GetSortMethod().sortBy == info.GetData1());
3000 case CONTAINER_SORT_DIRECTION:
3002 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
3005 const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
3007 bReturn = ((unsigned int)viewState->GetDisplaySortOrder() == info.GetData1());
3013 if (info.GetData2() == -1) // info doesn't contain valid startDate
3015 CDateTime date = CDateTime::GetCurrentDateTime();
3016 int currentDate = date.GetMonth()*100+date.GetDay();
3017 int startDate = info.GetData1();
3018 int stopDate = info.GetData2();
3020 if (stopDate < startDate)
3021 bReturn = currentDate >= startDate || currentDate < stopDate;
3023 bReturn = currentDate >= startDate && currentDate < stopDate;
3028 CDateTime time=CDateTime::GetCurrentDateTime();
3029 int currentTime = time.GetMinuteOfDay();
3030 int startTime = info.GetData1();
3031 int stopTime = info.GetData2();
3033 if (stopTime < startTime)
3034 bReturn = currentTime >= startTime || currentTime < stopTime;
3036 bReturn = currentTime >= startTime && currentTime < stopTime;
3039 case MUSICPLAYER_EXISTS:
3041 int index = info.GetData2();
3042 if (info.GetData1() == 1)
3044 if (g_playlistPlayer.GetCurrentPlaylist() != PLAYLIST_MUSIC)
3049 index += g_playlistPlayer.GetCurrentSong();
3051 bReturn = (index >= 0 && index < g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC).size());
3055 case PLAYLIST_ISRANDOM:
3057 int playlistid = info.GetData1();
3058 if (playlistid > PLAYLIST_NONE)
3059 bReturn = g_playlistPlayer.IsShuffled(playlistid);
3063 case PLAYLIST_ISREPEAT:
3065 int playlistid = info.GetData1();
3066 if (playlistid > PLAYLIST_NONE)
3067 bReturn = g_playlistPlayer.GetRepeat(playlistid) == PLAYLIST::REPEAT_ALL;
3071 case PLAYLIST_ISREPEATONE:
3073 int playlistid = info.GetData1();
3074 if (playlistid > PLAYLIST_NONE)
3075 bReturn = g_playlistPlayer.GetRepeat(playlistid) == PLAYLIST::REPEAT_ONE;
3080 return (info.m_info < 0) ? !bReturn : bReturn;
3083 bool CGUIInfoManager::GetMultiInfoInt(int &value, const GUIInfo &info, int contextWindow) const
3085 if (info.m_info >= LISTITEM_START && info.m_info <= LISTITEM_END)
3088 CGUIWindow *window = NULL;
3090 int data1 = info.GetData1();
3091 if (!data1) // No container specified, so we lookup the current view container
3093 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
3094 if (window && window->IsMediaWindow())
3095 data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
3098 if (!window) // If we don't have a window already (from lookup above), get one
3099 window = GetWindowWithCondition(contextWindow, 0);
3103 const CGUIControl *control = window->GetControl(data1);
3104 if (control && control->IsContainer())
3105 item = boost::static_pointer_cast<CFileItem>(((IGUIContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()));
3108 if (item) // If we got a valid item, do the lookup
3109 return GetItemInt(value, item.get(), info.m_info);
3115 /// \brief Examines the multi information sent and returns the string as appropriate
3116 CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWindow, CStdString *fallback)
3118 if (info.m_info == SKIN_STRING)
3120 return CSkinSettings::Get().GetString(info.GetData1());
3122 else if (info.m_info == SKIN_BOOL)
3124 bool bInfo = CSkinSettings::Get().GetBool(info.GetData1());
3126 return g_localizeStrings.Get(20122);
3128 if (info.m_info >= LISTITEM_START && info.m_info <= LISTITEM_END)
3131 CGUIWindow *window = NULL;
3133 int data1 = info.GetData1();
3134 if (!data1) // No container specified, so we lookup the current view container
3136 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
3137 if (window && window->IsMediaWindow())
3138 data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
3141 if (!window) // If we don't have a window already (from lookup above), get one
3142 window = GetWindowWithCondition(contextWindow, 0);
3146 const CGUIControl *control = window->GetControl(data1);
3147 if (control && control->IsContainer())
3148 item = boost::static_pointer_cast<CFileItem>(((IGUIContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()));
3151 if (item) // If we got a valid item, do the lookup
3152 return GetItemImage(item.get(), info.m_info, fallback); // Image prioritizes images over labels (in the case of music item ratings for instance)
3154 else if (info.m_info == PLAYER_TIME)
3156 return GetCurrentPlayTime((TIME_FORMAT)info.GetData1());
3158 else if (info.m_info == PLAYER_TIME_REMAINING)
3160 return GetCurrentPlayTimeRemaining((TIME_FORMAT)info.GetData1());
3162 else if (info.m_info == PLAYER_FINISH_TIME)
3165 CEpgInfoTag currentTag;
3166 if (GetEpgInfoTag(currentTag))
3167 time = currentTag.EndAsLocalTime();
3170 time = CDateTime::GetCurrentDateTime();
3171 time += CDateTimeSpan(0, 0, 0, GetPlayTimeRemaining());
3173 return LocalizeTime(time, (TIME_FORMAT)info.GetData1());
3175 else if (info.m_info == PLAYER_START_TIME)
3178 CEpgInfoTag currentTag;
3179 if (GetEpgInfoTag(currentTag))
3180 time = currentTag.StartAsLocalTime();
3183 time = CDateTime::GetCurrentDateTime();
3184 time -= CDateTimeSpan(0, 0, 0, (int)GetPlayTime());
3186 return LocalizeTime(time, (TIME_FORMAT)info.GetData1());
3188 else if (info.m_info == PLAYER_TIME_SPEED)
3191 if (g_application.m_pPlayer->GetPlaySpeed() != 1)
3192 strTime = StringUtils::Format("%s (%ix)", GetCurrentPlayTime((TIME_FORMAT)info.GetData1()).c_str(), g_application.m_pPlayer->GetPlaySpeed());
3194 strTime = GetCurrentPlayTime();
3197 else if (info.m_info == PLAYER_DURATION)
3199 return GetDuration((TIME_FORMAT)info.GetData1());
3201 else if (info.m_info == PLAYER_SEEKTIME)
3203 return GetCurrentSeekTime((TIME_FORMAT)info.GetData1());
3205 else if (info.m_info == PLAYER_SEEKOFFSET)
3207 CStdString seekOffset = StringUtils::SecondsToTimeString(abs(m_seekOffset), (TIME_FORMAT)info.GetData1());
3208 if (m_seekOffset < 0)
3209 return "-" + seekOffset;
3210 if (m_seekOffset > 0)
3211 return "+" + seekOffset;
3213 else if (info.m_info == PLAYER_ITEM_ART)
3215 return m_currentFile->GetArt(m_stringParameters[info.GetData1()]);
3217 else if (info.m_info == SYSTEM_TIME)
3219 return GetTime((TIME_FORMAT)info.GetData1());
3221 else if (info.m_info == SYSTEM_DATE)
3223 CDateTime time=CDateTime::GetCurrentDateTime();
3224 return time.GetAsLocalizedDate(m_stringParameters[info.GetData1()],false);
3226 else if (info.m_info == CONTAINER_NUM_PAGES || info.m_info == CONTAINER_CURRENT_PAGE ||
3227 info.m_info == CONTAINER_NUM_ITEMS || info.m_info == CONTAINER_POSITION)
3229 const CGUIControl *control = NULL;
3230 if (info.GetData1())
3231 { // container specified
3232 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
3234 control = window->GetControl(info.GetData1());
3237 { // no container specified - assume a mediawindow
3238 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
3240 control = window->GetControl(window->GetViewContainerID());
3244 if (control->IsContainer())
3245 return ((IGUIContainer *)control)->GetLabel(info.m_info);
3246 else if (control->GetControlType() == CGUIControl::GUICONTROL_TEXTBOX)
3247 return ((CGUITextBox *)control)->GetLabel(info.m_info);
3250 else if (info.m_info == SYSTEM_GET_CORE_USAGE)
3252 CStdString strCpu = StringUtils::Format("%4.2f", g_cpuInfo.GetCoreInfo(atoi(m_stringParameters[info.GetData1()].c_str())).m_fPct);
3255 else if (info.m_info >= MUSICPLAYER_TITLE && info.m_info <= MUSICPLAYER_ALBUM_ARTIST)
3256 return GetMusicPlaylistInfo(info);
3257 else if (info.m_info == CONTAINER_PROPERTY)
3259 CGUIWindow *window = NULL;
3260 if (info.GetData1())
3261 { // container specified
3262 window = GetWindowWithCondition(contextWindow, 0);
3265 { // no container specified - assume a mediawindow
3266 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
3269 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty(m_stringParameters[info.GetData2()]).asString();
3271 else if (info.m_info == CONTROL_GET_LABEL)
3273 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
3276 const CGUIControl *control = window->GetControl(info.GetData1());
3278 return control->GetDescription();
3281 else if (info.m_info == WINDOW_PROPERTY)
3283 CGUIWindow *window = NULL;
3284 if (info.GetData1())
3285 { // window specified
3286 window = g_windowManager.GetWindow(info.GetData1());//GetWindowWithCondition(contextWindow, 0);
3289 { // no window specified - assume active
3290 window = GetWindowWithCondition(contextWindow, 0);
3294 return window->GetProperty(m_stringParameters[info.GetData2()]).asString();
3296 else if (info.m_info == SYSTEM_ADDON_TITLE ||
3297 info.m_info == SYSTEM_ADDON_ICON ||
3298 info.m_info == SYSTEM_ADDON_VERSION)
3300 // This logic does not check/care whether an addon has been disabled/marked as broken,
3301 // it simply retrieves it's name or icon that means if an addon is placed on the home screen it
3302 // will stay there even if it's disabled/marked as broken. This might need to be changed/fixed
3305 if (info.GetData2() == 0)
3306 CAddonMgr::Get().GetAddon(const_cast<CGUIInfoManager*>(this)->GetLabel(info.GetData1(), contextWindow),addon,ADDON_UNKNOWN,false);
3308 CAddonMgr::Get().GetAddon(m_stringParameters[info.GetData1()],addon,ADDON_UNKNOWN,false);
3309 if (addon && info.m_info == SYSTEM_ADDON_TITLE)
3310 return addon->Name();
3311 if (addon && info.m_info == SYSTEM_ADDON_ICON)
3312 return addon->Icon();
3313 if (addon && info.m_info == SYSTEM_ADDON_VERSION)
3314 return addon->Version().c_str();
3316 else if (info.m_info == PLAYLIST_LENGTH ||
3317 info.m_info == PLAYLIST_POSITION ||
3318 info.m_info == PLAYLIST_RANDOM ||
3319 info.m_info == PLAYLIST_REPEAT)
3321 int playlistid = info.GetData1();
3322 if (playlistid > PLAYLIST_NONE)
3323 return GetPlaylistLabel(info.m_info, playlistid);
3326 return StringUtils::EmptyString;
3329 /// \brief Obtains the filename of the image to show from whichever subsystem is needed
3330 CStdString CGUIInfoManager::GetImage(int info, int contextWindow, CStdString *fallback)
3332 if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
3333 return GetSkinVariableString(info, true);
3335 if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
3337 return GetMultiInfoLabel(m_multiInfo[info - MULTI_INFO_START], contextWindow, fallback);
3339 else if (info == WEATHER_CONDITIONS)
3340 return g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON);
3341 else if (info == SYSTEM_PROFILETHUMB)
3343 CStdString thumb = CProfilesManager::Get().GetCurrentProfile().getThumb();
3345 thumb = "unknown-user.png";
3348 else if (info == MUSICPLAYER_COVER)
3350 if (!g_application.m_pPlayer->IsPlayingAudio()) return "";
3352 *fallback = "DefaultAlbumCover.png";
3353 return m_currentFile->HasArt("thumb") ? m_currentFile->GetArt("thumb") : "DefaultAlbumCover.png";
3355 else if (info == MUSICPLAYER_RATING)
3357 if (!g_application.m_pPlayer->IsPlayingAudio()) return "";
3358 return GetItemImage(m_currentFile, LISTITEM_RATING);
3360 else if (info == PLAYER_STAR_RATING)
3362 if (!g_application.m_pPlayer->IsPlaying()) return "";
3363 return GetItemImage(m_currentFile, LISTITEM_STAR_RATING);
3365 else if (info == VIDEOPLAYER_COVER)
3367 if (!g_application.m_pPlayer->IsPlayingVideo()) return "";
3369 *fallback = "DefaultVideoCover.png";
3370 if(m_currentMovieThumb.empty())
3371 return m_currentFile->HasArt("thumb") ? m_currentFile->GetArt("thumb") : "DefaultVideoCover.png";
3372 else return m_currentMovieThumb;
3374 else if (info == CONTAINER_FOLDERTHUMB)
3376 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
3378 return GetItemImage(&const_cast<CFileItemList&>(((CGUIMediaWindow*)window)->CurrentDirectory()), LISTITEM_THUMB, fallback);
3380 else if (info == CONTAINER_TVSHOWTHUMB)
3382 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
3384 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetArt("tvshow.thumb");
3386 else if (info == CONTAINER_SEASONTHUMB)
3388 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
3390 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetArt("season.thumb");
3392 else if (info == LISTITEM_THUMB || info == LISTITEM_ICON || info == LISTITEM_ACTUAL_ICON ||
3393 info == LISTITEM_OVERLAY || info == LISTITEM_RATING || info == LISTITEM_STAR_RATING)
3395 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
3398 CFileItemPtr item = window->GetCurrentListItem();
3400 return GetItemImage(item.get(), info, fallback);
3403 return GetLabel(info, contextWindow, fallback);
3406 CStdString CGUIInfoManager::GetDate(bool bNumbersOnly)
3408 CDateTime time=CDateTime::GetCurrentDateTime();
3409 return time.GetAsLocalizedDate(!bNumbersOnly);
3412 CStdString CGUIInfoManager::GetTime(TIME_FORMAT format) const
3414 CDateTime time=CDateTime::GetCurrentDateTime();
3415 return LocalizeTime(time, format);
3418 CStdString CGUIInfoManager::LocalizeTime(const CDateTime &time, TIME_FORMAT format) const
3420 const CStdString timeFormat = g_langInfo.GetTimeFormat();
3421 bool use12hourclock = timeFormat.find('h') != std::string::npos;
3424 case TIME_FORMAT_GUESS:
3425 return time.GetAsLocalizedTime("", false);
3426 case TIME_FORMAT_SS:
3427 return time.GetAsLocalizedTime("ss", true);
3428 case TIME_FORMAT_MM:
3429 return time.GetAsLocalizedTime("mm", true);
3430 case TIME_FORMAT_MM_SS:
3431 return time.GetAsLocalizedTime("mm:ss", true);
3432 case TIME_FORMAT_HH: // this forces it to a 12 hour clock
3433 return time.GetAsLocalizedTime(use12hourclock ? "h" : "HH", false);
3434 case TIME_FORMAT_HH_MM:
3435 return time.GetAsLocalizedTime(use12hourclock ? "h:mm" : "HH:mm", false);
3436 case TIME_FORMAT_HH_MM_XX:
3437 return time.GetAsLocalizedTime(use12hourclock ? "h:mm xx" : "HH:mm", false);
3438 case TIME_FORMAT_HH_MM_SS:
3439 return time.GetAsLocalizedTime(use12hourclock ? "hh:mm:ss" : "HH:mm:ss", true);
3440 case TIME_FORMAT_HH_MM_SS_XX:
3441 return time.GetAsLocalizedTime(use12hourclock ? "hh:mm:ss xx" : "HH:mm:ss", true);
3443 return time.GetAsLocalizedTime("h", false);
3444 case TIME_FORMAT_H_MM_SS:
3445 return time.GetAsLocalizedTime("h:mm:ss", true);
3446 case TIME_FORMAT_H_MM_SS_XX:
3447 return time.GetAsLocalizedTime("h:mm:ss xx", true);
3448 case TIME_FORMAT_XX:
3449 return use12hourclock ? time.GetAsLocalizedTime("xx", false) : "";
3453 return time.GetAsLocalizedTime("", false);
3456 CStdString CGUIInfoManager::GetDuration(TIME_FORMAT format) const
3458 if (g_application.m_pPlayer->IsPlayingAudio() && m_currentFile->HasMusicInfoTag())
3460 const CMusicInfoTag& tag = *m_currentFile->GetMusicInfoTag();
3461 if (tag.GetDuration() > 0)
3462 return StringUtils::SecondsToTimeString(tag.GetDuration(), format);
3464 if (g_application.m_pPlayer->IsPlayingVideo() && !m_currentMovieDuration.empty())
3465 return m_currentMovieDuration; // for tuxbox
3466 unsigned int iTotal = (unsigned int)g_application.GetTotalTime();
3468 return StringUtils::SecondsToTimeString(iTotal, format);
3472 CStdString CGUIInfoManager::GetMusicPartyModeLabel(int item)
3475 if (item >= MUSICPM_SONGSPLAYED && item <= MUSICPM_RANDOMSONGSPICKED)
3480 case MUSICPM_SONGSPLAYED:
3482 iSongs = g_partyModeManager.GetSongsPlayed();
3485 case MUSICPM_MATCHINGSONGS:
3487 iSongs = g_partyModeManager.GetMatchingSongs();
3490 case MUSICPM_MATCHINGSONGSPICKED:
3492 iSongs = g_partyModeManager.GetMatchingSongsPicked();
3495 case MUSICPM_MATCHINGSONGSLEFT:
3497 iSongs = g_partyModeManager.GetMatchingSongsLeft();
3500 case MUSICPM_RELAXEDSONGSPICKED:
3502 iSongs = g_partyModeManager.GetRelaxedSongs();
3505 case MUSICPM_RANDOMSONGSPICKED:
3507 iSongs = g_partyModeManager.GetRandomSongs();
3513 CStdString strLabel = StringUtils::Format("%i", iSongs);
3519 const CStdString CGUIInfoManager::GetMusicPlaylistInfo(const GUIInfo& info)
3521 PLAYLIST::CPlayList& playlist = g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC);
3522 if (playlist.size() < 1)
3524 int index = info.GetData2();
3525 if (info.GetData1() == 1)
3526 { // relative index (requires current playlist is PLAYLIST_MUSIC)
3527 if (g_playlistPlayer.GetCurrentPlaylist() != PLAYLIST_MUSIC)
3529 index = g_playlistPlayer.GetNextSong(index);
3531 if (index < 0 || index >= playlist.size())
3533 CFileItemPtr playlistItem = playlist[index];
3534 if (!playlistItem->GetMusicInfoTag()->Loaded())
3536 playlistItem->LoadMusicTag();
3537 playlistItem->GetMusicInfoTag()->SetLoaded();
3539 // try to set a thumbnail
3540 if (!playlistItem->HasArt("thumb"))
3542 CMusicThumbLoader loader;
3543 loader.LoadItem(playlistItem.get());
3544 // still no thumb? then just the set the default cover
3545 if (!playlistItem->HasArt("thumb"))
3546 playlistItem->SetArt("thumb", "DefaultAlbumCover.png");
3548 if (info.m_info == MUSICPLAYER_PLAYLISTPOS)
3550 CStdString strPosition = StringUtils::Format("%i", index + 1);
3553 else if (info.m_info == MUSICPLAYER_COVER)
3554 return playlistItem->GetArt("thumb");
3555 return GetMusicTagLabel(info.m_info, playlistItem.get());
3558 CStdString CGUIInfoManager::GetPlaylistLabel(int item, int playlistid /* = PLAYLIST_NONE */) const
3560 if (playlistid <= PLAYLIST_NONE && !g_application.m_pPlayer->IsPlaying())
3563 int iPlaylist = playlistid == PLAYLIST_NONE ? g_playlistPlayer.GetCurrentPlaylist() : playlistid;
3566 case PLAYLIST_LENGTH:
3568 return StringUtils::Format("%i", g_playlistPlayer.GetPlaylist(iPlaylist).size());;
3570 case PLAYLIST_POSITION:
3572 return StringUtils::Format("%i", g_playlistPlayer.GetCurrentSong() + 1);
3574 case PLAYLIST_RANDOM:
3576 if (g_playlistPlayer.IsShuffled(iPlaylist))
3577 return g_localizeStrings.Get(590); // 590: Random
3579 return g_localizeStrings.Get(591); // 591: Off
3581 case PLAYLIST_REPEAT:
3583 PLAYLIST::REPEAT_STATE state = g_playlistPlayer.GetRepeat(iPlaylist);
3584 if (state == PLAYLIST::REPEAT_ONE)
3585 return g_localizeStrings.Get(592); // 592: One
3586 else if (state == PLAYLIST::REPEAT_ALL)
3587 return g_localizeStrings.Get(593); // 593: All
3589 return g_localizeStrings.Get(594); // 594: Off
3595 CStdString CGUIInfoManager::GetMusicLabel(int item)
3597 if (!g_application.m_pPlayer->IsPlaying() || !m_currentFile->HasMusicInfoTag()) return "";
3602 case MUSICPLAYER_PLAYLISTLEN:
3604 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
3605 return GetPlaylistLabel(PLAYLIST_LENGTH);
3608 case MUSICPLAYER_PLAYLISTPOS:
3610 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
3611 return GetPlaylistLabel(PLAYLIST_POSITION);
3614 case MUSICPLAYER_BITRATE:
3616 CStdString strBitrate = "";
3617 if (m_audioInfo.bitrate > 0)
3618 strBitrate = StringUtils::Format("%i", MathUtils::round_int((double)m_audioInfo.bitrate / 1000.0));
3622 case MUSICPLAYER_CHANNELS:
3624 CStdString strChannels = "";
3625 if (m_audioInfo.channels > 0)
3627 strChannels = StringUtils::Format("%i", m_audioInfo.channels);
3632 case MUSICPLAYER_BITSPERSAMPLE:
3634 CStdString strBitsPerSample = "";
3635 if (m_audioInfo.bitspersample > 0)
3636 strBitsPerSample = StringUtils::Format("%i", m_audioInfo.bitspersample);
3637 return strBitsPerSample;
3640 case MUSICPLAYER_SAMPLERATE:
3642 CStdString strSampleRate = "";
3643 if (m_audioInfo.samplerate > 0)
3644 strSampleRate = StringUtils::Format("%.5g", ((double)m_audioInfo.samplerate / 1000.0));
3645 return strSampleRate;
3648 case MUSICPLAYER_CODEC:
3650 return StringUtils::Format("%s", m_audioInfo.audioCodecName.c_str());
3653 case MUSICPLAYER_LYRICS:
3654 return GetItemLabel(m_currentFile, AddListItemProp("lyrics"));
3656 return GetMusicTagLabel(item, m_currentFile);
3659 CStdString CGUIInfoManager::GetMusicTagLabel(int info, const CFileItem *item)
3661 if (!item->HasMusicInfoTag()) return "";
3662 const CMusicInfoTag &tag = *item->GetMusicInfoTag();
3665 case MUSICPLAYER_TITLE:
3666 if (tag.GetTitle().size()) { return tag.GetTitle(); }
3668 case MUSICPLAYER_ALBUM:
3669 if (tag.GetAlbum().size()) { return tag.GetAlbum(); }
3671 case MUSICPLAYER_ARTIST:
3672 if (tag.GetArtist().size()) { return StringUtils::Join(tag.GetArtist(), g_advancedSettings.m_musicItemSeparator); }
3674 case MUSICPLAYER_ALBUM_ARTIST:
3675 if (tag.GetAlbumArtist().size()) { return StringUtils::Join(tag.GetAlbumArtist(), g_advancedSettings.m_musicItemSeparator); }
3677 case MUSICPLAYER_YEAR:
3678 if (tag.GetYear()) { return tag.GetYearString(); }
3680 case MUSICPLAYER_GENRE:
3681 if (tag.GetGenre().size()) { return StringUtils::Join(tag.GetGenre(), g_advancedSettings.m_musicItemSeparator); }
3683 case MUSICPLAYER_LYRICS:
3684 if (tag.GetLyrics().size()) { return tag.GetLyrics(); }
3686 case MUSICPLAYER_TRACK_NUMBER:
3688 CStdString strTrack;
3689 if (tag.Loaded() && tag.GetTrackNumber() > 0)
3691 return StringUtils::Format("%02i", tag.GetTrackNumber());
3695 case MUSICPLAYER_DISC_NUMBER:
3696 return GetItemLabel(item, LISTITEM_DISC_NUMBER);
3697 case MUSICPLAYER_RATING:
3698 return GetItemLabel(item, LISTITEM_RATING);
3699 case MUSICPLAYER_COMMENT:
3700 return GetItemLabel(item, LISTITEM_COMMENT);
3701 case MUSICPLAYER_DURATION:
3702 return GetItemLabel(item, LISTITEM_DURATION);
3703 case MUSICPLAYER_CHANNEL_NAME:
3705 CPVRChannel* channeltag = m_currentFile->GetPVRChannelInfoTag();
3707 return channeltag->ChannelName();
3710 case MUSICPLAYER_CHANNEL_NUMBER:
3712 CPVRChannel* channeltag = m_currentFile->GetPVRChannelInfoTag();
3715 return StringUtils::Format("%i", channeltag->ChannelNumber());
3719 case MUSICPLAYER_CHANNEL_GROUP:
3721 CPVRChannel* channeltag = m_currentFile->GetPVRChannelInfoTag();
3722 if (channeltag && channeltag->IsRadio())
3723 return g_PVRManager.GetPlayingGroup(true)->GroupName();
3726 case MUSICPLAYER_PLAYCOUNT:
3727 return GetItemLabel(item, LISTITEM_PLAYCOUNT);
3728 case MUSICPLAYER_LASTPLAYED:
3729 return GetItemLabel(item, LISTITEM_LASTPLAYED);
3734 CStdString CGUIInfoManager::GetVideoLabel(int item)
3736 if (!g_application.m_pPlayer->IsPlaying())
3739 if (item == VIDEOPLAYER_TITLE)
3741 if(g_application.m_pPlayer->IsPlayingVideo())
3742 return GetLabel(PLAYER_TITLE);
3744 else if (item == VIDEOPLAYER_PLAYLISTLEN)
3746 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_VIDEO)
3747 return GetPlaylistLabel(PLAYLIST_LENGTH);
3749 else if (item == VIDEOPLAYER_PLAYLISTPOS)
3751 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_VIDEO)
3752 return GetPlaylistLabel(PLAYLIST_POSITION);
3754 else if (m_currentFile->HasPVRChannelInfoTag())
3756 CPVRChannel* tag = m_currentFile->GetPVRChannelInfoTag();
3761 /* Now playing infos */
3762 case VIDEOPLAYER_ORIGINALTITLE:
3763 return tag->GetEPGNow(epgTag) ?
3765 CSettings::Get().GetBool("epg.hidenoinfoavailable") ?
3766 StringUtils::EmptyString :
3767 g_localizeStrings.Get(19055); // no information available
3768 case VIDEOPLAYER_GENRE:
3769 return tag->GetEPGNow(epgTag) ? StringUtils::Join(epgTag.Genre(), g_advancedSettings.m_videoItemSeparator) : StringUtils::EmptyString;
3770 case VIDEOPLAYER_PLOT:
3771 return tag->GetEPGNow(epgTag) ? epgTag.Plot() : StringUtils::EmptyString;
3772 case VIDEOPLAYER_PLOT_OUTLINE:
3773 return tag->GetEPGNow(epgTag) ? epgTag.PlotOutline() : StringUtils::EmptyString;
3774 case VIDEOPLAYER_STARTTIME:
3775 return tag->GetEPGNow(epgTag) ? epgTag.StartAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
3776 case VIDEOPLAYER_ENDTIME:
3777 return tag->GetEPGNow(epgTag) ? epgTag.EndAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
3779 /* Next playing infos */
3780 case VIDEOPLAYER_NEXT_TITLE:
3781 return tag->GetEPGNext(epgTag) ?
3783 CSettings::Get().GetBool("epg.hidenoinfoavailable") ?
3784 StringUtils::EmptyString :
3785 g_localizeStrings.Get(19055); // no information available
3786 case VIDEOPLAYER_NEXT_GENRE:
3787 return tag->GetEPGNext(epgTag) ? StringUtils::Join(epgTag.Genre(), g_advancedSettings.m_videoItemSeparator) : StringUtils::EmptyString;
3788 case VIDEOPLAYER_NEXT_PLOT:
3789 return tag->GetEPGNext(epgTag) ? epgTag.Plot() : StringUtils::EmptyString;
3790 case VIDEOPLAYER_NEXT_PLOT_OUTLINE:
3791 return tag->GetEPGNext(epgTag) ? epgTag.PlotOutline() : StringUtils::EmptyString;
3792 case VIDEOPLAYER_NEXT_STARTTIME:
3793 return tag->GetEPGNext(epgTag) ? epgTag.StartAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
3794 case VIDEOPLAYER_NEXT_ENDTIME:
3795 return tag->GetEPGNext(epgTag) ? epgTag.EndAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
3796 case VIDEOPLAYER_NEXT_DURATION:
3798 CStdString duration;
3799 if (tag->GetEPGNext(epgTag) && epgTag.GetDuration() > 0)
3800 duration = StringUtils::SecondsToTimeString(epgTag.GetDuration());
3804 case VIDEOPLAYER_PARENTAL_RATING:
3807 if (tag->GetEPGNow(epgTag) && epgTag.ParentalRating() > 0)
3808 rating = StringUtils::Format("%i", epgTag.ParentalRating());
3813 /* General channel infos */
3814 case VIDEOPLAYER_CHANNEL_NAME:
3815 return tag->ChannelName();
3816 case VIDEOPLAYER_CHANNEL_NUMBER:
3818 return StringUtils::Format("%i", tag->ChannelNumber());;
3820 case VIDEOPLAYER_CHANNEL_GROUP:
3822 if (tag && !tag->IsRadio())
3823 return g_PVRManager.GetPlayingGroup(false)->GroupName();
3827 else if (m_currentFile->HasVideoInfoTag())
3831 case VIDEOPLAYER_ORIGINALTITLE:
3832 return m_currentFile->GetVideoInfoTag()->m_strOriginalTitle;
3834 case VIDEOPLAYER_GENRE:
3835 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_genre, g_advancedSettings.m_videoItemSeparator);
3837 case VIDEOPLAYER_DIRECTOR:
3838 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_director, g_advancedSettings.m_videoItemSeparator);
3840 case VIDEOPLAYER_RATING:
3842 CStdString strRating;
3843 if (m_currentFile->GetVideoInfoTag()->m_fRating > 0.f)
3844 strRating = StringUtils::Format("%.1f", m_currentFile->GetVideoInfoTag()->m_fRating);
3848 case VIDEOPLAYER_RATING_AND_VOTES:
3850 CStdString strRatingAndVotes;
3851 if (m_currentFile->GetVideoInfoTag()->m_fRating > 0.f)
3853 if (m_currentFile->GetVideoInfoTag()->m_strVotes.empty())
3854 strRatingAndVotes = StringUtils::Format("%.1f",
3855 m_currentFile->GetVideoInfoTag()->m_fRating);
3857 strRatingAndVotes = StringUtils::Format("%.1f (%s %s)",
3858 m_currentFile->GetVideoInfoTag()->m_fRating,
3859 m_currentFile->GetVideoInfoTag()->m_strVotes.c_str(),
3860 g_localizeStrings.Get(20350).c_str());
3862 return strRatingAndVotes;
3865 case VIDEOPLAYER_VOTES:
3866 return m_currentFile->GetVideoInfoTag()->m_strVotes;
3867 case VIDEOPLAYER_YEAR:
3870 if (m_currentFile->GetVideoInfoTag()->m_iYear > 0)
3871 strYear = StringUtils::Format("%i", m_currentFile->GetVideoInfoTag()->m_iYear);
3875 case VIDEOPLAYER_PREMIERED:
3878 if (m_currentFile->GetVideoInfoTag()->m_firstAired.IsValid())
3879 dateTime = m_currentFile->GetVideoInfoTag()->m_firstAired;
3880 else if (m_currentFile->GetVideoInfoTag()->m_premiered.IsValid())
3881 dateTime = m_currentFile->GetVideoInfoTag()->m_premiered;
3883 if (dateTime.IsValid())
3884 return dateTime.GetAsLocalizedDate();
3888 case VIDEOPLAYER_PLOT:
3889 return m_currentFile->GetVideoInfoTag()->m_strPlot;
3890 case VIDEOPLAYER_TRAILER:
3891 return m_currentFile->GetVideoInfoTag()->m_strTrailer;
3892 case VIDEOPLAYER_PLOT_OUTLINE:
3893 return m_currentFile->GetVideoInfoTag()->m_strPlotOutline;
3894 case VIDEOPLAYER_EPISODE:
3895 if (m_currentFile->GetVideoInfoTag()->m_iEpisode > 0)
3897 CStdString strEpisode;
3898 if (m_currentFile->GetVideoInfoTag()->m_iSeason == 0) // prefix episode with 'S'
3899 strEpisode = StringUtils::Format("S%i", m_currentFile->GetVideoInfoTag()->m_iEpisode);
3901 strEpisode = StringUtils::Format("%i", m_currentFile->GetVideoInfoTag()->m_iEpisode);
3905 case VIDEOPLAYER_SEASON:
3906 if (m_currentFile->GetVideoInfoTag()->m_iSeason > 0)
3908 return StringUtils::Format("%i", m_currentFile->GetVideoInfoTag()->m_iSeason);
3911 case VIDEOPLAYER_TVSHOW:
3912 return m_currentFile->GetVideoInfoTag()->m_strShowTitle;
3914 case VIDEOPLAYER_STUDIO:
3915 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_studio, g_advancedSettings.m_videoItemSeparator);
3916 case VIDEOPLAYER_COUNTRY:
3917 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_country, g_advancedSettings.m_videoItemSeparator);
3918 case VIDEOPLAYER_MPAA:
3919 return m_currentFile->GetVideoInfoTag()->m_strMPAARating;
3920 case VIDEOPLAYER_TOP250:
3922 CStdString strTop250;
3923 if (m_currentFile->GetVideoInfoTag()->m_iTop250 > 0)
3924 strTop250 = StringUtils::Format("%i", m_currentFile->GetVideoInfoTag()->m_iTop250);
3928 case VIDEOPLAYER_CAST:
3929 return m_currentFile->GetVideoInfoTag()->GetCast();
3930 case VIDEOPLAYER_CAST_AND_ROLE:
3931 return m_currentFile->GetVideoInfoTag()->GetCast(true);
3932 case VIDEOPLAYER_ARTIST:
3933 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator);
3934 case VIDEOPLAYER_ALBUM:
3935 return m_currentFile->GetVideoInfoTag()->m_strAlbum;
3936 case VIDEOPLAYER_WRITER:
3937 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_writingCredits, g_advancedSettings.m_videoItemSeparator);
3938 case VIDEOPLAYER_TAGLINE:
3939 return m_currentFile->GetVideoInfoTag()->m_strTagLine;
3940 case VIDEOPLAYER_LASTPLAYED:
3942 if (m_currentFile->GetVideoInfoTag()->m_lastPlayed.IsValid())
3943 return m_currentFile->GetVideoInfoTag()->m_lastPlayed.GetAsLocalizedDateTime();
3946 case VIDEOPLAYER_PLAYCOUNT:
3948 CStdString strPlayCount;
3949 if (m_currentFile->GetVideoInfoTag()->m_playCount > 0)
3950 strPlayCount = StringUtils::Format("%i", m_currentFile->GetVideoInfoTag()->m_playCount);
3951 return strPlayCount;
3958 int64_t CGUIInfoManager::GetPlayTime() const
3960 if (g_application.m_pPlayer->IsPlaying())
3962 int64_t lPTS = (int64_t)(g_application.GetTime() * 1000);
3963 if (lPTS < 0) lPTS = 0;
3969 CStdString CGUIInfoManager::GetCurrentPlayTime(TIME_FORMAT format) const
3971 if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
3972 format = TIME_FORMAT_HH_MM_SS;
3973 if (g_application.m_pPlayer->IsPlaying())
3974 return StringUtils::SecondsToTimeString((int)(GetPlayTime()/1000), format);
3978 CStdString CGUIInfoManager::GetCurrentSeekTime(TIME_FORMAT format) const
3980 if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
3981 format = TIME_FORMAT_HH_MM_SS;
3982 float time = GetTotalPlayTime() * g_application.GetSeekHandler()->GetPercent() * 0.01f;
3983 return StringUtils::SecondsToTimeString((int)time, format);
3986 int CGUIInfoManager::GetTotalPlayTime() const
3988 int iTotalTime = (int)g_application.GetTotalTime();
3989 return iTotalTime > 0 ? iTotalTime : 0;
3992 int CGUIInfoManager::GetPlayTimeRemaining() const
3994 int iReverse = GetTotalPlayTime() - (int)g_application.GetTime();
3995 return iReverse > 0 ? iReverse : 0;
3998 CStdString CGUIInfoManager::GetCurrentPlayTimeRemaining(TIME_FORMAT format) const
4000 if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
4001 format = TIME_FORMAT_HH_MM_SS;
4002 int timeRemaining = GetPlayTimeRemaining();
4003 if (timeRemaining && g_application.m_pPlayer->IsPlaying())
4004 return StringUtils::SecondsToTimeString(timeRemaining, format);
4008 void CGUIInfoManager::ResetCurrentItem()
4010 m_currentFile->Reset();
4011 m_currentMovieThumb = "";
4012 m_currentMovieDuration = "";
4015 void CGUIInfoManager::SetCurrentItem(CFileItem &item)
4020 SetCurrentSong(item);
4022 SetCurrentMovie(item);
4024 if (item.HasEPGInfoTag())
4025 *m_currentFile->GetEPGInfoTag() = *item.GetEPGInfoTag();
4026 else if (item.HasPVRChannelInfoTag())
4029 if (item.GetPVRChannelInfoTag()->GetEPGNow(tag))
4030 *m_currentFile->GetEPGInfoTag() = tag;
4034 NotifyObservers(ObservableMessageCurrentItem);
4037 void CGUIInfoManager::SetCurrentAlbumThumb(const CStdString &thumbFileName)
4039 if (CFile::Exists(thumbFileName))
4040 m_currentFile->SetArt("thumb", thumbFileName);
4043 m_currentFile->SetArt("thumb", "");
4044 m_currentFile->FillInDefaultIcon();
4048 void CGUIInfoManager::SetCurrentSong(CFileItem &item)
4050 CLog::Log(LOGDEBUG,"CGUIInfoManager::SetCurrentSong(%s)",item.GetPath().c_str());
4051 *m_currentFile = item;
4053 m_currentFile->LoadMusicTag();
4054 if (m_currentFile->GetMusicInfoTag()->GetTitle().empty())
4056 // No title in tag, show filename only
4057 m_currentFile->GetMusicInfoTag()->SetTitle(CUtil::GetTitleFromPath(m_currentFile->GetPath()));
4059 m_currentFile->GetMusicInfoTag()->SetLoaded(true);
4061 // find a thumb for this file.
4062 if (m_currentFile->IsInternetStream())
4064 if (!g_application.m_strPlayListFile.empty())
4066 CLog::Log(LOGDEBUG,"Streaming media detected... using %s to find a thumb", g_application.m_strPlayListFile.c_str());
4067 CFileItem streamingItem(g_application.m_strPlayListFile,false);
4069 CMusicThumbLoader loader;
4070 loader.FillThumb(streamingItem);
4071 if (streamingItem.HasArt("thumb"))
4072 m_currentFile->SetArt("thumb", streamingItem.GetArt("thumb"));
4077 CMusicThumbLoader loader;
4078 loader.LoadItem(m_currentFile);
4080 m_currentFile->FillInDefaultIcon();
4082 CMusicInfoLoader::LoadAdditionalTagInfo(m_currentFile);
4085 void CGUIInfoManager::SetCurrentMovie(CFileItem &item)
4087 CLog::Log(LOGDEBUG,"CGUIInfoManager::SetCurrentMovie(%s)", CURL::GetRedacted(item.GetPath()).c_str());
4088 *m_currentFile = item;
4090 /* also call GetMovieInfo() when a VideoInfoTag is already present or additional info won't be present in the tag */
4091 if (!m_currentFile->HasPVRChannelInfoTag())
4096 CStdString path = item.GetPath();
4097 CStdString videoInfoTagPath(item.GetVideoInfoTag()->m_strFileNameAndPath);
4098 if (videoInfoTagPath.find("removable://") == 0)
4099 path = videoInfoTagPath;
4100 dbs.LoadVideoInfo(path, *m_currentFile->GetVideoInfoTag());
4105 // Find a thumb for this file.
4106 if (!item.HasArt("thumb"))
4108 CVideoThumbLoader loader;
4109 loader.LoadItem(m_currentFile);
4112 // find a thumb for this stream
4113 if (item.IsInternetStream())
4115 // case where .strm is used to start an audio stream
4116 if (g_application.m_pPlayer->IsPlayingAudio())
4118 SetCurrentSong(item);
4123 if (!g_application.m_strPlayListFile.empty())
4125 CLog::Log(LOGDEBUG,"Streaming media detected... using %s to find a thumb", g_application.m_strPlayListFile.c_str());
4126 CFileItem thumbItem(g_application.m_strPlayListFile,false);
4128 CVideoThumbLoader loader;
4129 if (loader.FillThumb(thumbItem))
4130 item.SetArt("thumb", thumbItem.GetArt("thumb"));
4134 item.FillInDefaultIcon();
4135 m_currentMovieThumb = item.GetArt("thumb");
4138 string CGUIInfoManager::GetSystemHeatInfo(int info)
4140 if (CTimeUtils::GetFrameTime() - m_lastSysHeatInfoTime >= SYSHEATUPDATEINTERVAL)
4141 { // update our variables
4142 m_lastSysHeatInfoTime = CTimeUtils::GetFrameTime();
4143 #if defined(TARGET_POSIX)
4144 g_cpuInfo.getTemperature(m_cpuTemp);
4145 m_gpuTemp = GetGPUTemperature();
4152 case SYSTEM_CPU_TEMPERATURE:
4153 return m_cpuTemp.IsValid() ? m_cpuTemp.ToString() : "?";
4155 case SYSTEM_GPU_TEMPERATURE:
4156 return m_gpuTemp.IsValid() ? m_gpuTemp.ToString() : "?";
4158 case SYSTEM_FAN_SPEED:
4159 text = StringUtils::Format("%i%%", m_fanSpeed * 2);
4161 case SYSTEM_CPU_USAGE:
4162 #if defined(TARGET_DARWIN_OSX)
4163 text = StringUtils::Format("%4.2f%%", m_resourceCounter.GetCPUUsage());
4164 #elif defined(TARGET_DARWIN) || defined(TARGET_WINDOWS)
4165 text = StringUtils::Format("%d%%", g_cpuInfo.getUsedPercentage());
4167 text = StringUtils::Format("%s", g_cpuInfo.GetCoresUsageString().c_str());
4174 CTemperature CGUIInfoManager::GetGPUTemperature()
4179 #if defined(TARGET_DARWIN_OSX)
4180 value = SMCGetTemperature(SMC_KEY_GPU_TEMP);
4181 return CTemperature::CreateFromCelsius(value);
4183 CStdString cmd = g_advancedSettings.m_gpuTempCmd;
4187 if (cmd.empty() || !(p = popen(cmd.c_str(), "r")))
4188 return CTemperature();
4190 ret = fscanf(p, "%d %c", &value, &scale);
4194 return CTemperature();
4197 if (scale == 'C' || scale == 'c')
4198 return CTemperature::CreateFromCelsius(value);
4199 if (scale == 'F' || scale == 'f')
4200 return CTemperature::CreateFromFahrenheit(value);
4201 return CTemperature();
4204 // Version string MUST NOT contain spaces. It is used
4205 // in the HTTP request user agent.
4206 CStdString CGUIInfoManager::GetVersion()
4209 if (GetXbmcGitRevision())
4210 tmp = StringUtils::Format("%d.%d%s Git:%s", VERSION_MAJOR, VERSION_MINOR, VERSION_TAG, GetXbmcGitRevision());
4212 tmp = StringUtils::Format("%d.%d%s", VERSION_MAJOR, VERSION_MINOR, VERSION_TAG);
4216 CStdString CGUIInfoManager::GetBuild()
4218 return StringUtils::Format("%s", __DATE__);
4221 void CGUIInfoManager::SetDisplayAfterSeek(unsigned int timeOut, int seekOffset)
4223 g_infoManager.m_performingSeek = false;
4226 m_AfterSeekTimeout = CTimeUtils::GetFrameTime() + timeOut;
4228 m_seekOffset = seekOffset;
4231 m_AfterSeekTimeout = 0;
4234 bool CGUIInfoManager::GetDisplayAfterSeek()
4236 if (CTimeUtils::GetFrameTime() < m_AfterSeekTimeout)
4242 void CGUIInfoManager::Clear()
4244 CSingleLock lock(m_critInfo);
4245 m_skinVariableStrings.clear();
4248 Erase any info bools that are unused. We do this repeatedly as each run
4249 will remove those bools that are no longer dependencies of other bools
4252 vector<InfoPtr>::iterator i = remove_if(m_bools.begin(), m_bools.end(), std::mem_fun_ref(&InfoPtr::unique));
4253 while (i != m_bools.end())
4255 m_bools.erase(i, m_bools.end());
4256 i = remove_if(m_bools.begin(), m_bools.end(), std::mem_fun_ref(&InfoPtr::unique));
4258 // log which ones are used - they should all be gone by now
4259 for (vector<InfoPtr>::const_iterator i = m_bools.begin(); i != m_bools.end(); ++i)
4260 CLog::Log(LOGDEBUG, "Infobool '%s' still used by %u instances", (*i)->GetExpression().c_str(), (unsigned int) i->use_count());
4263 void CGUIInfoManager::UpdateFPS()
4266 unsigned int curTime = CTimeUtils::GetFrameTime();
4268 float fTimeSpan = (float)(curTime - m_lastFPSTime);
4269 if (fTimeSpan >= 1000.0f)
4271 fTimeSpan /= 1000.0f;
4272 m_fps = m_frameCounter / fTimeSpan;
4273 m_lastFPSTime = curTime;
4278 void CGUIInfoManager::UpdateAVInfo()
4280 if(g_application.m_pPlayer->IsPlaying())
4284 SPlayerVideoStreamInfo video;
4285 SPlayerAudioStreamInfo audio;
4287 g_application.m_pPlayer->GetVideoStreamInfo(video);
4288 g_application.m_pPlayer->GetAudioStreamInfo(g_application.m_pPlayer->GetAudioStream(), audio);
4290 m_videoInfo = video;
4291 m_audioInfo = audio;
4292 m_AVInfoValid = true;
4297 int CGUIInfoManager::AddListItemProp(const CStdString &str, int offset)
4299 for (int i=0; i < (int)m_listitemProperties.size(); i++)
4300 if (m_listitemProperties[i] == str)
4301 return (LISTITEM_PROPERTY_START+offset + i);
4303 if (m_listitemProperties.size() < LISTITEM_PROPERTY_END - LISTITEM_PROPERTY_START)
4305 m_listitemProperties.push_back(str);
4306 return LISTITEM_PROPERTY_START + offset + m_listitemProperties.size() - 1;
4309 CLog::Log(LOGERROR,"%s - not enough listitem property space!", __FUNCTION__);
4313 int CGUIInfoManager::AddMultiInfo(const GUIInfo &info)
4315 // check to see if we have this info already
4316 for (unsigned int i = 0; i < m_multiInfo.size(); i++)
4317 if (m_multiInfo[i] == info)
4318 return (int)i + MULTI_INFO_START;
4319 // return the new offset
4320 m_multiInfo.push_back(info);
4321 int id = (int)m_multiInfo.size() + MULTI_INFO_START - 1;
4322 if (id > MULTI_INFO_END)
4323 CLog::Log(LOGERROR, "%s - too many multiinfo bool/labels in this skin", __FUNCTION__);
4327 int CGUIInfoManager::ConditionalStringParameter(const CStdString ¶meter, bool caseSensitive /*= false*/)
4329 // check to see if we have this parameter already
4330 for (unsigned int i = 0; i < m_stringParameters.size(); i++)
4331 if (parameter.Equals(m_stringParameters[i], caseSensitive))
4333 // return the new offset
4334 m_stringParameters.push_back(parameter);
4335 return (int)m_stringParameters.size() - 1;
4338 bool CGUIInfoManager::GetItemInt(int &value, const CGUIListItem *item, int info) const
4346 if (info >= LISTITEM_PROPERTY_START && info - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size())
4347 { // grab the property
4348 CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START];
4349 CStdString val = item->GetProperty(property).asString();
4356 case LISTITEM_PROGRESS:
4359 if (item->IsFileItem())
4361 const CFileItem *pItem = (const CFileItem *)item;
4362 if (pItem && pItem->HasPVRChannelInfoTag())
4365 if (pItem->GetPVRChannelInfoTag()->GetEPGNow(epgNow))
4366 value = (int) epgNow.ProgressPercentage();
4368 else if (pItem && pItem->HasEPGInfoTag())
4370 value = (int) pItem->GetEPGInfoTag()->ProgressPercentage();
4377 case LISTITEM_PERCENT_PLAYED:
4378 if (item->IsFileItem() && ((const CFileItem *)item)->HasVideoInfoTag() && ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.IsPartWay())
4379 value = (int)(100 * ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.timeInSeconds / ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds);
4380 else if (item->IsFileItem() && ((const CFileItem *)item)->HasPVRRecordingInfoTag() && ((const CFileItem *)item)->GetPVRRecordingInfoTag()->m_resumePoint.IsPartWay())
4381 value = (int)(100 * ((const CFileItem *)item)->GetPVRRecordingInfoTag()->m_resumePoint.timeInSeconds / ((const CFileItem *)item)->GetPVRRecordingInfoTag()->m_resumePoint.totalTimeInSeconds);
4391 CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, CStdString *fallback)
4393 if (!item) return "";
4395 if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
4396 return GetSkinVariableString(info, false, item);
4398 if (info >= LISTITEM_PROPERTY_START + LISTITEM_ART_OFFSET && info - (LISTITEM_PROPERTY_START + LISTITEM_ART_OFFSET) < (int)m_listitemProperties.size())
4400 std::string art = m_listitemProperties[info - (LISTITEM_PROPERTY_START + LISTITEM_ART_OFFSET)];
4401 return item->GetArt(art);
4404 if (info >= LISTITEM_PROPERTY_START && info - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size())
4405 { // grab the property
4406 CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START];
4407 return item->GetProperty(property).asString();
4410 if (info >= LISTITEM_PICTURE_START && info <= LISTITEM_PICTURE_END && item->HasPictureInfoTag())
4411 return item->GetPictureInfoTag()->GetInfo(picture_slide_map[info - LISTITEM_PICTURE_START]);
4415 case LISTITEM_LABEL:
4416 return item->GetLabel();
4417 case LISTITEM_LABEL2:
4418 return item->GetLabel2();
4419 case LISTITEM_TITLE:
4420 if (item->HasPVRChannelInfoTag())
4423 return item->GetPVRChannelInfoTag()->GetEPGNow(epgTag) ?
4425 CSettings::Get().GetBool("epg.hidenoinfoavailable") ?
4426 StringUtils::EmptyString :
4427 g_localizeStrings.Get(19055); // no information available
4429 if (item->HasPVRRecordingInfoTag())
4430 return item->GetPVRRecordingInfoTag()->m_strTitle;
4431 if (item->HasEPGInfoTag())
4432 return item->GetEPGInfoTag()->Title();
4433 if (item->HasPVRTimerInfoTag())
4434 return item->GetPVRTimerInfoTag()->Title();
4435 if (item->HasVideoInfoTag())
4436 return item->GetVideoInfoTag()->m_strTitle;
4437 if (item->HasMusicInfoTag())
4438 return item->GetMusicInfoTag()->GetTitle();
4440 case LISTITEM_ORIGINALTITLE:
4441 if (item->HasVideoInfoTag())
4442 return item->GetVideoInfoTag()->m_strOriginalTitle;
4444 case LISTITEM_PLAYCOUNT:
4446 CStdString strPlayCount;
4447 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_playCount > 0)
4448 strPlayCount = StringUtils::Format("%i", item->GetVideoInfoTag()->m_playCount);
4449 if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetPlayCount() > 0)
4450 strPlayCount = StringUtils::Format("%i", item->GetMusicInfoTag()->GetPlayCount());
4451 return strPlayCount;
4453 case LISTITEM_LASTPLAYED:
4456 if (item->HasVideoInfoTag())
4457 dateTime = item->GetVideoInfoTag()->m_lastPlayed;
4458 else if (item->HasMusicInfoTag())
4459 dateTime = item->GetMusicInfoTag()->GetLastPlayed();
4461 if (dateTime.IsValid())
4462 return dateTime.GetAsLocalizedDate();
4465 case LISTITEM_TRACKNUMBER:
4468 if (item->HasMusicInfoTag())
4469 track = StringUtils::Format("%i", item->GetMusicInfoTag()->GetTrackNumber());
4473 case LISTITEM_DISC_NUMBER:
4476 if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDiscNumber() > 0)
4477 disc = StringUtils::Format("%i", item->GetMusicInfoTag()->GetDiscNumber());
4480 case LISTITEM_ARTIST:
4481 if (item->HasVideoInfoTag())
4482 return StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator);
4483 if (item->HasMusicInfoTag())
4484 return StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator);
4486 case LISTITEM_ALBUM_ARTIST:
4487 if (item->HasMusicInfoTag())
4488 return StringUtils::Join(item->GetMusicInfoTag()->GetAlbumArtist(), g_advancedSettings.m_musicItemSeparator);
4490 case LISTITEM_DIRECTOR:
4491 if (item->HasVideoInfoTag())
4492 return StringUtils::Join(item->GetVideoInfoTag()->m_director, g_advancedSettings.m_videoItemSeparator);
4494 case LISTITEM_ALBUM:
4495 if (item->HasVideoInfoTag())
4496 return item->GetVideoInfoTag()->m_strAlbum;
4497 if (item->HasMusicInfoTag())
4498 return item->GetMusicInfoTag()->GetAlbum();
4501 if (item->HasVideoInfoTag())
4503 CStdString strResult;
4504 if (item->GetVideoInfoTag()->m_iYear > 0)
4505 strResult = StringUtils::Format("%i",item->GetVideoInfoTag()->m_iYear);
4508 if (item->HasMusicInfoTag())
4509 return item->GetMusicInfoTag()->GetYearString();
4511 case LISTITEM_PREMIERED:
4512 if (item->HasVideoInfoTag())
4515 if (item->GetVideoInfoTag()->m_firstAired.IsValid())
4516 dateTime = item->GetVideoInfoTag()->m_firstAired;
4517 else if (item->GetVideoInfoTag()->m_premiered.IsValid())
4518 dateTime = item->GetVideoInfoTag()->m_premiered;
4520 if (dateTime.IsValid())
4521 return dateTime.GetAsLocalizedDate();
4525 case LISTITEM_GENRE:
4526 if (item->HasVideoInfoTag())
4527 return StringUtils::Join(item->GetVideoInfoTag()->m_genre, g_advancedSettings.m_videoItemSeparator);
4528 if (item->HasMusicInfoTag())
4529 return StringUtils::Join(item->GetMusicInfoTag()->GetGenre(), g_advancedSettings.m_musicItemSeparator);
4530 if (item->HasPVRChannelInfoTag())
4533 return item->GetPVRChannelInfoTag()->GetEPGNow(epgTag) ? StringUtils::Join(epgTag.Genre(), g_advancedSettings.m_videoItemSeparator) : StringUtils::EmptyString;
4535 if (item->HasPVRRecordingInfoTag())
4536 return StringUtils::Join(item->GetPVRRecordingInfoTag()->m_genre, g_advancedSettings.m_videoItemSeparator);
4537 if (item->HasEPGInfoTag())
4538 return StringUtils::Join(item->GetEPGInfoTag()->Genre(), g_advancedSettings.m_videoItemSeparator);
4540 case LISTITEM_FILENAME:
4541 case LISTITEM_FILE_EXTENSION:
4544 if (item->IsMusicDb() && item->HasMusicInfoTag())
4545 strFile = URIUtils::GetFileName(item->GetMusicInfoTag()->GetURL());
4546 else if (item->IsVideoDb() && item->HasVideoInfoTag())
4547 strFile = URIUtils::GetFileName(item->GetVideoInfoTag()->m_strFileNameAndPath);
4549 strFile = URIUtils::GetFileName(item->GetPath());
4551 if (info==LISTITEM_FILE_EXTENSION)
4553 CStdString strExtension = URIUtils::GetExtension(strFile);
4554 return StringUtils::TrimLeft(strExtension, ".");
4560 if (item->HasEPGInfoTag())
4561 return item->GetEPGInfoTag()->StartAsLocalTime().GetAsLocalizedDateTime(false, false);
4562 if (item->HasPVRChannelInfoTag())
4565 return item->GetPVRChannelInfoTag()->GetEPGNow(epgTag) ? epgTag.StartAsLocalTime().GetAsLocalizedDateTime(false, false) : CDateTime::GetCurrentDateTime().GetAsLocalizedDateTime(false, false);
4567 if (item->HasPVRRecordingInfoTag())
4568 return item->GetPVRRecordingInfoTag()->RecordingTimeAsLocalTime().GetAsLocalizedDateTime(false, false);
4569 if (item->HasPVRTimerInfoTag())
4570 return item->GetPVRTimerInfoTag()->Summary();
4571 if (item->m_dateTime.IsValid())
4572 return item->m_dateTime.GetAsLocalizedDate();
4575 if (!item->m_bIsFolder || item->m_dwSize)
4576 return StringUtils::SizeToString(item->m_dwSize);
4578 case LISTITEM_RATING:
4581 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_fRating > 0.f) // movie rating
4582 rating = StringUtils::Format("%.1f", item->GetVideoInfoTag()->m_fRating);
4583 else if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetRating() > '0')
4584 { // song rating. Images will probably be better than numbers for this in the long run
4585 rating = item->GetMusicInfoTag()->GetRating();
4589 case LISTITEM_RATING_AND_VOTES:
4591 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_fRating > 0.f) // movie rating
4593 CStdString strRatingAndVotes;
4594 if (item->GetVideoInfoTag()->m_strVotes.empty())
4595 strRatingAndVotes = StringUtils::Format("%.1f",
4596 item->GetVideoInfoTag()->m_fRating);
4598 strRatingAndVotes = StringUtils::Format("%.1f (%s %s)",
4599 item->GetVideoInfoTag()->m_fRating,
4600 item->GetVideoInfoTag()->m_strVotes.c_str(),
4601 g_localizeStrings.Get(20350).c_str());
4602 return strRatingAndVotes;
4606 case LISTITEM_VOTES:
4607 if (item->HasVideoInfoTag())
4608 return item->GetVideoInfoTag()->m_strVotes;
4610 case LISTITEM_PROGRAM_COUNT:
4612 return StringUtils::Format("%i", item->m_iprogramCount);;
4614 case LISTITEM_DURATION:
4616 CStdString duration;
4617 if (item->HasPVRChannelInfoTag())
4619 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4621 if (channel && channel->GetEPGNow(tag))
4622 return StringUtils::SecondsToTimeString(tag.GetDuration());
4623 return StringUtils::EmptyString;
4625 else if (item->HasPVRRecordingInfoTag())
4627 if (item->GetPVRRecordingInfoTag()->GetDuration() > 0)
4628 duration = StringUtils::SecondsToTimeString(item->GetPVRRecordingInfoTag()->GetDuration());
4630 else if (item->HasEPGInfoTag())
4632 if (item->GetEPGInfoTag()->GetDuration() > 0)
4633 duration = StringUtils::SecondsToTimeString(item->GetEPGInfoTag()->GetDuration());
4635 else if (item->HasVideoInfoTag())
4637 if (item->GetVideoInfoTag()->GetDuration() > 0)
4638 duration = StringUtils::Format("%d", item->GetVideoInfoTag()->GetDuration() / 60);
4640 else if (item->HasMusicInfoTag())
4642 if (item->GetMusicInfoTag()->GetDuration() > 0)
4643 duration = StringUtils::SecondsToTimeString(item->GetMusicInfoTag()->GetDuration());
4648 if (item->HasPVRChannelInfoTag())
4650 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4652 if (channel && channel->GetEPGNow(tag))
4654 return StringUtils::EmptyString;
4656 if (item->HasEPGInfoTag())
4657 return item->GetEPGInfoTag()->Plot();
4658 if (item->HasPVRRecordingInfoTag())
4659 return item->GetPVRRecordingInfoTag()->m_strPlot;
4660 if (item->HasVideoInfoTag())
4662 if (!(!item->GetVideoInfoTag()->m_strShowTitle.empty() && item->GetVideoInfoTag()->m_iSeason == -1)) // dont apply to tvshows
4663 if (item->GetVideoInfoTag()->m_playCount == 0 && !CSettings::Get().GetBool("videolibrary.showunwatchedplots"))
4664 return g_localizeStrings.Get(20370);
4666 return item->GetVideoInfoTag()->m_strPlot;
4669 case LISTITEM_PLOT_OUTLINE:
4670 if (item->HasPVRChannelInfoTag())
4672 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4674 if (channel && channel->GetEPGNow(tag))
4675 return tag.PlotOutline();
4676 return StringUtils::EmptyString;
4678 if (item->HasEPGInfoTag())
4679 return item->GetEPGInfoTag()->PlotOutline();
4680 if (item->HasPVRRecordingInfoTag())
4681 return item->GetPVRRecordingInfoTag()->m_strPlotOutline;
4682 if (item->HasVideoInfoTag())
4683 return item->GetVideoInfoTag()->m_strPlotOutline;
4685 case LISTITEM_EPISODE:
4686 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iEpisode > 0)
4688 CStdString strResult;
4689 if (item->GetVideoInfoTag()->m_iSeason == 0) // prefix episode with 'S'
4690 strResult = StringUtils::Format("S%d",item->GetVideoInfoTag()->m_iEpisode);
4692 strResult = StringUtils::Format("%d",item->GetVideoInfoTag()->m_iEpisode);
4696 case LISTITEM_SEASON:
4697 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iSeason > 0)
4699 return StringUtils::Format("%d",item->GetVideoInfoTag()->m_iSeason);;
4702 case LISTITEM_TVSHOW:
4703 if (item->HasVideoInfoTag())
4704 return item->GetVideoInfoTag()->m_strShowTitle;
4706 case LISTITEM_COMMENT:
4707 if (item->HasPVRTimerInfoTag())
4708 return item->GetPVRTimerInfoTag()->GetStatus();
4709 if (item->HasMusicInfoTag())
4710 return item->GetMusicInfoTag()->GetComment();
4712 case LISTITEM_ACTUAL_ICON:
4713 return item->GetIconImage();
4716 CStdString strThumb = item->GetArt("thumb");
4717 if (strThumb.empty())
4718 strThumb = item->GetIconImage();
4720 *fallback = item->GetIconImage();
4723 case LISTITEM_OVERLAY:
4724 return item->GetOverlayImage();
4725 case LISTITEM_THUMB:
4726 return item->GetArt("thumb");
4727 case LISTITEM_FOLDERPATH:
4728 return CURL(item->GetPath()).GetWithoutUserDetails();
4729 case LISTITEM_FOLDERNAME:
4733 if (item->IsMusicDb() && item->HasMusicInfoTag())
4734 path = URIUtils::GetDirectory(item->GetMusicInfoTag()->GetURL());
4735 else if (item->IsVideoDb() && item->HasVideoInfoTag())
4737 if( item->m_bIsFolder )
4738 path = item->GetVideoInfoTag()->m_strPath;
4740 URIUtils::GetParentPath(item->GetVideoInfoTag()->m_strFileNameAndPath, path);
4743 URIUtils::GetParentPath(item->GetPath(), path);
4744 path = CURL(path).GetWithoutUserDetails();
4745 if (info==LISTITEM_FOLDERNAME)
4747 URIUtils::RemoveSlashAtEnd(path);
4748 path=URIUtils::GetFileName(path);
4753 case LISTITEM_FILENAME_AND_PATH:
4756 if (item->IsMusicDb() && item->HasMusicInfoTag())
4757 path = item->GetMusicInfoTag()->GetURL();
4758 else if (item->IsVideoDb() && item->HasVideoInfoTag())
4759 path = item->GetVideoInfoTag()->m_strFileNameAndPath;
4761 path = item->GetPath();
4762 path = CURL(path).GetWithoutUserDetails();
4766 case LISTITEM_PICTURE_PATH:
4767 if (item->IsPicture() && (!item->IsZIP() || item->IsRAR() || item->IsCBZ() || item->IsCBR()))
4768 return item->GetPath();
4770 case LISTITEM_STUDIO:
4771 if (item->HasVideoInfoTag())
4772 return StringUtils::Join(item->GetVideoInfoTag()->m_studio, g_advancedSettings.m_videoItemSeparator);
4774 case LISTITEM_COUNTRY:
4775 if (item->HasVideoInfoTag())
4776 return StringUtils::Join(item->GetVideoInfoTag()->m_country, g_advancedSettings.m_videoItemSeparator);
4779 if (item->HasVideoInfoTag())
4780 return item->GetVideoInfoTag()->m_strMPAARating;
4783 if (item->HasVideoInfoTag())
4784 return item->GetVideoInfoTag()->GetCast();
4786 case LISTITEM_CAST_AND_ROLE:
4787 if (item->HasVideoInfoTag())
4788 return item->GetVideoInfoTag()->GetCast(true);
4790 case LISTITEM_WRITER:
4791 if (item->HasVideoInfoTag())
4792 return StringUtils::Join(item->GetVideoInfoTag()->m_writingCredits, g_advancedSettings.m_videoItemSeparator);
4794 case LISTITEM_TAGLINE:
4795 if (item->HasVideoInfoTag())
4796 return item->GetVideoInfoTag()->m_strTagLine;
4798 case LISTITEM_TRAILER:
4799 if (item->HasVideoInfoTag())
4800 return item->GetVideoInfoTag()->m_strTrailer;
4802 case LISTITEM_TOP250:
4803 if (item->HasVideoInfoTag())
4805 CStdString strResult;
4806 if (item->GetVideoInfoTag()->m_iTop250 > 0)
4807 strResult = StringUtils::Format("%i",item->GetVideoInfoTag()->m_iTop250);
4811 case LISTITEM_SORT_LETTER:
4814 std::wstring character(1, item->GetSortLabel()[0]);
4815 StringUtils::ToUpper(character);
4816 g_charsetConverter.wToUTF8(character, letter);
4820 case LISTITEM_VIDEO_CODEC:
4821 if (item->HasVideoInfoTag())
4822 return item->GetVideoInfoTag()->m_streamDetails.GetVideoCodec();
4824 case LISTITEM_VIDEO_RESOLUTION:
4825 if (item->HasVideoInfoTag())
4826 return CStreamDetails::VideoDimsToResolutionDescription(item->GetVideoInfoTag()->m_streamDetails.GetVideoWidth(), item->GetVideoInfoTag()->m_streamDetails.GetVideoHeight());
4828 case LISTITEM_VIDEO_ASPECT:
4829 if (item->HasVideoInfoTag())
4830 return CStreamDetails::VideoAspectToAspectDescription(item->GetVideoInfoTag()->m_streamDetails.GetVideoAspect());
4832 case LISTITEM_AUDIO_CODEC:
4833 if (item->HasVideoInfoTag())
4835 return item->GetVideoInfoTag()->m_streamDetails.GetAudioCodec();
4838 case LISTITEM_AUDIO_CHANNELS:
4839 if (item->HasVideoInfoTag())
4841 CStdString strResult;
4842 int iChannels = item->GetVideoInfoTag()->m_streamDetails.GetAudioChannels();
4844 strResult = StringUtils::Format("%i", iChannels);
4848 case LISTITEM_AUDIO_LANGUAGE:
4849 if (item->HasVideoInfoTag())
4850 return item->GetVideoInfoTag()->m_streamDetails.GetAudioLanguage();
4852 case LISTITEM_SUBTITLE_LANGUAGE:
4853 if (item->HasVideoInfoTag())
4854 return item->GetVideoInfoTag()->m_streamDetails.GetSubtitleLanguage();
4856 case LISTITEM_STARTTIME:
4857 if (item->HasPVRChannelInfoTag())
4859 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4861 if (channel && channel->GetEPGNow(tag))
4862 return tag.StartAsLocalTime().GetAsLocalizedTime("", false);
4863 return CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
4865 if (item->HasEPGInfoTag())
4866 return item->GetEPGInfoTag()->StartAsLocalTime().GetAsLocalizedTime("", false);
4867 if (item->HasPVRTimerInfoTag())
4868 return item->GetPVRTimerInfoTag()->StartAsLocalTime().GetAsLocalizedTime("", false);
4869 if (item->HasPVRRecordingInfoTag())
4870 return item->GetPVRRecordingInfoTag()->RecordingTimeAsLocalTime().GetAsLocalizedTime("", false);
4871 if (item->m_dateTime.IsValid())
4872 return item->m_dateTime.GetAsLocalizedTime("", false);
4874 case LISTITEM_ENDTIME:
4875 if (item->HasPVRChannelInfoTag())
4877 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4879 if (channel && channel->GetEPGNow(tag))
4880 return tag.EndAsLocalTime().GetAsLocalizedTime("", false);
4881 return CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
4883 if (item->HasEPGInfoTag())
4884 return item->GetEPGInfoTag()->EndAsLocalTime().GetAsLocalizedTime("", false);
4885 if (item->HasPVRTimerInfoTag())
4886 return item->GetPVRTimerInfoTag()->EndAsLocalTime().GetAsLocalizedTime("", false);
4888 case LISTITEM_STARTDATE:
4889 if (item->HasPVRChannelInfoTag())
4891 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4893 if (channel && channel->GetEPGNow(tag))
4894 return tag.StartAsLocalTime().GetAsLocalizedDate(true);
4895 return CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true);
4897 if (item->HasEPGInfoTag())
4898 return item->GetEPGInfoTag()->StartAsLocalTime().GetAsLocalizedDate(true);
4899 if (item->HasPVRTimerInfoTag())
4900 return item->GetPVRTimerInfoTag()->StartAsLocalTime().GetAsLocalizedDate(true);
4901 if (item->HasPVRRecordingInfoTag())
4902 return item->GetPVRRecordingInfoTag()->RecordingTimeAsLocalTime().GetAsLocalizedDate(true);
4903 if (item->m_dateTime.IsValid())
4904 return item->m_dateTime.GetAsLocalizedDate(true);
4906 case LISTITEM_ENDDATE:
4907 if (item->HasPVRChannelInfoTag())
4909 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4911 if (channel && channel->GetEPGNow(tag))
4912 return tag.EndAsLocalTime().GetAsLocalizedDate(true);
4913 return CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true);
4915 if (item->HasEPGInfoTag())
4916 return item->GetEPGInfoTag()->EndAsLocalTime().GetAsLocalizedDate(true);
4917 if (item->HasPVRTimerInfoTag())
4918 return item->GetPVRTimerInfoTag()->EndAsLocalTime().GetAsLocalizedDate(true);
4920 case LISTITEM_CHANNEL_NUMBER:
4923 if (item->HasPVRChannelInfoTag())
4924 number = StringUtils::Format("%i", item->GetPVRChannelInfoTag()->ChannelNumber());
4925 if (item->HasEPGInfoTag() && item->GetEPGInfoTag()->HasPVRChannel())
4926 number = StringUtils::Format("%i", item->GetEPGInfoTag()->PVRChannelNumber());
4927 if (item->HasPVRTimerInfoTag())
4928 number = StringUtils::Format("%i", item->GetPVRTimerInfoTag()->ChannelNumber());
4933 case LISTITEM_CHANNEL_NAME:
4934 if (item->HasPVRChannelInfoTag())
4935 return item->GetPVRChannelInfoTag()->ChannelName();
4936 if (item->HasEPGInfoTag() && item->GetEPGInfoTag()->HasPVRChannel())
4937 return item->GetEPGInfoTag()->PVRChannelName();
4938 if (item->HasPVRRecordingInfoTag())
4939 return item->GetPVRRecordingInfoTag()->m_strChannelName;
4940 if (item->HasPVRTimerInfoTag())
4941 return item->GetPVRTimerInfoTag()->ChannelName();
4943 case LISTITEM_NEXT_STARTTIME:
4945 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4947 if (channel && channel->GetEPGNext(tag))
4948 return tag.StartAsLocalTime().GetAsLocalizedTime("", false);
4950 return CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
4951 case LISTITEM_NEXT_ENDTIME:
4953 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4955 if (channel && channel->GetEPGNext(tag))
4956 return tag.EndAsLocalTime().GetAsLocalizedTime("", false);
4958 return CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
4959 case LISTITEM_NEXT_STARTDATE:
4961 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4963 if (channel && channel->GetEPGNext(tag))
4964 return tag.StartAsLocalTime().GetAsLocalizedDate(true);
4966 return CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true);
4967 case LISTITEM_NEXT_ENDDATE:
4969 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4971 if (channel && channel->GetEPGNext(tag))
4972 return tag.EndAsLocalTime().GetAsLocalizedDate(true);
4974 return CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true);
4975 case LISTITEM_NEXT_PLOT:
4977 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4979 if (channel && channel->GetEPGNext(tag))
4982 return StringUtils::EmptyString;
4983 case LISTITEM_NEXT_PLOT_OUTLINE:
4985 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4987 if (channel && channel->GetEPGNext(tag))
4988 return tag.PlotOutline();
4990 return StringUtils::EmptyString;
4991 case LISTITEM_NEXT_DURATION:
4993 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4995 if (channel && channel->GetEPGNext(tag))
4996 return StringUtils::SecondsToTimeString(tag.GetDuration());
4998 return StringUtils::EmptyString;
4999 case LISTITEM_NEXT_GENRE:
5001 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
5003 if (channel && channel->GetEPGNext(tag))
5004 return StringUtils::Join(tag.Genre(), g_advancedSettings.m_videoItemSeparator);
5006 return StringUtils::EmptyString;
5007 case LISTITEM_NEXT_TITLE:
5009 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
5011 if (channel && channel->GetEPGNext(tag))
5014 return StringUtils::EmptyString;
5015 case LISTITEM_PARENTALRATING:
5018 if (item->HasEPGInfoTag() && item->GetEPGInfoTag()->ParentalRating() > 0)
5019 rating = StringUtils::Format("%i", item->GetEPGInfoTag()->ParentalRating());
5023 case LISTITEM_PERCENT_PLAYED:
5026 if (GetItemInt(val, item, info))
5028 return StringUtils::Format("%d", val);;
5032 case LISTITEM_DATE_ADDED:
5033 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_dateAdded.IsValid())
5034 return item->GetVideoInfoTag()->m_dateAdded.GetAsLocalizedDate();
5036 case LISTITEM_DBTYPE:
5037 if (item->HasVideoInfoTag())
5038 return item->GetVideoInfoTag()->m_type;
5041 if (item->HasVideoInfoTag())
5043 return StringUtils::Format("%i", item->GetVideoInfoTag()->m_iDbId);;
5045 if (item->HasMusicInfoTag())
5047 return StringUtils::Format("%i", item->GetMusicInfoTag()->GetDatabaseId());;
5050 case LISTITEM_STEREOSCOPIC_MODE:
5052 std::string stereoMode = item->GetProperty("stereomode").asString();
5053 if (stereoMode.empty() && item->HasVideoInfoTag())
5054 stereoMode = CStereoscopicsManager::Get().NormalizeStereoMode(item->GetVideoInfoTag()->m_streamDetails.GetStereoMode());
5061 CStdString CGUIInfoManager::GetItemImage(const CFileItem *item, int info, CStdString *fallback)
5063 if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
5064 return GetSkinVariableString(info, true, item);
5068 case LISTITEM_RATING: // old song rating format
5070 if (item->HasMusicInfoTag())
5072 return StringUtils::Format("songrating%c.png", item->GetMusicInfoTag()->GetRating());
5076 case LISTITEM_STAR_RATING:
5079 if (item->HasVideoInfoTag())
5080 { // rating for videos is assumed 0..10, so convert to 0..5
5081 rating = StringUtils::Format("rating%d.png", (long)((item->GetVideoInfoTag()->m_fRating * 0.5f) + 0.5f));
5083 else if (item->HasMusicInfoTag())
5085 rating = StringUtils::Format("rating%c.png", item->GetMusicInfoTag()->GetRating());
5090 } /* switch (info) */
5092 return GetItemLabel(item, info, fallback);
5095 bool CGUIInfoManager::GetItemBool(const CGUIListItem *item, int condition) const
5097 if (!item) return false;
5098 if (condition >= LISTITEM_PROPERTY_START && condition - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size())
5099 { // grab the property
5100 CStdString property = m_listitemProperties[condition - LISTITEM_PROPERTY_START];
5101 return item->GetProperty(property).asBoolean();
5103 else if (condition == LISTITEM_ISPLAYING)
5105 if (item->HasProperty("playlistposition"))
5106 return (int)item->GetProperty("playlisttype").asInteger() == g_playlistPlayer.GetCurrentPlaylist() && (int)item->GetProperty("playlistposition").asInteger() == g_playlistPlayer.GetCurrentSong();
5107 else if (item->IsFileItem() && !m_currentFile->GetPath().empty())
5109 if (!g_application.m_strPlayListFile.empty())
5111 //playlist file that is currently playing or the playlistitem that is currently playing.
5112 return g_application.m_strPlayListFile.Equals(((const CFileItem *)item)->GetPath()) || m_currentFile->IsSamePath((const CFileItem *)item);
5114 return m_currentFile->IsSamePath((const CFileItem *)item);
5117 else if (condition == LISTITEM_ISSELECTED)
5118 return item->IsSelected();
5119 else if (condition == LISTITEM_IS_FOLDER)
5120 return item->m_bIsFolder;
5121 else if (condition == LISTITEM_IS_RESUMABLE)
5123 if (item->IsFileItem())
5125 if (((const CFileItem *)item)->HasVideoInfoTag())
5126 return ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.timeInSeconds > 0;
5127 else if (((const CFileItem *)item)->HasPVRRecordingInfoTag())
5128 return ((const CFileItem *)item)->GetPVRRecordingInfoTag()->m_resumePoint.timeInSeconds > 0;
5131 else if (item->IsFileItem())
5133 const CFileItem *pItem = (const CFileItem *)item;
5134 if (condition == LISTITEM_ISRECORDING)
5136 if (!g_PVRManager.IsStarted())
5139 if (pItem->HasPVRChannelInfoTag())
5141 return pItem->GetPVRChannelInfoTag()->IsRecording();
5143 else if (pItem->HasPVRTimerInfoTag())
5145 const CPVRTimerInfoTag *timer = pItem->GetPVRTimerInfoTag();
5147 return timer->IsRecording();
5149 else if (pItem->HasEPGInfoTag())
5151 CFileItemPtr timer = g_PVRTimers->GetTimerForEpgTag(pItem);
5152 if (timer && timer->HasPVRTimerInfoTag())
5153 return timer->GetPVRTimerInfoTag()->IsRecording();
5156 else if (condition == LISTITEM_HASTIMER)
5158 if (pItem->HasEPGInfoTag())
5160 CFileItemPtr timer = g_PVRTimers->GetTimerForEpgTag(pItem);
5161 if (timer && timer->HasPVRTimerInfoTag())
5162 return timer->GetPVRTimerInfoTag()->IsActive();
5165 else if (condition == LISTITEM_HAS_EPG)
5167 if (pItem->HasPVRChannelInfoTag())
5170 return pItem->GetPVRChannelInfoTag()->GetEPGNow(epgTag);
5174 return pItem->HasEPGInfoTag();
5177 else if (condition == LISTITEM_ISENCRYPTED)
5179 if (pItem->HasPVRChannelInfoTag())
5181 return pItem->GetPVRChannelInfoTag()->IsEncrypted();
5183 else if (pItem->HasEPGInfoTag() && pItem->GetEPGInfoTag()->HasPVRChannel())
5185 return pItem->GetEPGInfoTag()->ChannelTag()->IsEncrypted();
5188 else if (condition == LISTITEM_IS_STEREOSCOPIC)
5190 std::string stereoMode = pItem->GetProperty("stereomode").asString();
5191 if (stereoMode.empty() && pItem->HasVideoInfoTag())
5192 stereoMode = CStereoscopicsManager::Get().NormalizeStereoMode(pItem->GetVideoInfoTag()->m_streamDetails.GetStereoMode());
5193 if (!stereoMode.empty() && stereoMode != "mono")
5201 void CGUIInfoManager::ResetCache()
5203 // reset any animation triggers as well
5204 m_containerMoves.clear();
5205 // mark our infobools as dirty
5206 CSingleLock lock(m_critInfo);
5207 for (vector<InfoPtr>::iterator i = m_bools.begin(); i != m_bools.end(); ++i)
5211 // Called from tuxbox service thread to update current status
5212 void CGUIInfoManager::UpdateFromTuxBox()
5214 if(g_tuxbox.vVideoSubChannel.mode)
5215 m_currentFile->GetVideoInfoTag()->m_strTitle = g_tuxbox.vVideoSubChannel.current_name;
5217 // Set m_currentMovieDuration
5218 if(!g_tuxbox.sCurSrvData.current_event_duration.empty() &&
5219 !g_tuxbox.sCurSrvData.next_event_description.empty() &&
5220 !g_tuxbox.sCurSrvData.current_event_duration.Equals("-") &&
5221 !g_tuxbox.sCurSrvData.next_event_description.Equals("-"))
5223 StringUtils::Replace(g_tuxbox.sCurSrvData.current_event_duration, "(","");
5224 StringUtils::Replace(g_tuxbox.sCurSrvData.current_event_duration, ")","");
5226 m_currentMovieDuration = StringUtils::Format("%s: %s %s (%s - %s)",
5227 g_localizeStrings.Get(180).c_str(),
5228 g_tuxbox.sCurSrvData.current_event_duration.c_str(),
5229 g_localizeStrings.Get(12391).c_str(),
5230 g_tuxbox.sCurSrvData.current_event_time.c_str(),
5231 g_tuxbox.sCurSrvData.next_event_time.c_str());
5235 if (!g_tuxbox.sCurSrvData.current_event_description.empty() &&
5236 !g_tuxbox.sCurSrvData.next_event_description.empty() &&
5237 !g_tuxbox.sCurSrvData.current_event_description.Equals("-") &&
5238 !g_tuxbox.sCurSrvData.next_event_description.Equals("-"))
5240 CStdString genre = StringUtils::Format("%s %s - (%s: %s)",
5241 g_localizeStrings.Get(143).c_str(),
5242 g_tuxbox.sCurSrvData.current_event_description.c_str(),
5243 g_localizeStrings.Get(209).c_str(),
5244 g_tuxbox.sCurSrvData.next_event_description.c_str());
5245 m_currentFile->GetVideoInfoTag()->m_genre = StringUtils::Split(genre, g_advancedSettings.m_videoItemSeparator);
5248 //Set m_currentMovie.m_director
5249 if (!g_tuxbox.sCurSrvData.current_event_details.Equals("-") &&
5250 !g_tuxbox.sCurSrvData.current_event_details.empty())
5252 m_currentFile->GetVideoInfoTag()->m_director = StringUtils::Split(g_tuxbox.sCurSrvData.current_event_details, g_advancedSettings.m_videoItemSeparator);
5256 CStdString CGUIInfoManager::GetPictureLabel(int info)
5258 if (info == SLIDE_FILE_NAME)
5259 return GetItemLabel(m_currentSlide, LISTITEM_FILENAME);
5260 else if (info == SLIDE_FILE_PATH)
5262 CStdString path = URIUtils::GetDirectory(m_currentSlide->GetPath());
5263 return CURL(path).GetWithoutUserDetails();
5265 else if (info == SLIDE_FILE_SIZE)
5266 return GetItemLabel(m_currentSlide, LISTITEM_SIZE);
5267 else if (info == SLIDE_FILE_DATE)
5268 return GetItemLabel(m_currentSlide, LISTITEM_DATE);
5269 else if (info == SLIDE_INDEX)
5271 CGUIWindowSlideShow *slideshow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
5272 if (slideshow && slideshow->NumSlides())
5274 return StringUtils::Format("%d/%d", slideshow->CurrentSlide(), slideshow->NumSlides());
5277 if (m_currentSlide->HasPictureInfoTag())
5278 return m_currentSlide->GetPictureInfoTag()->GetInfo(info);
5282 void CGUIInfoManager::SetCurrentSlide(CFileItem &item)
5284 if (m_currentSlide->GetPath() != item.GetPath())
5286 if (!item.GetPictureInfoTag()->Loaded()) // If picture metadata has not been loaded yet, load it now
5287 item.GetPictureInfoTag()->Load(item.GetPath());
5288 *m_currentSlide = item;
5292 void CGUIInfoManager::ResetCurrentSlide()
5294 m_currentSlide->Reset();
5297 bool CGUIInfoManager::CheckWindowCondition(CGUIWindow *window, int condition) const
5299 // check if it satisfies our condition
5300 if (!window) return false;
5301 if ((condition & WINDOW_CONDITION_HAS_LIST_ITEMS) && !window->HasListItems())
5303 if ((condition & WINDOW_CONDITION_IS_MEDIA_WINDOW) && !window->IsMediaWindow())
5308 CGUIWindow *CGUIInfoManager::GetWindowWithCondition(int contextWindow, int condition) const
5310 CGUIWindow *window = g_windowManager.GetWindow(contextWindow);
5311 if (CheckWindowCondition(window, condition))
5314 // try topmost dialog
5315 window = g_windowManager.GetWindow(g_windowManager.GetTopMostModalDialogID());
5316 if (CheckWindowCondition(window, condition))
5319 // try active window
5320 window = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
5321 if (CheckWindowCondition(window, condition))
5327 void CGUIInfoManager::SetCurrentVideoTag(const CVideoInfoTag &tag)
5329 *m_currentFile->GetVideoInfoTag() = tag;
5330 m_currentFile->m_lStartOffset = 0;
5333 void CGUIInfoManager::SetCurrentSongTag(const MUSIC_INFO::CMusicInfoTag &tag)
5335 //CLog::Log(LOGDEBUG, "Asked to SetCurrentTag");
5336 *m_currentFile->GetMusicInfoTag() = tag;
5337 m_currentFile->m_lStartOffset = 0;
5340 const CFileItem& CGUIInfoManager::GetCurrentSlide() const
5342 return *m_currentSlide;
5345 const MUSIC_INFO::CMusicInfoTag* CGUIInfoManager::GetCurrentSongTag() const
5347 if (m_currentFile->HasMusicInfoTag())
5348 return m_currentFile->GetMusicInfoTag();
5353 const CVideoInfoTag* CGUIInfoManager::GetCurrentMovieTag() const
5355 if (m_currentFile->HasVideoInfoTag())
5356 return m_currentFile->GetVideoInfoTag();
5361 void GUIInfo::SetInfoFlag(uint32_t flag)
5363 assert(flag >= (1 << 24));
5367 uint32_t GUIInfo::GetInfoFlag() const
5369 // we strip out the bottom 24 bits, where we keep data
5370 // and return the flag only
5371 return m_data1 & 0xff000000;
5374 uint32_t GUIInfo::GetData1() const
5376 // we strip out the top 8 bits, where we keep flags
5377 // and return the unflagged data
5378 return m_data1 & ((1 << 24) -1);
5381 int GUIInfo::GetData2() const
5386 void CGUIInfoManager::SetLibraryBool(int condition, bool value)
5390 case LIBRARY_HAS_MUSIC:
5391 m_libraryHasMusic = value ? 1 : 0;
5393 case LIBRARY_HAS_MOVIES:
5394 m_libraryHasMovies = value ? 1 : 0;
5396 case LIBRARY_HAS_MOVIE_SETS:
5397 m_libraryHasMovieSets = value ? 1 : 0;
5399 case LIBRARY_HAS_TVSHOWS:
5400 m_libraryHasTVShows = value ? 1 : 0;
5402 case LIBRARY_HAS_MUSICVIDEOS:
5403 m_libraryHasMusicVideos = value ? 1 : 0;
5410 void CGUIInfoManager::ResetLibraryBools()
5412 m_libraryHasMusic = -1;
5413 m_libraryHasMovies = -1;
5414 m_libraryHasTVShows = -1;
5415 m_libraryHasMusicVideos = -1;
5416 m_libraryHasMovieSets = -1;
5419 bool CGUIInfoManager::GetLibraryBool(int condition)
5421 if (condition == LIBRARY_HAS_MUSIC)
5423 if (m_libraryHasMusic < 0)
5428 m_libraryHasMusic = (db.GetSongsCount() > 0) ? 1 : 0;
5432 return m_libraryHasMusic > 0;
5434 else if (condition == LIBRARY_HAS_MOVIES)
5436 if (m_libraryHasMovies < 0)
5441 m_libraryHasMovies = db.HasContent(VIDEODB_CONTENT_MOVIES) ? 1 : 0;
5445 return m_libraryHasMovies > 0;
5447 else if (condition == LIBRARY_HAS_MOVIE_SETS)
5449 if (m_libraryHasMovieSets < 0)
5454 m_libraryHasMovieSets = db.HasSets() ? 1 : 0;
5458 return m_libraryHasMovieSets > 0;
5460 else if (condition == LIBRARY_HAS_TVSHOWS)
5462 if (m_libraryHasTVShows < 0)
5467 m_libraryHasTVShows = db.HasContent(VIDEODB_CONTENT_TVSHOWS) ? 1 : 0;
5471 return m_libraryHasTVShows > 0;
5473 else if (condition == LIBRARY_HAS_MUSICVIDEOS)
5475 if (m_libraryHasMusicVideos < 0)
5480 m_libraryHasMusicVideos = db.HasContent(VIDEODB_CONTENT_MUSICVIDEOS) ? 1 : 0;
5484 return m_libraryHasMusicVideos > 0;
5486 else if (condition == LIBRARY_HAS_VIDEO)
5488 return (GetLibraryBool(LIBRARY_HAS_MOVIES) ||
5489 GetLibraryBool(LIBRARY_HAS_TVSHOWS) ||
5490 GetLibraryBool(LIBRARY_HAS_MUSICVIDEOS));
5495 int CGUIInfoManager::RegisterSkinVariableString(const CSkinVariableString* info)
5500 CSingleLock lock(m_critInfo);
5501 m_skinVariableStrings.push_back(*info);
5503 return CONDITIONAL_LABEL_START + m_skinVariableStrings.size() - 1;
5506 int CGUIInfoManager::TranslateSkinVariableString(const CStdString& name, int context)
5508 for (vector<CSkinVariableString>::const_iterator it = m_skinVariableStrings.begin();
5509 it != m_skinVariableStrings.end(); ++it)
5511 if (it->GetName().Equals(name) && it->GetContext() == context)
5512 return it - m_skinVariableStrings.begin() + CONDITIONAL_LABEL_START;
5517 CStdString CGUIInfoManager::GetSkinVariableString(int info,
5518 bool preferImage /*= false*/,
5519 const CGUIListItem *item /*= NULL*/)
5521 info -= CONDITIONAL_LABEL_START;
5522 if (info >= 0 && info < (int)m_skinVariableStrings.size())
5523 return m_skinVariableStrings[info].GetValue(preferImage, item);
5528 bool CGUIInfoManager::ConditionsChangedValues(const std::map<INFO::InfoPtr, bool>& map)
5530 for (std::map<INFO::InfoPtr, bool>::const_iterator it = map.begin() ; it != map.end() ; it++)
5532 if (it->first->Get() != it->second)
5538 bool CGUIInfoManager::GetEpgInfoTag(CEpgInfoTag& tag) const
5540 if (m_currentFile->HasEPGInfoTag())
5542 CEpgInfoTag* currentTag = m_currentFile->GetEPGInfoTag();
5543 while (currentTag && !currentTag->IsActive())
5544 currentTag = currentTag->GetNextEvent().get();