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 "GUIInfoManager.h"
24 #include "windows/GUIMediaWindow.h"
25 #include "dialogs/GUIDialogProgress.h"
26 #include "Application.h"
28 #include "utils/URIUtils.h"
29 #include "utils/Weather.h"
30 #include "PartyModeManager.h"
31 #include "addons/Visualisation.h"
32 #include "input/ButtonTranslator.h"
33 #include "utils/AlarmClock.h"
35 #include "utils/SystemInfo.h"
36 #include "guilib/GUITextBox.h"
37 #include "pictures/GUIWindowSlideShow.h"
38 #include "pictures/PictureInfoTag.h"
39 #include "music/tags/MusicInfoTag.h"
40 #include "guilib/GUIWindowManager.h"
41 #include "playlists/PlayList.h"
42 #include "profiles/ProfilesManager.h"
43 #include "utils/TuxBoxUtil.h"
44 #include "windowing/WindowingFactory.h"
45 #include "powermanagement/PowerManager.h"
46 #include "settings/AdvancedSettings.h"
47 #include "settings/DisplaySettings.h"
48 #include "settings/MediaSettings.h"
49 #include "settings/Settings.h"
50 #include "settings/SkinSettings.h"
51 #include "guilib/LocalizeStrings.h"
52 #include "utils/CharsetConverter.h"
53 #include "utils/CPUInfo.h"
54 #include "utils/StringUtils.h"
55 #include "utils/MathUtils.h"
56 #include "utils/SeekHandler.h"
58 #include "addons/Skin.h"
60 // stuff for current song
61 #include "music/MusicInfoLoader.h"
63 #include "GUIUserMessages.h"
64 #include "video/dialogs/GUIDialogVideoInfo.h"
65 #include "music/dialogs/GUIDialogMusicInfo.h"
66 #include "storage/MediaManager.h"
67 #include "utils/TimeUtils.h"
68 #include "threads/SingleLock.h"
69 #include "utils/log.h"
71 #include "pvr/PVRManager.h"
72 #include "pvr/channels/PVRChannelGroupsContainer.h"
73 #include "epg/EpgInfoTag.h"
74 #include "pvr/timers/PVRTimers.h"
75 #include "pvr/recordings/PVRRecording.h"
77 #include "addons/AddonManager.h"
78 #include "interfaces/info/InfoBool.h"
79 #include "video/VideoThumbLoader.h"
80 #include "music/MusicThumbLoader.h"
81 #include "video/VideoDatabase.h"
82 #include "cores/IPlayer.h"
83 #include "cores/AudioEngine/Utils/AEUtil.h"
85 #define SYSHEATUPDATEINTERVAL 60000
88 using namespace XFILE;
89 using namespace MUSIC_INFO;
90 using namespace ADDON;
95 CGUIInfoManager::CGUIInfoManager(void) :
98 m_lastSysHeatInfoTime = -SYSHEATUPDATEINTERVAL; // make sure we grab CPU temp on the first pass
99 m_lastMusicBitrateTime = 0;
101 m_AfterSeekTimeout = 0;
103 m_playerSeeking = false;
104 m_performingSeek = false;
105 m_nextWindowID = WINDOW_INVALID;
106 m_prevWindowID = WINDOW_INVALID;
107 m_stringParameters.push_back("__ZZZZ__"); // to offset the string parameters by 1 to assure that all entries are non-zero
108 m_currentFile = new CFileItem;
109 m_currentSlide = new CFileItem;
114 m_playerShowTime = false;
115 m_playerShowCodec = false;
116 m_playerShowInfo = false;
121 CGUIInfoManager::~CGUIInfoManager(void)
123 delete m_currentFile;
124 delete m_currentSlide;
127 bool CGUIInfoManager::OnMessage(CGUIMessage &message)
129 if (message.GetMessage() == GUI_MSG_NOTIFY_ALL)
131 if (message.GetParam1() == GUI_MSG_UPDATE_ITEM && message.GetItem())
133 CFileItemPtr item = boost::static_pointer_cast<CFileItem>(message.GetItem());
134 if (m_currentFile->IsSamePath(item.get()))
136 m_currentFile->UpdateInfo(*item);
144 /// \brief Translates a string as given by the skin into an int that we use for more
145 /// efficient retrieval of data. Can handle combined strings on the form
146 /// Player.Caching + VideoPlayer.IsFullscreen (Logical and)
147 /// Player.HasVideo | Player.HasAudio (Logical or)
148 int CGUIInfoManager::TranslateString(const CStdString &condition)
150 // translate $LOCALIZE as required
151 CStdString strCondition(CGUIInfoLabel::ReplaceLocalize(condition));
152 return TranslateSingleString(strCondition);
161 const infomap player_labels[] = {{ "hasmedia", PLAYER_HAS_MEDIA }, // bools from here
162 { "hasaudio", PLAYER_HAS_AUDIO },
163 { "hasvideo", PLAYER_HAS_VIDEO },
164 { "playing", PLAYER_PLAYING },
165 { "paused", PLAYER_PAUSED },
166 { "rewinding", PLAYER_REWINDING },
167 { "forwarding", PLAYER_FORWARDING },
168 { "rewinding2x", PLAYER_REWINDING_2x },
169 { "rewinding4x", PLAYER_REWINDING_4x },
170 { "rewinding8x", PLAYER_REWINDING_8x },
171 { "rewinding16x", PLAYER_REWINDING_16x },
172 { "rewinding32x", PLAYER_REWINDING_32x },
173 { "forwarding2x", PLAYER_FORWARDING_2x },
174 { "forwarding4x", PLAYER_FORWARDING_4x },
175 { "forwarding8x", PLAYER_FORWARDING_8x },
176 { "forwarding16x", PLAYER_FORWARDING_16x },
177 { "forwarding32x", PLAYER_FORWARDING_32x },
178 { "canrecord", PLAYER_CAN_RECORD },
179 { "recording", PLAYER_RECORDING },
180 { "displayafterseek", PLAYER_DISPLAY_AFTER_SEEK },
181 { "caching", PLAYER_CACHING },
182 { "seekbar", PLAYER_SEEKBAR },
183 { "seeking", PLAYER_SEEKING },
184 { "showtime", PLAYER_SHOWTIME },
185 { "showcodec", PLAYER_SHOWCODEC },
186 { "showinfo", PLAYER_SHOWINFO },
187 { "title", PLAYER_TITLE },
188 { "muted", PLAYER_MUTED },
189 { "hasduration", PLAYER_HASDURATION },
190 { "passthrough", PLAYER_PASSTHROUGH },
191 { "cachelevel", PLAYER_CACHELEVEL }, // labels from here
192 { "progress", PLAYER_PROGRESS },
193 { "progresscache", PLAYER_PROGRESS_CACHE },
194 { "volume", PLAYER_VOLUME },
195 { "subtitledelay", PLAYER_SUBTITLE_DELAY },
196 { "audiodelay", PLAYER_AUDIO_DELAY },
197 { "chapter", PLAYER_CHAPTER },
198 { "chaptercount", PLAYER_CHAPTERCOUNT },
199 { "chaptername", PLAYER_CHAPTERNAME },
200 { "starrating", PLAYER_STAR_RATING },
201 { "folderpath", PLAYER_PATH },
202 { "filenameandpath", PLAYER_FILEPATH },
203 { "pauseenabled", PLAYER_CAN_PAUSE },
204 { "seekenabled", PLAYER_CAN_SEEK }};
206 const infomap player_param[] = {{ "art", PLAYER_ITEM_ART }};
208 const infomap player_times[] = {{ "seektime", PLAYER_SEEKTIME },
209 { "seekoffset", PLAYER_SEEKOFFSET },
210 { "timeremaining", PLAYER_TIME_REMAINING },
211 { "timespeed", PLAYER_TIME_SPEED },
212 { "time", PLAYER_TIME },
213 { "duration", PLAYER_DURATION },
214 { "finishtime", PLAYER_FINISH_TIME },
215 { "starttime", PLAYER_START_TIME}};
217 const infomap weather[] = {{ "isfetched", WEATHER_IS_FETCHED },
218 { "conditions", WEATHER_CONDITIONS }, // labels from here
219 { "temperature", WEATHER_TEMPERATURE },
220 { "location", WEATHER_LOCATION },
221 { "fanartcode", WEATHER_FANART_CODE },
222 { "plugin", WEATHER_PLUGIN }};
224 const infomap system_labels[] = {{ "hasnetwork", SYSTEM_ETHERNET_LINK_ACTIVE },
225 { "hasmediadvd", SYSTEM_MEDIA_DVD },
226 { "dvdready", SYSTEM_DVDREADY },
227 { "trayopen", SYSTEM_TRAYOPEN },
228 { "haslocks", SYSTEM_HASLOCKS },
229 { "hasloginscreen", SYSTEM_HAS_LOGINSCREEN },
230 { "ismaster", SYSTEM_ISMASTER },
231 { "isfullscreen", SYSTEM_ISFULLSCREEN },
232 { "isstandalone", SYSTEM_ISSTANDALONE },
233 { "loggedon", SYSTEM_LOGGEDON },
234 { "showexitbutton", SYSTEM_SHOW_EXIT_BUTTON },
235 { "canpowerdown", SYSTEM_CAN_POWERDOWN },
236 { "cansuspend", SYSTEM_CAN_SUSPEND },
237 { "canhibernate", SYSTEM_CAN_HIBERNATE },
238 { "canreboot", SYSTEM_CAN_REBOOT },
239 { "screensaveractive",SYSTEM_SCREENSAVER_ACTIVE },
240 { "cputemperature", SYSTEM_CPU_TEMPERATURE }, // labels from here
241 { "cpuusage", SYSTEM_CPU_USAGE },
242 { "gputemperature", SYSTEM_GPU_TEMPERATURE },
243 { "fanspeed", SYSTEM_FAN_SPEED },
244 { "freespace", SYSTEM_FREE_SPACE },
245 { "usedspace", SYSTEM_USED_SPACE },
246 { "totalspace", SYSTEM_TOTAL_SPACE },
247 { "usedspacepercent", SYSTEM_USED_SPACE_PERCENT },
248 { "freespacepercent", SYSTEM_FREE_SPACE_PERCENT },
249 { "buildversion", SYSTEM_BUILD_VERSION },
250 { "builddate", SYSTEM_BUILD_DATE },
251 { "fps", SYSTEM_FPS },
252 { "dvdtraystate", SYSTEM_DVD_TRAY_STATE },
253 { "freememory", SYSTEM_FREE_MEMORY },
254 { "language", SYSTEM_LANGUAGE },
255 { "temperatureunits", SYSTEM_TEMPERATURE_UNITS },
256 { "screenmode", SYSTEM_SCREEN_MODE },
257 { "screenwidth", SYSTEM_SCREEN_WIDTH },
258 { "screenheight", SYSTEM_SCREEN_HEIGHT },
259 { "currentwindow", SYSTEM_CURRENT_WINDOW },
260 { "currentcontrol", SYSTEM_CURRENT_CONTROL },
261 { "dvdlabel", SYSTEM_DVD_LABEL },
262 { "internetstate", SYSTEM_INTERNET_STATE },
263 { "kernelversion", SYSTEM_KERNEL_VERSION },
264 { "uptime", SYSTEM_UPTIME },
265 { "totaluptime", SYSTEM_TOTALUPTIME },
266 { "cpufrequency", SYSTEM_CPUFREQUENCY },
267 { "screenresolution", SYSTEM_SCREEN_RESOLUTION },
268 { "videoencoderinfo", SYSTEM_VIDEO_ENCODER_INFO },
269 { "profilename", SYSTEM_PROFILENAME },
270 { "profilethumb", SYSTEM_PROFILETHUMB },
271 { "profilecount", SYSTEM_PROFILECOUNT },
272 { "progressbar", SYSTEM_PROGRESS_BAR },
273 { "batterylevel", SYSTEM_BATTERY_LEVEL },
274 { "friendlyname", SYSTEM_FRIENDLY_NAME },
275 { "alarmpos", SYSTEM_ALARM_POS },
276 { "isinhibit", SYSTEM_ISINHIBIT },
277 { "hasshutdown", SYSTEM_HAS_SHUTDOWN },
278 { "haspvr", SYSTEM_HAS_PVR }};
280 const infomap system_param[] = {{ "hasalarm", SYSTEM_HAS_ALARM },
281 { "hascoreid", SYSTEM_HAS_CORE_ID },
282 { "setting", SYSTEM_SETTING },
283 { "hasaddon", SYSTEM_HAS_ADDON },
284 { "coreusage", SYSTEM_GET_CORE_USAGE }};
286 const infomap network_labels[] = {{ "isdhcp", NETWORK_IS_DHCP },
287 { "ipaddress", NETWORK_IP_ADDRESS }, //labels from here
288 { "linkstate", NETWORK_LINK_STATE },
289 { "macaddress", NETWORK_MAC_ADDRESS },
290 { "subnetaddress", NETWORK_SUBNET_MASK }, //subnetaddress is misleading/wrong. should be deprecated. use subnetmask in stead
291 { "subnetmask", NETWORK_SUBNET_MASK },
292 { "gatewayaddress", NETWORK_GATEWAY_ADDRESS },
293 { "dns1address", NETWORK_DNS1_ADDRESS },
294 { "dns2address", NETWORK_DNS2_ADDRESS },
295 { "dhcpaddress", NETWORK_DHCP_ADDRESS }};
297 const infomap musicpartymode[] = {{ "enabled", MUSICPM_ENABLED },
298 { "songsplayed", MUSICPM_SONGSPLAYED },
299 { "matchingsongs", MUSICPM_MATCHINGSONGS },
300 { "matchingsongspicked", MUSICPM_MATCHINGSONGSPICKED },
301 { "matchingsongsleft", MUSICPM_MATCHINGSONGSLEFT },
302 { "relaxedsongspicked",MUSICPM_RELAXEDSONGSPICKED },
303 { "randomsongspicked", MUSICPM_RANDOMSONGSPICKED }};
305 const infomap musicplayer[] = {{ "title", MUSICPLAYER_TITLE },
306 { "album", MUSICPLAYER_ALBUM },
307 { "artist", MUSICPLAYER_ARTIST },
308 { "albumartist", MUSICPLAYER_ALBUM_ARTIST },
309 { "year", MUSICPLAYER_YEAR },
310 { "genre", MUSICPLAYER_GENRE },
311 { "duration", MUSICPLAYER_DURATION },
312 { "tracknumber", MUSICPLAYER_TRACK_NUMBER },
313 { "cover", MUSICPLAYER_COVER },
314 { "bitrate", MUSICPLAYER_BITRATE },
315 { "playlistlength", MUSICPLAYER_PLAYLISTLEN },
316 { "playlistposition", MUSICPLAYER_PLAYLISTPOS },
317 { "channels", MUSICPLAYER_CHANNELS },
318 { "bitspersample", MUSICPLAYER_BITSPERSAMPLE },
319 { "samplerate", MUSICPLAYER_SAMPLERATE },
320 { "codec", MUSICPLAYER_CODEC },
321 { "discnumber", MUSICPLAYER_DISC_NUMBER },
322 { "rating", MUSICPLAYER_RATING },
323 { "comment", MUSICPLAYER_COMMENT },
324 { "lyrics", MUSICPLAYER_LYRICS },
325 { "playlistplaying", MUSICPLAYER_PLAYLISTPLAYING },
326 { "exists", MUSICPLAYER_EXISTS },
327 { "hasprevious", MUSICPLAYER_HASPREVIOUS },
328 { "hasnext", MUSICPLAYER_HASNEXT },
329 { "playcount", MUSICPLAYER_PLAYCOUNT },
330 { "lastplayed", MUSICPLAYER_LASTPLAYED },
331 { "channelname", MUSICPLAYER_CHANNEL_NAME },
332 { "channelnumber", MUSICPLAYER_CHANNEL_NUMBER },
333 { "channelgroup", MUSICPLAYER_CHANNEL_GROUP }
336 const infomap videoplayer[] = {{ "title", VIDEOPLAYER_TITLE },
337 { "genre", VIDEOPLAYER_GENRE },
338 { "country", VIDEOPLAYER_COUNTRY },
339 { "originaltitle", VIDEOPLAYER_ORIGINALTITLE },
340 { "director", VIDEOPLAYER_DIRECTOR },
341 { "year", VIDEOPLAYER_YEAR },
342 { "cover", VIDEOPLAYER_COVER },
343 { "usingoverlays", VIDEOPLAYER_USING_OVERLAYS },
344 { "isfullscreen", VIDEOPLAYER_ISFULLSCREEN },
345 { "hasmenu", VIDEOPLAYER_HASMENU },
346 { "playlistlength", VIDEOPLAYER_PLAYLISTLEN },
347 { "playlistposition", VIDEOPLAYER_PLAYLISTPOS },
348 { "plot", VIDEOPLAYER_PLOT },
349 { "plotoutline", VIDEOPLAYER_PLOT_OUTLINE },
350 { "episode", VIDEOPLAYER_EPISODE },
351 { "season", VIDEOPLAYER_SEASON },
352 { "rating", VIDEOPLAYER_RATING },
353 { "ratingandvotes", VIDEOPLAYER_RATING_AND_VOTES },
354 { "tvshowtitle", VIDEOPLAYER_TVSHOW },
355 { "premiered", VIDEOPLAYER_PREMIERED },
356 { "studio", VIDEOPLAYER_STUDIO },
357 { "mpaa", VIDEOPLAYER_MPAA },
358 { "top250", VIDEOPLAYER_TOP250 },
359 { "cast", VIDEOPLAYER_CAST },
360 { "castandrole", VIDEOPLAYER_CAST_AND_ROLE },
361 { "artist", VIDEOPLAYER_ARTIST },
362 { "album", VIDEOPLAYER_ALBUM },
363 { "writer", VIDEOPLAYER_WRITER },
364 { "tagline", VIDEOPLAYER_TAGLINE },
365 { "hasinfo", VIDEOPLAYER_HAS_INFO },
366 { "trailer", VIDEOPLAYER_TRAILER },
367 { "videocodec", VIDEOPLAYER_VIDEO_CODEC },
368 { "videoresolution", VIDEOPLAYER_VIDEO_RESOLUTION },
369 { "videoaspect", VIDEOPLAYER_VIDEO_ASPECT },
370 { "audiocodec", VIDEOPLAYER_AUDIO_CODEC },
371 { "audiochannels", VIDEOPLAYER_AUDIO_CHANNELS },
372 { "hasteletext", VIDEOPLAYER_HASTELETEXT },
373 { "lastplayed", VIDEOPLAYER_LASTPLAYED },
374 { "playcount", VIDEOPLAYER_PLAYCOUNT },
375 { "hassubtitles", VIDEOPLAYER_HASSUBTITLES },
376 { "subtitlesenabled", VIDEOPLAYER_SUBTITLESENABLED },
377 { "endtime", VIDEOPLAYER_ENDTIME },
378 { "nexttitle", VIDEOPLAYER_NEXT_TITLE },
379 { "nextgenre", VIDEOPLAYER_NEXT_GENRE },
380 { "nextplot", VIDEOPLAYER_NEXT_PLOT },
381 { "nextplotoutline", VIDEOPLAYER_NEXT_PLOT_OUTLINE },
382 { "nextstarttime", VIDEOPLAYER_NEXT_STARTTIME },
383 { "nextendtime", VIDEOPLAYER_NEXT_ENDTIME },
384 { "nextduration", VIDEOPLAYER_NEXT_DURATION },
385 { "channelname", VIDEOPLAYER_CHANNEL_NAME },
386 { "channelnumber", VIDEOPLAYER_CHANNEL_NUMBER },
387 { "channelgroup", VIDEOPLAYER_CHANNEL_GROUP },
388 { "hasepg", VIDEOPLAYER_HAS_EPG },
389 { "parentalrating", VIDEOPLAYER_PARENTAL_RATING }};
391 const infomap mediacontainer[] = {{ "hasfiles", CONTAINER_HASFILES },
392 { "hasfolders", CONTAINER_HASFOLDERS },
393 { "isstacked", CONTAINER_STACKED },
394 { "folderthumb", CONTAINER_FOLDERTHUMB },
395 { "tvshowthumb", CONTAINER_TVSHOWTHUMB },
396 { "seasonthumb", CONTAINER_SEASONTHUMB },
397 { "folderpath", CONTAINER_FOLDERPATH },
398 { "foldername", CONTAINER_FOLDERNAME },
399 { "pluginname", CONTAINER_PLUGINNAME },
400 { "viewmode", CONTAINER_VIEWMODE },
401 { "totaltime", CONTAINER_TOTALTIME },
402 { "hasthumb", CONTAINER_HAS_THUMB },
403 { "sortmethod", CONTAINER_SORT_METHOD },
404 { "showplot", CONTAINER_SHOWPLOT }};
406 const infomap container_bools[] ={{ "onnext", CONTAINER_MOVE_NEXT },
407 { "onprevious", CONTAINER_MOVE_PREVIOUS },
408 { "onscrollnext", CONTAINER_SCROLL_NEXT },
409 { "onscrollprevious", CONTAINER_SCROLL_PREVIOUS },
410 { "numpages", CONTAINER_NUM_PAGES },
411 { "numitems", CONTAINER_NUM_ITEMS },
412 { "currentpage", CONTAINER_CURRENT_PAGE },
413 { "scrolling", CONTAINER_SCROLLING },
414 { "hasnext", CONTAINER_HAS_NEXT },
415 { "hasprevious", CONTAINER_HAS_PREVIOUS },
416 { "canfilter", CONTAINER_CAN_FILTER },
417 { "canfilteradvanced",CONTAINER_CAN_FILTERADVANCED },
418 { "filtered", CONTAINER_FILTERED }};
420 const infomap container_ints[] = {{ "row", CONTAINER_ROW },
421 { "column", CONTAINER_COLUMN },
422 { "position", CONTAINER_POSITION },
423 { "subitem", CONTAINER_SUBITEM },
424 { "hasfocus", CONTAINER_HAS_FOCUS }};
426 const infomap container_str[] = {{ "property", CONTAINER_PROPERTY },
427 { "content", CONTAINER_CONTENT }};
429 const infomap listitem_labels[]= {{ "thumb", LISTITEM_THUMB },
430 { "icon", LISTITEM_ICON },
431 { "actualicon", LISTITEM_ACTUAL_ICON },
432 { "overlay", LISTITEM_OVERLAY },
433 { "label", LISTITEM_LABEL },
434 { "label2", LISTITEM_LABEL2 },
435 { "title", LISTITEM_TITLE },
436 { "tracknumber", LISTITEM_TRACKNUMBER },
437 { "artist", LISTITEM_ARTIST },
438 { "album", LISTITEM_ALBUM },
439 { "albumartist", LISTITEM_ALBUM_ARTIST },
440 { "year", LISTITEM_YEAR },
441 { "genre", LISTITEM_GENRE },
442 { "director", LISTITEM_DIRECTOR },
443 { "filename", LISTITEM_FILENAME },
444 { "filenameandpath", LISTITEM_FILENAME_AND_PATH },
445 { "fileextension", LISTITEM_FILE_EXTENSION },
446 { "date", LISTITEM_DATE },
447 { "size", LISTITEM_SIZE },
448 { "rating", LISTITEM_RATING },
449 { "ratingandvotes", LISTITEM_RATING_AND_VOTES },
450 { "programcount", LISTITEM_PROGRAM_COUNT },
451 { "duration", LISTITEM_DURATION },
452 { "isselected", LISTITEM_ISSELECTED },
453 { "isplaying", LISTITEM_ISPLAYING },
454 { "plot", LISTITEM_PLOT },
455 { "plotoutline", LISTITEM_PLOT_OUTLINE },
456 { "episode", LISTITEM_EPISODE },
457 { "season", LISTITEM_SEASON },
458 { "tvshowtitle", LISTITEM_TVSHOW },
459 { "premiered", LISTITEM_PREMIERED },
460 { "comment", LISTITEM_COMMENT },
461 { "path", LISTITEM_PATH },
462 { "foldername", LISTITEM_FOLDERNAME },
463 { "folderpath", LISTITEM_FOLDERPATH },
464 { "picturepath", LISTITEM_PICTURE_PATH },
465 { "pictureresolution",LISTITEM_PICTURE_RESOLUTION },
466 { "picturedatetime", LISTITEM_PICTURE_DATETIME },
467 { "picturecomment", LISTITEM_PICTURE_COMMENT },
468 { "picturecaption", LISTITEM_PICTURE_CAPTION },
469 { "picturedesc", LISTITEM_PICTURE_DESC },
470 { "picturekeywords", LISTITEM_PICTURE_KEYWORDS },
471 { "picturecammake", LISTITEM_PICTURE_CAM_MAKE },
472 { "picturecammodel", LISTITEM_PICTURE_CAM_MODEL },
473 { "pictureaperture", LISTITEM_PICTURE_APERTURE },
474 { "picturefocallen", LISTITEM_PICTURE_FOCAL_LEN },
475 { "picturefocusdist", LISTITEM_PICTURE_FOCUS_DIST },
476 { "pictureexpmode", LISTITEM_PICTURE_EXP_MODE },
477 { "pictureexptime", LISTITEM_PICTURE_EXP_TIME },
478 { "pictureiso", LISTITEM_PICTURE_ISO },
479 { "picturegpslat", LISTITEM_PICTURE_GPS_LAT },
480 { "picturegpslon", LISTITEM_PICTURE_GPS_LON },
481 { "picturegpsalt", LISTITEM_PICTURE_GPS_ALT },
482 { "studio", LISTITEM_STUDIO },
483 { "country", LISTITEM_COUNTRY },
484 { "mpaa", LISTITEM_MPAA },
485 { "cast", LISTITEM_CAST },
486 { "castandrole", LISTITEM_CAST_AND_ROLE },
487 { "writer", LISTITEM_WRITER },
488 { "tagline", LISTITEM_TAGLINE },
489 { "top250", LISTITEM_TOP250 },
490 { "trailer", LISTITEM_TRAILER },
491 { "starrating", LISTITEM_STAR_RATING },
492 { "sortletter", LISTITEM_SORT_LETTER },
493 { "videocodec", LISTITEM_VIDEO_CODEC },
494 { "videoresolution", LISTITEM_VIDEO_RESOLUTION },
495 { "videoaspect", LISTITEM_VIDEO_ASPECT },
496 { "audiocodec", LISTITEM_AUDIO_CODEC },
497 { "audiochannels", LISTITEM_AUDIO_CHANNELS },
498 { "audiolanguage", LISTITEM_AUDIO_LANGUAGE },
499 { "subtitlelanguage", LISTITEM_SUBTITLE_LANGUAGE },
500 { "isresumable", LISTITEM_IS_RESUMABLE},
501 { "percentplayed", LISTITEM_PERCENT_PLAYED},
502 { "isfolder", LISTITEM_IS_FOLDER },
503 { "originaltitle", LISTITEM_ORIGINALTITLE },
504 { "lastplayed", LISTITEM_LASTPLAYED },
505 { "playcount", LISTITEM_PLAYCOUNT },
506 { "discnumber", LISTITEM_DISC_NUMBER },
507 { "starttime", LISTITEM_STARTTIME },
508 { "endtime", LISTITEM_ENDTIME },
509 { "startdate", LISTITEM_STARTDATE },
510 { "enddate", LISTITEM_ENDDATE },
511 { "nexttitle", LISTITEM_NEXT_TITLE },
512 { "nextgenre", LISTITEM_NEXT_GENRE },
513 { "nextplot", LISTITEM_NEXT_PLOT },
514 { "nextplotoutline", LISTITEM_NEXT_PLOT_OUTLINE },
515 { "nextstarttime", LISTITEM_NEXT_STARTTIME },
516 { "nextendtime", LISTITEM_NEXT_ENDTIME },
517 { "nextstartdate", LISTITEM_NEXT_STARTDATE },
518 { "nextenddate", LISTITEM_NEXT_ENDDATE },
519 { "channelname", LISTITEM_CHANNEL_NAME },
520 { "channelnumber", LISTITEM_CHANNEL_NUMBER },
521 { "channelgroup", LISTITEM_CHANNEL_GROUP },
522 { "hasepg", LISTITEM_HAS_EPG },
523 { "hastimer", LISTITEM_HASTIMER },
524 { "isrecording", LISTITEM_ISRECORDING },
525 { "isencrypted", LISTITEM_ISENCRYPTED },
526 { "progress", LISTITEM_PROGRESS },
527 { "dateadded", LISTITEM_DATE_ADDED },
528 { "dbtype", LISTITEM_DBTYPE },
529 { "dbid", LISTITEM_DBID }};
531 const infomap visualisation[] = {{ "locked", VISUALISATION_LOCKED },
532 { "preset", VISUALISATION_PRESET },
533 { "name", VISUALISATION_NAME },
534 { "enabled", VISUALISATION_ENABLED }};
536 const infomap fanart_labels[] = {{ "color1", FANART_COLOR1 },
537 { "color2", FANART_COLOR2 },
538 { "color3", FANART_COLOR3 },
539 { "image", FANART_IMAGE }};
541 const infomap skin_labels[] = {{ "currenttheme", SKIN_THEME },
542 { "currentcolourtheme",SKIN_COLOUR_THEME },
543 {"hasvideooverlay", SKIN_HAS_VIDEO_OVERLAY},
544 {"hasmusicoverlay", SKIN_HAS_MUSIC_OVERLAY},
545 {"aspectratio", SKIN_ASPECT_RATIO}};
547 const infomap window_bools[] = {{ "ismedia", WINDOW_IS_MEDIA },
548 { "isactive", WINDOW_IS_ACTIVE },
549 { "istopmost", WINDOW_IS_TOPMOST },
550 { "isvisible", WINDOW_IS_VISIBLE },
551 { "previous", WINDOW_PREVIOUS },
552 { "next", WINDOW_NEXT }};
554 const infomap control_labels[] = {{ "hasfocus", CONTROL_HAS_FOCUS },
555 { "isvisible", CONTROL_IS_VISIBLE },
556 { "isenabled", CONTROL_IS_ENABLED },
557 { "getlabel", CONTROL_GET_LABEL }};
559 const infomap playlist[] = {{ "length", PLAYLIST_LENGTH },
560 { "position", PLAYLIST_POSITION },
561 { "random", PLAYLIST_RANDOM },
562 { "repeat", PLAYLIST_REPEAT },
563 { "israndom", PLAYLIST_ISRANDOM },
564 { "isrepeat", PLAYLIST_ISREPEAT },
565 { "isrepeatone", PLAYLIST_ISREPEATONE }};
567 const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING },
568 { "hastimer", PVR_HAS_TIMER },
569 { "hasnonrecordingtimer", PVR_HAS_NONRECORDING_TIMER },
570 { "nowrecordingtitle", PVR_NOW_RECORDING_TITLE },
571 { "nowrecordingdatetime", PVR_NOW_RECORDING_DATETIME },
572 { "nowrecordingchannel", PVR_NOW_RECORDING_CHANNEL },
573 { "nowrecordingchannelicon", PVR_NOW_RECORDING_CHAN_ICO },
574 { "nextrecordingtitle", PVR_NEXT_RECORDING_TITLE },
575 { "nextrecordingdatetime", PVR_NEXT_RECORDING_DATETIME },
576 { "nextrecordingchannel", PVR_NEXT_RECORDING_CHANNEL },
577 { "nextrecordingchannelicon", PVR_NEXT_RECORDING_CHAN_ICO },
578 { "backendname", PVR_BACKEND_NAME },
579 { "backendversion", PVR_BACKEND_VERSION },
580 { "backendhost", PVR_BACKEND_HOST },
581 { "backenddiskspace", PVR_BACKEND_DISKSPACE },
582 { "backendchannels", PVR_BACKEND_CHANNELS },
583 { "backendtimers", PVR_BACKEND_TIMERS },
584 { "backendrecordings", PVR_BACKEND_RECORDINGS },
585 { "backendnumber", PVR_BACKEND_NUMBER },
586 { "hasepg", PVR_HAS_EPG },
587 { "hastxt", PVR_HAS_TXT },
588 { "hasdirector", PVR_HAS_DIRECTOR },
589 { "totaldiscspace", PVR_TOTAL_DISKSPACE },
590 { "nexttimer", PVR_NEXT_TIMER },
591 { "isplayingtv", PVR_IS_PLAYING_TV },
592 { "isplayingradio", PVR_IS_PLAYING_RADIO },
593 { "isplayingrecording", PVR_IS_PLAYING_RECORDING },
594 { "duration", PVR_PLAYING_DURATION },
595 { "time", PVR_PLAYING_TIME },
596 { "progress", PVR_PLAYING_PROGRESS },
597 { "actstreamclient", PVR_ACTUAL_STREAM_CLIENT },
598 { "actstreamdevice", PVR_ACTUAL_STREAM_DEVICE },
599 { "actstreamstatus", PVR_ACTUAL_STREAM_STATUS },
600 { "actstreamsignal", PVR_ACTUAL_STREAM_SIG },
601 { "actstreamsnr", PVR_ACTUAL_STREAM_SNR },
602 { "actstreamber", PVR_ACTUAL_STREAM_BER },
603 { "actstreamunc", PVR_ACTUAL_STREAM_UNC },
604 { "actstreamvideobitrate", PVR_ACTUAL_STREAM_VIDEO_BR },
605 { "actstreamaudiobitrate", PVR_ACTUAL_STREAM_AUDIO_BR },
606 { "actstreamdolbybitrate", PVR_ACTUAL_STREAM_DOLBY_BR },
607 { "actstreamprogrsignal", PVR_ACTUAL_STREAM_SIG_PROGR },
608 { "actstreamprogrsnr", PVR_ACTUAL_STREAM_SNR_PROGR },
609 { "actstreamisencrypted", PVR_ACTUAL_STREAM_ENCRYPTED },
610 { "actstreamencryptionname", PVR_ACTUAL_STREAM_CRYPTION }};
612 const infomap slideshow[] = {{ "ispaused", SLIDESHOW_ISPAUSED },
613 { "isactive", SLIDESHOW_ISACTIVE },
614 { "israndom", SLIDESHOW_ISRANDOM }};
616 const int picture_slide_map[] = {/* LISTITEM_PICTURE_RESOLUTION => */ SLIDE_RESOLUTION,
617 /* LISTITEM_PICTURE_DATE => */ SLIDE_EXIF_DATE,
618 /* LISTITEM_PICTURE_DATETIME => */ SLIDE_EXIF_DATE_TIME,
619 /* LISTITEM_PICTURE_COMMENT => */ SLIDE_COMMENT,
620 /* LISTITEM_PICTURE_CAPTION => */ SLIDE_IPTC_CAPTION,
621 /* LISTITEM_PICTURE_DESC => */ SLIDE_EXIF_DESCRIPTION,
622 /* LISTITEM_PICTURE_KEYWORDS => */ SLIDE_IPTC_KEYWORDS,
623 /* LISTITEM_PICTURE_CAM_MAKE => */ SLIDE_EXIF_CAMERA_MAKE,
624 /* LISTITEM_PICTURE_CAM_MODEL => */ SLIDE_EXIF_CAMERA_MODEL,
625 /* LISTITEM_PICTURE_APERTURE => */ SLIDE_EXIF_APERTURE,
626 /* LISTITEM_PICTURE_FOCAL_LEN => */ SLIDE_EXIF_FOCAL_LENGTH,
627 /* LISTITEM_PICTURE_FOCUS_DIST => */ SLIDE_EXIF_FOCUS_DIST,
628 /* LISTITEM_PICTURE_EXP_MODE => */ SLIDE_EXIF_EXPOSURE_MODE,
629 /* LISTITEM_PICTURE_EXP_TIME => */ SLIDE_EXIF_EXPOSURE_TIME,
630 /* LISTITEM_PICTURE_ISO => */ SLIDE_EXIF_ISO_EQUIV,
631 /* LISTITEM_PICTURE_GPS_LAT => */ SLIDE_EXIF_GPS_LATITUDE,
632 /* LISTITEM_PICTURE_GPS_LON => */ SLIDE_EXIF_GPS_LONGITUDE,
633 /* LISTITEM_PICTURE_GPS_ALT => */ SLIDE_EXIF_GPS_ALTITUDE };
635 CGUIInfoManager::Property::Property(const CStdString &property, const CStdString ¶meters)
638 CUtil::SplitParams(parameters, params);
641 const CStdString &CGUIInfoManager::Property::param(unsigned int n /* = 0 */) const
643 if (n < params.size())
645 return StringUtils::EmptyString;
648 unsigned int CGUIInfoManager::Property::num_params() const
650 return params.size();
653 void CGUIInfoManager::SplitInfoString(const CStdString &infoString, vector<Property> &info)
655 // our string is of the form:
656 // category[(params)][.info(params).info2(params)] ...
657 // so we need to split on . while taking into account of () pairs
658 unsigned int parentheses = 0;
661 for (size_t i = 0; i < infoString.size(); ++i)
663 if (infoString[i] == '(')
668 else if (infoString[i] == ')')
671 CLog::Log(LOGERROR, "unmatched parentheses in %s", infoString.c_str());
672 else if (!--parentheses)
675 else if (infoString[i] == '.' && !parentheses)
677 if (!property.IsEmpty()) // add our property and parameters
678 info.push_back(Property(property.ToLower(), param));
684 param += infoString[i];
686 property += infoString[i];
689 CLog::Log(LOGERROR, "unmatched parentheses in %s", infoString.c_str());
690 if (!property.IsEmpty())
691 info.push_back(Property(property.ToLower(), param));
694 /// \brief Translates a string as given by the skin into an int that we use for more
695 /// efficient retrieval of data.
696 int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition)
699 CStdString strTest = strCondition;
700 strTest.TrimLeft(" \t\r\n");
701 strTest.TrimRight(" \t\r\n");
703 vector< Property> info;
704 SplitInfoString(strTest, info);
709 const Property &cat = info[0];
710 if (info.size() == 1)
712 if (cat.name == "false" || cat.name == "no" || cat.name == "off")
713 return SYSTEM_ALWAYS_FALSE;
714 else if (cat.name == "true" || cat.name == "yes" || cat.name == "on")
715 return SYSTEM_ALWAYS_TRUE;
716 if (cat.name == "isempty" && cat.num_params() == 1)
717 return AddMultiInfo(GUIInfo(STRING_IS_EMPTY, TranslateSingleString(cat.param())));
718 else if (cat.name == "stringcompare" && cat.num_params() == 2)
720 int info = TranslateSingleString(cat.param(0));
721 int info2 = TranslateSingleString(cat.param(1));
723 return AddMultiInfo(GUIInfo(STRING_COMPARE, info, -info2));
724 // pipe our original string through the localize parsing then make it lowercase (picks up $LBRACKET etc.)
725 CStdString label = CGUIInfoLabel::GetLabel(cat.param(1)).ToLower();
726 int compareString = ConditionalStringParameter(label);
727 return AddMultiInfo(GUIInfo(STRING_COMPARE, info, compareString));
729 else if (cat.name == "integergreaterthan" && cat.num_params() == 2)
731 int info = TranslateSingleString(cat.param(0));
732 int compareInt = atoi(cat.param(1).c_str());
733 return AddMultiInfo(GUIInfo(INTEGER_GREATER_THAN, info, compareInt));
735 else if (cat.name == "substring" && cat.num_params() >= 2)
737 int info = TranslateSingleString(cat.param(0));
738 CStdString label = CGUIInfoLabel::GetLabel(cat.param(1)).ToLower();
739 int compareString = ConditionalStringParameter(label);
740 if (cat.num_params() > 2)
742 if (cat.param(2).CompareNoCase("left") == 0)
743 return AddMultiInfo(GUIInfo(STRING_STR_LEFT, info, compareString));
744 else if (cat.param(2).CompareNoCase("right") == 0)
745 return AddMultiInfo(GUIInfo(STRING_STR_RIGHT, info, compareString));
747 return AddMultiInfo(GUIInfo(STRING_STR, info, compareString));
750 else if (info.size() == 2)
752 const Property &prop = info[1];
753 if (cat.name == "player")
755 for (size_t i = 0; i < sizeof(player_labels) / sizeof(infomap); i++)
757 if (prop.name == player_labels[i].str)
758 return player_labels[i].val;
760 for (size_t i = 0; i < sizeof(player_times) / sizeof(infomap); i++)
762 if (prop.name == player_times[i].str)
763 return AddMultiInfo(GUIInfo(player_times[i].val, TranslateTimeFormat(prop.param())));
765 if (prop.num_params() == 1)
767 for (size_t i = 0; i < sizeof(player_param) / sizeof(infomap); i++)
769 if (prop.name == player_param[i].str)
770 return AddMultiInfo(GUIInfo(player_param[i].val, ConditionalStringParameter(prop.param())));
774 else if (cat.name == "weather")
776 for (size_t i = 0; i < sizeof(weather) / sizeof(infomap); i++)
778 if (prop.name == weather[i].str)
779 return weather[i].val;
782 else if (cat.name == "network")
784 for (size_t i = 0; i < sizeof(network_labels) / sizeof(infomap); i++)
786 if (prop.name == network_labels[i].str)
787 return network_labels[i].val;
790 else if (cat.name == "musicpartymode")
792 for (size_t i = 0; i < sizeof(musicpartymode) / sizeof(infomap); i++)
794 if (prop.name == musicpartymode[i].str)
795 return musicpartymode[i].val;
798 else if (cat.name == "system")
800 for (size_t i = 0; i < sizeof(system_labels) / sizeof(infomap); i++)
802 if (prop.name == system_labels[i].str)
803 return system_labels[i].val;
805 if (prop.num_params() == 1)
807 const CStdString ¶m = prop.param();
808 if (prop.name == "getbool")
810 std::string paramCopy = param;
811 StringUtils::ToLower(paramCopy);
812 return AddMultiInfo(GUIInfo(SYSTEM_GET_BOOL, ConditionalStringParameter(paramCopy, true)));
814 for (size_t i = 0; i < sizeof(system_param) / sizeof(infomap); i++)
816 if (prop.name == system_param[i].str)
817 return AddMultiInfo(GUIInfo(system_param[i].val, ConditionalStringParameter(param)));
819 if (prop.name == "memory")
821 if (param == "free") return SYSTEM_FREE_MEMORY;
822 else if (param == "free.percent") return SYSTEM_FREE_MEMORY_PERCENT;
823 else if (param == "used") return SYSTEM_USED_MEMORY;
824 else if (param == "used.percent") return SYSTEM_USED_MEMORY_PERCENT;
825 else if (param == "total") return SYSTEM_TOTAL_MEMORY;
827 else if (prop.name == "addontitle")
829 int infoLabel = TranslateSingleString(param);
831 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_TITLE, infoLabel, 0));
832 CStdString label = CGUIInfoLabel::GetLabel(param).ToLower();
833 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_TITLE, ConditionalStringParameter(label), 1));
835 else if (prop.name == "addonicon")
837 int infoLabel = TranslateSingleString(param);
839 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_ICON, infoLabel, 0));
840 CStdString label = CGUIInfoLabel::GetLabel(param).ToLower();
841 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_ICON, ConditionalStringParameter(label), 1));
843 else if (prop.name == "idletime")
844 return AddMultiInfo(GUIInfo(SYSTEM_IDLE_TIME, atoi(param.c_str())));
846 if (prop.name == "alarmlessorequal" && prop.num_params() == 2)
847 return AddMultiInfo(GUIInfo(SYSTEM_ALARM_LESS_OR_EQUAL, ConditionalStringParameter(prop.param(0)), ConditionalStringParameter(prop.param(1))));
848 else if (prop.name == "date")
850 if (prop.num_params() == 2)
851 return AddMultiInfo(GUIInfo(SYSTEM_DATE, StringUtils::DateStringToYYYYMMDD(prop.param(0)) % 10000, StringUtils::DateStringToYYYYMMDD(prop.param(1)) % 10000));
852 else if (prop.num_params() == 1)
854 int dateformat = StringUtils::DateStringToYYYYMMDD(prop.param(0));
855 if (dateformat <= 0) // not concrete date
856 return AddMultiInfo(GUIInfo(SYSTEM_DATE, ConditionalStringParameter(prop.param(0), true), -1));
858 return AddMultiInfo(GUIInfo(SYSTEM_DATE, dateformat % 10000));
862 else if (prop.name == "time")
864 if (prop.num_params() == 0)
865 return AddMultiInfo(GUIInfo(SYSTEM_TIME, TIME_FORMAT_GUESS));
866 if (prop.num_params() == 1)
868 TIME_FORMAT timeFormat = TranslateTimeFormat(prop.param(0));
869 if (timeFormat == TIME_FORMAT_GUESS)
870 return AddMultiInfo(GUIInfo(SYSTEM_TIME, StringUtils::TimeStringToSeconds(prop.param(0))));
871 return AddMultiInfo(GUIInfo(SYSTEM_TIME, timeFormat));
874 return AddMultiInfo(GUIInfo(SYSTEM_TIME, StringUtils::TimeStringToSeconds(prop.param(0)), StringUtils::TimeStringToSeconds(prop.param(1))));
877 else if (cat.name == "library")
879 if (prop.name == "isscanning") return LIBRARY_IS_SCANNING;
880 else if (prop.name == "isscanningvideo") return LIBRARY_IS_SCANNING_VIDEO; // TODO: change to IsScanning(Video)
881 else if (prop.name == "isscanningmusic") return LIBRARY_IS_SCANNING_MUSIC;
882 else if (prop.name == "hascontent" && prop.num_params())
884 CStdString cat = prop.param(0); cat.ToLower();
885 if (cat == "music") return LIBRARY_HAS_MUSIC;
886 else if (cat == "video") return LIBRARY_HAS_VIDEO;
887 else if (cat == "movies") return LIBRARY_HAS_MOVIES;
888 else if (cat == "tvshows") return LIBRARY_HAS_TVSHOWS;
889 else if (cat == "musicvideos") return LIBRARY_HAS_MUSICVIDEOS;
890 else if (cat == "moviesets") return LIBRARY_HAS_MOVIE_SETS;
893 else if (cat.name == "musicplayer")
895 for (size_t i = 0; i < sizeof(player_times) / sizeof(infomap); i++) // TODO: remove these, they're repeats
897 if (prop.name == player_times[i].str)
898 return AddMultiInfo(GUIInfo(player_times[i].val, TranslateTimeFormat(prop.param())));
900 if (prop.name == "property")
902 if (prop.param().Equals("fanart_image"))
903 return AddMultiInfo(GUIInfo(PLAYER_ITEM_ART, ConditionalStringParameter("fanart")));
904 return AddListItemProp(prop.param(), MUSICPLAYER_PROPERTY_OFFSET);
906 return TranslateMusicPlayerString(prop.name);
908 else if (cat.name == "videoplayer")
910 for (size_t i = 0; i < sizeof(player_times) / sizeof(infomap); i++) // TODO: remove these, they're repeats
912 if (prop.name == player_times[i].str)
913 return AddMultiInfo(GUIInfo(player_times[i].val, TranslateTimeFormat(prop.param())));
915 if (prop.name == "content" && prop.num_params())
916 return AddMultiInfo(GUIInfo(VIDEOPLAYER_CONTENT, ConditionalStringParameter(prop.param()), 0));
917 for (size_t i = 0; i < sizeof(videoplayer) / sizeof(infomap); i++)
919 if (prop.name == videoplayer[i].str)
920 return videoplayer[i].val;
923 else if (cat.name == "slideshow")
925 for (size_t i = 0; i < sizeof(slideshow) / sizeof(infomap); i++)
927 if (prop.name == slideshow[i].str)
928 return slideshow[i].val;
930 return CPictureInfoTag::TranslateString(prop.name);
932 else if (cat.name == "container")
934 for (size_t i = 0; i < sizeof(mediacontainer) / sizeof(infomap); i++) // these ones don't have or need an id
936 if (prop.name == mediacontainer[i].str)
937 return mediacontainer[i].val;
939 int id = atoi(cat.param().c_str());
940 for (size_t i = 0; i < sizeof(container_bools) / sizeof(infomap); i++) // these ones can have an id (but don't need to?)
942 if (prop.name == container_bools[i].str)
943 return id ? AddMultiInfo(GUIInfo(container_bools[i].val, id)) : container_bools[i].val;
945 for (size_t i = 0; i < sizeof(container_ints) / sizeof(infomap); i++) // these ones can have an int param on the property
947 if (prop.name == container_ints[i].str)
948 return AddMultiInfo(GUIInfo(container_ints[i].val, id, atoi(prop.param().c_str())));
950 for (size_t i = 0; i < sizeof(container_str) / sizeof(infomap); i++) // these ones have a string param on the property
952 if (prop.name == container_str[i].str)
953 return AddMultiInfo(GUIInfo(container_str[i].val, id, ConditionalStringParameter(prop.param())));
955 if (prop.name == "sortdirection")
957 SortOrder order = SortOrderNone;
958 if (prop.param().Equals("ascending"))
959 order = SortOrderAscending;
960 else if (prop.param().Equals("descending"))
961 order = SortOrderDescending;
962 return AddMultiInfo(GUIInfo(CONTAINER_SORT_DIRECTION, order));
964 else if (prop.name == "sort")
966 SORT_METHOD sort = SORT_METHOD_NONE;
967 if (prop.param().Equals("songrating")) sort = SORT_METHOD_SONG_RATING;
968 if (sort != SORT_METHOD_NONE)
969 return AddMultiInfo(GUIInfo(CONTAINER_SORT_METHOD, sort));
972 else if (cat.name == "listitem")
974 int offset = atoi(cat.param().c_str());
975 int ret = TranslateListItem(prop);
976 if (offset || ret == LISTITEM_ISSELECTED || ret == LISTITEM_ISPLAYING || ret == LISTITEM_IS_FOLDER)
977 return AddMultiInfo(GUIInfo(ret, 0, offset, INFOFLAG_LISTITEM_WRAP));
980 else if (cat.name == "listitemposition")
982 int offset = atoi(cat.param().c_str());
983 int ret = TranslateListItem(prop);
984 if (offset || ret == LISTITEM_ISSELECTED || ret == LISTITEM_ISPLAYING || ret == LISTITEM_IS_FOLDER)
985 return AddMultiInfo(GUIInfo(ret, 0, offset, INFOFLAG_LISTITEM_POSITION));
988 else if (cat.name == "listitemnowrap")
990 int offset = atoi(cat.param().c_str());
991 int ret = TranslateListItem(prop);
992 if (offset || ret == LISTITEM_ISSELECTED || ret == LISTITEM_ISPLAYING || ret == LISTITEM_IS_FOLDER)
993 return AddMultiInfo(GUIInfo(ret, 0, offset));
996 else if (cat.name == "visualisation")
998 for (size_t i = 0; i < sizeof(visualisation) / sizeof(infomap); i++)
1000 if (prop.name == visualisation[i].str)
1001 return visualisation[i].val;
1004 else if (cat.name == "fanart")
1006 for (size_t i = 0; i < sizeof(fanart_labels) / sizeof(infomap); i++)
1008 if (prop.name == fanart_labels[i].str)
1009 return fanart_labels[i].val;
1012 else if (cat.name == "skin")
1014 for (size_t i = 0; i < sizeof(skin_labels) / sizeof(infomap); i++)
1016 if (prop.name == skin_labels[i].str)
1017 return skin_labels[i].val;
1019 if (prop.num_params())
1021 if (prop.name == "string")
1023 if (prop.num_params() == 2)
1024 return AddMultiInfo(GUIInfo(SKIN_STRING, CSkinSettings::Get().TranslateString(prop.param(0)), ConditionalStringParameter(prop.param(1))));
1026 return AddMultiInfo(GUIInfo(SKIN_STRING, CSkinSettings::Get().TranslateString(prop.param(0))));
1028 if (prop.name == "hassetting")
1029 return AddMultiInfo(GUIInfo(SKIN_BOOL, CSkinSettings::Get().TranslateBool(prop.param(0))));
1030 else if (prop.name == "hastheme")
1031 return AddMultiInfo(GUIInfo(SKIN_HAS_THEME, ConditionalStringParameter(prop.param(0))));
1034 else if (cat.name == "window")
1036 if (prop.name == "property" && prop.num_params() == 1)
1037 { // TODO: this doesn't support foo.xml
1038 int winID = cat.param().IsEmpty() ? 0 : CButtonTranslator::TranslateWindow(cat.param());
1039 if (winID != WINDOW_INVALID)
1040 return AddMultiInfo(GUIInfo(WINDOW_PROPERTY, winID, ConditionalStringParameter(prop.param())));
1042 for (size_t i = 0; i < sizeof(window_bools) / sizeof(infomap); i++)
1044 if (prop.name == window_bools[i].str)
1045 { // TODO: The parameter for these should really be on the first not the second property
1046 if (prop.param().Find("xml") >= 0)
1047 return AddMultiInfo(GUIInfo(window_bools[i].val, 0, ConditionalStringParameter(prop.param())));
1048 int winID = prop.param().IsEmpty() ? 0 : CButtonTranslator::TranslateWindow(prop.param());
1049 if (winID != WINDOW_INVALID)
1050 return AddMultiInfo(GUIInfo(window_bools[i].val, winID, 0));
1055 else if (cat.name == "control")
1057 for (size_t i = 0; i < sizeof(control_labels) / sizeof(infomap); i++)
1059 if (prop.name == control_labels[i].str)
1060 { // TODO: The parameter for these should really be on the first not the second property
1061 int controlID = atoi(prop.param().c_str());
1063 return AddMultiInfo(GUIInfo(control_labels[i].val, controlID, 0));
1068 else if (cat.name == "controlgroup" && prop.name == "hasfocus")
1070 int groupID = atoi(cat.param().c_str());
1072 return AddMultiInfo(GUIInfo(CONTROL_GROUP_HAS_FOCUS, groupID, atoi(prop.param(0).c_str())));
1074 else if (cat.name == "playlist")
1076 for (size_t i = 0; i < sizeof(playlist) / sizeof(infomap); i++)
1078 if (prop.name == playlist[i].str)
1079 return playlist[i].val;
1082 else if (cat.name == "pvr")
1084 for (size_t i = 0; i < sizeof(pvr) / sizeof(infomap); i++)
1086 if (prop.name == pvr[i].str)
1091 else if (info.size() == 3)
1093 if (info[0].name == "system" && info[1].name == "platform")
1094 { // TODO: replace with a single system.platform
1095 CStdString platform = info[2].name;
1096 if (platform == "linux") return SYSTEM_PLATFORM_LINUX;
1097 else if (platform == "windows") return SYSTEM_PLATFORM_WINDOWS;
1098 else if (platform == "darwin") return SYSTEM_PLATFORM_DARWIN;
1099 else if (platform == "osx") return SYSTEM_PLATFORM_DARWIN_OSX;
1100 else if (platform == "ios") return SYSTEM_PLATFORM_DARWIN_IOS;
1101 else if (platform == "atv2") return SYSTEM_PLATFORM_DARWIN_ATV2;
1102 else if (platform == "android") return SYSTEM_PLATFORM_ANDROID;
1104 if (info[0].name == "musicplayer")
1105 { // TODO: these two don't allow duration(foo) and also don't allow more than this number of levels...
1106 if (info[1].name == "position")
1108 int position = atoi(info[1].param().c_str());
1109 int value = TranslateMusicPlayerString(info[2].name); // musicplayer.position(foo).bar
1110 return AddMultiInfo(GUIInfo(value, 0, position));
1112 else if (info[1].name == "offset")
1114 int position = atoi(info[1].param().c_str());
1115 int value = TranslateMusicPlayerString(info[2].name); // musicplayer.offset(foo).bar
1116 return AddMultiInfo(GUIInfo(value, 1, position));
1119 else if (info[0].name == "container")
1121 int id = atoi(info[0].param().c_str());
1122 int offset = atoi(info[1].param().c_str());
1123 if (info[1].name == "listitemnowrap")
1124 return AddMultiInfo(GUIInfo(TranslateListItem(info[2]), id, offset));
1125 else if (info[1].name == "listitemposition")
1126 return AddMultiInfo(GUIInfo(TranslateListItem(info[2]), id, offset, INFOFLAG_LISTITEM_POSITION));
1127 else if (info[1].name == "listitem")
1128 return AddMultiInfo(GUIInfo(TranslateListItem(info[2]), id, offset, INFOFLAG_LISTITEM_WRAP));
1135 int CGUIInfoManager::TranslateListItem(const Property &info)
1137 for (size_t i = 0; i < sizeof(listitem_labels) / sizeof(infomap); i++) // these ones don't have or need an id
1139 if (info.name == listitem_labels[i].str)
1140 return listitem_labels[i].val;
1142 if (info.name == "property" && info.num_params() == 1)
1144 if (info.param().Equals("fanart_image"))
1145 return AddListItemProp("fanart", LISTITEM_ART_OFFSET);
1146 return AddListItemProp(info.param());
1148 if (info.name == "art" && info.num_params() == 1)
1149 return AddListItemProp(info.param(), LISTITEM_ART_OFFSET);
1153 int CGUIInfoManager::TranslateMusicPlayerString(const CStdString &info) const
1155 for (size_t i = 0; i < sizeof(musicplayer) / sizeof(infomap); i++)
1157 if (info == musicplayer[i].str)
1158 return musicplayer[i].val;
1163 TIME_FORMAT CGUIInfoManager::TranslateTimeFormat(const CStdString &format)
1165 if (format.IsEmpty()) return TIME_FORMAT_GUESS;
1166 else if (format.Equals("hh")) return TIME_FORMAT_HH;
1167 else if (format.Equals("mm")) return TIME_FORMAT_MM;
1168 else if (format.Equals("ss")) return TIME_FORMAT_SS;
1169 else if (format.Equals("hh:mm")) return TIME_FORMAT_HH_MM;
1170 else if (format.Equals("mm:ss")) return TIME_FORMAT_MM_SS;
1171 else if (format.Equals("hh:mm:ss")) return TIME_FORMAT_HH_MM_SS;
1172 else if (format.Equals("hh:mm:ss xx")) return TIME_FORMAT_HH_MM_SS_XX;
1173 else if (format.Equals("h")) return TIME_FORMAT_H;
1174 else if (format.Equals("h:mm:ss")) return TIME_FORMAT_H_MM_SS;
1175 else if (format.Equals("h:mm:ss xx")) return TIME_FORMAT_H_MM_SS_XX;
1176 else if (format.Equals("xx")) return TIME_FORMAT_XX;
1177 return TIME_FORMAT_GUESS;
1180 CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fallback)
1182 if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
1183 return GetSkinVariableString(info, false);
1185 CStdString strLabel;
1186 if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
1187 return GetMultiInfoLabel(m_multiInfo[info - MULTI_INFO_START], contextWindow);
1189 if (info >= SLIDE_INFO_START && info <= SLIDE_INFO_END)
1190 return GetPictureLabel(info);
1192 if (info >= LISTITEM_PROPERTY_START+MUSICPLAYER_PROPERTY_OFFSET &&
1193 info - (LISTITEM_PROPERTY_START+MUSICPLAYER_PROPERTY_OFFSET) < (int)m_listitemProperties.size())
1194 { // grab the property
1198 CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START-MUSICPLAYER_PROPERTY_OFFSET];
1199 return m_currentFile->GetProperty(property).asString();
1202 if (info >= LISTITEM_START && info <= LISTITEM_END)
1204 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS); // true for has list items
1207 CFileItemPtr item = window->GetCurrentListItem();
1208 strLabel = GetItemLabel(item.get(), info, fallback);
1216 case PVR_NEXT_RECORDING_CHANNEL:
1217 case PVR_NEXT_RECORDING_CHAN_ICO:
1218 case PVR_NEXT_RECORDING_DATETIME:
1219 case PVR_NEXT_RECORDING_TITLE:
1220 case PVR_NOW_RECORDING_CHANNEL:
1221 case PVR_NOW_RECORDING_CHAN_ICO:
1222 case PVR_NOW_RECORDING_DATETIME:
1223 case PVR_NOW_RECORDING_TITLE:
1224 case PVR_BACKEND_NAME:
1225 case PVR_BACKEND_VERSION:
1226 case PVR_BACKEND_HOST:
1227 case PVR_BACKEND_DISKSPACE:
1228 case PVR_BACKEND_CHANNELS:
1229 case PVR_BACKEND_TIMERS:
1230 case PVR_BACKEND_RECORDINGS:
1231 case PVR_BACKEND_NUMBER:
1232 case PVR_TOTAL_DISKSPACE:
1233 case PVR_NEXT_TIMER:
1234 case PVR_PLAYING_DURATION:
1235 case PVR_PLAYING_TIME:
1236 case PVR_PLAYING_PROGRESS:
1237 case PVR_ACTUAL_STREAM_CLIENT:
1238 case PVR_ACTUAL_STREAM_DEVICE:
1239 case PVR_ACTUAL_STREAM_STATUS:
1240 case PVR_ACTUAL_STREAM_SIG:
1241 case PVR_ACTUAL_STREAM_SNR:
1242 case PVR_ACTUAL_STREAM_SIG_PROGR:
1243 case PVR_ACTUAL_STREAM_SNR_PROGR:
1244 case PVR_ACTUAL_STREAM_BER:
1245 case PVR_ACTUAL_STREAM_UNC:
1246 case PVR_ACTUAL_STREAM_VIDEO_BR:
1247 case PVR_ACTUAL_STREAM_AUDIO_BR:
1248 case PVR_ACTUAL_STREAM_DOLBY_BR:
1249 case PVR_ACTUAL_STREAM_CRYPTION:
1250 g_PVRManager.TranslateCharInfo(info, strLabel);
1252 case WEATHER_CONDITIONS:
1253 strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_COND);
1254 strLabel = strLabel.Trim();
1256 case WEATHER_TEMPERATURE:
1257 strLabel.Format("%s%s", g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_TEMP), g_langInfo.GetTempUnitString().c_str());
1259 case WEATHER_LOCATION:
1260 strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_LOCATION);
1262 case WEATHER_FANART_CODE:
1263 strLabel = URIUtils::GetFileName(g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON));
1264 URIUtils::RemoveExtension(strLabel);
1266 case WEATHER_PLUGIN:
1267 strLabel = g_guiSettings.GetString("weather.addon");
1270 strLabel = GetDate();
1273 strLabel.Format("%02.2f", m_fps);
1276 strLabel.Format("%2.1f dB", CAEUtil::PercentToGain(g_settings.m_fVolumeLevel));
1278 case PLAYER_SUBTITLE_DELAY:
1279 strLabel.Format("%2.3f s", CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay);
1281 case PLAYER_AUDIO_DELAY:
1282 strLabel.Format("%2.3f s", CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay);
1284 case PLAYER_CHAPTER:
1285 if(g_application.IsPlaying() && g_application.m_pPlayer)
1286 strLabel.Format("%02d", g_application.m_pPlayer->GetChapter());
1288 case PLAYER_CHAPTERCOUNT:
1289 if(g_application.IsPlaying() && g_application.m_pPlayer)
1290 strLabel.Format("%02d", g_application.m_pPlayer->GetChapterCount());
1292 case PLAYER_CHAPTERNAME:
1293 if(g_application.IsPlaying() && g_application.m_pPlayer)
1294 g_application.m_pPlayer->GetChapterName(strLabel);
1296 case PLAYER_CACHELEVEL:
1299 if(g_application.IsPlaying() && GetInt(iLevel, PLAYER_CACHELEVEL) && iLevel >= 0)
1300 strLabel.Format("%i", iLevel);
1304 if(g_application.IsPlaying() && g_application.m_pPlayer)
1305 strLabel = GetCurrentPlayTime(TIME_FORMAT_HH_MM);
1307 case PLAYER_DURATION:
1308 if(g_application.IsPlaying() && g_application.m_pPlayer)
1309 strLabel = GetDuration(TIME_FORMAT_HH_MM);
1312 case PLAYER_FILEPATH:
1315 if (m_currentFile->HasMusicInfoTag())
1316 strLabel = m_currentFile->GetMusicInfoTag()->GetURL();
1317 else if (m_currentFile->HasVideoInfoTag())
1318 strLabel = m_currentFile->GetVideoInfoTag()->m_strFileNameAndPath;
1319 if (strLabel.IsEmpty())
1320 strLabel = m_currentFile->GetPath();
1322 if (info == PLAYER_PATH)
1324 // do this twice since we want the path outside the archive if this
1326 if (URIUtils::IsInArchive(strLabel))
1327 strLabel = URIUtils::GetParentPath(strLabel);
1328 strLabel = URIUtils::GetParentPath(strLabel);
1335 if (m_currentFile->HasPVRChannelInfoTag())
1338 return m_currentFile->GetPVRChannelInfoTag()->GetEPGNow(tag) ?
1340 g_guiSettings.GetBool("epg.hidenoinfoavailable") ?
1341 StringUtils::EmptyString :
1342 g_localizeStrings.Get(19055); // no information available
1344 if (m_currentFile->HasPVRRecordingInfoTag() && !m_currentFile->GetPVRRecordingInfoTag()->m_strTitle.IsEmpty())
1345 return m_currentFile->GetPVRRecordingInfoTag()->m_strTitle;
1346 if (m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->m_strTitle.IsEmpty())
1347 return m_currentFile->GetVideoInfoTag()->m_strTitle;
1348 if (m_currentFile->HasMusicInfoTag() && !m_currentFile->GetMusicInfoTag()->GetTitle().IsEmpty())
1349 return m_currentFile->GetMusicInfoTag()->GetTitle();
1350 // don't have the title, so use dvdplayer, label, or drop down to title from path
1351 if (g_application.m_pPlayer && !g_application.m_pPlayer->GetPlayingTitle().IsEmpty())
1352 return g_application.m_pPlayer->GetPlayingTitle();
1353 if (!m_currentFile->GetLabel().IsEmpty())
1354 return m_currentFile->GetLabel();
1355 return CUtil::GetTitleFromPath(m_currentFile->GetPath());
1359 if (g_application.m_pPlayer && !g_application.m_pPlayer->GetPlayingTitle().IsEmpty())
1360 return g_application.m_pPlayer->GetPlayingTitle();
1364 case MUSICPLAYER_TITLE:
1365 case MUSICPLAYER_ALBUM:
1366 case MUSICPLAYER_ARTIST:
1367 case MUSICPLAYER_ALBUM_ARTIST:
1368 case MUSICPLAYER_GENRE:
1369 case MUSICPLAYER_YEAR:
1370 case MUSICPLAYER_TRACK_NUMBER:
1371 case MUSICPLAYER_BITRATE:
1372 case MUSICPLAYER_PLAYLISTLEN:
1373 case MUSICPLAYER_PLAYLISTPOS:
1374 case MUSICPLAYER_CHANNELS:
1375 case MUSICPLAYER_BITSPERSAMPLE:
1376 case MUSICPLAYER_SAMPLERATE:
1377 case MUSICPLAYER_CODEC:
1378 case MUSICPLAYER_DISC_NUMBER:
1379 case MUSICPLAYER_RATING:
1380 case MUSICPLAYER_COMMENT:
1381 case MUSICPLAYER_LYRICS:
1382 case MUSICPLAYER_CHANNEL_NAME:
1383 case MUSICPLAYER_CHANNEL_NUMBER:
1384 case MUSICPLAYER_CHANNEL_GROUP:
1385 case MUSICPLAYER_PLAYCOUNT:
1386 case MUSICPLAYER_LASTPLAYED:
1387 strLabel = GetMusicLabel(info);
1389 case VIDEOPLAYER_TITLE:
1390 case VIDEOPLAYER_ORIGINALTITLE:
1391 case VIDEOPLAYER_GENRE:
1392 case VIDEOPLAYER_DIRECTOR:
1393 case VIDEOPLAYER_YEAR:
1394 case VIDEOPLAYER_PLAYLISTLEN:
1395 case VIDEOPLAYER_PLAYLISTPOS:
1396 case VIDEOPLAYER_PLOT:
1397 case VIDEOPLAYER_PLOT_OUTLINE:
1398 case VIDEOPLAYER_EPISODE:
1399 case VIDEOPLAYER_SEASON:
1400 case VIDEOPLAYER_RATING:
1401 case VIDEOPLAYER_RATING_AND_VOTES:
1402 case VIDEOPLAYER_TVSHOW:
1403 case VIDEOPLAYER_PREMIERED:
1404 case VIDEOPLAYER_STUDIO:
1405 case VIDEOPLAYER_COUNTRY:
1406 case VIDEOPLAYER_MPAA:
1407 case VIDEOPLAYER_TOP250:
1408 case VIDEOPLAYER_CAST:
1409 case VIDEOPLAYER_CAST_AND_ROLE:
1410 case VIDEOPLAYER_ARTIST:
1411 case VIDEOPLAYER_ALBUM:
1412 case VIDEOPLAYER_WRITER:
1413 case VIDEOPLAYER_TAGLINE:
1414 case VIDEOPLAYER_TRAILER:
1415 case VIDEOPLAYER_STARTTIME:
1416 case VIDEOPLAYER_ENDTIME:
1417 case VIDEOPLAYER_NEXT_TITLE:
1418 case VIDEOPLAYER_NEXT_GENRE:
1419 case VIDEOPLAYER_NEXT_PLOT:
1420 case VIDEOPLAYER_NEXT_PLOT_OUTLINE:
1421 case VIDEOPLAYER_NEXT_STARTTIME:
1422 case VIDEOPLAYER_NEXT_ENDTIME:
1423 case VIDEOPLAYER_NEXT_DURATION:
1424 case VIDEOPLAYER_CHANNEL_NAME:
1425 case VIDEOPLAYER_CHANNEL_NUMBER:
1426 case VIDEOPLAYER_CHANNEL_GROUP:
1427 case VIDEOPLAYER_PARENTAL_RATING:
1428 case VIDEOPLAYER_PLAYCOUNT:
1429 case VIDEOPLAYER_LASTPLAYED:
1430 strLabel = GetVideoLabel(info);
1432 case VIDEOPLAYER_VIDEO_CODEC:
1433 if(g_application.IsPlaying() && g_application.m_pPlayer)
1435 SPlayerVideoStreamInfo info;
1436 g_application.m_pPlayer->GetVideoStreamInfo(info);
1437 strLabel = info.videoCodecName;
1440 case VIDEOPLAYER_VIDEO_RESOLUTION:
1441 if(g_application.IsPlaying() && g_application.m_pPlayer)
1442 return CStreamDetails::VideoDimsToResolutionDescription(g_application.m_pPlayer->GetPictureWidth(), g_application.m_pPlayer->GetPictureHeight());
1444 case VIDEOPLAYER_AUDIO_CODEC:
1445 if(g_application.IsPlaying() && g_application.m_pPlayer)
1447 SPlayerAudioStreamInfo info;
1448 g_application.m_pPlayer->GetAudioStreamInfo(g_application.m_pPlayer->GetAudioStream(), info);
1449 strLabel = info.audioCodecName;
1452 case VIDEOPLAYER_VIDEO_ASPECT:
1453 if (g_application.IsPlaying() && g_application.m_pPlayer)
1455 SPlayerVideoStreamInfo info;
1456 g_application.m_pPlayer->GetVideoStreamInfo(info);
1457 strLabel = CStreamDetails::VideoAspectToAspectDescription(info.videoAspectRatio);
1460 case VIDEOPLAYER_AUDIO_CHANNELS:
1461 if(g_application.IsPlaying() && g_application.m_pPlayer)
1463 SPlayerAudioStreamInfo info;
1464 g_application.m_pPlayer->GetAudioStreamInfo(g_application.m_pPlayer->GetAudioStream(), info);
1465 strLabel.Format("%i", info.channels);
1468 case PLAYLIST_LENGTH:
1469 case PLAYLIST_POSITION:
1470 case PLAYLIST_RANDOM:
1471 case PLAYLIST_REPEAT:
1472 strLabel = GetPlaylistLabel(info);
1474 case MUSICPM_SONGSPLAYED:
1475 case MUSICPM_MATCHINGSONGS:
1476 case MUSICPM_MATCHINGSONGSPICKED:
1477 case MUSICPM_MATCHINGSONGSLEFT:
1478 case MUSICPM_RELAXEDSONGSPICKED:
1479 case MUSICPM_RANDOMSONGSPICKED:
1480 strLabel = GetMusicPartyModeLabel(info);
1483 case SYSTEM_FREE_SPACE:
1484 case SYSTEM_USED_SPACE:
1485 case SYSTEM_TOTAL_SPACE:
1486 case SYSTEM_FREE_SPACE_PERCENT:
1487 case SYSTEM_USED_SPACE_PERCENT:
1488 return g_sysinfo.GetHddSpaceInfo(info);
1491 case SYSTEM_CPU_TEMPERATURE:
1492 case SYSTEM_GPU_TEMPERATURE:
1493 case SYSTEM_FAN_SPEED:
1494 case SYSTEM_CPU_USAGE:
1495 return GetSystemHeatInfo(info);
1498 case SYSTEM_VIDEO_ENCODER_INFO:
1499 case NETWORK_MAC_ADDRESS:
1500 case SYSTEM_KERNEL_VERSION:
1501 case SYSTEM_CPUFREQUENCY:
1502 case SYSTEM_INTERNET_STATE:
1504 case SYSTEM_TOTALUPTIME:
1505 case SYSTEM_BATTERY_LEVEL:
1506 return g_sysinfo.GetInfo(info);
1509 case SYSTEM_SCREEN_RESOLUTION:
1510 if(g_Windowing.IsFullScreen())
1511 strLabel.Format("%ix%i@%.2fHz - %s (%02.2f fps)",
1512 CDisplaySettings::Get().GetCurrentResolutionInfo().iScreenWidth,
1513 CDisplaySettings::Get().GetCurrentResolutionInfo().iScreenHeight,
1514 CDisplaySettings::Get().GetCurrentResolutionInfo().fRefreshRate,
1515 g_localizeStrings.Get(244), GetFPS());
1517 strLabel.Format("%ix%i - %s (%02.2f fps)",
1518 CDisplaySettings::Get().GetCurrentResolutionInfo().iScreenWidth,
1519 CDisplaySettings::Get().GetCurrentResolutionInfo().iScreenHeight,
1520 g_localizeStrings.Get(242), GetFPS());
1524 case CONTAINER_FOLDERPATH:
1525 case CONTAINER_FOLDERNAME:
1527 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1530 if (info==CONTAINER_FOLDERNAME)
1531 strLabel = ((CGUIMediaWindow*)window)->CurrentDirectory().GetLabel();
1533 strLabel = CURL(((CGUIMediaWindow*)window)->CurrentDirectory().GetPath()).GetWithoutUserDetails();
1537 case CONTAINER_PLUGINNAME:
1539 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1542 CURL url(((CGUIMediaWindow*)window)->CurrentDirectory().GetPath());
1543 if (url.GetProtocol().Equals("plugin"))
1545 strLabel = url.GetFileName();
1546 URIUtils::RemoveSlashAtEnd(strLabel);
1551 case CONTAINER_VIEWMODE:
1553 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1556 const CGUIControl *control = window->GetControl(window->GetViewContainerID());
1557 if (control && control->IsContainer())
1558 strLabel = ((IGUIContainer *)control)->GetLabel();
1562 case CONTAINER_SORT_METHOD:
1564 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1567 const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
1569 strLabel = g_localizeStrings.Get(viewState->GetSortMethodLabel());
1573 case CONTAINER_NUM_PAGES:
1574 case CONTAINER_NUM_ITEMS:
1575 case CONTAINER_CURRENT_PAGE:
1576 return GetMultiInfoLabel(GUIInfo(info), contextWindow);
1578 case CONTAINER_SHOWPLOT:
1580 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1582 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("showplot").asString();
1585 case CONTAINER_TOTALTIME:
1587 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1590 const CFileItemList& items=((CGUIMediaWindow *)window)->CurrentDirectory();
1592 for (int i=0;i<items.Size();++i)
1594 CFileItemPtr item=items.Get(i);
1595 if (item->HasMusicInfoTag())
1596 duration += item->GetMusicInfoTag()->GetDuration();
1597 else if (item->HasVideoInfoTag())
1598 duration += item->GetVideoInfoTag()->m_streamDetails.GetVideoDuration();
1601 return StringUtils::SecondsToTimeString(duration);
1605 case SYSTEM_BUILD_VERSION:
1606 strLabel = GetVersion();
1608 case SYSTEM_BUILD_DATE:
1609 strLabel = GetBuild();
1611 case SYSTEM_FREE_MEMORY:
1612 case SYSTEM_FREE_MEMORY_PERCENT:
1613 case SYSTEM_USED_MEMORY:
1614 case SYSTEM_USED_MEMORY_PERCENT:
1615 case SYSTEM_TOTAL_MEMORY:
1617 MEMORYSTATUSEX stat;
1618 stat.dwLength = sizeof(MEMORYSTATUSEX);
1619 GlobalMemoryStatusEx(&stat);
1620 int iMemPercentFree = 100 - ((int)( 100.0f* (stat.ullTotalPhys - stat.ullAvailPhys)/stat.ullTotalPhys + 0.5f ));
1621 int iMemPercentUsed = 100 - iMemPercentFree;
1623 if (info == SYSTEM_FREE_MEMORY)
1624 strLabel.Format("%luMB", (ULONG)(stat.ullAvailPhys/MB));
1625 else if (info == SYSTEM_FREE_MEMORY_PERCENT)
1626 strLabel.Format("%i%%", iMemPercentFree);
1627 else if (info == SYSTEM_USED_MEMORY)
1628 strLabel.Format("%luMB", (ULONG)((stat.ullTotalPhys - stat.ullAvailPhys)/MB));
1629 else if (info == SYSTEM_USED_MEMORY_PERCENT)
1630 strLabel.Format("%i%%", iMemPercentUsed);
1631 else if (info == SYSTEM_TOTAL_MEMORY)
1632 strLabel.Format("%luMB", (ULONG)(stat.ullTotalPhys/MB));
1635 case SYSTEM_SCREEN_MODE:
1636 strLabel = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()).strMode;
1638 case SYSTEM_SCREEN_WIDTH:
1639 strLabel.Format("%i", CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()).iScreenWidth);
1641 case SYSTEM_SCREEN_HEIGHT:
1642 strLabel.Format("%i", CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()).iScreenHeight);
1644 case SYSTEM_CURRENT_WINDOW:
1645 return g_localizeStrings.Get(g_windowManager.GetFocusedWindow());
1647 case SYSTEM_CURRENT_CONTROL:
1649 CGUIWindow *window = g_windowManager.GetWindow(g_windowManager.GetFocusedWindow());
1652 CGUIControl *control = window->GetFocusedControl();
1654 strLabel = control->GetDescription();
1658 #ifdef HAS_DVD_DRIVE
1659 case SYSTEM_DVD_LABEL:
1660 strLabel = g_mediaManager.GetDiskLabel();
1663 case SYSTEM_ALARM_POS:
1664 if (g_alarmClock.GetRemaining("shutdowntimer") == 0.f)
1668 double fTime = g_alarmClock.GetRemaining("shutdowntimer");
1670 strLabel.Format(g_localizeStrings.Get(13213).c_str(),g_alarmClock.GetRemaining("shutdowntimer")/60.f);
1672 strLabel.Format(g_localizeStrings.Get(13214).c_str(),g_alarmClock.GetRemaining("shutdowntimer"));
1675 case SYSTEM_PROFILENAME:
1676 strLabel = CProfilesManager::Get().GetCurrentProfile().getName();
1678 case SYSTEM_PROFILECOUNT:
1679 strLabel.Format("%i", CProfilesManager::Get().GetNumberOfProfiles());
1681 case SYSTEM_LANGUAGE:
1682 strLabel = g_guiSettings.GetString("locale.language");
1684 case SYSTEM_TEMPERATURE_UNITS:
1685 strLabel = g_langInfo.GetTempUnitString();
1687 case SYSTEM_PROGRESS_BAR:
1690 if (GetInt(percent, SYSTEM_PROGRESS_BAR) && percent > 0)
1691 strLabel.Format("%i", percent);
1694 case SYSTEM_FRIENDLY_NAME:
1696 CStdString friendlyName = g_guiSettings.GetString("services.devicename");
1697 if (friendlyName.Equals("XBMC"))
1698 strLabel.Format("%s (%s)", friendlyName.c_str(), g_application.getNetwork().GetHostName().c_str());
1700 strLabel = friendlyName;
1705 strLabel = g_guiSettings.GetString("lookandfeel.skintheme");
1707 case SKIN_COLOUR_THEME:
1708 strLabel = g_guiSettings.GetString("lookandfeel.skincolors");
1710 case SKIN_ASPECT_RATIO:
1712 strLabel = g_SkinInfo->GetCurrentAspect();
1714 case NETWORK_IP_ADDRESS:
1716 CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1718 return iface->GetCurrentIPAddress();
1721 case NETWORK_SUBNET_MASK:
1723 CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1725 return iface->GetCurrentNetmask();
1728 case NETWORK_GATEWAY_ADDRESS:
1730 CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1732 return iface->GetCurrentDefaultGateway();
1735 case NETWORK_DNS1_ADDRESS:
1737 vector<CStdString> nss = g_application.getNetwork().GetNameServers();
1738 if (nss.size() >= 1)
1742 case NETWORK_DNS2_ADDRESS:
1744 vector<CStdString> nss = g_application.getNetwork().GetNameServers();
1745 if (nss.size() >= 2)
1749 case NETWORK_DHCP_ADDRESS:
1751 CStdString dhcpserver;
1755 case NETWORK_LINK_STATE:
1757 CStdString linkStatus = g_localizeStrings.Get(151);
1759 CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1760 if (iface && iface->IsConnected())
1761 linkStatus += g_localizeStrings.Get(15207);
1763 linkStatus += g_localizeStrings.Get(15208);
1768 case VISUALISATION_PRESET:
1770 CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
1771 g_windowManager.SendMessage(msg);
1772 if (msg.GetPointer())
1774 CVisualisation* viz = NULL;
1775 viz = (CVisualisation*)msg.GetPointer();
1778 strLabel = viz->GetPresetName();
1779 URIUtils::RemoveExtension(strLabel);
1784 case VISUALISATION_NAME:
1787 strLabel = g_guiSettings.GetString("musicplayer.visualisation");
1788 if (CAddonMgr::Get().GetAddon(strLabel,addon) && addon)
1789 strLabel = addon->Name();
1794 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1796 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color1").asString();
1801 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1803 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color2").asString();
1808 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1810 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color3").asString();
1815 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1817 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetArt("fanart");
1820 case SYSTEM_RENDER_VENDOR:
1821 strLabel = g_Windowing.GetRenderVendor();
1823 case SYSTEM_RENDER_RENDERER:
1824 strLabel = g_Windowing.GetRenderRenderer();
1826 case SYSTEM_RENDER_VERSION:
1827 strLabel = g_Windowing.GetRenderVersionString();
1834 // tries to get a integer value for use in progressbars/sliders and such
1835 bool CGUIInfoManager::GetInt(int &value, int info, int contextWindow, const CGUIListItem *item /* = NULL */) const
1837 if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
1838 return GetMultiInfoInt(value, m_multiInfo[info - MULTI_INFO_START], contextWindow);
1840 if (info >= LISTITEM_START && info <= LISTITEM_END)
1841 return GetItemInt(value, item, info);
1847 value = g_application.GetVolume();
1849 case PLAYER_SUBTITLE_DELAY:
1850 value = g_application.GetSubtitleDelay();
1852 case PLAYER_AUDIO_DELAY:
1853 value = g_application.GetAudioDelay();
1855 case PLAYER_PROGRESS:
1856 case PLAYER_PROGRESS_CACHE:
1857 case PLAYER_SEEKBAR:
1858 case PLAYER_CACHELEVEL:
1859 case PLAYER_CHAPTER:
1860 case PLAYER_CHAPTERCOUNT:
1862 if( g_application.IsPlaying() && g_application.m_pPlayer)
1866 case PLAYER_PROGRESS:
1867 value = (int)(g_application.GetPercentage());
1869 case PLAYER_PROGRESS_CACHE:
1870 value = (int)(g_application.GetCachePercentage());
1872 case PLAYER_SEEKBAR:
1873 value = (int)g_application.GetSeekHandler()->GetPercent();
1875 case PLAYER_CACHELEVEL:
1876 value = (int)(g_application.m_pPlayer->GetCacheLevel());
1878 case PLAYER_CHAPTER:
1879 value = g_application.m_pPlayer->GetChapter();
1881 case PLAYER_CHAPTERCOUNT:
1882 value = g_application.m_pPlayer->GetChapterCount();
1888 case SYSTEM_FREE_MEMORY:
1889 case SYSTEM_USED_MEMORY:
1891 MEMORYSTATUSEX stat;
1892 stat.dwLength = sizeof(MEMORYSTATUSEX);
1893 GlobalMemoryStatusEx(&stat);
1894 int memPercentUsed = (int)( 100.0f* (stat.ullTotalPhys - stat.ullAvailPhys)/stat.ullTotalPhys + 0.5f );
1895 if (info == SYSTEM_FREE_MEMORY)
1896 value = 100 - memPercentUsed;
1898 value = memPercentUsed;
1901 case SYSTEM_PROGRESS_BAR:
1903 CGUIDialogProgress *bar = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
1904 if (bar && bar->IsDialogRunning())
1905 value = bar->GetPercentage();
1908 case SYSTEM_FREE_SPACE:
1909 case SYSTEM_USED_SPACE:
1911 g_sysinfo.GetHddSpaceInfo(value, info, true);
1914 case SYSTEM_CPU_USAGE:
1915 value = g_cpuInfo.getUsedPercentage();
1917 case PVR_PLAYING_PROGRESS:
1918 case PVR_ACTUAL_STREAM_SIG_PROGR:
1919 case PVR_ACTUAL_STREAM_SNR_PROGR:
1920 value = g_PVRManager.TranslateIntInfo(info);
1922 case SYSTEM_BATTERY_LEVEL:
1923 value = g_powerManager.BatteryLevel();
1929 unsigned int CGUIInfoManager::Register(const CStdString &expression, int context)
1931 CStdString condition(CGUIInfoLabel::ReplaceLocalize(expression));
1932 condition.TrimLeft(" \t\r\n");
1933 condition.TrimRight(" \t\r\n");
1935 if (condition.IsEmpty())
1938 CSingleLock lock(m_critInfo);
1939 // do we have the boolean expression already registered?
1940 InfoBool test(condition, context);
1941 for (unsigned int i = 0; i < m_bools.size(); ++i)
1943 if (*m_bools[i] == test)
1947 if (condition.find_first_of("|+[]!") != condition.npos)
1948 m_bools.push_back(new InfoExpression(condition, context));
1950 m_bools.push_back(new InfoSingle(condition, context));
1952 return m_bools.size();
1955 bool CGUIInfoManager::EvaluateBool(const CStdString &expression, int contextWindow)
1957 bool result = false;
1958 unsigned int info = Register(expression, contextWindow);
1960 result = GetBoolValue(info);
1965 TODO: what to do with item-based infobools...
1967 1. if condition is between LISTITEM_START and LISTITEM_END
1968 2. if condition is STRING_IS_EMPTY, STRING_COMPARE, STRING_STR, INTEGER_GREATER_THAN and the
1969 corresponding label is between LISTITEM_START and LISTITEM_END
1971 In both cases they shouldn't be in our cache as they depend on items outside of our control atm.
1973 We only pass a listitem object in for controls inside a listitemlayout, so I think it's probably OK
1974 to not cache these, as they're "pushed" out anyway.
1976 The problem is how do we avoid these? The only thing we have to go on is the expression here, so I
1977 guess what we have to do is call through via Update. One thing we don't handle, however, is that the
1978 majority of conditions (even inside lists) don't depend on the listitem at all.
1980 Advantage is that we know this at creation time I think, so could perhaps signal it in IsDirty()?
1982 bool CGUIInfoManager::GetBoolValue(unsigned int expression, const CGUIListItem *item)
1984 if (expression && --expression < m_bools.size())
1985 return m_bools[expression]->Get(m_updateTime, item);
1989 // checks the condition and returns it as necessary. Currently used
1990 // for toggle button controls and visibility of images.
1991 bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListItem *item)
1993 bool bReturn = false;
1994 int condition = abs(condition1);
1996 if (item && condition >= LISTITEM_START && condition < LISTITEM_END)
1997 bReturn = GetItemBool(item, condition);
1998 // Ethernet Link state checking
1999 // Will check if system has a Ethernet Link connection! [Cable in!]
2000 // This can used for the skinner to switch off Network or Inter required functions
2001 else if ( condition == SYSTEM_ALWAYS_TRUE)
2003 else if (condition == SYSTEM_ALWAYS_FALSE)
2005 else if (condition == SYSTEM_ETHERNET_LINK_ACTIVE)
2007 else if (condition == WINDOW_IS_MEDIA)
2008 { // note: This doesn't return true for dialogs (content, favourites, login, videoinfo)
2009 CGUIWindow *pWindow = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
2010 bReturn = (pWindow && pWindow->IsMediaWindow());
2012 else if (condition == PLAYER_MUTED)
2013 bReturn = g_settings.m_bMute;
2014 else if (condition >= LIBRARY_HAS_MUSIC && condition <= LIBRARY_HAS_MUSICVIDEOS)
2015 bReturn = GetLibraryBool(condition);
2016 else if (condition == LIBRARY_IS_SCANNING)
2018 if (g_application.IsMusicScanning() || g_application.IsVideoScanning())
2023 else if (condition == LIBRARY_IS_SCANNING_VIDEO)
2025 bReturn = g_application.IsVideoScanning();
2027 else if (condition == LIBRARY_IS_SCANNING_MUSIC)
2029 bReturn = g_application.IsMusicScanning();
2031 else if (condition == SYSTEM_PLATFORM_LINUX)
2032 #if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(TARGET_ANDROID)
2037 else if (condition == SYSTEM_PLATFORM_WINDOWS)
2043 else if (condition == SYSTEM_PLATFORM_DARWIN)
2044 #ifdef TARGET_DARWIN
2049 else if (condition == SYSTEM_PLATFORM_DARWIN_OSX)
2050 #ifdef TARGET_DARWIN_OSX
2055 else if (condition == SYSTEM_PLATFORM_DARWIN_IOS)
2056 #ifdef TARGET_DARWIN_IOS
2061 else if (condition == SYSTEM_PLATFORM_DARWIN_ATV2)
2062 #ifdef TARGET_DARWIN_IOS_ATV2
2067 else if (condition == SYSTEM_PLATFORM_ANDROID)
2068 #if defined(TARGET_ANDROID)
2073 else if (condition == SYSTEM_MEDIA_DVD)
2074 bReturn = g_mediaManager.IsDiscInDrive();
2075 #ifdef HAS_DVD_DRIVE
2076 else if (condition == SYSTEM_DVDREADY)
2077 bReturn = g_mediaManager.GetDriveStatus() != DRIVE_NOT_READY;
2078 else if (condition == SYSTEM_TRAYOPEN)
2079 bReturn = g_mediaManager.GetDriveStatus() == DRIVE_OPEN;
2081 else if (condition == SYSTEM_CAN_POWERDOWN)
2082 bReturn = g_powerManager.CanPowerdown();
2083 else if (condition == SYSTEM_CAN_SUSPEND)
2084 bReturn = g_powerManager.CanSuspend();
2085 else if (condition == SYSTEM_CAN_HIBERNATE)
2086 bReturn = g_powerManager.CanHibernate();
2087 else if (condition == SYSTEM_CAN_REBOOT)
2088 bReturn = g_powerManager.CanReboot();
2089 else if (condition == SYSTEM_SCREENSAVER_ACTIVE)
2090 bReturn = g_application.IsInScreenSaver();
2092 else if (condition == PLAYER_SHOWINFO)
2093 bReturn = m_playerShowInfo;
2094 else if (condition == PLAYER_SHOWCODEC)
2095 bReturn = m_playerShowCodec;
2096 else if (condition >= MULTI_INFO_START && condition <= MULTI_INFO_END)
2098 return GetMultiInfoBool(m_multiInfo[condition - MULTI_INFO_START], contextWindow, item);
2100 else if (condition == SYSTEM_HASLOCKS)
2101 bReturn = CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE;
2102 else if (condition == SYSTEM_HAS_PVR)
2104 else if (condition == SYSTEM_ISMASTER)
2105 bReturn = CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && g_passwordManager.bMasterUser;
2106 else if (condition == SYSTEM_ISFULLSCREEN)
2107 bReturn = g_Windowing.IsFullScreen();
2108 else if (condition == SYSTEM_ISSTANDALONE)
2109 bReturn = g_application.IsStandAlone();
2110 else if (condition == SYSTEM_ISINHIBIT)
2111 bReturn = g_application.IsIdleShutdownInhibited();
2112 else if (condition == SYSTEM_HAS_SHUTDOWN)
2113 bReturn = (g_guiSettings.GetInt("powermanagement.shutdowntime") > 0);
2114 else if (condition == SYSTEM_LOGGEDON)
2115 bReturn = !(g_windowManager.GetActiveWindow() == WINDOW_LOGIN_SCREEN);
2116 else if (condition == SYSTEM_SHOW_EXIT_BUTTON)
2117 bReturn = g_advancedSettings.m_showExitButton;
2118 else if (condition == SYSTEM_HAS_LOGINSCREEN)
2119 bReturn = CProfilesManager::Get().UsingLoginScreen();
2120 else if (condition == WEATHER_IS_FETCHED)
2121 bReturn = g_weatherManager.IsFetched();
2122 else if (condition >= PVR_CONDITIONS_START && condition <= PVR_CONDITIONS_END)
2123 bReturn = g_PVRManager.TranslateBoolInfo(condition);
2125 else if (condition == SYSTEM_INTERNET_STATE)
2127 g_sysinfo.GetInfo(condition);
2128 bReturn = g_sysinfo.HasInternet();
2130 else if (condition == SKIN_HAS_VIDEO_OVERLAY)
2132 bReturn = g_windowManager.IsOverlayAllowed() && g_application.IsPlayingVideo();
2134 else if (condition == SKIN_HAS_MUSIC_OVERLAY)
2136 bReturn = g_windowManager.IsOverlayAllowed() && g_application.IsPlayingAudio();
2138 else if (condition == CONTAINER_HASFILES || condition == CONTAINER_HASFOLDERS)
2140 CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2143 const CFileItemList& items=((CGUIMediaWindow*)pWindow)->CurrentDirectory();
2144 for (int i=0;i<items.Size();++i)
2146 CFileItemPtr item=items.Get(i);
2147 if (!item->m_bIsFolder && condition == CONTAINER_HASFILES)
2152 else if (item->m_bIsFolder && !item->IsParentFolder() && condition == CONTAINER_HASFOLDERS)
2160 else if (condition == CONTAINER_STACKED)
2162 CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2164 bReturn = ((CGUIMediaWindow*)pWindow)->CurrentDirectory().GetProperty("isstacked").asBoolean();
2166 else if (condition == CONTAINER_HAS_THUMB)
2168 CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2170 bReturn = ((CGUIMediaWindow*)pWindow)->CurrentDirectory().HasArt("thumb");
2172 else if (condition == CONTAINER_HAS_NEXT || condition == CONTAINER_HAS_PREVIOUS || condition == CONTAINER_SCROLLING)
2174 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2177 const CGUIControl* control = window->GetControl(window->GetViewContainerID());
2179 bReturn = control->GetCondition(condition, 0);
2182 else if (condition == CONTAINER_CAN_FILTER)
2184 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2186 bReturn = !((CGUIMediaWindow*)window)->CanFilterAdvanced();
2188 else if (condition == CONTAINER_CAN_FILTERADVANCED)
2190 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2192 bReturn = ((CGUIMediaWindow*)window)->CanFilterAdvanced();
2194 else if (condition == CONTAINER_FILTERED)
2196 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2198 bReturn = ((CGUIMediaWindow*)window)->IsFiltered();
2200 else if (condition == VIDEOPLAYER_HAS_INFO)
2201 bReturn = ((m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->IsEmpty()) ||
2202 (m_currentFile->HasPVRChannelInfoTag() && !m_currentFile->GetPVRChannelInfoTag()->IsEmpty()));
2203 else if (condition >= CONTAINER_SCROLL_PREVIOUS && condition <= CONTAINER_SCROLL_NEXT)
2205 // no parameters, so we assume it's just requested for a media window. It therefore
2206 // can only happen if the list has focus.
2207 CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2210 map<int,int>::const_iterator it = m_containerMoves.find(pWindow->GetViewContainerID());
2211 if (it != m_containerMoves.end())
2213 if (condition > CONTAINER_STATIC) // moving up
2214 bReturn = it->second >= std::max(condition - CONTAINER_STATIC, 1);
2216 bReturn = it->second <= std::min(condition - CONTAINER_STATIC, -1);
2220 else if (condition == SLIDESHOW_ISPAUSED)
2222 CGUIWindowSlideShow *slideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
2223 bReturn = (slideShow && slideShow->IsPaused());
2225 else if (condition == SLIDESHOW_ISRANDOM)
2227 CGUIWindowSlideShow *slideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
2228 bReturn = (slideShow && slideShow->IsShuffled());
2230 else if (condition == SLIDESHOW_ISACTIVE)
2232 CGUIWindowSlideShow *slideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
2233 bReturn = (slideShow && slideShow->InSlideShow());
2235 else if (g_application.IsPlaying())
2239 case PLAYER_HAS_MEDIA:
2242 case PLAYER_HAS_AUDIO:
2243 bReturn = g_application.IsPlayingAudio();
2245 case PLAYER_HAS_VIDEO:
2246 bReturn = g_application.IsPlayingVideo();
2248 case PLAYER_PLAYING:
2249 bReturn = !g_application.IsPaused() && (g_application.GetPlaySpeed() == 1);
2252 bReturn = g_application.IsPaused();
2254 case PLAYER_REWINDING:
2255 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() < 1;
2257 case PLAYER_FORWARDING:
2258 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() > 1;
2260 case PLAYER_REWINDING_2x:
2261 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -2;
2263 case PLAYER_REWINDING_4x:
2264 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -4;
2266 case PLAYER_REWINDING_8x:
2267 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -8;
2269 case PLAYER_REWINDING_16x:
2270 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -16;
2272 case PLAYER_REWINDING_32x:
2273 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -32;
2275 case PLAYER_FORWARDING_2x:
2276 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 2;
2278 case PLAYER_FORWARDING_4x:
2279 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 4;
2281 case PLAYER_FORWARDING_8x:
2282 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 8;
2284 case PLAYER_FORWARDING_16x:
2285 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 16;
2287 case PLAYER_FORWARDING_32x:
2288 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 32;
2290 case PLAYER_CAN_RECORD:
2291 bReturn = g_application.m_pPlayer->CanRecord();
2293 case PLAYER_CAN_PAUSE:
2294 bReturn = g_application.m_pPlayer->CanPause();
2296 case PLAYER_CAN_SEEK:
2297 bReturn = g_application.m_pPlayer->CanSeek();
2299 case PLAYER_RECORDING:
2300 bReturn = g_application.m_pPlayer->IsRecording();
2302 case PLAYER_DISPLAY_AFTER_SEEK:
2303 bReturn = GetDisplayAfterSeek();
2305 case PLAYER_CACHING:
2306 bReturn = g_application.m_pPlayer->IsCaching();
2308 case PLAYER_SEEKBAR:
2310 CGUIDialog *seekBar = (CGUIDialog*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
2311 bReturn = seekBar ? seekBar->IsDialogRunning() : false;
2314 case PLAYER_SEEKING:
2315 bReturn = m_playerSeeking;
2317 case PLAYER_SHOWTIME:
2318 bReturn = m_playerShowTime;
2320 case PLAYER_PASSTHROUGH:
2321 bReturn = g_application.m_pPlayer && g_application.m_pPlayer->IsPassthrough();
2323 case MUSICPM_ENABLED:
2324 bReturn = g_partyModeManager.IsEnabled();
2326 case MUSICPLAYER_HASPREVIOUS:
2328 // requires current playlist be PLAYLIST_MUSIC
2330 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2331 bReturn = (g_playlistPlayer.GetCurrentSong() > 0); // not first song
2334 case MUSICPLAYER_HASNEXT:
2336 // requires current playlist be PLAYLIST_MUSIC
2338 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2339 bReturn = (g_playlistPlayer.GetCurrentSong() < (g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC).size() - 1)); // not last song
2342 case MUSICPLAYER_PLAYLISTPLAYING:
2345 if (g_application.IsPlayingAudio() && g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2349 case VIDEOPLAYER_USING_OVERLAYS:
2350 bReturn = (g_guiSettings.GetInt("videoplayer.rendermethod") == RENDER_OVERLAYS);
2352 case VIDEOPLAYER_ISFULLSCREEN:
2353 bReturn = g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO;
2355 case VIDEOPLAYER_HASMENU:
2356 bReturn = g_application.m_pPlayer->HasMenu();
2358 case PLAYLIST_ISRANDOM:
2359 bReturn = g_playlistPlayer.IsShuffled(g_playlistPlayer.GetCurrentPlaylist());
2361 case PLAYLIST_ISREPEAT:
2362 bReturn = g_playlistPlayer.GetRepeat(g_playlistPlayer.GetCurrentPlaylist()) == PLAYLIST::REPEAT_ALL;
2364 case PLAYLIST_ISREPEATONE:
2365 bReturn = g_playlistPlayer.GetRepeat(g_playlistPlayer.GetCurrentPlaylist()) == PLAYLIST::REPEAT_ONE;
2367 case PLAYER_HASDURATION:
2368 bReturn = g_application.GetTotalTime() > 0;
2370 case VIDEOPLAYER_HASTELETEXT:
2371 if (g_application.m_pPlayer->GetTeletextCache())
2374 case VIDEOPLAYER_HASSUBTITLES:
2375 bReturn = g_application.m_pPlayer->GetSubtitleCount() > 0;
2377 case VIDEOPLAYER_SUBTITLESENABLED:
2378 bReturn = g_application.m_pPlayer->GetSubtitleVisible();
2380 case VISUALISATION_LOCKED:
2382 CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
2383 g_windowManager.SendMessage(msg);
2384 if (msg.GetPointer())
2386 CVisualisation *pVis = (CVisualisation *)msg.GetPointer();
2387 bReturn = pVis->IsLocked();
2391 case VISUALISATION_ENABLED:
2392 bReturn = !g_guiSettings.GetString("musicplayer.visualisation").IsEmpty();
2394 case VIDEOPLAYER_HAS_EPG:
2395 if (m_currentFile->HasPVRChannelInfoTag())
2398 bReturn = m_currentFile->GetPVRChannelInfoTag()->GetEPGNow(epgTag);
2401 default: // default, use integer value different from 0 as true
2404 bReturn = GetInt(val, condition) && val != 0;
2413 /// \brief Examines the multi information sent and returns true or false accordingly.
2414 bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, const CGUIListItem *item)
2416 bool bReturn = false;
2417 int condition = abs(info.m_info);
2419 if (condition >= LISTITEM_START && condition <= LISTITEM_END)
2423 CGUIWindow *window = NULL;
2424 int data1 = info.GetData1();
2425 if (!data1) // No container specified, so we lookup the current view container
2427 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
2428 if (window && window->IsMediaWindow())
2429 data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
2432 if (!window) // If we don't have a window already (from lookup above), get one
2433 window = GetWindowWithCondition(contextWindow, 0);
2437 const CGUIControl *control = window->GetControl(data1);
2438 if (control && control->IsContainer())
2439 item = ((IGUIContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()).get();
2442 if (item) // If we got a valid item, do the lookup
2443 bReturn = GetItemBool(item, condition); // Image prioritizes images over labels (in the case of music item ratings for instance)
2451 bReturn = CSkinSettings::Get().GetBool(info.GetData1());
2456 if (info.GetData2())
2457 bReturn = StringUtils::EqualsNoCase(CSkinSettings::Get().GetString(info.GetData1()), m_stringParameters[info.GetData2()]);
2459 bReturn = !CSkinSettings::Get().GetString(info.GetData1()).empty();
2462 case SKIN_HAS_THEME:
2464 CStdString theme = g_guiSettings.GetString("lookandfeel.skintheme");
2466 URIUtils::RemoveExtension(theme);
2467 bReturn = theme.Equals(m_stringParameters[info.GetData1()]);
2470 case STRING_IS_EMPTY:
2471 // note: Get*Image() falls back to Get*Label(), so this should cover all of them
2472 if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2473 bReturn = GetItemImage((const CFileItem *)item, info.GetData1()).IsEmpty();
2475 bReturn = GetImage(info.GetData1(), contextWindow).IsEmpty();
2477 case STRING_COMPARE:
2480 if (info.GetData2() < 0) // info labels are stored with negative numbers
2482 int info2 = -info.GetData2();
2483 if (item && item->IsFileItem() && info2 >= LISTITEM_START && info2 < LISTITEM_END)
2484 compare = GetItemImage((const CFileItem *)item, info2);
2486 compare = GetImage(info2, contextWindow);
2488 else if (info.GetData2() < (int)m_stringParameters.size())
2489 { // conditional string
2490 compare = m_stringParameters[info.GetData2()];
2492 if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2493 bReturn = GetItemImage((const CFileItem *)item, info.GetData1()).Equals(compare);
2495 bReturn = GetImage(info.GetData1(), contextWindow).Equals(compare);
2498 case INTEGER_GREATER_THAN:
2501 if (GetInt(integer, info.GetData1(), contextWindow, item))
2502 bReturn = integer > info.GetData2();
2507 if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2508 value = GetItemImage((const CFileItem *)item, info.GetData1());
2510 value = GetImage(info.GetData1(), contextWindow);
2512 // Handle the case when a value contains time separator (:). This makes IntegerGreaterThan
2513 // useful for Player.Time* members without adding a separate set of members returning time in seconds
2514 if ( value.find_first_of( ':' ) != value.npos )
2515 bReturn = StringUtils::TimeStringToSeconds( value ) > info.GetData2();
2517 bReturn = atoi( value.c_str() ) > info.GetData2();
2522 case STRING_STR_LEFT:
2523 case STRING_STR_RIGHT:
2525 CStdString compare = m_stringParameters[info.GetData2()];
2526 // our compare string is already in lowercase, so lower case our label as well
2527 // as CStdString::Find() is case sensitive
2529 if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2530 label = GetItemImage((const CFileItem *)item, info.GetData1()).ToLower();
2532 label = GetImage(info.GetData1(), contextWindow).ToLower();
2533 if (condition == STRING_STR_LEFT)
2534 bReturn = label.Find(compare) == 0;
2535 else if (condition == STRING_STR_RIGHT)
2536 bReturn = label.Find(compare) == (int)(label.size()-compare.size());
2538 bReturn = label.Find(compare) > -1;
2541 case SYSTEM_ALARM_LESS_OR_EQUAL:
2543 int time = lrint(g_alarmClock.GetRemaining(m_stringParameters[info.GetData1()]));
2544 int timeCompare = atoi(m_stringParameters[info.GetData2()]);
2546 bReturn = timeCompare >= time;
2551 case SYSTEM_IDLE_TIME:
2552 bReturn = g_application.GlobalIdleTime() >= (int)info.GetData1();
2554 case CONTROL_GROUP_HAS_FOCUS:
2556 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2558 bReturn = window->ControlGroupHasFocus(info.GetData1(), info.GetData2());
2561 case CONTROL_IS_VISIBLE:
2563 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2566 // Note: This'll only work for unique id's
2567 const CGUIControl *control = window->GetControl(info.GetData1());
2569 bReturn = control->IsVisible();
2573 case CONTROL_IS_ENABLED:
2575 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2578 // Note: This'll only work for unique id's
2579 const CGUIControl *control = window->GetControl(info.GetData1());
2581 bReturn = !control->IsDisabled();
2585 case CONTROL_HAS_FOCUS:
2587 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2589 bReturn = (window->GetFocusedControlID() == (int)info.GetData1());
2593 if (info.GetData1())
2594 bReturn = ((int)info.GetData1() == m_nextWindowID);
2597 CGUIWindow *window = g_windowManager.GetWindow(m_nextWindowID);
2598 if (window && URIUtils::GetFileName(window->GetProperty("xmlfile").asString()).Equals(m_stringParameters[info.GetData2()]))
2602 case WINDOW_PREVIOUS:
2603 if (info.GetData1())
2604 bReturn = ((int)info.GetData1() == m_prevWindowID);
2607 CGUIWindow *window = g_windowManager.GetWindow(m_prevWindowID);
2608 if (window && URIUtils::GetFileName(window->GetProperty("xmlfile").asString()).Equals(m_stringParameters[info.GetData2()]))
2612 case WINDOW_IS_VISIBLE:
2613 if (info.GetData1())
2614 bReturn = g_windowManager.IsWindowVisible(info.GetData1());
2616 bReturn = g_windowManager.IsWindowVisible(m_stringParameters[info.GetData2()]);
2618 case WINDOW_IS_TOPMOST:
2619 if (info.GetData1())
2620 bReturn = g_windowManager.IsWindowTopMost(info.GetData1());
2622 bReturn = g_windowManager.IsWindowTopMost(m_stringParameters[info.GetData2()]);
2624 case WINDOW_IS_ACTIVE:
2625 if (info.GetData1())
2626 bReturn = g_windowManager.IsWindowActive(info.GetData1());
2628 bReturn = g_windowManager.IsWindowActive(m_stringParameters[info.GetData2()]);
2630 case SYSTEM_HAS_ALARM:
2631 bReturn = g_alarmClock.HasAlarm(m_stringParameters[info.GetData1()]);
2633 case SYSTEM_GET_BOOL:
2634 bReturn = g_guiSettings.GetBool(m_stringParameters[info.GetData1()]);
2636 case SYSTEM_HAS_CORE_ID:
2637 bReturn = g_cpuInfo.HasCoreId(info.GetData1());
2639 case SYSTEM_SETTING:
2641 if ( m_stringParameters[info.GetData1()].Equals("hidewatched") )
2643 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2645 bReturn = CMediaSettings::Get().GetWatchedMode(((CGUIMediaWindow *)window)->CurrentDirectory().GetContent()) == WatchedModeUnwatched;
2649 case SYSTEM_HAS_ADDON:
2652 bReturn = CAddonMgr::Get().GetAddon(m_stringParameters[info.GetData1()],addon) && addon;
2655 case CONTAINER_SCROLL_PREVIOUS:
2656 case CONTAINER_MOVE_PREVIOUS:
2657 case CONTAINER_MOVE_NEXT:
2658 case CONTAINER_SCROLL_NEXT:
2660 map<int,int>::const_iterator it = m_containerMoves.find(info.GetData1());
2661 if (it != m_containerMoves.end())
2663 if (condition > CONTAINER_STATIC) // moving up
2664 bReturn = it->second >= std::max(condition - CONTAINER_STATIC, 1);
2666 bReturn = it->second <= std::min(condition - CONTAINER_STATIC, -1);
2670 case CONTAINER_CONTENT:
2673 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2676 if (window->GetID() == WINDOW_DIALOG_MUSIC_INFO)
2677 content = ((CGUIDialogMusicInfo *)window)->CurrentDirectory().GetContent();
2678 else if (window->GetID() == WINDOW_DIALOG_VIDEO_INFO)
2679 content = ((CGUIDialogVideoInfo *)window)->CurrentDirectory().GetContent();
2681 if (content.IsEmpty())
2683 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2685 content = ((CGUIMediaWindow *)window)->CurrentDirectory().GetContent();
2687 bReturn = m_stringParameters[info.GetData2()].Equals(content);
2691 case CONTAINER_COLUMN:
2692 case CONTAINER_POSITION:
2693 case CONTAINER_HAS_NEXT:
2694 case CONTAINER_HAS_PREVIOUS:
2695 case CONTAINER_SCROLLING:
2696 case CONTAINER_SUBITEM:
2698 const CGUIControl *control = NULL;
2699 if (info.GetData1())
2700 { // container specified
2701 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2703 control = window->GetControl(info.GetData1());
2706 { // no container specified - assume a mediawindow
2707 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2709 control = window->GetControl(window->GetViewContainerID());
2712 bReturn = control->GetCondition(condition, info.GetData2());
2715 case CONTAINER_HAS_FOCUS:
2716 { // grab our container
2717 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2720 const CGUIControl *control = window->GetControl(info.GetData1());
2721 if (control && control->IsContainer())
2723 CFileItemPtr item = boost::static_pointer_cast<CFileItem>(((IGUIContainer *)control)->GetListItem(0));
2724 if (item && item->m_iprogramCount == info.GetData2()) // programcount used to store item id
2730 case VIDEOPLAYER_CONTENT:
2732 CStdString strContent="movies";
2733 if (!m_currentFile->HasVideoInfoTag() || m_currentFile->GetVideoInfoTag()->IsEmpty())
2734 strContent = "files";
2735 if (m_currentFile->HasVideoInfoTag() && m_currentFile->GetVideoInfoTag()->m_iSeason > -1) // episode
2736 strContent = "episodes";
2737 if (m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->m_artist.empty())
2738 strContent = "musicvideos";
2739 if (m_currentFile->HasVideoInfoTag() && m_currentFile->GetVideoInfoTag()->m_strStatus == "livetv")
2740 strContent = "livetv";
2741 if (m_currentFile->HasPVRChannelInfoTag())
2742 strContent = "livetv";
2743 bReturn = m_stringParameters[info.GetData1()].Equals(strContent);
2746 case CONTAINER_SORT_METHOD:
2748 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2751 const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
2753 bReturn = ((unsigned int)viewState->GetSortMethod() == info.GetData1());
2757 case CONTAINER_SORT_DIRECTION:
2759 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2762 const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
2764 bReturn = ((unsigned int)viewState->GetDisplaySortOrder() == info.GetData1());
2770 if (info.GetData2() == -1) // info doesn't contain valid startDate
2772 CDateTime date = CDateTime::GetCurrentDateTime();
2773 int currentDate = date.GetMonth()*100+date.GetDay();
2774 int startDate = info.GetData1();
2775 int stopDate = info.GetData2();
2777 if (stopDate < startDate)
2778 bReturn = currentDate >= startDate || currentDate < stopDate;
2780 bReturn = currentDate >= startDate && currentDate < stopDate;
2785 CDateTime time=CDateTime::GetCurrentDateTime();
2786 int currentTime = time.GetMinuteOfDay();
2787 int startTime = info.GetData1();
2788 int stopTime = info.GetData2();
2790 if (stopTime < startTime)
2791 bReturn = currentTime >= startTime || currentTime < stopTime;
2793 bReturn = currentTime >= startTime && currentTime < stopTime;
2796 case MUSICPLAYER_EXISTS:
2798 int index = info.GetData2();
2799 if (info.GetData1() == 1)
2801 if (g_playlistPlayer.GetCurrentPlaylist() != PLAYLIST_MUSIC)
2803 index += g_playlistPlayer.GetCurrentSong();
2805 if (index >= 0 && index < g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC).size())
2812 return (info.m_info < 0) ? !bReturn : bReturn;
2815 bool CGUIInfoManager::GetMultiInfoInt(int &value, const GUIInfo &info, int contextWindow) const
2817 if (info.m_info >= LISTITEM_START && info.m_info <= LISTITEM_END)
2820 CGUIWindow *window = NULL;
2822 int data1 = info.GetData1();
2823 if (!data1) // No container specified, so we lookup the current view container
2825 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
2826 if (window && window->IsMediaWindow())
2827 data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
2830 if (!window) // If we don't have a window already (from lookup above), get one
2831 window = GetWindowWithCondition(contextWindow, 0);
2835 const CGUIControl *control = window->GetControl(data1);
2836 if (control && control->IsContainer())
2837 item = boost::static_pointer_cast<CFileItem>(((IGUIContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()));
2840 if (item) // If we got a valid item, do the lookup
2841 return GetItemInt(value, item.get(), info.m_info);
2847 /// \brief Examines the multi information sent and returns the string as appropriate
2848 CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWindow, CStdString *fallback)
2850 if (info.m_info == SKIN_STRING)
2852 return CSkinSettings::Get().GetString(info.GetData1());
2854 else if (info.m_info == SKIN_BOOL)
2856 bool bInfo = CSkinSettings::Get().GetBool(info.GetData1());
2858 return g_localizeStrings.Get(20122);
2860 if (info.m_info >= LISTITEM_START && info.m_info <= LISTITEM_END)
2863 CGUIWindow *window = NULL;
2865 int data1 = info.GetData1();
2866 if (!data1) // No container specified, so we lookup the current view container
2868 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
2869 if (window && window->IsMediaWindow())
2870 data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
2873 if (!window) // If we don't have a window already (from lookup above), get one
2874 window = GetWindowWithCondition(contextWindow, 0);
2878 const CGUIControl *control = window->GetControl(data1);
2879 if (control && control->IsContainer())
2880 item = boost::static_pointer_cast<CFileItem>(((IGUIContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()));
2883 if (item) // If we got a valid item, do the lookup
2884 return GetItemImage(item.get(), info.m_info, fallback); // Image prioritizes images over labels (in the case of music item ratings for instance)
2886 else if (info.m_info == PLAYER_TIME)
2888 return GetCurrentPlayTime((TIME_FORMAT)info.GetData1());
2890 else if (info.m_info == PLAYER_TIME_REMAINING)
2892 return GetCurrentPlayTimeRemaining((TIME_FORMAT)info.GetData1());
2894 else if (info.m_info == PLAYER_FINISH_TIME)
2897 CEpgInfoTag currentTag;
2898 if (GetEpgInfoTag(currentTag))
2899 time = currentTag.EndAsLocalTime();
2902 time = CDateTime::GetCurrentDateTime();
2903 time += CDateTimeSpan(0, 0, 0, GetPlayTimeRemaining());
2905 return LocalizeTime(time, (TIME_FORMAT)info.GetData1());
2907 else if (info.m_info == PLAYER_START_TIME)
2910 CEpgInfoTag currentTag;
2911 if (GetEpgInfoTag(currentTag))
2912 time = currentTag.StartAsLocalTime();
2915 time = CDateTime::GetCurrentDateTime();
2916 time -= CDateTimeSpan(0, 0, 0, (int)GetPlayTime());
2918 return LocalizeTime(time, (TIME_FORMAT)info.GetData1());
2920 else if (info.m_info == PLAYER_TIME_SPEED)
2923 if (g_application.GetPlaySpeed() != 1)
2924 strTime.Format("%s (%ix)", GetCurrentPlayTime((TIME_FORMAT)info.GetData1()).c_str(), g_application.GetPlaySpeed());
2926 strTime = GetCurrentPlayTime();
2929 else if (info.m_info == PLAYER_DURATION)
2931 return GetDuration((TIME_FORMAT)info.GetData1());
2933 else if (info.m_info == PLAYER_SEEKTIME)
2935 return GetCurrentSeekTime((TIME_FORMAT)info.GetData1());
2937 else if (info.m_info == PLAYER_SEEKOFFSET)
2939 CStdString seekOffset = StringUtils::SecondsToTimeString(abs(m_seekOffset), (TIME_FORMAT)info.GetData1());
2940 if (m_seekOffset < 0)
2941 return "-" + seekOffset;
2942 if (m_seekOffset > 0)
2943 return "+" + seekOffset;
2945 else if (info.m_info == PLAYER_ITEM_ART)
2947 return m_currentFile->GetArt(m_stringParameters[info.GetData1()]);
2949 else if (info.m_info == SYSTEM_TIME)
2951 return GetTime((TIME_FORMAT)info.GetData1());
2953 else if (info.m_info == SYSTEM_DATE)
2955 CDateTime time=CDateTime::GetCurrentDateTime();
2956 return time.GetAsLocalizedDate(m_stringParameters[info.GetData1()],false);
2958 else if (info.m_info == CONTAINER_NUM_PAGES || info.m_info == CONTAINER_CURRENT_PAGE ||
2959 info.m_info == CONTAINER_NUM_ITEMS || info.m_info == CONTAINER_POSITION)
2961 const CGUIControl *control = NULL;
2962 if (info.GetData1())
2963 { // container specified
2964 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2966 control = window->GetControl(info.GetData1());
2969 { // no container specified - assume a mediawindow
2970 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2972 control = window->GetControl(window->GetViewContainerID());
2976 if (control->IsContainer())
2977 return ((IGUIContainer *)control)->GetLabel(info.m_info);
2978 else if (control->GetControlType() == CGUIControl::GUICONTROL_TEXTBOX)
2979 return ((CGUITextBox *)control)->GetLabel(info.m_info);
2982 else if (info.m_info == SYSTEM_GET_CORE_USAGE)
2985 strCpu.Format("%4.2f", g_cpuInfo.GetCoreInfo(atoi(m_stringParameters[info.GetData1()].c_str())).m_fPct);
2988 else if (info.m_info >= MUSICPLAYER_TITLE && info.m_info <= MUSICPLAYER_ALBUM_ARTIST)
2989 return GetMusicPlaylistInfo(info);
2990 else if (info.m_info == CONTAINER_PROPERTY)
2992 CGUIWindow *window = NULL;
2993 if (info.GetData1())
2994 { // container specified
2995 window = GetWindowWithCondition(contextWindow, 0);
2998 { // no container specified - assume a mediawindow
2999 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
3002 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty(m_stringParameters[info.GetData2()]).asString();
3004 else if (info.m_info == CONTROL_GET_LABEL)
3006 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
3009 const CGUIControl *control = window->GetControl(info.GetData1());
3011 return control->GetDescription();
3014 else if (info.m_info == WINDOW_PROPERTY)
3016 CGUIWindow *window = NULL;
3017 if (info.GetData1())
3018 { // window specified
3019 window = g_windowManager.GetWindow(info.GetData1());//GetWindowWithCondition(contextWindow, 0);
3022 { // no window specified - assume active
3023 window = GetWindowWithCondition(contextWindow, 0);
3027 return window->GetProperty(m_stringParameters[info.GetData2()]).asString();
3029 else if (info.m_info == SYSTEM_ADDON_TITLE ||
3030 info.m_info == SYSTEM_ADDON_ICON)
3032 // This logic does not check/care whether an addon has been disabled/marked as broken,
3033 // it simply retrieves it's name or icon that means if an addon is placed on the home screen it
3034 // will stay there even if it's disabled/marked as broken. This might need to be changed/fixed
3037 if (info.GetData2() == 0)
3038 CAddonMgr::Get().GetAddon(const_cast<CGUIInfoManager*>(this)->GetLabel(info.GetData1(), contextWindow),addon,ADDON_UNKNOWN,false);
3040 CAddonMgr::Get().GetAddon(m_stringParameters[info.GetData1()],addon,ADDON_UNKNOWN,false);
3041 if (addon && info.m_info == SYSTEM_ADDON_TITLE)
3042 return addon->Name();
3043 if (addon && info.m_info == SYSTEM_ADDON_ICON)
3044 return addon->Icon();
3047 return StringUtils::EmptyString;
3050 /// \brief Obtains the filename of the image to show from whichever subsystem is needed
3051 CStdString CGUIInfoManager::GetImage(int info, int contextWindow, CStdString *fallback)
3053 if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
3054 return GetSkinVariableString(info, true);
3056 if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
3058 return GetMultiInfoLabel(m_multiInfo[info - MULTI_INFO_START], contextWindow, fallback);
3060 else if (info == WEATHER_CONDITIONS)
3061 return g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON);
3062 else if (info == SYSTEM_PROFILETHUMB)
3064 CStdString thumb = CProfilesManager::Get().GetCurrentProfile().getThumb();
3065 if (thumb.IsEmpty())
3066 thumb = "unknown-user.png";
3069 else if (info == MUSICPLAYER_COVER)
3071 if (!g_application.IsPlayingAudio()) return "";
3073 *fallback = "DefaultAlbumCover.png";
3074 return m_currentFile->HasArt("thumb") ? m_currentFile->GetArt("thumb") : "DefaultAlbumCover.png";
3076 else if (info == MUSICPLAYER_RATING)
3078 if (!g_application.IsPlayingAudio()) return "";
3079 return GetItemImage(m_currentFile, LISTITEM_RATING);
3081 else if (info == PLAYER_STAR_RATING)
3083 if (!g_application.IsPlaying()) return "";
3084 return GetItemImage(m_currentFile, LISTITEM_STAR_RATING);
3086 else if (info == VIDEOPLAYER_COVER)
3088 if (!g_application.IsPlayingVideo()) return "";
3090 *fallback = "DefaultVideoCover.png";
3091 if(m_currentMovieThumb.IsEmpty())
3092 return m_currentFile->HasArt("thumb") ? m_currentFile->GetArt("thumb") : "DefaultVideoCover.png";
3093 else return m_currentMovieThumb;
3095 else if (info == CONTAINER_FOLDERTHUMB)
3097 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
3099 return GetItemImage(&const_cast<CFileItemList&>(((CGUIMediaWindow*)window)->CurrentDirectory()), LISTITEM_THUMB, fallback);
3101 else if (info == CONTAINER_TVSHOWTHUMB)
3103 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
3105 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetArt("tvshow.thumb");
3107 else if (info == CONTAINER_SEASONTHUMB)
3109 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
3111 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetArt("season.thumb");
3113 else if (info == LISTITEM_THUMB || info == LISTITEM_ICON || info == LISTITEM_ACTUAL_ICON ||
3114 info == LISTITEM_OVERLAY || info == LISTITEM_RATING || info == LISTITEM_STAR_RATING)
3116 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
3119 CFileItemPtr item = window->GetCurrentListItem();
3121 return GetItemImage(item.get(), info, fallback);
3124 return GetLabel(info, contextWindow, fallback);
3127 CStdString CGUIInfoManager::GetDate(bool bNumbersOnly)
3129 CDateTime time=CDateTime::GetCurrentDateTime();
3130 return time.GetAsLocalizedDate(!bNumbersOnly);
3133 CStdString CGUIInfoManager::GetTime(TIME_FORMAT format) const
3135 CDateTime time=CDateTime::GetCurrentDateTime();
3136 return LocalizeTime(time, format);
3139 CStdString CGUIInfoManager::LocalizeTime(const CDateTime &time, TIME_FORMAT format) const
3141 const CStdString timeFormat = g_langInfo.GetTimeFormat();
3142 bool use12hourclock = timeFormat.Find('h') != -1;
3145 case TIME_FORMAT_GUESS:
3146 return time.GetAsLocalizedTime("", false);
3147 case TIME_FORMAT_SS:
3148 return time.GetAsLocalizedTime("ss", true);
3149 case TIME_FORMAT_MM:
3150 return time.GetAsLocalizedTime("mm", true);
3151 case TIME_FORMAT_MM_SS:
3152 return time.GetAsLocalizedTime("mm:ss", true);
3153 case TIME_FORMAT_HH: // this forces it to a 12 hour clock
3154 return time.GetAsLocalizedTime(use12hourclock ? "h" : "HH", false);
3155 case TIME_FORMAT_HH_MM:
3156 return time.GetAsLocalizedTime(use12hourclock ? "h:mm" : "HH:mm", false);
3157 case TIME_FORMAT_HH_MM_XX:
3158 return time.GetAsLocalizedTime(use12hourclock ? "h:mm xx" : "HH:mm", false);
3159 case TIME_FORMAT_HH_MM_SS:
3160 return time.GetAsLocalizedTime("hh:mm:ss", true);
3161 case TIME_FORMAT_HH_MM_SS_XX:
3162 return time.GetAsLocalizedTime("hh:mm:ss xx", true);
3164 return time.GetAsLocalizedTime("h", false);
3165 case TIME_FORMAT_H_MM_SS:
3166 return time.GetAsLocalizedTime("h:mm:ss", true);
3167 case TIME_FORMAT_H_MM_SS_XX:
3168 return time.GetAsLocalizedTime("h:mm:ss xx", true);
3169 case TIME_FORMAT_XX:
3170 return use12hourclock ? time.GetAsLocalizedTime("xx", false) : "";
3174 return time.GetAsLocalizedTime("", false);
3177 CStdString CGUIInfoManager::GetDuration(TIME_FORMAT format) const
3179 if (g_application.IsPlayingAudio() && m_currentFile->HasMusicInfoTag())
3181 const CMusicInfoTag& tag = *m_currentFile->GetMusicInfoTag();
3182 if (tag.GetDuration() > 0)
3183 return StringUtils::SecondsToTimeString(tag.GetDuration(), format);
3185 if (g_application.IsPlayingVideo() && !m_currentMovieDuration.IsEmpty())
3186 return m_currentMovieDuration; // for tuxbox
3187 unsigned int iTotal = (unsigned int)g_application.GetTotalTime();
3189 return StringUtils::SecondsToTimeString(iTotal, format);
3193 CStdString CGUIInfoManager::GetMusicPartyModeLabel(int item)
3196 if (item >= MUSICPM_SONGSPLAYED && item <= MUSICPM_RANDOMSONGSPICKED)
3201 case MUSICPM_SONGSPLAYED:
3203 iSongs = g_partyModeManager.GetSongsPlayed();
3206 case MUSICPM_MATCHINGSONGS:
3208 iSongs = g_partyModeManager.GetMatchingSongs();
3211 case MUSICPM_MATCHINGSONGSPICKED:
3213 iSongs = g_partyModeManager.GetMatchingSongsPicked();
3216 case MUSICPM_MATCHINGSONGSLEFT:
3218 iSongs = g_partyModeManager.GetMatchingSongsLeft();
3221 case MUSICPM_RELAXEDSONGSPICKED:
3223 iSongs = g_partyModeManager.GetRelaxedSongs();
3226 case MUSICPM_RANDOMSONGSPICKED:
3228 iSongs = g_partyModeManager.GetRandomSongs();
3234 CStdString strLabel;
3235 strLabel.Format("%i", iSongs);
3241 const CStdString CGUIInfoManager::GetMusicPlaylistInfo(const GUIInfo& info)
3243 PLAYLIST::CPlayList& playlist = g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC);
3244 if (playlist.size() < 1)
3246 int index = info.GetData2();
3247 if (info.GetData1() == 1)
3248 { // relative index (requires current playlist is PLAYLIST_MUSIC)
3249 if (g_playlistPlayer.GetCurrentPlaylist() != PLAYLIST_MUSIC)
3251 index = g_playlistPlayer.GetNextSong(index);
3253 if (index < 0 || index >= playlist.size())
3255 CFileItemPtr playlistItem = playlist[index];
3256 if (!playlistItem->GetMusicInfoTag()->Loaded())
3258 playlistItem->LoadMusicTag();
3259 playlistItem->GetMusicInfoTag()->SetLoaded();
3261 // try to set a thumbnail
3262 if (!playlistItem->HasArt("thumb"))
3264 CMusicThumbLoader loader;
3265 loader.LoadItem(playlistItem.get());
3266 // still no thumb? then just the set the default cover
3267 if (!playlistItem->HasArt("thumb"))
3268 playlistItem->SetArt("thumb", "DefaultAlbumCover.png");
3270 if (info.m_info == MUSICPLAYER_PLAYLISTPOS)
3272 CStdString strPosition = "";
3273 strPosition.Format("%i", index + 1);
3276 else if (info.m_info == MUSICPLAYER_COVER)
3277 return playlistItem->GetArt("thumb");
3278 return GetMusicTagLabel(info.m_info, playlistItem.get());
3281 CStdString CGUIInfoManager::GetPlaylistLabel(int item) const
3283 if (!g_application.IsPlaying()) return "";
3284 int iPlaylist = g_playlistPlayer.GetCurrentPlaylist();
3287 case PLAYLIST_LENGTH:
3289 CStdString strLength = "";
3290 strLength.Format("%i", g_playlistPlayer.GetPlaylist(iPlaylist).size());
3293 case PLAYLIST_POSITION:
3295 CStdString strPosition = "";
3296 strPosition.Format("%i", g_playlistPlayer.GetCurrentSong() + 1);
3299 case PLAYLIST_RANDOM:
3301 if (g_playlistPlayer.IsShuffled(iPlaylist))
3302 return g_localizeStrings.Get(590); // 590: Random
3304 return g_localizeStrings.Get(591); // 591: Off
3306 case PLAYLIST_REPEAT:
3308 PLAYLIST::REPEAT_STATE state = g_playlistPlayer.GetRepeat(iPlaylist);
3309 if (state == PLAYLIST::REPEAT_ONE)
3310 return g_localizeStrings.Get(592); // 592: One
3311 else if (state == PLAYLIST::REPEAT_ALL)
3312 return g_localizeStrings.Get(593); // 593: All
3314 return g_localizeStrings.Get(594); // 594: Off
3320 CStdString CGUIInfoManager::GetMusicLabel(int item)
3322 if (!g_application.IsPlaying() || !m_currentFile->HasMusicInfoTag()) return "";
3324 SPlayerAudioStreamInfo info;
3325 g_application.m_pPlayer->GetAudioStreamInfo(g_application.m_pPlayer->GetAudioStream(), info);
3329 case MUSICPLAYER_PLAYLISTLEN:
3331 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
3332 return GetPlaylistLabel(PLAYLIST_LENGTH);
3335 case MUSICPLAYER_PLAYLISTPOS:
3337 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
3338 return GetPlaylistLabel(PLAYLIST_POSITION);
3341 case MUSICPLAYER_BITRATE:
3343 float fTimeSpan = (float)(CTimeUtils::GetFrameTime() - m_lastMusicBitrateTime);
3344 if (fTimeSpan >= 500.0f)
3346 m_MusicBitrate = info.bitrate;
3347 m_lastMusicBitrateTime = CTimeUtils::GetFrameTime();
3349 CStdString strBitrate = "";
3350 if (m_MusicBitrate > 0)
3351 strBitrate.Format("%i", MathUtils::round_int((double)m_MusicBitrate / 1000.0));
3355 case MUSICPLAYER_CHANNELS:
3357 CStdString strChannels = "";
3358 if (info.channels > 0)
3360 strChannels.Format("%i", info.channels);
3365 case MUSICPLAYER_BITSPERSAMPLE:
3367 CStdString strBitsPerSample = "";
3368 if (g_application.m_pPlayer->GetBitsPerSample() > 0)
3370 strBitsPerSample.Format("%i", g_application.m_pPlayer->GetBitsPerSample());
3372 return strBitsPerSample;
3375 case MUSICPLAYER_SAMPLERATE:
3377 CStdString strSampleRate = "";
3378 if (g_application.m_pPlayer->GetSampleRate() > 0)
3380 strSampleRate.Format("%.5g", ((double)g_application.m_pPlayer->GetSampleRate() / 1000.0));
3382 return strSampleRate;
3385 case MUSICPLAYER_CODEC:
3387 CStdString strCodec;
3388 strCodec.Format("%s", info.audioCodecName);
3392 case MUSICPLAYER_LYRICS:
3393 return GetItemLabel(m_currentFile, AddListItemProp("lyrics"));
3395 return GetMusicTagLabel(item, m_currentFile);
3398 CStdString CGUIInfoManager::GetMusicTagLabel(int info, const CFileItem *item)
3400 if (!item->HasMusicInfoTag()) return "";
3401 const CMusicInfoTag &tag = *item->GetMusicInfoTag();
3404 case MUSICPLAYER_TITLE:
3405 if (tag.GetTitle().size()) { return tag.GetTitle(); }
3407 case MUSICPLAYER_ALBUM:
3408 if (tag.GetAlbum().size()) { return tag.GetAlbum(); }
3410 case MUSICPLAYER_ARTIST:
3411 if (tag.GetArtist().size()) { return StringUtils::Join(tag.GetArtist(), g_advancedSettings.m_musicItemSeparator); }
3413 case MUSICPLAYER_ALBUM_ARTIST:
3414 if (tag.GetAlbumArtist().size()) { return StringUtils::Join(tag.GetAlbumArtist(), g_advancedSettings.m_musicItemSeparator); }
3416 case MUSICPLAYER_YEAR:
3417 if (tag.GetYear()) { return tag.GetYearString(); }
3419 case MUSICPLAYER_GENRE:
3420 if (tag.GetGenre().size()) { return StringUtils::Join(tag.GetGenre(), g_advancedSettings.m_musicItemSeparator); }
3422 case MUSICPLAYER_LYRICS:
3423 if (tag.GetLyrics().size()) { return tag.GetLyrics(); }
3425 case MUSICPLAYER_TRACK_NUMBER:
3427 CStdString strTrack;
3428 if (tag.Loaded() && tag.GetTrackNumber() > 0)
3430 strTrack.Format("%02i", tag.GetTrackNumber());
3435 case MUSICPLAYER_DISC_NUMBER:
3436 return GetItemLabel(item, LISTITEM_DISC_NUMBER);
3437 case MUSICPLAYER_RATING:
3438 return GetItemLabel(item, LISTITEM_RATING);
3439 case MUSICPLAYER_COMMENT:
3440 return GetItemLabel(item, LISTITEM_COMMENT);
3441 case MUSICPLAYER_DURATION:
3442 return GetItemLabel(item, LISTITEM_DURATION);
3443 case MUSICPLAYER_CHANNEL_NAME:
3445 CPVRChannel* channeltag = m_currentFile->GetPVRChannelInfoTag();
3447 return channeltag->ChannelName();
3450 case MUSICPLAYER_CHANNEL_NUMBER:
3452 CPVRChannel* channeltag = m_currentFile->GetPVRChannelInfoTag();
3455 CStdString strNumber;
3456 strNumber.Format("%i", channeltag->ChannelNumber());
3461 case MUSICPLAYER_CHANNEL_GROUP:
3463 CPVRChannel* channeltag = m_currentFile->GetPVRChannelInfoTag();
3464 if (channeltag && channeltag->IsRadio())
3465 return g_PVRManager.GetPlayingGroup(true)->GroupName();
3468 case MUSICPLAYER_PLAYCOUNT:
3469 return GetItemLabel(item, LISTITEM_PLAYCOUNT);
3470 case MUSICPLAYER_LASTPLAYED:
3471 return GetItemLabel(item, LISTITEM_LASTPLAYED);
3476 CStdString CGUIInfoManager::GetVideoLabel(int item)
3478 if (!g_application.IsPlaying())
3481 if (item == VIDEOPLAYER_TITLE)
3483 if(g_application.IsPlayingVideo())
3484 return GetLabel(PLAYER_TITLE);
3486 else if (item == VIDEOPLAYER_PLAYLISTLEN)
3488 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_VIDEO)
3489 return GetPlaylistLabel(PLAYLIST_LENGTH);
3491 else if (item == VIDEOPLAYER_PLAYLISTPOS)
3493 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_VIDEO)
3494 return GetPlaylistLabel(PLAYLIST_POSITION);
3496 else if (m_currentFile->HasPVRChannelInfoTag())
3498 CPVRChannel* tag = m_currentFile->GetPVRChannelInfoTag();
3503 /* Now playing infos */
3504 case VIDEOPLAYER_ORIGINALTITLE:
3505 return tag->GetEPGNow(epgTag) ?
3507 g_guiSettings.GetBool("epg.hidenoinfoavailable") ?
3508 StringUtils::EmptyString :
3509 g_localizeStrings.Get(19055); // no information available
3510 case VIDEOPLAYER_GENRE:
3511 return tag->GetEPGNow(epgTag) ? StringUtils::Join(epgTag.Genre(), g_advancedSettings.m_videoItemSeparator) : StringUtils::EmptyString;
3512 case VIDEOPLAYER_PLOT:
3513 return tag->GetEPGNow(epgTag) ? epgTag.Plot() : StringUtils::EmptyString;
3514 case VIDEOPLAYER_PLOT_OUTLINE:
3515 return tag->GetEPGNow(epgTag) ? epgTag.PlotOutline() : StringUtils::EmptyString;
3516 case VIDEOPLAYER_STARTTIME:
3517 return tag->GetEPGNow(epgTag) ? epgTag.StartAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
3518 case VIDEOPLAYER_ENDTIME:
3519 return tag->GetEPGNow(epgTag) ? epgTag.EndAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
3521 /* Next playing infos */
3522 case VIDEOPLAYER_NEXT_TITLE:
3523 return tag->GetEPGNext(epgTag) ?
3525 g_guiSettings.GetBool("epg.hidenoinfoavailable") ?
3526 StringUtils::EmptyString :
3527 g_localizeStrings.Get(19055); // no information available
3528 case VIDEOPLAYER_NEXT_GENRE:
3529 return tag->GetEPGNext(epgTag) ? StringUtils::Join(epgTag.Genre(), g_advancedSettings.m_videoItemSeparator) : StringUtils::EmptyString;
3530 case VIDEOPLAYER_NEXT_PLOT:
3531 return tag->GetEPGNext(epgTag) ? epgTag.Plot() : StringUtils::EmptyString;
3532 case VIDEOPLAYER_NEXT_PLOT_OUTLINE:
3533 return tag->GetEPGNext(epgTag) ? epgTag.PlotOutline() : StringUtils::EmptyString;
3534 case VIDEOPLAYER_NEXT_STARTTIME:
3535 return tag->GetEPGNext(epgTag) ? epgTag.StartAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
3536 case VIDEOPLAYER_NEXT_ENDTIME:
3537 return tag->GetEPGNext(epgTag) ? epgTag.EndAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
3538 case VIDEOPLAYER_NEXT_DURATION:
3540 CStdString duration;
3541 if (tag->GetEPGNext(epgTag) && epgTag.GetDuration() > 0)
3542 duration = StringUtils::SecondsToTimeString(epgTag.GetDuration());
3546 case VIDEOPLAYER_PARENTAL_RATING:
3549 if (tag->GetEPGNow(epgTag) && epgTag.ParentalRating() > 0)
3550 rating.Format("%i", epgTag.ParentalRating());
3555 /* General channel infos */
3556 case VIDEOPLAYER_CHANNEL_NAME:
3557 return tag->ChannelName();
3558 case VIDEOPLAYER_CHANNEL_NUMBER:
3560 CStdString strNumber;
3561 strNumber.Format("%i", tag->ChannelNumber());
3564 case VIDEOPLAYER_CHANNEL_GROUP:
3566 if (tag && !tag->IsRadio())
3567 return g_PVRManager.GetPlayingGroup(false)->GroupName();
3571 else if (m_currentFile->HasVideoInfoTag())
3575 case VIDEOPLAYER_ORIGINALTITLE:
3576 return m_currentFile->GetVideoInfoTag()->m_strOriginalTitle;
3578 case VIDEOPLAYER_GENRE:
3579 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_genre, g_advancedSettings.m_videoItemSeparator);
3581 case VIDEOPLAYER_DIRECTOR:
3582 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_director, g_advancedSettings.m_videoItemSeparator);
3584 case VIDEOPLAYER_RATING:
3586 CStdString strRating;
3587 if (m_currentFile->GetVideoInfoTag()->m_fRating > 0.f)
3588 strRating.Format("%.1f", m_currentFile->GetVideoInfoTag()->m_fRating);
3592 case VIDEOPLAYER_RATING_AND_VOTES:
3594 CStdString strRatingAndVotes;
3595 if (m_currentFile->GetVideoInfoTag()->m_fRating > 0.f)
3597 if (m_currentFile->GetVideoInfoTag()->m_strVotes.IsEmpty())
3598 strRatingAndVotes.Format("%.1f", m_currentFile->GetVideoInfoTag()->m_fRating);
3600 strRatingAndVotes.Format("%.1f (%s %s)", m_currentFile->GetVideoInfoTag()->m_fRating, m_currentFile->GetVideoInfoTag()->m_strVotes, g_localizeStrings.Get(20350));
3602 return strRatingAndVotes;
3605 case VIDEOPLAYER_YEAR:
3608 if (m_currentFile->GetVideoInfoTag()->m_iYear > 0)
3609 strYear.Format("%i", m_currentFile->GetVideoInfoTag()->m_iYear);
3613 case VIDEOPLAYER_PREMIERED:
3616 if (m_currentFile->GetVideoInfoTag()->m_firstAired.IsValid())
3617 dateTime = m_currentFile->GetVideoInfoTag()->m_firstAired;
3618 else if (m_currentFile->GetVideoInfoTag()->m_premiered.IsValid())
3619 dateTime = m_currentFile->GetVideoInfoTag()->m_premiered;
3621 if (dateTime.IsValid())
3622 return dateTime.GetAsLocalizedDate();
3626 case VIDEOPLAYER_PLOT:
3627 return m_currentFile->GetVideoInfoTag()->m_strPlot;
3628 case VIDEOPLAYER_TRAILER:
3629 return m_currentFile->GetVideoInfoTag()->m_strTrailer;
3630 case VIDEOPLAYER_PLOT_OUTLINE:
3631 return m_currentFile->GetVideoInfoTag()->m_strPlotOutline;
3632 case VIDEOPLAYER_EPISODE:
3634 CStdString strEpisode;
3635 if (m_currentFile->GetVideoInfoTag()->m_iSpecialSortEpisode > 0)
3636 strEpisode.Format("S%i", m_currentFile->GetVideoInfoTag()->m_iSpecialSortEpisode);
3637 else if(m_currentFile->GetVideoInfoTag()->m_iEpisode > 0)
3638 strEpisode.Format("%i", m_currentFile->GetVideoInfoTag()->m_iEpisode);
3642 case VIDEOPLAYER_SEASON:
3644 CStdString strSeason;
3645 if (m_currentFile->GetVideoInfoTag()->m_iSpecialSortSeason > 0)
3646 strSeason.Format("%i", m_currentFile->GetVideoInfoTag()->m_iSpecialSortSeason);
3647 else if(m_currentFile->GetVideoInfoTag()->m_iSeason > 0)
3648 strSeason.Format("%i", m_currentFile->GetVideoInfoTag()->m_iSeason);
3652 case VIDEOPLAYER_TVSHOW:
3653 return m_currentFile->GetVideoInfoTag()->m_strShowTitle;
3655 case VIDEOPLAYER_STUDIO:
3656 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_studio, g_advancedSettings.m_videoItemSeparator);
3657 case VIDEOPLAYER_COUNTRY:
3658 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_country, g_advancedSettings.m_videoItemSeparator);
3659 case VIDEOPLAYER_MPAA:
3660 return m_currentFile->GetVideoInfoTag()->m_strMPAARating;
3661 case VIDEOPLAYER_TOP250:
3663 CStdString strTop250;
3664 if (m_currentFile->GetVideoInfoTag()->m_iTop250 > 0)
3665 strTop250.Format("%i", m_currentFile->GetVideoInfoTag()->m_iTop250);
3669 case VIDEOPLAYER_CAST:
3670 return m_currentFile->GetVideoInfoTag()->GetCast();
3671 case VIDEOPLAYER_CAST_AND_ROLE:
3672 return m_currentFile->GetVideoInfoTag()->GetCast(true);
3673 case VIDEOPLAYER_ARTIST:
3674 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator);
3675 case VIDEOPLAYER_ALBUM:
3676 return m_currentFile->GetVideoInfoTag()->m_strAlbum;
3677 case VIDEOPLAYER_WRITER:
3678 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_writingCredits, g_advancedSettings.m_videoItemSeparator);
3679 case VIDEOPLAYER_TAGLINE:
3680 return m_currentFile->GetVideoInfoTag()->m_strTagLine;
3681 case VIDEOPLAYER_LASTPLAYED:
3683 if (m_currentFile->GetVideoInfoTag()->m_lastPlayed.IsValid())
3684 return m_currentFile->GetVideoInfoTag()->m_lastPlayed.GetAsLocalizedDateTime();
3687 case VIDEOPLAYER_PLAYCOUNT:
3689 CStdString strPlayCount;
3690 if (m_currentFile->GetVideoInfoTag()->m_playCount > 0)
3691 strPlayCount.Format("%i", m_currentFile->GetVideoInfoTag()->m_playCount);
3692 return strPlayCount;
3699 int64_t CGUIInfoManager::GetPlayTime() const
3701 if (g_application.IsPlaying())
3703 int64_t lPTS = (int64_t)(g_application.GetTime() * 1000);
3704 if (lPTS < 0) lPTS = 0;
3710 CStdString CGUIInfoManager::GetCurrentPlayTime(TIME_FORMAT format) const
3712 if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
3713 format = TIME_FORMAT_HH_MM_SS;
3714 if (g_application.IsPlaying())
3715 return StringUtils::SecondsToTimeString((int)(GetPlayTime()/1000), format);
3719 CStdString CGUIInfoManager::GetCurrentSeekTime(TIME_FORMAT format) const
3721 if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
3722 format = TIME_FORMAT_HH_MM_SS;
3723 float time = GetTotalPlayTime() * g_application.GetSeekHandler()->GetPercent() * 0.01f;
3724 return StringUtils::SecondsToTimeString((int)time, format);
3727 int CGUIInfoManager::GetTotalPlayTime() const
3729 int iTotalTime = (int)g_application.GetTotalTime();
3730 return iTotalTime > 0 ? iTotalTime : 0;
3733 int CGUIInfoManager::GetPlayTimeRemaining() const
3735 int iReverse = GetTotalPlayTime() - (int)g_application.GetTime();
3736 return iReverse > 0 ? iReverse : 0;
3739 CStdString CGUIInfoManager::GetCurrentPlayTimeRemaining(TIME_FORMAT format) const
3741 if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
3742 format = TIME_FORMAT_HH_MM_SS;
3743 int timeRemaining = GetPlayTimeRemaining();
3744 if (timeRemaining && g_application.IsPlaying())
3745 return StringUtils::SecondsToTimeString(timeRemaining, format);
3749 void CGUIInfoManager::ResetCurrentItem()
3751 m_currentFile->Reset();
3752 m_currentMovieThumb = "";
3753 m_currentMovieDuration = "";
3756 void CGUIInfoManager::SetCurrentItem(CFileItem &item)
3761 SetCurrentSong(item);
3763 SetCurrentMovie(item);
3765 if (item.HasEPGInfoTag())
3766 *m_currentFile->GetEPGInfoTag() = *item.GetEPGInfoTag();
3767 else if (item.HasPVRChannelInfoTag())
3770 if (item.GetPVRChannelInfoTag()->GetEPGNow(tag))
3771 *m_currentFile->GetEPGInfoTag() = tag;
3775 NotifyObservers(ObservableMessageCurrentItem);
3778 void CGUIInfoManager::SetCurrentAlbumThumb(const CStdString thumbFileName)
3780 if (CFile::Exists(thumbFileName))
3781 m_currentFile->SetArt("thumb", thumbFileName);
3784 m_currentFile->SetArt("thumb", "");
3785 m_currentFile->FillInDefaultIcon();
3789 void CGUIInfoManager::SetCurrentSong(CFileItem &item)
3791 CLog::Log(LOGDEBUG,"CGUIInfoManager::SetCurrentSong(%s)",item.GetPath().c_str());
3792 *m_currentFile = item;
3794 m_currentFile->LoadMusicTag();
3795 if (m_currentFile->GetMusicInfoTag()->GetTitle().IsEmpty())
3797 // No title in tag, show filename only
3798 m_currentFile->GetMusicInfoTag()->SetTitle(CUtil::GetTitleFromPath(m_currentFile->GetPath()));
3800 m_currentFile->GetMusicInfoTag()->SetLoaded(true);
3802 // find a thumb for this file.
3803 if (m_currentFile->IsInternetStream())
3805 if (!g_application.m_strPlayListFile.IsEmpty())
3807 CLog::Log(LOGDEBUG,"Streaming media detected... using %s to find a thumb", g_application.m_strPlayListFile.c_str());
3808 CFileItem streamingItem(g_application.m_strPlayListFile,false);
3809 CMusicThumbLoader::FillThumb(streamingItem);
3810 if (streamingItem.HasArt("thumb"))
3811 m_currentFile->SetArt("thumb", streamingItem.GetArt("thumb"));
3816 CMusicThumbLoader loader;
3817 loader.LoadItem(m_currentFile);
3819 m_currentFile->FillInDefaultIcon();
3821 CMusicInfoLoader::LoadAdditionalTagInfo(m_currentFile);
3824 void CGUIInfoManager::SetCurrentMovie(CFileItem &item)
3826 CLog::Log(LOGDEBUG,"CGUIInfoManager::SetCurrentMovie(%s)",item.GetPath().c_str());
3827 *m_currentFile = item;
3829 /* also call GetMovieInfo() when a VideoInfoTag is already present or additional info won't be present in the tag */
3830 if (!m_currentFile->HasPVRChannelInfoTag())
3835 dbs.LoadVideoInfo(item.GetPath(), *m_currentFile->GetVideoInfoTag());
3840 // Find a thumb for this file.
3841 if (!item.HasArt("thumb"))
3843 CVideoThumbLoader loader;
3844 loader.LoadItem(m_currentFile);
3847 // find a thumb for this stream
3848 if (item.IsInternetStream())
3850 // case where .strm is used to start an audio stream
3851 if (g_application.IsPlayingAudio())
3853 SetCurrentSong(item);
3858 if (!g_application.m_strPlayListFile.IsEmpty())
3860 CLog::Log(LOGDEBUG,"Streaming media detected... using %s to find a thumb", g_application.m_strPlayListFile.c_str());
3861 CFileItem thumbItem(g_application.m_strPlayListFile,false);
3862 if (CVideoThumbLoader::FillThumb(thumbItem))
3863 item.SetArt("thumb", thumbItem.GetArt("thumb"));
3867 item.FillInDefaultIcon();
3868 m_currentMovieThumb = item.GetArt("thumb");
3871 string CGUIInfoManager::GetSystemHeatInfo(int info)
3873 if (CTimeUtils::GetFrameTime() - m_lastSysHeatInfoTime >= SYSHEATUPDATEINTERVAL)
3874 { // update our variables
3875 m_lastSysHeatInfoTime = CTimeUtils::GetFrameTime();
3877 g_cpuInfo.getTemperature(m_cpuTemp);
3878 m_gpuTemp = GetGPUTemperature();
3885 case SYSTEM_CPU_TEMPERATURE:
3886 return m_cpuTemp.IsValid() ? m_cpuTemp.ToString() : "?";
3888 case SYSTEM_GPU_TEMPERATURE:
3889 return m_gpuTemp.IsValid() ? m_gpuTemp.ToString() : "?";
3891 case SYSTEM_FAN_SPEED:
3892 text.Format("%i%%", m_fanSpeed * 2);
3894 case SYSTEM_CPU_USAGE:
3895 #if defined(TARGET_DARWIN) || defined(_WIN32)
3896 text.Format("%d%%", g_cpuInfo.getUsedPercentage());
3898 text.Format("%s", g_cpuInfo.GetCoresUsageString());
3905 CTemperature CGUIInfoManager::GetGPUTemperature()
3907 CStdString cmd = g_advancedSettings.m_gpuTempCmd;
3913 if (cmd.IsEmpty() || !(p = popen(cmd.c_str(), "r")))
3914 return CTemperature();
3916 ret = fscanf(p, "%d %c", &value, &scale);
3920 return CTemperature();
3922 if (scale == 'C' || scale == 'c')
3923 return CTemperature::CreateFromCelsius(value);
3924 if (scale == 'F' || scale == 'f')
3925 return CTemperature::CreateFromFahrenheit(value);
3926 return CTemperature();
3929 // Version string MUST NOT contain spaces. It is used
3930 // in the HTTP request user agent.
3931 CStdString CGUIInfoManager::GetVersion()
3935 tmp.Format("%d.%d%s Git:%s", VERSION_MAJOR, VERSION_MINOR, VERSION_TAG, GIT_REV);
3937 tmp.Format("%d.%d%s", VERSION_MAJOR, VERSION_MINOR, VERSION_TAG);
3942 CStdString CGUIInfoManager::GetBuild()
3945 tmp.Format("%s", __DATE__);
3949 void CGUIInfoManager::SetDisplayAfterSeek(unsigned int timeOut, int seekOffset)
3951 g_infoManager.m_performingSeek = false;
3954 m_AfterSeekTimeout = CTimeUtils::GetFrameTime() + timeOut;
3956 m_seekOffset = seekOffset;
3959 m_AfterSeekTimeout = 0;
3962 bool CGUIInfoManager::GetDisplayAfterSeek()
3964 if (CTimeUtils::GetFrameTime() < m_AfterSeekTimeout)
3970 void CGUIInfoManager::Clear()
3972 CSingleLock lock(m_critInfo);
3973 for (unsigned int i = 0; i < m_bools.size(); ++i)
3977 m_skinVariableStrings.clear();
3980 void CGUIInfoManager::UpdateFPS()
3983 unsigned int curTime = CTimeUtils::GetFrameTime();
3985 float fTimeSpan = (float)(curTime - m_lastFPSTime);
3986 if (fTimeSpan >= 1000.0f)
3988 fTimeSpan /= 1000.0f;
3989 m_fps = m_frameCounter / fTimeSpan;
3990 m_lastFPSTime = curTime;
3995 int CGUIInfoManager::AddListItemProp(const CStdString &str, int offset)
3997 for (int i=0; i < (int)m_listitemProperties.size(); i++)
3998 if (m_listitemProperties[i] == str)
3999 return (LISTITEM_PROPERTY_START+offset + i);
4001 if (m_listitemProperties.size() < LISTITEM_PROPERTY_END - LISTITEM_PROPERTY_START)
4003 m_listitemProperties.push_back(str);
4004 return LISTITEM_PROPERTY_START + offset + m_listitemProperties.size() - 1;
4007 CLog::Log(LOGERROR,"%s - not enough listitem property space!", __FUNCTION__);
4011 int CGUIInfoManager::AddMultiInfo(const GUIInfo &info)
4013 // check to see if we have this info already
4014 for (unsigned int i = 0; i < m_multiInfo.size(); i++)
4015 if (m_multiInfo[i] == info)
4016 return (int)i + MULTI_INFO_START;
4017 // return the new offset
4018 m_multiInfo.push_back(info);
4019 int id = (int)m_multiInfo.size() + MULTI_INFO_START - 1;
4020 if (id > MULTI_INFO_END)
4021 CLog::Log(LOGERROR, "%s - too many multiinfo bool/labels in this skin", __FUNCTION__);
4025 int CGUIInfoManager::ConditionalStringParameter(const CStdString ¶meter, bool caseSensitive /*= false*/)
4027 // check to see if we have this parameter already
4028 for (unsigned int i = 0; i < m_stringParameters.size(); i++)
4029 if (parameter.Equals(m_stringParameters[i], caseSensitive))
4031 // return the new offset
4032 m_stringParameters.push_back(parameter);
4033 return (int)m_stringParameters.size() - 1;
4036 bool CGUIInfoManager::GetItemInt(int &value, const CGUIListItem *item, int info) const
4044 if (info >= LISTITEM_PROPERTY_START && info - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size())
4045 { // grab the property
4046 CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START];
4047 CStdString val = item->GetProperty(property).asString();
4054 case LISTITEM_PROGRESS:
4057 if (item->IsFileItem())
4059 const CFileItem *pItem = (const CFileItem *)item;
4060 if (pItem && pItem->HasPVRChannelInfoTag())
4063 if (pItem->GetPVRChannelInfoTag()->GetEPGNow(epgNow))
4064 value = (int) epgNow.ProgressPercentage();
4066 else if (pItem && pItem->HasEPGInfoTag())
4068 value = (int) pItem->GetEPGInfoTag()->ProgressPercentage();
4075 case LISTITEM_PERCENT_PLAYED:
4076 if (item->IsFileItem() && ((const CFileItem *)item)->HasVideoInfoTag() && ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.IsPartWay())
4077 value = (int)(100 * ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.timeInSeconds / ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds);
4078 else if (item->IsFileItem() && ((const CFileItem *)item)->HasPVRRecordingInfoTag() && ((const CFileItem *)item)->GetPVRRecordingInfoTag()->m_resumePoint.IsPartWay())
4079 value = (int)(100 * ((const CFileItem *)item)->GetPVRRecordingInfoTag()->m_resumePoint.timeInSeconds / ((const CFileItem *)item)->GetPVRRecordingInfoTag()->m_resumePoint.totalTimeInSeconds);
4089 CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, CStdString *fallback)
4091 if (!item) return "";
4093 if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
4094 return GetSkinVariableString(info, false, item);
4096 if (info >= LISTITEM_PROPERTY_START + LISTITEM_ART_OFFSET && info - (LISTITEM_PROPERTY_START + LISTITEM_ART_OFFSET) < (int)m_listitemProperties.size())
4098 std::string art = m_listitemProperties[info - (LISTITEM_PROPERTY_START + LISTITEM_ART_OFFSET)];
4099 return item->GetArt(art);
4102 if (info >= LISTITEM_PROPERTY_START && info - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size())
4103 { // grab the property
4104 CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START];
4105 return item->GetProperty(property).asString();
4108 if (info >= LISTITEM_PICTURE_START && info <= LISTITEM_PICTURE_END && item->HasPictureInfoTag())
4109 return item->GetPictureInfoTag()->GetInfo(picture_slide_map[info - LISTITEM_PICTURE_START]);
4113 case LISTITEM_LABEL:
4114 return item->GetLabel();
4115 case LISTITEM_LABEL2:
4116 return item->GetLabel2();
4117 case LISTITEM_TITLE:
4118 if (item->HasPVRChannelInfoTag())
4121 return item->GetPVRChannelInfoTag()->GetEPGNow(epgTag) ?
4123 g_guiSettings.GetBool("epg.hidenoinfoavailable") ?
4124 StringUtils::EmptyString :
4125 g_localizeStrings.Get(19055); // no information available
4127 if (item->HasPVRRecordingInfoTag())
4128 return item->GetPVRRecordingInfoTag()->m_strTitle;
4129 if (item->HasEPGInfoTag())
4130 return item->GetEPGInfoTag()->Title();
4131 if (item->HasPVRTimerInfoTag())
4132 return item->GetPVRTimerInfoTag()->Title();
4133 if (item->HasVideoInfoTag())
4134 return item->GetVideoInfoTag()->m_strTitle;
4135 if (item->HasMusicInfoTag())
4136 return item->GetMusicInfoTag()->GetTitle();
4138 case LISTITEM_ORIGINALTITLE:
4139 if (item->HasVideoInfoTag())
4140 return item->GetVideoInfoTag()->m_strOriginalTitle;
4142 case LISTITEM_PLAYCOUNT:
4144 CStdString strPlayCount;
4145 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_playCount > 0)
4146 strPlayCount.Format("%i", item->GetVideoInfoTag()->m_playCount);
4147 if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetPlayCount() > 0)
4148 strPlayCount.Format("%i", item->GetMusicInfoTag()->GetPlayCount());
4149 return strPlayCount;
4151 case LISTITEM_LASTPLAYED:
4154 if (item->HasVideoInfoTag())
4155 dateTime = item->GetVideoInfoTag()->m_lastPlayed;
4156 else if (item->HasMusicInfoTag())
4157 dateTime = item->GetMusicInfoTag()->GetLastPlayed();
4159 if (dateTime.IsValid())
4160 return dateTime.GetAsLocalizedDate();
4163 case LISTITEM_TRACKNUMBER:
4166 if (item->HasMusicInfoTag())
4167 track.Format("%i", item->GetMusicInfoTag()->GetTrackNumber());
4171 case LISTITEM_DISC_NUMBER:
4174 if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDiscNumber() > 0)
4175 disc.Format("%i", item->GetMusicInfoTag()->GetDiscNumber());
4178 case LISTITEM_ARTIST:
4179 if (item->HasVideoInfoTag())
4180 return StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator);
4181 if (item->HasMusicInfoTag())
4182 return StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator);
4184 case LISTITEM_ALBUM_ARTIST:
4185 if (item->HasMusicInfoTag())
4186 return StringUtils::Join(item->GetMusicInfoTag()->GetAlbumArtist(), g_advancedSettings.m_musicItemSeparator);
4188 case LISTITEM_DIRECTOR:
4189 if (item->HasVideoInfoTag())
4190 return StringUtils::Join(item->GetVideoInfoTag()->m_director, g_advancedSettings.m_videoItemSeparator);
4192 case LISTITEM_ALBUM:
4193 if (item->HasVideoInfoTag())
4194 return item->GetVideoInfoTag()->m_strAlbum;
4195 if (item->HasMusicInfoTag())
4196 return item->GetMusicInfoTag()->GetAlbum();
4199 if (item->HasVideoInfoTag())
4201 CStdString strResult;
4202 if (item->GetVideoInfoTag()->m_iYear > 0)
4203 strResult.Format("%i",item->GetVideoInfoTag()->m_iYear);
4206 if (item->HasMusicInfoTag())
4207 return item->GetMusicInfoTag()->GetYearString();
4209 case LISTITEM_PREMIERED:
4210 if (item->HasVideoInfoTag())
4213 if (item->GetVideoInfoTag()->m_firstAired.IsValid())
4214 dateTime = item->GetVideoInfoTag()->m_firstAired;
4215 else if (item->GetVideoInfoTag()->m_premiered.IsValid())
4216 dateTime = item->GetVideoInfoTag()->m_premiered;
4218 if (dateTime.IsValid())
4219 return dateTime.GetAsLocalizedDate();
4223 case LISTITEM_GENRE:
4224 if (item->HasVideoInfoTag())
4225 return StringUtils::Join(item->GetVideoInfoTag()->m_genre, g_advancedSettings.m_videoItemSeparator);
4226 if (item->HasMusicInfoTag())
4227 return StringUtils::Join(item->GetMusicInfoTag()->GetGenre(), g_advancedSettings.m_musicItemSeparator);
4228 if (item->HasPVRChannelInfoTag())
4231 return item->GetPVRChannelInfoTag()->GetEPGNow(epgTag) ? StringUtils::Join(epgTag.Genre(), g_advancedSettings.m_videoItemSeparator) : StringUtils::EmptyString;
4233 if (item->HasPVRRecordingInfoTag())
4234 return StringUtils::Join(item->GetPVRRecordingInfoTag()->m_genre, g_advancedSettings.m_videoItemSeparator);
4235 if (item->HasEPGInfoTag())
4236 return StringUtils::Join(item->GetEPGInfoTag()->Genre(), g_advancedSettings.m_videoItemSeparator);
4238 case LISTITEM_FILENAME:
4239 case LISTITEM_FILE_EXTENSION:
4242 if (item->IsMusicDb() && item->HasMusicInfoTag())
4243 strFile = URIUtils::GetFileName(item->GetMusicInfoTag()->GetURL());
4244 else if (item->IsVideoDb() && item->HasVideoInfoTag())
4245 strFile = URIUtils::GetFileName(item->GetVideoInfoTag()->m_strFileNameAndPath);
4247 strFile = URIUtils::GetFileName(item->GetPath());
4249 if (info==LISTITEM_FILE_EXTENSION)
4251 CStdString strExtension = URIUtils::GetExtension(strFile);
4252 return strExtension.TrimLeft(".");
4258 if (item->HasEPGInfoTag())
4259 return item->GetEPGInfoTag()->StartAsLocalTime().GetAsLocalizedDateTime(false, false);
4260 if (item->HasPVRChannelInfoTag())
4263 return item->GetPVRChannelInfoTag()->GetEPGNow(epgTag) ? epgTag.StartAsLocalTime().GetAsLocalizedDateTime(false, false) : CDateTime::GetCurrentDateTime().GetAsLocalizedDateTime(false, false);
4265 if (item->HasPVRRecordingInfoTag())
4266 return item->GetPVRRecordingInfoTag()->RecordingTimeAsLocalTime().GetAsLocalizedDateTime(false, false);
4267 if (item->HasPVRTimerInfoTag())
4268 return item->GetPVRTimerInfoTag()->Summary();
4269 if (item->m_dateTime.IsValid())
4270 return item->m_dateTime.GetAsLocalizedDate();
4273 if (!item->m_bIsFolder || item->m_dwSize)
4274 return StringUtils::SizeToString(item->m_dwSize);
4276 case LISTITEM_RATING:
4279 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_fRating > 0.f) // movie rating
4280 rating.Format("%.1f", item->GetVideoInfoTag()->m_fRating);
4281 else if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetRating() > '0')
4282 { // song rating. Images will probably be better than numbers for this in the long run
4283 rating = item->GetMusicInfoTag()->GetRating();
4287 case LISTITEM_RATING_AND_VOTES:
4289 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_fRating > 0.f) // movie rating
4291 CStdString strRatingAndVotes;
4292 if (item->GetVideoInfoTag()->m_strVotes.IsEmpty())
4293 strRatingAndVotes.Format("%.1f", item->GetVideoInfoTag()->m_fRating);
4295 strRatingAndVotes.Format("%.1f (%s %s)", item->GetVideoInfoTag()->m_fRating, item->GetVideoInfoTag()->m_strVotes, g_localizeStrings.Get(20350));
4296 return strRatingAndVotes;
4300 case LISTITEM_PROGRAM_COUNT:
4303 count.Format("%i", item->m_iprogramCount);
4306 case LISTITEM_DURATION:
4308 CStdString duration;
4309 if (item->HasPVRChannelInfoTag())
4311 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4313 if (channel && channel->GetEPGNow(tag))
4314 return StringUtils::SecondsToTimeString(tag.GetDuration());
4315 return StringUtils::EmptyString;
4317 else if (item->HasPVRRecordingInfoTag())
4319 if (item->GetPVRRecordingInfoTag()->GetDuration() > 0)
4320 duration = StringUtils::SecondsToTimeString(item->GetPVRRecordingInfoTag()->GetDuration());
4322 else if (item->HasEPGInfoTag())
4324 if (item->GetEPGInfoTag()->GetDuration() > 0)
4325 duration = StringUtils::SecondsToTimeString(item->GetEPGInfoTag()->GetDuration());
4327 else if (item->HasVideoInfoTag())
4329 if (item->GetVideoInfoTag()->GetDuration() > 0)
4330 duration.Format("%d", item->GetVideoInfoTag()->GetDuration() / 60);
4332 else if (item->HasMusicInfoTag())
4334 if (item->GetMusicInfoTag()->GetDuration() > 0)
4335 duration = StringUtils::SecondsToTimeString(item->GetMusicInfoTag()->GetDuration());
4340 if (item->HasPVRChannelInfoTag())
4342 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4344 if (channel && channel->GetEPGNow(tag))
4346 return StringUtils::EmptyString;
4348 if (item->HasEPGInfoTag())
4349 return item->GetEPGInfoTag()->Plot();
4350 if (item->HasPVRRecordingInfoTag())
4351 return item->GetPVRRecordingInfoTag()->m_strPlot;
4352 if (item->HasVideoInfoTag())
4354 if (!(!item->GetVideoInfoTag()->m_strShowTitle.IsEmpty() && item->GetVideoInfoTag()->m_iSeason == -1)) // dont apply to tvshows
4355 if (item->GetVideoInfoTag()->m_playCount == 0 && !g_guiSettings.GetBool("videolibrary.showunwatchedplots"))
4356 return g_localizeStrings.Get(20370);
4358 return item->GetVideoInfoTag()->m_strPlot;
4361 case LISTITEM_PLOT_OUTLINE:
4362 if (item->HasPVRChannelInfoTag())
4364 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4366 if (channel && channel->GetEPGNow(tag))
4367 return tag.PlotOutline();
4368 return StringUtils::EmptyString;
4370 if (item->HasEPGInfoTag())
4371 return item->GetEPGInfoTag()->PlotOutline();
4372 if (item->HasPVRRecordingInfoTag())
4373 return item->GetPVRRecordingInfoTag()->m_strPlotOutline;
4374 if (item->HasVideoInfoTag())
4375 return item->GetVideoInfoTag()->m_strPlotOutline;
4377 case LISTITEM_EPISODE:
4378 if (item->HasVideoInfoTag())
4380 CStdString strResult;
4381 if (item->GetVideoInfoTag()->m_iSpecialSortEpisode > 0)
4382 strResult.Format("S%d",item->GetVideoInfoTag()->m_iEpisode);
4383 else if (item->GetVideoInfoTag()->m_iEpisode > 0) // if m_iEpisode = -1 there's no episode detail
4384 strResult.Format("%d",item->GetVideoInfoTag()->m_iEpisode);
4388 case LISTITEM_SEASON:
4389 if (item->HasVideoInfoTag())
4391 CStdString strResult;
4392 if (item->GetVideoInfoTag()->m_iSpecialSortSeason > 0)
4393 strResult.Format("%d",item->GetVideoInfoTag()->m_iSpecialSortSeason);
4394 else if (item->GetVideoInfoTag()->m_iSeason > 0) // if m_iSeason = -1 there's no season detail
4395 strResult.Format("%d",item->GetVideoInfoTag()->m_iSeason);
4399 case LISTITEM_TVSHOW:
4400 if (item->HasVideoInfoTag())
4401 return item->GetVideoInfoTag()->m_strShowTitle;
4403 case LISTITEM_COMMENT:
4404 if (item->HasPVRTimerInfoTag())
4405 return item->GetPVRTimerInfoTag()->GetStatus();
4406 if (item->HasMusicInfoTag())
4407 return item->GetMusicInfoTag()->GetComment();
4409 case LISTITEM_ACTUAL_ICON:
4410 return item->GetIconImage();
4413 CStdString strThumb = item->GetArt("thumb");
4414 if (strThumb.IsEmpty())
4415 strThumb = item->GetIconImage();
4417 *fallback = item->GetIconImage();
4420 case LISTITEM_OVERLAY:
4421 return item->GetOverlayImage();
4422 case LISTITEM_THUMB:
4423 return item->GetArt("thumb");
4424 case LISTITEM_FOLDERPATH:
4425 return CURL(item->GetPath()).GetWithoutUserDetails();
4426 case LISTITEM_FOLDERNAME:
4430 if (item->IsMusicDb() && item->HasMusicInfoTag())
4431 URIUtils::GetDirectory(item->GetMusicInfoTag()->GetURL(), path);
4432 else if (item->IsVideoDb() && item->HasVideoInfoTag())
4434 if( item->m_bIsFolder )
4435 path = item->GetVideoInfoTag()->m_strPath;
4437 URIUtils::GetParentPath(item->GetVideoInfoTag()->m_strFileNameAndPath, path);
4440 URIUtils::GetParentPath(item->GetPath(), path);
4441 path = CURL(path).GetWithoutUserDetails();
4442 if (info==LISTITEM_FOLDERNAME)
4444 URIUtils::RemoveSlashAtEnd(path);
4445 path=URIUtils::GetFileName(path);
4450 case LISTITEM_FILENAME_AND_PATH:
4453 if (item->IsMusicDb() && item->HasMusicInfoTag())
4454 path = item->GetMusicInfoTag()->GetURL();
4455 else if (item->IsVideoDb() && item->HasVideoInfoTag())
4456 path = item->GetVideoInfoTag()->m_strFileNameAndPath;
4458 path = item->GetPath();
4459 path = CURL(path).GetWithoutUserDetails();
4463 case LISTITEM_PICTURE_PATH:
4464 if (item->IsPicture() && (!item->IsZIP() || item->IsRAR() || item->IsCBZ() || item->IsCBR()))
4465 return item->GetPath();
4467 case LISTITEM_STUDIO:
4468 if (item->HasVideoInfoTag())
4469 return StringUtils::Join(item->GetVideoInfoTag()->m_studio, g_advancedSettings.m_videoItemSeparator);
4471 case LISTITEM_COUNTRY:
4472 if (item->HasVideoInfoTag())
4473 return StringUtils::Join(item->GetVideoInfoTag()->m_country, g_advancedSettings.m_videoItemSeparator);
4476 if (item->HasVideoInfoTag())
4477 return item->GetVideoInfoTag()->m_strMPAARating;
4480 if (item->HasVideoInfoTag())
4481 return item->GetVideoInfoTag()->GetCast();
4483 case LISTITEM_CAST_AND_ROLE:
4484 if (item->HasVideoInfoTag())
4485 return item->GetVideoInfoTag()->GetCast(true);
4487 case LISTITEM_WRITER:
4488 if (item->HasVideoInfoTag())
4489 return StringUtils::Join(item->GetVideoInfoTag()->m_writingCredits, g_advancedSettings.m_videoItemSeparator);
4491 case LISTITEM_TAGLINE:
4492 if (item->HasVideoInfoTag())
4493 return item->GetVideoInfoTag()->m_strTagLine;
4495 case LISTITEM_TRAILER:
4496 if (item->HasVideoInfoTag())
4497 return item->GetVideoInfoTag()->m_strTrailer;
4499 case LISTITEM_TOP250:
4500 if (item->HasVideoInfoTag())
4502 CStdString strResult;
4503 if (item->GetVideoInfoTag()->m_iTop250 > 0)
4504 strResult.Format("%i",item->GetVideoInfoTag()->m_iTop250);
4508 case LISTITEM_SORT_LETTER:
4511 g_charsetConverter.wToUTF8(item->GetSortLabel().Left(1).ToUpper(), letter);
4515 case LISTITEM_VIDEO_CODEC:
4516 if (item->HasVideoInfoTag())
4517 return item->GetVideoInfoTag()->m_streamDetails.GetVideoCodec();
4519 case LISTITEM_VIDEO_RESOLUTION:
4520 if (item->HasVideoInfoTag())
4521 return CStreamDetails::VideoDimsToResolutionDescription(item->GetVideoInfoTag()->m_streamDetails.GetVideoWidth(), item->GetVideoInfoTag()->m_streamDetails.GetVideoHeight());
4523 case LISTITEM_VIDEO_ASPECT:
4524 if (item->HasVideoInfoTag())
4525 return CStreamDetails::VideoAspectToAspectDescription(item->GetVideoInfoTag()->m_streamDetails.GetVideoAspect());
4527 case LISTITEM_AUDIO_CODEC:
4528 if (item->HasVideoInfoTag())
4530 return item->GetVideoInfoTag()->m_streamDetails.GetAudioCodec();
4533 case LISTITEM_AUDIO_CHANNELS:
4534 if (item->HasVideoInfoTag())
4536 CStdString strResult;
4537 int iChannels = item->GetVideoInfoTag()->m_streamDetails.GetAudioChannels();
4539 strResult.Format("%i", iChannels);
4543 case LISTITEM_AUDIO_LANGUAGE:
4544 if (item->HasVideoInfoTag())
4545 return item->GetVideoInfoTag()->m_streamDetails.GetAudioLanguage();
4547 case LISTITEM_SUBTITLE_LANGUAGE:
4548 if (item->HasVideoInfoTag())
4549 return item->GetVideoInfoTag()->m_streamDetails.GetSubtitleLanguage();
4551 case LISTITEM_STARTTIME:
4552 if (item->HasPVRChannelInfoTag())
4554 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4556 if (channel && channel->GetEPGNow(tag))
4557 return tag.StartAsLocalTime().GetAsLocalizedTime("", false);
4558 return CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
4560 if (item->HasEPGInfoTag())
4561 return item->GetEPGInfoTag()->StartAsLocalTime().GetAsLocalizedTime("", false);
4562 if (item->HasPVRTimerInfoTag())
4563 return item->GetPVRTimerInfoTag()->StartAsLocalTime().GetAsLocalizedTime("", false);
4564 if (item->HasPVRRecordingInfoTag())
4565 return item->GetPVRRecordingInfoTag()->RecordingTimeAsLocalTime().GetAsLocalizedTime("", false);
4566 if (item->m_dateTime.IsValid())
4567 return item->m_dateTime.GetAsLocalizedTime("", false);
4569 case LISTITEM_ENDTIME:
4570 if (item->HasPVRChannelInfoTag())
4572 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4574 if (channel && channel->GetEPGNow(tag))
4575 return tag.EndAsLocalTime().GetAsLocalizedTime("", false);
4576 return CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
4578 if (item->HasEPGInfoTag())
4579 return item->GetEPGInfoTag()->EndAsLocalTime().GetAsLocalizedTime("", false);
4580 if (item->HasPVRTimerInfoTag())
4581 return item->GetPVRTimerInfoTag()->EndAsLocalTime().GetAsLocalizedTime("", false);
4583 case LISTITEM_STARTDATE:
4584 if (item->HasPVRChannelInfoTag())
4586 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4588 if (channel && channel->GetEPGNow(tag))
4589 return tag.StartAsLocalTime().GetAsLocalizedDate(true);
4590 return CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true);
4592 if (item->HasEPGInfoTag())
4593 return item->GetEPGInfoTag()->StartAsLocalTime().GetAsLocalizedDate(true);
4594 if (item->HasPVRTimerInfoTag())
4595 return item->GetPVRTimerInfoTag()->StartAsLocalTime().GetAsLocalizedDate(true);
4596 if (item->HasPVRRecordingInfoTag())
4597 return item->GetPVRRecordingInfoTag()->RecordingTimeAsLocalTime().GetAsLocalizedDate(true);
4598 if (item->m_dateTime.IsValid())
4599 return item->m_dateTime.GetAsLocalizedDate(true);
4601 case LISTITEM_ENDDATE:
4602 if (item->HasPVRChannelInfoTag())
4604 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4606 if (channel && channel->GetEPGNow(tag))
4607 return tag.EndAsLocalTime().GetAsLocalizedDate(true);
4608 return CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true);
4610 if (item->HasEPGInfoTag())
4611 return item->GetEPGInfoTag()->EndAsLocalTime().GetAsLocalizedDate(true);
4612 if (item->HasPVRTimerInfoTag())
4613 return item->GetPVRTimerInfoTag()->EndAsLocalTime().GetAsLocalizedDate(true);
4615 case LISTITEM_CHANNEL_NUMBER:
4618 if (item->HasPVRChannelInfoTag())
4619 number.Format("%i", item->GetPVRChannelInfoTag()->ChannelNumber());
4620 if (item->HasEPGInfoTag() && item->GetEPGInfoTag()->HasPVRChannel())
4621 number.Format("%i", item->GetEPGInfoTag()->PVRChannelNumber());
4622 if (item->HasPVRTimerInfoTag())
4623 number.Format("%i", item->GetPVRTimerInfoTag()->ChannelNumber());
4628 case LISTITEM_CHANNEL_NAME:
4629 if (item->HasPVRChannelInfoTag())
4630 return item->GetPVRChannelInfoTag()->ChannelName();
4631 if (item->HasEPGInfoTag() && item->GetEPGInfoTag()->HasPVRChannel())
4632 return item->GetEPGInfoTag()->PVRChannelName();
4633 if (item->HasPVRRecordingInfoTag())
4634 return item->GetPVRRecordingInfoTag()->m_strChannelName;
4635 if (item->HasPVRTimerInfoTag())
4636 return item->GetPVRTimerInfoTag()->ChannelName();
4638 case LISTITEM_NEXT_STARTTIME:
4640 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4642 if (channel && channel->GetEPGNext(tag))
4643 return tag.StartAsLocalTime().GetAsLocalizedTime("", false);
4645 return CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
4646 case LISTITEM_NEXT_ENDTIME:
4648 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4650 if (channel && channel->GetEPGNext(tag))
4651 return tag.EndAsLocalTime().GetAsLocalizedTime("", false);
4653 return CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
4654 case LISTITEM_NEXT_STARTDATE:
4656 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4658 if (channel && channel->GetEPGNext(tag))
4659 return tag.StartAsLocalTime().GetAsLocalizedDate(true);
4661 return CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true);
4662 case LISTITEM_NEXT_ENDDATE:
4664 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4666 if (channel && channel->GetEPGNext(tag))
4667 return tag.EndAsLocalTime().GetAsLocalizedDate(true);
4669 return CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true);
4670 case LISTITEM_NEXT_PLOT:
4672 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4674 if (channel && channel->GetEPGNext(tag))
4677 return StringUtils::EmptyString;
4678 case LISTITEM_NEXT_PLOT_OUTLINE:
4680 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4682 if (channel && channel->GetEPGNext(tag))
4683 return tag.PlotOutline();
4685 return StringUtils::EmptyString;
4686 case LISTITEM_NEXT_DURATION:
4688 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4690 if (channel && channel->GetEPGNext(tag))
4691 return StringUtils::SecondsToTimeString(tag.GetDuration());
4693 return StringUtils::EmptyString;
4694 case LISTITEM_NEXT_GENRE:
4696 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4698 if (channel && channel->GetEPGNext(tag))
4699 return StringUtils::Join(tag.Genre(), g_advancedSettings.m_videoItemSeparator);
4701 return StringUtils::EmptyString;
4702 case LISTITEM_NEXT_TITLE:
4704 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4706 if (channel && channel->GetEPGNext(tag))
4709 return StringUtils::EmptyString;
4710 case LISTITEM_PARENTALRATING:
4713 if (item->HasEPGInfoTag() && item->GetEPGInfoTag()->ParentalRating() > 0)
4714 rating.Format("%i", item->GetEPGInfoTag()->ParentalRating());
4718 case LISTITEM_PERCENT_PLAYED:
4721 if (GetItemInt(val, item, info))
4724 str.Format("%d", val);
4729 case LISTITEM_DATE_ADDED:
4730 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_dateAdded.IsValid())
4731 return item->GetVideoInfoTag()->m_dateAdded.GetAsLocalizedDate();
4733 case LISTITEM_DBTYPE:
4734 if (item->HasVideoInfoTag())
4735 return item->GetVideoInfoTag()->m_type;
4738 if (item->HasVideoInfoTag())
4741 dbid.Format("%i", item->GetVideoInfoTag()->m_iDbId);
4744 if (item->HasMusicInfoTag())
4747 dbid.Format("%i", item->GetMusicInfoTag()->GetDatabaseId());
4755 CStdString CGUIInfoManager::GetItemImage(const CFileItem *item, int info, CStdString *fallback)
4757 if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
4758 return GetSkinVariableString(info, true, item);
4762 case LISTITEM_RATING: // old song rating format
4765 if (item->HasMusicInfoTag())
4767 rating.Format("songrating%c.png", item->GetMusicInfoTag()->GetRating());
4772 case LISTITEM_STAR_RATING:
4775 if (item->HasVideoInfoTag())
4776 { // rating for videos is assumed 0..10, so convert to 0..5
4777 rating.Format("rating%d.png", (long)((item->GetVideoInfoTag()->m_fRating * 0.5f) + 0.5f));
4779 else if (item->HasMusicInfoTag())
4781 rating.Format("rating%c.png", item->GetMusicInfoTag()->GetRating());
4786 } /* switch (info) */
4788 return GetItemLabel(item, info, fallback);
4791 bool CGUIInfoManager::GetItemBool(const CGUIListItem *item, int condition) const
4793 if (!item) return false;
4794 if (condition >= LISTITEM_PROPERTY_START && condition - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size())
4795 { // grab the property
4796 CStdString property = m_listitemProperties[condition - LISTITEM_PROPERTY_START];
4797 return item->GetProperty(property).asBoolean();
4799 else if (condition == LISTITEM_ISPLAYING)
4801 if (item->HasProperty("playlistposition"))
4802 return (int)item->GetProperty("playlisttype").asInteger() == g_playlistPlayer.GetCurrentPlaylist() && (int)item->GetProperty("playlistposition").asInteger() == g_playlistPlayer.GetCurrentSong();
4803 else if (item->IsFileItem() && !m_currentFile->GetPath().IsEmpty())
4805 if (!g_application.m_strPlayListFile.IsEmpty())
4807 //playlist file that is currently playing or the playlistitem that is currently playing.
4808 return g_application.m_strPlayListFile.Equals(((const CFileItem *)item)->GetPath()) || m_currentFile->IsSamePath((const CFileItem *)item);
4810 return m_currentFile->IsSamePath((const CFileItem *)item);
4813 else if (condition == LISTITEM_ISSELECTED)
4814 return item->IsSelected();
4815 else if (condition == LISTITEM_IS_FOLDER)
4816 return item->m_bIsFolder;
4817 else if (condition == LISTITEM_IS_RESUMABLE)
4819 if (item->IsFileItem())
4821 if (((const CFileItem *)item)->HasVideoInfoTag())
4822 return ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.timeInSeconds > 0;
4823 else if (((const CFileItem *)item)->HasPVRRecordingInfoTag())
4824 return ((const CFileItem *)item)->GetPVRRecordingInfoTag()->m_resumePoint.timeInSeconds > 0;
4827 else if (item->IsFileItem())
4829 const CFileItem *pItem = (const CFileItem *)item;
4830 if (condition == LISTITEM_ISRECORDING)
4832 if (!g_PVRManager.IsStarted())
4835 if (pItem->HasPVRChannelInfoTag())
4837 return pItem->GetPVRChannelInfoTag()->IsRecording();
4839 else if (pItem->HasPVRTimerInfoTag())
4841 const CPVRTimerInfoTag *timer = pItem->GetPVRTimerInfoTag();
4843 return timer->IsRecording();
4845 else if (pItem->HasEPGInfoTag())
4847 CFileItemPtr timer = g_PVRTimers->GetTimerForEpgTag(pItem);
4848 if (timer && timer->HasPVRTimerInfoTag())
4849 return timer->GetPVRTimerInfoTag()->IsRecording();
4852 else if (condition == LISTITEM_HASTIMER)
4854 if (pItem->HasEPGInfoTag())
4856 CFileItemPtr timer = g_PVRTimers->GetTimerForEpgTag(pItem);
4857 if (timer && timer->HasPVRTimerInfoTag())
4858 return timer->GetPVRTimerInfoTag()->IsActive();
4861 else if (condition == LISTITEM_HAS_EPG)
4863 if (pItem->HasPVRChannelInfoTag())
4866 return pItem->GetPVRChannelInfoTag()->GetEPGNow(epgTag);
4870 return pItem->HasEPGInfoTag();
4873 else if (condition == LISTITEM_ISENCRYPTED)
4875 if (pItem->HasPVRChannelInfoTag())
4877 return pItem->GetPVRChannelInfoTag()->IsEncrypted();
4879 else if (pItem->HasEPGInfoTag() && pItem->GetEPGInfoTag()->HasPVRChannel())
4881 return pItem->GetEPGInfoTag()->ChannelTag()->IsEncrypted();
4889 void CGUIInfoManager::ResetCache()
4891 // reset any animation triggers as well
4892 m_containerMoves.clear();
4896 // Called from tuxbox service thread to update current status
4897 void CGUIInfoManager::UpdateFromTuxBox()
4899 if(g_tuxbox.vVideoSubChannel.mode)
4900 m_currentFile->GetVideoInfoTag()->m_strTitle = g_tuxbox.vVideoSubChannel.current_name;
4902 // Set m_currentMovieDuration
4903 if(!g_tuxbox.sCurSrvData.current_event_duration.IsEmpty() &&
4904 !g_tuxbox.sCurSrvData.next_event_description.IsEmpty() &&
4905 !g_tuxbox.sCurSrvData.current_event_duration.Equals("-") &&
4906 !g_tuxbox.sCurSrvData.next_event_description.Equals("-"))
4908 g_tuxbox.sCurSrvData.current_event_duration.Replace("(","");
4909 g_tuxbox.sCurSrvData.current_event_duration.Replace(")","");
4911 m_currentMovieDuration.Format("%s: %s %s (%s - %s)",
4912 g_localizeStrings.Get(180),
4913 g_tuxbox.sCurSrvData.current_event_duration,
4914 g_localizeStrings.Get(12391),
4915 g_tuxbox.sCurSrvData.current_event_time,
4916 g_tuxbox.sCurSrvData.next_event_time);
4920 if (!g_tuxbox.sCurSrvData.current_event_description.IsEmpty() &&
4921 !g_tuxbox.sCurSrvData.next_event_description.IsEmpty() &&
4922 !g_tuxbox.sCurSrvData.current_event_description.Equals("-") &&
4923 !g_tuxbox.sCurSrvData.next_event_description.Equals("-"))
4926 genre.Format("%s %s - (%s: %s)",
4927 g_localizeStrings.Get(143),
4928 g_tuxbox.sCurSrvData.current_event_description,
4929 g_localizeStrings.Get(209),
4930 g_tuxbox.sCurSrvData.next_event_description);
4931 m_currentFile->GetVideoInfoTag()->m_genre = StringUtils::Split(genre, g_advancedSettings.m_videoItemSeparator);
4934 //Set m_currentMovie.m_director
4935 if (!g_tuxbox.sCurSrvData.current_event_details.Equals("-") &&
4936 !g_tuxbox.sCurSrvData.current_event_details.IsEmpty())
4938 m_currentFile->GetVideoInfoTag()->m_director = StringUtils::Split(g_tuxbox.sCurSrvData.current_event_details, g_advancedSettings.m_videoItemSeparator);
4942 CStdString CGUIInfoManager::GetPictureLabel(int info)
4944 if (info == SLIDE_FILE_NAME)
4945 return GetItemLabel(m_currentSlide, LISTITEM_FILENAME);
4946 else if (info == SLIDE_FILE_PATH)
4949 URIUtils::GetDirectory(m_currentSlide->GetPath(), path);
4950 return CURL(path).GetWithoutUserDetails();
4952 else if (info == SLIDE_FILE_SIZE)
4953 return GetItemLabel(m_currentSlide, LISTITEM_SIZE);
4954 else if (info == SLIDE_FILE_DATE)
4955 return GetItemLabel(m_currentSlide, LISTITEM_DATE);
4956 else if (info == SLIDE_INDEX)
4958 CGUIWindowSlideShow *slideshow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
4959 if (slideshow && slideshow->NumSlides())
4962 index.Format("%d/%d", slideshow->CurrentSlide(), slideshow->NumSlides());
4966 if (m_currentSlide->HasPictureInfoTag())
4967 return m_currentSlide->GetPictureInfoTag()->GetInfo(info);
4971 void CGUIInfoManager::SetCurrentSlide(CFileItem &item)
4973 if (m_currentSlide->GetPath() != item.GetPath())
4975 if (!item.GetPictureInfoTag()->Loaded()) // If picture metadata has not been loaded yet, load it now
4976 item.GetPictureInfoTag()->Load(item.GetPath());
4977 *m_currentSlide = item;
4981 void CGUIInfoManager::ResetCurrentSlide()
4983 m_currentSlide->Reset();
4986 bool CGUIInfoManager::CheckWindowCondition(CGUIWindow *window, int condition) const
4988 // check if it satisfies our condition
4989 if (!window) return false;
4990 if ((condition & WINDOW_CONDITION_HAS_LIST_ITEMS) && !window->HasListItems())
4992 if ((condition & WINDOW_CONDITION_IS_MEDIA_WINDOW) && !window->IsMediaWindow())
4997 CGUIWindow *CGUIInfoManager::GetWindowWithCondition(int contextWindow, int condition) const
4999 CGUIWindow *window = g_windowManager.GetWindow(contextWindow);
5000 if (CheckWindowCondition(window, condition))
5003 // try topmost dialog
5004 window = g_windowManager.GetWindow(g_windowManager.GetTopMostModalDialogID());
5005 if (CheckWindowCondition(window, condition))
5008 // try active window
5009 window = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
5010 if (CheckWindowCondition(window, condition))
5016 void CGUIInfoManager::SetCurrentVideoTag(const CVideoInfoTag &tag)
5018 *m_currentFile->GetVideoInfoTag() = tag;
5019 m_currentFile->m_lStartOffset = 0;
5022 void CGUIInfoManager::SetCurrentSongTag(const MUSIC_INFO::CMusicInfoTag &tag)
5024 //CLog::Log(LOGDEBUG, "Asked to SetCurrentTag");
5025 *m_currentFile->GetMusicInfoTag() = tag;
5026 m_currentFile->m_lStartOffset = 0;
5029 const CFileItem& CGUIInfoManager::GetCurrentSlide() const
5031 return *m_currentSlide;
5034 const MUSIC_INFO::CMusicInfoTag* CGUIInfoManager::GetCurrentSongTag() const
5036 if (m_currentFile->HasMusicInfoTag())
5037 return m_currentFile->GetMusicInfoTag();
5042 const CVideoInfoTag* CGUIInfoManager::GetCurrentMovieTag() const
5044 if (m_currentFile->HasVideoInfoTag())
5045 return m_currentFile->GetVideoInfoTag();
5050 void GUIInfo::SetInfoFlag(uint32_t flag)
5052 assert(flag >= (1 << 24));
5056 uint32_t GUIInfo::GetInfoFlag() const
5058 // we strip out the bottom 24 bits, where we keep data
5059 // and return the flag only
5060 return m_data1 & 0xff000000;
5063 uint32_t GUIInfo::GetData1() const
5065 // we strip out the top 8 bits, where we keep flags
5066 // and return the unflagged data
5067 return m_data1 & ((1 << 24) -1);
5070 int GUIInfo::GetData2() const
5075 void CGUIInfoManager::SetLibraryBool(int condition, bool value)
5079 case LIBRARY_HAS_MUSIC:
5080 m_libraryHasMusic = value ? 1 : 0;
5082 case LIBRARY_HAS_MOVIES:
5083 m_libraryHasMovies = value ? 1 : 0;
5085 case LIBRARY_HAS_MOVIE_SETS:
5086 m_libraryHasMovieSets = value ? 1 : 0;
5088 case LIBRARY_HAS_TVSHOWS:
5089 m_libraryHasTVShows = value ? 1 : 0;
5091 case LIBRARY_HAS_MUSICVIDEOS:
5092 m_libraryHasMusicVideos = value ? 1 : 0;
5099 void CGUIInfoManager::ResetLibraryBools()
5101 m_libraryHasMusic = -1;
5102 m_libraryHasMovies = -1;
5103 m_libraryHasTVShows = -1;
5104 m_libraryHasMusicVideos = -1;
5105 m_libraryHasMovieSets = -1;
5108 bool CGUIInfoManager::GetLibraryBool(int condition)
5110 if (condition == LIBRARY_HAS_MUSIC)
5112 if (m_libraryHasMusic < 0)
5117 m_libraryHasMusic = (db.GetSongsCount() > 0) ? 1 : 0;
5121 return m_libraryHasMusic > 0;
5123 else if (condition == LIBRARY_HAS_MOVIES)
5125 if (m_libraryHasMovies < 0)
5130 m_libraryHasMovies = db.HasContent(VIDEODB_CONTENT_MOVIES) ? 1 : 0;
5134 return m_libraryHasMovies > 0;
5136 else if (condition == LIBRARY_HAS_MOVIE_SETS)
5138 if (m_libraryHasMovieSets < 0)
5143 m_libraryHasMovieSets = db.HasSets() ? 1 : 0;
5147 return m_libraryHasMovieSets > 0;
5149 else if (condition == LIBRARY_HAS_TVSHOWS)
5151 if (m_libraryHasTVShows < 0)
5156 m_libraryHasTVShows = db.HasContent(VIDEODB_CONTENT_TVSHOWS) ? 1 : 0;
5160 return m_libraryHasTVShows > 0;
5162 else if (condition == LIBRARY_HAS_MUSICVIDEOS)
5164 if (m_libraryHasMusicVideos < 0)
5169 m_libraryHasMusicVideos = db.HasContent(VIDEODB_CONTENT_MUSICVIDEOS) ? 1 : 0;
5173 return m_libraryHasMusicVideos > 0;
5175 else if (condition == LIBRARY_HAS_VIDEO)
5177 return (GetLibraryBool(LIBRARY_HAS_MOVIES) ||
5178 GetLibraryBool(LIBRARY_HAS_TVSHOWS) ||
5179 GetLibraryBool(LIBRARY_HAS_MUSICVIDEOS));
5184 int CGUIInfoManager::RegisterSkinVariableString(const CSkinVariableString* info)
5189 CSingleLock lock(m_critInfo);
5190 m_skinVariableStrings.push_back(*info);
5192 return CONDITIONAL_LABEL_START + m_skinVariableStrings.size() - 1;
5195 int CGUIInfoManager::TranslateSkinVariableString(const CStdString& name, int context)
5197 for (vector<CSkinVariableString>::const_iterator it = m_skinVariableStrings.begin();
5198 it != m_skinVariableStrings.end(); ++it)
5200 if (it->GetName().Equals(name) && it->GetContext() == context)
5201 return it - m_skinVariableStrings.begin() + CONDITIONAL_LABEL_START;
5206 CStdString CGUIInfoManager::GetSkinVariableString(int info,
5207 bool preferImage /*= false*/,
5208 const CGUIListItem *item /*= NULL*/)
5210 info -= CONDITIONAL_LABEL_START;
5211 if (info >= 0 && info < (int)m_skinVariableStrings.size())
5212 return m_skinVariableStrings[info].GetValue(preferImage, item);
5217 bool CGUIInfoManager::ConditionsChangedValues(const std::map<int, bool>& map)
5219 for (std::map<int, bool>::const_iterator it = map.begin() ; it != map.end() ; it++)
5221 if (GetBoolValue(it->first) != it->second)
5227 bool CGUIInfoManager::GetEpgInfoTag(CEpgInfoTag& tag) const
5229 if (m_currentFile->HasEPGInfoTag())
5231 CEpgInfoTag* currentTag = m_currentFile->GetEPGInfoTag();
5232 while (currentTag && !currentTag->IsActive())
5233 currentTag = currentTag->GetNextEvent().get();